Переглянути джерело

[cppia] Do not allow running script from string on utf16 target.

hughsando 6 роки тому
батько
коміт
44e3ab61fa
1 змінених файлів з 14 додано та 5 видалено
  1. 14 5
      std/cpp/cppia/Host.hx

+ 14 - 5
std/cpp/cppia/Host.hx

@@ -24,12 +24,21 @@
 
 
 class Host
 class Host
 {
 {
+   #if utf16
+   public static function run(source:haxe.io.Bytes)
+   {
+      var module = Module.fromData(source.getData());
+      module.boot();
+      module.run();
+   }
+   #else
    public static function run(source:String)
    public static function run(source:String)
    {
    {
       var module = Module.fromString(source);
       var module = Module.fromString(source);
       module.boot();
       module.boot();
       module.run();
       module.run();
    }
    }
+   #end
 
 
 
 
    @:native("hx::EnableJit")
    @:native("hx::EnableJit")
@@ -37,7 +46,10 @@ class Host
 
 
    public static function runFile(filename:String)
    public static function runFile(filename:String)
    {
    {
-      run( sys.io.File.getContent(filename) );
+      var source = sys.io.File.getBytes(filename);
+      var module = Module.fromData(source.getData());
+      module.boot();
+      module.run();
    }
    }
 
 
 
 
@@ -58,10 +70,7 @@ class Host
       }
       }
       else
       else
       {
       {
-         var source = sys.io.File.getBytes(script);
-         var module = Module.fromData(source.getData());
-         module.boot();
-         module.run();
+         runFile(script);
       }
       }
    }
    }
 }
 }