BindPropertyToObject - Bind a data property to a JavaScript object This creates real data properties using JS_DefinePropertyValueStr
| 763 | // BindPropertyToObject - Bind a data property to a JavaScript object |
| 764 | // This creates real data properties using JS_DefinePropertyValueStr |
| 765 | JSValue BindPropertyToObject(JSContext *ctx, JSValue obj, const PropertyEntry *property) { |
| 766 | // Duplicate the value to ensure proper reference counting |
| 767 | // JS_DefinePropertyValueStr takes ownership of the value |
| 768 | JSValue property_value = JS_DupValue(ctx, property->value); |
| 769 | |
| 770 | // Define the data property using QuickJS API |
| 771 | // This creates a real data property, not an accessor property |
| 772 | int result = JS_DefinePropertyValueStr(ctx, obj, property->name, |
| 773 | property_value, property->flags); |
| 774 | |
| 775 | if (result < 0) { |
| 776 | // If define failed, we need to free the duplicated value |
| 777 | JS_FreeValue(ctx, property_value); |
| 778 | return JS_ThrowInternalError(ctx, "failed to bind property: %s", property->name); |
| 779 | } |
| 780 | |
| 781 | // Success: property_value ownership has been transferred to QuickJS |
| 782 | return JS_UNDEFINED; |
| 783 | } |
| 784 | |
| 785 | |
| 786 |
no outgoing calls
no test coverage detected