MCPcopy Create free account
hub / github.com/Snapchat/Valdi / construct

Method construct

third-party/jscore/include/JavaScriptCore/APICallbackFunction.h:76–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75template <typename T>
76EncodedJSValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec)
77{
78 VM& vm = exec->vm();
79 auto scope = DECLARE_THROW_SCOPE(vm);
80 JSObject* constructor = exec->jsCallee();
81 JSContextRef ctx = toRef(exec);
82 JSObjectRef constructorRef = toRef(constructor);
83
84 JSObjectCallAsConstructorCallback callback = jsCast<T*>(constructor)->constructCallback();
85 if (callback) {
86 size_t argumentCount = exec->argumentCount();
87 Vector<JSValueRef, 16> arguments;
88 arguments.reserveInitialCapacity(argumentCount);
89 for (size_t i = 0; i < argumentCount; ++i)
90 arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i)));
91
92 JSValueRef exception = 0;
93 JSObjectRef result;
94 {
95 JSLock::DropAllLocks dropAllLocks(exec);
96 result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception);
97 }
98 if (exception) {
99 throwException(exec, scope, toJS(exec, exception));
100 return JSValue::encode(toJS(exec, exception));
101 }
102 // result must be a valid JSValue.
103 if (!result)
104 return throwVMTypeError(exec, scope);
105 return JSValue::encode(toJS(result));
106 }
107
108 return JSValue::encode(toJS(JSObjectMake(ctx, jsCast<JSCallbackConstructor*>(constructor)->classRef(), 0)));
109}
110
111} // namespace JSC
112

Callers

nothing calls this directly

Calls 7

toRefFunction · 0.85
callbackFunction · 0.85
toJSFunction · 0.85
encodeFunction · 0.85
constructCallbackMethod · 0.45
dataMethod · 0.45
classRefMethod · 0.45

Tested by

no test coverage detected