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

Method getValueType

valdi/src/valdi/quickjs/QuickJSJavaScriptContext.cpp:921–966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919 auto ret = JS_DefineProperty(_context,
920 fromValdiJSValue(object),
921 fromValdiJSPropertyName(propertyName),
922 propertyValue,
923 JS_UNDEFINED,
924 JS_UNDEFINED,
925 JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE | JS_PROP_HAS_VALUE |
926 JS_PROP_HAS_CONFIGURABLE | JS_PROP_HAS_WRITABLE | JS_PROP_THROW);
927 JS_FreeValue(_context, propertyValue);
928 checkCall(exceptionTracker, ret);
929}
930
931void QuickJSJavaScriptContext::setObjectProperty(const Valdi::JSValue& object,
932 const Valdi::JSValue& propertyName,
933 const Valdi::JSValue& propertyValue,
934 bool enumerable,
935 Valdi::JSExceptionTracker& exceptionTracker) {
936 auto guard = _threadAccessChecker.guard();
937 auto atom = JS_ValueToAtom(_context, fromValdiJSValue(propertyName));
938 if (atom == JS_ATOM_NULL) {
939 setExceptionToTracker(exceptionTracker);
940 return;
941 }
942
943 setObjectProperty(object, toValdiJSPropertyName(atom), propertyValue, enumerable, exceptionTracker);
944
945 JS_FreeAtom(_context, atom);
946}
947
948void QuickJSJavaScriptContext::setObjectPropertyIndex(const Valdi::JSValue& object,
949 size_t index,
950 const Valdi::JSValue& value,
951 Valdi::JSExceptionTracker& exceptionTracker) {
952 auto guard = _threadAccessChecker.guard();
953 // JS_SetProperty() automatically releases the given value.
954 auto retainedJsValue = JS_DupValue(_context, fromValdiJSValue(value));
955 checkCall(exceptionTracker,
956 JS_SetPropertyUint32(_context, fromValdiJSValue(object), static_cast<uint32_t>(index), retainedJsValue));
957}
958
959Valdi::JSValueRef QuickJSJavaScriptContext::callObjectAsFunction(const Valdi::JSValue& object,
960 Valdi::JSFunctionCallContext& callContext) {
961 auto guard = _threadAccessChecker.guard();
962 JSValue argv[callContext.getParameterSize()];
963 for (size_t i = 0; i < callContext.getParameterSize(); i++) {
964 argv[i] = fromValdiJSValue(callContext.getParameter(i));
965 }
966
967 return checkCallAndGetValue(callContext.getExceptionTracker(),
968 JS_Call(_context,
969 fromValdiJSValue(object),

Callers

nothing calls this directly

Calls 11

JS_IsUndefinedFunction · 0.85
JS_IsNullFunction · 0.85
JS_IsStringFunction · 0.85
JS_IsNumberFunction · 0.85
JS_IsBoolFunction · 0.85
getWrappedObjectClassDefFunction · 0.85
JS_IsSymbolFunction · 0.85
guardMethod · 0.80
fromValdiJSValueFunction · 0.70
getMethod · 0.65
emptyMethod · 0.45

Tested by

no test coverage detected