Skip to content

Commit

Permalink
Merge pull request nadako#3 from firefalcom/feature/haxe4
Browse files Browse the repository at this point in the history
Haxe4 support
  • Loading branch information
gogoprog authored Nov 13, 2020
2 parents 51c87ee + 70086f1 commit 8314400
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
28 changes: 22 additions & 6 deletions src/ash/ClassMap.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ash;

import haxe.ds.StringMap;
import haxe.Constraints;

class ClassMap<K:Class<Dynamic>, V> implements Map.IMap<K, V>
class ClassMap<K:Class<Dynamic>, V> implements haxe.IMap<K, V>
{
var valueMap:StringMap<V> = new StringMap<V>(); // class name to value
var keyMap:StringMap<K> = new StringMap<K>(); // class name to class
Expand All @@ -18,8 +19,8 @@ class ClassMap<K:Class<Dynamic>, V> implements Map.IMap<K, V>

public inline function set(k:K, v:V):Void
{
var name:String = Type.getClassName(k);
keyMap.set(name, k);
var name:String = Type.getClassName(k);
keyMap.set(name, k);
valueMap.set(name, v);
}

Expand All @@ -30,14 +31,14 @@ class ClassMap<K:Class<Dynamic>, V> implements Map.IMap<K, V>

public inline function remove(k:K):Bool
{
var name:String = Type.getClassName(k);
keyMap.remove(name);
var name:String = Type.getClassName(k);
keyMap.remove(name);
return valueMap.remove(name);
}

public inline function keys():Iterator<K>
{
return keyMap.iterator();
return keyMap.iterator();
}

public inline function iterator():Iterator<V>
Expand All @@ -49,4 +50,19 @@ class ClassMap<K:Class<Dynamic>, V> implements Map.IMap<K, V>
{
return valueMap.toString();
}

public inline function clear():Void {
valueMap.clear();
keyMap.clear();
}

public inline function copy():haxe.IMap<K, V>
{
throw ":TODO:";
}

public inline function keyValueIterator():KeyValueIterator<K, V>
{
throw ":TODO:";
}
}
4 changes: 2 additions & 2 deletions src/ash/core/Engine.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import ash.signals.Signal1;
*/
class Engine
{
public var entities(get_entities, never):Iterable<Entity>;
public var systems(get_systems, never):Iterable<System>;
public var entities(get, never):Iterable<Entity>;
public var systems(get, never):Iterable<System>;

private var entityNames:Map<String, Entity>;
private var entityList:EntityList;
Expand Down
2 changes: 1 addition & 1 deletion src/ash/core/Entity.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Entity
/**
* Optional, give the entity a name. This can help with debugging and with serialising the entity.
*/
public var name(default, set_name):String;
public var name(default, set):String;
/**
* This signal is dispatched when a component is added to the entity.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ash/core/NodeList.hx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class NodeList<TNode:Node<TNode>>
/**
* true if the list is empty, false otherwise.
*/
public var empty(get_empty, never):Bool;
public var empty(get, never):Bool;

private inline function get_empty():Bool
{
Expand Down

0 comments on commit 8314400

Please sign in to comment.