Browse Source

Packages works correctly, Probably all std library should work.
Some libraries from haxelib could work.

rsredsq 10 years ago
parent
commit
db6e20f719
27 changed files with 354 additions and 76 deletions
  1. BIN
      Script/Haxe/HaxeTest/Cache/c4bc40f33b83aca308bd6d8e0c278ef5
  2. BIN
      Script/Haxe/HaxeTest/Cache/c4bc40f33b83aca308bd6d8e0c278ef5_thumbnail.png
  3. 11 0
      Script/Haxe/HaxeTest/Resources/Components/Background.hx
  4. 12 3
      Script/Haxe/HaxeTest/Resources/Components/Star.hx
  5. 4 2
      Script/Haxe/HaxeTest/Resources/Components/Star.js
  6. 0 8
      Script/Haxe/HaxeTest/Resources/Components/SuperStar.hx
  7. 2 2
      Script/Haxe/HaxeTest/Resources/Components/SuperStar.js
  8. 5 0
      Script/Haxe/HaxeTest/Resources/Components/addit.asset
  9. 18 0
      Script/Haxe/HaxeTest/Resources/Components/addit/MegaStar.hx
  10. 22 0
      Script/Haxe/HaxeTest/Resources/Components/addit/MegaStar.js
  11. 7 0
      Script/Haxe/HaxeTest/Resources/Components/addit/MegaStar.js.asset
  12. 76 0
      Script/Haxe/HaxeTest/Resources/Modules/Boot.js
  13. 7 0
      Script/Haxe/HaxeTest/Resources/Modules/Boot.js.asset
  14. 8 0
      Script/Haxe/HaxeTest/Resources/Modules/Std.js
  15. 7 0
      Script/Haxe/HaxeTest/Resources/Modules/Std.js.asset
  16. 11 0
      Script/Haxe/HaxeTest/Resources/Modules/StringTools.js
  17. 7 0
      Script/Haxe/HaxeTest/Resources/Modules/StringTools.js.asset
  18. 3 3
      Script/Haxe/HaxeTest/Resources/Scenes/Scene.scene
  19. 1 4
      Script/Haxe/HaxeTest/Resources/Scripts/Main.hx
  20. 1 1
      Script/Haxe/HaxeTest/Resources/Scripts/Main.js
  21. 5 0
      Script/Haxe/HaxeTest/Resources/Scripts/utils.asset
  22. 10 0
      Script/Haxe/HaxeTest/Resources/Scripts/utils/Loler.hx
  23. 10 0
      Script/Haxe/HaxeTest/Resources/Scripts/utils/Loler.js
  24. 7 0
      Script/Haxe/HaxeTest/Resources/Scripts/utils/Loler.js.asset
  25. 1 1
      Script/Haxe/HaxeTest/Resources/atomic-haxe.hxproj
  26. 118 52
      Script/Haxe/HaxeTest/Resources/atomic/AtomicBuilder.hx
  27. 1 0
      Script/Haxe/HaxeTest/Resources/build.hxml

BIN
Script/Haxe/HaxeTest/Cache/c4bc40f33b83aca308bd6d8e0c278ef5


BIN
Script/Haxe/HaxeTest/Cache/c4bc40f33b83aca308bd6d8e0c278ef5_thumbnail.png


+ 11 - 0
Script/Haxe/HaxeTest/Resources/Components/Background.hx

@@ -0,0 +1,11 @@
+package components;
+
+import atomic.Atomic;
+
+class Background extends JSComponent {
+
+	public function new() {
+		
+	}
+	
+}

+ 12 - 3
Script/Haxe/HaxeTest/Resources/Components/Star.hx

@@ -1,16 +1,25 @@
 package components;
 package components;
 
 
 import atomic.Atomic;
 import atomic.Atomic;
-import haxe.ds.ArraySort;
 
 
 class Star extends JSComponent {
 class Star extends JSComponent {
-	
+
+	var speed:Int;
+
 	function new() {
 	function new() {
 		super();
 		super();
+		speed = 1;
 	}
 	}
 	
 	
 	function update(timeStep:Float):Void {
 	function update(timeStep:Float):Void {
-		this.node.rotate2D(timeStep * 75);
+		this.node.rotate2D(speed);
 		this.node.rotateAround2D([1, 1], timeStep * 50, Atomic.TS_WORLD);
 		this.node.rotateAround2D([1, 1], timeStep * 50, Atomic.TS_WORLD);
 	}
 	}
+}
+
+enum Stars {
+  SuperStar;
+  NotSuperStar;
+  RandomStar;
+  Star(x:Int, y:Int);
 }
 }

+ 4 - 2
Script/Haxe/HaxeTest/Resources/Components/Star.js

@@ -4,12 +4,14 @@ var Star = (function(_super) {
 __extends(Star, _super);
 __extends(Star, _super);
 function Star() {
 function Star() {
 	Atomic.JSComponent.call(this);
 	Atomic.JSComponent.call(this);
+	this.speed = 1;
 };
 };
+Star.prototype.speed = null;
 Star.prototype.update = function(timeStep) {
 Star.prototype.update = function(timeStep) {
-	this.node.rotate2D(timeStep * 75);
+	this.node.rotate2D(this.speed);
 	this.node.rotateAround2D([1,1],timeStep * 50,Atomic.TS_WORLD);
 	this.node.rotateAround2D([1,1],timeStep * 50,Atomic.TS_WORLD);
 };
 };
 ;
 ;
 return Star;
 return Star;
 })(Atomic.JSComponent);
 })(Atomic.JSComponent);
-module.exports = Star;
+module.exports = Star;

+ 0 - 8
Script/Haxe/HaxeTest/Resources/Components/SuperStar.hx

@@ -2,14 +2,6 @@ package components;
 
 
 import components.Star;
 import components.Star;
 
 
-//Yeah, we imported Star, but we still need to define it.
-//https://github.com/HaxeFoundation/haxe/issues/3560
-
-//examples: 
-//@:require("CStar") - will require a component Star(Components/Star)
-//@:require("SFoo") - will require a script Foo(Scripts/Foo)
-//@:require("MBar") - will require a module Bar(Modules/Bar)
-@:require("CStar")
 class SuperStar extends Star {
 class SuperStar extends Star {
 	
 	
 	function start():Void {
 	function start():Void {

+ 2 - 2
Script/Haxe/HaxeTest/Resources/Components/SuperStar.js

@@ -1,4 +1,4 @@
-var Star = require("Components/Star");
+var Star = require("components/Star");
 var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
 var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
 "atomic component";
 "atomic component";
 var SuperStar = (function(_super) {
 var SuperStar = (function(_super) {
@@ -12,4 +12,4 @@ SuperStar.prototype.start = function() {
 ;
 ;
 return SuperStar;
 return SuperStar;
 })(Star);
 })(Star);
-module.exports = SuperStar;
+module.exports = SuperStar;

+ 5 - 0
Script/Haxe/HaxeTest/Resources/Components/addit.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "6e03be6ecba928709fc56b4d83bd5b1f",
+	"FolderImporter": {}
+}

+ 18 - 0
Script/Haxe/HaxeTest/Resources/Components/addit/MegaStar.hx

@@ -0,0 +1,18 @@
+package components.addit;
+
+import components.SuperStar;
+import scripts.utils.Loler;
+
+class MegaStar extends SuperStar {
+	
+	override function start() {
+		var lol:Loler = new Loler("lol");
+		var nlol:Loler = new Loler("foo");
+		node.scale2D = [4, 4];
+		
+		var str:String = "ReplAce me :)";
+		str = StringTools.replace(str, "Ace", "LOL");
+		trace(str);
+	}
+	
+}

+ 22 - 0
Script/Haxe/HaxeTest/Resources/Components/addit/MegaStar.js

@@ -0,0 +1,22 @@
+var StringTools = require("Modules/StringTools");
+var Loler = require("scripts/utils/Loler");
+var SuperStar = require("components/SuperStar");
+var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
+"atomic component";
+var MegaStar = (function(_super) {
+__extends(MegaStar, _super);
+function MegaStar() {
+	SuperStar.call(this);
+};
+MegaStar.prototype.start = function() {
+	var lol = new Loler("lol");
+	var nlol = new Loler("foo");
+	this.node.scale2D = [4,4];
+	var str = "ReplAce me :)";
+	str = StringTools.replace(str,"Ace","LOL");
+	console.log(str);
+};
+;
+return MegaStar;
+})(SuperStar);
+module.exports = MegaStar;

+ 7 - 0
Script/Haxe/HaxeTest/Resources/Components/addit/MegaStar.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "601c7fc53722853d70d32443341337f4",
+	"JavascriptImporter": {
+		"IsComponentFile": true
+	}
+}

+ 76 - 0
Script/Haxe/HaxeTest/Resources/Modules/Boot.js

@@ -0,0 +1,76 @@
+var String = require("Modules/String");
+var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
+var Boot = (function(_super) {
+__extends(Boot, _super);
+function Boot(){};
+Boot.__string_rec = function(o,s) {
+	if(o == null) return "null";
+	if(s.length >= 5) return "<...>";
+	var t = typeof(o);
+	if(t == "function" && (o.__name__ || o.__ename__)) t = "object";
+	switch(t) {
+	case "object":
+		if(o instanceof Array) {
+			if(o.__enum__) {
+				if(o.length == 2) return o[0];
+				var str2 = o[0] + "(";
+				s += "\t";
+				var _g1 = 2;
+				var _g = o.length;
+				while(_g1 < _g) {
+					var i1 = _g1++;
+					if(i1 != 2) str2 += "," + Boot.__string_rec(o[i1],s); else str2 += Boot.__string_rec(o[i1],s);
+				}
+				return str2 + ")";
+			}
+			var l = o.length;
+			var i;
+			var str1 = "[";
+			s += "\t";
+			var _g2 = 0;
+			while(_g2 < l) {
+				var i2 = _g2++;
+				str1 += (i2 > 0?",":"") + Boot.__string_rec(o[i2],s);
+			}
+			str1 += "]";
+			return str1;
+		}
+		var tostr;
+		try {
+			tostr = o.toString;
+		} catch( e ) {
+			return "???";
+		}
+		if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+			var s2 = o.toString();
+			if(s2 != "[object Object]") return s2;
+		}
+		var k = null;
+		var str = "{\n";
+		s += "\t";
+		var hasp = o.hasOwnProperty != null;
+		for( var k in o ) {
+		if(hasp && !o.hasOwnProperty(k)) {
+			continue;
+		}
+		if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+			continue;
+		}
+		if(str.length != 2) str += ", \n";
+		str += s + k + " : " + Boot.__string_rec(o[k],s);
+		}
+		s = s.substring(1);
+		str += "\n" + s + "}";
+		return str;
+	case "function":
+		return "<function>";
+	case "string":
+		return o;
+	default:
+		return String(o);
+	}
+};
+;
+return Boot;
+})(Object);
+module.exports = Boot;

+ 7 - 0
Script/Haxe/HaxeTest/Resources/Modules/Boot.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "4aa86d3dcaa070f0236f7bb85c841178",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 8 - 0
Script/Haxe/HaxeTest/Resources/Modules/Std.js

@@ -0,0 +1,8 @@
+var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
+var Std = (function(_super) {
+__extends(Std, _super);
+function Std(){};
+;
+return Std;
+})(Object);
+module.exports = Std;

+ 7 - 0
Script/Haxe/HaxeTest/Resources/Modules/Std.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "0271f913c849d2c94764a2dae4211509",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 11 - 0
Script/Haxe/HaxeTest/Resources/Modules/StringTools.js

@@ -0,0 +1,11 @@
+var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
+var StringTools = (function(_super) {
+__extends(StringTools, _super);
+function StringTools(){};
+StringTools.replace = function(s,sub,by) {
+	return s.split(sub).join(by);
+};
+;
+return StringTools;
+})(Object);
+module.exports = StringTools;

+ 7 - 0
Script/Haxe/HaxeTest/Resources/Modules/StringTools.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "2566625f979f2a59880dfd6645393ff8",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 3 - 3
Script/Haxe/HaxeTest/Resources/Scenes/Scene.scene

@@ -5,8 +5,8 @@
 	<attribute name="Smoothing Constant" value="50" />
 	<attribute name="Smoothing Constant" value="50" />
 	<attribute name="Snap Threshold" value="5" />
 	<attribute name="Snap Threshold" value="5" />
 	<attribute name="Elapsed Time" value="0" />
 	<attribute name="Elapsed Time" value="0" />
-	<attribute name="Next Replicated Node ID" value="368" />
-	<attribute name="Next Replicated Component ID" value="1982" />
+	<attribute name="Next Replicated Node ID" value="371" />
+	<attribute name="Next Replicated Component ID" value="1985" />
 	<attribute name="Next Local Node ID" value="16778496" />
 	<attribute name="Next Local Node ID" value="16778496" />
 	<attribute name="Next Local Component ID" value="16777216" />
 	<attribute name="Next Local Component ID" value="16777216" />
 	<attribute name="Variables" />
 	<attribute name="Variables" />
@@ -39,7 +39,7 @@
 			<attribute name="Sprite" value="Sprite2D;Sprites/star.png" />
 			<attribute name="Sprite" value="Sprite2D;Sprites/star.png" />
 		</component>
 		</component>
 		<component type="JSComponent" id="1977">
 		<component type="JSComponent" id="1977">
-			<attribute name="ComponentFile" value="JSComponentFile;Components/Star.js" />
+			<attribute name="ComponentFile" value="JSComponentFile;Components/addit/MegaStar.js" />
 		</component>
 		</component>
 	</node>
 	</node>
 </scene>
 </scene>

+ 1 - 4
Script/Haxe/HaxeTest/Resources/Scripts/Main.hx

@@ -4,14 +4,11 @@ import atomic.Atomic;
 
 
 import components.Star;
 import components.Star;
 import components.SuperStar;
 import components.SuperStar;
+import components.addit.MegaStar;
 
 
 class Main {
 class Main {
 	
 	
 	static inline function main() {
 	static inline function main() {
-		//Just a note:
-		//I used untyped here because Atomic.player is not exists in definitions
-		//untyped will compile your code as is
-		//right now only one way to use player, input, graphics, engine, etc...(need to write definitions for that)
 		untyped Atomic.player.loadScene("Scenes/Scene.scene");
 		untyped Atomic.player.loadScene("Scenes/Scene.scene");
 	}
 	}
 
 

+ 1 - 1
Script/Haxe/HaxeTest/Resources/Scripts/Main.js

@@ -9,4 +9,4 @@ Main.main();
 ;
 ;
 return Main;
 return Main;
 })(Object);
 })(Object);
-module.exports = Main;
+module.exports = Main;

+ 5 - 0
Script/Haxe/HaxeTest/Resources/Scripts/utils.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "42c43492bccc3a936ff5b2b5be18e7e6",
+	"FolderImporter": {}
+}

+ 10 - 0
Script/Haxe/HaxeTest/Resources/Scripts/utils/Loler.hx

@@ -0,0 +1,10 @@
+package scripts.utils;
+
+class Loler {
+
+	public function new(lol:String) {
+		if (lol == "lol") trace("LOL!")
+		else trace("NOT LOL :(");
+	}
+	
+}

+ 10 - 0
Script/Haxe/HaxeTest/Resources/Scripts/utils/Loler.js

@@ -0,0 +1,10 @@
+var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};
+var Loler = (function(_super) {
+__extends(Loler, _super);
+function Loler(lol) {
+	if(lol == "lol") console.log("LOL!"); else console.log("NOT LOL :(");
+};
+;
+return Loler;
+})(Object);
+module.exports = Loler;

+ 7 - 0
Script/Haxe/HaxeTest/Resources/Scripts/utils/Loler.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "4ff48ceb13e4836cac13b59d7bae17c0",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 1 - 1
Script/Haxe/HaxeTest/Resources/atomic-haxe.hxproj

@@ -28,7 +28,7 @@
   </build>
   </build>
   <!-- haxelib libraries -->
   <!-- haxelib libraries -->
   <haxelib>
   <haxelib>
-    <!-- example: <library name="..." /> -->
+    <library name="Actuate" />
   </haxelib>
   </haxelib>
   <!-- Class files to compile (other referenced classes will automatically be included) -->
   <!-- Class files to compile (other referenced classes will automatically be included) -->
   <compileTargets>
   <compileTargets>

+ 118 - 52
Script/Haxe/HaxeTest/Resources/atomic/AtomicBuilder.hx

@@ -14,20 +14,88 @@ class AtomicBuilder {
 	var buf: StringBuf;
 	var buf: StringBuf;
 	var inits : List<TypedExpr>;
 	var inits : List<TypedExpr>;
 	var statics : List<{ c : ClassType, f : ClassField }>;
 	var statics : List<{ c : ClassType, f : ClassField }>;
-	var requirements: List<String>;
+	var requirements: Map<String, Array<String>>;
+	var currClass:ClassType;
+	var components:List<ClassType>;
 	
 	
 	function new(api:JSGenApi) {
 	function new(api:JSGenApi) {
 		this.api = api;
 		this.api = api;
 		this.buf = new StringBuf();
 		this.buf = new StringBuf();
 		this.inits = new List();
 		this.inits = new List();
 		this.statics = new List();
 		this.statics = new List();
-		this.requirements = new List();
+		this.requirements = new Map();
+		this.components = new List();
+		api.setTypeAccessor(getType);
 		build();
 		build();
 	}
 	}
 	
 	
+	function getType( t : Type ) {
+		return switch(t) {
+			case TInst(c, _):
+				getPath(c.get());
+			case TEnum(e, _): 
+				getPath(e.get());
+			case TAbstract(a, _): 
+				getPath(a.get());
+			default: throw "assert";
+		};
+	}
+	
+	function getPath( t : BaseType ) {
+		var s:Array<String> = t.module.split(".");
+		if (s[0].toLowerCase() == "atomic") {
+			if (StringTools.startsWith(t.name, "Atomic")) {
+				return t.name;
+			}
+			return "Atomic." + t.name;
+		}
+		//skip to do not require itself
+		if (t.name == currClass.name) return t.name;
+		
+		var mod = t.module.split(".");
+		if (mod[0].toLowerCase() == "scripts") {
+			var n = "";
+			for (pa in mod) {
+				if (mod[0] == pa) {
+					n += pa;
+					continue;
+				}
+				n += "/" + pa;
+			}
+			addReq(n);
+		} else if (mod[0].toLowerCase() == "components") {
+			var n = "";
+			for (pa in mod) {
+				if (mod[0] == pa) {
+					n += pa;
+					continue;
+				}
+				n += "/" + pa;
+			}
+			addReq(n);
+		} else {
+			addReq("Modules/" + t.name);
+		}
+		return t.name;
+	}
+	
+	function addReq(name:String) {
+		if (!requirements.exists(currClass.name)) {
+			requirements.set(currClass.name, new Array());
+		}
+		var arr = requirements.get(currClass.name);
+		for (i in arr) {
+			if (i == name) return;
+		}
+		arr.push(name);
+	}
+
+	
 	function build():Void {
 	function build():Void {
 		for( t in api.types )
 		for( t in api.types )
 			genType(t);
 			genType(t);
+		for (comp in components) 
+			genComponent(comp);
 	}
 	}
 	
 	
 	function genType( t : Type ):Void {
 	function genType( t : Type ):Void {
@@ -48,12 +116,18 @@ class AtomicBuilder {
 	inline function print(str):Void {
 	inline function print(str):Void {
 		buf.add(str);
 		buf.add(str);
 	}
 	}
+	
+	inline function prepend(str):Void {
+		var b = new StringBuf();
+		b.add(str);
+		b.add(buf.toString());
+		buf = b;
+	}
 
 
 	inline function newline():Void {
 	inline function newline():Void {
 		buf.add(";\n");
 		buf.add(";\n");
 	}
 	}
 	
 	
-	//extend function which I took from typescript
 	inline function printExtend__():Void {
 	inline function printExtend__():Void {
 		var str:String = "var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};\n";
 		var str:String = "var __extends = (this && this.__extends) || function (d, b) {for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];function __() { this.constructor = d; };__.prototype = b.prototype;d.prototype = new __();};\n";
 		print(str);
 		print(str);
@@ -65,48 +139,24 @@ class AtomicBuilder {
 	
 	
 	inline function getExpr(e):String {
 	inline function getExpr(e):String {
 		var out = api.generateValue(e);
 		var out = api.generateValue(e);
-		//TODO: properly handle components
-		//I'm renaming it, to avoid components_Star e.g.
-		out = StringTools.replace(out, "atomic.", "");
-		out = StringTools.replace(out, "scripts_", "");
-		out = StringTools.replace(out, "components_", "");
 		return out;
 		return out;
 	}
 	}
 	
 	
-	//TODO: Rethink how to handle imports correctly, because now it's really not a good way
 	//https://github.com/HaxeFoundation/haxe/issues/3560
 	//https://github.com/HaxeFoundation/haxe/issues/3560
 	function checkRequires(c: ClassType):Void {
 	function checkRequires(c: ClassType):Void {
-		requirements.clear();
-		var mets = c.meta.get();
-		
-		for (meta in mets) {
-			if (meta.name == ":require") {
-				for (param in meta.params) {
-					switch(param.expr) {
-						case EConst(CString(s)):
-							requirements.add(s);
-						default:
-					}
-				}
-			}
-		}
-		for (req in requirements) {
-			var name = "";
-			if (req.charAt(0) == 'C') {
-				name = "Components/" + req.substr(1, req.length);
-			}else if (req.charAt(0) == 'S') {
-				name = "Scripts/" + req.substr(1, req.length);		
-			} else if (req.charAt(0) == 'M') {
-				name = "Modules/" + req.substr(1, req.length);
-			}
-			print("var " + req.substr(1, req.length) + " = require(\"" + name + "\");\n");
+		var arr = requirements.get(currClass.name);
+		if (arr == null || arr.length == 0) return;
+		for (req in requirements.get(currClass.name)) {
+			var a = req.split("/");
+			var name = a[a.length - 1];
+			prepend("var " + name + " = require(\"" + req + "\");\n");
 		}
 		}
 	}
 	}
 	
 	
 	function genClass(c:ClassType):Void {
 	function genClass(c:ClassType):Void {
-		if (c.name == "Std") return;
-		if (c.pack[0] == "components") {
-			genComponent(c);
+		//if (c.name == "Std") return;
+		if (c.pack.length > 0 && c.pack[0].toLowerCase() == "components") {
+			components.add(c);
 		} else {
 		} else {
 			genScript(c);
 			genScript(c);
 		}
 		}
@@ -126,11 +176,11 @@ class AtomicBuilder {
 	
 	
 	function genScript(c: ClassType):Void {
 	function genScript(c: ClassType):Void {
 		//If pack length equals 0, so it's probably a haxe's class, so, require a HxOverrides
 		//If pack length equals 0, so it's probably a haxe's class, so, require a HxOverrides
-		if (c.pack.length == 0) {
-			print("var HxOverrides = require(\"./HxOverrides\");\n");
-		}
+		//if (c.pack.length == 0) {
+		//	print("var HxOverrides = require(\"./HxOverrides\");\n");
+		//}
 		api.setCurrentClass(c);
 		api.setCurrentClass(c);
-		checkRequires(c);
+		currClass = c;
 		printExtend__();
 		printExtend__();
 		print("var " + c.name + " = (function(_super) {\n");
 		print("var " + c.name + " = (function(_super) {\n");
 		print("__extends(" + c.name + ", _super);\n");
 		print("__extends(" + c.name + ", _super);\n");
@@ -142,19 +192,26 @@ class AtomicBuilder {
 		}
 		}
 		newline();
 		newline();
 		print("return " + c.name + ";\n");
 		print("return " + c.name + ";\n");
-		print("})(" + (c.superClass == null ? "Object" : c.superClass.t.toString()) +");\n");
-		print("module.exports = " + c.name + ";");
-		
-		var p = c.pack[0] + ("/") + c.name + ".js";
-		//If it's a haxe's class
-		p = StringTools.replace(p, "null", "Modules");
+		print("})(" + (c.superClass == null ? "Object" : getPath(c.superClass.t.get())) +");\n");
+		print("module.exports = " + c.name + ";\n");
+		checkRequires(c);
+		var p = "";
+		//script path
+		if (c.pack.length > 0 && c.pack[0].toLowerCase() == "scripts") {
+			for (pa in c.pack) {
+				p += pa + "/";
+			}
+			p += c.name + ".js";
+		} else {
+			p = "Modules/" + c.name + ".js";
+		}
 		File.saveContent(p, buf.toString());
 		File.saveContent(p, buf.toString());
 		buf = new StringBuf();
 		buf = new StringBuf();
 	}
 	}
 	
 	
 	function genComponent(c: ClassType):Void {
 	function genComponent(c: ClassType):Void {
-		api.setCurrentClass(c);		
-		checkRequires(c);
+		api.setCurrentClass(c);
+		currClass = c;
 		printExtend__();
 		printExtend__();
 		print("\"atomic component\"");
 		print("\"atomic component\"");
 		newline();
 		newline();
@@ -168,9 +225,14 @@ class AtomicBuilder {
 		}
 		}
 		newline();
 		newline();
 		print("return " + c.name + ";\n");
 		print("return " + c.name + ";\n");
-		print("})(" + (c.superClass == null ? "Object" : StringTools.replace(c.superClass.t.toString(), "components.", "")) +");\n");
-		print("module.exports = " + c.name + ";");
-		var p = c.pack[0] + ("/") + c.name + ".js";
+		print("})(" + (c.superClass == null ? "Object" : getPath(c.superClass.t.get())) +");\n");
+		print("module.exports = " + getPath(c) + ";\n");
+		checkRequires(c);
+		var p = "";
+		for (pa in c.pack) {
+			p += pa + "/";
+		}
+		p += c.name + ".js";
 		File.saveContent(p, buf.toString());
 		File.saveContent(p, buf.toString());
 		buf = new StringBuf();
 		buf = new StringBuf();
 	}
 	}
@@ -179,7 +241,7 @@ class AtomicBuilder {
 		var field = f.name;
 		var field = f.name;
 		var e = f.expr();
 		var e = f.expr();
 		if( e == null ) {
 		if( e == null ) {
-			print('NULL :(');
+			print("null");
 			newline();
 			newline();
 		} else switch( f.kind ) {
 		} else switch( f.kind ) {
 		case FMethod(_):
 		case FMethod(_):
@@ -190,6 +252,10 @@ class AtomicBuilder {
 				genExpr(api.main);
 				genExpr(api.main);
 			}
 			}
 			newline();
 			newline();
+		case FVar(r, w):
+			print(c.name + '.$field = ');
+			genExpr(e);
+			newline();
 		default:
 		default:
 			statics.add( { c : c, f : f } );
 			statics.add( { c : c, f : f } );
 		}
 		}

+ 1 - 0
Script/Haxe/HaxeTest/Resources/build.hxml

@@ -1,5 +1,6 @@
 -js out/main.js
 -js out/main.js
 -cp .
 -cp .
 -main scripts.Main
 -main scripts.Main
+-lib Actuate
 --macro atomic.AtomicBuilder.use()
 --macro atomic.AtomicBuilder.use()
 #-cmd "C:/Users/rsred/Documents/GitHub/AtomicGameEngine-build/Source/AtomicEditor/Debug/AtomicEditor.exe --player --project C:\Users\rsred\Documents\AtomicProjects\HaxeTest1 --log-std"
 #-cmd "C:/Users/rsred/Documents/GitHub/AtomicGameEngine-build/Source/AtomicEditor/Debug/AtomicEditor.exe --player --project C:\Users\rsred\Documents\AtomicProjects\HaxeTest1 --log-std"