MCPcopy
hub / github.com/putyy/res-downloader / __embind_register_class_function

Function __embind_register_class_function

frontend/src/assets/js/decrypt.js:3131–3192  ·  view source on GitHub ↗
(
      rawClassType,
      methodName,
      argCount,
      rawArgTypesAddr, // [ReturnType, ThisType, Args...]
      invokerSignature,
      rawInvoker,
      context,
      isPureVirtual
    )

Source from the content-addressed store, hash-verified

3129 return invokerFunction;
3130 }
3131 function __embind_register_class_function(
3132 rawClassType,
3133 methodName,
3134 argCount,
3135 rawArgTypesAddr, // [ReturnType, ThisType, Args...]
3136 invokerSignature,
3137 rawInvoker,
3138 context,
3139 isPureVirtual
3140 ) {
3141 var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
3142 methodName = readLatin1String(methodName);
3143 rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
3144
3145 whenDependentTypesAreResolved([], [rawClassType], function(classType) {
3146 classType = classType[0];
3147 var humanName = classType.name + '.' + methodName;
3148
3149 if (methodName.startsWith("@@")) {
3150 methodName = Symbol[methodName.substring(2)];
3151 }
3152
3153 if (isPureVirtual) {
3154 classType.registeredClass.pureVirtualFunctions.push(methodName);
3155 }
3156
3157 function unboundTypesHandler() {
3158 throwUnboundTypeError('Cannot call ' + humanName + ' due to unbound types', rawArgTypes);
3159 }
3160
3161 var proto = classType.registeredClass.instancePrototype;
3162 var method = proto[methodName];
3163 if (undefined === method || (undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2)) {
3164 // This is the first overload to be registered, OR we are replacing a function in the base class with a function in the derived class.
3165 unboundTypesHandler.argCount = argCount - 2;
3166 unboundTypesHandler.className = classType.name;
3167 proto[methodName] = unboundTypesHandler;
3168 } else {
3169 // There was an existing function with the same name registered. Set up a function overload routing table.
3170 ensureOverloadTable(proto, methodName, humanName);
3171 proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
3172 }
3173
3174 whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
3175
3176 var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context);
3177
3178 // Replace the initial unbound-handler-stub function with the appropriate member function, now that all types
3179 // are resolved. If multiple overloads are registered for this function, the function goes into an overload table.
3180 if (undefined === proto[methodName].overloadTable) {
3181 // Set argCount in case an overload is registered later
3182 memberFunction.argCount = argCount - 2;
3183 proto[methodName] = memberFunction;
3184 } else {
3185 proto[methodName].overloadTable[argCount - 2] = memberFunction;
3186 }
3187
3188 return [];

Callers

nothing calls this directly

Calls 6

heap32VectorToArrayFunction · 0.85
readLatin1StringFunction · 0.85
embind__requireFunctionFunction · 0.85
ensureOverloadTableFunction · 0.85
craftInvokerFunctionFunction · 0.85

Tested by

no test coverage detected