seed r321 - trunk/libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r321 - trunk/libseed
- Date: Mon, 24 Nov 2008 05:52:44 +0000 (UTC)
Author: racarr
Date: Mon Nov 24 05:52:44 2008
New Revision: 321
URL: http://svn.gnome.org/viewvc/seed?rev=321&view=rev
Log:
Add seed_pointer_set_free, which specifies that when a pointer base type (parent of struct, union, boxed, etc...) is collected, the pointer itself should be freed.
Modified:
trunk/libseed/seed-structs.c
trunk/libseed/seed-structs.h
Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c (original)
+++ trunk/libseed/seed-structs.c Mon Nov 24 05:52:44 2008
@@ -29,6 +29,8 @@
typedef struct _seed_struct_privates {
gpointer pointer;
GIBaseInfo *info;
+
+ gboolean free_pointer;
} seed_struct_privates;
static void seed_pointer_finalize(JSObjectRef object)
@@ -36,6 +38,9 @@
seed_struct_privates *priv =
(seed_struct_privates *) JSObjectGetPrivate(object);
+ if (priv->free_pointer)
+ g_free(priv->pointer);
+
g_free(priv);
}
@@ -320,9 +325,9 @@
NULL, /* Static Values */
NULL, /* Static Functions */
NULL,
- seed_boxed_finalize,
+ seed_boxed_finalize,
NULL, /* Has Property */
- 0,
+ NULL,
NULL, /* Set Property */
NULL, /* Delete Property */
NULL, /* Get Property Names */
@@ -342,6 +347,15 @@
return 0;
}
+void seed_pointer_set_free(JSValueRef pointer, gboolean free_pointer)
+{
+ if (JSValueIsObjectOfClass(eng->context, pointer, seed_pointer_class))
+ {
+ seed_struct_privates *priv = JSObjectGetPrivate((JSObjectRef) pointer);
+ priv->free_pointer = free_pointer;
+ }
+}
+
JSObjectRef seed_make_pointer(gpointer pointer)
{
seed_struct_privates *priv = g_malloc(sizeof(seed_struct_privates));
@@ -359,6 +373,7 @@
priv->pointer = younion;
priv->info = info;
+ priv->free_pointer = FALSE;
object = JSObjectMake(eng->context, seed_union_class, priv);
@@ -388,6 +403,8 @@
priv->info = info;
priv->pointer = boxed;
+ // Boxed finalize handler handles freeing.
+ priv->free_pointer = FALSE;
object = JSObjectMake(eng->context, seed_boxed_class, priv);
@@ -404,6 +421,7 @@
priv->info = info;
priv->pointer = strukt;
+ priv->free_pointer = FALSE;
object = JSObjectMake(eng->context, seed_struct_class, priv);
Modified: trunk/libseed/seed-structs.h
==============================================================================
--- trunk/libseed/seed-structs.h (original)
+++ trunk/libseed/seed-structs.h Mon Nov 24 05:52:44 2008
@@ -35,6 +35,8 @@
JSValueRef * exception);
gpointer seed_pointer_get_pointer(JSValueRef strukt);
+void seed_pointer_set_free(JSValueRef pointer, gboolean free_pointer);
+
void seed_structs_init();
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]