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

Method callObjectAsConstructor

valdi/src/valdi/jscore/JavaScriptCoreContext.cpp:789–805  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

787 }
788 auto constructorData = getAttachedNativeClassFunctionData(classObject);
789 if (constructorData == nullptr) {
790 exceptionTracker.onError("Value is not a native class");
791 return Valdi::JSValueRef();
792 }
793 JSValueRef exception = nullptr;
794 auto prototypeValue = JSObjectGetProperty(
795 getJSGlobalContext(), classObject, fromValdiJSPropertyName(_prototypePropertyName.get()), &exception);
796 if (exception != nullptr) {
797 storeException(exceptionTracker, exception);
798 return Valdi::JSValueRef();
799 }
800 auto prototypeObject = JSValueToObject(getJSGlobalContext(), prototypeValue, &exception);
801 if (exception != nullptr) {
802 storeException(exceptionTracker, exception);
803 return Valdi::JSValueRef();
804 }
805 auto instanceData = Valdi::makeShared<Valdi::JSNativeClassInstanceData>(constructorData->nativeClass, opaque);
806 auto object =
807 JSObjectMake(getJSGlobalContext(), getWrappedObjectClassRef(), Valdi::unsafeBridgeRetain(instanceData.get()));
808 JSObjectSetPrototype(getJSGlobalContext(), object, prototypeObject);

Callers

nothing calls this directly

Calls 4

asObjectRefOrThrowMethod · 0.80
getParameterSizeMethod · 0.80
getParameterMethod · 0.80
fromValdiJSValueFunction · 0.70

Tested by

no test coverage detected