| 903 | template <class Base, class Prototype, class Instance> |
| 904 | template <typename... Args> |
| 905 | JSObject* BoxedInstance<Base, Prototype, Instance>::new_for_c_struct_impl( |
| 906 | JSContext* cx, const BoxedInfo& info, void* gboxed, Args... args) { |
| 907 | if (gboxed == nullptr) |
| 908 | return nullptr; |
| 909 | |
| 910 | gjs_debug_marshal(GJS_DEBUG_GBOXED, "Wrapping struct %s %p with JSObject", |
| 911 | info.name(), gboxed); |
| 912 | |
| 913 | JS::RootedObject obj(cx, gjs_new_object_with_generic_prototype(cx, info)); |
| 914 | if (!obj) |
| 915 | return nullptr; |
| 916 | |
| 917 | BoxedInstance* priv = BoxedInstance::new_for_js_object(cx, obj); |
| 918 | if (!priv) |
| 919 | return nullptr; |
| 920 | |
| 921 | if (!priv->init_from_c_struct(cx, gboxed, std::forward<Args>(args)...)) |
| 922 | return nullptr; |
| 923 | |
| 924 | priv->debug_lifecycle("Adding associated memory (new_for_c_struct_impl)"); |
| 925 | priv->to_instance()->add_associated_memory(obj); |
| 926 | return obj; |
| 927 | } |
| 928 | |
| 929 | /** |
| 930 | * BoxedInstance::init_from_c_struct: |
nothing calls this directly
no test coverage detected