Bläddra i källkod

Fixes to compile on wince, not yet complete.

mingodad 13 år sedan
förälder
incheckning
df5667554f

+ 22 - 12
SquiLu/include/squirrel.h

@@ -122,19 +122,30 @@ struct SQOuter;
 #define wchar_t unsigned short
 #endif
 
-#else
-typedef unsigned short wchar_t;
+#else
+#ifndef _WIN32_WCE
+typedef unsigned short wchar_t;
+#endif
 #endif
 
 typedef wchar_t SQChar;
 typedef wchar_t USQChar;
 #define uchar(c)    ((unsigned short)(c))
 #define _SC(a) L##a
-#define scstrchr wcschr
+#define scstrchr wcschr
+#ifdef _WIN32_WCE
+#define scsnprintf _snwprintf
+#define scvfprintf	_vfwprintf
+#define scvsprintf	_vswprintf
+#define scvsnprintf	_vsnwprintf
+#else
 #define scsnprintf wsnprintf
+#define scvfprintf	vfwprintf
+#define scvsprintf	vswprintf
+#define scvsnprintf	vswnprintf
+#endif
 #define	scstrcmp	wcscmp
 #define scsprintf	swprintf
-#define scsnprintf	swnprintf
 #define scstrlen	wcslen
 #define scstrtod	wcstod
 #ifdef _SQ64
@@ -144,10 +155,8 @@ typedef wchar_t USQChar;
 #endif
 #define scatoi		_wtoi
 #define scstrtoul	wcstoul
-#define scvfprintf	vfwprintf
-#define scvsprintf	vswprintf
-#define scvsnprintf	vswnprintf
-#define scstrstr	wcsstr
+#define scstrstr	wcsstr
+#define scstrpbrk	wcspbrk
 #define scisspace	iswspace
 #define scisdigit	iswdigit
 #define scisxdigit	iswxdigit
@@ -161,11 +170,10 @@ typedef char SQChar;
 typedef unsigned char USQChar;
 #define uchar(c)    ((unsigned char)(c))
 #define _SC(a) a
-#define scstrchr strchr
+#define scstrchr strchr
 #define scsnprintf snprintf
 #define	scstrcmp	strcmp
 #define scsprintf	sprintf
-#define scsnprintf	snprintf
 #define scstrlen	strlen
 #define scstrtod	strtod
 #ifdef _SQ64
@@ -182,7 +190,9 @@ typedef unsigned char USQChar;
 #define scvfprintf	vfprintf
 #define scvsprintf	vsprintf
 #define scvsnprintf	vsnprintf
-#define scstrstr	strstr
+#define scstrstr	strstr
+#define scstrpbrk	strpbrk
+#define scstrtok strtok
 #define scisspace	isspace
 #define scisdigit	isdigit
 #define scisxdigit	isxdigit
@@ -580,7 +590,7 @@ SQUIRREL_API void sq_getlaststackinfo(HSQUIRRELVM v);
     SQInteger var##_size;\
     if((_rc_ = sq_getstr_and_size(v,idx, &var, &var##_size)) < 0) return _rc_;
 
-#define SQ_OPT_STRING_STRLEN() static inline size_t sq_opt_strlen(const char *v) {return v ? scstrlen(v) : 0;}
+#define SQ_OPT_STRING_STRLEN() static inline size_t sq_opt_strlen(const SQChar *v) {return v ? scstrlen(v) : 0;}
 
 #define SQ_OPT_STRING(v, idx, var, dflt)\
     const SQChar *var;\

+ 5 - 3
SquiLu/sq/sq.c

@@ -110,9 +110,11 @@ void PrintUsage()
 int getargs(HSQUIRRELVM v,int argc, char* argv[],SQInteger *retval)
 {
 	int compiles_only = 0;
-	int compiles_as_source_only = 0;
-	//static SQChar temp[500];
-	//const SQChar *ret=NULL;
+	int compiles_as_source_only = 0;
+#ifdef SQUNICODE
+	static SQChar temp[500];
+	//const SQChar *ret=NULL;
+#endif
 	char * output = NULL;
 	//int lineinfo=0;
 	*retval = 0;

+ 2 - 2
SquiLu/sqstdlib/sqstdio.cpp

@@ -417,7 +417,7 @@ SQInteger _g_io_dumpclosure(HSQUIRRELVM v)
 SQInteger blob_read(SQUserPointer file,SQUserPointer p,SQInteger size);
 SQInteger _g_io_loadstring(HSQUIRRELVM v)
 {
-    if(sq_gettype(v, 2) != OT_STRING) return sq_throwerror(v, "string expected as parameter");
+    if(sq_gettype(v, 2) != OT_STRING) return sq_throwerror(v, _SC("string expected as parameter"));
     SQInteger rc, size = sq_getsize(v, 2);
     const SQChar *dump;
     sq_getstring(v, 2, &dump);
@@ -430,7 +430,7 @@ SQInteger _g_io_loadstring(HSQUIRRELVM v)
     }
     else
     {
-        rc = sq_compilebuffer(v, dump, size, "loadstring", SQFalse, SQFalse);
+        rc = sq_compilebuffer(v, dump, size, _SC("loadstring"), SQFalse, SQFalse);
     }
 	return rc < 0 ? rc : 1;
 }

+ 11 - 11
SquiLu/sqstdlib/sqstdmath.cpp

@@ -89,7 +89,7 @@ static SQRESULT math_roundf (HSQUIRRELVM v) {
   SQ_GET_FLOAT(v, 2, x);
   SQ_OPT_INTEGER(v, 3, dec_places, 0);
   SQFloat dec_factor;
-  if( dec_places>15 || dec_places<0 ) return sq_throwerror(v, "decimal places out of range 0-15");
+  if( dec_places>15 || dec_places<0 ) return sq_throwerror(v, _SC("decimal places out of range 0-15"));
   switch(dec_places){
 	case 0: dec_factor = 1.0; break;
 	case 1: dec_factor = 10.0; break;
@@ -114,7 +114,7 @@ static SQRESULT math_broundf (HSQUIRRELVM v) {
   SQ_OPT_INTEGER(v, 3, dec_places, 0);
   SQFloat dec_factor, tmp, itmp;
   int neg;
-  if( dec_places>15 || dec_places<0 ) return sq_throwerror(v, "decimal places out of range 0-15");
+  if( dec_places>15 || dec_places<0 ) return sq_throwerror(v, _SC("decimal places out of range 0-15"));
   neg = num < 0;
   switch(dec_places){
 	case 0: dec_factor = 1.0; break;
@@ -142,8 +142,8 @@ static SQRESULT math_broundf (HSQUIRRELVM v) {
   return 1;
 }
 
-static char math_number_format_dec_point[2] = ".";
-static char math_number_format_thousand_sep[2] = ",";
+static SQChar math_number_format_dec_point[2] = _SC(".");
+static SQChar math_number_format_thousand_sep[2] = _SC(",");
 
 static SQRESULT math_number_format_get_dec_point(HSQUIRRELVM v) {
 	sq_pushstring(v, math_number_format_dec_point, -1);
@@ -154,7 +154,7 @@ static SQRESULT math_number_format_set_dec_point(HSQUIRRELVM v) {
     SQ_FUNC_VARS_NO_TOP(v);
     SQ_GET_STRING(v, 2, dec_point);
 	math_number_format_dec_point[0] = *dec_point;
-	math_number_format_dec_point[1] = '\0';
+	math_number_format_dec_point[1] = _SC('\0');
 	return 0;
 }
 
@@ -177,9 +177,9 @@ static SQRESULT math_number_format(HSQUIRRELVM v) {
     SQ_OPT_INTEGER(v, 3, dec, 2);
     SQ_OPT_STRING(v, 4, dec_point, math_number_format_dec_point);
     SQ_OPT_STRING(v, 5, thousand_sep, math_number_format_thousand_sep);
-	char tmpbuf[64], resbuf[64];
-	char *s, *t;  /* source, target */
-	char *dp;
+	SQChar tmpbuf[64], resbuf[64];
+	SQChar *s, *t;  /* source, target */
+	SQChar *dp;
 	int integral;
 	size_t tmplen, reslen=0;
 	int count=0;
@@ -197,15 +197,15 @@ static SQRESULT math_number_format(HSQUIRRELVM v) {
 	}
 
     int idec = dec; //on 64 bits there is a warning here about SQInteger/int
-	tmplen = scsnprintf(tmpbuf, sizeof(tmpbuf), "%.*f", idec, d);
+	tmplen = scsnprintf(tmpbuf, sizeof(tmpbuf), _SC("%.*f"), idec, d);
 
-	resbuf[0] = '\0';
+	resbuf[0] = _SC('\0');
 
 	if (isdigit((int)tmpbuf[0])) {
 
 		/* find decimal point, if expected */
 		if (dec) {
-			dp = strpbrk(tmpbuf, ".,");
+			dp = scstrpbrk(tmpbuf, _SC(".,"));
 		} else {
 			dp = NULL;
 		}

+ 43 - 36
SquiLu/sqstdlib/sqstdstring.cpp

@@ -4,9 +4,16 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <assert.h>
-#include <stddef.h>
+#include <stddef.h>
+
+#ifdef _WIN32_WCE
+extern "C" {
+int _wtoi (const wchar_t *);
+}
+#endif // _WINCE
 
 #define MAX_FORMAT_LEN	20
 #define MAX_WFORMAT_LEN	3
@@ -17,7 +24,7 @@ static SQRESULT validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, S
 	SQChar swidth[MAX_WFORMAT_LEN];
 	SQInteger wc = 0;
 	SQInteger start = n;
-	fmt[0] = '%';
+	fmt[0] = _SC('%');
 	while (scstrchr(_SC("-+ #0"), src[n])) n++;
 	while (scisdigit(src[n])) {
 		swidth[wc] = src[n];
@@ -26,13 +33,13 @@ static SQRESULT validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, S
 		if(wc>=MAX_WFORMAT_LEN)
 			return sq_throwerror(v,_SC("width format too long"));
 	}
-	swidth[wc] = '\0';
+	swidth[wc] = _SC('\0');
 	if(wc > 0) {
 		width = scatoi(swidth);
 	}
 	else
 		width = 0;
-	if (src[n] == '.') {
+	if (src[n] == _SC('.')) {
 	    n++;
 
 		wc = 0;
@@ -43,7 +50,7 @@ static SQRESULT validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, S
 			if(wc>=MAX_WFORMAT_LEN)
 				return sq_throwerror(v,_SC("precision format too long"));
 		}
-		swidth[wc] = '\0';
+		swidth[wc] = _SC('\0');
 		if(wc > 0) {
 			width += scatoi(swidth);
 		}
@@ -51,7 +58,7 @@ static SQRESULT validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, S
 	if (n-start > MAX_FORMAT_LEN )
 		return sq_throwerror(v,_SC("format too long"));
 	memcpy(&fmt[1],&src[start],((n-start)+1)*sizeof(SQChar));
-	fmt[(n-start)+2] = '\0';
+	fmt[(n-start)+2] = _SC('\0');
 	return n;
 }
 
@@ -66,13 +73,13 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
 	dest = sq_getscratchpad(v,allocated);
 	SQInteger n = 0,i = 0, nparam = nformatstringidx+1, w = 0;
 	while(n < format_size) {
-		if(format[n] != '%') {
+		if(format[n] != _SC('%')) {
 			assert(i < allocated);
 			dest[i++] = format[n];
 			n++;
 		}
-		else if(format[n+1] == '%') { //handles %%
-				dest[i++] = '%';
+		else if(format[n+1] == _SC('%')) { //handles %%
+				dest[i++] = _SC('%');
 				n += 2;
 		}
 		else {
@@ -88,26 +95,26 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
 			SQFloat tf;
 			SQInteger fc = format[n];
 			switch(fc) {
-            case 'q':
-			case 's':
+            case _SC('q'):
+			case _SC('s'):
 				if(SQ_FAILED(sq_getstring(v,nparam,&ts)))
 					return sq_throwerror(v,_SC("string expected for the specified format"));
-                if(fc == 'q'){
+                if(fc == _SC('q')){
                     addlen = 2; //quotes before and after
                     SQInteger size = sq_getsize(v,nparam);
                     SQChar *ts2 = (SQChar*)ts;
                       while (size--) {
                         ++addlen;
-                        if (*ts2 == '\r' && *(ts2+1) == '\n' ) {
+                        if (*ts2 == _SC('\r') && *(ts2+1) == _SC('\n') ) {
                           ++addlen;
                           ++ts2; //eat \r and output only \n
                         }
-                        else if (*ts2 == '"' || *ts2 == '\\' || *ts2 == '\n') {
+                        else if (*ts2 == _SC('"') || *ts2 == _SC('\\') || *ts2 == _SC('\n')) {
                           ++addlen;
                         }
-                        else if (*ts2 == '\0' || iscntrl(uchar(*ts2))) {
+                        else if (*ts2 == _SC('\0') || iscntrl(uchar(*ts2))) {
                           SQChar buff[10];
-                          addlen += scsprintf(buff, "\\x%x", (int)uchar(*ts2))-1; //-1 because we already added the original char to the sum
+                          addlen += scsprintf(buff, _SC("\\x%x"), (int)uchar(*ts2))-1; //-1 because we already added the original char to the sum
                         }
                         ++ts2;
                       }
@@ -119,30 +126,30 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
                       size = sq_getsize(v,nparam);
 
                       ts2 = &dest[(ptrdiff_t)ts2]; //use saved i position saved on pointer as integer
-                      *ts2++ = '"';
+                      *ts2++ = _SC('"');
                       while (size--) {
-                        if (*ts == '\r' && *(ts+1) == '\n' ) {
+                        if (*ts == _SC('\r') && *(ts+1) == _SC('\n') ) {
                           ++ts; //eat \r and output only \n
                         }
-                        if (*ts == '"' || *ts == '\\') {
-                            *ts2++ = '\\';
+                        if (*ts == _SC('"') || *ts == _SC('\\')) {
+                            *ts2++ = _SC('\\');
                             *ts2++ = *ts;
                         }
-                        else if (*ts == '\n') {
-                            *ts2++ = '\\';
-                            *ts2++ = 'n';
+                        else if (*ts == _SC('\n')) {
+                            *ts2++ = _SC('\\');
+                            *ts2++ = _SC('n');
                         }
-                        else if (*ts == '\0' || iscntrl(uchar(*ts))) {
+                        else if (*ts == _SC('\0') || iscntrl(uchar(*ts))) {
                           SQChar buff[10];
                           int iw;
-                          iw = scsprintf(buff, "\\x%x", (int)uchar(*ts));
+                          iw = scsprintf(buff, _SC("\\x%x"), (int)uchar(*ts));
                           for(int i=0; i< iw; ++i) *ts2++ = buff[i];
                         }
                         else
                             *ts2++ = *ts;
                         ++ts;
                       }
-                      *ts2++ = '"';
+                      *ts2++ = _SC('"');
 
                       ++n;
                       ++nparam;
@@ -151,10 +158,10 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
                 else
                 {
                     addlen = (sq_getsize(v,nparam)*sizeof(SQChar))+((w+1)*sizeof(SQChar));
-                    valtype = 's';
+                    valtype = _SC('s');
                 }
 				break;
-			case 'i': case 'd': case 'o': case 'u':  case 'x':  case 'X':
+			case _SC('i'): case _SC('d'): case _SC('o'): case _SC('u'):  case _SC('x'):  case _SC('X'):
 #ifdef _SQ64
 				{
 				size_t flen = scstrlen(fmt);
@@ -168,17 +175,17 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
 				fmt[fpos++] = _SC('\0');
 				}
 #endif
-			case 'c':
+			case _SC('c'):
 				if(SQ_FAILED(sq_getinteger(v,nparam,&ti)))
 					return sq_throwerror(v,_SC("integer expected for the specified format"));
 				addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar));
-				valtype = 'i';
+				valtype = _SC('i');
 				break;
-			case 'f': case 'g': case 'G': case 'e':  case 'E':
+			case _SC('f'): case _SC('g'): case _SC('G'): case _SC('e'):  case _SC('E'):
 				if(SQ_FAILED(sq_getfloat(v,nparam,&tf)))
 					return sq_throwerror(v,_SC("float expected for the specified format"));
 				addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar));
-				valtype = 'f';
+				valtype = _SC('f');
 				break;
 			default:
 				return sq_throwerror(v,_SC("invalid format"));
@@ -187,15 +194,15 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
 			allocated += addlen + sizeof(SQChar);
 			dest = sq_getscratchpad(v,allocated);
 			switch(valtype) {
-			case 's': i += scsprintf(&dest[i],fmt,ts); break;
-			case 'i': i += scsprintf(&dest[i],fmt,ti); break;
-			case 'f': i += scsprintf(&dest[i],fmt,tf); break;
+			case _SC('s'): i += scsprintf(&dest[i],fmt,ts); break;
+			case _SC('i'): i += scsprintf(&dest[i],fmt,ti); break;
+			case _SC('f'): i += scsprintf(&dest[i],fmt,tf); break;
 			};
 			nparam ++;
 		}
 	}
 	*outlen = i;
-	dest[i] = '\0';
+	dest[i] = _SC('\0');
 	*output = dest;
 	return SQ_OK;
 }

+ 34 - 23
SquiLu/sqstdlib/sqstdsystem.cpp

@@ -5,7 +5,9 @@
 #include <time.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <signal.h>
+#ifndef _WIN32_WCE
+#include <signal.h>
+#endif
 #include <sqstdsystem.h>
 
 #ifdef _WIN32
@@ -30,7 +32,8 @@
 #endif
 
 SQ_OPT_STRING_STRLEN();
-
+
+#ifndef _WIN32_WCE
 static SQRESULT _system_getenv(HSQUIRRELVM v)
 {
 	const SQChar *s;
@@ -41,7 +44,6 @@ static SQRESULT _system_getenv(HSQUIRRELVM v)
 	return 0;
 }
 
-
 static SQRESULT _system_system(HSQUIRRELVM v)
 {
 	const SQChar *s;
@@ -58,6 +60,7 @@ static SQRESULT _system_clock(HSQUIRRELVM v)
 	sq_pushfloat(v,((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC);
 	return 1;
 }
+#endif
 
 /*
 static SQRESULT _system_time(HSQUIRRELVM v)
@@ -95,27 +98,27 @@ static SQRESULT _system_time(HSQUIRRELVM v) {
     if(sq_gettype(v, 2) != OT_TABLE)
         return sq_throwerror(v, _SC("table expected as parameter but got (%s)"), sq_gettypename(v, 2));
     sq_settop(v, 2);  /* make sure table is at the top */
-    SQInteger rc = get_int_field(v, "sec", 0);
+    SQInteger rc = get_int_field(v, _SC("sec"), 0);
     if(rc == SQ_ERROR) return rc;
     else ts.tm_sec = rc;
 
-    rc = get_int_field(v, "min", 0);
+    rc = get_int_field(v, _SC("min"), 0);
     if(rc == SQ_ERROR) return rc;
     else ts.tm_min = rc;
 
-    rc = get_int_field(v, "hour", 12);
+    rc = get_int_field(v, _SC("hour"), 12);
     if(rc == SQ_ERROR) return rc;
     else ts.tm_hour = rc;
 
-    rc = get_int_field(v, "day", -1);
+    rc = get_int_field(v, _SC("day"), -1);
     if(rc == SQ_ERROR) return rc;
     else ts.tm_mday = rc;
 
-    rc = get_int_field(v, "month", -1);
+    rc = get_int_field(v, _SC("month"), -1);
     if(rc == SQ_ERROR) return rc;
     else ts.tm_mon = rc;
 
-    rc = get_int_field(v, "year", -1);
+    rc = get_int_field(v, _SC("year"), -1);
     if(rc == SQ_ERROR) return rc;
     else ts.tm_year = rc - 1900;
 
@@ -145,6 +148,7 @@ static SQRESULT _system_difftime (HSQUIRRELVM v) {
   return 1;
 }
 
+#ifndef _WIN32_WCE
 static SQRESULT _system_remove(HSQUIRRELVM v)
 {
 	const SQChar *s;
@@ -153,7 +157,7 @@ static SQRESULT _system_remove(HSQUIRRELVM v)
 		return sq_throwerror(v,_SC("remove() failed"));
 	return 0;
 }
-
+
 static SQRESULT _system_rename(HSQUIRRELVM v)
 {
 	const SQChar *oldn,*newn;
@@ -220,6 +224,7 @@ static SQRESULT _system_date(HSQUIRRELVM v)
     }
     return 1;
 }
+#endif
 
 static SQRESULT _system_exit (HSQUIRRELVM v) {
   SQRESULT status = 0;
@@ -252,12 +257,13 @@ static SQRESULT _system_exit (HSQUIRRELVM v) {
 #define sq_tmpnam(b,e)		{ e = (tmpnam(b) == NULL); }
 #endif
 
+#ifndef _WIN32_WCE
 static SQRESULT _system_tmpname (HSQUIRRELVM v) {
-  char buff[SQ_TMPNAMBUFSIZE];
+  SQChar buff[SQ_TMPNAMBUFSIZE];
   int err;
   sq_tmpnam(buff, err);
   if (err)
-    return sq_throwerror(v, "unable to generate a unique filename");
+    return sq_throwerror(v, _SC("unable to generate a unique filename"));
   sq_pushstring(v, buff, -1);
   return 1;
 }
@@ -266,18 +272,19 @@ static SQRESULT _system_tmpname (HSQUIRRELVM v) {
 static SQRESULT _system_setlocale (HSQUIRRELVM v) {
   static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
                       LC_NUMERIC, LC_TIME};
-  static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
-     "numeric", "time", NULL};
+  static const SQChar *const catnames[] = {_SC("all"), _SC("collate"), _SC("ctype"),
+		_SC("monetary"), _SC("numeric"), _SC("time"), NULL};
   SQ_FUNC_VARS(v);
   SQ_OPT_STRING(v, 2, l, NULL);
-  SQ_OPT_STRING(v, 3, name, "all");
+  SQ_OPT_STRING(v, 3, name, _SC("all"));
   for (int i=0; catnames[i]; i++)
-    if (strcmp(catnames[i], name) == 0){
+    if (scstrcmp(catnames[i], name) == 0){
         sq_pushstring(v, setlocale(cat[i], l), -1);
         return 1;
     }
-  return sq_throwerror(v, "invalid option %s for param %d", name, 3);
+  return sq_throwerror(v, _SC("invalid option %s for param %d"), name, 3);
 }
+#endif
 
 /*-------------------------------------------------------------------------*\
 * Sleep for n seconds.
@@ -302,6 +309,7 @@ static SQRESULT  _system_sleep(HSQUIRRELVM v)
     return 0;
 }
 
+#ifndef _WIN32_WCE
 #include <sys/timeb.h>
 
 int GetMilliCount()
@@ -334,6 +342,7 @@ static SQRESULT _system_getmillispan (HSQUIRRELVM v) {
     sq_pushinteger(v, GetMilliSpan(nTimeStart));
     return 1;
 }
+#endif
 
 #if 0
 struct sq_signal_list
@@ -499,21 +508,23 @@ static int _system_raise(HSQUIRRELVM v)
 #endif
 
 #define _DECL_FUNC(name,nparams,pmask) {_SC(#name),_system_##name,nparams,pmask}
-static SQRegFunction systemlib_funcs[]={
+static SQRegFunction systemlib_funcs[]={
+#ifndef _WIN32_WCE
 	_DECL_FUNC(getenv,2,_SC(".s")),
 	_DECL_FUNC(system,2,_SC(".s")),
 	_DECL_FUNC(clock,0,NULL),
-	_DECL_FUNC(time,-1,_SC(".t")),
-	_DECL_FUNC(difftime,-2,_SC(".nn")),
-	_DECL_FUNC(date,-1,_SC(".sn")),
 	_DECL_FUNC(remove,2,_SC(".s")),
 	_DECL_FUNC(rename,3,_SC(".ss")),
-	_DECL_FUNC(exit, -1,_SC(". b|i b")),
-	_DECL_FUNC(sleep, 2,_SC(".n")),
+	_DECL_FUNC(date,-1,_SC(".sn")),
 	_DECL_FUNC(tmpname,1,_SC(".")),
 	_DECL_FUNC(setlocale,-1,_SC(".ss")),
 	_DECL_FUNC(getmillicount,1,_SC(".")),
 	_DECL_FUNC(getmillispan,2,_SC(".i")),
+#endif
+	_DECL_FUNC(time,-1,_SC(".t")),
+	_DECL_FUNC(difftime,-2,_SC(".nn")),
+	_DECL_FUNC(exit, -1,_SC(". b|i b")),
+	_DECL_FUNC(sleep, 2,_SC(".n")),
 	{0,0}
 };
 #undef _DECL_FUNC

+ 39 - 1
SquiLu/squilu.cbp

@@ -308,11 +308,40 @@
 					<Add directory="../fltk/lib" />
 				</Linker>
 			</Target>
+			<Target title="Release alone wince">
+				<Option output="bin/squilu-alone-wince" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release-alone-wince/" />
+				<Option type="1" />
+				<Option compiler="mingw32ce_compiler" />
+				<Compiler>
+					<Add option="-Os" />
+					<Add option="-Wall" />
+					<Add option="-fno-rtti" />
+					<Add option="-fno-strict-aliasing" />
+					<Add option="-DNEED_SUBLATIN_C=1" />
+					<Add option="-DSQUILU_ALONE=1" />
+					<Add option="-D_WIN32_WCE=1" />
+					<Add directory="../../zeromq-3.2.2/include" />
+				</Compiler>
+				<Linker>
+					<Add option="-s" />
+					<Add library="../../zeromq-3.2.2/libzmq3.a" />
+					<Add library="pthread" />
+					<Add library="rt" />
+					<Add library="dl" />
+					<Add library="axtls" />
+					<Add library="mpdecimal" />
+					<Add library="discount" />
+					<Add library="fltk_z" />
+					<Add directory="../../zeromq-3.2.2" />
+					<Add directory="../fltk/lib" />
+				</Linker>
+			</Target>
 		</Build>
 		<Compiler>
 			<Add option="-Wall" />
 			<Add option="-fno-strict-aliasing" />
-			<Add option="-DPROFILE_SQVM=1" />
+			<Add option="-DPROFILE_SQVM0=1" />
 			<Add option="-DSQ_JIT_LLVM44=1" />
 			<Add option="-D_DEBUG_DUMP33=1" />
 			<Add option="-DWITH_DAD_EXTRAS=1" />
@@ -791,6 +820,15 @@
 			<code_completion />
 			<debugger />
 			<envvars />
+			<DoxyBlocks>
+				<comment_style block="0" line="0" />
+				<doxyfile_project />
+				<doxyfile_build />
+				<doxyfile_warnings />
+				<doxyfile_output />
+				<doxyfile_dot />
+				<general />
+			</DoxyBlocks>
 		</Extensions>
 	</Project>
 </CodeBlocks_project_file>

+ 15 - 15
SquiLu/squirrel/sqapi.cpp

@@ -1831,7 +1831,7 @@ SQRESULT sq_optstr_and_size(HSQUIRRELVM sqvm, SQInteger idx, const SQChar **valu
         return sq_getstr_and_size(sqvm, idx, value, size);
     }
     *value = dflt;
-    *size = strlen(dflt);
+    *size = scstrlen(dflt);
     return SQ_OK;
 }
 
@@ -1883,31 +1883,31 @@ SQRESULT sq_call_va_vl(HSQUIRRELVM v, SQBool reset_stack, SQInteger idx, const S
     {
         switch (*sig++)
         {
-        case 'd':  /* double argument */
+        case _SC('d'):  /* double argument */
             sq_pushfloat(v, va_arg(vl, double));
             break;
 
-        case 'i':  /* int argument */
+        case _SC('i'):  /* int argument */
             sq_pushinteger(v, va_arg(vl, int));
             break;
 
-        case 's':  /* string argument */
-            sq_pushstring(v, va_arg(vl, char *), -1);
+        case _SC('s'):  /* string argument */
+            sq_pushstring(v, va_arg(vl, SQChar *), -1);
             break;
 
-        case 'b':  /* string argument */
+        case _SC('b'):  /* string argument */
             sq_pushbool(v, va_arg(vl, int));
             break;
 
-        case 'n':  /* string argument */
+        case _SC('n'):  /* string argument */
             sq_pushnull(v);
             break;
 
-        case 'p':  /* string argument */
+        case _SC('p'):  /* string argument */
             sq_pushuserpointer(v, va_arg(vl, void *));
             break;
 
-        case '>':
+        case _SC('>'):
             goto endwhile;
 
         default:
@@ -1931,27 +1931,27 @@ endwhile:
         switch (*sig)
         {
 
-        case 'd':  /* double result */
+        case _SC('d'):  /* double result */
             if (!sq_isnumeric(o))  DONE_AND_RETURN(-1000);
             *va_arg(vl, double *) = tofloat(o);
             break;
 
-        case 'i':  /* int result */
+        case _SC('i'):  /* int result */
             if (!sq_isnumeric(o))  DONE_AND_RETURN(-1100);
             *va_arg(vl, int *) = tointeger(o);
             break;
         //string do not work with stack reset
-        case 's':  /* string result */
+        case _SC('s'):  /* string result */
             if(reset_stack) DONE_AND_RETURN(-1250);
             if (!sq_isstring(o)) DONE_AND_RETURN(-1200);
-            *va_arg(vl, const char **) = _stringval(o);
+            *va_arg(vl, const SQChar **) = _stringval(o);
             break;
-        case 'b':  /* bool result */
+        case _SC('b'):  /* bool result */
             if (!sq_isbool(o)) DONE_AND_RETURN(-1300);
             *va_arg(vl, int *) = tointeger(o);
             break;
 
-        case 'p':  /* user pointer result */
+        case _SC('p'):  /* user pointer result */
             if (!sq_isuserpointer(o)) DONE_AND_RETURN(-1400);
             *va_arg(vl, void **) = _userpointer(o);
             break;

+ 11 - 22
SquiLu/squirrel/sqbaselib.cpp

@@ -368,7 +368,7 @@ static SQRESULT base_str_from_chars (HSQUIRRELVM v) {
   for (i=2; i<=n; ++i) {
     SQ_GET_INTEGER(v, i, c);
     if(uchar(c) != c){
-        return sq_throwerror(v, "invalid value for parameter %d", i);
+        return sq_throwerror(v, _SC("invalid value for parameter %d"), i);
     }
     data[i-2] = uchar(c);
   }
@@ -487,8 +487,8 @@ static SQRESULT default_delegate_tointeger(HSQUIRRELVM v)
 		SQObjectPtr res;
 		SQInteger base;
 		if(sq_gettop(v) > 1){
-		    if(sq_getinteger(v, 2, &base) < 0) return sq_throwerror(v, "parameter integer expected (2-36)");
-		    if(base < 2 || base > 36) return sq_throwerror(v, "invalid base \"%d\" to tointeger (2-36)", base);
+		    if(sq_getinteger(v, 2, &base) < 0) return sq_throwerror(v, _SC("parameter integer expected (2-36)"));
+		    if(base < 2 || base > 36) return sq_throwerror(v, _SC("invalid base \"%d\" to tointeger (2-36)"), base);
 		}
 		else base = 10;
 		if(str2num(_stringval(o),res, base)){
@@ -969,10 +969,10 @@ static SQRESULT array_concat0 (HSQUIRRELVM v, int allowAll) {
     SQObjectPtrVec &aryvec = _array(arobj)->_values;
     SQInteger last = aryvec.size();
     if(last == 0){
-        sq_pushstring(v, "", 0);
+        sq_pushstring(v, _SC(""), 0);
         return 1;
     }
-    SQ_OPT_STRING(v, 2, sep, "");
+    SQ_OPT_STRING(v, 2, sep, _SC(""));
     SQ_OPT_INTEGER(v, 3, i, 0);
     SQ_OPT_INTEGER(v, 4, opt_last, last);
 
@@ -996,7 +996,8 @@ static SQRESULT array_concat0 (HSQUIRRELVM v, int allowAll) {
               break;
             }
           default:
-              return sq_throwerror(v, "Invalid type \"%s\" at position %d for array concat !", GetTypeName(o), i);
+              return sq_throwerror(v, _SC("Invalid type \"%s\" at position %d for array concat !"),
+								GetTypeName(o), i);
       }
 
       const SQChar *value;
@@ -1136,7 +1137,7 @@ STRING_TOFUNCZ(toupper)
 
 //on 64 bits there is an error SQRESULT/int
 static int process_string_gsub(LuaMatchState *ms, void *udata, char_buffer_st **b) {
-    const char *str;
+    const SQChar *str;
     SQInteger str_size;
     HSQUIRRELVM v = (HSQUIRRELVM)udata;
     SQObjectType rtype = sq_gettype(v, 3);
@@ -1230,7 +1231,7 @@ static SQRESULT string_gsub(HSQUIRRELVM v)
             }
         }
     }
-	return sq_throwerror(v,"invalid type for parameter 3 function/table/array/string expected");
+	return sq_throwerror(v,_SC("invalid type for parameter 3 function/table/array/string expected"));
 }
 
 static SQRESULT process_string_gmatch_find(LuaMatchState *ms, void *udata, char_buffer_st **b, bool isFind) {
@@ -1290,7 +1291,7 @@ static SQRESULT string_gmatch(HSQUIRRELVM v)
             sq_pushinteger(v, _rc_);
             return 1;
         }
-        return sq_throwerror(v,"invalid type for parameter 3 function expected");
+        return sq_throwerror(v,_SC("invalid type for parameter 3 function expected"));
     }
     _rc_ = str_match(&ms, src, src_size, pattern, pattern_size,
             0, 0, 0, 0);
@@ -1370,7 +1371,7 @@ static SQRESULT string_find_lua(HSQUIRRELVM v)
         sq_pushinteger(v, rc);
         return 1;
     }
-	return sq_throwerror(v,"invalid type for parameter 3 function expected");
+	return sq_throwerror(v,_SC("invalid type for parameter 3 function expected"));
 }
 
 static const SQChar *lmemfind (const SQChar *s1, size_t l1,
@@ -1520,18 +1521,6 @@ static SQRESULT string_getdelegate(HSQUIRRELVM v)
 
 //DAD end
 
-#ifdef SQUNICODE
-#define scstrchr wcschr
-#define scsnprintf wsnprintf
-#define scatoi _wtoi
-#define scstrtok wcstok
-#else
-#define scstrchr strchr
-#define scsnprintf snprintf
-#define scatoi atoi
-#define scstrtok strtok
-#endif
-
 static void __strip_l(const SQChar *str,const SQChar **start)
 {
 	const SQChar *t = str;