Various improvements

This commit is contained in:
Fabian Wolff 2016-03-06 19:43:57 +01:00
parent b115b84dd1
commit 2fb3522470
21 changed files with 155 additions and 136 deletions

View File

@ -1,39 +1,42 @@
cmake_minimum_required(VERSION 2.8)
project(squirrel)
# get machine
execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE DUMP_MACHINE OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Dump Machine : ${DUMP_MACHINE}")
# get architecture
if(NOT DEFINED ARCHITECTURE)
string(FIND ${DUMP_MACHINE} "-" DUMP_MACHINE_STRIP)
string(SUBSTRING ${DUMP_MACHINE} 0 ${DUMP_MACHINE_STRIP} ARCHITECTURE)
endif()
message("Architecture : ${ARCHITECTURE}")
# global includes
include_directories(
${PROJECT_SOURCE_DIR}/include
)
# global flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -Wall -fno-strict-aliasing")
set(SQGLOB_FLAGS_RELEASE "-O2")
set(SQGLOB_FLAGS_DEBUG "-pg -pie -gstabs -g3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${SQGLOB_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_DEBUG} ${SQGLOB_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SQGLOB_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} ${SQGLOB_FLAGS_DEBUG}")
if("${ARCHITECTURE}" STREQUAL "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SQ64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SQ64")
if(MSVC)
cmake_minimum_required(VERSION 3.4)
else()
cmake_minimum_required(VERSION 2.8)
endif()
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}" CACHE PATH "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
project(squirrel C CXX)
include_directories(${CMAKE_SOURCE_DIR}/include)
if(CMAKE_COMPILER_IS_GNUCXX)
set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(SQ_FLAGS ${SQ_FLAGS} -O3)
else()
set(SQ_FLAGS ${SQ_FLAGS} -pg -pie -gstabs -g3)
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")
elseif(MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-D_SQ64)
endif()
# subdirectories
add_subdirectory(squirrel)
add_subdirectory(sqstdlib)
add_subdirectory(sq)
install(FILES doc/squirrel3.pdf doc/sqstdlib3.pdf DESTINATION share/doc/squirrel3)

23
COMPILE
View File

@ -23,6 +23,29 @@ samples
HOW TO COMPILE
---------------------------------------------------------
CMAKE USERS
.........................................................
If you want to build the shared libraries under Windows using Visual
Studio, you will have to use CMake version 3.4 or newer. If not, an
earlier version will suffice. For a traditional out-of-source build
under Linux, type something like
$ mkdir build # Create temporary build directory
$ cd build
$ cmake .. # CMake will determine all the necessary information,
# including the platform (32- vs. 64-Bit)
$ make
$ 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:
$ cmake .. -DCMAKE_INSTALL_PREFIX=/some/path/on/your/system
Under Windows, it is probably easiest to use the CMake GUI interface.
GCC USERS
.........................................................
There is a very simple makefile that compiles all libraries and exes

23
README
View File

@ -1,16 +1,26 @@
The programming language SQUIRREL 3.1 stable
--------------------------------------------------
The project has been compiled and run on Windows(x86 and x64) and
Linux(x86 and x64) and Solaris(x86 and x64).
This project has successfully been compiled and run on
* Windows (x86 and amd64)
* Linux (x86, amd64 and ARM)
* Solaris (x86 and amd64)
Has been tested with the following compilers:
MS Visual C++ 6.0,7.0,7.1,8.0,9.0,10.0 (32 and 64bits)
The following compilers have been confirmed to be working:
MS Visual C++ 6.0 (all on x86 and amd64)
7.0 |
7.1 v
8.0
9.0
10.0 ---
12.0 (only on x86)
MinGW gcc 3.2 (mingw special 20020817-1)
Cygnus gcc 3.2
Linux gcc 3.2.3
Linux gcc 4.0.0 (x86 & 64bits)
Solaris gcc 4.0.0 (x86 & 64bits)
4.0.0 (x86 and amd64)
5.3.1 (amd64)
Solaris gcc 4.0.0 (x86 and amd64)
ARM Linux gcc 4.6.3 (Raspberry Pi Model B)
Feedback and suggestions are appreciated
@ -20,4 +30,3 @@ wiki - http://wiki.squirrel-lang.org
author - alberto@demichelis.net
END OF README

View File

@ -392,6 +392,12 @@ SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
#define SQ_FAILED(res) (res<0)
#define SQ_SUCCEEDED(res) (res>=0)
#ifdef __GNUC__
# define SQ_UNUSED_ARG(x) __attribute__((unused)) x
#else
# define SQ_UNUSED_ARG(x) x
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@ -1,22 +1,14 @@
cmake_minimum_required(VERSION 2.8)
project(libsquirrel)
add_executable(sq sq.c)
set_target_properties(sq PROPERTIES LINKER_LANGUAGE C)
target_link_libraries(sq squirrel sqstd)
install(TARGETS sq RUNTIME DESTINATION bin)
# sources
set(SQ_SRCS
sq.c
)
add_executable(sq_static sq.c)
set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C)
target_link_libraries(sq_static squirrel_static sqstd_static)
# libs
set(SQ_LIBS
sqstd
squirrel
)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static")
endif()
# shared lib
add_executable(sq ${SQ_SRCS})
target_link_libraries(sq ${SQ_LIBS})
# static lib
add_executable(sq_static ${SQ_SRCS})
set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static")
target_link_libraries(sq_static ${SQ_LIBS})
install(TARGETS sq_static RUNTIME DESTINATION bin)

View File

@ -46,7 +46,7 @@ SQInteger quit(HSQUIRRELVM v)
return 0;
}
void printfunc(HSQUIRRELVM v,const SQChar *s,...)
void printfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...)
{
va_list vl;
va_start(vl, s);
@ -54,7 +54,7 @@ void printfunc(HSQUIRRELVM v,const SQChar *s,...)
va_end(vl);
}
void errorfunc(HSQUIRRELVM v,const SQChar *s,...)
void errorfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...)
{
va_list vl;
va_start(vl, s);
@ -87,10 +87,7 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[],SQInteger *retval)
{
int i;
int compiles_only = 0;
static SQChar temp[500];
const SQChar *ret=NULL;
char * output = NULL;
int lineinfo=0;
*retval = 0;
if(argc>1)
{
@ -307,7 +304,6 @@ int main(int argc, char* argv[])
{
HSQUIRRELVM v;
SQInteger retval = 0;
const SQChar *filename=NULL;
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetAllocHook(MemAllocHook);
#endif

View File

@ -1,20 +1,15 @@
cmake_minimum_required(VERSION 2.8)
project(sqstd)
set(SQSTD_SRC sqstdblob.cpp
sqstdio.cpp
sqstdstream.cpp
sqstdmath.cpp
sqstdsystem.cpp
sqstdstring.cpp
sqstdaux.cpp
sqstdrex.cpp)
# sources
set(SQSTD_SRCS
sqstdblob.cpp
sqstdio.cpp
sqstdstream.cpp
sqstdmath.cpp
sqstdsystem.cpp
sqstdstring.cpp
sqstdaux.cpp
sqstdrex.cpp
)
add_library(sqstd SHARED ${SQSTD_SRC})
target_link_libraries(sqstd squirrel)
install(TARGETS sqstd LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
# shared lib
add_library(sqstd SHARED ${SQSTD_SRCS})
# static lib
add_library(sqstd_static STATIC ${SQSTD_SRCS})
add_library(sqstd_static STATIC ${SQSTD_SRC})
install(TARGETS sqstd_static ARCHIVE DESTINATION lib)

View File

@ -114,7 +114,7 @@ static SQInteger _blob__typeof(HSQUIRRELVM v)
return 1;
}
static SQInteger _blob_releasehook(SQUserPointer p, SQInteger size)
static SQInteger _blob_releasehook(SQUserPointer p, SQInteger SQ_UNUSED_ARG(size))
{
SQBlob *self = (SQBlob*)p;
self->~SQBlob();
@ -230,7 +230,7 @@ static const SQRegFunction bloblib_funcs[]={
_DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")),
{0,0}
{0,0,0,0}
};
SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr)

View File

@ -115,7 +115,7 @@ static SQInteger _file__typeof(HSQUIRRELVM v)
return 1;
}
static SQInteger _file_releasehook(SQUserPointer p, SQInteger size)
static SQInteger _file_releasehook(SQUserPointer p, SQInteger SQ_UNUSED_ARG(size))
{
SQFile *self = (SQFile*)p;
self->~SQFile();
@ -463,7 +463,7 @@ static const SQRegFunction iolib_funcs[]={
_DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")),
{0,0}
{0,0,0,0}
};
SQRESULT sqstd_register_iolib(HSQUIRRELVM v)

View File

@ -78,7 +78,7 @@ static const SQRegFunction mathlib_funcs[] = {
_DECL_FUNC(rand,1,NULL),
_DECL_FUNC(fabs,2,_SC(".n")),
_DECL_FUNC(abs,2,_SC(".n")),
{0,0},
{0,0,0,0},
};
#undef _DECL_FUNC

View File

@ -249,7 +249,7 @@ static const SQRegFunction _stream_methods[] = {
_DECL_STREAM_FUNC(eos,1,_SC("x")),
_DECL_STREAM_FUNC(flush,1,_SC("x")),
_DECL_STREAM_FUNC(_cloned,0,NULL),
{0,0}
{0,0,0,0}
};
void init_streamclass(HSQUIRRELVM v)

View File

@ -350,7 +350,7 @@ static SQInteger _string_endswith(HSQUIRRELVM v)
SQRex *self = NULL; \
sq_getinstanceup(v,1,(SQUserPointer *)&self,0);
static SQInteger _rexobj_releasehook(SQUserPointer p, SQInteger size)
static SQInteger _rexobj_releasehook(SQUserPointer p, SQInteger SQ_UNUSED_ARG(size))
{
SQRex *self = ((SQRex *)p);
sqstd_rex_free(self);
@ -452,7 +452,7 @@ static const SQRegFunction rexobj_funcs[]={
_DECL_REX_FUNC(capture,-2,_SC("xsn")),
_DECL_REX_FUNC(subexpcount,1,_SC("x")),
_DECL_REX_FUNC(_typeof,1,_SC("x")),
{0,0}
{0,0,0,0}
};
#undef _DECL_REX_FUNC
@ -466,7 +466,7 @@ static const SQRegFunction stringlib_funcs[]={
_DECL_FUNC(escape,2,_SC(".s")),
_DECL_FUNC(startswith,3,_SC(".ss")),
_DECL_FUNC(endswith,3,_SC(".ss")),
{0,0}
{0,0,0,0}
};
#undef _DECL_FUNC

View File

@ -126,7 +126,7 @@ static const SQRegFunction systemlib_funcs[]={
_DECL_FUNC(date,-1,_SC(".nn")),
_DECL_FUNC(remove,2,_SC(".s")),
_DECL_FUNC(rename,3,_SC(".ss")),
{0,0}
{0,0,0,0}
};
#undef _DECL_FUNC

View File

@ -1,24 +1,18 @@
cmake_minimum_required(VERSION 2.8)
project(libsquirrel)
set(SQUIRREL_SRC sqapi.cpp
sqbaselib.cpp
sqfuncstate.cpp
sqdebug.cpp
sqlexer.cpp
sqobject.cpp
sqcompiler.cpp
sqstate.cpp
sqtable.cpp
sqmem.cpp
sqvm.cpp
sqclass.cpp)
# sources
set(SQUIRREL_SRCS
sqapi.cpp
sqbaselib.cpp
sqfuncstate.cpp
sqdebug.cpp
sqlexer.cpp
sqobject.cpp
sqcompiler.cpp
sqstate.cpp
sqtable.cpp
sqmem.cpp
sqvm.cpp
sqclass.cpp
)
add_library(squirrel SHARED ${SQUIRREL_SRC})
install(TARGETS squirrel LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
# shared lib
add_library(squirrel SHARED ${SQUIRREL_SRCS})
# static lib
add_library(squirrel_static STATIC ${SQUIRREL_SRCS})
add_library(squirrel_static STATIC ${SQUIRREL_SRC})
install(TARGETS squirrel_static ARCHIVE DESTINATION lib)

View File

@ -180,7 +180,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
#endif
}
SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM v, const HSQOBJECT *po)
SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM SQ_UNUSED_ARG(v), const HSQOBJECT *po)
{
if (!ISREFCOUNTED(type(*po))) return 0;
return po->_unVal.pRefCounted->_uiRef;

View File

@ -40,7 +40,7 @@ static bool str2num(const SQChar *s,SQObjectPtr &res,SQInteger base)
return true;
}
static SQInteger base_dummy(HSQUIRRELVM v)
static SQInteger base_dummy(HSQUIRRELVM SQ_UNUSED_ARG(v))
{
return 0;
}
@ -296,7 +296,7 @@ static const SQRegFunction base_funcs[]={
{_SC("collectgarbage"),base_collectgarbage,0, NULL},
{_SC("resurrectunreachable"),base_resurectureachable,0, NULL},
#endif
{0,0}
{0,0,0,0}
};
void sq_base_register(HSQUIRRELVM v)
@ -475,7 +475,7 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
{_SC("clear"),obj_clear,1, _SC(".")},
{_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")},
{_SC("getdelegate"),table_getdelegate,1, _SC(".")},
{0,0}
{0,0,0,0}
};
//ARRAY DEFAULT DELEGATE///////////////////////////////////////
@ -721,7 +721,7 @@ static bool _hsort_sift_down(HSQUIRRELVM v,SQArray *arr, SQInteger root, SQInteg
return true;
}
static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger l, SQInteger r,SQInteger func)
static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger SQ_UNUSED_ARG(l), SQInteger SQ_UNUSED_ARG(r),SQInteger func)
{
SQArray *a = _array(arr);
SQInteger i;
@ -794,7 +794,7 @@ const SQRegFunction SQSharedState::_array_default_delegate_funcz[]={
{_SC("reduce"),array_reduce,2, _SC("ac")},
{_SC("filter"),array_filter,2, _SC("ac")},
{_SC("find"),array_find,2, _SC("a.")},
{0,0}
{0,0,0,0}
};
//STRING DEFAULT DELEGATE//////////////////////////
@ -863,7 +863,7 @@ const SQRegFunction SQSharedState::_string_default_delegate_funcz[]={
{_SC("tolower"),string_tolower,-1, _SC("s n n")},
{_SC("toupper"),string_toupper,-1, _SC("s n n")},
{_SC("weakref"),obj_delegate_weakref,1, NULL },
{0,0}
{0,0,0,0}
};
//INTEGER DEFAULT DELEGATE//////////////////////////
@ -873,7 +873,7 @@ const SQRegFunction SQSharedState::_number_default_delegate_funcz[]={
{_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{_SC("tochar"),number_delegate_tochar,1, _SC("n|b")},
{_SC("weakref"),obj_delegate_weakref,1, NULL },
{0,0}
{0,0,0,0}
};
//CLOSURE DEFAULT DELEGATE//////////////////////////
@ -983,7 +983,7 @@ const SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={
{_SC("getinfos"),closure_getinfos,1, _SC("c")},
{_SC("getroot"),closure_getroot,1, _SC("c")},
{_SC("setroot"),closure_setroot,2, _SC("ct")},
{0,0}
{0,0,0,0}
};
//GENERATOR DEFAULT DELEGATE
@ -1002,7 +1002,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
{_SC("getstatus"),generator_getstatus,1, _SC("g")},
{_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0}
{0,0,0,0}
};
//THREAD DEFAULT DELEGATE
@ -1162,7 +1162,7 @@ const SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = {
{_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("getstackinfos"),thread_getstackinfos,2, _SC("vn")},
{_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0},
{0,0,0,0},
};
static SQInteger class_getattributes(HSQUIRRELVM v)
@ -1229,7 +1229,7 @@ const SQRegFunction SQSharedState::_class_default_delegate_funcz[] = {
{_SC("getbase"),class_getbase,1, _SC("y")},
{_SC("newmember"),class_newmember,-3, _SC("y")},
{_SC("rawnewmember"),class_rawnewmember,-3, _SC("y")},
{0,0}
{0,0,0,0}
};
@ -1247,7 +1247,7 @@ const SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = {
{_SC("rawin"),container_rawexists,2, _SC("x")},
{_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0}
{0,0,0,0}
};
static SQInteger weakref_ref(HSQUIRRELVM v)
@ -1261,6 +1261,6 @@ const SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = {
{_SC("ref"),weakref_ref,1, _SC("r")},
{_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0}
{0,0,0,0}
};

View File

@ -189,7 +189,7 @@ SQInstance::~SQInstance()
if(_class){ Finalize(); } //if _class is null it was already finalized by the GC
}
bool SQInstance::GetMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res)
bool SQInstance::GetMetaMethod(SQVM SQ_UNUSED_ARG(*v),SQMetaMethod mm,SQObjectPtr &res)
{
if(type(_class->_metamethods[mm]) != OT_NULL) {
res = _class->_metamethods[mm];

View File

@ -982,6 +982,7 @@ public:
SQInteger val = _fs->PopTarget();
SQInteger key = _fs->PopTarget();
SQInteger attrs = hasattrs ? _fs->PopTarget():-1;
((void)attrs);
assert((hasattrs && (attrs == key-1)) || !hasattrs);
unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0);
SQInteger table = _fs->TopTarget(); //<<BECAUSE OF THIS NO COMMON EMIT FUNC IS POSSIBLE

View File

@ -5,7 +5,7 @@
#ifndef SQ_EXCLUDE_DEFAULT_MEMFUNCTIONS
void *sq_vm_malloc(SQUnsignedInteger size){ return malloc(size); }
void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return realloc(p, size); }
void *sq_vm_realloc(void *p, SQUnsignedInteger SQ_UNUSED_ARG(oldsize), SQUnsignedInteger size){ return realloc(p, size); }
void sq_vm_free(void *p, SQUnsignedInteger size){ free(p); }
void sq_vm_free(void *p, SQUnsignedInteger SQ_UNUSED_ARG(size)){ free(p); }
#endif

View File

@ -251,7 +251,7 @@ void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
}
void SQSharedState::RunMark(SQVM *vm,SQCollectable **tchain)
void SQSharedState::RunMark(SQVM SQ_UNUSED_ARG(*vm),SQCollectable **tchain)
{
SQVM *vms = _thread(_root_vm);

View File

@ -514,7 +514,7 @@ SQRESULT SQVM::Suspend()
#define _FINISH(howmuchtojump) {jump = howmuchtojump; return true; }
bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
&o3,SQObjectPtr &o4,SQInteger arg_2,int exitpos,int &jump)
&o3,SQObjectPtr &o4,SQInteger SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
{
SQInteger nrefidx;
switch(type(o1)) {
@ -1573,7 +1573,7 @@ SQInteger prevstackbase = _stackbase;
return true;
}
bool SQVM::CallMetaMethod(SQObjectPtr &closure,SQMetaMethod mm,SQInteger nparams,SQObjectPtr &outres)
bool SQVM::CallMetaMethod(SQObjectPtr &closure,SQMetaMethod SQ_UNUSED_ARG(mm),SQInteger nparams,SQObjectPtr &outres)
{
//SQObjectPtr closure;