bool _corto_delegate_compatible( corto_delegate _this, corto_type type) { static corto_uint32 _methodId; corto_method _method; bool _result; corto_interface _abstract; _abstract = corto_interface(corto_typeof(_this)); /* Determine methodId once, then cache it for subsequent calls. */ if (!_methodId) { _methodId = corto_interface_resolveMethodId(_abstract, "compatible(type type)"); } corto_assert(_methodId, "virtual 'compatible(type type)' not found in '%s'%s%s", corto_fullpath(NULL, _abstract), corto_lasterr() ? ": " : "", corto_lasterr() ? corto_lasterr() : ""); /* Lookup method-object. */ _method = corto_interface_resolveMethodById(_abstract, _methodId); corto_assert(_method != NULL, "unresolved method '%s::compatible(type type)@%d'", corto_idof(_this), _methodId); if (corto_function(_method)->kind == CORTO_PROCEDURE_CDECL) { _result = ((bool ___ (*)(corto_object, corto_type))((corto_function)_method)->fptr)(_this, type); } else { corto_call(corto_function(_method), &_result, _this, type); } return _result; }
/* Create a class that mounts fibonacci numbers in corto */ corto_class createFiboClass(void) { corto_class FiboClass = corto_declareChild(root_o, "FiboConnector", corto_class_o); if (!FiboClass) { goto error; } /* Inherit from the corto mount class */ corto_setref(&corto_interface(FiboClass)->base, corto_mount_o); /* Create onNotify method (called when the mount receives an update) */ corto_method onRequestMethod = corto_declareChild( FiboClass, "onRequest(core/request request)", corto_method_o); if (!onRequestMethod) { goto error; } corto_function(onRequestMethod)->kind = CORTO_PROCEDURE_CDECL; corto_function(onRequestMethod)->fptr = (corto_word)onRequest; if (corto_define(onRequestMethod)) { goto error; } /* Finalize class */ if (corto_define(FiboClass)) { goto error; } return FiboClass; error: return NULL; }
int corto_routerimpl_countArgs(corto_object o, void *userData) { if (corto_instanceof(corto_route_o, o)) { if (corto_routerimpl(userData)->maxArgs < corto_function(o)->parameters.length) { corto_routerimpl(userData)->maxArgs = corto_function(o)->parameters.length; } } return 1; }
static corto_string doc_parse(corto_string input) { corto_string result = NULL; corto_function f = corto_function(corto_resolve(NULL, "md::parse")); if (corto_checkState(f, CORTO_DEFINED)) { corto_call(f, &result, input); } return result; }