consts and set
This commit is contained in:
8
haxework/core/Const.hx
Executable file
8
haxework/core/Const.hx
Executable file
@@ -0,0 +1,8 @@
|
||||
package haxework.core;
|
||||
|
||||
class Const {
|
||||
public static var UINT_MAX_VALUE:UInt = untyped __global__["uint"].MAX_VALUE;
|
||||
public static var UINT_MIN_VALUE:UInt = untyped __global__["uint"].MIN_VALUE;
|
||||
public static var INT_MAX_VALUE:Int = untyped __global__["int"].MAX_VALUE;
|
||||
public static var INT_MIN_VALUE:Int = untyped __global__["int"].MIN_VALUE;
|
||||
}
|
||||
31
haxework/core/Set.hx
Executable file
31
haxework/core/Set.hx
Executable file
@@ -0,0 +1,31 @@
|
||||
package haxework.core;
|
||||
|
||||
import haxe.ds.ObjectMap;
|
||||
import Map.IMap;
|
||||
|
||||
class Set<T:{}> {
|
||||
|
||||
private static var O:Dynamic = {};
|
||||
|
||||
private var map:ObjectMap<T, Dynamic>;
|
||||
|
||||
public function new() {
|
||||
map = new ObjectMap<T, Dynamic>();
|
||||
}
|
||||
|
||||
public inline function iterator():Iterator<T> {
|
||||
return map.keys();
|
||||
}
|
||||
|
||||
public inline function set(value:T):Void {
|
||||
map.set(value, O);
|
||||
}
|
||||
|
||||
public inline function exists(value:T):Bool {
|
||||
return map.exists(value);
|
||||
}
|
||||
|
||||
public inline inline function remove(value:T):Bool {
|
||||
return map.remove(value);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package haxework.log;
|
||||
|
||||
import flash.errors.Error;
|
||||
import haxework.log.ILogger.LogLevel;
|
||||
|
||||
class BaseLogger implements ILogger {
|
||||
@@ -7,10 +8,18 @@ class BaseLogger implements ILogger {
|
||||
public function new() {}
|
||||
|
||||
public function log(level:LogLevel, tag:String, message:String, ?error:Dynamic, ?p:haxe.PosInfos):Void {
|
||||
var s:String = "[" + level + "] " + tag + " - " + message + (error == null ? "" : " {" + Std.string(error) + "}");
|
||||
var s:String = "[" + level + "] " + tag + " - " + message + (error == null ? "" : " {" + error2strign(error) + "}");
|
||||
write(s, p);
|
||||
}
|
||||
|
||||
private function error2strign(error:Dynamic):String {
|
||||
return if (Std.is(error, Error)) {
|
||||
cast(error, Error).getStackTrace();
|
||||
} else {
|
||||
Std.string(error);
|
||||
}
|
||||
}
|
||||
|
||||
private function write(text:String, ?p:haxe.PosInfos):Void {}
|
||||
|
||||
public function d(tag:String, message:String, ?error:Dynamic, ?p:haxe.PosInfos):Void {
|
||||
|
||||
@@ -9,6 +9,7 @@ import haxework.net.ILoader.Method;
|
||||
class BaseLoader<T> implements ILoader<T> {
|
||||
|
||||
public static var urlProcessors(default, null):Array<String->String> = new Array<String->String>();
|
||||
public static function prepareUrl(url:String):String { for (p in urlProcessors) url = p(url); return url; };
|
||||
|
||||
|
||||
public var busy(default, null):Bool;
|
||||
@@ -27,8 +28,7 @@ class BaseLoader<T> implements ILoader<T> {
|
||||
this.data = data;
|
||||
callback = new Callback<T>();
|
||||
var url:String = this.url;
|
||||
for (p in urlProcessors) url = p(url);
|
||||
internalRequest(url);
|
||||
internalRequest(prepareUrl(url));
|
||||
return callback;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user