Permalink
Browse files

some tweaks to compile with NME client

  • Loading branch information...
1 parent 125939a commit c89d66563d543d834511be2187881e39fb03bd11 @cloudshift committed May 25, 2012
Showing with 32 additions and 5 deletions.
  1. +2 −2 cloudshift/Core.hx
  2. +20 −0 cloudshift/Mixin.hx
  3. +2 −1 cloudshift/Sys.hx
  4. +6 −1 cloudshift/core/LogImpl.hx
  5. +2 −1 cloudshift/http/RemoteImpl.hx
View
4 cloudshift/Core.hx
@@ -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
View
20 cloudshift/Mixin.hx
@@ -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
}
}
@@ -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
@@ -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
}
View
3 cloudshift/Sys.hx
@@ -32,7 +32,8 @@ enum SysWriteStreamEvents {
enum SysReadStreamEvents {
Data(d:String);
Error(e:String);
- End;
+
+ End;
Close;
Fd;
}
View
7 cloudshift/core/LogImpl.hx
@@ -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":
@@ -69,6 +73,7 @@ class LogImpl {
default:
untyped __js__("console.log(msg)");
}
+ #end
}
#end
View
3 cloudshift/http/RemoteImpl.hx
@@ -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) {

0 comments on commit c89d665

Please sign in to comment.