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

Method newStringUTF8

valdi/src/valdi/jscore/JavaScriptCoreContext.cpp:374–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372
373Valdi::JSValueRef JavaScriptCoreContext::newFunction(const Valdi::Ref<Valdi::JSFunction>& callable,
374 Valdi::JSExceptionTracker& exceptionTracker) {
375 auto context = getJSGlobalContext();
376
377 auto functionData = Valdi::makeShared<JSFunctionData>(*this, callable);
378 auto object = JSObjectMake(context, getNativeFunctionClassRef(), Valdi::unsafeBridgeRetain(functionData.get()));
379
380 if (!callable->getReferenceInfo().getName().isEmpty()) {
381 static auto kName = JSStringCreateWithUTF8CString("name");
382 auto value = newStringUTF8(callable->getReferenceInfo().getName().toStringView(), exceptionTracker);
383 if (!exceptionTracker) {
384 return Valdi::JSValueRef();
385 }
386 JSObjectSetProperty(
387 context, object, kName, fromValdiJSValue(value.get()).valueRef, kJSPropertyAttributeNone, nullptr);
388 }
389
390 JSObjectSetPrototype(context, object, _functionPrototype);
391 return returnJSValueRef(object, kJSTypeObject);

Callers

nothing calls this directly

Calls 6

utf8ToUtf16Function · 0.85
toValdiJSPropertyNameFunction · 0.70
fromValdiJSPropertyNameFunction · 0.70
getMethod · 0.65
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected