[seed] [libseed] Prototype of gobject_methods should be Function.prototype. JSCore does not expose the JSOb



commit c5c340ad6dea7d0e034b1544e9ea074b03329891
Author: Robert Carr <racarr gnome org>
Date:   Wed Jul 29 03:42:01 2009 -0400

    [libseed] Prototype of gobject_methods should be Function.prototype. JSCore does not expose the JSObjectRef for Function.prototype, so it is neccessary to evaluate Function.prototype and assign from this.

 libseed/seed-engine.c |   10 ++++++++++
 libseed/seed-engine.h |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index cf3d345..dc365a3 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -23,6 +23,8 @@
 #include <stdarg.h>
 #include <string.h>
 
+JSObjectRef function_proto;
+
 JSObjectRef seed_obj_ref;
 
 GQuark qname;
@@ -618,6 +620,8 @@ seed_gobject_define_property_from_function_info (JSContextRef ctx,
 
   method_ref = JSObjectMake (ctx, gobject_method_class,
 			     g_base_info_ref ((GIBaseInfo *) info));
+  
+  JSObjectSetPrototype (ctx, method_ref, function_proto);
 
   name = g_base_info_get_name ((GIBaseInfo *) info);
   if (!g_strcmp0 (name, "new"))
@@ -1320,6 +1324,9 @@ seed_init (gint * argc, gchar *** argv)
   eng->group = context_group;
   eng->search_path = NULL;
 
+  function_proto = (JSObjectRef)
+	  seed_simple_evaluate (eng->context, "Function.prototype", NULL);
+
   gobject_class = JSClassCreate (&gobject_def);
   JSClassRetain (gobject_class);
   gobject_method_class = JSClassCreate (&gobject_method_def);
@@ -1413,6 +1420,9 @@ seed_init_with_context_group (gint * argc,
   eng->global = JSContextGetGlobalObject (eng->context);
   eng->group = context_group;
   eng->search_path = NULL;
+  
+  function_proto = (JSObjectRef)
+	  seed_simple_evaluate (eng->context, "Function.prototype", NULL);
 
   gobject_class = JSClassCreate (&gobject_def);
   JSClassRetain (gobject_class);
diff --git a/libseed/seed-engine.h b/libseed/seed-engine.h
index 904b120..89b0203 100644
--- a/libseed/seed-engine.h
+++ b/libseed/seed-engine.h
@@ -79,4 +79,6 @@ JSValueRef seed_evaluate (JSContextRef ctx, SeedScript *script, JSObjectRef this
 
 void seed_script_destroy (SeedScript *s);
 
+JSValueRef seed_simple_evaluate (JSContextRef ctx, const gchar *script, JSValueRef *exception);
+
 #endif



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