[gjs] object: switch to C++ struct
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] object: switch to C++ struct
- Date: Wed, 8 Feb 2017 02:02:39 +0000 (UTC)
commit f4e5ef6f8358d17719aeeb02bfdb5ae1237c7224
Author: Philip Chimento <philip endlessm com>
Date: Thu Feb 2 16:12:24 2017 -0800
object: switch to C++ struct
This will be necessary because we are going to convert the raw JSObject *
member of ObjectInstance to a heap wrapper.
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 aa33ad2..8b63651 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;
@@ -1287,6 +1287,7 @@ init_object_private (JSContext *context,
JS_BeginRequest(context);
priv = g_slice_new0(ObjectInstance);
+ new (priv) ObjectInstance();
GJS_INC_COUNTER(object);
@@ -1592,6 +1593,7 @@ object_instance_finalize(JSFreeOp *fop,
}
GJS_DEC_COUNTER(object);
+ priv->~ObjectInstance();
g_slice_free(ObjectInstance, priv);
}
@@ -2100,6 +2102,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]