MCPcopy Create free account
hub / github.com/GNOME/gjs / new_for_c_struct_impl

Method new_for_c_struct_impl

gi/boxed.cpp:905–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903template <class Base, class Prototype, class Instance>
904template <typename... Args>
905JSObject* 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:

Callers

nothing calls this directly

Calls 6

init_from_c_structMethod · 0.80
to_instanceMethod · 0.80
nameMethod · 0.45
debug_lifecycleMethod · 0.45
add_associated_memoryMethod · 0.45

Tested by

no test coverage detected