Move Seed.print to the global object, as 'print', keep Seed.print for this release
authorRobert Carr <racarr@svn.gnome.org>
Wed, 27 May 2009 08:19:07 +0000 (04:19 -0400)
committerRobert Carr <racarr@svn.gnome.org>
Wed, 27 May 2009 08:19:07 +0000 (04:19 -0400)
libseed/seed-builtins.c
libseed/seed-builtins.h
libseed/seed-engine.c

index b24cb68..6097b34 100644 (file)
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <signal.h>
 
+JSValueRef seed_print_ref;
+
 static JSValueRef
 seed_include (JSContextRef ctx,
              JSObjectRef function,
@@ -483,7 +485,12 @@ seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv)
   seed_create_function (local_eng->context, "include", &seed_include, obj);
   seed_create_function (local_eng->context, "scoped_include", 
                        &seed_scoped_include, obj);
-  seed_create_function (local_eng->context, "print", &seed_print, obj);
+
+  seed_print_ref = JSObjectMakeFunctionWithCallback (local_eng->context, NULL, &seed_print);
+  seed_object_set_property (local_eng->context, obj, "print", seed_print_ref);
+  seed_object_set_property (local_eng->context, local_eng->global, "print", seed_print_ref);
+  JSValueProtect (local_eng->context, seed_print_ref);
+  
   seed_create_function (local_eng->context,
                        "check_syntax", &seed_check_syntax, obj);
   seed_create_function (local_eng->context,
index 247bd53..259d9e7 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "seed-private.h"
 
+extern JSValueRef seed_print_ref;
+
 void seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv);
 
 extern JSClassRef seed_argv_class;
index e03dc77..aeae25a 100644 (file)
@@ -68,6 +68,8 @@ seed_prepare_global_context (JSContextRef ctx)
   seed_object_set_property (ctx, global, "imports", importer);
   seed_object_set_property (ctx, global, "GType", seed_gtype_constructor);
   seed_object_set_property (ctx, global, "Seed", seed_obj_ref);
+  seed_object_set_property (ctx, global, "print", seed_print_ref);
+
 
   JSEvaluateScript (ctx, defaults_script, NULL, NULL, 0, NULL);
 }