[gjs/wip/ptomato/mozjs38: 5/29] WIP - object: switch to C++ struct



commit bcd27dbfe2bc7e0d7508d06103f0472cbf7c9b25
Author: Philip Chimento <philip endlessm com>
Date:   Thu Feb 2 16:12:24 2017 -0800

    WIP - object: switch to C++ struct
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776966

 gi/object.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 0248d46..da92787 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -51,7 +51,7 @@
 #include <util/hash-x32.h>
 #include <girepository.h>
 
-typedef struct {
+struct ObjectInstance {
     GIObjectInfo *info;
     GObject *gobj; /* NULL if we are the prototype and not an instance */
     JSObject *keep_alive; /* NULL if we are not added to it */
@@ -63,7 +63,7 @@ typedef struct {
     /* the GObjectClass wrapped by this JS Object (only used for
        prototypes) */
     GTypeClass *klass;
-} ObjectInstance;
+};
 
 typedef struct {
     ObjectInstance *obj;
@@ -1281,6 +1281,7 @@ init_object_private (JSContext       *context,
     JS_BeginRequest(context);
 
     priv = g_slice_new0(ObjectInstance);
+    new (priv) ObjectInstance();
 
     GJS_INC_COUNTER(object);
 
@@ -1586,6 +1587,7 @@ object_instance_finalize(JSFreeOp  *fop,
     }
 
     GJS_DEC_COUNTER(object);
+    priv->~ObjectInstance();
     g_slice_free(ObjectInstance, priv);
 }
 
@@ -2094,6 +2096,7 @@ gjs_define_object_class(JSContext              *context,
 
     GJS_INC_COUNTER(object);
     priv = g_slice_new0(ObjectInstance);
+    new (priv) ObjectInstance();
     priv->info = info;
     if (info)
         g_base_info_ref((GIBaseInfo*) info);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]