mirror of https://github.com/OpenTTD/OpenTTD
(svn r26853) -Cleanup [Squirrel]: remove some stuff that we never did and especially never should use
parent
bd0cd31d4b
commit
79ca66eb67
|
@ -951,13 +951,7 @@
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqpcheader.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqpcheader.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdblob.h" />
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h" />
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdio.h" />
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h" />
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdstring.h" />
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdsystem.h" />
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" />
|
||||||
|
|
|
@ -2082,27 +2082,9 @@
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h">
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h">
|
||||||
<Filter>Squirrel headers</Filter>
|
<Filter>Squirrel headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdblob.h">
|
|
||||||
<Filter>Squirrel headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h">
|
|
||||||
<Filter>Squirrel headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdio.h">
|
|
||||||
<Filter>Squirrel headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h">
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h">
|
||||||
<Filter>Squirrel headers</Filter>
|
<Filter>Squirrel headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h">
|
|
||||||
<Filter>Squirrel headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdstring.h">
|
|
||||||
<Filter>Squirrel headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdsystem.h">
|
|
||||||
<Filter>Squirrel headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h">
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h">
|
||||||
<Filter>Squirrel headers</Filter>
|
<Filter>Squirrel headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -3118,34 +3118,10 @@
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdblob.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdio.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdsystem.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -3115,34 +3115,10 @@
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdblob.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdio.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdsystem.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -721,13 +721,7 @@ script/squirrel_std.hpp
|
||||||
3rdparty/squirrel/squirrel/sqpcheader.h
|
3rdparty/squirrel/squirrel/sqpcheader.h
|
||||||
3rdparty/squirrel/squirrel/sqstate.h
|
3rdparty/squirrel/squirrel/sqstate.h
|
||||||
3rdparty/squirrel/include/sqstdaux.h
|
3rdparty/squirrel/include/sqstdaux.h
|
||||||
3rdparty/squirrel/include/sqstdblob.h
|
|
||||||
3rdparty/squirrel/sqstdlib/sqstdblobimpl.h
|
|
||||||
3rdparty/squirrel/include/sqstdio.h
|
|
||||||
3rdparty/squirrel/include/sqstdmath.h
|
3rdparty/squirrel/include/sqstdmath.h
|
||||||
3rdparty/squirrel/sqstdlib/sqstdstream.h
|
|
||||||
3rdparty/squirrel/include/sqstdstring.h
|
|
||||||
3rdparty/squirrel/include/sqstdsystem.h
|
|
||||||
3rdparty/squirrel/squirrel/sqstring.h
|
3rdparty/squirrel/squirrel/sqstring.h
|
||||||
3rdparty/squirrel/squirrel/sqtable.h
|
3rdparty/squirrel/squirrel/sqtable.h
|
||||||
3rdparty/squirrel/include/squirrel.h
|
3rdparty/squirrel/include/squirrel.h
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
Squirrel 2.2.4 stable
|
|
||||||
--------------------------------------------------------
|
|
||||||
What is in this distribution?
|
|
||||||
|
|
||||||
squirrel
|
|
||||||
static library implementing the compiler and interpreter of the language
|
|
||||||
|
|
||||||
sqstdlib
|
|
||||||
the standard utility libraries
|
|
||||||
|
|
||||||
sq
|
|
||||||
stand alone interpreter
|
|
||||||
|
|
||||||
doc
|
|
||||||
The manual
|
|
||||||
|
|
||||||
etc
|
|
||||||
a minimalistic embedding sample
|
|
||||||
|
|
||||||
samples
|
|
||||||
samples programs
|
|
||||||
|
|
||||||
|
|
||||||
HOW TO COMPILE
|
|
||||||
---------------------------------------------------------
|
|
||||||
GCC USERS
|
|
||||||
.........................................................
|
|
||||||
There is a very simple makefile that compiles all libraries and exes
|
|
||||||
from the root of the project run 'make'
|
|
||||||
|
|
||||||
for 32 bits systems
|
|
||||||
|
|
||||||
$ make
|
|
||||||
|
|
||||||
for 64 bits systems
|
|
||||||
|
|
||||||
$ make sq64
|
|
||||||
|
|
||||||
VISUAL C++ USERS
|
|
||||||
.........................................................
|
|
||||||
Open squirrel.dsw from the root project directory and build(dho!)
|
|
|
@ -1,357 +0,0 @@
|
||||||
***version 2.2.5 stable***
|
|
||||||
-sq_getsize() now returns userdatasize for classes and instances
|
|
||||||
-added parameter 'isstatic' to _newmember metamethod(thx G.Meyer)
|
|
||||||
-now array.sort() is implemented with heapsort
|
|
||||||
-added SQUIRREL_VERSION_NUMBER preprocessor definition
|
|
||||||
-now floats in scientific notation also accept numbers with no '.' (eg. 1e+6 or 1e6)
|
|
||||||
-fixed some compiler warning
|
|
||||||
-fixed a minor compiler bug
|
|
||||||
-fixed some bugs when SQUSEDOUBLE is used in 32bits systems
|
|
||||||
-fixed bug in GC
|
|
||||||
|
|
||||||
***2009-11-15 ***
|
|
||||||
***version 2.2.4 stable***
|
|
||||||
-fixed bug in functions with default parameters
|
|
||||||
|
|
||||||
***2009-06-30 ***
|
|
||||||
***version 2.2.3 stable***
|
|
||||||
-added sq_getfunctioninfo
|
|
||||||
-added compile time flag SQUSEDOUBLE to use double precision floats
|
|
||||||
-added global slot _floatsize_ int the base lib to recognize single precision and double precision builds
|
|
||||||
-sq_wakeupvm can now resume the vm with an exception
|
|
||||||
-added sqstd_format
|
|
||||||
-generators can now be instantiated by calling sq_call() or closure.call()
|
|
||||||
-fixed a bug in sqstd_printcallstack(thx takayuki_h)
|
|
||||||
-fixed modulo by zero(thx jup)
|
|
||||||
-fixed negative enums and constants
|
|
||||||
-fixed generator crash bug if invoked as tail call (thx Mr.Accident)
|
|
||||||
-fixed some minor bug
|
|
||||||
|
|
||||||
***2008-09-24 ***
|
|
||||||
***version 2.2.2 stable***
|
|
||||||
-fixed some behaviour inconsistencies in thread.call() and thread.wakeup() (thx Mr.Accident)
|
|
||||||
-fixed coroutine error propagation
|
|
||||||
-fixed lingering return value from native function (thx Tom Leonard)
|
|
||||||
-fixed a bug if array.sort() is given a bad sort function (thx Tom Leonard)
|
|
||||||
-fixed some minor api bug
|
|
||||||
-added sq_arrayremove() and sq_arrayinsert()
|
|
||||||
|
|
||||||
***2008-05-16 ***
|
|
||||||
***version 2.2.1 stable***
|
|
||||||
-fixed a tailcall bug
|
|
||||||
|
|
||||||
***2008-02-17 ***
|
|
||||||
***version 2.2 stable ***
|
|
||||||
-added _newslot metamethod in classes
|
|
||||||
-added enums added constants
|
|
||||||
-added sq_pushconsttable, sq_setconsttable
|
|
||||||
-added default param
|
|
||||||
-added octal literals(thx Dinosaur)
|
|
||||||
-fixed debug hook, 'calls' and 'returns' are properly notified in the same number.
|
|
||||||
-fixed a coroutine bug
|
|
||||||
|
|
||||||
***2007-07-29 ***
|
|
||||||
***version 2.1.2 stable***
|
|
||||||
-new behaviour for generators iteration using foreach
|
|
||||||
now when a generator is iterated by foreach the value returned by a 'return val' statement
|
|
||||||
will terminate the iteration but will not be returned as foreach iteration
|
|
||||||
-added sq_setclassudsize()
|
|
||||||
-added sq_clear()
|
|
||||||
-added table.clear(), array.clear()
|
|
||||||
-fixed sq_cmp() (thx jyuill)
|
|
||||||
-fixed minor bugs
|
|
||||||
|
|
||||||
***2006-08-21 ***
|
|
||||||
***version 2.1.1 stable***
|
|
||||||
-vm refactoring
|
|
||||||
-optimized internal function memory layout
|
|
||||||
-new global symbol _version_ (is the version string)
|
|
||||||
-code size optimization for float literals(on 32bits float builts)
|
|
||||||
-now the raw ref API(sq_addref etc...) is fully reentrant.
|
|
||||||
-fixed a bug in sq_getdelegate() now pushes null if the object doesn't have a delegate(thx MatzeB)
|
|
||||||
-improved C reference performances in NO_GARBAGE_COLLECTOR builds
|
|
||||||
-sq_getlocal() now enumerates also outer values.
|
|
||||||
-fixed regexp library for GCC users.
|
|
||||||
|
|
||||||
***2006-03-19 ***
|
|
||||||
***version 2.1 stable***
|
|
||||||
-added static class fields, new keyword static
|
|
||||||
-added 64bits architecture support
|
|
||||||
-added global slot _intsize_ int the base lib to recognize 32bits and 64bits builds
|
|
||||||
-added functions with fixed environment, closure.bindenv() built-in function
|
|
||||||
-all types except userdata and null implement the tostring() method
|
|
||||||
-string concatenation now invokes metamethod _tostring
|
|
||||||
-new metamethods for class objects _newmember and _inherited
|
|
||||||
-sq_call() sq_resume() sq_wakeupvm() have a new signature
|
|
||||||
-new C referencing implementation(scales more with the amount of references)
|
|
||||||
-refactored hash table
|
|
||||||
-new api functions sq_newslot(),sq_tobool(),sq_getbase(), sq_instanceof(), sq_bindenv()
|
|
||||||
-the api func sq_createslot was deprecated but still supported in form of C macro on top of sq_newslot
|
|
||||||
-sq_setreleasehook() now also works for classes
|
|
||||||
-stream.readstr() and stream.writestr() have been deprecated(this affects file and blob)
|
|
||||||
-fixed squirrel.h undeclared api calls
|
|
||||||
-fixed few minor bugs
|
|
||||||
-SQChar is now defined as wchar_t
|
|
||||||
-removed warning when building with -Wall -pedantic for GCC users
|
|
||||||
-added new std io function writeclosuretofile()
|
|
||||||
-added new std string functions strip(),rstrip(),lstrip() and split()
|
|
||||||
-regular expressions operators (+,*) now have more POSIX greedyness behaviour
|
|
||||||
-class constructors are now invoked as normal functions
|
|
||||||
|
|
||||||
***2005-10-02 ***
|
|
||||||
***version 2.0.5 stable***
|
|
||||||
-fixed some 64bits incompatibilities (thx sarge)
|
|
||||||
-fixed minor bug in the stdlib format() function (thx Rick)
|
|
||||||
-fixed a bug in dofile() that was preventing to compile empty files
|
|
||||||
-added new API sq_poptop() & sq_getfreevariable()
|
|
||||||
-some performance improvements
|
|
||||||
|
|
||||||
***2005-08-14 ***
|
|
||||||
***version 2.0.4 stable***
|
|
||||||
-weak references and related API calls
|
|
||||||
-added sq_objtobool()
|
|
||||||
-class instances memory policies improved(1 mem allocation for the whole instance)
|
|
||||||
-typetags are now declared as SQUserPointer instead of unsigned int
|
|
||||||
-first pass for 64bits compatibility
|
|
||||||
-fixed minor bug in the stdio stream
|
|
||||||
-fixed a bug in format()
|
|
||||||
-fixed bug in string.tointeger() and string.tofloat()
|
|
||||||
|
|
||||||
***2005-06-24 ***
|
|
||||||
***version 2.0.3 stable***
|
|
||||||
-dofile() and loadfile() in the iolib now can decode ASCII, UTF8 files UCS2 big-endian and little-endian
|
|
||||||
-sq_setparamscheck() : now typemesk can check for null
|
|
||||||
-added string escape sequence \xhhhh
|
|
||||||
-fixed some C++ standard incompatibilities
|
|
||||||
|
|
||||||
***2005-05-15 ***
|
|
||||||
***version 2.0.2 stable***
|
|
||||||
-performances improvements (expecially for GCC users)
|
|
||||||
-removed all dependencies from C++ exception handling
|
|
||||||
-various bugfixes
|
|
||||||
|
|
||||||
***2005-04-12 ***
|
|
||||||
***version 2.0.1 stable***
|
|
||||||
-various bugfixes
|
|
||||||
-sq_setparamscheck() now allows spaces in the typemask
|
|
||||||
|
|
||||||
***2005-04-03 ***
|
|
||||||
***version 2.0 stable***
|
|
||||||
-added API sq_gettypetag()
|
|
||||||
-added built-in function to the bool type(tointeger, tostring etc...)
|
|
||||||
|
|
||||||
***2005-02-27 ***
|
|
||||||
***version 2.0 release candidate 1(RC 1)***
|
|
||||||
-added API sq_reseterror()
|
|
||||||
-modified sq_release()
|
|
||||||
-now class instances can be cloned
|
|
||||||
-various bufixes
|
|
||||||
|
|
||||||
***2005-01-26 ***
|
|
||||||
***version 2.0 beta 1***
|
|
||||||
-added bool type
|
|
||||||
-class properties can be redefined in a derived class
|
|
||||||
-added ops *= /= and %=
|
|
||||||
-new syntax for class attributes declaration </ and /> instead of ( and )
|
|
||||||
-increased the max number of literals per function from 65535 to 16777215
|
|
||||||
-now free variables have proper lexical scoping
|
|
||||||
-added API sq_createinstance(), sq_pushbool(), sq_getbool()
|
|
||||||
-added built-in function type()
|
|
||||||
-added built-in function obj.rawin(key) in table,class and instance
|
|
||||||
-sq_rawget() and sq_rawset() now work also on classes and instances
|
|
||||||
-the VM no longer uses C++ exception handling (more suitable for embedded devices)
|
|
||||||
-various bufixes
|
|
||||||
|
|
||||||
***2004-12-21 ***
|
|
||||||
***version 2.0 alpha 2***
|
|
||||||
-globals scoping changed, now if :: is omitted the VM automatically falls back on the root table
|
|
||||||
-various bufixes
|
|
||||||
-added class level attributes
|
|
||||||
|
|
||||||
***2004-12-12 ***
|
|
||||||
***version 2.0 alpha 1***
|
|
||||||
-codebase branch from version 1.x
|
|
||||||
-added classes
|
|
||||||
-added functions with variable number of parameters(vargc & vargv and the ...)
|
|
||||||
-0 and 0.0 are now considered 'false' by all conditional statements(if,while,for,?,do-while)
|
|
||||||
-added new api functions sq_newclass() sq_setinstanceup() sq_getinstanceup() sq_getattributes() sq_setattributes()
|
|
||||||
-modified api sq_settypetag()
|
|
||||||
|
|
||||||
***2004-11-01 ***
|
|
||||||
***version 1.0 stable***
|
|
||||||
-fixed some minor bug
|
|
||||||
-improoved operator 'delete' performances
|
|
||||||
-added scientific notation for float numbers( eg. 2.e16 or 2.e-2)
|
|
||||||
|
|
||||||
***2004-08-30 ***
|
|
||||||
***version 1.0 release candidate 2(RC 2)***
|
|
||||||
-fixed bug in the vm(thx Pierre Renaux)
|
|
||||||
-fixed bug in the optimizer(thx Pierre Renaux)
|
|
||||||
-fixed some bug in the documentation(thx JD)
|
|
||||||
-added new api functions for raw object handling
|
|
||||||
-removed nested multiline comments
|
|
||||||
-reduced memory footprint in C references
|
|
||||||
|
|
||||||
***2004-08-23 ***
|
|
||||||
***version 1.0 release candidate 1(RC 1)***
|
|
||||||
-fixed division by zero
|
|
||||||
-the 'in' operator and obj.rawget() do not query the default delegate anymore
|
|
||||||
-added function sq_getprintfunc()
|
|
||||||
-added new standard library 'auxlib'(implements default error handlers)
|
|
||||||
|
|
||||||
***2004-07-12 ***
|
|
||||||
***version 1.0 beta 4***
|
|
||||||
-fixed a bug in the integer.tochar() built-in method
|
|
||||||
-fixed unary minus operator
|
|
||||||
-fixed bug in dofile()
|
|
||||||
-fixed inconsistency between != and == operators(on float/integer comparison)
|
|
||||||
-added javascript style unsigned right shift operator '>>>'
|
|
||||||
-added array(size) constructor built-in function
|
|
||||||
-array.resize(size,[fill]) built-in function accepts an optional 'fill' value
|
|
||||||
-improved debug API, added sq_getclosureinfo() and sq_setnativeclosurename()
|
|
||||||
|
|
||||||
***2004-05-23 ***
|
|
||||||
***version 1.0 beta 3***
|
|
||||||
-minor vm bug fixes
|
|
||||||
-string allocation is now faster
|
|
||||||
-tables and array memory usage is now less conservative(they shrink)
|
|
||||||
-added regular expression routines in the standard library
|
|
||||||
-The 'c' expression now accepts only 1 character(thx irbrian)
|
|
||||||
-multiline strings <[ ]> have been substituted with C# style verbatim strings (eg. @"string")
|
|
||||||
-added new keyword 'parent' for accessing the delegate of tables and unserdata
|
|
||||||
-The metamethod '_clone' has been renamed '_cloned'
|
|
||||||
-the _delslot metamethod's behaviour and prototype have been changed
|
|
||||||
-new default function in the integer and float object 'tochar()'
|
|
||||||
-the built-in function chcode2string has been removed
|
|
||||||
-the default method [table].getdelegate() has been removed
|
|
||||||
-new api sq_rawdeleteslot()
|
|
||||||
-new table built-in method rawdelete(key)
|
|
||||||
-the dynamic mudule loading has been removed from the standard distribution
|
|
||||||
-some optimizations in the VM
|
|
||||||
|
|
||||||
***2004-04-21 ***
|
|
||||||
***version 1.0 beta 2***
|
|
||||||
-minor compiler/parser bug fixes
|
|
||||||
-sq_newclosure has a different prototype, the "paramscheck" of paramter has been moved to the new function sq_setparamscheck()
|
|
||||||
-sq_setparamscheck allows to add automatic parameters type checking in native closures
|
|
||||||
-sq_compile() lost the lineinfo parameter
|
|
||||||
-new api sq_enabledebuginfo() globally sets compiler's debug info generation
|
|
||||||
-added consistency check on bytecode serialization
|
|
||||||
-fixed += operator, now works on strings like +
|
|
||||||
-added global slot in the base lib _charsize_ to recognize unicode builds from ascii builds runtime
|
|
||||||
-added registry table
|
|
||||||
-new api call sq_pushregistrytable()
|
|
||||||
-added type tag to the userdata type sq_settypetag()
|
|
||||||
-sq_getuserdata now queries the userdata typetag
|
|
||||||
-the built in function collect_garbage() as been renamed collectgarbage() for consistency reasons
|
|
||||||
-new standard libraries(sqlibs are now obsolete)
|
|
||||||
|
|
||||||
***2004-02-20 ***
|
|
||||||
***version 1.0 beta 1***
|
|
||||||
-fixed a bug in the compiler (thanks Martin Kofler)
|
|
||||||
-fixed bug in the switch case statement
|
|
||||||
-fixed the _unm metamethod
|
|
||||||
-fixed minor bugs in the API
|
|
||||||
-fixed automatic stack resizing
|
|
||||||
-first beta version
|
|
||||||
first pass code clean up in the VM and base lib
|
|
||||||
first pass code coverege test has been done on VM and built-in lib
|
|
||||||
-new VM creation API sq_open() sq_close() (sq_newvm and sq_releasevm are now obsolete)
|
|
||||||
-new api allows to specifiy a "print" function to output text(sq_printfunc)
|
|
||||||
-added some small optimizations
|
|
||||||
-new cooperative multi-threading capabilities in the base library(coroutines), VMs are now a built in type("thread")
|
|
||||||
-new built in functions have been added for manipulating the new "thread" type
|
|
||||||
-friend virtual machines share the same root table, error handler and debug hook by default
|
|
||||||
-new compile time options
|
|
||||||
|
|
||||||
***2004-01-19 ***
|
|
||||||
***version 0.9 alpha***
|
|
||||||
-fixed a garbage collection bug
|
|
||||||
-fixed some API bugs(thanks to Joshua Jensen)
|
|
||||||
-fixed tail calls (in the version 0.8 the tail call optimization was erroneously disabled)
|
|
||||||
-new function parameters semantic, now passing a wrong number of parameters generates an exception
|
|
||||||
-native closures have now a built in parameter number checking
|
|
||||||
-sq_rawget and sq_rawset now work also on arrays
|
|
||||||
-sq_getsize now woks also on userdata
|
|
||||||
-the userdata release hook prototype is changed(now passes the size of the userdata)
|
|
||||||
-the lexer reader function now returns an integer instead of a char that allows better error checking on the input(thx Joshua Jensen)
|
|
||||||
-faster compiler
|
|
||||||
-try/catch blocks do not cause any runtime memory allocation anymore
|
|
||||||
|
|
||||||
***2003-12-06 ***
|
|
||||||
***version 0.8 alpha***
|
|
||||||
-fixed a bug that was preventing to have callable userdata throught the metamethod _call
|
|
||||||
-fixed a garbage collection bug
|
|
||||||
-fixed == operator now can compare correctly different types
|
|
||||||
-new built in method getstackinfos(level)
|
|
||||||
-improoved line informations precision for the debug hook
|
|
||||||
-new api call sq_compilebuffer()
|
|
||||||
-new built-in api function compilestring()
|
|
||||||
-new syntactic sugar for function declarations inside tables
|
|
||||||
-the debug API has been finalized
|
|
||||||
|
|
||||||
***2003-11-17 ***
|
|
||||||
***version 0.7 alpha***
|
|
||||||
-fixed critical bug SQInteger the tail call system
|
|
||||||
-fixed bug in the continue statement code generation
|
|
||||||
-fixed func call param issue(thanks to Rewoonenco Andrew)
|
|
||||||
-added _delslot metamethod(thanks to Rewoonenco Andrew)
|
|
||||||
-new multiline string expression ( delimited by <[ and ]> )
|
|
||||||
-normal strings ("") do not allow embedded new line anymore
|
|
||||||
-reduced vm memory footprint(C refs are shared between friend VMs)
|
|
||||||
-new api method sq_deleteslot()
|
|
||||||
-new debug hook event 'r' is triggered when a function returns
|
|
||||||
|
|
||||||
***2003-11-04 ***
|
|
||||||
***version 0.6 alpha***
|
|
||||||
-fixed switch statement(was executing the default case after a break)
|
|
||||||
-sq_call() doesn't pop the closure (just the params)
|
|
||||||
-the vm execution can be suspended from the C API anytime (micro-threads)
|
|
||||||
-new api calls sq_suspendvm() sq_wakeupvm() sq_getvmstate() and sq_reservestack()
|
|
||||||
|
|
||||||
***2003-10-13 ***
|
|
||||||
***version 0.5 alpha***
|
|
||||||
-fixed some minor bug
|
|
||||||
-tested with non ASCII identifiers in unicode mode(I've tried chinese chars)
|
|
||||||
-added built-in function string.find()
|
|
||||||
-the built-in function array.sort() optionally accepts a cmp(a,b) function
|
|
||||||
-the debug hook function now has a new prototype debug_hook(event_type,sourcefile,line,functionname)
|
|
||||||
-fixed some debug info imprecision
|
|
||||||
|
|
||||||
***2003-10-01 ***
|
|
||||||
***version 0.4 alpha***
|
|
||||||
-faster VM
|
|
||||||
-sq_call will pop arguments and closure also in case of failure
|
|
||||||
-fixed a bug in sq_remove
|
|
||||||
-now the VM detects delegation cycles(and throws an exception)
|
|
||||||
-new operators ++ and --
|
|
||||||
-new operator ',' comma operator
|
|
||||||
-fixed some expression precedence issue
|
|
||||||
-fixed bug in sq_arraypop
|
|
||||||
|
|
||||||
***2003-09-15 ***
|
|
||||||
***version 0.3 alpha***
|
|
||||||
-fixed a bug in array::insert()
|
|
||||||
-optional Unicode core(define SQUNICODE or _UNICODE on Win32)
|
|
||||||
-sq_compiler uses a new reader function SQLEXREADFUNC
|
|
||||||
-the debug hook passes 'l' instead of 'line' for line callbacks
|
|
||||||
and 'c' instead of 'call' for call callbacks
|
|
||||||
-new array.extend() bulit-in function
|
|
||||||
-new API sq_clone()
|
|
||||||
|
|
||||||
***2003-09-10 ***
|
|
||||||
***version 0.2 pre-alpha***
|
|
||||||
-new completely reentrant VM (sq_open and sq_close are now obsolete)
|
|
||||||
-sq_newvm() has a new prototype
|
|
||||||
-allocators are now global and linked in the VM
|
|
||||||
-_newslot meta method added
|
|
||||||
-rawset creates a slot if doesn't exists
|
|
||||||
-the compiler error callback pass the vm handle(thanks Pierre Renaux)
|
|
||||||
-sq_setforeignptr() sq_getforeingptr() are now public
|
|
||||||
-sq_resume() now is possible to resume generators from C
|
|
||||||
-sq_getlasterror() retrieve the last thrown error
|
|
||||||
-improved docs
|
|
||||||
|
|
||||||
***2003-09-06 ***
|
|
||||||
***version 0.1 pre-alpha***
|
|
||||||
first release
|
|
|
@ -1,23 +0,0 @@
|
||||||
|
|
||||||
SQUIRREL=.
|
|
||||||
MAKE=make
|
|
||||||
|
|
||||||
sq32:
|
|
||||||
cd squirrel; $(MAKE)
|
|
||||||
cd sqstdlib; $(MAKE)
|
|
||||||
cd sq; $(MAKE)
|
|
||||||
|
|
||||||
sqprof:
|
|
||||||
cd squirrel; $(MAKE) sqprof
|
|
||||||
cd sqstdlib; $(MAKE) sqprof
|
|
||||||
cd sq; $(MAKE) sqprof
|
|
||||||
|
|
||||||
sq64:
|
|
||||||
cd squirrel; $(MAKE) sq64
|
|
||||||
cd sqstdlib; $(MAKE) sq64
|
|
||||||
cd sq; $(MAKE) sq64
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(MAKE) -C squirrel clean
|
|
||||||
$(MAKE) -C sqstdlib clean
|
|
||||||
$(MAKE) -C sq clean
|
|
|
@ -1,22 +0,0 @@
|
||||||
The programming language SQUIRREL 2.2.5 stable
|
|
||||||
|
|
||||||
--------------------------------------------------
|
|
||||||
The project has been compiled and run on Windows(Windows XP/2000 on Intel x86 Windows XP Pro on AMD x64) and
|
|
||||||
Linux(Slackware 9.0 on Intel x86, Fedora Core 4 on AMD x64).
|
|
||||||
|
|
||||||
Has been tested with the following compilers:
|
|
||||||
MS Visual C++ 6.0,7.0,7.1 and 8.0 (32 and 64bits)
|
|
||||||
MinGW gcc 3.2 (mingw special 20020817-1)
|
|
||||||
Cygnus gcc 3.2
|
|
||||||
Linux gcc 3.2.3
|
|
||||||
Linux gcc 4.0.0 (x86 64bits)
|
|
||||||
|
|
||||||
|
|
||||||
Feedback and suggestions are appreciated
|
|
||||||
project page - http://www.squirrel-lang.org
|
|
||||||
community forums - http://www.squirrel-lang.org/Forums
|
|
||||||
wiki - http://wiki.squirrel-lang.org
|
|
||||||
author - alberto@demichelis.net
|
|
||||||
|
|
||||||
END OF README
|
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,58 +0,0 @@
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <squirrel.h>
|
|
||||||
#include <sqstdaux.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma comment (lib ,"squirrel.lib")
|
|
||||||
#pragma comment (lib ,"sqstdlib.lib")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define scvprintf vprintf
|
|
||||||
|
|
||||||
void printfunc(HSQUIRRELVM v, const SQChar *s, ...)
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, s);
|
|
||||||
vprintf(s, arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
|
|
||||||
void call_foo(HSQUIRRELVM v, int n,float f,const SQChar *s)
|
|
||||||
{
|
|
||||||
SQInteger top = sq_gettop(v); //saves the stack size before the call
|
|
||||||
sq_pushroottable(v); //pushes the global table
|
|
||||||
sq_pushstring(v,"foo",-1);
|
|
||||||
if(SQ_SUCCEEDED(sq_get(v,-2))) { //gets the field 'foo' from the global table
|
|
||||||
sq_pushroottable(v); //push the 'this' (in this case is the global table)
|
|
||||||
sq_pushinteger(v,n);
|
|
||||||
sq_pushfloat(v,f);
|
|
||||||
sq_pushstring(v,s,-1);
|
|
||||||
sq_call(v,4,SQFalse,SQTrue); //calls the function
|
|
||||||
}
|
|
||||||
sq_settop(v,top); //restores the original stack size
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
HSQUIRRELVM v;
|
|
||||||
v = sq_open(1024); // creates a VM with initial stack size 1024
|
|
||||||
|
|
||||||
//sq_pushroottable(v); //push the root table were to register the lib function
|
|
||||||
//sqstd_register_iolib(v);
|
|
||||||
sqstd_seterrorhandlers(v); //registers the default error handlers
|
|
||||||
|
|
||||||
sq_setprintfunc(v, printfunc); //sets the print function
|
|
||||||
|
|
||||||
sq_pushroottable(v); //push the root table(were the globals of the script will be stored)
|
|
||||||
if(SQ_SUCCEEDED(sqstd_dofile(v, "test.nut", SQFalse, SQTrue))) // also prints syntax errors if any
|
|
||||||
{
|
|
||||||
call_foo(v,1,2.5,"teststring");
|
|
||||||
}
|
|
||||||
|
|
||||||
sq_pop(v,1); //pops the root table
|
|
||||||
sq_close(v);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
function foo(i, f, s)
|
|
||||||
{
|
|
||||||
print("Called foo(), i="+i+", f="+f+", s='"+s+"'\n");
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#ifndef _SQSTDBLOB_H_
|
|
||||||
#define _SQSTDBLOB_H_
|
|
||||||
|
|
||||||
SQUserPointer sqstd_createblob(HSQUIRRELVM v, SQInteger size);
|
|
||||||
SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr);
|
|
||||||
SQInteger sqstd_getblobsize(HSQUIRRELVM v,SQInteger idx);
|
|
||||||
|
|
||||||
SQRESULT sqstd_register_bloblib(HSQUIRRELVM v);
|
|
||||||
|
|
||||||
#endif /*_SQSTDBLOB_H_*/
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#ifndef _SQSTDIO_H_
|
|
||||||
#define _SQSTDIO_H_
|
|
||||||
|
|
||||||
#define SQSTD_STREAM_TYPE_TAG 0x80000000
|
|
||||||
|
|
||||||
struct SQStream {
|
|
||||||
virtual ~SQStream() {}
|
|
||||||
virtual SQInteger Read(void *buffer, SQInteger size) = 0;
|
|
||||||
virtual SQInteger Write(void *buffer, SQInteger size) = 0;
|
|
||||||
virtual SQInteger Flush() = 0;
|
|
||||||
virtual SQInteger Tell() = 0;
|
|
||||||
virtual SQInteger Len() = 0;
|
|
||||||
virtual SQInteger Seek(SQInteger offset, SQInteger origin) = 0;
|
|
||||||
virtual bool IsValid() = 0;
|
|
||||||
virtual bool EOS() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SQ_SEEK_CUR 0
|
|
||||||
#define SQ_SEEK_END 1
|
|
||||||
#define SQ_SEEK_SET 2
|
|
||||||
|
|
||||||
typedef void* SQFILE;
|
|
||||||
|
|
||||||
SQFILE sqstd_fopen(const SQChar *,const SQChar *);
|
|
||||||
SQInteger sqstd_fread(SQUserPointer, SQInteger, SQInteger, SQFILE);
|
|
||||||
SQInteger sqstd_fwrite(const SQUserPointer, SQInteger, SQInteger, SQFILE);
|
|
||||||
SQInteger sqstd_fseek(SQFILE , SQInteger , SQInteger);
|
|
||||||
SQInteger sqstd_ftell(SQFILE);
|
|
||||||
SQInteger sqstd_fflush(SQFILE);
|
|
||||||
SQInteger sqstd_fclose(SQFILE);
|
|
||||||
SQInteger sqstd_feof(SQFILE);
|
|
||||||
|
|
||||||
SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own);
|
|
||||||
SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file);
|
|
||||||
|
|
||||||
//compiler helpers
|
|
||||||
SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror);
|
|
||||||
SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror);
|
|
||||||
SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename);
|
|
||||||
|
|
||||||
SQRESULT sqstd_register_iolib(HSQUIRRELVM v);
|
|
||||||
|
|
||||||
#endif /*_SQSTDIO_H_*/
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#ifndef _SQSTD_SYSTEMLIB_H_
|
|
||||||
#define _SQSTD_SYSTEMLIB_H_
|
|
||||||
|
|
||||||
SQInteger sqstd_register_systemlib(HSQUIRRELVM v);
|
|
||||||
|
|
||||||
#endif /* _SQSTD_SYSTEMLIB_H_ */
|
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function Ack(M, N) {
|
|
||||||
if (M == 0) return( N + 1 );
|
|
||||||
if (N == 0) return( Ack(M - 1, 1) );
|
|
||||||
return( Ack(M - 1, Ack(M, (N - 1))) );
|
|
||||||
}
|
|
||||||
|
|
||||||
local n;
|
|
||||||
|
|
||||||
if(ARGS.len()!=0) {
|
|
||||||
n = ARGS[0].tointeger();
|
|
||||||
if(n < 1) n = 1;
|
|
||||||
} else {
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
print("n="+n+"\n");
|
|
||||||
print("Ack(3,"+ n+ "):"+ Ack(3, n));
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
local n, i, k;
|
|
||||||
|
|
||||||
if(ARGS.len()!=0) {
|
|
||||||
n = ARGS[0].tointeger();
|
|
||||||
if(n < 1) n = 1;
|
|
||||||
} else {
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
local x = []; x.resize(n);
|
|
||||||
local y = []; y.resize(n);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i+=1) {
|
|
||||||
x[i] = i + 1;
|
|
||||||
y[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (k = 0 ; k < n; k+=1) {
|
|
||||||
for (i = n-1; i >= 0; i-=1) {
|
|
||||||
y[i] = y[i]+ x[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print(y[0].tostring()+" "+y[n-1]);
|
|
|
@ -1,49 +0,0 @@
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
class BaseVector {
|
|
||||||
constructor(...)
|
|
||||||
{
|
|
||||||
if(vargc >= 3) {
|
|
||||||
x = vargv[0];
|
|
||||||
y = vargv[1];
|
|
||||||
z = vargv[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Vector3 extends BaseVector {
|
|
||||||
function _add(other)
|
|
||||||
{
|
|
||||||
if(other instanceof this.getclass())
|
|
||||||
return ::Vector3(x+other.x,y+other.y,z+other.z);
|
|
||||||
else
|
|
||||||
throw "wrong parameter";
|
|
||||||
}
|
|
||||||
function Print()
|
|
||||||
{
|
|
||||||
::print(x+","+y+","+z+"\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local v0 = Vector3(1,2,3)
|
|
||||||
local v1 = Vector3(11,12,13)
|
|
||||||
local v2 = v0 + v1;
|
|
||||||
v2.Print();
|
|
||||||
|
|
||||||
FakeNamespace <- {
|
|
||||||
Utils = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FakeNamespace.Utils.SuperClass {
|
|
||||||
constructor()
|
|
||||||
{
|
|
||||||
::print("FakeNamespace.Utils.SuperClass")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local testy = FakeNamespace.Utils.SuperClass();
|
|
|
@ -1,35 +0,0 @@
|
||||||
class Foo {
|
|
||||||
//constructor
|
|
||||||
constructor(a)
|
|
||||||
{
|
|
||||||
testy = ["stuff",1,2,3];
|
|
||||||
}
|
|
||||||
//attributes of PrintTesty
|
|
||||||
</ test = "freakin attribute"/>
|
|
||||||
function PrintTesty()
|
|
||||||
{
|
|
||||||
foreach(i,val in testy)
|
|
||||||
{
|
|
||||||
::print("idx = "+i+" = "+val+" \n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//attributes of testy
|
|
||||||
</ flippy = 10 , second = [1,2,3] />
|
|
||||||
testy = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(member,val in Foo)
|
|
||||||
{
|
|
||||||
::print(member+"\n");
|
|
||||||
local attr;
|
|
||||||
if((attr = Foo.getattributes(member)) != null) {
|
|
||||||
foreach(i,v in attr)
|
|
||||||
{
|
|
||||||
::print("\t"+i+" = "+(typeof v)+"\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
::print("\t<no attributes>\n")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
function coroutine_test(a,b)
|
|
||||||
{
|
|
||||||
::print(a+" "+b+"\n");
|
|
||||||
local ret = ::suspend("suspend 1");
|
|
||||||
::print("the coroutine says "+ret+"\n");
|
|
||||||
ret = ::suspend("suspend 2");
|
|
||||||
::print("the coroutine says "+ret+"\n");
|
|
||||||
ret = ::suspend("suspend 3");
|
|
||||||
::print("the coroutine says "+ret+"\n");
|
|
||||||
return "I'm done"
|
|
||||||
}
|
|
||||||
|
|
||||||
local coro = ::newthread(coroutine_test);
|
|
||||||
|
|
||||||
local susparam = coro.call("test","coroutine"); //starts the coroutine
|
|
||||||
|
|
||||||
local i = 1;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
::print("suspend passed ["+susparam+"]\n")
|
|
||||||
susparam = coro.wakeup("ciao "+i);
|
|
||||||
++i;
|
|
||||||
}while(coro.getstatus()=="suspended")
|
|
||||||
|
|
||||||
::print("return passed ["+susparam+"]\n")
|
|
|
@ -1,52 +0,0 @@
|
||||||
|
|
||||||
PEntity <- {
|
|
||||||
name="noname"
|
|
||||||
pos={x=0,y=0,z=0}
|
|
||||||
type="entity"
|
|
||||||
//methamethod
|
|
||||||
_typeof=function()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function PEntity::PrintPos()
|
|
||||||
{
|
|
||||||
::print("x="+pos.x+" y="+pos.y+" z="+pos.z+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function PEntity::new(name,pos)
|
|
||||||
{
|
|
||||||
local newentity=clone ::PEntity;
|
|
||||||
if(name)
|
|
||||||
newentity.name=name;
|
|
||||||
if(pos)
|
|
||||||
newentity.pos=pos;
|
|
||||||
return newentity;
|
|
||||||
}
|
|
||||||
|
|
||||||
PPlayer <- {
|
|
||||||
model="warrior.mdl"
|
|
||||||
weapon="fist"
|
|
||||||
health=100
|
|
||||||
armor=0
|
|
||||||
//overrides the parent type
|
|
||||||
type="player"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PPlayer::new(name,pos)
|
|
||||||
{
|
|
||||||
local newplayer=delegate ::PEntity.new(name,pos) : clone ::PPlayer;
|
|
||||||
return newplayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
local player=PPlayer.new("godzilla",{x=10,y=20,z=30});
|
|
||||||
|
|
||||||
::print("PLAYER NAME"+player.name+"\n");
|
|
||||||
::print("ENTITY TYPE"+typeof player+"\n");
|
|
||||||
|
|
||||||
player.PrintPos();
|
|
||||||
|
|
||||||
player.pos.x=123;
|
|
||||||
|
|
||||||
player.PrintPos();
|
|
|
@ -1,15 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function fib(n)
|
|
||||||
{
|
|
||||||
if (n < 2) return 1
|
|
||||||
return fib(n-2) + fib(n-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
local n = ARGS.len()!=0?ARGS[0].tointeger():1
|
|
||||||
|
|
||||||
print(fib(n)+"\n")
|
|
|
@ -1,33 +0,0 @@
|
||||||
function min(x,y)
|
|
||||||
return x<y?x:y;
|
|
||||||
|
|
||||||
function max(x,y)
|
|
||||||
return x>y?x:y;
|
|
||||||
|
|
||||||
if(min(100,200)>max(50,20))
|
|
||||||
print("I'm useless statement just to show up the if/else\n");
|
|
||||||
else
|
|
||||||
print("squirrel!!\n");
|
|
||||||
|
|
||||||
print("\n")
|
|
||||||
|
|
||||||
function typy(obj)
|
|
||||||
{
|
|
||||||
switch(typeof obj)
|
|
||||||
{
|
|
||||||
case "integer":
|
|
||||||
case "float":
|
|
||||||
return "is a number";
|
|
||||||
case "table":
|
|
||||||
case "array":
|
|
||||||
return "is a container";
|
|
||||||
default:
|
|
||||||
return "is other stuff"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local a=1,b={},c=function(a,b){return a+b;}
|
|
||||||
|
|
||||||
print("a "+typy(a)+"\n");
|
|
||||||
print("b "+typy(b)+"\n");
|
|
||||||
print("c "+typy(c)+"\n");
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
*Random number function from The Great Computer Language shootout
|
|
||||||
*converted to a generator func
|
|
||||||
*/
|
|
||||||
|
|
||||||
function gen_random(max) {
|
|
||||||
local last=42
|
|
||||||
local IM = 139968;
|
|
||||||
local IA = 3877;
|
|
||||||
local IC = 29573;
|
|
||||||
for(;;){ //loops forever
|
|
||||||
yield (max * (last = (last * IA + IC) % IM) / IM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local randtor=gen_random(100);
|
|
||||||
|
|
||||||
print("RAND NUMBERS \n")
|
|
||||||
|
|
||||||
for(local i=0;i<10;i+=1)
|
|
||||||
print(">"+resume randtor+"\n");
|
|
||||||
|
|
||||||
print("FIBONACCI \n")
|
|
||||||
function fiboz(n)
|
|
||||||
{
|
|
||||||
local prev=0;
|
|
||||||
local curr=1;
|
|
||||||
yield 1;
|
|
||||||
|
|
||||||
for(local i=0;i<n-1;i+=1)
|
|
||||||
{
|
|
||||||
local res=prev+curr;
|
|
||||||
prev=curr;
|
|
||||||
yield curr=res;
|
|
||||||
}
|
|
||||||
return prev+curr;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(val in fiboz(10))
|
|
||||||
{
|
|
||||||
::print(">"+val+"\n");
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
print("Hello World!")
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*translation of the list test from The Great Computer Language Shootout
|
|
||||||
*/
|
|
||||||
|
|
||||||
function compare_arr(a1,a2)
|
|
||||||
{
|
|
||||||
foreach(i,val in a1)
|
|
||||||
if(val!=a2[i])return null;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function test()
|
|
||||||
{
|
|
||||||
local size=10000
|
|
||||||
local l1=[]; l1.resize(size);
|
|
||||||
for(local i=0;i<size;i+=1) l1[i]=i;
|
|
||||||
local l2=clone l1;
|
|
||||||
local l3=[]
|
|
||||||
|
|
||||||
l2.reverse();
|
|
||||||
while(l2.len()>0)
|
|
||||||
l3.append(l2.pop());
|
|
||||||
while(l3.len()>0)
|
|
||||||
l2.append(l3.pop());
|
|
||||||
l1.reverse();
|
|
||||||
|
|
||||||
if(compare_arr(l1,l2))
|
|
||||||
return l1.len();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
local n = ARGS.len()!=0?ARGS[0].tointeger():1
|
|
||||||
for(local i=0;i<n;i+=1)
|
|
||||||
if(!test())
|
|
||||||
{
|
|
||||||
print("failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print("oki doki");
|
|
|
@ -1,32 +0,0 @@
|
||||||
local arr=["one","two","three"]
|
|
||||||
|
|
||||||
::print("FOREACH\n");
|
|
||||||
|
|
||||||
foreach(i,val in arr)
|
|
||||||
{
|
|
||||||
::print("index ["+i+"]="+val+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
::print("FOR\n");
|
|
||||||
|
|
||||||
for(local i=0;i<arr.len();i+=1)
|
|
||||||
{
|
|
||||||
::print("index ["+i+"]="+arr[i]+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
::print("WHILE\n");
|
|
||||||
|
|
||||||
local i=0;
|
|
||||||
while(i<arr.len())
|
|
||||||
{
|
|
||||||
::print("index ["+i+"]="+arr[i]+"\n");
|
|
||||||
i+=1;
|
|
||||||
}
|
|
||||||
::print("DO WHILE\n");
|
|
||||||
|
|
||||||
local i=0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
::print("index ["+i+"]="+arr[i]+"\n");
|
|
||||||
i+=1;
|
|
||||||
}while(i<arr.len());
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
local SIZE=30;
|
|
||||||
|
|
||||||
function mkmatrix(rows, cols) {
|
|
||||||
local i, j, count = 1;
|
|
||||||
local m = []; m.resize(rows);
|
|
||||||
for (i = 0; i < rows; i+=1) {
|
|
||||||
m[i] = [];m[i].resize(cols)
|
|
||||||
for (j = 0; j < cols; j+=1) {
|
|
||||||
m[i][j] = count+=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mmult(rows, cols, m1, m2, m3) {
|
|
||||||
local i, j, k, val;
|
|
||||||
for (i = 0; i < rows; i+=1) {
|
|
||||||
for (j = 0; j < cols; j+=1) {
|
|
||||||
val = 0;
|
|
||||||
for (k = 0; k < cols; k+=1) {
|
|
||||||
val += m1[i][k] * m2[k][j];
|
|
||||||
}
|
|
||||||
m3[i][j] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return m3;
|
|
||||||
}
|
|
||||||
|
|
||||||
local n = ARGS.len()!=0?ARGS[0].tointeger():1
|
|
||||||
|
|
||||||
local m1 = mkmatrix(SIZE, SIZE);
|
|
||||||
local m2 = mkmatrix(SIZE, SIZE);
|
|
||||||
local mm = mkmatrix(SIZE, SIZE);
|
|
||||||
|
|
||||||
for (local i = 0; i < n; i+=1) {
|
|
||||||
mmult(SIZE, SIZE, m1, m2, mm);
|
|
||||||
}
|
|
||||||
|
|
||||||
print(mm[0][0]+" "+mm[2][3]+" "+mm[3][2]+" "+mm[4][4]);
|
|
|
@ -1,115 +0,0 @@
|
||||||
|
|
||||||
local base_vec={
|
|
||||||
function _add(n)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
x=x+n.x,
|
|
||||||
y=y+n.y,
|
|
||||||
z=z+n.z,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function _sub(n)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
x=x-n.x,
|
|
||||||
y=y-n.y,
|
|
||||||
z=z-n.z,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function _div(n)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
x=x/n.x,
|
|
||||||
y=y/n.y,
|
|
||||||
z=z/n.z,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function _mul(n)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
x=x*n.x,
|
|
||||||
y=y*n.y,
|
|
||||||
z=z*n.z,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function _modulo(n)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
x=x%n,
|
|
||||||
y=y%n,
|
|
||||||
z=z%n,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function _typeof() {return "vector";}
|
|
||||||
function _get(key)
|
|
||||||
{
|
|
||||||
if(key==100)
|
|
||||||
{
|
|
||||||
return test_field;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function _set(key,val)
|
|
||||||
{
|
|
||||||
::print("key = "+key+"\n");
|
|
||||||
::print("val = "+val+"\n")
|
|
||||||
if(key==100)
|
|
||||||
{
|
|
||||||
return test_field=val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
test_field="nothing"
|
|
||||||
}
|
|
||||||
|
|
||||||
function vector(_x,_y,_z):(base_vec)
|
|
||||||
{
|
|
||||||
return delegate base_vec : {x=_x,y=_y,z=_z }
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
local v1=vector(1.5,2.5,3.5);
|
|
||||||
local v2=vector(1.5,2.5,3.5);
|
|
||||||
|
|
||||||
local r=v1+v2;
|
|
||||||
|
|
||||||
|
|
||||||
foreach(i,val in r)
|
|
||||||
{
|
|
||||||
print(i+" = "+val+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
r=v1*v2;
|
|
||||||
|
|
||||||
foreach(i,val in r)
|
|
||||||
{
|
|
||||||
print(i+" = "+val+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
r=v1/v2;
|
|
||||||
|
|
||||||
foreach(i,val in r)
|
|
||||||
{
|
|
||||||
print(i+" = "+val+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
r=v1-v2;
|
|
||||||
|
|
||||||
foreach(i,val in r)
|
|
||||||
{
|
|
||||||
print(i+" = "+val+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
r=v1%2;
|
|
||||||
|
|
||||||
foreach(i,val in r)
|
|
||||||
{
|
|
||||||
print(i+" = "+val+"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
print(v1[100]+"\n");
|
|
||||||
v1[100]="set SUCCEEDED";
|
|
||||||
print(v1[100]+"\n");
|
|
||||||
|
|
||||||
if(typeof v1=="vector")
|
|
||||||
print("<SUCCEEDED>\n");
|
|
||||||
else
|
|
||||||
print("<FAILED>\n");
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*translation of the methcall test from The Great Computer Language Shootout
|
|
||||||
*/
|
|
||||||
|
|
||||||
Toggle <- {
|
|
||||||
bool=null
|
|
||||||
}
|
|
||||||
|
|
||||||
function Toggle::value() {
|
|
||||||
return bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Toggle::activate() {
|
|
||||||
bool = !bool;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Toggle::new(startstate) {
|
|
||||||
local newo=clone this;
|
|
||||||
newo.bool = startstate;
|
|
||||||
return newo;
|
|
||||||
}
|
|
||||||
|
|
||||||
NthToggle <- {
|
|
||||||
count_max=null
|
|
||||||
count=0
|
|
||||||
}
|
|
||||||
|
|
||||||
function NthToggle::new(start_state,max_counter)
|
|
||||||
{
|
|
||||||
local newo=delegate ::Toggle.new(start_state) : clone this;
|
|
||||||
newo.count_max <- max_counter
|
|
||||||
return newo;
|
|
||||||
}
|
|
||||||
|
|
||||||
function NthToggle::activate ()
|
|
||||||
{
|
|
||||||
count+=1
|
|
||||||
if (count >= count_max) {
|
|
||||||
bool = !bool;
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local n = ARGS.len()!=0?ARGS[0].tointeger():1
|
|
||||||
|
|
||||||
local val = 1;
|
|
||||||
local toggle = Toggle.new(val);
|
|
||||||
for (local i=0; i<n; i+=1) {
|
|
||||||
val = toggle.activate().value();
|
|
||||||
|
|
||||||
}
|
|
||||||
print(toggle.value() ? "true\n" : "false\n");
|
|
||||||
|
|
||||||
val = 1;
|
|
||||||
local ntoggle = NthToggle.new(val, 3);
|
|
||||||
for (local i=0; i<n; i+=1) {
|
|
||||||
val = ntoggle.activate().value();
|
|
||||||
}
|
|
||||||
print(ntoggle.value() ? "true\n" : "false\n");
|
|
|
@ -1,24 +0,0 @@
|
||||||
function state1()
|
|
||||||
{
|
|
||||||
::suspend("state1");
|
|
||||||
return state2();
|
|
||||||
}
|
|
||||||
|
|
||||||
function state2()
|
|
||||||
{
|
|
||||||
::suspend("state2");
|
|
||||||
return state3();
|
|
||||||
}
|
|
||||||
|
|
||||||
function state3()
|
|
||||||
{
|
|
||||||
::suspend("state3");
|
|
||||||
return state1();
|
|
||||||
}
|
|
||||||
|
|
||||||
local statethread = ::newthread(state1)
|
|
||||||
|
|
||||||
::print(statethread.call()+"\n");
|
|
||||||
|
|
||||||
for(local i = 0; i < 10000; i++)
|
|
||||||
::print(statethread.wakeup()+"\n");
|
|
|
@ -1,24 +0,0 @@
|
||||||
SQUIRREL= ..
|
|
||||||
|
|
||||||
|
|
||||||
OUT= $(SQUIRREL)/bin/sq
|
|
||||||
INCZ= -I$(SQUIRREL)/include -I. -I$(SQUIRREL)/sqlibs
|
|
||||||
LIBZ= -L$(SQUIRREL)/lib
|
|
||||||
LIB= -lsquirrel -lsqstdlib
|
|
||||||
|
|
||||||
OBJS= sq.o
|
|
||||||
|
|
||||||
SRCS= sq.c
|
|
||||||
|
|
||||||
|
|
||||||
sq32:
|
|
||||||
g++ -O2 -fno-rtti -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB)
|
|
||||||
|
|
||||||
sqprof:
|
|
||||||
g++ -O2 -pg -fno-rtti -pie -gstabs -g3 -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB)
|
|
||||||
|
|
||||||
sq64:
|
|
||||||
g++ -O2 -fno-rtti -D_SQ64 -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OUT)
|
|
|
@ -1,300 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#include <conio.h>
|
|
||||||
#endif
|
|
||||||
#include <squirrel.h>
|
|
||||||
#include <sqstdblob.h>
|
|
||||||
#include <sqstdsystem.h>
|
|
||||||
#include <sqstdio.h>
|
|
||||||
#include <sqstdmath.h>
|
|
||||||
#include <sqstdstring.h>
|
|
||||||
#include <sqstdaux.h>
|
|
||||||
|
|
||||||
#define scfprintf fprintf
|
|
||||||
#define scfopen fopen
|
|
||||||
#define scvprintf vprintf
|
|
||||||
|
|
||||||
|
|
||||||
void PrintVersionInfos();
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
int MemAllocHook( int allocType, void *userData, size_t size, int blockType,
|
|
||||||
long requestNumber, const unsigned char *filename, int lineNumber)
|
|
||||||
{
|
|
||||||
// if(requestNumber==585)_asm int 3;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
SQInteger quit(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
int *done;
|
|
||||||
sq_getuserpointer(v,-1,(SQUserPointer*)&done);
|
|
||||||
*done=1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printfunc(HSQUIRRELVM v,const SQChar *s,...)
|
|
||||||
{
|
|
||||||
va_list vl;
|
|
||||||
va_start(vl, s);
|
|
||||||
vprintf( s, vl);
|
|
||||||
va_end(vl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintVersionInfos()
|
|
||||||
{
|
|
||||||
fprintf(stdout,"%s %s (%d bits)\n",SQUIRREL_VERSION,SQUIRREL_COPYRIGHT,sizeof(SQInteger)*8);
|
|
||||||
if(sizeof(SQFloat) != sizeof(float)) {
|
|
||||||
fprintf(stdout,"[%d bits floats]\n",sizeof(SQFloat)*8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintUsage()
|
|
||||||
{
|
|
||||||
fprintf(stderr,"usage: sq <options> <scriptpath [args]>.\n"
|
|
||||||
"Available options are:\n"
|
|
||||||
" -c compiles the file to bytecode(default output 'out.cnut')\n"
|
|
||||||
" -o specifies output file for the -c option\n"
|
|
||||||
" -c compiles only\n"
|
|
||||||
" -d generates debug infos\n"
|
|
||||||
" -v displays version infos\n"
|
|
||||||
" -h prints help\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _INTERACTIVE 0
|
|
||||||
#define _DONE 2
|
|
||||||
//<<FIXME>> this func is a mess
|
|
||||||
int getargs(HSQUIRRELVM v,int argc, char* argv[])
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int compiles_only = 0;
|
|
||||||
static SQChar temp[500];
|
|
||||||
const SQChar *ret=NULL;
|
|
||||||
char * output = NULL;
|
|
||||||
int lineinfo=0;
|
|
||||||
if(argc>1)
|
|
||||||
{
|
|
||||||
int arg=1,exitloop=0;
|
|
||||||
while(arg < argc && !exitloop)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(argv[arg][0]=='-')
|
|
||||||
{
|
|
||||||
switch(argv[arg][1])
|
|
||||||
{
|
|
||||||
case 'd': //DEBUG(debug infos)
|
|
||||||
sq_enabledebuginfo(v,1);
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
compiles_only = 1;
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
if(arg < argc) {
|
|
||||||
arg++;
|
|
||||||
output = argv[arg];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
PrintVersionInfos();
|
|
||||||
return _DONE;
|
|
||||||
|
|
||||||
case 'h':
|
|
||||||
PrintVersionInfos();
|
|
||||||
PrintUsage();
|
|
||||||
return _DONE;
|
|
||||||
default:
|
|
||||||
PrintVersionInfos();
|
|
||||||
printf("unknown prameter '-%c'\n",argv[arg][1]);
|
|
||||||
PrintUsage();
|
|
||||||
return _DONE;
|
|
||||||
}
|
|
||||||
}else break;
|
|
||||||
arg++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// src file
|
|
||||||
|
|
||||||
if(arg<argc) {
|
|
||||||
const SQChar *filename=NULL;
|
|
||||||
filename=argv[arg];
|
|
||||||
|
|
||||||
arg++;
|
|
||||||
sq_pushroottable(v);
|
|
||||||
sq_pushstring(v,"ARGS",-1);
|
|
||||||
sq_newarray(v,0);
|
|
||||||
for(i=arg;i<argc;i++)
|
|
||||||
{
|
|
||||||
const SQChar *a;
|
|
||||||
a=argv[i];
|
|
||||||
sq_pushstring(v,a,-1);
|
|
||||||
|
|
||||||
sq_arrayappend(v,-2);
|
|
||||||
}
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pop(v,1);
|
|
||||||
if(compiles_only) {
|
|
||||||
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,SQTrue))){
|
|
||||||
SQChar *outfile = "out.cnut";
|
|
||||||
if(output) {
|
|
||||||
outfile = output;
|
|
||||||
}
|
|
||||||
if(SQ_SUCCEEDED(sqstd_writeclosuretofile(v,outfile)))
|
|
||||||
return _DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(SQ_SUCCEEDED(sqstd_dofile(v,filename,SQFalse,SQTrue))) {
|
|
||||||
return _DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if this point is reached an error occured
|
|
||||||
{
|
|
||||||
const SQChar *err;
|
|
||||||
sq_getlasterror(v);
|
|
||||||
if(SQ_SUCCEEDED(sq_getstring(v,-1,&err))) {
|
|
||||||
printf("Error [%s]\n",err);
|
|
||||||
return _DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _INTERACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Interactive(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
|
|
||||||
#define MAXINPUT 1024
|
|
||||||
SQChar buffer[MAXINPUT];
|
|
||||||
SQInteger blocks =0;
|
|
||||||
SQInteger string=0;
|
|
||||||
SQInteger retval=0;
|
|
||||||
SQInteger done=0;
|
|
||||||
PrintVersionInfos();
|
|
||||||
|
|
||||||
sq_pushroottable(v);
|
|
||||||
sq_pushstring(v,"quit",-1);
|
|
||||||
sq_pushuserpointer(v,&done);
|
|
||||||
sq_newclosure(v,quit,1);
|
|
||||||
sq_setparamscheck(v,1,NULL);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pop(v,1);
|
|
||||||
|
|
||||||
while (!done)
|
|
||||||
{
|
|
||||||
SQInteger i = 0;
|
|
||||||
printf("\nsq>");
|
|
||||||
for(;;) {
|
|
||||||
int c;
|
|
||||||
if(done)return;
|
|
||||||
c = getchar();
|
|
||||||
if (c == '\n') {
|
|
||||||
if (i>0 && buffer[i-1] == '\\')
|
|
||||||
{
|
|
||||||
buffer[i-1] = '\n';
|
|
||||||
}
|
|
||||||
else if(blocks==0)break;
|
|
||||||
buffer[i++] = '\n';
|
|
||||||
}
|
|
||||||
else if (c=='}') {blocks--; buffer[i++] = (SQChar)c;}
|
|
||||||
else if(c=='{' && !string){
|
|
||||||
blocks++;
|
|
||||||
buffer[i++] = (SQChar)c;
|
|
||||||
}
|
|
||||||
else if(c=='"' || c=='\''){
|
|
||||||
string=!string;
|
|
||||||
buffer[i++] = (SQChar)c;
|
|
||||||
}
|
|
||||||
else if (i >= MAXINPUT-1) {
|
|
||||||
fprintf(stderr, "sq : input line too long\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
buffer[i++] = (SQChar)c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buffer[i] = '\0';
|
|
||||||
|
|
||||||
if(buffer[0]=='='){
|
|
||||||
sprintf(sq_getscratchpad(v,MAXINPUT),"return (%s)",&buffer[1]);
|
|
||||||
memcpy(buffer,sq_getscratchpad(v,-1),(strlen(sq_getscratchpad(v,-1))+1)*sizeof(SQChar));
|
|
||||||
retval=1;
|
|
||||||
}
|
|
||||||
i=strlen(buffer);
|
|
||||||
if(i>0){
|
|
||||||
SQInteger oldtop=sq_gettop(v);
|
|
||||||
if(SQ_SUCCEEDED(sq_compilebuffer(v,buffer,i,"interactive console",SQTrue))){
|
|
||||||
sq_pushroottable(v);
|
|
||||||
if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue)) && retval){
|
|
||||||
printf("\n");
|
|
||||||
sq_pushroottable(v);
|
|
||||||
sq_pushstring(v,"print",-1);
|
|
||||||
sq_get(v,-2);
|
|
||||||
sq_pushroottable(v);
|
|
||||||
sq_push(v,-4);
|
|
||||||
sq_call(v,2,SQFalse,SQTrue);
|
|
||||||
retval=0;
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sq_settop(v,oldtop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
HSQUIRRELVM v;
|
|
||||||
|
|
||||||
const SQChar *filename=NULL;
|
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
_CrtSetAllocHook(MemAllocHook);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
v=sq_open(1024);
|
|
||||||
sq_setprintfunc(v,printfunc);
|
|
||||||
|
|
||||||
sq_pushroottable(v);
|
|
||||||
|
|
||||||
sqstd_register_bloblib(v);
|
|
||||||
sqstd_register_iolib(v);
|
|
||||||
sqstd_register_systemlib(v);
|
|
||||||
sqstd_register_mathlib(v);
|
|
||||||
sqstd_register_stringlib(v);
|
|
||||||
|
|
||||||
//aux library
|
|
||||||
//sets error handlers
|
|
||||||
sqstd_seterrorhandlers(v);
|
|
||||||
|
|
||||||
//gets arguments
|
|
||||||
switch(getargs(v,argc,argv))
|
|
||||||
{
|
|
||||||
case _INTERACTIVE:
|
|
||||||
Interactive(v);
|
|
||||||
break;
|
|
||||||
case _DONE:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
sq_close(v);
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
_getch();
|
|
||||||
_CrtMemDumpAllObjectsSince( NULL );
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
# Microsoft Developer Studio Project File - Name="sq" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=sq - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "sq.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "sq.mak" CFG="sq - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "sq - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "sq - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_LocalPath ".."
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "sq - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /I "..\sqstdlib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x410 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x410 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 squirrel.lib sqstdlib.lib /nologo /subsystem:console /machine:I386 /out:"../bin/sq.exe" /libpath:"../lib"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "sq - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\sqstdlib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x410 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x410 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 squirrel.lib sqstdlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/sq.exe" /pdbtype:sept /libpath:"../lib"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "sq - Win32 Release"
|
|
||||||
# Name "sq - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sq.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
|
@ -1,31 +0,0 @@
|
||||||
SQUIRREL= ..
|
|
||||||
|
|
||||||
|
|
||||||
OUT= $(SQUIRREL)/lib/libsqstdlib.a
|
|
||||||
INCZ= -I$(SQUIRREL)/include -I. -Iinclude
|
|
||||||
|
|
||||||
SRCS= \
|
|
||||||
sqstdblob.cpp \
|
|
||||||
sqstdio.cpp \
|
|
||||||
sqstdstream.cpp \
|
|
||||||
sqstdmath.cpp \
|
|
||||||
sqstdsystem.cpp \
|
|
||||||
sqstdstring.cpp \
|
|
||||||
sqstdaux.cpp \
|
|
||||||
sqstdrex.cpp
|
|
||||||
|
|
||||||
|
|
||||||
sq32:
|
|
||||||
gcc -O2 -fno-rtti -Wall -c $(SRCS) $(INCZ)
|
|
||||||
ar rc $(OUT) *.o
|
|
||||||
|
|
||||||
sqprof:
|
|
||||||
gcc -O2 -pg -fno-rtti -pie -gstabs -g3 -Wall -c $(SRCS) $(INCZ)
|
|
||||||
ar rc $(OUT) *.o
|
|
||||||
|
|
||||||
sq64:
|
|
||||||
gcc -O2 -D_SQ64 -fno-rtti -Wall -c $(SRCS) $(INCZ)
|
|
||||||
ar rc $(OUT) *.o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OUT) $(SRCS:%.cpp=%.o)
|
|
|
@ -1,250 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#include <new>
|
|
||||||
#include <squirrel.h>
|
|
||||||
#include <sqstdio.h>
|
|
||||||
#include <sqstdblob.h>
|
|
||||||
#include "sqstdstream.h"
|
|
||||||
#include "sqstdblobimpl.h"
|
|
||||||
|
|
||||||
#define SQSTD_BLOB_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000002)
|
|
||||||
|
|
||||||
//Blob
|
|
||||||
|
|
||||||
|
|
||||||
#define SETUP_BLOB(v) \
|
|
||||||
SQBlob *self = NULL; \
|
|
||||||
{ if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_BLOB_TYPE_TAG))) \
|
|
||||||
return SQ_ERROR; }
|
|
||||||
|
|
||||||
|
|
||||||
static SQInteger _blob_resize(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_BLOB(v);
|
|
||||||
SQInteger size;
|
|
||||||
sq_getinteger(v,2,&size);
|
|
||||||
if(!self->Resize(size))
|
|
||||||
return sq_throwerror(v,"resize failed");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __swap_dword(unsigned int *n)
|
|
||||||
{
|
|
||||||
*n=(unsigned int)(((*n&0xFF000000)>>24) |
|
|
||||||
((*n&0x00FF0000)>>8) |
|
|
||||||
((*n&0x0000FF00)<<8) |
|
|
||||||
((*n&0x000000FF)<<24));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __swap_word(unsigned short *n)
|
|
||||||
{
|
|
||||||
*n=(unsigned short)((*n>>8)&0x00FF)| ((*n<<8)&0xFF00);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob_swap4(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_BLOB(v);
|
|
||||||
SQInteger num=(self->Len()-(self->Len()%4))>>2;
|
|
||||||
unsigned int *t=(unsigned int *)self->GetBuf();
|
|
||||||
for(SQInteger i = 0; i < num; i++) {
|
|
||||||
__swap_dword(&t[i]);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob_swap2(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_BLOB(v);
|
|
||||||
SQInteger num=(self->Len()-(self->Len()%2))>>1;
|
|
||||||
unsigned short *t = (unsigned short *)self->GetBuf();
|
|
||||||
for(SQInteger i = 0; i < num; i++) {
|
|
||||||
__swap_word(&t[i]);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob__set(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_BLOB(v);
|
|
||||||
SQInteger idx,val;
|
|
||||||
sq_getinteger(v,2,&idx);
|
|
||||||
sq_getinteger(v,3,&val);
|
|
||||||
if(idx < 0 || idx >= self->Len())
|
|
||||||
return sq_throwerror(v,"index out of range");
|
|
||||||
((unsigned char *)self->GetBuf())[idx] = (unsigned char) val;
|
|
||||||
sq_push(v,3);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob__get(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_BLOB(v);
|
|
||||||
SQInteger idx;
|
|
||||||
sq_getinteger(v,2,&idx);
|
|
||||||
if(idx < 0 || idx >= self->Len())
|
|
||||||
return sq_throwerror(v,"index out of range");
|
|
||||||
sq_pushinteger(v,((unsigned char *)self->GetBuf())[idx]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob__nexti(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_BLOB(v);
|
|
||||||
if(sq_gettype(v,2) == OT_NULL) {
|
|
||||||
sq_pushinteger(v, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
SQInteger idx;
|
|
||||||
if(SQ_SUCCEEDED(sq_getinteger(v, 2, &idx))) {
|
|
||||||
if(idx+1 < self->Len()) {
|
|
||||||
sq_pushinteger(v, idx+1);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
sq_pushnull(v);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return sq_throwerror(v,"internal error (_nexti) wrong argument type");
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob__typeof(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
sq_pushstring(v,"blob",-1);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob_releasehook(SQUserPointer p, SQInteger size)
|
|
||||||
{
|
|
||||||
SQBlob *self = (SQBlob*)p;
|
|
||||||
delete self;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _blob_constructor(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQInteger nparam = sq_gettop(v);
|
|
||||||
SQInteger size = 0;
|
|
||||||
if(nparam == 2) {
|
|
||||||
sq_getinteger(v, 2, &size);
|
|
||||||
}
|
|
||||||
if(size < 0) return sq_throwerror(v, "cannot create blob with negative size");
|
|
||||||
SQBlob *b = new SQBlob(size);
|
|
||||||
if(SQ_FAILED(sq_setinstanceup(v,1,b))) {
|
|
||||||
delete b;
|
|
||||||
return sq_throwerror(v, "cannot create blob with negative size");
|
|
||||||
}
|
|
||||||
sq_setreleasehook(v,1,_blob_releasehook);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _DECL_BLOB_FUNC(name,nparams,typecheck) {#name,_blob_##name,nparams,typecheck}
|
|
||||||
static SQRegFunction _blob_methods[] = {
|
|
||||||
_DECL_BLOB_FUNC(constructor,-1,"xn"),
|
|
||||||
_DECL_BLOB_FUNC(resize,2,"xn"),
|
|
||||||
_DECL_BLOB_FUNC(swap2,1,"x"),
|
|
||||||
_DECL_BLOB_FUNC(swap4,1,"x"),
|
|
||||||
_DECL_BLOB_FUNC(_set,3,"xnn"),
|
|
||||||
_DECL_BLOB_FUNC(_get,2,"xn"),
|
|
||||||
_DECL_BLOB_FUNC(_typeof,1,"x"),
|
|
||||||
_DECL_BLOB_FUNC(_nexti,2,"x"),
|
|
||||||
{0,0,0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//GLOBAL FUNCTIONS
|
|
||||||
|
|
||||||
static SQInteger _g_blob_casti2f(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQInteger i;
|
|
||||||
sq_getinteger(v,2,&i);
|
|
||||||
sq_pushfloat(v,*((SQFloat *)&i));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _g_blob_castf2i(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQFloat f;
|
|
||||||
sq_getfloat(v,2,&f);
|
|
||||||
sq_pushinteger(v,*((SQInteger *)&f));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _g_blob_swap2(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQInteger i;
|
|
||||||
sq_getinteger(v,2,&i);
|
|
||||||
short s=(short)i;
|
|
||||||
sq_pushinteger(v,(s<<8)|((s>>8)&0x00FF));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _g_blob_swap4(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQInteger i;
|
|
||||||
sq_getinteger(v,2,&i);
|
|
||||||
unsigned int t4 = (unsigned int)i;
|
|
||||||
__swap_dword(&t4);
|
|
||||||
sq_pushinteger(v,(SQInteger)t4);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _g_blob_swapfloat(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQFloat f;
|
|
||||||
sq_getfloat(v,2,&f);
|
|
||||||
__swap_dword((unsigned int *)&f);
|
|
||||||
sq_pushfloat(v,f);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _DECL_GLOBALBLOB_FUNC(name,nparams,typecheck) {#name,_g_blob_##name,nparams,typecheck}
|
|
||||||
static SQRegFunction bloblib_funcs[]={
|
|
||||||
_DECL_GLOBALBLOB_FUNC(casti2f,2,".n"),
|
|
||||||
_DECL_GLOBALBLOB_FUNC(castf2i,2,".n"),
|
|
||||||
_DECL_GLOBALBLOB_FUNC(swap2,2,".n"),
|
|
||||||
_DECL_GLOBALBLOB_FUNC(swap4,2,".n"),
|
|
||||||
_DECL_GLOBALBLOB_FUNC(swapfloat,2,".n"),
|
|
||||||
{0,0,0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr)
|
|
||||||
{
|
|
||||||
SQBlob *blob;
|
|
||||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
|
|
||||||
return -1;
|
|
||||||
*ptr = blob->GetBuf();
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_getblobsize(HSQUIRRELVM v,SQInteger idx)
|
|
||||||
{
|
|
||||||
SQBlob *blob;
|
|
||||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
|
|
||||||
return -1;
|
|
||||||
return blob->Len();
|
|
||||||
}
|
|
||||||
|
|
||||||
SQUserPointer sqstd_createblob(HSQUIRRELVM v, SQInteger size)
|
|
||||||
{
|
|
||||||
SQInteger top = sq_gettop(v);
|
|
||||||
sq_pushregistrytable(v);
|
|
||||||
sq_pushstring(v,"std_blob",-1);
|
|
||||||
if(SQ_SUCCEEDED(sq_get(v,-2))) {
|
|
||||||
sq_remove(v,-2); //removes the registry
|
|
||||||
sq_push(v,1); // push the this
|
|
||||||
sq_pushinteger(v,size); //size
|
|
||||||
SQBlob *blob = NULL;
|
|
||||||
if(SQ_SUCCEEDED(sq_call(v,2,SQTrue,SQFalse))
|
|
||||||
&& SQ_SUCCEEDED(sq_getinstanceup(v,-1,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG))) {
|
|
||||||
sq_remove(v,-2);
|
|
||||||
return blob->GetBuf();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sq_settop(v,top);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRESULT sqstd_register_bloblib(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
return declare_stream(v,"blob",(SQUserPointer)SQSTD_BLOB_TYPE_TAG,"std_blob",_blob_methods,bloblib_funcs);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#ifndef _SQSTD_BLOBIMPL_H_
|
|
||||||
#define _SQSTD_BLOBIMPL_H_
|
|
||||||
|
|
||||||
struct SQBlob : public SQStream
|
|
||||||
{
|
|
||||||
SQBlob(SQInteger size) {
|
|
||||||
_size = size;
|
|
||||||
_allocated = size;
|
|
||||||
_buf = (unsigned char *)sq_malloc(size);
|
|
||||||
memset(_buf, 0, _size);
|
|
||||||
_ptr = 0;
|
|
||||||
_owns = true;
|
|
||||||
}
|
|
||||||
virtual ~SQBlob() {
|
|
||||||
sq_free(_buf, _allocated);
|
|
||||||
}
|
|
||||||
SQInteger Write(void *buffer, SQInteger size) {
|
|
||||||
if(!CanAdvance(size)) {
|
|
||||||
GrowBufOf(_ptr + size - _size);
|
|
||||||
}
|
|
||||||
memcpy(&_buf[_ptr], buffer, size);
|
|
||||||
_ptr += size;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
SQInteger Read(void *buffer,SQInteger size) {
|
|
||||||
SQInteger n = size;
|
|
||||||
if(!CanAdvance(size)) {
|
|
||||||
if((_size - _ptr) > 0)
|
|
||||||
n = _size - _ptr;
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
memcpy(buffer, &_buf[_ptr], n);
|
|
||||||
_ptr += n;
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
bool Resize(SQInteger n) {
|
|
||||||
if(!_owns) return false;
|
|
||||||
if(n != _allocated) {
|
|
||||||
unsigned char *newbuf = (unsigned char *)sq_malloc(n);
|
|
||||||
memset(newbuf,0,n);
|
|
||||||
if(_size > n)
|
|
||||||
memcpy(newbuf,_buf,n);
|
|
||||||
else
|
|
||||||
memcpy(newbuf,_buf,_size);
|
|
||||||
sq_free(_buf,_allocated);
|
|
||||||
_buf=newbuf;
|
|
||||||
_allocated = n;
|
|
||||||
if(_size > _allocated)
|
|
||||||
_size = _allocated;
|
|
||||||
if(_ptr > _allocated)
|
|
||||||
_ptr = _allocated;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool GrowBufOf(SQInteger n)
|
|
||||||
{
|
|
||||||
bool ret = true;
|
|
||||||
if(_size + n > _allocated) {
|
|
||||||
if(_size + n > _size * 2)
|
|
||||||
ret = Resize(_size + n);
|
|
||||||
else
|
|
||||||
ret = Resize(_size * 2);
|
|
||||||
}
|
|
||||||
_size = _size + n;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
bool CanAdvance(SQInteger n) {
|
|
||||||
if(_ptr+n>_size)return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SQInteger Seek(SQInteger offset, SQInteger origin) {
|
|
||||||
switch(origin) {
|
|
||||||
case SQ_SEEK_SET:
|
|
||||||
if(offset > _size || offset < 0) return -1;
|
|
||||||
_ptr = offset;
|
|
||||||
break;
|
|
||||||
case SQ_SEEK_CUR:
|
|
||||||
if(_ptr + offset > _size || _ptr + offset < 0) return -1;
|
|
||||||
_ptr += offset;
|
|
||||||
break;
|
|
||||||
case SQ_SEEK_END:
|
|
||||||
if(_size + offset > _size || _size + offset < 0) return -1;
|
|
||||||
_ptr = _size + offset;
|
|
||||||
break;
|
|
||||||
default: return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
bool IsValid() {
|
|
||||||
return _buf?true:false;
|
|
||||||
}
|
|
||||||
bool EOS() {
|
|
||||||
return _ptr == _size;
|
|
||||||
}
|
|
||||||
SQInteger Flush() { return 0; }
|
|
||||||
SQInteger Tell() { return _ptr; }
|
|
||||||
SQInteger Len() { return _size; }
|
|
||||||
SQUserPointer GetBuf(){ return _buf; }
|
|
||||||
private:
|
|
||||||
SQInteger _size;
|
|
||||||
SQInteger _allocated;
|
|
||||||
SQInteger _ptr;
|
|
||||||
unsigned char *_buf;
|
|
||||||
bool _owns;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_SQSTD_BLOBIMPL_H_
|
|
|
@ -1,405 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <squirrel.h>
|
|
||||||
#include <new>
|
|
||||||
#include "sqstdstream.h"
|
|
||||||
|
|
||||||
#define SQSTD_FILE_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000001)
|
|
||||||
//basic API
|
|
||||||
SQFILE sqstd_fopen(const SQChar *filename ,const SQChar *mode)
|
|
||||||
{
|
|
||||||
return (SQFILE)fopen(filename,mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_fread(void* buffer, SQInteger size, SQInteger count, SQFILE file)
|
|
||||||
{
|
|
||||||
return (SQInteger)fread(buffer,size,count,(FILE *)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_fwrite(const SQUserPointer buffer, SQInteger size, SQInteger count, SQFILE file)
|
|
||||||
{
|
|
||||||
return (SQInteger)fwrite(buffer,size,count,(FILE *)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_fseek(SQFILE file, SQInteger offset, SQInteger origin)
|
|
||||||
{
|
|
||||||
SQInteger realorigin;
|
|
||||||
switch(origin) {
|
|
||||||
case SQ_SEEK_CUR: realorigin = SEEK_CUR; break;
|
|
||||||
case SQ_SEEK_END: realorigin = SEEK_END; break;
|
|
||||||
case SQ_SEEK_SET: realorigin = SEEK_SET; break;
|
|
||||||
default: return -1; //failed
|
|
||||||
}
|
|
||||||
return fseek((FILE *)file,(long)offset,(int)realorigin);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_ftell(SQFILE file)
|
|
||||||
{
|
|
||||||
return ftell((FILE *)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_fflush(SQFILE file)
|
|
||||||
{
|
|
||||||
return fflush((FILE *)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_fclose(SQFILE file)
|
|
||||||
{
|
|
||||||
return fclose((FILE *)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger sqstd_feof(SQFILE file)
|
|
||||||
{
|
|
||||||
return feof((FILE *)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
//File
|
|
||||||
struct SQFile : public SQStream {
|
|
||||||
SQFile() { _handle = NULL; _owns = false;}
|
|
||||||
SQFile(SQFILE file, bool owns) { _handle = file; _owns = owns;}
|
|
||||||
virtual ~SQFile() { Close(); }
|
|
||||||
bool Open(const SQChar *filename ,const SQChar *mode) {
|
|
||||||
Close();
|
|
||||||
if( (_handle = sqstd_fopen(filename,mode)) ) {
|
|
||||||
_owns = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void Close() {
|
|
||||||
if(_handle && _owns) {
|
|
||||||
sqstd_fclose(_handle);
|
|
||||||
_handle = NULL;
|
|
||||||
_owns = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SQInteger Read(void *buffer,SQInteger size) {
|
|
||||||
return sqstd_fread(buffer,1,size,_handle);
|
|
||||||
}
|
|
||||||
SQInteger Write(void *buffer,SQInteger size) {
|
|
||||||
return sqstd_fwrite(buffer,1,size,_handle);
|
|
||||||
}
|
|
||||||
SQInteger Flush() {
|
|
||||||
return sqstd_fflush(_handle);
|
|
||||||
}
|
|
||||||
SQInteger Tell() {
|
|
||||||
return sqstd_ftell(_handle);
|
|
||||||
}
|
|
||||||
SQInteger Len() {
|
|
||||||
SQInteger prevpos=Tell();
|
|
||||||
Seek(0,SQ_SEEK_END);
|
|
||||||
SQInteger size=Tell();
|
|
||||||
Seek(prevpos,SQ_SEEK_SET);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
SQInteger Seek(SQInteger offset, SQInteger origin) {
|
|
||||||
return sqstd_fseek(_handle,offset,origin);
|
|
||||||
}
|
|
||||||
bool IsValid() { return _handle?true:false; }
|
|
||||||
bool EOS() { return Tell()==Len()?true:false;}
|
|
||||||
SQFILE GetHandle() {return _handle;}
|
|
||||||
private:
|
|
||||||
SQFILE _handle;
|
|
||||||
bool _owns;
|
|
||||||
};
|
|
||||||
|
|
||||||
static SQInteger _file__typeof(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
sq_pushstring(v,"file",-1);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _file_releasehook(SQUserPointer p, SQInteger size)
|
|
||||||
{
|
|
||||||
SQFile *self = (SQFile*)p;
|
|
||||||
delete self;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _file_constructor(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *filename,*mode;
|
|
||||||
bool owns = true;
|
|
||||||
SQFile *f;
|
|
||||||
SQFILE newf;
|
|
||||||
if(sq_gettype(v,2) == OT_STRING && sq_gettype(v,3) == OT_STRING) {
|
|
||||||
sq_getstring(v, 2, &filename);
|
|
||||||
sq_getstring(v, 3, &mode);
|
|
||||||
newf = sqstd_fopen(filename, mode);
|
|
||||||
if(!newf) return sq_throwerror(v, "cannot open file");
|
|
||||||
} else if(sq_gettype(v,2) == OT_USERPOINTER) {
|
|
||||||
owns = !(sq_gettype(v,3) == OT_NULL);
|
|
||||||
sq_getuserpointer(v,2,&newf);
|
|
||||||
} else {
|
|
||||||
return sq_throwerror(v,"wrong parameter");
|
|
||||||
}
|
|
||||||
f = new SQFile(newf,owns);
|
|
||||||
if(SQ_FAILED(sq_setinstanceup(v,1,f))) {
|
|
||||||
delete f;
|
|
||||||
return sq_throwerror(v, "cannot create blob with negative size");
|
|
||||||
}
|
|
||||||
sq_setreleasehook(v,1,_file_releasehook);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//bindings
|
|
||||||
#define _DECL_FILE_FUNC(name,nparams,typecheck) {#name,_file_##name,nparams,typecheck}
|
|
||||||
static SQRegFunction _file_methods[] = {
|
|
||||||
_DECL_FILE_FUNC(constructor,3,"x"),
|
|
||||||
_DECL_FILE_FUNC(_typeof,1,"x"),
|
|
||||||
{0,0,0,0},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own)
|
|
||||||
{
|
|
||||||
SQInteger top = sq_gettop(v);
|
|
||||||
sq_pushregistrytable(v);
|
|
||||||
sq_pushstring(v,"std_file",-1);
|
|
||||||
if(SQ_SUCCEEDED(sq_get(v,-2))) {
|
|
||||||
sq_remove(v,-2); //removes the registry
|
|
||||||
sq_pushroottable(v); // push the this
|
|
||||||
sq_pushuserpointer(v,file); //file
|
|
||||||
if(own){
|
|
||||||
sq_pushinteger(v,1); //true
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
sq_pushnull(v); //false
|
|
||||||
}
|
|
||||||
if(SQ_SUCCEEDED( sq_call(v,3,SQTrue,SQFalse) )) {
|
|
||||||
sq_remove(v,-2);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sq_settop(v,top);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file)
|
|
||||||
{
|
|
||||||
SQFile *fileobj = NULL;
|
|
||||||
if(SQ_SUCCEEDED(sq_getinstanceup(v,idx,(SQUserPointer*)&fileobj,(SQUserPointer)SQSTD_FILE_TYPE_TAG))) {
|
|
||||||
*file = fileobj->GetHandle();
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
return sq_throwerror(v,"not a file");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static SQInteger _io_file_lexfeed_ASCII(SQUserPointer file)
|
|
||||||
{
|
|
||||||
SQInteger ret;
|
|
||||||
char c;
|
|
||||||
if( ( ret=sqstd_fread(&c,sizeof(c),1,(FILE *)file )>0) )
|
|
||||||
return c;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _io_file_lexfeed_UTF8(SQUserPointer file)
|
|
||||||
{
|
|
||||||
#define READ() \
|
|
||||||
if(sqstd_fread(&inchar,sizeof(inchar),1,(FILE *)file) != 1) \
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
static const SQInteger utf8_lengths[16] =
|
|
||||||
{
|
|
||||||
1,1,1,1,1,1,1,1, /* 0000 to 0111 : 1 byte (plain ASCII) */
|
|
||||||
0,0,0,0, /* 1000 to 1011 : not valid */
|
|
||||||
2,2, /* 1100, 1101 : 2 bytes */
|
|
||||||
3, /* 1110 : 3 bytes */
|
|
||||||
4 /* 1111 :4 bytes */
|
|
||||||
};
|
|
||||||
static unsigned char byte_masks[5] = {0,0,0x1f,0x0f,0x07};
|
|
||||||
unsigned char inchar;
|
|
||||||
SQInteger c = 0;
|
|
||||||
READ();
|
|
||||||
c = inchar;
|
|
||||||
//
|
|
||||||
if(c >= 0x80) {
|
|
||||||
SQInteger tmp;
|
|
||||||
SQInteger codelen = utf8_lengths[c>>4];
|
|
||||||
if(codelen == 0)
|
|
||||||
return 0;
|
|
||||||
//"invalid UTF-8 stream";
|
|
||||||
tmp = c&byte_masks[codelen];
|
|
||||||
for(SQInteger n = 0; n < codelen-1; n++) {
|
|
||||||
tmp<<=6;
|
|
||||||
READ();
|
|
||||||
tmp |= inchar & 0x3F;
|
|
||||||
}
|
|
||||||
c = tmp;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _io_file_lexfeed_UCS2_LE(SQUserPointer file)
|
|
||||||
{
|
|
||||||
SQInteger ret;
|
|
||||||
wchar_t c;
|
|
||||||
if( ( ret=sqstd_fread(&c,sizeof(c),1,(FILE *)file )>0) )
|
|
||||||
return (SQChar)c;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _io_file_lexfeed_UCS2_BE(SQUserPointer file)
|
|
||||||
{
|
|
||||||
SQInteger ret;
|
|
||||||
unsigned short c;
|
|
||||||
if( ( ret=sqstd_fread(&c,sizeof(c),1,(FILE *)file )>0) ) {
|
|
||||||
c = ((c>>8)&0x00FF)| ((c<<8)&0xFF00);
|
|
||||||
return (SQChar)c;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger file_read(SQUserPointer file,SQUserPointer buf,SQInteger size)
|
|
||||||
{
|
|
||||||
SQInteger ret;
|
|
||||||
if( ( ret = sqstd_fread(buf,1,size,(SQFILE)file ))!=0 )return ret;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger file_write(SQUserPointer file,SQUserPointer p,SQInteger size)
|
|
||||||
{
|
|
||||||
return sqstd_fwrite(p,1,size,(SQFILE)file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror)
|
|
||||||
{
|
|
||||||
SQFILE file = sqstd_fopen(filename,"rb");
|
|
||||||
SQInteger ret;
|
|
||||||
unsigned short us;
|
|
||||||
unsigned char uc;
|
|
||||||
SQLEXREADFUNC func = _io_file_lexfeed_ASCII;
|
|
||||||
if(file){
|
|
||||||
ret = sqstd_fread(&us,1,2,file);
|
|
||||||
if(ret != 2) {
|
|
||||||
//probably an empty file
|
|
||||||
us = 0;
|
|
||||||
}
|
|
||||||
if(us == SQ_BYTECODE_STREAM_TAG) { //BYTECODE
|
|
||||||
sqstd_fseek(file,0,SQ_SEEK_SET);
|
|
||||||
if(SQ_SUCCEEDED(sq_readclosure(v,file_read,file))) {
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { //SCRIPT
|
|
||||||
switch(us)
|
|
||||||
{
|
|
||||||
//gotta swap the next 2 lines on BIG endian machines
|
|
||||||
case 0xFFFE: func = _io_file_lexfeed_UCS2_BE; break;//UTF-16 little endian;
|
|
||||||
case 0xFEFF: func = _io_file_lexfeed_UCS2_LE; break;//UTF-16 big endian;
|
|
||||||
case 0xBBEF:
|
|
||||||
if(sqstd_fread(&uc,1,sizeof(uc),file) == 0) {
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return sq_throwerror(v,"io error");
|
|
||||||
}
|
|
||||||
if(uc != 0xBF) {
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return sq_throwerror(v,"Unrecognozed ecoding");
|
|
||||||
}
|
|
||||||
func = _io_file_lexfeed_UTF8;
|
|
||||||
break;//UTF-8 ;
|
|
||||||
default: sqstd_fseek(file,0,SQ_SEEK_SET); break; // ascii
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SQ_SUCCEEDED(sq_compile(v,func,file,filename,printerror))){
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return SQ_ERROR;
|
|
||||||
}
|
|
||||||
return sq_throwerror(v,"cannot open the file");
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror)
|
|
||||||
{
|
|
||||||
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror))) {
|
|
||||||
sq_push(v,-2);
|
|
||||||
if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue))) {
|
|
||||||
sq_remove(v,retval?-2:-1); //removes the closure
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
sq_pop(v,1); //removes the closure
|
|
||||||
}
|
|
||||||
return SQ_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename)
|
|
||||||
{
|
|
||||||
SQFILE file = sqstd_fopen(filename,"wb+");
|
|
||||||
if(!file) return sq_throwerror(v,"cannot open the file");
|
|
||||||
if(SQ_SUCCEEDED(sq_writeclosure(v,file_write,file))) {
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
sqstd_fclose(file);
|
|
||||||
return SQ_ERROR; //forward the error
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _g_io_loadfile(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *filename;
|
|
||||||
SQBool printerror = SQFalse;
|
|
||||||
sq_getstring(v,2,&filename);
|
|
||||||
if(sq_gettop(v) >= 3) {
|
|
||||||
sq_getbool(v,3,&printerror);
|
|
||||||
}
|
|
||||||
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror)))
|
|
||||||
return 1;
|
|
||||||
return SQ_ERROR; //propagates the error
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _g_io_writeclosuretofile(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *filename;
|
|
||||||
sq_getstring(v,2,&filename);
|
|
||||||
if(SQ_SUCCEEDED(sqstd_writeclosuretofile(v,filename)))
|
|
||||||
return 1;
|
|
||||||
return SQ_ERROR; //propagates the error
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _g_io_dofile(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *filename;
|
|
||||||
SQBool printerror = SQFalse;
|
|
||||||
sq_getstring(v,2,&filename);
|
|
||||||
if(sq_gettop(v) >= 3) {
|
|
||||||
sq_getbool(v,3,&printerror);
|
|
||||||
}
|
|
||||||
sq_push(v,1); //repush the this
|
|
||||||
if(SQ_SUCCEEDED(sqstd_dofile(v,filename,SQTrue,printerror)))
|
|
||||||
return 1;
|
|
||||||
return SQ_ERROR; //propagates the error
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _DECL_GLOBALIO_FUNC(name,nparams,typecheck) {#name,_g_io_##name,nparams,typecheck}
|
|
||||||
static SQRegFunction iolib_funcs[]={
|
|
||||||
_DECL_GLOBALIO_FUNC(loadfile,-2,".sb"),
|
|
||||||
_DECL_GLOBALIO_FUNC(dofile,-2,".sb"),
|
|
||||||
_DECL_GLOBALIO_FUNC(writeclosuretofile,3,".sc"),
|
|
||||||
{0,0,0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
SQRESULT sqstd_register_iolib(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQInteger top = sq_gettop(v);
|
|
||||||
//create delegate
|
|
||||||
declare_stream(v,"file",(SQUserPointer)SQSTD_FILE_TYPE_TAG,"std_file",_file_methods,iolib_funcs);
|
|
||||||
sq_pushstring(v,"stdout",-1);
|
|
||||||
sqstd_createfile(v,stdout,SQFalse);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pushstring(v,"stdin",-1);
|
|
||||||
sqstd_createfile(v,stdin,SQFalse);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pushstring(v,"stderr",-1);
|
|
||||||
sqstd_createfile(v,stderr,SQFalse);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_settop(v,top);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
|
@ -1,131 +0,0 @@
|
||||||
# Microsoft Developer Studio Project File - Name="sqstdlib" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
|
||||||
|
|
||||||
CFG=sqstdlib - Win32 Release
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "sqstdlib.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "sqstdlib.mak" CFG="sqstdlib - Win32 Release"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "sqstdlib - Win32 Release" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE "sqstdlib - Win32 Debug" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_LocalPath ".."
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "sqstdlib - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x410 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x410 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "sqstdlib - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x410 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x410 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "sqstdlib - Win32 Release"
|
|
||||||
# Name "sqstdlib - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdblob.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdio.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdmath.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdrex.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdstream.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdstring.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdaux.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdsystem.cpp
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdblobimpl.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstdstream.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
|
@ -1,327 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#include <new>
|
|
||||||
#include <squirrel.h>
|
|
||||||
#include <sqstdio.h>
|
|
||||||
#include <sqstdblob.h>
|
|
||||||
#include "sqstdstream.h"
|
|
||||||
#include "sqstdblobimpl.h"
|
|
||||||
|
|
||||||
#define SETUP_STREAM(v) \
|
|
||||||
SQStream *self = NULL; \
|
|
||||||
if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_STREAM_TYPE_TAG))) \
|
|
||||||
return sq_throwerror(v,"invalid type tag"); \
|
|
||||||
if(!self->IsValid()) \
|
|
||||||
return sq_throwerror(v,"the stream is invalid");
|
|
||||||
|
|
||||||
SQInteger _stream_readblob(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
SQUserPointer data,blobp;
|
|
||||||
SQInteger size,res;
|
|
||||||
sq_getinteger(v,2,&size);
|
|
||||||
if(size > self->Len()) {
|
|
||||||
size = self->Len();
|
|
||||||
}
|
|
||||||
data = sq_getscratchpad(v,size);
|
|
||||||
res = self->Read(data,size);
|
|
||||||
if(res <= 0)
|
|
||||||
return sq_throwerror(v,"no data left to read");
|
|
||||||
blobp = sqstd_createblob(v,res);
|
|
||||||
memcpy(blobp,data,res);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SAFE_READN(ptr,len) { \
|
|
||||||
if(self->Read(ptr,len) != len) return sq_throwerror(v,"io error"); \
|
|
||||||
}
|
|
||||||
SQInteger _stream_readn(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
SQInteger format;
|
|
||||||
sq_getinteger(v, 2, &format);
|
|
||||||
switch(format) {
|
|
||||||
case 'l': {
|
|
||||||
SQInteger i;
|
|
||||||
SAFE_READN(&i, sizeof(i));
|
|
||||||
sq_pushinteger(v, i);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'i': {
|
|
||||||
SQInt32 i;
|
|
||||||
SAFE_READN(&i, sizeof(i));
|
|
||||||
sq_pushinteger(v, i);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 's': {
|
|
||||||
short s;
|
|
||||||
SAFE_READN(&s, sizeof(short));
|
|
||||||
sq_pushinteger(v, s);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'w': {
|
|
||||||
unsigned short w;
|
|
||||||
SAFE_READN(&w, sizeof(unsigned short));
|
|
||||||
sq_pushinteger(v, w);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'c': {
|
|
||||||
char c;
|
|
||||||
SAFE_READN(&c, sizeof(char));
|
|
||||||
sq_pushinteger(v, c);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'b': {
|
|
||||||
unsigned char c;
|
|
||||||
SAFE_READN(&c, sizeof(unsigned char));
|
|
||||||
sq_pushinteger(v, c);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'f': {
|
|
||||||
float f;
|
|
||||||
SAFE_READN(&f, sizeof(float));
|
|
||||||
sq_pushfloat(v, f);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'd': {
|
|
||||||
double d;
|
|
||||||
SAFE_READN(&d, sizeof(double));
|
|
||||||
sq_pushfloat(v, (SQFloat)d);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return sq_throwerror(v, "invalid format");
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_writeblob(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQUserPointer data;
|
|
||||||
SQInteger size;
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
if(SQ_FAILED(sqstd_getblob(v,2,&data)))
|
|
||||||
return sq_throwerror(v,"invalid parameter");
|
|
||||||
size = sqstd_getblobsize(v,2);
|
|
||||||
if(self->Write(data,size) != size)
|
|
||||||
return sq_throwerror(v,"io error");
|
|
||||||
sq_pushinteger(v,size);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_writen(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
SQInteger format, ti;
|
|
||||||
SQFloat tf;
|
|
||||||
sq_getinteger(v, 3, &format);
|
|
||||||
switch(format) {
|
|
||||||
case 'l': {
|
|
||||||
SQInteger i;
|
|
||||||
sq_getinteger(v, 2, &ti);
|
|
||||||
i = ti;
|
|
||||||
self->Write(&i, sizeof(SQInteger));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'i': {
|
|
||||||
SQInt32 i;
|
|
||||||
sq_getinteger(v, 2, &ti);
|
|
||||||
i = (SQInt32)ti;
|
|
||||||
self->Write(&i, sizeof(SQInt32));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 's': {
|
|
||||||
short s;
|
|
||||||
sq_getinteger(v, 2, &ti);
|
|
||||||
s = (short)ti;
|
|
||||||
self->Write(&s, sizeof(short));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'w': {
|
|
||||||
unsigned short w;
|
|
||||||
sq_getinteger(v, 2, &ti);
|
|
||||||
w = (unsigned short)ti;
|
|
||||||
self->Write(&w, sizeof(unsigned short));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'c': {
|
|
||||||
char c;
|
|
||||||
sq_getinteger(v, 2, &ti);
|
|
||||||
c = (char)ti;
|
|
||||||
self->Write(&c, sizeof(char));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'b': {
|
|
||||||
unsigned char b;
|
|
||||||
sq_getinteger(v, 2, &ti);
|
|
||||||
b = (unsigned char)ti;
|
|
||||||
self->Write(&b, sizeof(unsigned char));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'f': {
|
|
||||||
float f;
|
|
||||||
sq_getfloat(v, 2, &tf);
|
|
||||||
f = (float)tf;
|
|
||||||
self->Write(&f, sizeof(float));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'd': {
|
|
||||||
double d;
|
|
||||||
sq_getfloat(v, 2, &tf);
|
|
||||||
d = tf;
|
|
||||||
self->Write(&d, sizeof(double));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return sq_throwerror(v, "invalid format");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_seek(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
SQInteger offset, origin = SQ_SEEK_SET;
|
|
||||||
sq_getinteger(v, 2, &offset);
|
|
||||||
if(sq_gettop(v) > 2) {
|
|
||||||
SQInteger t;
|
|
||||||
sq_getinteger(v, 3, &t);
|
|
||||||
switch(t) {
|
|
||||||
case 'b': origin = SQ_SEEK_SET; break;
|
|
||||||
case 'c': origin = SQ_SEEK_CUR; break;
|
|
||||||
case 'e': origin = SQ_SEEK_END; break;
|
|
||||||
default: return sq_throwerror(v,"invalid origin");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sq_pushinteger(v, self->Seek(offset, origin));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_tell(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
sq_pushinteger(v, self->Tell());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_len(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
sq_pushinteger(v, self->Len());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_flush(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
if(!self->Flush())
|
|
||||||
sq_pushinteger(v, 1);
|
|
||||||
else
|
|
||||||
sq_pushnull(v);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQInteger _stream_eos(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SETUP_STREAM(v);
|
|
||||||
if(self->EOS())
|
|
||||||
sq_pushinteger(v, 1);
|
|
||||||
else
|
|
||||||
sq_pushnull(v);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQRegFunction _stream_methods[] = {
|
|
||||||
_DECL_STREAM_FUNC(readblob,2,"xn"),
|
|
||||||
_DECL_STREAM_FUNC(readn,2,"xn"),
|
|
||||||
_DECL_STREAM_FUNC(writeblob,-2,"xx"),
|
|
||||||
_DECL_STREAM_FUNC(writen,3,"xnn"),
|
|
||||||
_DECL_STREAM_FUNC(seek,-2,"xnn"),
|
|
||||||
_DECL_STREAM_FUNC(tell,1,"x"),
|
|
||||||
_DECL_STREAM_FUNC(len,1,"x"),
|
|
||||||
_DECL_STREAM_FUNC(eos,1,"x"),
|
|
||||||
_DECL_STREAM_FUNC(flush,1,"x"),
|
|
||||||
{0,0,0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
void init_streamclass(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
sq_pushregistrytable(v);
|
|
||||||
sq_pushstring(v,"std_stream",-1);
|
|
||||||
if(SQ_FAILED(sq_get(v,-2))) {
|
|
||||||
sq_pushstring(v,"std_stream",-1);
|
|
||||||
sq_newclass(v,SQFalse);
|
|
||||||
sq_settypetag(v,-1,(SQUserPointer)SQSTD_STREAM_TYPE_TAG);
|
|
||||||
SQInteger i = 0;
|
|
||||||
while(_stream_methods[i].name != 0) {
|
|
||||||
SQRegFunction &f = _stream_methods[i];
|
|
||||||
sq_pushstring(v,f.name,-1);
|
|
||||||
sq_newclosure(v,f.f,0);
|
|
||||||
sq_setparamscheck(v,f.nparamscheck,f.typemask);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pushroottable(v);
|
|
||||||
sq_pushstring(v,"stream",-1);
|
|
||||||
sq_pushstring(v,"std_stream",-1);
|
|
||||||
sq_get(v,-4);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pop(v,1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sq_pop(v,1); //result
|
|
||||||
}
|
|
||||||
sq_pop(v,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRESULT declare_stream(HSQUIRRELVM v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,SQRegFunction *methods,SQRegFunction *globals)
|
|
||||||
{
|
|
||||||
if(sq_gettype(v,-1) != OT_TABLE)
|
|
||||||
return sq_throwerror(v,"table expected");
|
|
||||||
SQInteger top = sq_gettop(v);
|
|
||||||
//create delegate
|
|
||||||
init_streamclass(v);
|
|
||||||
sq_pushregistrytable(v);
|
|
||||||
sq_pushstring(v,reg_name,-1);
|
|
||||||
sq_pushstring(v,"std_stream",-1);
|
|
||||||
if(SQ_SUCCEEDED(sq_get(v,-3))) {
|
|
||||||
sq_newclass(v,SQTrue);
|
|
||||||
sq_settypetag(v,-1,typetag);
|
|
||||||
SQInteger i = 0;
|
|
||||||
while(methods[i].name != 0) {
|
|
||||||
SQRegFunction &f = methods[i];
|
|
||||||
sq_pushstring(v,f.name,-1);
|
|
||||||
sq_newclosure(v,f.f,0);
|
|
||||||
sq_setparamscheck(v,f.nparamscheck,f.typemask);
|
|
||||||
sq_setnativeclosurename(v,-1,f.name);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
sq_pop(v,1);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while(globals[i].name!=0)
|
|
||||||
{
|
|
||||||
SQRegFunction &f = globals[i];
|
|
||||||
sq_pushstring(v,f.name,-1);
|
|
||||||
sq_newclosure(v,f.f,0);
|
|
||||||
sq_setparamscheck(v,f.nparamscheck,f.typemask);
|
|
||||||
sq_setnativeclosurename(v,-1,f.name);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
//register the class in the target table
|
|
||||||
sq_pushstring(v,name,-1);
|
|
||||||
sq_pushregistrytable(v);
|
|
||||||
sq_pushstring(v,reg_name,-1);
|
|
||||||
sq_get(v,-2);
|
|
||||||
sq_remove(v,-2);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
|
|
||||||
sq_settop(v,top);
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
sq_settop(v,top);
|
|
||||||
return SQ_ERROR;
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#ifndef _SQSTD_STREAM_H_
|
|
||||||
#define _SQSTD_STREAM_H_
|
|
||||||
|
|
||||||
SQInteger _stream_readblob(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_readline(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_readn(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_writeblob(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_writen(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_seek(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_tell(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_len(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_eos(HSQUIRRELVM v);
|
|
||||||
SQInteger _stream_flush(HSQUIRRELVM v);
|
|
||||||
|
|
||||||
#define _DECL_STREAM_FUNC(name,nparams,typecheck) {#name,_stream_##name,nparams,typecheck}
|
|
||||||
SQRESULT declare_stream(HSQUIRRELVM v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,SQRegFunction *methods,SQRegFunction *globals);
|
|
||||||
#endif /*_SQSTD_STREAM_H_*/
|
|
|
@ -1,136 +0,0 @@
|
||||||
/* see copyright notice in squirrel.h */
|
|
||||||
#include <squirrel.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sqstdsystem.h>
|
|
||||||
|
|
||||||
#define scgetenv getenv
|
|
||||||
#define scsystem system
|
|
||||||
#define scasctime asctime
|
|
||||||
#define scremove remove
|
|
||||||
#define screname rename
|
|
||||||
|
|
||||||
static SQInteger _system_getenv(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *s;
|
|
||||||
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
|
|
||||||
sq_pushstring(v,scgetenv(s),-1);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static SQInteger _system_system(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *s;
|
|
||||||
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
|
|
||||||
sq_pushinteger(v,scsystem(s));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return sq_throwerror(v,"wrong param");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static SQInteger _system_clock(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
sq_pushfloat(v,((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _system_time(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
time_t t;
|
|
||||||
time(&t);
|
|
||||||
sq_pushinteger(v,*((SQInteger *)&t));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _system_remove(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *s;
|
|
||||||
sq_getstring(v,2,&s);
|
|
||||||
if(scremove(s)==-1)
|
|
||||||
return sq_throwerror(v,"remove() failed");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _system_rename(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
const SQChar *oldn,*newn;
|
|
||||||
sq_getstring(v,2,&oldn);
|
|
||||||
sq_getstring(v,3,&newn);
|
|
||||||
if(screname(oldn,newn)==-1)
|
|
||||||
return sq_throwerror(v,"rename() failed");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _set_integer_slot(HSQUIRRELVM v,const SQChar *name,SQInteger val)
|
|
||||||
{
|
|
||||||
sq_pushstring(v,name,-1);
|
|
||||||
sq_pushinteger(v,val);
|
|
||||||
sq_rawset(v,-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SQInteger _system_date(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
time_t t;
|
|
||||||
SQInteger it;
|
|
||||||
SQInteger format = 'l';
|
|
||||||
if(sq_gettop(v) > 1) {
|
|
||||||
sq_getinteger(v,2,&it);
|
|
||||||
t = it;
|
|
||||||
if(sq_gettop(v) > 2) {
|
|
||||||
sq_getinteger(v,3,(SQInteger*)&format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
time(&t);
|
|
||||||
}
|
|
||||||
tm *date;
|
|
||||||
if(format == 'u')
|
|
||||||
date = gmtime(&t);
|
|
||||||
else
|
|
||||||
date = localtime(&t);
|
|
||||||
if(!date)
|
|
||||||
return sq_throwerror(v,"crt api failure");
|
|
||||||
sq_newtable(v);
|
|
||||||
_set_integer_slot(v, "sec", date->tm_sec);
|
|
||||||
_set_integer_slot(v, "min", date->tm_min);
|
|
||||||
_set_integer_slot(v, "hour", date->tm_hour);
|
|
||||||
_set_integer_slot(v, "day", date->tm_mday);
|
|
||||||
_set_integer_slot(v, "month", date->tm_mon);
|
|
||||||
_set_integer_slot(v, "year", date->tm_year+1900);
|
|
||||||
_set_integer_slot(v, "wday", date->tm_wday);
|
|
||||||
_set_integer_slot(v, "yday", date->tm_yday);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define _DECL_FUNC(name,nparams,pmask) {#name,_system_##name,nparams,pmask}
|
|
||||||
static SQRegFunction systemlib_funcs[]={
|
|
||||||
_DECL_FUNC(getenv,2,".s"),
|
|
||||||
_DECL_FUNC(system,2,".s"),
|
|
||||||
_DECL_FUNC(clock,1,NULL),
|
|
||||||
_DECL_FUNC(time,1,NULL),
|
|
||||||
_DECL_FUNC(date,-1,".nn"),
|
|
||||||
_DECL_FUNC(remove,2,".s"),
|
|
||||||
_DECL_FUNC(rename,3,".ss"),
|
|
||||||
{0,0,0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SQInteger sqstd_register_systemlib(HSQUIRRELVM v)
|
|
||||||
{
|
|
||||||
SQInteger i=0;
|
|
||||||
while(systemlib_funcs[i].name!=0)
|
|
||||||
{
|
|
||||||
sq_pushstring(v,systemlib_funcs[i].name,-1);
|
|
||||||
sq_newclosure(v,systemlib_funcs[i].f,0);
|
|
||||||
sq_setparamscheck(v,systemlib_funcs[i].nparamscheck,systemlib_funcs[i].typemask);
|
|
||||||
sq_setnativeclosurename(v,-1,systemlib_funcs[i].name);
|
|
||||||
sq_createslot(v,-3);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "sq"=.\sq\sq.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
begin source code control
|
|
||||||
.
|
|
||||||
end source code control
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
Begin Project Dependency
|
|
||||||
Project_Dep_Name sqlibs
|
|
||||||
End Project Dependency
|
|
||||||
Begin Project Dependency
|
|
||||||
Project_Dep_Name squirrel
|
|
||||||
End Project Dependency
|
|
||||||
Begin Project Dependency
|
|
||||||
Project_Dep_Name sqstdlib
|
|
||||||
End Project Dependency
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "sqstdlib"=.\sqstdlib\sqstdlib.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
begin source code control
|
|
||||||
"$/squirrel", HAAAAAAA
|
|
||||||
.
|
|
||||||
end source code control
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "squirrel"=.\squirrel\squirrel.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
begin source code control
|
|
||||||
"$/squirrel", HAAAAAAA
|
|
||||||
.
|
|
||||||
end source code control
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
begin source code control
|
|
||||||
"$/squirrel", HAAAAAAA
|
|
||||||
.
|
|
||||||
end source code control
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
SQUIRREL= ..
|
|
||||||
|
|
||||||
|
|
||||||
OUT= $(SQUIRREL)/lib/libsquirrel.a
|
|
||||||
INCZ= -I$(SQUIRREL)/include -I. -Iinclude
|
|
||||||
DEFS=
|
|
||||||
LIB=
|
|
||||||
|
|
||||||
OBJS= \
|
|
||||||
sqapi.o \
|
|
||||||
sqbaselib.o \
|
|
||||||
sqcompiler.o \
|
|
||||||
sqdebug.o \
|
|
||||||
sqlexer.o \
|
|
||||||
sqobject.o \
|
|
||||||
sqparser.o \
|
|
||||||
sqstate.o \
|
|
||||||
sqtable.o \
|
|
||||||
sqvm.o \
|
|
||||||
sqmem.o \
|
|
||||||
sqclass.o
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sq32:
|
|
||||||
gcc -O2 -fno-rtti -Wall -c $(SRCS) $(INCZ) $(DEFS)
|
|
||||||
ar rc $(OUT) *.o
|
|
||||||
|
|
||||||
sqprof:
|
|
||||||
gcc -O2 -pg -fno-rtti -pie -gstabs -g3 -Wall -c $(SRCS) $(INCZ) $(DEFS)
|
|
||||||
ar rc $(OUT) *.o
|
|
||||||
|
|
||||||
sq64:
|
|
||||||
gcc -O2 -D_SQ64 -fno-rtti -Wall -c $(SRCS) $(INCZ) $(DEFS)
|
|
||||||
ar rc $(OUT) *.o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OUT) $(SRCS:%.cpp=%.o)
|
|
|
@ -1,302 +0,0 @@
|
||||||
# Microsoft Developer Studio Project File - Name="squirrel" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
|
||||||
|
|
||||||
CFG=squirrel - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "squirrel.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "squirrel.mak" CFG="squirrel - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "squirrel - Win32 Release" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE "squirrel - Win32 Debug" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_LocalPath ".."
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "GARBAGE_COLLECTOR" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x410 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x410 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "GARBAGE_COLLECTOR" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x410 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x410 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "squirrel - Win32 Release"
|
|
||||||
# Name "squirrel - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqapi.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqbaselib.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqcompiler.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqdebug.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqfuncstate.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqlexer.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqmem.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqobject.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstate.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqtable.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqclass.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqvm.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "squirrel - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /YX"stdafx.h"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqarray.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqclosure.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqcompiler.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqfuncproto.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqfuncstate.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqlexer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqobject.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqopcodes.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqpcheader.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstate.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqstring.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqtable.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\squserdata.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\squtils.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqclass.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\sqvm.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
Loading…
Reference in New Issue