@@ -10,7 +10,7 @@ import haxe.macro.Expr;
1010class LiveClass {
1111
1212 @:persistent static var CONFIG : { api : String , srcPath : Array <String > } #if !macro = getMacroConfig () #end;
13-
13+
1414 public static function isEnable () {
1515 return CONFIG != null ;
1616 }
@@ -110,15 +110,15 @@ class LiveClass {
110110 return filePath ;
111111 }
112112
113- #elseif (sys || hxnodejs)
113+ #else
114114
115115 // runtime
116116
117117 public static function registerFile ( file : String , onChange : Void -> Void ) {
118118 for ( dir in CONFIG .srcPath ) {
119119 var path = dir + " /" + file ;
120- if ( ! sys. FileSystem .exists (path ) ) continue ;
121120 #if hl
121+ if ( ! sys. FileSystem .exists (path ) ) continue ;
122122 new hl.uv. Fs (null , path , function (ev ) onChange ());
123123 #else
124124 throw " Not implemented for this platform" ;
@@ -133,12 +133,20 @@ class LiveClass {
133133 if ( types != null )
134134 return types ;
135135 if ( CONFIG == null ) throw " Checker types were not configured" ;
136- var xml = Xml .parse (sys.io. File . getContent (CONFIG .api ));
136+ var xml = Xml .parse (getContent (CONFIG .api ));
137137 types = new Checker . CheckerTypes ();
138138 types .addXmlApi (xml .firstElement ());
139139 return types ;
140140 }
141141
142+ public static dynamic function getContent ( file : String ) : String {
143+ #if (sys || hxnodejs)
144+ return sys.io. File .getContent (file );
145+ #else
146+ throw " This platform cannot load " + file + " : redefine hscript.LiveClass.getContent" ;
147+ #end
148+ }
149+
142150 #end
143151
144152}
@@ -178,7 +186,7 @@ class LiveClassRuntime {
178186 if ( type == null )
179187 loadType ();
180188 try {
181- var content = sys.io. File .getContent (path );
189+ var content = LiveClass .getContent (path );
182190 var parser = new hscript. Parser ();
183191 parser .allowTypes = true ;
184192 parser .allowMetadata = true ;
0 commit comments