Skip to content

Commit

Permalink
some tweaks to compile with NME client
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudshift committed May 25, 2012
1 parent 125939a commit c89d665
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cloudshift/Core.hx
Expand Up @@ -183,12 +183,12 @@ class Core {

public static function
parse(str:String):Dynamic {
return untyped __js__("JSON.parse(str)");
return haxe.Json.parse(str);
}

public static function
stringify(obj:Dynamic):String {
return untyped __js__("JSON.stringify(obj)");
return haxe.Json.stringify(obj);
}

public static
Expand Down
20 changes: 20 additions & 0 deletions cloudshift/Mixin.hx
Expand Up @@ -33,7 +33,11 @@ class DynamicX {

public static function
stringify(o:Dynamic):String {
#if js
return untyped __js__("JSON.stringify(o)");
#else
return Std.string(o);
#end
}

}
Expand Down Expand Up @@ -186,12 +190,20 @@ class StringX {

public static function
parse(str:String):Dynamic {
#if js
return untyped __js__("JSON.parse(str)");
#else
return haxe.Json.parse(str);
#end
}

public static inline function
clone(o:Dynamic):Dynamic {
#if js
return untyped __js__("JSON.parse(JSON.stringify(o))");
#else
return haxe.Json.parse(haxe.Json.stringify(o));
#end
}

inline static public function
Expand Down Expand Up @@ -225,15 +237,23 @@ class DateX {
}

public static function UTCString(d:Date) : String {
#if js
return untyped __js__("d.toUTCString()");
#else
return Std.string(d);
#end
}
}

class ArrayX {

public static function
stringify<T>(a:Array<T>):String {
#if js
return untyped __js__("JSON.stringify(o)");
#else
return Std.string(a);
#end
}


Expand Down
3 changes: 2 additions & 1 deletion cloudshift/Sys.hx
Expand Up @@ -32,7 +32,8 @@ enum SysWriteStreamEvents {
enum SysReadStreamEvents {
Data(d:String);
Error(e:String);
End;

End;
Close;
Fd;
}
Expand Down
7 changes: 6 additions & 1 deletion cloudshift/core/LogImpl.hx
Expand Up @@ -47,15 +47,19 @@ class LogImpl {
var b = new NodeBuffer(msg+"\n",NodeC.UTF8);
Node.fs.write(logFileFD,b,0,b.length,null);
}
else
else {
#if js
untyped __js__("console.log(msg)");
#end
}
}
}

#else

static function
write(msg,type) {
#if js
if (msg != null)
switch(type) {
case "info":
Expand All @@ -69,6 +73,7 @@ class LogImpl {
default:
untyped __js__("console.log(msg)");
}
#end
}

#end
Expand Down
3 changes: 2 additions & 1 deletion cloudshift/http/RemoteImpl.hx
Expand Up @@ -12,7 +12,8 @@ class RemoteImpl extends Context, implements RemoteProvider {
public function
httpHandler(re:EReg,req:NodeHttpServerReq,resp:NodeHttpServerResp) {
if(Reflect.field(req.headers,"x-haxe-remoting") == null){
resp.end("bad request");
resp.end("bad remoting request");
return;
}

HttpImpl.parseFields(req,function(flds,optFiles) {
Expand Down

0 comments on commit c89d665

Please sign in to comment.