Browse Source

Change macro type() to sqtype() as done in squirrel, also updating sqlite3

mingodad 8 years ago
parent
commit
6ee9f39571

File diff suppressed because it is too large
+ 311 - 253
SquiLu-ext/sqlite3.c


+ 64 - 35
SquiLu-ext/sqlite3.h

@@ -121,9 +121,9 @@ extern "C" {
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.20.0"
-#define SQLITE_VERSION_NUMBER 3020000
-#define SQLITE_SOURCE_ID      "2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40"
+#define SQLITE_VERSION        "3.21.0"
+#define SQLITE_VERSION_NUMBER 3021000
+#define SQLITE_SOURCE_ID      "2017-08-01 00:20:34 95e8f31658254dd2df3eeaae337aff0fe2125d170ae966c74f4fc70400e099b1"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
@@ -235,7 +235,7 @@ SQLITE_API int sqlite3_threadsafe(void);
 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
 ** and [sqlite3_close_v2()] are its destructors.  There are many other
 ** interfaces (such as
-** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
+** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
 ** sqlite3 object.
 */
@@ -352,7 +352,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
 ** METHOD: sqlite3
 **
 ** The sqlite3_exec() interface is a convenience wrapper around
-** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
 ** that allows an application to run multiple statements of SQL
 ** without having to use a lot of C code. 
 **
@@ -2023,10 +2023,10 @@ struct sqlite3_mem_methods {
 ** </dd>
 **
 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
-** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
+** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
 ** the [query planner stability guarantee] (QPSG).  When the QPSG is active,
 ** a single SQL query statement will always use the same algorithm regardless
-** of values of [bound parameters].  The QPSG disables some query optimizations
+** of values of [bound parameters].)^ The QPSG disables some query optimizations
 ** that look at the values of bound parameters, which can make some queries
 ** slower.  But the QPSG has the advantage of more predictable behavior.  With
 ** the QPSG active, SQLite will always use the same query plan in the field as
@@ -2732,12 +2732,12 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
 ** rejected with an error.  ^If the authorizer callback returns
 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
-** then the [sqlite3_prepare_v3()] or equivalent call that triggered
+** then the [sqlite3_prepare_v2()] or equivalent call that triggered
 ** the authorizer will fail with an error message.
 **
 ** When the callback returns [SQLITE_OK], that means the operation
 ** requested is ok.  ^When the callback returns [SQLITE_DENY], the
-** [sqlite3_prepare_v3()] or equivalent call that triggered the
+** [sqlite3_prepare_v2()] or equivalent call that triggered the
 ** authorizer will fail with an error message explaining that
 ** access is denied. 
 **
@@ -2788,10 +2788,10 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 **
 ** The authorizer callback must not do anything that will modify
 ** the database connection that invoked the authorizer callback.
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
-** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
 ** statement might be re-prepared during [sqlite3_step()] due to a 
 ** schema change.  Hence, the application should ensure that the
 ** correct authorizer callback remains in place during the [sqlite3_step()].
@@ -2800,7 +2800,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
 ** [sqlite3_prepare()] or its variants.  Authorization is not
 ** performed during statement evaluation in [sqlite3_step()], unless
 ** as stated in the previous paragraph, sqlite3_step() invokes
-** sqlite3_prepare_v3() to reprepare a statement after a schema change.
+** sqlite3_prepare_v2() to reprepare a statement after a schema change.
 */
 SQLITE_API int sqlite3_set_authorizer(
   sqlite3*,
@@ -3036,7 +3036,7 @@ SQLITE_API int sqlite3_trace_v2(
 **
 ** The progress handler callback must not do anything that will modify
 ** the database connection that invoked the progress handler.
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
 */
@@ -3393,7 +3393,7 @@ SQLITE_API const char *sqlite3_errstr(int);
 ** The life-cycle of a prepared statement object usually goes like this:
 **
 ** <ol>
-** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
 **      interfaces.
 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
@@ -3475,7 +3475,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 **
 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
 ** <dd>The maximum number of instructions in a virtual machine program
-** used to implement an SQL statement.  If [sqlite3_prepare_v3()] or
+** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or
 ** the equivalent tries to allocate space for more than this many opcodes
 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
 **
@@ -3526,13 +3526,15 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 **
 ** <dl>
 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
-** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
-** and [sqlite3_prepare16_v3()]
-** to optimize the resulting prepared statement to be retained for a 
-** relatively long amount of time.)^  ^Without this flag,
-** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
-** the prepared statement will be used just once or at most a few times
-** and then destroyed using [sqlite3_finalize()] relatively soon.
+** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
+** that the prepared statement will be retained for a long time and
+** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
+** and [sqlite3_prepare16_v3()] assume that the prepared statement will 
+** be used just once or at most a few times and then destroyed using
+** [sqlite3_finalize()] relatively soon. The current implementation acts
+** on this hint by avoiding the use of [lookaside memory] so as not to
+** deplete the limited store of lookaside memory. Future versions of
+** SQLite may act on this hint differently.
 ** </dl>
 */
 #define SQLITE_PREPARE_PERSISTENT              0x01
@@ -3677,7 +3679,7 @@ SQLITE_API int sqlite3_prepare16_v3(
   sqlite3 *db,            /* Database handle */
   const void *zSql,       /* SQL statement, UTF-16 encoded */
   int nByte,              /* Maximum length of zSql in bytes. */
-  unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
+  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
   const void **pzTail     /* OUT: Pointer to unused portion of zSql */
 );
@@ -3835,7 +3837,7 @@ typedef struct sqlite3_context sqlite3_context;
 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
 ** METHOD: sqlite3_stmt
 **
-** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
 ** literals may be replaced by a [parameter] that matches one of following
 ** templates:
 **
@@ -3854,7 +3856,7 @@ typedef struct sqlite3_context sqlite3_context;
 **
 ** ^The first argument to the sqlite3_bind_*() routines is always
 ** a pointer to the [sqlite3_stmt] object returned from
-** [sqlite3_prepare_v3()] or its variants.
+** [sqlite3_prepare_v2()] or its variants.
 **
 ** ^The second argument is the index of the SQL parameter to be set.
 ** ^The leftmost SQL parameter has an index of 1.  ^When the same named
@@ -3915,6 +3917,15 @@ typedef struct sqlite3_context sqlite3_context;
 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
 ** ^A negative value for the zeroblob results in a zero-length BLOB.
 **
+** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in
+** [prepared statement] S to have an SQL value of NULL, but to also be
+** associated with the pointer P of type T.  ^D is either a NULL pointer or
+** a pointer to a destructor function for P. ^SQLite will invoke the
+** destructor D with a single argument of P when it is finished using
+** P.  The T parameter should be a static string, preferably a string
+** literal. The sqlite3_bind_pointer() routine is part of the
+** [pointer passing interface] added for SQLite 3.20.0.
+**
 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
 ** for the [prepared statement] or with a prepared statement for which
 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
@@ -3948,6 +3959,7 @@ SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)
 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
                          void(*)(void*), unsigned char encoding);
 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));
 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
 SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
 
@@ -4327,7 +4339,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** ^These routines return information about a single column of the current
 ** result row of a query.  ^In every case the first argument is a pointer
 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
-** that was returned from [sqlite3_prepare_v3()] or one of its variants)
+** that was returned from [sqlite3_prepare_v2()] or one of its variants)
 ** and the second argument is the index of the column for which information
 ** should be returned. ^The leftmost column of the result set has the index 0.
 ** ^The number of columns in the result can be determined using
@@ -4741,6 +4753,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
+** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value
 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
 ** the native byteorder
@@ -4760,7 +4773,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 **
 ** <b>Details:</b>
 **
-** This routine extract type, size, and content information from
+** These routines extract type, size, and content information from
 ** [protected sqlite3_value] objects.  Protected sqlite3_value objects
 ** are used to pass parameter information into implementation of
 ** [application-defined SQL functions] and [virtual tables].
@@ -4778,6 +4791,13 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
 ** extract UTF-16 strings as big-endian and little-endian respectively.
 **
+** ^If [sqlite3_value] object V was initialized 
+** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]
+** and if X and Y are strings that compare equal according to strcmp(X,Y),
+** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,
+** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() 
+** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
+**
 ** ^(The sqlite3_value_type(V) interface returns the
 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
@@ -4810,6 +4830,7 @@ SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
 SQLITE_API sqlite_double sqlite3_value_double(sqlite3_value*);
 SQLITE_API int sqlite3_value_int(sqlite3_value*);
 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
@@ -4828,10 +4849,6 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
 ** information can be used to pass a limited amount of context from
 ** one SQL function to another.  Use the [sqlite3_result_subtype()]
 ** routine to set the subtype for the return value of an SQL function.
-**
-** SQLite makes no use of subtype itself.  It merely passes the subtype
-** from the result of one [application-defined SQL function] into the
-** input of another.
 */
 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
 
@@ -5102,7 +5119,7 @@ typedef void (*sqlite3_destructor_type)(void*);
 ** when it has finished using that result.
 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
-** then SQLite makes a copy of the result into space obtained from
+** then SQLite makes a copy of the result into space obtained
 ** from [sqlite3_malloc()] before it returns.
 **
 ** ^The sqlite3_result_value() interface sets the result of
@@ -5115,6 +5132,17 @@ typedef void (*sqlite3_destructor_type)(void*);
 ** [unprotected sqlite3_value] object is required, so either
 ** kind of [sqlite3_value] object can be used with this interface.
 **
+** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an
+** SQL NULL value, just like [sqlite3_result_null(C)], except that it
+** also associates the host-language pointer P or type T with that 
+** NULL value such that the pointer can be retrieved within an
+** [application-defined SQL function] using [sqlite3_value_pointer()].
+** ^If the D parameter is not NULL, then it is a pointer to a destructor
+** for the P parameter.  ^SQLite invokes D with P as its only argument
+** when SQLite is finished with P.  The T parameter should be a static
+** string and preferably a string literal. The sqlite3_result_pointer()
+** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
+**
 ** If these routines are called from within the different thread
 ** than the one containing the application-defined function that received
 ** the [sqlite3_context] pointer, the results are undefined.
@@ -5138,6 +5166,7 @@ SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*
 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));
 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
 
@@ -5502,7 +5531,7 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
 ** to which a [prepared statement] belongs.  ^The [database connection]
 ** returned by sqlite3_db_handle is the same [database connection]
 ** that was the first argument
-** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
+** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
 ** create the statement in the first place.
 */
 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
@@ -5578,7 +5607,7 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 ** completion of the [sqlite3_step()] call that triggered the commit
 ** or rollback hook in the first place.
 ** Note that running any other SQL statements, including SELECT statements,
-** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
+** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
 ** the database connections for the meaning of "modify" in this paragraph.
 **
 ** ^Registering a NULL function disables the callback.
@@ -5638,7 +5667,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
 ** the database connection that invoked the update hook.  Any actions
 ** to modify the database connection must be deferred until after the
 ** completion of the [sqlite3_step()] call that triggered the update hook.
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
 **
 ** ^The sqlite3_update_hook(D,C,P) function

+ 2 - 2
SquiLu/Makefile-SquiLu

@@ -38,6 +38,8 @@ CFLAGS = $(INC) -O3 -Wall -fno-strict-aliasing  \
     -DSQLITE_SOUNDEX=1 \
     -DSQLITE_USE_URI=1 \
     -DUSE_BITVECTOR=1 \
+	-DSQLITE_ENABLE_SESSION=1 \
+	-DSQLITE_ENABLE_PREUPDATE_HOOK=1 \
     -DSQ_SUBLATIN=1 \
     -DSQUSEDECIMAL64x=1 \
     -DSQUSEDOUBLE=1 \
@@ -108,8 +110,6 @@ SOURCES= \
     ../SquiLu-ext/sq_zlib.cpp  \
     ../SquiLu-ext/tinyxml2.cpp \
     ../SquiLu-ext/dad_utils.cpp \
-    ../SquiLu-ext/sq_tweetnacl.cpp \
-    ../SquiLu-ext/tweetnacl.c \
     ../SquiLu-ext/randombytes.c \
     ../SquiLu-ext/tweetnacl.c \
     ../SquiLu-ext/sq_tweetnacl.cpp \

+ 5 - 1
SquiLu/Makefile-SquiLu-PI3

@@ -39,9 +39,12 @@ CFLAGS = $(INC) -O3 -Wall -fno-strict-aliasing  \
     -DSQLITE_OMIT_TCL_VARIABLE=1 \
     -DSQLITE_SOUNDEX=1 \
     -DSQLITE_USE_URI=1 \
+	-DUSE_BITVECTOR=1 \
     -DSQLITE_OMIT_PREPARED=1 \
     -DSQLITE_ENABLE_JSON1=1 \
     -DSQLITE_USE_DECIMAL2=1 \
+	-DSQLITE_ENABLE_SESSION=1 \
+	-DSQLITE_ENABLE_PREUPDATE_HOOK=1 \
     -DSQ_SUBLATIN=1 \
     -DSQUSEDECIMAL64x=1 \
     -DSQUSEDOUBLE=1 \
@@ -98,7 +101,7 @@ SOURCES= \
     ../SquiLu-ext/sq_decimal.cpp  \
     ../SquiLu-ext/sq_libcurl.cpp  \
     ../SquiLu-ext/sq_markdown.cpp  \
-    ../SquiLu-ext/sq_mix.c \
+    ../SquiLu-ext/sq_mix.cpp \
     ../SquiLu-ext/sq_mongoose.cpp  \
     ../SquiLu-ext/sq_mysql.cpp  \
     ../SquiLu-ext/sq_postgresql.cpp  \
@@ -107,6 +110,7 @@ SOURCES= \
     ../SquiLu-ext/sq_slave_vm.cpp  \
     ../SquiLu-ext/sq_socket.cpp  \
     ../SquiLu-ext/sq_sqlite3.cpp  \
+    ../SquiLu-ext/sq_bitvector.cpp  \
     ../SquiLu-ext/sq_tinyxml2.cpp  \
     ../SquiLu-ext/sq_zlib.cpp  \
     ../SquiLu-ext/tinyxml2.cpp \

+ 4 - 0
SquiLu/samples/test-regex.nut

@@ -7,3 +7,7 @@ ex = regexp(@"\m()");
 string = "123 Test; strlen(str);";
 res = ex.search(string);
 print(string.slice(res.begin,res.end)); //prints "(str)"
+
+local re = regexp(@"(style|layout)\.width");
+
+print(re.gsub(txt, "$1.dimensions[DIMENSION_WIDTH]"));

+ 9 - 0
SquiLu/samples/test-slave-vm.nut

@@ -1,5 +1,14 @@
 local svm = SlaveVM(1024, true, true);
 
+print(SQLite3, SQLite3.SQLITE_ERROR);
+
+if(svm.preload_lib("sqlite3"))
+{
+	local slave_func = "getInteger";
+	svm.compilestring(slave_func, "return SQLite3.SQLITE_ERROR;");
+	local slave_integer = svm.call(true, slave_func);
+	print("SQLite3.SQLITE_ERROR", slave_integer);	
+}
 print(svm);
 print(svm.is_thread_idle(), svm.is_runing_as_thread());
 

+ 54 - 54
SquiLu/squirrel/sqapi.cpp

@@ -19,12 +19,12 @@ void sq_raise_type_error(HSQUIRRELVM v, SQObjectType type,SQObjectPtr &o)
     SQObjectPtr oval = v->PrintObjVal(o);
     v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
 }
-#define _CHECK_OBJ_TYPE(v,otype,o) if(type(o) != otype) {sq_raise_type_error(v, otype, o); return SQ_ERROR;}
+#define _CHECK_OBJ_TYPE(v,otype,o) if(sqtype(o) != otype) {sq_raise_type_error(v, otype, o); return SQ_ERROR;}
 
 bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPtr **o)
 {
 	*o = &stack_get(v,idx);
-	if(type(**o) != type){
+	if(sqtype(**o) != type){
 		SQObjectPtr oval = v->PrintObjVal(**o);
 		v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
 		return false;
@@ -178,7 +178,7 @@ void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable)
 
 void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
 {
-	if(!ISREFCOUNTED(type(*po))) return;
+	if(!ISREFCOUNTED(sqtype(*po))) return;
 #ifdef NO_GARBAGE_COLLECTOR
 	__AddRef(po->_type,po->_unVal);
 #else
@@ -188,7 +188,7 @@ void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
 
 SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po)
 {
-	if(!ISREFCOUNTED(type(*po))) return 0;
+	if(!ISREFCOUNTED(sqtype(*po))) return 0;
 #ifdef NO_GARBAGE_COLLECTOR
    return po->_unVal.pRefCounted->_uiRef;
 #else
@@ -198,7 +198,7 @@ SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po)
 
 SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
 {
-	if(!ISREFCOUNTED(type(*po))) return SQTrue;
+	if(!ISREFCOUNTED(sqtype(*po))) return SQTrue;
 #ifdef NO_GARBAGE_COLLECTOR
 	bool ret = (po->_unVal.pRefCounted->_uiRef <= 1) ? SQTrue : SQFalse;
 	__Release(po->_type,po->_unVal);
@@ -210,7 +210,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
 
 SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM SQ_UNUSED_ARG(v), const HSQOBJECT *po)
 {
-    if (!ISREFCOUNTED(type(*po))) return 0;
+    if (!ISREFCOUNTED(sqtype(*po))) return 0;
     return po->_unVal.pRefCounted->_uiRef;
 }
 
@@ -331,7 +331,7 @@ SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase)
 	SQClass *baseclass = NULL;
 	if(hasbase) {
 		SQObjectPtr &base = stack_get(v,-1);
-		if(type(base) != OT_CLASS)
+		if(sqtype(base) != OT_CLASS)
 			return sq_throwerror(v,_SC("invalid base type"));
 		baseclass = _class(base);
 	}
@@ -380,7 +380,7 @@ SQBool sq_instanceof(HSQUIRRELVM v)
 {
 	SQObjectPtr &inst = stack_get(v,-1);
 	SQObjectPtr &cl = stack_get(v,-2);
-	if(type(inst) != OT_INSTANCE || type(cl) != OT_CLASS)
+	if(sqtype(inst) != OT_INSTANCE || sqtype(cl) != OT_CLASS)
 		return sq_throwerror(v,_SC("invalid param type"));
 	return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
 }
@@ -499,14 +499,14 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars)
 SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars)
 {
 	SQObjectPtr &o = stack_get(v, idx);
-	if(type(o) == OT_CLOSURE) {
+	if(sqtype(o) == OT_CLOSURE) {
 		SQClosure *c = _closure(o);
 		SQFunctionProto *proto = c->_function;
 		*nparams = (SQUnsignedInteger)proto->_nparameters;
 		*nfreevars = (SQUnsignedInteger)proto->_noutervalues;
 		return SQ_OK;
 	}
-	else if(type(o) == OT_NATIVECLOSURE)
+	else if(sqtype(o) == OT_NATIVECLOSURE)
 	{
 		SQNativeClosure *c = _nativeclosure(o);
 		*nparams = (SQUnsignedInteger)c->_nparamscheck;
@@ -561,7 +561,7 @@ SQRESULT sq_setfenv(HSQUIRRELVM v,SQInteger idx, SQBool cloning)
 		!sq_isclass(env) &&
 		!sq_isinstance(env))
 		return sq_throwerror(v,_SC("invalid environment"));
-	SQWeakRef *w = _refcounted(env)->GetWeakRef(type(env));
+	SQWeakRef *w = _refcounted(env)->GetWeakRef(sqtype(env));
 	SQObjectPtr ret;
 	if(sq_isclosure(o)) {
 		SQClosure *c = cloning ? _closure(o)->Clone() : _closure(o);
@@ -655,7 +655,7 @@ SQRESULT sq_getclosureroot(HSQUIRRELVM v,SQInteger idx)
 SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &o=stack_get(v,idx);
-	switch(type(o)) {
+	switch(sqtype(o)) {
 		case OT_TABLE: _table(o)->Clear();	break;
 		case OT_ARRAY: _array(o)->Resize(0); break;
 		default:
@@ -683,7 +683,7 @@ SQRESULT sq_getonroottable(HSQUIRRELVM v)
 SQRESULT sq_setonroottable(HSQUIRRELVM v)
 {
     SQObjectPtr &key = v->GetUp(-2);
-	if(type(key) == OT_NULL) {
+	if(sqtype(key) == OT_NULL) {
 		v->Pop(2);
 		return sq_throwerror(v, _SC("null key"));
 	}
@@ -709,7 +709,7 @@ SQRESULT sq_getonregistrytable(HSQUIRRELVM v)
 SQRESULT sq_setonregistrytable(HSQUIRRELVM v)
 {
     SQObjectPtr &key = v->GetUp(-2);
-	if(type(key) == OT_NULL) {
+	if(sqtype(key) == OT_NULL) {
 		v->Pop(2);
 		return sq_throwerror(v, _SC("null key"));
 	}
@@ -721,7 +721,7 @@ SQRESULT sq_setonregistrytable(HSQUIRRELVM v)
 SQRESULT sq_delete_on_registry_table(HSQUIRRELVM v, SQUserPointer uptr)
 {
     SQObjectPtr key = uptr;
-	if(type(key) == OT_NULL) {
+	if(sqtype(key) == OT_NULL) {
 		return sq_throwerror(v, _SC("null key"));
 	}
 	if(v->_closing) return SQ_OK;
@@ -849,7 +849,7 @@ void sq_push(HSQUIRRELVM v,SQInteger idx)
 
 SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx)
 {
-	return type(stack_get(v, idx));
+	return sqtype(stack_get(v, idx));
 }
 
 SQUIRREL_API const SQChar *sq_gettypename(HSQUIRRELVM v,SQInteger idx){
@@ -998,7 +998,7 @@ SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx)
 SQInteger sq_getsize(HSQUIRRELVM v, SQInteger idx)
 {
 	SQObjectPtr &o = stack_get(v, idx);
-	SQObjectType type = type(o);
+	SQObjectType type = sqtype(o);
 	switch(type) {
 	case OT_STRING:		return _string(o)->_len;
 	case OT_TABLE:		return _table(o)->CountUsed();
@@ -1029,7 +1029,7 @@ SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPoint
 SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
 {
 	SQObjectPtr &o = stack_get(v,idx);
-	switch(type(o)) {
+	switch(sqtype(o)) {
 		case OT_USERDATA:	_userdata(o)->_typetag = typetag;	break;
 		case OT_CLASS:		_class(o)->_typetag = typetag;		break;
 		default:			return sq_throwerror(v,_SC("invalid object type"));
@@ -1039,7 +1039,7 @@ SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
 
 SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag)
 {
-  switch(type(*o)) {
+  switch(sqtype(*o)) {
     case OT_INSTANCE: *typetag = _instance(*o)->_class->_typetag; break;
     case OT_USERDATA: *typetag = _userdata(*o)->_typetag; break;
     case OT_CLASS:    *typetag = _class(*o)->_typetag; break;
@@ -1073,7 +1073,7 @@ SQUserPointer sq_get_as_userpointer(HSQUIRRELVM v,SQInteger idx)
 SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
 {
 	SQObjectPtr &o = stack_get(v,idx);
-	if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
+	if(sqtype(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
 	_instance(o)->_userpointer = p;
 	return SQ_OK;
 }
@@ -1081,7 +1081,7 @@ SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
 SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
 {
 	SQObjectPtr &o = stack_get(v,idx);
-	if(type(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
+	if(sqtype(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
 	if(_class(o)->_locked) return sq_throwerror(v,_SC("the class is locked"));
 	_class(o)->_udsize = udsize;
 	return SQ_OK;
@@ -1091,7 +1091,7 @@ SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
 SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag)
 {
 	SQObjectPtr &o = stack_get(v,idx);
-	if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
+	if(sqtype(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
 	(*p) = _instance(o)->_userpointer;
 	if(typetag != 0) {
 		SQClass *cl = _instance(o)->_class;
@@ -1170,9 +1170,9 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
 {
 	sq_aux_paramscheck(v, 3);
 	SQObjectPtr &self = stack_get(v, idx);
-	if(type(self) == OT_TABLE || type(self) == OT_CLASS) {
+	if(sqtype(self) == OT_TABLE || sqtype(self) == OT_CLASS) {
 		SQObjectPtr &key = v->GetUp(-2);
-		if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
+		if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
 		v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
 		v->Pop(2);
 	}
@@ -1185,7 +1185,7 @@ SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
 	SQObjectPtr &self = stack_get(v,idx);
 	_CHECK_OBJ_TYPE(v, OT_TABLE, self);
 	SQObjectPtr &key = v->GetUp(-1);
-	if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
+	if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
 	SQObjectPtr res;
 	if(!v->DeleteSlot(self, key, res)){
 		v->Pop();
@@ -1210,11 +1210,11 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &self = stack_get(v, idx);
 	SQObjectPtr &key = v->GetUp(-2);
-	if(type(key) == OT_NULL) {
+	if(sqtype(key) == OT_NULL) {
 		v->Pop(2);
 		return sq_throwerror(v, _SC("null key"));
 	}
-	switch(type(self)) {
+	switch(sqtype(self)) {
 	case OT_TABLE:
 		_table(self)->NewSlot(key, v->GetUp(-1));
 		v->Pop(2);
@@ -1247,9 +1247,9 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
 SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
 {
 	SQObjectPtr &self = stack_get(v, idx);
-	if(type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
+	if(sqtype(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
 	SQObjectPtr &key = v->GetUp(-3);
-	if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
+	if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
 	if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,false))
 		return SQ_ERROR;
 	return SQ_OK;
@@ -1258,9 +1258,9 @@ SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
 SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
 {
 	SQObjectPtr &self = stack_get(v, idx);
-	if(type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
+	if(sqtype(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
 	SQObjectPtr &key = v->GetUp(-3);
-	if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
+	if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
 	if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,true))
 		return SQ_ERROR;
 	return SQ_OK;
@@ -1270,19 +1270,19 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &self = stack_get(v, idx);
 	SQObjectPtr &mt = v->GetUp(-1);
-	SQObjectType type = type(self);
+	SQObjectType type = sqtype(self);
 	switch(type) {
 	case OT_TABLE:
-		if(type(mt) == OT_TABLE) {
+		if(sqtype(mt) == OT_TABLE) {
 			if(!_table(self)->SetDelegate(_table(mt))) return sq_throwerror(v, _SC("delagate cycle")); v->Pop();}
-		else if(type(mt)==OT_NULL) {
+		else if(sqtype(mt)==OT_NULL) {
 			_table(self)->SetDelegate(NULL); v->Pop(); }
 		else return sq_aux_invalidtype(v,type);
 		break;
 	case OT_USERDATA:
-		if(type(mt)==OT_TABLE) {
+		if(sqtype(mt)==OT_TABLE) {
 			_userdata(self)->SetDelegate(_table(mt)); v->Pop(); }
-		else if(type(mt)==OT_NULL) {
+		else if(sqtype(mt)==OT_NULL) {
 			_userdata(self)->SetDelegate(NULL); v->Pop(); }
 		else return sq_aux_invalidtype(v, type);
 		break;
@@ -1313,7 +1313,7 @@ SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
 SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &self=stack_get(v,idx);
-	switch(type(self)){
+	switch(sqtype(self)){
 	case OT_TABLE:
 	case OT_USERDATA:
 		if(!_delegable(self)->_delegate){
@@ -1343,7 +1343,7 @@ SQRESULT sq_getbyname(HSQUIRRELVM v,SQInteger idx, const SQChar *key, SQInteger
 	SQObjectPtr &self=stack_get(v,idx);
 	sq_pushstring(v, key, key_len);
 	SQObjectPtr &obj = v->GetUp(-1);
-	switch(type(self)) {
+	switch(sqtype(self)) {
 	case OT_TABLE:
 		if(_table(self)->Get(obj,obj))
 			return SQ_OK;
@@ -1368,7 +1368,7 @@ SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &self=stack_get(v,idx);
 	SQObjectPtr &obj = v->GetUp(-1);
-	switch(type(self)) {
+	switch(sqtype(self)) {
 	case OT_TABLE:
 		if(_table(self)->Get(obj,obj))
 			return SQ_OK;
@@ -1406,7 +1406,7 @@ SQBool sq_rawexists(HSQUIRRELVM v,SQInteger idx)
 	SQObjectPtr &self=stack_get(v,idx);
 	SQObjectPtr &obj = v->GetUp(-1);
 	SQBool result = SQFalse;
-	switch(type(self)) {
+	switch(sqtype(self)) {
 	case OT_TABLE:
 		result = _table(self)->Exists(obj);
 		break;
@@ -1443,7 +1443,7 @@ const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedIntege
 			stackbase-=ci._prevstkbase;
 		}
 		SQVM::CallInfo &ci=v->_callsstack[lvl];
-		if(type(ci._closure)!=OT_CLOSURE)
+		if(sqtype(ci._closure)!=OT_CLOSURE)
 			return NULL;
 		SQClosure *c=_closure(ci._closure);
 		SQFunctionProto *func=c->_function;
@@ -1534,7 +1534,7 @@ SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize)
 
 SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
 {
-	if (type(v->GetUp(-1)) == OT_GENERATOR)
+	if (sqtype(v->GetUp(-1)) == OT_GENERATOR)
 	{
 		v->PushNull(); //retval
 		if (!v->Execute(v->GetUp(-2), 0, v->_top, v->GetUp(-1), raiseerror, SQVM::ET_RESUME_GENERATOR))
@@ -1602,7 +1602,7 @@ void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook)
 {
 	if(sq_gettop(v) >= 1){
 		SQObjectPtr &ud=stack_get(v,idx);
-		switch( type(ud) ) {
+		switch( sqtype(ud) ) {
 		case OT_USERDATA:	_userdata(ud)->_hook = hook;	break;
 		case OT_INSTANCE:	_instance(ud)->_hook = hook;	break;
 		case OT_CLASS:		_class(ud)->_hook = hook;		break;
@@ -1615,7 +1615,7 @@ SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx)
 {
     if(sq_gettop(v) >= 1){
         SQObjectPtr &ud=stack_get(v,idx);
-        switch( type(ud) ) {
+        switch( sqtype(ud) ) {
         case OT_USERDATA:   return _userdata(ud)->_hook;    break;
         case OT_INSTANCE:   return _instance(ud)->_hook;    break;
         case OT_CLASS:      return _class(ud)->_hook;       break;
@@ -1714,7 +1714,7 @@ const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger n
 {
 	SQObjectPtr &self=stack_get(v,idx);
 	const SQChar *name = NULL;
-	switch(type(self))
+	switch(sqtype(self))
 	{
 	case OT_CLOSURE:{
 		SQClosure *clo = _closure(self);
@@ -1742,7 +1742,7 @@ const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger n
 SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
 {
 	SQObjectPtr &self=stack_get(v,idx);
-	switch(type(self))
+	switch(sqtype(self))
 	{
 	case OT_CLOSURE:{
 		SQFunctionProto *fp = _closure(self)->_function;
@@ -1759,7 +1759,7 @@ SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
 		else return sq_throwerror(v,_SC("invalid free var index"));
 		break;
 	default:
-		return sq_aux_invalidtype(v,type(self));
+		return sq_aux_invalidtype(v,sqtype(self));
 	}
 	v->Pop();
 	return SQ_OK;
@@ -1772,7 +1772,7 @@ SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx)
 	SQObjectPtr &key = stack_get(v,-2);
 	SQObjectPtr &val = stack_get(v,-1);
 	SQObjectPtr attrs;
-	if(type(key) == OT_NULL) {
+	if(sqtype(key) == OT_NULL) {
 		attrs = _class(o)->_attributes;
 		_class(o)->_attributes = val;
 		v->Pop(2);
@@ -1793,7 +1793,7 @@ SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
 	_CHECK_OBJ_TYPE(v, OT_CLASS, o);
 	SQObjectPtr &key = stack_get(v,-1);
 	SQObjectPtr attrs;
-	if(type(key) == OT_NULL) {
+	if(sqtype(key) == OT_NULL) {
 		attrs = _class(o)->_attributes;
 		v->Pop();
 		v->Push(attrs);
@@ -1825,7 +1825,7 @@ SQRESULT sq_getmemberhandle(HSQUIRRELVM v,SQInteger idx,HSQMEMBERHANDLE *handle)
 
 SQRESULT _getmemberbyhandle(HSQUIRRELVM v,SQObjectPtr &self,const HSQMEMBERHANDLE *handle,SQObjectPtr *&val)
 {
-	switch(type(self)) {
+	switch(sqtype(self)) {
 		case OT_INSTANCE: {
 				SQInstance *i = _instance(self);
 				if(handle->_static) {
@@ -1908,8 +1908,8 @@ SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx)
 void sq_weakref(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &o=stack_get(v,idx);
-	if(ISREFCOUNTED(type(o))) {
-		v->Push(_refcounted(o)->GetWeakRef(type(o)));
+	if(ISREFCOUNTED(sqtype(o))) {
+		v->Push(_refcounted(o)->GetWeakRef(sqtype(o)));
 		return;
 	}
 	v->Push(o);
@@ -1918,7 +1918,7 @@ void sq_weakref(HSQUIRRELVM v,SQInteger idx)
 SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &o = stack_get(v,idx);
-	if(type(o) != OT_WEAKREF) {
+	if(sqtype(o) != OT_WEAKREF) {
 		return sq_throwerror(v,_SC("the object must be a weakref"));
 	}
 	v->Push(_weakref(o)->_obj);
@@ -1947,7 +1947,7 @@ SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t)
 SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx)
 {
 	SQObjectPtr &o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val;
-	if(type(o) == OT_GENERATOR) {
+	if(sqtype(o) == OT_GENERATOR) {
 		return sq_throwerror(v,_SC("cannot iterate a generator"));
 	}
 	int faketojump;

+ 11 - 11
SquiLu/squirrel/sqbaselib.cpp

@@ -62,7 +62,7 @@ static SQRESULT base_resurectureachable(HSQUIRRELVM v)
 static SQRESULT base_getrefcount(HSQUIRRELVM v)
 {
     SQObjectPtr &o=stack_get(v,2);
-    if(!ISREFCOUNTED(type(o))) sq_pushinteger(v,0);
+    if(!ISREFCOUNTED(sqtype(o))) sq_pushinteger(v,0);
     else sq_pushinteger(v, o._unVal.pRefCounted->_uiRef - 1);
 	return 1;
 }
@@ -244,7 +244,7 @@ static SQRESULT get_slice_params(HSQUIRRELVM v,SQInteger &sidx,SQInteger &eidx,S
 	o=stack_get(v,1);
 	if(top>1){
 		SQObjectPtr &start=stack_get(v,2);
-		if(type(start)!=OT_NULL && sq_isnumeric(start)){
+		if(sqtype(start)!=OT_NULL && sq_isnumeric(start)){
 			sidx=tointeger(start);
 		}
 	}
@@ -618,7 +618,7 @@ static SQRESULT default_delegate_len(HSQUIRRELVM v)
 static SQRESULT default_delegate_tofloat(HSQUIRRELVM v)
 {
 	SQObjectPtr &o=stack_get(v,1);
-	switch(type(o)){
+	switch(sqtype(o)){
 	case OT_STRING:{
 		SQObjectPtr res;
 		if(str2num(_stringval(o),res)){
@@ -643,7 +643,7 @@ static SQRESULT default_delegate_tofloat(HSQUIRRELVM v)
 static SQRESULT default_delegate_tointeger(HSQUIRRELVM v)
 {
 	SQObjectPtr &o=stack_get(v,1);
-	switch(type(o)){
+	switch(sqtype(o)){
 	case OT_STRING:{
 		SQObjectPtr res;
 		SQInteger base;
@@ -1163,7 +1163,7 @@ static SQRESULT array_concat0 (HSQUIRRELVM v, int allowAll) {
 
   for (; i < last; ++i) {
       SQObjectPtr str, &o = aryvec[i];
-      switch(type(o)){
+      switch(sqtype(o)){
           case OT_STRING:
               break;
           case OT_INTEGER:
@@ -1183,7 +1183,7 @@ static SQRESULT array_concat0 (HSQUIRRELVM v, int allowAll) {
 
       const SQChar *value;
       SQInteger value_size;
-      if(type(o) == OT_STRING) {
+      if(sqtype(o) == OT_STRING) {
 		value = _stringval(o);
 		value_size = _string(o)->_len;
       }
@@ -2360,7 +2360,7 @@ static SQRESULT closure_getenv(HSQUIRRELVM v)
 static SQRESULT closure_getinfos(HSQUIRRELVM v) {
 	SQObject o = stack_get(v,1);
 	SQTable *res = SQTable::Create(_ss(v),4);
-	if(type(o) == OT_CLOSURE) {
+	if(sqtype(o) == OT_CLOSURE) {
 		SQFunctionProto *f = _closure(o)->_function;
 		SQInteger nparams = f->_nparameters + (f->_varparams?1:0);
 		SQObjectPtr params = SQArray::Create(_ss(v),nparams);
@@ -2457,7 +2457,7 @@ SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
 static SQRESULT thread_call(HSQUIRRELVM v)
 {
 	SQObjectPtr o = stack_get(v,1);
-	if(type(o) == OT_THREAD) {
+	if(sqtype(o) == OT_THREAD) {
 		SQInteger nparams = sq_gettop(v);
 		_thread(o)->Push(_thread(o)->_roottable);
 		for(SQInteger i = 2; i<(nparams+1); i++)
@@ -2476,7 +2476,7 @@ static SQRESULT thread_call(HSQUIRRELVM v)
 static SQRESULT thread_wakeup(HSQUIRRELVM v)
 {
 	SQObjectPtr o = stack_get(v,1);
-	if(type(o) == OT_THREAD) {
+	if(sqtype(o) == OT_THREAD) {
 		SQVM *thread = _thread(o);
 		SQInteger state = sq_getvmstate(thread);
 		if(state != SQ_VMSTATE_SUSPENDED) {
@@ -2531,7 +2531,7 @@ static SQRESULT thread_getstatus(HSQUIRRELVM v)
 static SQRESULT thread_getstackinfos(HSQUIRRELVM v)
 {
 	SQObjectPtr o = stack_get(v,1);
-	if(type(o) == OT_THREAD) {
+	if(sqtype(o) == OT_THREAD) {
 		SQVM *thread = _thread(o);
 		SQInteger threadtop = sq_gettop(thread);
 		SQInteger level;
@@ -2540,7 +2540,7 @@ static SQRESULT thread_getstackinfos(HSQUIRRELVM v)
 		if(SQ_FAILED(res))
 		{
 			sq_settop(thread,threadtop);
-			if(type(thread->_lasterror) == OT_STRING) {
+			if(sqtype(thread->_lasterror) == OT_STRING) {
 				sq_throwerror(v,_stringval(thread->_lasterror));
 			}
 			else {

+ 5 - 5
SquiLu/squirrel/sqclass.cpp

@@ -49,7 +49,7 @@ SQClass::~SQClass()
 bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
 {
 	SQObjectPtr temp;
-	bool belongs_to_static_table = type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE || bstatic;
+	bool belongs_to_static_table = sqtype(val) == OT_CLOSURE || sqtype(val) == OT_NATIVECLOSURE || bstatic;
 	if(_locked && !belongs_to_static_table)
 		return false; //the class already has an instance so cannot be modified
 	if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
@@ -59,18 +59,18 @@ bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr
 	}
 	if(belongs_to_static_table) {
 		SQInteger mmidx;
-		if((type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE) &&
+		if((sqtype(val) == OT_CLOSURE || sqtype(val) == OT_NATIVECLOSURE) &&
 			(mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
 			_metamethods[mmidx] = val;
 		}
 		else {
 			SQObjectPtr theval = val;
-			if(_base && type(val) == OT_CLOSURE) {
+			if(_base && sqtype(val) == OT_CLOSURE) {
 				theval = _closure(val)->Clone();
 				_closure(theval)->_base = _base;
 				__ObjAddRef(_base); //ref for the closure
 			}
-			if(type(temp) == OT_NULL) {
+			if(sqtype(temp) == OT_NULL) {
 				if(SQVM::IsEqual(ss->_constructoridx, key)) {
 					_constructoridx = (SQInteger)_methods.size();
 				}
@@ -191,7 +191,7 @@ SQInstance::~SQInstance()
 
 bool SQInstance::GetMetaMethod(SQVM SQ_UNUSED_ARG(*v),SQMetaMethod mm,SQObjectPtr &res)
 {
-	if(type(_class->_metamethods[mm]) != OT_NULL) {
+	if(sqtype(_class->_metamethods[mm]) != OT_NULL) {
 		res = _class->_metamethods[mm];
 		return true;
 	}

+ 1 - 1
SquiLu/squirrel/sqclass.h

@@ -63,7 +63,7 @@ public:
 	}
     bool Set(SQObjectPtr &idx, const SQObjectPtr &val){
         SQClassMember &m = _methods[_member_idx(idx)];
-        if(!(type(m.val) == OT_CLOSURE || type(m.val) == OT_NATIVECLOSURE)){
+        if(!(sqtype(m.val) == OT_CLOSURE || sqtype(m.val) == OT_NATIVECLOSURE)){
             m.val = val;
             return true;
         }

+ 6 - 6
SquiLu/squirrel/sqcompiler.cpp

@@ -297,7 +297,7 @@ public:
             /* Handle named constant */
             SQObjectPtr constval;
             SQObject    constid;
-            if(type(constant) == OT_TABLE) {
+            if(sqtype(constant) == OT_TABLE) {
                 Expect('.');
                 constid = Expect(TK_IDENTIFIER);
                 if(!_table(constant)->Get(constid, constval)) {
@@ -311,7 +311,7 @@ public:
             epos = _fs->PushTarget();
 
             /* generate direct or literal function depending on size */
-            SQObjectType ctype = type(constval);
+            SQObjectType ctype = sqtype(constval);
             switch(ctype) {
                 case OT_INTEGER: EmitLoadConstInt(_integer(constval),epos); break;
                 case OT_FLOAT: EmitLoadConstFloat(_float(constval),epos); break;
@@ -558,7 +558,7 @@ public:
 		}
 		else {
 			if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
-				_ss(_vm)->_compilererrorhandler(_vm, _compilererror, type(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
+				_ss(_vm)->_compilererrorhandler(_vm, _compilererror, sqtype(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
 					_lex.data->currentline, _lex.data->currentcolumn);
 			}
 			_vm->_lasterror = SQString::Create(_ss(_vm), _compilererror, -1);
@@ -910,7 +910,7 @@ public:
 				if(ds == OBJECT || ds == BASE) {
 					EmitDerefOp(_OP_NEWSLOT);
                     if((_es.epos == -1) && (es.etype == EXPR_STATEMENT)
-                       && (type(id) == OT_STRING) ) AddGlobalName(id);
+                       && (sqtype(id) == OT_STRING) ) AddGlobalName(id);
 				}
 				else //if _derefstate != DEREF_NO_DEREF && DEREF_FIELD so is the index of a local
 					Error(_SC("can't 'create' a local slot"));
@@ -1296,7 +1296,7 @@ public:
 					/* Handle named constant */
 					SQObjectPtr constval;
 					SQObject    constid;
-					if(type(constant) == OT_TABLE) {
+					if(sqtype(constant) == OT_TABLE) {
 						Expect('.');
 						constid = Expect(TK_IDENTIFIER);
 						if(!_table(constant)->Get(constid, constval)) {
@@ -1310,7 +1310,7 @@ public:
 					_es.epos = _fs->PushTarget();
 
 					/* generate direct or literal function depending on size */
-					SQObjectType ctype = type(constval);
+					SQObjectType ctype = sqtype(constval);
 					switch(ctype) {
 						case OT_INTEGER: EmitLoadConstInt(_integer(constval),_es.epos); break;
 						case OT_FLOAT: EmitLoadConstFloat(_float(constval),_es.epos); break;

+ 7 - 7
SquiLu/squirrel/sqdebug.cpp

@@ -17,8 +17,8 @@ SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi)
 			SQClosure *c = _closure(ci._closure);
 			SQFunctionProto *proto = c->_function;
 			fi->funcid = proto;
-			fi->name = type(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
-			fi->source = type(proto->_sourcename) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
+			fi->name = sqtype(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
+			fi->source = sqtype(proto->_sourcename) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
 			fi->line = proto->_lineinfos[0]._line;
 			return SQ_OK;
 		}
@@ -32,12 +32,12 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)
 	if (cssize > level) {
 		memset(si, 0, sizeof(SQStackInfos));
 		SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
-		switch (type(ci._closure)) {
+		switch (sqtype(ci._closure)) {
 		case OT_CLOSURE:{
 			SQFunctionProto *func = _closure(ci._closure)->_function;
-			if (type(func->_name) == OT_STRING)
+			if (sqtype(func->_name) == OT_STRING)
 				si->funcname = _stringval(func->_name);
-			if (type(func->_sourcename) == OT_STRING)
+			if (sqtype(func->_sourcename) == OT_STRING)
 				si->source = _stringval(func->_sourcename);
 			si->line = func->GetLine(ci._ip);
 						}
@@ -45,7 +45,7 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)
 		case OT_NATIVECLOSURE:
 			si->source = _SC("NATIVE");
 			si->funcname = _SC("unknown");
-			if(type(_nativeclosure(ci._closure)->_name) == OT_STRING)
+			if(sqtype(_nativeclosure(ci._closure)->_name) == OT_STRING)
 				si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
 			si->line = -1;
 			break;
@@ -73,7 +73,7 @@ void SQVM::Raise_Error(const SQObjectPtr &desc)
 
 SQString *SQVM::PrintObjVal(const SQObjectPtr &o)
 {
-    switch(type(o)) {
+    switch(sqtype(o)) {
     case OT_STRING: return _string(o);
     case OT_INTEGER:
         scsprintf(_sp(sq_rsl(NUMBER_MAX_CHAR+1)),sq_rsl(NUMBER_MAX_CHAR), _PRINT_INT_FMT, _integer(o));

+ 6 - 6
SquiLu/squirrel/sqfuncstate.cpp

@@ -19,7 +19,7 @@ SQInstructionDesc g_InstrDesc[]={
 #endif
 void DumpLiteral(SQObjectPtr &o)
 {
-	switch(type(o)){
+	switch(sqtype(o)){
 		case OT_STRING:	scprintf(_SC("\"%s\""),_stringval(o));break;
 		case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
 		case OT_INTEGER: scprintf(_SC("{") _PRINT_INT_FMT _SC("}"),_integer(o));break;
@@ -50,7 +50,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
 	scprintf(_SC("SQInstruction sizeof %d\n"),sizeof(SQInstruction));
 	scprintf(_SC("SQObject sizeof %d\n"),sizeof(SQObject));
 	scprintf(_SC("--------------------------------------------------------------------\n"));
-	scprintf(_SC("*****FUNCTION [%s]\n"),type(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
+	scprintf(_SC("*****FUNCTION [%s]\n"),sqtype(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
 	scprintf(_SC("-----LITERALS\n"));
 	SQObjectPtr refidx,key,val;
 	SQInteger idx;
@@ -220,7 +220,7 @@ SQInteger SQFuncState::PopTarget()
 	SQUnsignedInteger npos=_targetstack.back();
 	assert(npos < _vlocals.size());
 	SQLocalVarInfo &t = _vlocals[npos];
-	if(type(t._name)==OT_NULL){
+	if(sqtype(t._name)==OT_NULL){
 		_vlocals.pop_back();
 	}
 	_targetstack.pop_back();
@@ -252,7 +252,7 @@ void SQFuncState::SetStackSize(SQInteger n)
 	while(size>n){
 		size--;
 		SQLocalVarInfo lvi = _vlocals.back();
-		if(type(lvi._name)!=OT_NULL){
+		if(sqtype(lvi._name)!=OT_NULL){
 			if(lvi._end_op == UINT_MINUS_ONE) { //this means is an outer
 				_outers--;
 			}
@@ -276,7 +276,7 @@ bool SQFuncState::IsConstant(const SQObject &name,SQObject &e)
 bool SQFuncState::IsLocal(SQUnsignedInteger stkpos)
 {
 	if(stkpos>=_vlocals.size())return false;
-	else if(type(_vlocals[stkpos]._name)!=OT_NULL)return true;
+	else if(sqtype(_vlocals[stkpos]._name)!=OT_NULL)return true;
 	return false;
 }
 
@@ -302,7 +302,7 @@ SQInteger SQFuncState::GetLocalVariable(const SQObject &name)
 	SQInteger locals=_vlocals.size();
 	while(locals>=1){
 		SQLocalVarInfo &lvi = _vlocals[locals-1];
-		if(type(lvi._name)==OT_STRING && _string(lvi._name)==_string(name)){
+		if(sqtype(lvi._name)==OT_STRING && _string(lvi._name)==_string(name)){
 			return locals-1;
 		}
 		locals--;

+ 10 - 10
SquiLu/squirrel/sqobject.cpp

@@ -43,18 +43,18 @@ const SQChar *IdType2Name(SQObjectType type)
 
 const SQChar *GetTypeName(const SQObjectPtr &obj1)
 {
-	return IdType2Name(type(obj1));
+	return IdType2Name(sqtype(obj1));
 }
 
 SQObjectPtr SQObjectPtr::operator[](SQInteger nidx) {
     SQObjectPtr val;
-    if(type(*this) == OT_ARRAY) _array(*this)->Get(nidx, val);
+    if(sqtype(*this) == OT_ARRAY) _array(*this)->Get(nidx, val);
     return val;
 }
 
 SQObjectPtr SQObjectPtr::operator[](const SQChar *key) {
     SQObjectPtr val;
-    switch(type(*this))
+    switch(sqtype(*this))
     {
         case OT_TABLE: _table(*this)->Get(key, val); break;
         case OT_CLASS: _class(*this)->Get(key, val); break;
@@ -89,7 +89,7 @@ SQInteger SQString::Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjec
 
 SQUnsignedInteger SQTranslateIndex(const SQObjectPtr &idx)
 {
-	switch(type(idx)){
+	switch(sqtype(idx)){
 		case OT_NULL:
 			return 0;
 		case OT_INTEGER:
@@ -156,7 +156,7 @@ bool SQGenerator::Yield(SQVM *v,SQInteger target)
 
 	_stack.resize(size);
 	SQObject _this = v->_stack[v->_stackbase];
-	_stack._vals[0] = ISREFCOUNTED(type(_this)) ? SQObjectPtr(_refcounted(_this)->GetWeakRef(type(_this))) : _this;
+	_stack._vals[0] = ISREFCOUNTED(sqtype(_this)) ? SQObjectPtr(_refcounted(_this)->GetWeakRef(sqtype(_this))) : _this;
 	for(SQInteger n =1; n<target; n++) {
 		_stack._vals[n] = v->_stack[v->_stackbase+n];
 	}
@@ -208,7 +208,7 @@ bool SQGenerator::Resume(SQVM *v,SQObjectPtr &dest)
 		et._stacksize += newbase;
 	}
 	SQObject _this = _stack._vals[0];
-	v->_stack[v->_stackbase] = type(_this) == OT_WEAKREF ? _weakref(_this)->_obj : _this;
+	v->_stack[v->_stackbase] = sqtype(_this) == OT_WEAKREF ? _weakref(_this)->_obj : _this;
 
 	for(SQInteger n = 1; n<size; n++) {
 		v->_stack[v->_stackbase+n] = _stack._vals[n];
@@ -344,7 +344,7 @@ static bool WriteObjectAsCode(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,S
 {
 	SQChar buf[32];
 	SQInteger sz;
-	switch(type(o)){
+	switch(sqtype(o)){
 	case OT_STRING:{
             SQInteger str_size = _string(o)->_len;
             if(str_size){
@@ -390,9 +390,9 @@ static bool WriteObjectAsCode(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,S
 
 static bool WriteObject(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
 {
-	SQUnsignedInteger32 _type = (SQUnsignedInteger32)type(o);
+	SQUnsignedInteger32 _type = (SQUnsignedInteger32)sqtype(o);
 	_CHECK_IO(SafeWrite(v,write,up,&_type,sizeof(_type)));
-	switch(type(o)){
+	switch(sqtype(o)){
 	case OT_STRING:
 		_CHECK_IO(SafeWrite(v,write,up,&_string(o)->_len,sizeof(SQInteger)));
 		_CHECK_IO(SafeWrite(v,write,up,_stringval(o),rsl(_string(o)->_len)));
@@ -794,7 +794,7 @@ bool SQFunctionProto::SaveAsSource(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
                                      inst._arg0, inst._arg1, SQGetNewObjTypeName(inst._arg3), inst._arg3);
             break;
             case _OP_APPENDARRAY:
-                        SafeWriteFmt(v,write,up,"\t/* array_at_stk(%d), %s(%d), type(%d) */",
+                        SafeWriteFmt(v,write,up,"\t/* array_at_stk(%d), %s(%d), sqtype(%d) */",
                                      inst._arg0, SQGetArrayAppendTypeName(inst._arg2), inst._arg1, inst._arg2);
             break;
             case _OP_NEWSLOT:

+ 5 - 5
SquiLu/squirrel/sqobject.h

@@ -101,7 +101,7 @@ struct SQWeakRef : SQRefCounted
 	SQObject _obj;
 };
 
-#define _realval(o) (type((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj)
+#define _realval(o) (sqtype((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj)
 
 struct SQObjectPtr;
 
@@ -129,8 +129,8 @@ struct SQObjectPtr;
 	(obj)->_uiRef++; \
 }
 
-#define type(obj) ((obj)._type)
-#define is_delegable(t) (type(t)&SQOBJECT_DELEGABLE)
+#define sqtype(obj) ((obj)._type)
+#define is_delegable(t) (sqtype(t)&SQOBJECT_DELEGABLE)
 #define raw_type(obj) _RAW_TYPE((obj)._type)
 
 #define _integer(obj) ((obj)._unVal.nInteger)
@@ -156,8 +156,8 @@ struct SQObjectPtr;
 #define _stringval(obj) (obj)._unVal.pString->_val
 #define _userdataval(obj) ((SQUserPointer)sq_aligning((obj)._unVal.pUserData + 1))
 
-#define tofloat(num) ((type(num)==OT_INTEGER)?(SQFloat)_integer(num):_float(num))
-#define tointeger(num) ((type(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num))
+#define tofloat(num) ((sqtype(num)==OT_INTEGER)?(SQFloat)_integer(num):_float(num))
+#define tointeger(num) ((sqtype(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num))
 /////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////
 #if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)

+ 6 - 6
SquiLu/squirrel/sqstate.cpp

@@ -185,7 +185,7 @@ SQSharedState::~SQSharedState()
 		_systemstrings->back().Null();
 		_systemstrings->pop_back();
 	}
-	if(type(_root_vm) != OT_NULL)
+	if(sqtype(_root_vm) != OT_NULL)
     {
         _thread(_root_vm)->Finalize();
         _root_vm.Null();
@@ -232,7 +232,7 @@ SQSharedState::~SQSharedState()
 
 SQInteger SQSharedState::GetMetaMethodIdxByName(const SQObjectPtr &name)
 {
-	if(type(name) != OT_STRING)
+	if(sqtype(name) != OT_STRING)
 		return -1;
 	SQObjectPtr ret;
 	if(_table(_metamethodsmap)->Get(name,ret)) {
@@ -275,7 +275,7 @@ void SQSharedState::CallDelayedReleaseHooks(SQVM *vm, int count)
 
 void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
 {
-	switch(type(o)){
+	switch(sqtype(o)){
 	case OT_TABLE:_table(o)->Mark(chain);break;
 	case OT_ARRAY:_array(o)->Mark(chain);break;
 	case OT_USERDATA:_userdata(o)->Mark(chain);break;
@@ -464,7 +464,7 @@ void RefTable::Mark(SQCollectable **chain)
 {
 	RefNode *nodes = (RefNode *)_nodes;
 	for(SQUnsignedInteger n = 0; n < _numofslots; n++) {
-		if(type(nodes->obj) != OT_NULL) {
+		if(sqtype(nodes->obj) != OT_NULL) {
 			SQSharedState::MarkObject(nodes->obj,chain);
 		}
 		nodes++;
@@ -526,7 +526,7 @@ void RefTable::Resize(SQUnsignedInteger size)
 	//rehash
 	SQUnsignedInteger nfound = 0;
 	for(SQUnsignedInteger n = 0; n < oldnumofslots; n++) {
-		if(type(t->obj) != OT_NULL) {
+		if(sqtype(t->obj) != OT_NULL) {
 			//add back;
 			assert(t->refs != 0);
 			RefNode *nn = Add(::HashObj(t->obj)&(_numofslots-1),t->obj);
@@ -559,7 +559,7 @@ RefTable::RefNode *RefTable::Get(SQObject &obj,SQHash &mainpos,RefNode **prev,bo
 	mainpos = ::HashObj(obj)&(_numofslots-1);
 	*prev = NULL;
 	for (ref = _buckets[mainpos]; ref; ) {
-		if(_rawval(ref->obj) == _rawval(obj) && type(ref->obj) == type(obj))
+		if(_rawval(ref->obj) == _rawval(obj) && sqtype(ref->obj) == sqtype(obj))
 			break;
 		*prev = ref;
 		ref = ref->next;

+ 7 - 7
SquiLu/squirrel/sqtable.cpp

@@ -61,7 +61,7 @@ void SQTable::Rehash(bool force)
 	_usednodes = 0;
 	for (SQInteger i=0; i<oldsize; i++) {
 		_HashNode *old = nold+i;
-		if (type(old->key) != OT_NULL)
+		if (sqtype(old->key) != OT_NULL)
 			NewSlot(old->key,old->val);
 	}
 	for(SQInteger k=0;k<oldsize;k++)
@@ -106,7 +106,7 @@ SQTable *SQTable::Clone()
 
 bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val)
 {
-	if(type(key) == OT_NULL)
+	if(sqtype(key) == OT_NULL)
 		return false;
 	_HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1));
 	if (n) {
@@ -117,14 +117,14 @@ bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val)
 }
 bool SQTable::Exists(const SQObjectPtr &key)
 {
-	if(type(key) == OT_NULL)
+	if(sqtype(key) == OT_NULL)
 		return false;
 	_HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1));
 	return n ? true : false;
 }
 bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
 {
-	assert(type(key) != OT_NULL);
+	assert(sqtype(key) != OT_NULL);
 	SQHash h = HashObj(key) & (_numofnodes - 1);
 	_HashNode *n = _Get(key, h);
 	if (n) {
@@ -138,7 +138,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
 	//key not found I'll insert it
 	//main pos is not free
 
-	if(type(mp->key) != OT_NULL) {
+	if(sqtype(mp->key) != OT_NULL) {
 		n = _firstfree;  /* get a free place */
 		SQHash mph = HashObj(mp->key) & (_numofnodes - 1);
 		_HashNode *othern;  /* main position of colliding node */
@@ -167,7 +167,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
 	mp->key = key;
 
 	for (;;) {  /* correct `firstfree' */
-		if (type(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
+		if (sqtype(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
 			mp->val = val;
 			_usednodes++;
 			return true;  /* OK; table still has a free place */
@@ -183,7 +183,7 @@ SQInteger SQTable::Next(bool getweakrefs,const SQObjectPtr &refpos, SQObjectPtr
 {
 	SQInteger idx = (SQInteger)SQTranslateIndex(refpos);
 	while (idx < _numofnodes) {
-		if(type(_nodes[idx].key) != OT_NULL) {
+		if(sqtype(_nodes[idx].key) != OT_NULL) {
 			//first found
 			_HashNode &n = _nodes[idx];
 			outkey = n.key;

+ 3 - 3
SquiLu/squirrel/sqtable.h

@@ -14,7 +14,7 @@
 
 inline SQHash HashObj(const SQObjectPtr &key)
 {
-	switch(type(key)) {
+	switch(sqtype(key)) {
 		case OT_STRING:		return _string(key)->_hash;
 		case OT_FLOAT:		return (SQHash)((SQInteger)_float(key));
 		case OT_BOOL: case OT_INTEGER:	return (SQHash)((SQInteger)_integer(key));
@@ -67,7 +67,7 @@ public:
 	{
 		_HashNode *n = &_nodes[hash];
 		do{
-			if(_rawval(n->key) == _rawval(key) && type(n->key) == type(key)){
+			if(_rawval(n->key) == _rawval(key) && sqtype(n->key) == sqtype(key)){
 				return n;
 			}
 		}while((n = n->next));
@@ -80,7 +80,7 @@ public:
 		_HashNode *n = &_nodes[hash & (_numofnodes - 1)];
 		_HashNode *res = NULL;
 		do{
-			if(type(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
+			if(sqtype(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
 				res = n;
 				break;
 			}

+ 54 - 54
SquiLu/squirrel/sqvm.cpp

@@ -28,7 +28,7 @@
 bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
 {
 	SQInteger res;
-	if((type(o1)|type(o2)) == OT_INTEGER)
+	if((sqtype(o1)|sqtype(o2)) == OT_INTEGER)
 	{
 		SQInteger i1 = _integer(o1), i2 = _integer(o2);
 		switch(op) {
@@ -48,7 +48,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
 
 #define _ARITH_BASE_(op,trg,o1,o2, ARITH_INTEGER) \
 { \
-	switch(type(o1)|type(o2)) { \
+	switch(sqtype(o1)|sqtype(o2)) { \
 		case OT_INTEGER: ARITH_INTEGER;break; \
 		case (OT_FLOAT): trg = _float(o1) op _float(o2); break;\
 		case (OT_FLOAT|OT_INTEGER): trg = tofloat(o1) op tofloat(o2); break;\
@@ -67,7 +67,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
 
 bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
 {
-	SQInteger tmask = type(o1)|type(o2);
+	SQInteger tmask = sqtype(o1)|sqtype(o2);
 
 	switch(tmask) {
 		case OT_INTEGER:{
@@ -227,7 +227,7 @@ bool SQVM::ArithMetaMethod(SQInteger op,const SQObjectPtr &o1,const SQObjectPtr
 bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
 {
 
-	switch(type(o)) {
+	switch(sqtype(o)) {
 	case OT_INTEGER:
 		trg = -_integer(o);
 		return true;
@@ -256,7 +256,7 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
 #define _RET_SUCCEED(exp) { result = (exp); return true; }
 bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
 {
-	SQObjectType t1 = type(o1), t2 = type(o2);
+	SQObjectType t1 = sqtype(o1), t2 = sqtype(o2);
 	if(t1 == t2) {
 		if(_rawval(o1) == _rawval(o2))_RET_SUCCEED(0);
 		SQObjectPtr res;
@@ -275,7 +275,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
 				if(_delegable(o1)->GetMetaMethod(this, MT_CMP, closure)) {
 					Push(o1);Push(o2);
 					if(CallMetaMethod(closure,MT_CMP,2,res)) {
-						if(type(res) != OT_INTEGER) {
+						if(sqtype(res) != OT_INTEGER) {
 							Raise_Error(_SC("_cmp must return an integer"));
 							return false;
 						}
@@ -289,7 +289,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
 			_RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 );
 		}
 		assert(0);
-		//if(type(res)!=OT_INTEGER) { Raise_CompareError(o1,o2); return false; }
+		//if(sqtype(res)!=OT_INTEGER) { Raise_CompareError(o1,o2); return false; }
 		//	_RET_SUCCEED(_integer(res));
 
 	}
@@ -333,7 +333,7 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObject
 
 bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
 {
-	switch(type(o)) {
+	switch(sqtype(o)) {
 	case OT_STRING:
 		res = o;
 		return true;
@@ -354,7 +354,7 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
 			if(_delegable(o)->GetMetaMethod(this, MT_TOSTRING, closure)) {
 				Push(o);
 				if(CallMetaMethod(closure,MT_TOSTRING,1,res)) {
-					if(type(res) == OT_STRING)
+					if(sqtype(res) == OT_STRING)
 						return true;
 				}
 				else {
@@ -568,7 +568,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
 &o3,SQObjectPtr &o4,SQInteger SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
 {
 	SQInteger nrefidx;
-	switch(type(o1)) {
+	switch(sqtype(o1)) {
 	case OT_TABLE:
 		if((nrefidx = _table(o1)->Next(false,o4, o2, o3)) == -1) _FINISH(exitpos);
 		o4 = (SQInteger)nrefidx; _FINISH(1);
@@ -591,7 +591,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
 				Push(o4);
 				if(CallMetaMethod(closure, MT_NEXTI, 2, itr)) {
 					o4 = o2 = itr;
-					if(type(itr) == OT_NULL) _FINISH(exitpos);
+					if(sqtype(itr) == OT_NULL) _FINISH(exitpos);
 					if(!Get(o1, itr, o3, false, DONT_FALL_BACK)) {
 						Raise_Error(_SC("_nexti returned an invalid idx")); // cloud be changed
 						return false;
@@ -612,7 +612,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
             break;
             case SQGenerator::eSuspended:{
                 SQInteger idx = 0;
-                if(type(o4) == OT_INTEGER) {
+                if(sqtype(o4) == OT_INTEGER) {
                     idx = _integer(o4) + 1;
                 }
                 o2 = idx;
@@ -669,14 +669,14 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
 	SQClass *base = NULL;
 	SQObjectPtr attrs;
 	if(baseclass != -1) {
-		if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
+		if(sqtype(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
 		base = _class(_stack._vals[_stackbase + baseclass]);
 	}
 	if(attributes != MAX_FUNC_STACKSIZE) {
 		attrs = _stack._vals[_stackbase+attributes];
 	}
 	target = SQClass::Create(_ss(this),base);
-	if(type(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) {
+	if(sqtype(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) {
 		int nparams = 2;
 		SQObjectPtr ret;
 		Push(target); Push(attrs);
@@ -693,7 +693,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
 bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2)
 {
 	bool res = false;
-	if(type(o1) == type(o2)) {
+	if(sqtype(o1) == sqtype(o2)) {
 		res = (_rawval(o1) == _rawval(o2));
 	}
 	else if(sq_isnumeric(o1) && sq_isnumeric(o2)) {
@@ -705,7 +705,7 @@ bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2)
 bool SQVM::IsEqualIdentity(const SQObjectPtr &o1,const SQObjectPtr &o2)
 {
 	bool res = false;
-	if(type(o1) == type(o2)) {
+	if(sqtype(o1) == sqtype(o2)) {
 		res = (_rawval(o1) == _rawval(o2));
 	}
 	return res;
@@ -713,12 +713,12 @@ bool SQVM::IsEqualIdentity(const SQObjectPtr &o1,const SQObjectPtr &o2)
 
 bool SQVM::IsFalse(SQObjectPtr &o)
 {
-	if(((type(o) & SQOBJECT_CANBEFALSE)
-		&& ( ((type(o) == OT_FLOAT) && (_float(o) == SQFloat(0.0))) ))
+	if(((sqtype(o) & SQOBJECT_CANBEFALSE)
+		&& ( ((sqtype(o) == OT_FLOAT) && (_float(o) == SQFloat(0.0))) ))
 #if !defined(SQUSEDOUBLE) || (defined(SQUSEDOUBLE) && defined(_SQ64))
 		|| (_integer(o) == 0) )  //OT_NULL|OT_INTEGER|OT_BOOL
 #else
-		|| (((type(o) != OT_FLOAT) && (_integer(o) == 0))) )  //OT_NULL|OT_INTEGER|OT_BOOL
+		|| (((sqtype(o) != OT_FLOAT) && (_integer(o) == 0))) )  //OT_NULL|OT_INTEGER|OT_BOOL
 #endif
 	{
 		return true;
@@ -916,7 +916,7 @@ exception_restore:
 			OPCODE_TARGET(DLOAD) { TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue;}
 			OPCODE_TARGET(TAILCALL) {
 				SQObjectPtr &t = STK(arg1);
-				if (type(t) == OT_CLOSURE
+				if (sqtype(t) == OT_CLOSURE
 					&& (!_closure(t)->_function->_bgenerator)){
 					SQObjectPtr clo = t;
 					SQInteger last_top = _top;
@@ -929,7 +929,7 @@ exception_restore:
 							  }
 			OPCODE_TARGET(CALL) {
 					SQObjectPtr clo = STK(arg1);
-					switch (type(clo)) {
+					switch (sqtype(clo)) {
 					case OT_CLOSURE:
 						_GUARD(StartCall(_closure(clo), sarg0, arg3, _stackbase+arg2, false));
 						continue;
@@ -959,7 +959,7 @@ exception_restore:
 							STK(arg0) = inst;
 						}
 						SQInteger stkbase;
-						switch(type(clo)) {
+						switch(sqtype(clo)) {
 							case OT_CLOSURE:
 								stkbase = _stackbase+arg2;
 								_stack._vals[stkbase] = inst;
@@ -994,7 +994,7 @@ exception_restore:
 					  }
 					default:
 						Raise_Error(_SC("attempt to call '%s' [%s]"), GetTypeName(clo),
-                            type(clo) == OT_STRING ? _stringval(clo) : "");
+                            sqtype(clo) == OT_STRING ? _stringval(clo) : "");
 						SQ_THROW();
 					}
 				}
@@ -1134,7 +1134,7 @@ exception_restore:
 			OPCODE_TARGET(INC) {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, false, arg1));} continue;
 			OPCODE_TARGET(INCL) {
 				SQObjectPtr &a = STK(arg1);
-				if(type(a) == OT_INTEGER) {
+				if(sqtype(a) == OT_INTEGER) {
 					a._unVal.nInteger = _integer(a) + sarg3;
 				}
 				else {
@@ -1145,7 +1145,7 @@ exception_restore:
 			OPCODE_TARGET(PINC) {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, true, arg1));} continue;
 			OPCODE_TARGET(PINCL) {
 				SQObjectPtr &a = STK(arg1);
-				if(type(a) == OT_INTEGER) {
+				if(sqtype(a) == OT_INTEGER) {
 					TARGET = a;
 					a._unVal.nInteger = _integer(a) + sarg3;
 				}
@@ -1157,9 +1157,9 @@ exception_restore:
 			OPCODE_TARGET(CMP) {	_GUARD(CMP_OP((CmpOP)arg3,STK(arg2),STK(arg1),TARGET))	continue;}
 			OPCODE_TARGET(EXISTS) { TARGET = Get(STK(arg1), STK(arg2), temp_reg, true,EXISTS_FALL_BACK);continue;}
 			OPCODE_TARGET(INSTANCEOF) {
-				if(type(STK(arg1)) != OT_CLASS)
+				if(sqtype(STK(arg1)) != OT_CLASS)
 				{Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();}
-				TARGET = (type(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false;
+				TARGET = (sqtype(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false;
 				continue;}
 			OPCODE_TARGET(AND) {
 				if(IsFalse(STK(arg2))) {
@@ -1176,7 +1176,7 @@ exception_restore:
 			OPCODE_TARGET(NEG) { _GUARD(NEG_OP(TARGET,STK(arg1))); continue;}
 			OPCODE_TARGET(NOT) { TARGET = IsFalse(STK(arg1)); continue;}
 			OPCODE_TARGET(BWNOT) {
-				if(type(STK(arg1)) == OT_INTEGER) {
+				if(sqtype(STK(arg1)) == OT_INTEGER) {
 					SQInteger t = _integer(STK(arg1));
 					TARGET = SQInteger(~t);
 					continue;
@@ -1206,7 +1206,7 @@ exception_restore:
 				}
 				continue;
 			OPCODE_TARGET(RESUME) {
-				if(type(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();}
+				if(sqtype(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();}
 				_GUARD(_generator(STK(arg1))->Resume(this, TARGET));
 				traps += ci->_etraps;
                 continue;}
@@ -1215,7 +1215,7 @@ exception_restore:
 				ci->_ip += tojump; }
 				continue;
 			OPCODE_TARGET(POSTFOREACH) {
-				assert(type(STK(arg0)) == OT_GENERATOR);
+				assert(sqtype(STK(arg0)) == OT_GENERATOR);
 				if(_generator(STK(arg0))->_state == SQGenerator::eDead)
 					ci->_ip += (sarg1 - 1);
 				continue;}
@@ -1312,7 +1312,7 @@ bool SQVM::CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr
 
 void SQVM::CallErrorHandler(SQObjectPtr &error)
 {
-	if(type(_errorhandler) != OT_NULL) {
+	if(sqtype(_errorhandler) != OT_NULL) {
 		SQObjectPtr out;
 		Push(_roottable); Push(error);
 		Call(_errorhandler, 2, _top-2, out,SQFalse);
@@ -1322,7 +1322,7 @@ void SQVM::CallErrorHandler(SQObjectPtr &error)
 
 void SQVM::CallAtExitHandler()
 {
-	if(type(_atexithandler) != OT_NULL) {
+	if(sqtype(_atexithandler) != OT_NULL) {
 		SQObjectPtr out;
 		Push(_roottable);
 		Call(_atexithandler, 1, _top-1, out,SQFalse);
@@ -1335,8 +1335,8 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forcedline)
 	_debughook = false;
 	SQFunctionProto *func=_closure(ci->_closure)->_function;
 	if(_debughook_native) {
-		const SQChar *src = type(func->_sourcename) == OT_STRING?_stringval(func->_sourcename):NULL;
-		const SQChar *fname = type(func->_name) == OT_STRING?_stringval(func->_name):NULL;
+		const SQChar *src = sqtype(func->_sourcename) == OT_STRING?_stringval(func->_sourcename):NULL;
+		const SQChar *fname = sqtype(func->_name) == OT_STRING?_stringval(func->_name):NULL;
 		SQInteger line = forcedline?forcedline:func->GetLine(ci->_ip);
 		_debughook_native(this,type,src,line,fname);
 	}
@@ -1377,7 +1377,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newb
 					//if nclosure->_env is set then check it instead
 					ptype = nclosure->_env->_obj._type;
 				}
-				else ptype = type(_stack._vals[newbase+i]);
+				else ptype = sqtype(_stack._vals[newbase+i]);
 
 				if(!(ptype & tc._vals[i])) {
 					Raise_ParamTypeError(i,tc._vals[i],ptype);
@@ -1428,7 +1428,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newb
 
 bool SQVM::Get(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest,bool raw, SQInteger selfidx)
 {
-	switch(type(self)){
+	switch(sqtype(self)){
 	case OT_TABLE:
 		if(_table(self)->Get(key,dest))return true;
 		break;
@@ -1479,7 +1479,7 @@ bool SQVM::Get(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest,
 bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
 {
 	SQTable *ddel = NULL;
-	switch(type(self)) {
+	switch(sqtype(self)) {
 		case OT_CLASS: ddel = _class_ddel; break;
 		case OT_TABLE: ddel = _table_ddel; break;
 		case OT_ARRAY: ddel = _array_ddel; break;
@@ -1498,7 +1498,7 @@ bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,
 
 SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
 {
-	switch(type(self)){
+	switch(sqtype(self)){
 	case OT_TABLE:
 	case OT_USERDATA:
         //delegation
@@ -1521,7 +1521,7 @@ SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObj
 			}
 			else {
 				Pop(2);
-				if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
+				if(sqtype(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
 					return FALLBACK_ERROR;
 				}
 			}
@@ -1536,7 +1536,7 @@ SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObj
 
 bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,SQInteger selfidx)
 {
-	switch(type(self)){
+	switch(sqtype(self)){
 	case OT_TABLE:
 		if(_table(self)->Set(key,val)) return true;
 		break;
@@ -1573,7 +1573,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
 
 SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val)
 {
-	switch(type(self)) {
+	switch(sqtype(self)) {
 	case OT_TABLE:
 		if(_table(self)->_delegate) {
 			if(Set(_table(self)->_delegate,key,val,DONT_FALL_BACK))	return FALLBACK_OK;
@@ -1593,7 +1593,7 @@ SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const
 			}
 			else {
                 Pop(3);
-				if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
+				if(sqtype(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
 					return FALLBACK_ERROR;
 				}
 			}
@@ -1610,7 +1610,7 @@ bool SQVM::Clone(const SQObjectPtr &self,SQObjectPtr &target)
 {
 	SQObjectPtr temp_reg;
 	SQObjectPtr newobj;
-	switch(type(self)){
+	switch(sqtype(self)){
 	case OT_TABLE:
 		newobj = _table(self)->Clone();
 		goto cloned_mt;
@@ -1638,14 +1638,14 @@ cloned_mt:
 
 bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw)
 {
-	if(type(self) != OT_CLASS) {
+	if(sqtype(self) != OT_CLASS) {
 		Raise_Error(_SC("object must be a class"));
 		return false;
 	}
 	SQClass *c = _class(self);
 	if(!raw) {
 		SQObjectPtr &mm = c->_metamethods[MT_NEWMEMBER];
-		if(type(mm) != OT_NULL ) {
+		if(sqtype(mm) != OT_NULL ) {
 			Push(self); Push(key); Push(val);
 			Push(attrs);
 			Push(bstatic);
@@ -1654,7 +1654,7 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjec
 	}
 	if(!NewSlot(self, key, val,bstatic))
 		return false;
-	if(type(attrs) != OT_NULL) {
+	if(sqtype(attrs) != OT_NULL) {
 		c->SetAttributes(key,attrs);
 	}
 	return true;
@@ -1662,8 +1662,8 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjec
 
 bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
 {
-	if(type(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; }
-	switch(type(self)) {
+	if(sqtype(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; }
+	switch(sqtype(self)) {
 	case OT_TABLE: {
 		bool rawcall = true;
 		if(_table(self)->_delegate) {
@@ -1723,7 +1723,7 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject
 
 bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res)
 {
-	switch(type(self)) {
+	switch(sqtype(self)) {
 	case OT_TABLE:
 	case OT_INSTANCE:
 	case OT_USERDATA: {
@@ -1735,7 +1735,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
 			return CallMetaMethod(closure,MT_DELSLOT,2,res);
 		}
 		else {
-			if(type(self) == OT_TABLE) {
+			if(sqtype(self) == OT_TABLE) {
 				if(_table(self)->Get(key,t)) {
 					_table(self)->Remove(key);
 				}
@@ -1764,7 +1764,7 @@ bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams,SQInteger stackbase,SQObj
 #ifdef _DEBUG
 SQInteger prevstackbase = _stackbase;
 #endif
-	switch(type(closure)) {
+	switch(sqtype(closure)) {
 	case OT_CLOSURE:
 		return Execute(closure, nparams, stackbase, outres, raiseerror);
 		break;
@@ -1778,7 +1778,7 @@ SQInteger prevstackbase = _stackbase;
 		SQObjectPtr constr;
 		SQObjectPtr temp;
 		CreateClassInstance(_class(closure),outres,constr);
-		SQObjectType ctype = type(constr);
+		SQObjectType ctype = sqtype(constr);
 		if (ctype == OT_NATIVECLOSURE || ctype == OT_CLOSURE) {
 			_stack[stackbase] = outres;
 			return Call(constr,nparams,stackbase,temp,raiseerror);
@@ -1878,7 +1878,7 @@ void SQVM::LeaveFrame() {
 			SQObjectPtr dtor;
 			if(_instance(val)->_class->GetDestructor(dtor)){
 				SQInteger stkbase;
-				switch(type(dtor)) {
+				switch(sqtype(dtor)) {
 					case OT_CLOSURE:
 					case OT_NATIVECLOSURE:{
 						SQObjectPtr res;
@@ -2007,7 +2007,7 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
 		SQObjectPtr &obj=_stack[i];
 		if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" "));
 		scprintf(_SC("[%d]:"),n);
-		switch(type(obj)){
+		switch(sqtype(obj)){
 		case OT_FLOAT:			scprintf(_SC("FLOAT %.3f"),_float(obj));break;
 		case OT_INTEGER:		scprintf(_SC("INTEGER %d"),_integer(obj));break;
 		case OT_BOOL:			scprintf(_SC("BOOL %s"),_integer(obj)?"true":"false");break;

Some files were not shown because too many files changed in this diff