Browse Source

Merge branch 'master' of https://github.com/albertodemichelis/squirrel

albertodemichelis 5 years ago
parent
commit
0c5d01ab2d

+ 84 - 51
CMakeLists.txt

@@ -1,76 +1,109 @@
-if(MSVC)
-  cmake_minimum_required(VERSION 3.4)
-else()
-  cmake_minimum_required(VERSION 2.8)
-endif()
+cmake_minimum_required(VERSION 3.4)
+project(squirrel VERSION 3.1 LANGUAGES C CXX)
 
 option(DISABLE_STATIC "Avoid building/installing static libraries.")
 option(LONG_OUTPUT_NAMES "Use longer names for binaries and libraries: squirrel3 (not sq).")
 
-set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}" CACHE PATH "")
 if (NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE "Release")
 endif ()
 
-project(squirrel C CXX)
+include(GNUInstallDirs)
 
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
+set(CMAKE_CXX_STANDARD 11)
 
 if(CMAKE_COMPILER_IS_GNUCXX)
-  set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra -pedantic -Wcast-qual)
-
-  if(CMAKE_BUILD_TYPE STREQUAL "Release")
-    set(SQ_FLAGS ${SQ_FLAGS} -O3)
-  elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
-    set(SQ_FLAGS ${SQ_FLAGS} -O3 -g)
-  elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
-    set(SQ_FLAGS ${SQ_FLAGS} -Os)
-  elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
-    set(SQ_FLAGS ${SQ_FLAGS} -pg -pie -gstabs -g3 -Og)
-  endif()
-
-  if(CMAKE_VERSION VERSION_GREATER 3)
-    add_compile_options(${SQ_FLAGS})
-  else()
-    add_definitions(${SQ_FLAGS})
-  endif()
-
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -std=c++0x")
+  add_compile_options(
+    "$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti;-fno-exceptions>"
+    -fno-strict-aliasing
+    -Wall
+    -Wextra
+    -pedantic
+    -Wcast-qual
+    "$<$<CONFIG:Release>:-O3>"
+    "$<$<CONFIG:RelWithDebInfo>:-O3;-g>"
+    "$<$<CONFIG:MinSizeRel>:-Os>"
+    "$<$<CONFIG:Debug>:-pg;-pie;-gstabs;-g3;-Og>"
+    )
 elseif(MSVC)
   set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
 endif()
 
-if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-  add_definitions(-D_SQ64)
-endif()
+add_subdirectory(squirrel)
+add_subdirectory(sqstdlib)
+add_subdirectory(sq)
 
-if(NOT SQ_DISABLE_INSTALLER)
-  if(NOT INSTALL_BIN_DIR)
-    set(INSTALL_BIN_DIR bin)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+  set(tgts)
+  if(NOT DISABLE_DYNAMIC)
+    list(APPEND tgts squirrel sqstdlib sq)
   endif()
-
-  if(NOT INSTALL_LIB_DIR)
-    set(INSTALL_LIB_DIR lib)
+  if(NOT DISABLE_STATIC)
+    list(APPEND tgts squirrel_static sqstdlib_static sq_static)
   endif()
+  foreach(t ${tgts})
+    target_compile_definitions(${t} PUBLIC -D_SQ64)
+  endforeach()
 endif()
 
-add_subdirectory(squirrel)
-add_subdirectory(sqstdlib)
-add_subdirectory(sq)
-
-if(NOT WIN32 AND NOT DISABLE_DYNAMIC)
+if(NOT DISABLE_DYNAMIC)
   set_target_properties(squirrel sqstdlib PROPERTIES SOVERSION 0 VERSION 0.0.0)
 endif()
 
-if(INSTALL_INC_DIR)
-  set(SQ_PUB_HEADERS include/sqconfig.h
-                     include/sqstdaux.h
-                     include/sqstdblob.h
-                     include/sqstdio.h
-                     include/sqstdmath.h
-                     include/sqstdstring.h
-                     include/sqstdsystem.h
-                     include/squirrel.h)
-  install(FILES ${SQ_PUB_HEADERS} DESTINATION ${INSTALL_INC_DIR})
+if(NOT SQ_DISABLE_INSTALLER AND NOT SQ_DISABLE_HEADER_INSTALLER)
+  install(FILES
+    include/sqconfig.h
+    include/squirrel.h
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+    COMPONENT Development
+    )
+  install(FILES
+    include/sqstdaux.h
+    include/sqstdblob.h
+    include/sqstdio.h
+    include/sqstdmath.h
+    include/sqstdstring.h
+    include/sqstdsystem.h
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+    COMPONENT Development
+    )
+endif()
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+  "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-config-version.cmake"
+  VERSION "${squirrel_VERSION}"
+  COMPATIBILITY AnyNewerVersion
+  )
+
+configure_package_config_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/squirrel-config.cmake.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-config.cmake"
+  INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/squirrel"
+  )
+
+export(EXPORT squirrel
+  NAMESPACE squirrel::
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-targets.cmake"
+  )
+
+if(NOT SQ_DISABLE_INSTALLER AND NOT SQ_DISABLE_CMAKE_INSTALLER)
+  install(FILES
+    "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-config-version.cmake"
+    "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-config.cmake"
+    DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/squirrel"
+    COMPONENT Development
+    )
+
+  install(EXPORT squirrel
+    NAMESPACE squirrel::
+    DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/squirrel"
+    FILE "squirrel-targets.cmake"
+    COMPONENT Development
+    )
 endif()

+ 9 - 9
COMPILE

@@ -38,23 +38,23 @@ under Linux, type something like
  $ make install
  $ cd ..; rm -r build
 
-The default installation directory will be the top source directory,
-i. e. the binaries will go into bin/ and the libraries into lib/. You
-can change this behavior by calling CMake like this:
+The default installation directory will be /usr/local on Unix platforms,
+and C:/Program Files/squirrel on Windows. The binaries will go into bin/
+and the libraries into lib/. You can change this behavior by calling CMake like
+this:
 
  $ cmake .. -DCMAKE_INSTALL_PREFIX=/some/path/on/your/system
 
-With the INSTALL_BIN_DIR and INSTALL_LIB_DIR options, the directories
+With the CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_LIBDIR options, the directories
 the binaries & libraries will go in (relative to CMAKE_INSTALL_PREFIX)
 can be specified. For instance,
 
- $ cmake .. -DINSTALL_LIB_DIR=lib64
+ $ cmake .. -DCMAKE_INSTALL_LIBDIR=lib64
 
 will install the libraries into a 'lib64' subdirectory in the top
-source directory. If INSTALL_INC_DIR is set, the public header files
-will be installed into the directory the value of INSTALL_INC_DIR
-points to. There is no default directory - if you want only the
-binaries and no headers, just don't specify INSTALL_INC_DIR, and no
+source directory. The public header files will be installed into the directory
+the value of CMAKE_INSTALL_INCLUDEDIR points to. If you want only the
+binaries and no headers, just set -DSQ_DISABLE_HEADER_INSTALLER=ON, and no
 header files will be installed.
 
 Under Windows, it is probably easiest to use the CMake GUI interface,

+ 1 - 0
README

@@ -5,6 +5,7 @@ This project has successfully been compiled and run on
  * Windows (x86 and amd64)
  * Linux (x86, amd64 and ARM)
  * Illumos (x86 and amd64)
+ * FreeBSD (x86 and ARM)
 
 The following compilers have been confirmed to be working:
     MS Visual C++  6.0 (all on x86 and amd64)

+ 1 - 1
doc/source/reference/api/object_creation_and_handling.rst

@@ -560,7 +560,7 @@ sets the userpointer of the class instance at position idx in the stack.
     :param const SQChar * name: the name that has to be set
     :returns: an SQRESULT
 
-sets the name of the native closure at the position idx in the stack. The name of a native closure is purely for debug purposes. The name is retrieved trough the function sq_stackinfos() while the closure is in the call stack.
+sets the name of the native closure at the position idx in the stack. The name of a native closure is purely for debug purposes. The name is retrieved through the function sq_stackinfos() while the closure is in the call stack.
 
 
 

+ 2 - 0
include/sqstdaux.h

@@ -9,6 +9,8 @@ extern "C" {
 SQUIRREL_API void sqstd_seterrorhandlers(HSQUIRRELVM v);
 SQUIRREL_API void sqstd_printcallstack(HSQUIRRELVM v);
 
+SQUIRREL_API SQRESULT sqstd_throwerrorf(HSQUIRRELVM v,const SQChar *err,...);
+
 #ifdef __cplusplus
 } /*extern "C"*/
 #endif

+ 2 - 0
include/sqstdstring.h

@@ -24,6 +24,8 @@ SQUIRREL_API SQBool sqstd_rex_getsubexp(SQRex* exp, SQInteger n, SQRexMatch *sub
 
 SQUIRREL_API SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output);
 
+SQUIRREL_API void sqstd_pushstringf(HSQUIRRELVM v,const SQChar *s,...);
+
 SQUIRREL_API SQRESULT sqstd_register_stringlib(HSQUIRRELVM v);
 
 #ifdef __cplusplus

+ 15 - 11
sq/CMakeLists.txt

@@ -1,22 +1,30 @@
+set(CMAKE_C_STANDARD 99)
 if(NOT DISABLE_DYNAMIC)
-  if(CMAKE_COMPILER_IS_GNUCXX)
-    set_source_files_properties(sq.c PROPERTIES COMPILE_FLAGS -std=c99)
-  endif()
   add_executable(sq sq.c)
-  set_target_properties(sq PROPERTIES LINKER_LANGUAGE C)
+  add_executable(squirrel::interpreter ALIAS sq)
+  set_target_properties(sq PROPERTIES LINKER_LANGUAGE C EXPORT_NAME interpreter)
   target_link_libraries(sq squirrel sqstdlib)
   if(NOT SQ_DISABLE_INSTALLER)
-    install(TARGETS sq RUNTIME DESTINATION ${INSTALL_BIN_DIR})
+    install(TARGETS sq EXPORT squirrel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime)
   endif()
+  target_include_directories(sq PUBLIC
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+    )
 endif()
 
 if(NOT DISABLE_STATIC)
   add_executable(sq_static sq.c)
-  set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C)
+  add_executable(squirrel::interpreter_static ALIAS sq)
+  set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C EXPORT_NAME interpreter_static)
   target_link_libraries(sq_static squirrel_static sqstdlib_static)
   if(NOT SQ_DISABLE_INSTALLER)
-    install(TARGETS sq_static RUNTIME DESTINATION ${INSTALL_BIN_DIR})
+    install(TARGETS sq_static EXPORT squirrel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime)
   endif()
+  target_include_directories(sq_static PUBLIC
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+    )
 endif()
 
 if(LONG_OUTPUT_NAMES)
@@ -28,7 +36,3 @@ if(LONG_OUTPUT_NAMES)
     set_target_properties(sq_static PROPERTIES OUTPUT_NAME squirrel3_static)
   endif()
 endif()
-
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT DISABLE_STATIC)
-  set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static")
-endif()

+ 21 - 4
sqstdlib/CMakeLists.txt

@@ -9,19 +9,36 @@ set(SQSTDLIB_SRC sqstdaux.cpp
 
 if(NOT DISABLE_DYNAMIC)
   add_library(sqstdlib SHARED ${SQSTDLIB_SRC})
+  add_library(squirrel::sqstdlib ALIAS sqstdlib)
+  set_property(TARGET sqstdlib PROPERTY EXPORT_NAME sqstdlib)
   target_link_libraries(sqstdlib squirrel)
   if(NOT SQ_DISABLE_INSTALLER)
-    install(TARGETS sqstdlib RUNTIME DESTINATION ${INSTALL_BIN_DIR}
-                             LIBRARY DESTINATION ${INSTALL_LIB_DIR}
-                             ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
+    install(TARGETS sqstdlib EXPORT squirrel
+      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Libraries
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries NAMELINK_SKIP
+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries
+      )
+    install(TARGETS sqstdlib EXPORT squirrel
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development NAMELINK_ONLY
+      )
   endif()
+  target_include_directories(sqstdlib PUBLIC
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+    )
 endif()
 
 if(NOT DISABLE_STATIC)
   add_library(sqstdlib_static STATIC ${SQSTDLIB_SRC})
+  add_library(squirrel::sqstdlib_static ALIAS sqstdlib_static)
+  set_property(TARGET sqstdlib_static PROPERTY EXPORT_NAME sqstdlib_static)
   if(NOT SQ_DISABLE_INSTALLER)
-    install(TARGETS sqstdlib_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
+    install(TARGETS sqstdlib_static EXPORT squirrel ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
   endif()
+  target_include_directories(sqstdlib_static PUBLIC
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+    )
 endif()
 
 if(LONG_OUTPUT_NAMES)

+ 21 - 0
sqstdlib/sqstdaux.cpp

@@ -1,7 +1,9 @@
 /* see copyright notice in squirrel.h */
 #include <squirrel.h>
 #include <sqstdaux.h>
+#include <stdio.h>
 #include <assert.h>
+#include <stdarg.h>
 
 void sqstd_printcallstack(HSQUIRRELVM v)
 {
@@ -128,3 +130,22 @@ void sqstd_seterrorhandlers(HSQUIRRELVM v)
     sq_newclosure(v,_sqstd_aux_printerror,0);
     sq_seterrorhandler(v);
 }
+
+SQRESULT sqstd_throwerrorf(HSQUIRRELVM v,const SQChar *err,...)
+{
+    SQInteger n=256;
+    va_list args;
+begin:
+    va_start(args,err);
+    SQChar *b=sq_getscratchpad(v,n);
+    SQInteger r=scvsprintf(b,n,err,args);
+    va_end(args);
+    if (r>=n) {
+        n=r+1;//required+null
+        goto begin;
+    } else if (r<0) {
+        return sq_throwerror(v,_SC("@failed to generate formatted error message"));
+    } else {
+        return sq_throwerror(v,b);
+    }
+}

+ 21 - 1
sqstdlib/sqstdstring.cpp

@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <assert.h>
+#include <stdarg.h>
 
 #define MAX_FORMAT_LEN  20
 #define MAX_WFORMAT_LEN 3
@@ -153,6 +154,25 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
     return SQ_OK;
 }
 
+void sqstd_pushstringf(HSQUIRRELVM v,const SQChar *s,...)
+{
+    SQInteger n=256;
+    va_list args;
+begin:
+    va_start(args,s);
+    SQChar *b=sq_getscratchpad(v,n);
+    SQInteger r=scvsprintf(b,n,s,args);
+    va_end(args);
+    if (r>=n) {
+        n=r+1;//required+null
+        goto begin;
+    } else if (r<0) {
+        sq_pushnull(v);
+    } else {
+        sq_pushstring(v,b,r);
+    }
+}
+
 static SQInteger _string_printf(HSQUIRRELVM v)
 {
     SQChar *dest = NULL;
@@ -161,7 +181,7 @@ static SQInteger _string_printf(HSQUIRRELVM v)
         return -1;
 
     SQPRINTFUNCTION printfunc = sq_getprintfunc(v);
-    if(printfunc) printfunc(v,dest);
+    if(printfunc) printfunc(v,_SC("%s"),dest);
 
     return 0;
 }

+ 11 - 3
sqstdlib/sqstdsystem.cpp

@@ -19,6 +19,10 @@
 #define scremove remove
 #define screname rename
 #endif
+#ifdef IOS
+	#include <spawn.h>
+	extern char **environ;
+#endif
 
 static SQInteger _system_getenv(HSQUIRRELVM v)
 {
@@ -30,18 +34,22 @@ static SQInteger _system_getenv(HSQUIRRELVM v)
     return 0;
 }
 
-
 static SQInteger _system_system(HSQUIRRELVM v)
 {
     const SQChar *s;
     if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
-        sq_pushinteger(v,scsystem(s));
+	#ifdef IOS
+		pid_t pid;
+		posix_spawn(&pid, s, NULL, NULL, NULL, environ);
+		sq_pushinteger(v, 0);
+	#else
+	        sq_pushinteger(v,scsystem(s));
+	#endif
         return 1;
     }
     return sq_throwerror(v,_SC("wrong param"));
 }
 
-
 static SQInteger _system_clock(HSQUIRRELVM v)
 {
     sq_pushfloat(v,((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC);

+ 4 - 0
squirrel-config.cmake.in

@@ -0,0 +1,4 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/squirrel-config-version.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/squirrel-targets.cmake")

+ 21 - 4
squirrel/CMakeLists.txt

@@ -13,18 +13,35 @@ set(SQUIRREL_SRC sqapi.cpp
 
 if(NOT DISABLE_DYNAMIC)
   add_library(squirrel SHARED ${SQUIRREL_SRC})
+  add_library(squirrel::squirrel ALIAS squirrel)
+  set_property(TARGET squirrel PROPERTY EXPORT_NAME squirrel)
   if(NOT SQ_DISABLE_INSTALLER)
-    install(TARGETS squirrel RUNTIME DESTINATION ${INSTALL_BIN_DIR}
-                         LIBRARY DESTINATION ${INSTALL_LIB_DIR}
-                         ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
+    install(TARGETS squirrel EXPORT squirrel
+      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Libraries
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries NAMELINK_SKIP
+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Libraries
+      )
+    install(TARGETS squirrel EXPORT squirrel
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development NAMELINK_ONLY
+      )
   endif()
+  target_include_directories(squirrel PUBLIC
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+    )
 endif()
 
 if(NOT DISABLE_STATIC)
   add_library(squirrel_static STATIC ${SQUIRREL_SRC})
+  add_library(squirrel::squirrel_static ALIAS squirrel_static)
+  set_property(TARGET squirrel_static PROPERTY EXPORT_NAME squirrel_static)
   if(NOT SQ_DISABLE_INSTALLER)
-    install(TARGETS squirrel_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
+    install(TARGETS squirrel_static EXPORT squirrel ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
   endif()
+  target_include_directories(squirrel_static PUBLIC
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+    )
 endif()
 
 if(LONG_OUTPUT_NAMES)

+ 1 - 1
squirrel/sqapi.cpp

@@ -978,7 +978,7 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx)
     case OT_TABLE:
         if(sq_type(mt) == OT_TABLE) {
             if(!_table(self)->SetDelegate(_table(mt))) {
-                return sq_throwerror(v, _SC("delagate cycle"));
+                return sq_throwerror(v, _SC("delegate cycle"));
             }
             v->Pop();
         }

+ 1 - 1
squirrel/sqbaselib.cpp

@@ -625,7 +625,7 @@ static SQInteger __map_array(SQArray *dest,SQArray *src,HSQUIRRELVM v) {
     SQObject &closure = stack_get(v, 2);
     v->Push(closure);
 
-    SQInteger nArgs;
+    SQInteger nArgs = 0;
     if(sq_type(closure) == OT_CLOSURE) {
         nArgs = _closure(closure)->_function->_nparameters;
     }

+ 1 - 1
squirrel/sqcompiler.cpp

@@ -635,7 +635,7 @@ public:
                 }
                 break;
             case _SC('['):
-                if(_lex._prevtoken == _SC('\n')) Error(_SC("cannot brake deref/or comma needed after [exp]=exp slot declaration"));
+                if(_lex._prevtoken == _SC('\n')) Error(_SC("cannot break deref/or comma needed after [exp]=exp slot declaration"));
                 Lex(); Expression(); Expect(_SC(']'));
                 pos = -1;
                 if(_es.etype==BASE) {

+ 0 - 4
squirrel/sqfuncstate.cpp

@@ -481,7 +481,6 @@ void SQFuncState::AddInstruction(SQInstruction &i)
         break;
         case _OP_GET:
             if( pi.op == _OP_LOAD && pi._arg0 == i._arg2 && (!IsLocal(pi._arg0))){
-                pi._arg1 = pi._arg1;
                 pi._arg2 = (unsigned char)i._arg1;
                 pi.op = _OP_GETK;
                 pi._arg0 = i._arg0;
@@ -493,7 +492,6 @@ void SQFuncState::AddInstruction(SQInstruction &i)
             if( pi.op == _OP_LOAD  && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){
                 pi.op = _OP_PREPCALLK;
                 pi._arg0 = i._arg0;
-                pi._arg1 = pi._arg1;
                 pi._arg2 = i._arg2;
                 pi._arg3 = i._arg3;
                 return;
@@ -511,7 +509,6 @@ void SQFuncState::AddInstruction(SQInstruction &i)
             if(aat != -1 && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){
                 pi.op = _OP_APPENDARRAY;
                 pi._arg0 = i._arg0;
-                pi._arg1 = pi._arg1;
                 pi._arg2 = (unsigned char)aat;
                 pi._arg3 = MAX_FUNC_STACKSIZE;
                 return;
@@ -553,7 +550,6 @@ void SQFuncState::AddInstruction(SQInstruction &i)
             {
                 pi.op = i.op;
                 pi._arg0 = i._arg0;
-                pi._arg1 = pi._arg1;
                 pi._arg2 = i._arg2;
                 pi._arg3 = MAX_FUNC_STACKSIZE;
                 return;

+ 6 - 2
squirrel/sqvm.cpp

@@ -296,6 +296,9 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
     case OT_BOOL:
         scsprintf(_sp(sq_rsl(6)),sq_rsl(6),_integer(o)?_SC("true"):_SC("false"));
         break;
+    case OT_NULL:
+        scsprintf(_sp(sq_rsl(5)),sq_rsl(5),_SC("null"));
+        break;
     case OT_TABLE:
     case OT_USERDATA:
     case OT_INSTANCE:
@@ -668,7 +671,7 @@ bool SQVM::IsFalse(SQObjectPtr &o)
 #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
+        || (((sq_type(o) != OT_FLOAT) && (_integer(o) == 0))) )  //OT_NULL|OT_INTEGER|OT_BOOL
 #endif
     {
         return true;
@@ -1602,6 +1605,7 @@ SQInteger prevstackbase = _stackbase;
                    }
         break;
     default:
+        Raise_Error(_SC("attempt to call '%s'"), GetTypeName(closure));
         return false;
     }
 #ifdef _DEBUG
@@ -1772,7 +1776,7 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
         case OT_USERPOINTER:    scprintf(_SC("USERPOINTER %p"),_userpointer(obj));break;
         case OT_CLASS:          scprintf(_SC("CLASS %p"),_class(obj));break;
         case OT_INSTANCE:       scprintf(_SC("INSTANCE %p"),_instance(obj));break;
-        case OT_WEAKREF:        scprintf(_SC("WEAKERF %p"),_weakref(obj));break;
+        case OT_WEAKREF:        scprintf(_SC("WEAKREF %p"),_weakref(obj));break;
         default:
             assert(0);
             break;