shithub: libmujs

Download patch

ref: e7e1e0de9ce6a17e020f3267ba2175779395b2c3
parent: c67ca523aa2331728ef77ef25b31f4f37389941f
author: Tor Andersson <tor@ccxvii.net>
date: Tue Feb 25 15:43:14 EST 2014

Build on MSVC 2005.

--- a/js.h
+++ b/js.h
@@ -76,8 +76,8 @@
 void js_loadstring(js_State *J, const char *filename, const char *source);
 void js_loadfile(js_State *J, const char *filename);
 
-void js_call(js_State *J, unsigned int n);
-void js_construct(js_State *J, unsigned int n);
+void js_call(js_State *J, int n);
+void js_construct(js_State *J, int n);
 
 const char *js_ref(js_State *J);
 void js_unref(js_State *J, const char *ref);
--- a/jscompile.c
+++ b/jscompile.c
@@ -6,7 +6,7 @@
 
 #define JF js_State *J, js_Function *F
 
-JS_NORETURN int jsC_error(js_State *J, js_Ast *node, const char *fmt, ...) JS_PRINTFLIKE(3,4);
+JS_NORETURN void jsC_error(js_State *J, js_Ast *node, const char *fmt, ...) JS_PRINTFLIKE(3,4);
 
 static void cfunbody(JF, js_Ast *name, js_Ast *params, js_Ast *body);
 static void cexp(JF, js_Ast *exp);
@@ -13,7 +13,7 @@
 static void cstmlist(JF, js_Ast *list);
 static void cstm(JF, js_Ast *stm);
 
-int jsC_error(js_State *J, js_Ast *node, const char *fmt, ...)
+void jsC_error(js_State *J, js_Ast *node, const char *fmt, ...)
 {
 	va_list ap;
 	char buf[512];
--- a/jsi.h
+++ b/jsi.h
@@ -12,10 +12,19 @@
 #include <math.h>
 #include <float.h>
 
-#ifdef _WIN32
+#ifdef _MSC_VER
+#pragma warning(disable:4996) /* _CRT_SECURE_NO_WARNINGS */
+#pragma warning(disable:4244) /* implicit conversion from double to int */
+#pragma warning(disable:4267) /* implicit conversion of int to smaller int */
 #define inline __inline
 #define snprintf _snprintf
 #define vsnprintf _vsnprintf
+#define round(x) floor((x) < 0 ? (x) - 0.5 : (x) + 0.5)
+#define isnan(x) _isnan(x)
+#define isinf(x) (!_finite(x))
+#define isfinite(x) _finite(x)
+#define INFINITY (DBL_MAX+DBL_MAX)
+#define NAN (INFINITY-INFINITY)
 #endif
 
 typedef struct js_Regexp js_Regexp;
--- a/jsrun.c
+++ b/jsrun.c
@@ -854,15 +854,15 @@
 	js_pushvalue(J, v);
 }
 
-void js_call(js_State *J, unsigned int n)
+void js_call(js_State *J, int n)
 {
 	js_Object *obj;
 	int savebot;
 
-	if (!js_iscallable(J, -n - 2))
+	if (!js_iscallable(J, -n-2))
 		js_typeerror(J, "called object is not a function");
 
-	obj = js_toobject(J, -n - 2);
+	obj = js_toobject(J, -n-2);
 
 	savebot = BOT;
 	BOT = TOP - n - 1;
@@ -880,16 +880,16 @@
 	BOT = savebot;
 }
 
-void js_construct(js_State *J, unsigned int n)
+void js_construct(js_State *J, int n)
 {
 	js_Object *obj;
 	js_Object *prototype;
 	js_Object *newobj;
 
-	if (!js_iscallable(J, -n - 1))
+	if (!js_iscallable(J, -n-1))
 		js_typeerror(J, "called object is not a function");
 
-	obj = js_toobject(J, -n - 1);
+	obj = js_toobject(J, -n-1);
 
 	/* built-in constructors create their own objects, give them a 'null' this */
 	if (obj->type == JS_CCFUNCTION && obj->u.c.constructor) {