[seed] Adding ondemand for reference -



commit e03106d8d3ae328186d35eb41bb47048d7dadd31
Author: Alan Knowles <alan akbkhome com>
Date:   Sun Mar 31 22:45:52 2013 +0800

    Adding ondemand for reference -
    
    Standard seed loads all properties into the namespace when you reference it, this patch file changes the 
behaviour so a fake namespace object
    is created, then when you request properties, the objects are created (eg. ctors/classes/enums etc..)
    
    The net effect of this is a shared memory reduction of around 20M when using a few key namespaces (eg. 
Gtk ... etc..)
    
    Still not close to gjs memory but a small improvement..

 ondemand.namespace.diff |  697 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 697 insertions(+), 0 deletions(-)
---
diff --git a/ondemand.namespace.diff b/ondemand.namespace.diff
new file mode 100644
index 0000000..f56dbfa
--- /dev/null
+++ b/ondemand.namespace.diff
@@ -0,0 +1,697 @@
+diff --git a/libseed/seed-builtins.c b/libseed/seed-builtins.c
+index b5b14fc..6bbb07c 100644
+--- a/libseed/seed-builtins.c
++++ b/libseed/seed-builtins.c
+@@ -279,6 +279,48 @@ seed_g_type_name_to_string (GITypeInfo * type)
+   return type_name;
+ }
+ 
++
++
++static JSValueRef
++seed_run_dispose (JSContextRef ctx,
++               JSObjectRef function,
++               JSObjectRef this_object,
++               size_t argumentCount,
++               const JSValueRef arguments[], JSValueRef * exception)
++{
++   
++  GObject* object;
++  
++
++  if (argumentCount != 1)
++    {
++      seed_make_exception (ctx, exception, "ArgumentError",
++                         "Seed.run_dispose^ expected 1 argument, "
++                         "got %zd", argumentCount);
++      return JSValueMakeNull (ctx);
++    }
++
++  if (!JSValueIsObject (ctx, arguments[0]))
++    return JSValueMakeNull (ctx);
++  if (!JSValueIsObjectOfClass (ctx, arguments[0], gobject_class)) {
++    SEED_NOTE (FINALIZATION,
++               "seed_run_dispose - failed - not gobject_class ");
++ 
++    return JSValueMakeNull (ctx);
++  }
++
++  object = seed_value_to_object (ctx,  arguments[0], exception);
++  while(object->ref_count > 1) 
++     g_object_unref(object);
++  
++   SEED_NOTE (FINALIZATION,
++               "Manual dispose of gobject.");
++     
++  g_object_run_dispose(object);
++  return JSValueMakeNull (ctx);
++}
++
++
+ static JSValueRef
+ seed_introspect (JSContextRef ctx,
+                JSObjectRef function,
+@@ -542,6 +584,7 @@ seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv)
+                       "introspect", &seed_introspect, obj);
+   seed_create_function (local_eng->context, "spawn", &seed_spawn, obj);
+   seed_create_function (local_eng->context, "quit", &seed_quit, obj);
++  seed_create_function (local_eng->context, "run_dispose", &seed_run_dispose, obj);
+   seed_create_function (local_eng->context, "breakpoint",
+                       &seed_breakpoint, obj);
+ 
+diff --git a/libseed/seed-closure.c b/libseed/seed-closure.c
+index 62241c8..f621160 100644
+--- a/libseed/seed-closure.c
++++ b/libseed/seed-closure.c
+@@ -288,10 +288,9 @@ seed_handle_closure (ffi_cif * cif, void *result, void **args, gpointer userdata
+       *(gpointer *) result = 0;
+     }
+   g_base_info_unref ((GIBaseInfo *) return_type);
+-  
+-  JSGarbageCollect(ctx);
+-
++   
+   JSGlobalContextRelease ((JSGlobalContextRef) ctx);
++  JSGarbageCollect(ctx);
+ }
+ 
+ SeedNativeClosure *
+diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
+index 3870fb0..06364f1 100644
+--- a/libseed/seed-engine.c
++++ b/libseed/seed-engine.c
+@@ -1009,6 +1009,45 @@ seed_gobject_define_property_from_function_info (JSContextRef ctx,
+ 
+ }
+ 
++
++
++JSObjectRef
++seed_gobject_function_info_to_value (JSContextRef ctx,
++                                               GIFunctionInfo * info,
++                                               gboolean instance)
++{
++  GIFunctionInfoFlags flags;
++  JSObjectRef method_ref;
++  const gchar *name;
++
++  //if (g_base_info_is_deprecated ((GIBaseInfo *) info))
++  //g_printf("Not defining deprecated symbol: %s \n",
++  //g_base_info_get_name((GIBaseInfo *)info));
++
++  flags = g_function_info_get_flags (info);
++
++  if (instance && (flags & GI_FUNCTION_IS_CONSTRUCTOR))
++    {
++      return;
++    }
++
++  method_ref = JSObjectMake (ctx, gobject_method_class,
++                           g_base_info_ref ((GIBaseInfo *) info));
++
++  JSObjectSetPrototype (ctx, method_ref, function_proto);
++
++   
++  seed_object_set_property (ctx, method_ref, "info",
++                          seed_make_struct (ctx,
++                                            g_base_info_ref ((GIBaseInfo *)
++                                                             info),
++                                            base_info_info));
++  return method_ref;
++  
++}
++
++
++
+ static void
+ seed_gobject_add_methods_for_interfaces (JSContextRef ctx,
+                                        GIObjectInfo * oinfo,
+diff --git a/libseed/seed-engine.h b/libseed/seed-engine.h
+index 4adcde5..a97c4bd 100644
+--- a/libseed/seed-engine.h
++++ b/libseed/seed-engine.h
+@@ -52,6 +52,10 @@ typedef struct _SeedScript
+ JSObjectRef seed_gobject_get_prototype_for_gtype (GType type);
+ JSClassRef seed_gobject_get_class_for_gtype (JSContextRef ctx, GType type);
+ 
++JSObjectRef
++seed_gobject_function_info_to_value (JSContextRef ctx,
++                                               GIFunctionInfo * info,
++                                               gboolean instance);
+ void
+ seed_gobject_define_property_from_function_info (JSContextRef ctx,
+                                                GIFunctionInfo * info,
+diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
+index de331ff..b345480 100644
+--- a/libseed/seed-importer.c
++++ b/libseed/seed-importer.c
+@@ -28,6 +28,8 @@ JSClassRef importer_class;
+ JSObjectRef importer;
+ 
+ JSClassRef gi_importer_class;
++JSClassRef gi_importer_namespace;
++
+ JSObjectRef gi_importer;
+ JSObjectRef gi_importer_versions;
+ 
+@@ -90,24 +92,25 @@ seed_gi_importer_is_init (GIFunctionInfo * info)
+   return TRUE;
+ }
+ 
+-static void
++static JSValueRef
+ seed_gi_importer_handle_function (JSContextRef ctx,
+-                                JSObjectRef namespace_ref,
+                                 GIFunctionInfo * info,
+                                 JSValueRef * exception)
+ {
+-  if (!seed_gi_importer_is_init (info))
+-    seed_gobject_define_property_from_function_info (ctx,
+-                                                   (GIFunctionInfo *) info,
+-                                                   namespace_ref, FALSE);
+-  else
+-    {
+-      JSObjectRef init_method;
+-
+-      init_method = JSObjectMake (ctx, gobject_init_method_class,
++ 
++  if (seed_gi_importer_is_init (info)) {
++     
++   
++      return  JSObjectMake (ctx, gobject_init_method_class,
+                                 g_base_info_ref ((GIBaseInfo *) info));
+-      seed_object_set_property (ctx, namespace_ref, "init", init_method);
++      
+     }
++
++return seed_gobject_function_info_to_value (ctx,  info,  FALSE);
++ 
++
++
++  
+ }
+ 
+ /*
+@@ -116,9 +119,8 @@ seed_gi_importer_handle_function (JSContextRef ctx,
+  * a value for each member, all in uppercase
+  * i.e. Gtk.WindowType.NORMAL
+  */
+-static void
+-seed_gi_importer_handle_enum (JSContextRef ctx,
+-                            JSObjectRef namespace_ref,
++static JSValueRef
++seed_gi_importer_handle_enum (JSContextRef ctx, 
+                             GIEnumInfo * info, JSValueRef * exception)
+ {
+   JSObjectRef enum_class;
+@@ -130,9 +132,9 @@ seed_gi_importer_handle_enum (JSContextRef ctx,
+ 
+   enum_class = JSObjectMake (ctx, 0, 0);
+   num_vals = g_enum_info_get_n_values (info);
+-  seed_object_set_property (ctx, namespace_ref,
+-                          g_base_info_get_name ((GIBaseInfo *) info),
+-                          enum_class);
++  //seed_object_set_property (ctx, namespace_ref,
++ //                       g_base_info_get_name ((GIBaseInfo *) info),
++ //                       enum_class);
+ 
+   for (i = 0; i < num_vals; i++)
+     {
+@@ -158,6 +160,7 @@ seed_gi_importer_handle_enum (JSContextRef ctx,
+       g_base_info_unref ((GIBaseInfo *) val);
+ 
+     }
++  return enum_class;
+ }
+ 
+ /*
+@@ -165,78 +168,81 @@ seed_gi_importer_handle_enum (JSContextRef ctx,
+  * Namespace.Type will be the constructor and Namespace.Type.prototype is
+  * the prototype object. Namespace.Type.type will be the GType.
+  */
+-static void
+-seed_gi_importer_handle_object (JSContextRef ctx,
+-                              JSObjectRef namespace_ref,
++static JSValueRef
++seed_gi_importer_handle_object (JSContextRef ctx, 
+                               GIObjectInfo * info, JSValueRef * exception)
+ {
+   GType type;
+   JSClassRef class_ref;
++  //JSValueRef ret;
+ 
++  
+   type = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) info);
+ 
+-  if (type != 0)
+-    {
+-      GIFunctionInfo *finfo;
+-      GIFunctionInfoFlags flags;
+-      JSObjectRef constructor_ref;
+-      guint i, n_methods;
++  if (type == 0) {
++    return NULL;
++  }
+ 
+-      class_ref = seed_gobject_get_class_for_gtype (ctx, type);
+ 
+-      constructor_ref =
+-      JSObjectMake (ctx, gobject_constructor_class, (gpointer) type);
++  GIFunctionInfo *finfo;
++  GIFunctionInfoFlags flags;
++  JSObjectRef constructor_ref;
++  guint i, n_methods;
+ 
+-      seed_object_set_property (ctx, constructor_ref,
+-                              "type",
+-                              seed_value_from_long (ctx, type, exception));
+-      n_methods = g_object_info_get_n_methods (info);
+-      for (i = 0; i < n_methods; i++)
+-      {
+-        finfo = g_object_info_get_method (info, i);
+-        flags = g_function_info_get_flags (finfo);
+-        if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
+-          {
+-            JSObjectRef constructor = JSObjectMake (ctx,
+-                                                    gobject_named_constructor_class,
+-                                                    finfo);
+-            const gchar *fname =
+-              g_base_info_get_name ((GIBaseInfo *) finfo);
+-            if (g_strrstr (fname, "new_") == fname)
+-              fname += 4;
+-            else if (!g_strcmp0 (fname, "new"))
+-              fname = "c_new";
+-
+-            seed_object_set_property (ctx,
+-                                      constructor_ref, fname, constructor);
+-          }
+-        else if (!(flags & GI_FUNCTION_IS_METHOD))
+-          {
+-            seed_gobject_define_property_from_function_info
+-              (ctx, finfo, constructor_ref, FALSE);
+-          }
+-        else
+-          {
+-            g_base_info_unref ((GIBaseInfo *) finfo);
+-          }
+-      }
++  class_ref = seed_gobject_get_class_for_gtype (ctx, type);
++
++  constructor_ref =
++    JSObjectMake (ctx, gobject_constructor_class, (gpointer) type);
+ 
+-      seed_object_set_property (ctx, namespace_ref,
+-                              g_base_info_get_name ((GIBaseInfo *) info),
+-                              constructor_ref);
+-      seed_object_set_property (ctx, constructor_ref,
+-                              "prototype",
+-                              seed_gobject_get_prototype_for_gtype (type));
++  seed_object_set_property (ctx, constructor_ref,
++                            "type",
++                            seed_value_from_long (ctx, type, exception));
++  n_methods = g_object_info_get_n_methods (info);
++  for (i = 0; i < n_methods; i++)
++  {
++    finfo = g_object_info_get_method (info, i);
++    flags = g_function_info_get_flags (finfo);
++    if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
++    {
++      JSObjectRef constructor = JSObjectMake (ctx,
++                                              gobject_named_constructor_class,
++                                              finfo);
++      const gchar *fname =
++      g_base_info_get_name ((GIBaseInfo *) finfo);
++      if (g_strrstr (fname, "new_") == fname)
++      fname += 4;
++      else if (!g_strcmp0 (fname, "new"))
++      fname = "c_new";
++
++      seed_object_set_property (ctx,
++                                constructor_ref, fname, constructor);
+     }
++    else if (!(flags & GI_FUNCTION_IS_METHOD))
++    {
++      seed_gobject_define_property_from_function_info
++      (ctx, finfo, constructor_ref, FALSE);
++    }
++    else
++    {
++      g_base_info_unref ((GIBaseInfo *) finfo);
++    }
++  }
++  // sets up imports.gi.Gtk.Window << 
++
++  seed_object_set_property (ctx, constructor_ref,
++                            "prototype",
++                            seed_gobject_get_prototype_for_gtype (type));
++
++  return  (JSValueRef) constructor_ref;
++  
+ }
+ 
+ /*
+  * Set up prototype and constructor for structs. Same semantics as objects except
+  * for the type.
+  */
+-static void
++static JSValueRef
+ seed_gi_importer_handle_struct (JSContextRef ctx,
+-                              JSObjectRef namespace_ref,
+                               GIStructInfo * info, JSValueRef * exception)
+ {
+   JSObjectRef struct_ref;
+@@ -279,14 +285,15 @@ seed_gi_importer_handle_struct (JSContextRef ctx,
+   proto = seed_struct_prototype (ctx, (GIBaseInfo *) info);
+   seed_object_set_property (ctx, struct_ref, "prototype", proto);
+ 
+-  seed_object_set_property (ctx, namespace_ref,
++  return struct_ref;
++  /*seed_object_set_property (ctx, namespace_ref,
+                           g_base_info_get_name ((GIBaseInfo *) info),
+                           struct_ref);
++  */
+ }
+ 
+-static void
++static JSValueRef
+ seed_gi_importer_handle_union (JSContextRef ctx,
+-                             JSObjectRef namespace_ref,
+                              GIUnionInfo * info, JSValueRef * exception)
+ {
+   JSObjectRef union_ref;
+@@ -315,32 +322,31 @@ seed_gi_importer_handle_union (JSContextRef ctx,
+ 
+   proto = seed_union_prototype (ctx, (GIBaseInfo *) info);
+   seed_object_set_property (ctx, union_ref, "prototype", proto);
+-
+-  seed_object_set_property (ctx, namespace_ref,
+-                          g_base_info_get_name ((GIBaseInfo *) info),
+-                          union_ref);
++  return union_ref;
++  //seed_object_set_property (ctx, namespace_ref,
++//                        g_base_info_get_name ((GIBaseInfo *) info),
++                      //    union_ref);
+ }
+ 
+-static void
++static JSValueRef
+ seed_gi_importer_handle_callback (JSContextRef ctx,
+-                                JSObjectRef namespace_ref,
+                                 GICallbackInfo * info,
+                                 JSValueRef * exception)
+ {
+   JSObjectRef callback_ref = JSObjectMake (ctx,
+                                          seed_callback_class,
+                                          info);
+-  seed_object_set_property (ctx, namespace_ref,
+-                          g_base_info_get_name ((GIBaseInfo *) info),
+-                          (JSValueRef) callback_ref);
++  return callback_ref;
++ // seed_object_set_property (ctx, namespace_ref,
++//                        g_base_info_get_name ((GIBaseInfo *) info),
++//                        (JSValueRef) callback_ref);
+ }
+ 
+ /*
+  * Define constants toplevel. Uses the casing as in the typelib
+  */
+-static void
++static JSValueRef
+ seed_gi_importer_handle_constant (JSContextRef ctx,
+-                                JSObjectRef namespace_ref,
+                                 GIConstantInfo * info,
+                                 JSValueRef * exception)
+ {
+@@ -351,11 +357,14 @@ seed_gi_importer_handle_constant (JSContextRef ctx,
+   g_constant_info_get_value (info, &argument);
+   constant_value =
+     seed_value_from_gi_argument (ctx, &argument, constant_type, exception);
+-  seed_object_set_property (ctx, namespace_ref,
+-                          g_base_info_get_name ((GIBaseInfo *) info),
+-                          constant_value);
++g_base_info_unref ((GIBaseInfo *) constant_type);
++  return constant_value;
++  
++  //seed_object_set_property (ctx, namespace_ref,
++      //                  g_base_info_get_name ((GIBaseInfo *) info),
++      //                  constant_value);
+ 
+-  g_base_info_unref ((GIBaseInfo *) constant_type);
++  
+ }
+ 
+ static gchar *
+@@ -373,6 +382,13 @@ seed_gi_importer_get_version (JSContextRef ctx,
+   return version;
+ }
+ 
++/**
++ * original code creates a huge object, when even a large namespace is pulled in.
++ * let's try and create a fake object, representing the namespace,
++ * and see what happens
++ * 
++ */
++
+ JSObjectRef
+ seed_gi_importer_do_namespace (JSContextRef ctx,
+                              gchar * namespace, JSValueRef * exception)
+@@ -380,7 +396,6 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
+   GIBaseInfo *info;
+   JSObjectRef namespace_ref;
+   GError *e = NULL;
+-  guint n, i;
+   gchar *version = NULL;
+   gchar *jsextension;
+   JSStringRef extension_script;
+@@ -397,6 +412,7 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
+ 
+   if (gi_importer_versions != NULL)
+     version = seed_gi_importer_get_version (ctx, namespace, exception);
++  
+   if (!g_irepository_require (NULL, namespace, version, 0, &e))
+     {
+       seed_make_exception_from_gerror (ctx, exception, e);
+@@ -407,6 +423,16 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
+   if (version != NULL)
+     g_free (version);
+ 
++ // at this point we have loaded the namespace (eg. proved it exists)
++  namespace_ref = JSObjectMake (ctx, gi_importer_namespace, 
++                              g_strdup (namespace));
++  
++  SEED_NOTE (IMPORTER, "Constructing namespace ref (%p) for %s",
++           namespace_ref, namespace);
++
++  JSValueProtect (ctx, namespace_ref);
++
++  /*
+   n = g_irepository_get_n_infos (NULL, namespace);
+ 
+   namespace_ref = JSObjectMake (ctx, NULL, NULL);
+@@ -461,9 +487,13 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
+       }
+       g_base_info_unref (info);
+     }
+-
++*/
++  // store it for quick lookup
++  
+   g_hash_table_insert (gi_imports, g_strdup (namespace), namespace_ref);
+ 
++  // run a specific extension relating to this namespace..
++  
+   jsextension = g_strdup_printf ("imports.extensions.%s", namespace);
+   extension_script = JSStringCreateWithUTF8CString (jsextension);
+   JSEvaluateScript (ctx, extension_script, NULL, NULL, 0, exception);
+@@ -476,6 +506,117 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
+ }
+ 
+ static JSValueRef
++seed_gi_importer_namespace_get_property (JSContextRef ctx,
++                             JSObjectRef object,
++                             JSStringRef property_name,
++                             JSValueRef * exception)
++{
++   JSObjectRef ret;
++   guint len;
++   gchar *prop;
++    gchar * namespace;
++   guint n, i;
++ GIBaseInfo *info;  
++ 
++    //what prop are we trying to get...
++    len = JSStringGetMaximumUTF8CStringSize (property_name);
++    prop = g_alloca (len * sizeof (gchar));
++    JSStringGetUTF8CString (property_name, prop, len);
++
++    // what are we trying to get it from 
++    namespace = (gchar*) JSObjectGetPrivate (object);
++
++  SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s",
++              namespace, prop);
++
++  
++    n = g_irepository_get_n_infos (NULL, namespace);
++
++    ret = NULL;
++  
++    for (i = 0; i < n; i++)
++    {
++      GIInfoType info_type;
++
++      info = g_irepository_get_info (NULL, namespace, i);
++      info_type = g_base_info_get_type (info);
++      // does the name need freeing???
++      //info_name =  if (g_strcmp0 (g_base_info_get_name ((GIBaseInfo *) info), "init"))
++
++      if (g_strcmp0 (g_base_info_get_name ((GIBaseInfo *) info), prop)) {
++      g_base_info_unref (info);
++      continue;
++      }
++      
++      switch (info_type)
++      {
++      case GI_INFO_TYPE_FUNCTION:
++        SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s :: is a function",
++              namespace, prop);
++
++         ret =  seed_gi_importer_handle_function (ctx,   (GIFunctionInfo *) info,
++                      exception);
++       
++           
++        break;
++      case GI_INFO_TYPE_ENUM:
++      case GI_INFO_TYPE_FLAGS:
++              SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s :: is a enum/flag",
++                              namespace, prop);
++
++         ret =   seed_gi_importer_handle_enum (ctx, 
++                                      (GIEnumInfo *) info, exception);
++           
++           g_base_info_unref (info);
++        return ret; 
++      
++        break;
++      case GI_INFO_TYPE_OBJECT:
++        ret = seed_gi_importer_handle_object (ctx, 
++                                        (GIObjectInfo *) info, exception);
++         break;
++      case GI_INFO_TYPE_STRUCT:
++          SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s :: is a struct",
++              namespace, prop);
++
++        ret = seed_gi_importer_handle_struct (ctx, 
++                                        (GIStructInfo *) info, exception);
++         break;
++      case GI_INFO_TYPE_UNION:
++          SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s :: is a union",
++              namespace, prop);
++
++       ret = seed_gi_importer_handle_union (ctx,  
++                                       (GIUnionInfo *) info, exception);
++       
++          break;
++      case GI_INFO_TYPE_CALLBACK:
++          SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s :: is a callback",
++              namespace, prop);
++
++      ret =   seed_gi_importer_handle_callback (ctx, 
++                                          (GICallbackInfo *) info,
++                                          exception);
++        break;
++      case GI_INFO_TYPE_CONSTANT:
++          SEED_NOTE (IMPORTER, "seed_gi_importer_namespace_get_property %s::%s :: is a constant",
++              namespace, prop);
++
++      ret =   seed_gi_importer_handle_constant (ctx, 
++                                          (GIConstantInfo *) info,
++                                          exception);
++        break;
++      default:
++        break;
++      }
++      g_base_info_unref (info);
++    }
++  
++    return ret;
++
++}
++
++static JSValueRef
+ seed_gi_importer_get_property (JSContextRef ctx,
+                              JSObjectRef object,
+                              JSStringRef property_name,
+@@ -1040,6 +1181,28 @@ JSClassDefinition gi_importer_class_def = {
+   NULL                                /* Convert To Type */
+ };
+ 
++JSClassDefinition gi_importer_namespace_def = {
++  0,                          /* Version, always 0 */
++  0,
++  "gi_namespace_importer",    /* Class Name */
++  NULL,                               /* Parent Class */
++  NULL,                               /* Static Values */
++  NULL,                               /* Static Functions */
++  NULL,                               /* Initialize */
++  NULL,                               /* Finalize */
++  NULL,                               /* Has Property */
++  seed_gi_importer_namespace_get_property,    /* Get Property */
++  NULL,                               /* Set Property */
++  NULL,                               /* Delete Property */
++  NULL,                               /* Get Property Names */
++  NULL,                               /* Call As Function */
++  NULL,                               /* Call As Constructor */
++  NULL,                               /* Has Instance */
++  NULL                                /* Convert To Type */
++};
++
++
++
+ JSClassDefinition importer_dir_class_def = {
+   0,                          /* Version, always 0 */
+   0,
+@@ -1075,6 +1238,10 @@ seed_initialize_importer (JSContextRef ctx, JSObjectRef global)
+   JSValueProtect (ctx, gi_importer);
+   JSValueProtect (ctx, gi_importer_versions);
+ 
++   gi_importer_namespace = JSClassCreate (&gi_importer_namespace_def);
++   //JSValueProtect (ctx, gi_importer_namespace);
++  
++  
+   importer_dir_class = JSClassCreate (&importer_dir_class_def);
+ 
+   gi_imports = g_hash_table_new (g_str_hash, g_str_equal);
+diff --git a/libseed/seed-types.c b/libseed/seed-types.c
+index 5f17d9b..e68ab89 100644
+--- a/libseed/seed-types.c
++++ b/libseed/seed-types.c
+@@ -45,6 +45,10 @@ seed_toggle_ref (gpointer data, GObject * object, gboolean is_last_ref)
+   if (!g_object_get_data (object, "js-ref"))
+     return;
+ 
++ SEED_NOTE (MISC,
++               "seed_toggle_ref %d", is_last_ref ? 1 : 0);
++  
++  
+   wrapper = (JSValueRef) data;
+ 
+   if (is_last_ref)
+@@ -60,6 +64,9 @@ seed_toggle_ref (gpointer data, GObject * object, gboolean is_last_ref)
+ static void
+ seed_gobject_destroyed (gpointer object)
+ {
++SEED_NOTE (MISC,
++               "seed_gobject_destroyed ");
++ 
+   JSValueUnprotect (eng->context, (JSValueRef) object);
+   JSObjectSetPrivate ((JSObjectRef) object, 0);
+ }
+@@ -110,7 +117,7 @@ seed_wrap_object (JSContextRef ctx, GObject * object)
+   g_object_set_qdata_full (object, js_ref_quark, (gpointer) js_ref,
+                          seed_gobject_destroyed);
+ 
+-  JSValueProtect (eng->context, js_ref);
++  //JSValueProtect (eng->context, js_ref);
+   g_object_add_toggle_ref (object, seed_toggle_ref, (gpointer) js_ref);
+ 
+   seed_add_signals_to_object (ctx, js_ref, object);


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