diff options
Diffstat (limited to 'gi/boxed.h')
-rw-r--r-- | gi/boxed.h | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -37,6 +37,13 @@ namespace js { class SystemAllocPolicy; } +namespace Gjs { +enum class DirectAllocationPolicy { + NO_POINTERS, + ALLOCATE_POINTERS, +}; +}; + /* To conserve memory, we have two different kinds of private data for GBoxed * JS wrappers: BoxedInstance, and BoxedPrototype. Both inherit from BoxedBase * for their common functionality. For more information, see the notes in @@ -90,6 +97,7 @@ class BoxedPrototype : public GIWrapperPrototype<BoxedBase, BoxedPrototype, JS::Heap<jsid> m_default_constructor_name; std::unique_ptr<FieldMap> m_field_map; bool m_can_allocate_directly : 1; + bool m_can_allocate_directly_with_pointers : 1; explicit BoxedPrototype(GIStructInfo* info, GType gtype); ~BoxedPrototype(void); @@ -101,8 +109,14 @@ class BoxedPrototype : public GIWrapperPrototype<BoxedBase, BoxedPrototype, // Accessors public: - [[nodiscard]] bool can_allocate_directly() const { - return m_can_allocate_directly; + [[nodiscard]] bool can_allocate_directly( + Gjs::DirectAllocationPolicy allocation_policy = + Gjs::DirectAllocationPolicy::ALLOCATE_POINTERS) const { + if (allocation_policy == Gjs::DirectAllocationPolicy::NO_POINTERS) { + return m_can_allocate_directly; + } + + return m_can_allocate_directly_with_pointers; } [[nodiscard]] bool has_zero_args_constructor() const { return m_zero_args_constructor >= 0; |