[seed] When evaluating a script in the importer, deifne the this object to be the global context of the scr



commit 1c9468574123a1b95a9d6006bbb23930e62eece4
Author: Robert Carr <racarr mireia (none)>
Date:   Tue Apr 14 23:47:51 2009 -0400

    When evaluating a script in the importer, deifne the this object to be the global context of the script including the included script
---
 examples/introspect.js  |    2 +-
 libseed/seed-importer.c |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/introspect.js b/examples/introspect.js
index ce0e20f..7e34ade 100755
--- a/examples/introspect.js
+++ b/examples/introspect.js
@@ -3,7 +3,7 @@
 // JSON.stringify and JSON.fromString come from json2.js available on json.org
 // Also in extensions/seed.js.
 
-Seed.import_namespace("Gtk");
+Gtk = imports.gi.Gtk;
 
 var proto = Gtk.Window.prototype;
 var method = Seed.introspect(proto.translate_coordinates);
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index aa73463..d7c3492 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -540,7 +540,7 @@ seed_importer_handle_file (JSContextRef ctx,
 			   JSValueRef *exception)
 {
   JSContextRef nctx;
-  JSObjectRef global;
+  JSObjectRef global, c_global;
   JSStringRef file_contents, file_name;
   gchar *contents, *walk, *file_path;
   
@@ -582,11 +582,12 @@ seed_importer_handle_file (JSContextRef ctx,
   seed_prepare_global_context (nctx);
   
   global = JSContextGetGlobalObject (nctx);
+  c_global = JSContextGetGlobalObject (ctx);
   JSValueProtect (eng->context, global);
   
   g_hash_table_insert (file_imports, file_path, global);
 
-  JSEvaluateScript (nctx, file_contents, NULL, file_name, 0, exception);
+  JSEvaluateScript (nctx, file_contents, c_global, file_name, 0, exception);
 
   // Does leak...but it's a debug statement.
   SEED_NOTE (IMPORTER, "Evaluated file, exception: %s", 



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