bool setter_method::invoke(QObject *on, QObject *parameter) const { assert(!is_empty()); assert(on != nullptr); assert(implements(type{on->metaObject()}, _object_type)); assert(parameter != nullptr); assert(!type{parameter->metaObject()}.is_empty()); assert(implements(type{parameter->metaObject()}, _parameter_type)); return _meta_method.invoke(on, Q_ARG(QObject *, parameter)); }
void ComponentExecutor:: implements (Type& e) { implements_pre (e); implements (e, edge_traverser ()); implements_post (e); }
// Qualifiers are known to be appropriate for 'class' void Parser::classDefinition(int /*flags*/, Qualifier* qual) { // FIXME: pick up the methods plus all other flags somehow, these are available from the binding ribs // Maybe time to package them up conveniently (FunctionDefinition needs it too). eat(T_Class); Str* name = identifier(); Str* extends = NULL; SeqBuilder<Str*> implements(allocator); if (match(T_Extends)) { extends = identifier(); } if (match(T_Implements)) { do { implements.addAtEnd(identifier()); } while (match(T_Comma)); } eat(T_LeftBrace); pushBindingRib(RIB_Class); pushBindingRib(RIB_Instance); Seq<Stmt*>* instance_init = NULL; Seq<Stmt*>* class_init = directives(SFLAG_Class, &instance_init); popBindingRib(); popBindingRib(); eat(T_RightBrace); addClass(ALLOC(ClassDefn, (qual, name, extends, implements.get(), class_init, instance_init))); }
dsk_err_t remote_close(DSK_DRIVER *self) { dsk_err_t err; RPCFUNC function; if (self == NULL || self->dr_remote == NULL) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; /* Update the comment (if any) */ if (implements(self, RPC_DSK_SETCOMMENT)) { char *cmt; err = dsk_get_comment(self, &cmt); if (!err) dsk_r_set_comment(self, function, self->dr_remote->rd_handle, cmt); } /* Close the file */ dsk_r_close(self, function, self->dr_remote->rd_handle); /* Close the connection */ err = (*self->dr_remote->rd_class->rc_close)(self); if (self->dr_remote->rd_functions) dsk_free(self->dr_remote->rd_functions); if (self->dr_remote->rd_name) dsk_free(self->dr_remote->rd_name); dsk_free(self->dr_remote); return err; }
// ComponentExecutor // // void ComponentExecutor:: traverse (Type& e) { pre (e); name (e); implements (e); post (e); }
bool action_method::invoke(QObject *on) const { assert(!is_empty()); assert(on != nullptr); assert(implements(type{on->metaObject()}, _object_type)); return _meta_method.invoke(on); }
implemented_by::implemented_by(type interface_type, type implementation_type) : _interface_type{std::move(interface_type)}, _implementation_type{std::move(implementation_type)} { assert(!_interface_type.is_empty()); assert(!_implementation_type.is_empty()); assert(implements(_implementation_type, _interface_type)); }
// HomeExecutor // // void HomeExecutor:: traverse (Type& e) { pre (e); name (e); implements (e); manages (e); post (e); }
dsk_err_t remote_getgeom(DSK_DRIVER *self, DSK_GEOMETRY *geom) { RPCFUNC function; if (!self || !geom || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_GETGEOM)) return DSK_ERR_NOTIMPL; return dsk_r_getgeom(self, function, self->dr_remote->rd_handle, geom); }
/* List driver-specific options */ dsk_err_t remote_option_enum(DSK_DRIVER *self, int idx, char **optname) { RPCFUNC function; if (!self || !optname) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_OPTION_ENUM)) return DSK_ERR_NOTIMPL; return dsk_r_option_enum(self, function, self->dr_remote->rd_handle, idx, optname); }
dsk_err_t remote_status(DSK_DRIVER *self, const DSK_GEOMETRY *geom, dsk_phead_t head, unsigned char *result) { RPCFUNC function; if (!self || !geom || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_DRIVE_STATUS)) return DSK_ERR_NOTIMPL; return dsk_r_drive_status(self, function, self->dr_remote->rd_handle, geom, head, result); }
/* Read raw track, including sector headers */ dsk_err_t remote_rtread(DSK_DRIVER *self, const DSK_GEOMETRY *geom, void *buf, dsk_pcyl_t cylinder, dsk_phead_t head, int reserved, size_t *bufsize) { RPCFUNC function; if (!self || !geom || !buf) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_RTREAD)) return DSK_ERR_NOTIMPL; return dsk_r_rtread(self, function, self->dr_remote->rd_handle, geom, buf, cylinder, head, reserved, bufsize); }
dsk_err_t remote_trackids(DSK_DRIVER *self, const DSK_GEOMETRY *geom, dsk_pcyl_t cylinder, dsk_phead_t head, dsk_psect_t *count, DSK_FORMAT **result) { RPCFUNC function; if (!self || !geom || !count || !result) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_TRACKIDS)) return DSK_ERR_NOTIMPL; return dsk_r_trackids(self, function, self->dr_remote->rd_handle, geom, cylinder, head, count, result); }
dsk_err_t remote_xseek(DSK_DRIVER *self, const DSK_GEOMETRY *geom, dsk_pcyl_t cylinder, dsk_phead_t head) { RPCFUNC function; if (!self || !geom || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_PSEEK)) return DSK_ERR_NOTIMPL; return dsk_r_pseek(self, function, self->dr_remote->rd_handle, geom, cylinder, head); }
dsk_err_t remote_secid(DSK_DRIVER *self, const DSK_GEOMETRY *geom, dsk_pcyl_t cylinder, dsk_phead_t head, DSK_FORMAT *result) { RPCFUNC function; if (!self || !geom || !result || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_PSECID)) return DSK_ERR_NOTIMPL; return dsk_r_secid(self, function, self->dr_remote->rd_handle, geom, cylinder, head, result); }
dsk_err_t remote_format(DSK_DRIVER *self, DSK_GEOMETRY *geom, dsk_pcyl_t cylinder, dsk_phead_t head, const DSK_FORMAT *format, unsigned char filler) { RPCFUNC function; if (!self || !geom || !format || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_PFORMAT)) return DSK_ERR_NOTIMPL; return dsk_r_format(self, function, self->dr_remote->rd_handle, geom, cylinder, head, format, filler); }
dsk_err_t remote_write(DSK_DRIVER *self, const DSK_GEOMETRY *geom, const void *buf, dsk_pcyl_t cylinder, dsk_phead_t head, dsk_psect_t sector) { RPCFUNC function; if (!self || !geom || !buf || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_PWRITE)) return DSK_ERR_NOTIMPL; return dsk_r_write(self, function, self->dr_remote->rd_handle, geom, buf, cylinder, head, sector); }
dsk_err_t remote_xtread(DSK_DRIVER *self, const DSK_GEOMETRY *geom, void *buf, dsk_pcyl_t cylinder, dsk_phead_t head, dsk_pcyl_t cyl_expected, dsk_phead_t head_expected) { RPCFUNC function; if (!self || !geom || !buf || !self->dr_remote) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!implements(self, RPC_DSK_XTREAD)) return DSK_ERR_NOTIMPL; return dsk_r_xtread(self, function, self->dr_remote->rd_handle, geom, buf, cylinder, head, cyl_expected, head_expected); }
/* Get a driver-specific option */ dsk_err_t remote_option_get(DSK_DRIVER *self, const char *optname, int *value) { RPCFUNC function; if (!self || !optname || !value) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; if (!strcmp(optname, "REMOTE:TESTING")) { *value = self->dr_remote->rd_testing; return DSK_ERR_OK; } if (!implements(self, RPC_DSK_OPTION_GET)) return DSK_ERR_NOTIMPL; return dsk_r_option_get(self, function, self->dr_remote->rd_handle, optname, value); }
shared_ptr<NameIO> NameIO::New(const Interface &iface, const shared_ptr<CipherV1> &cipher) { shared_ptr<NameIO> result; if (gNameIOMap) { NameIOMap_t::const_iterator it; NameIOMap_t::const_iterator end = gNameIOMap->end(); for (it = gNameIOMap->begin(); it != end; ++it) { if (implements(it->second.iface, iface)) { Constructor fn = it->second.constructor; result = (*fn)(iface, cipher); break; } } } return result; }
/* Set a driver-specific option */ dsk_err_t remote_option_set(DSK_DRIVER *self, const char *optname, int value) { RPCFUNC function; if (!self || !optname) return DSK_ERR_BADPTR; function = self->dr_remote->rd_class->rc_call; /* We also support this option, which does not show up in dsk_option_enum * (because it would be quite tricky to get right) */ if (!strcmp(optname, "REMOTE:TESTING")) { self->dr_remote->rd_testing = value; return DSK_ERR_OK; } if (!implements(self, RPC_DSK_OPTION_SET)) return DSK_ERR_NOTIMPL; return dsk_r_option_set(self, function, self->dr_remote->rd_handle, optname, value); }
/* * type check switch statement */ void typecheckswitch(Node *n) { int top, lno, ptr; char *nilonly; Type *t, *badtype, *missing, *have; NodeList *l, *ll; Node *ncase, *nvar; Node *def; lno = lineno; typechecklist(n->ninit, Etop); nilonly = nil; if(n->ntest != N && n->ntest->op == OTYPESW) { // type switch top = Etype; typecheck(&n->ntest->right, Erv); t = n->ntest->right->type; if(t != T && t->etype != TINTER) yyerror("cannot type switch on non-interface value %lN", n->ntest->right); } else { // value switch top = Erv; if(n->ntest) { typecheck(&n->ntest, Erv); defaultlit(&n->ntest, T); t = n->ntest->type; } else t = types[TBOOL]; if(t) { if(!okforeq[t->etype]) yyerror("cannot switch on %lN", n->ntest); else if(t->etype == TARRAY && !isfixedarray(t)) nilonly = "slice"; else if(t->etype == TARRAY && isfixedarray(t) && algtype1(t, nil) == ANOEQ) yyerror("cannot switch on %lN", n->ntest); else if(t->etype == TSTRUCT && algtype1(t, &badtype) == ANOEQ) yyerror("cannot switch on %lN (struct containing %T cannot be compared)", n->ntest, badtype); else if(t->etype == TFUNC) nilonly = "func"; else if(t->etype == TMAP) nilonly = "map"; } } n->type = t; def = N; for(l=n->list; l; l=l->next) { ncase = l->n; setlineno(n); if(ncase->list == nil) { // default if(def != N) yyerror("multiple defaults in switch (first at %L)", def->lineno); else def = ncase; } else { for(ll=ncase->list; ll; ll=ll->next) { setlineno(ll->n); typecheck(&ll->n, Erv | Etype); if(ll->n->type == T || t == T) continue; setlineno(ncase); switch(top) { case Erv: // expression switch defaultlit(&ll->n, t); if(ll->n->op == OTYPE) yyerror("type %T is not an expression", ll->n->type); else if(ll->n->type != T && !assignop(ll->n->type, t, nil) && !assignop(t, ll->n->type, nil)) { if(n->ntest) yyerror("invalid case %N in switch on %N (mismatched types %T and %T)", ll->n, n->ntest, ll->n->type, t); else yyerror("invalid case %N in switch (mismatched types %T and bool)", ll->n, ll->n->type); } else if(nilonly && !isconst(ll->n, CTNIL)) { yyerror("invalid case %N in switch (can only compare %s %N to nil)", ll->n, nilonly, n->ntest); } break; case Etype: // type switch if(ll->n->op == OLITERAL && istype(ll->n->type, TNIL)) { ; } else if(ll->n->op != OTYPE && ll->n->type != T) { // should this be ||? yyerror("%lN is not a type", ll->n); // reset to original type ll->n = n->ntest->right; } else if(ll->n->type->etype != TINTER && t->etype == TINTER && !implements(ll->n->type, t, &missing, &have, &ptr)) { if(have && !missing->broke && !have->broke) yyerror("impossible type switch case: %lN cannot have dynamic type %T" " (wrong type for %S method)\n\thave %S%hT\n\twant %S%hT", n->ntest->right, ll->n->type, missing->sym, have->sym, have->type, missing->sym, missing->type); else if(!missing->broke) yyerror("impossible type switch case: %lN cannot have dynamic type %T" " (missing %S method)", n->ntest->right, ll->n->type, missing->sym); } break; } } } if(top == Etype && n->type != T) { ll = ncase->list; nvar = ncase->nname; if(nvar != N) { if(ll && ll->next == nil && ll->n->type != T && !istype(ll->n->type, TNIL)) { // single entry type switch nvar->ntype = typenod(ll->n->type); } else { // multiple entry type switch or default nvar->ntype = typenod(n->type); } } } typechecklist(ncase->nbody, Etop); } lineno = lno; }