| 373 | auto guard = _threadAccessChecker.guard(); |
| 374 | JSAtom atom = JS_NewAtomLen(_context, str.data(), str.size()); |
| 375 | return Valdi::JSPropertyNameRef(this, toValdiJSPropertyName(atom), true); |
| 376 | } |
| 377 | |
| 378 | Valdi::StringBox QuickJSJavaScriptContext::propertyNameToString(const Valdi::JSPropertyName& propertyName) { |
| 379 | auto guard = _threadAccessChecker.guard(); |
| 380 | const auto* cString = JS_AtomToCString(_context, fromValdiJSPropertyName(propertyName)); |
| 381 | if (cString == nullptr) { |
| 382 | return Valdi::StringBox(); |
| 383 | } |
| 384 | |
| 385 | auto convertedString = Valdi::StringCache::makeStringFromCLiteral(cString); |
| 386 | |
| 387 | JS_FreeCString(_context, cString); |
| 388 | |
| 389 | return convertedString; |
| 390 | } |
| 391 | |
| 392 | Valdi::JSValueRef QuickJSJavaScriptContext::newObject(Valdi::JSExceptionTracker& exceptionTracker) { |
| 393 | auto guard = _threadAccessChecker.guard(); |
| 394 | return checkCallAndGetValue(exceptionTracker, JS_NewObject(_context)); |
| 395 | } |
| 396 | |
| 397 | Valdi::JSValueRef QuickJSJavaScriptContext::newFunction(const Valdi::Ref<Valdi::JSFunction>& callable, |
| 398 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 399 | auto guard = _threadAccessChecker.guard(); |
| 400 | // TODO(simon): Use functionName |
| 401 | |
| 402 | auto functionObject = |
| 403 | checkCallAndGetValue(exceptionTracker, JS_NewObjectProtoClass(_context, _functionPrototype, _functionClassID)); |
| 404 | if (!exceptionTracker) { |
| 405 | return Valdi::JSValueRef(); |
| 406 | } |
| 407 | |
| 408 | setObjectCallable(fromValdiJSValue(functionObject.get()), callable); |
| 409 |
nothing calls this directly
no test coverage detected