corto_int16 _corto_delegate_bind(corto_function object) { /* $begin(::corto::lang::delegate::bind) */ corto_object parent = corto_parentof(object); if (corto_class_instanceof(corto_interface_o, corto_typeof(parent))) { corto_interface type = corto_interface(corto_typeof(parent)); corto_id functionName; corto_member m = NULL; /* Get function name, lookup delegate, assign function */ corto_signatureName(corto_nameof(object), functionName); if (corto_checkState(corto_type_o, CORTO_DEFINED) && (m = corto_interface_resolveMember(type, functionName)) && (m->type->kind == CORTO_COMPOSITE) && (corto_interface(m->type)->kind == CORTO_DELEGATE)) { if (corto_delegate_instanceof(corto_delegate(m->type), object)) { /* Bind instance of function is a method */ if (corto_procedure(corto_typeof(object))->kind == CORTO_METHOD) { corto_setref(&((corto_delegatedata *) CORTO_OFFSET(parent, m->offset))->instance, parent); } /* Bind procedure */ corto_setref(&((corto_delegatedata *) CORTO_OFFSET(parent, m->offset))->procedure, object); } else { /* If there is a member that corresponds to a delegate but has a non matching * signature, always report error */ corto_id id1, id2; corto_error("member '%s' of delegate type '%s' does not match signature of '%s'", corto_nameof(m), corto_fullname(m->type, id1), corto_fullname(object, id2)); goto error; } } } return 0; error: return -1; /* $end */ }
/* $CORTO_GENERATED * * web_DDPServer_Publication.c * * Only code written between the begin and end tags will be preserved * when the file is regenerated. */ #include "web.h" corto_int16 _web_DDPServer_Publication_create(web_DDPServer_Publication this, corto_object session, corto_object sub) { /* $begin(::corto::web::DDPServer::Publication::create) */ web_DDPServer_Session _session = web_DDPServer_Session(session); web_DDPServer_Subscription _sub = web_DDPServer_Subscription(sub); web_DDPServer_Collection coll = web_DDPServer_Session_getCollection(_session, corto_nameof(this->scope)); if (!coll) { goto error; } web_DDPServer_Subscription_ready(_sub); web_DDPServer_Collection_subscribe(coll, _sub->value, _sub->meta, _sub->scope); return 0; error: return -1; /* $end */ }
/* Resolve dependency, decrease refcount */ static int g_itemResolveDependency(void* o, void* userData) { g_dependency dep; corto_depresolver data; dep = o; data = userData; if (!dep->processed) { switch(dep->kind) { case CORTO_DECLARED: dep->item->declareCount--; corto_assert(dep->item->declareCount >= 0, "negative declareCount for item '%s'.", corto_nameof(dep->item->o)); if (!dep->item->declareCount) { corto_llInsert(data->toPrint, dep->item); } break; case CORTO_DEFINED: dep->item->defineCount--; corto_assert(dep->item->defineCount >= 0, "negative defineCount for item '%s'.", corto_nameof(dep->item->o)); if (!dep->item->defineCount) { corto_llInsert(data->toPrint, dep->item); } break; } } dep->processed = TRUE; return 1; }