| 879 | // JS_SetProperty() automatically releases the given value. |
| 880 | auto retainedJsValue = JS_DupValue(_context, fromValdiJSValue(propertyValue)); |
| 881 | |
| 882 | if (VALDI_LIKELY(enumerable)) { |
| 883 | checkCall(exceptionTracker, |
| 884 | JS_SetPropertyStr(_context, fromValdiJSValue(object), propertyName.data(), retainedJsValue)); |
| 885 | } else { |
| 886 | auto convertedPropertyName = newPropertyName(propertyName); |
| 887 | setObjectPropertyNonEumerable(object, convertedPropertyName.get(), retainedJsValue, exceptionTracker); |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | void QuickJSJavaScriptContext::setObjectProperty(const Valdi::JSValue& object, |
| 892 | const Valdi::JSPropertyName& propertyName, |
| 893 | const Valdi::JSValue& propertyValue, |
| 894 | bool enumerable, |
| 895 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 896 | auto guard = _threadAccessChecker.guard(); |
| 897 | // JS_SetProperty() automatically releases the given value. |
| 898 | auto retainedJsValue = JS_DupValue(_context, fromValdiJSValue(propertyValue)); |
| 899 | |
| 900 | if (VALDI_LIKELY(enumerable)) { |
| 901 | checkCall( |
| 902 | exceptionTracker, |
| 903 | JS_SetProperty(_context, fromValdiJSValue(object), fromValdiJSPropertyName(propertyName), retainedJsValue)); |
| 904 | } else { |
| 905 | setObjectPropertyNonEumerable(object, propertyName, retainedJsValue, exceptionTracker); |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | void QuickJSJavaScriptContext::setObjectPropertyNonEumerable(const Valdi::JSValue& object, |
| 910 | const Valdi::JSPropertyName& propertyName, |
| 911 | const JSValue& propertyValue, |
| 912 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 913 | auto ret = JS_DefineProperty(_context, |
| 914 | fromValdiJSValue(object), |
| 915 | fromValdiJSPropertyName(propertyName), |
| 916 | propertyValue, |
| 917 | JS_UNDEFINED, |
| 918 | JS_UNDEFINED, |
| 919 | JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE | JS_PROP_HAS_VALUE | |
| 920 | JS_PROP_HAS_CONFIGURABLE | JS_PROP_HAS_WRITABLE | JS_PROP_THROW); |
| 921 | JS_FreeValue(_context, propertyValue); |
| 922 | checkCall(exceptionTracker, ret); |
nothing calls this directly
no test coverage detected