src/Palete/Javascript.vala
authorAlan Knowles <alan@roojs.com>
Wed, 18 Mar 2015 09:39:21 +0000 (17:39 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 18 Mar 2015 09:39:21 +0000 (17:39 +0800)
src/Palete/Javascript.vala

index 8aab571..35eb78f 100644 (file)
@@ -116,17 +116,26 @@ namespace Palete {
                 */
                void executeFile(string filename, string method, string json)
                {
+                       
+                       var jfile_data new JSCore.String.with_utf8_c_string(file_data);
+                       var jmethod = new JSCore.String.with_utf8_c_string(method);
+                       var json_args = new JSCore.String.with_utf8_c_string(json);
+                       
                        JSCore.Value ex;
                        
                        var goc = new JSCore.Class(  class_definition ); 
                        var ctx = new JSCore.GlobalContext(goc);
+                       var othis = ctx.get_global_object();
                        
+                       var val = ctx.evaluate_script (
+                                               jfile_data
+                                               othis,
+                                               null,
+                               0,
+                               ex
+                                       );
                        
                        
-                       var jmethod = new JSCore.String.with_utf8_c_string(method);
-                       var json_args = new JSCore.String.with_utf8_c_string(json);
-                       
-                       var othis = ctx.get_global_object();
                        if (!othis.has_property(ctx,jmethod)) {
                                throw new JavascriptError.MISSING_METHOD ("Plugin: missing method  %s", method);
                                return;
@@ -137,9 +146,14 @@ namespace Palete {
                                throw new JavascriptError.MISSING_METHOD ("Plugin: not a method  %s", method);
                        }
                        JSCore.value[] args = {};
-                       args += new 
-                       val.call_as_function(ctx, othis, 
+                       args += json_args;
+                        
+                       var res = val.call_as_function(ctx, othis, args, ex);
+                       
                        
+                       
+                       
+               }