diff options
Diffstat (limited to 'ThirdParty/tolua-5.2.4/src/tests')
102 files changed, 1703 insertions, 0 deletions
diff --git a/ThirdParty/tolua-5.2.4/src/tests/._Makefile b/ThirdParty/tolua-5.2.4/src/tests/._Makefile Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._Makefile diff --git a/ThirdParty/tolua-5.2.4/src/tests/._myassert.lua b/ThirdParty/tolua-5.2.4/src/tests/._myassert.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._myassert.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._t.pkg b/ThirdParty/tolua-5.2.4/src/tests/._t.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._t.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tarray.c b/ThirdParty/tolua-5.2.4/src/tests/._tarray.c Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tarray.c diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tarray.h b/ThirdParty/tolua-5.2.4/src/tests/._tarray.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tarray.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tarray.lua b/ThirdParty/tolua-5.2.4/src/tests/._tarray.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tarray.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tarray.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tarray.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tarray.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tclass.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tclass.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tclass.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tclass.h b/ThirdParty/tolua-5.2.4/src/tests/._tclass.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tclass.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tclass.lua b/ThirdParty/tolua-5.2.4/src/tests/._tclass.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tclass.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tclass.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tclass.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tclass.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tconstant.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tconstant.h b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tconstant.lua b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tconstant.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tconstant.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tdirective.lua b/ThirdParty/tolua-5.2.4/src/tests/._tdirective.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tdirective.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tdirective.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tdirective.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tdirective.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tdirectivelua.lua b/ThirdParty/tolua-5.2.4/src/tests/._tdirectivelua.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tdirectivelua.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tdirectivepkg.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tdirectivepkg.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tdirectivepkg.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tenum.c b/ThirdParty/tolua-5.2.4/src/tests/._tenum.c Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tenum.c diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tenum.h b/ThirdParty/tolua-5.2.4/src/tests/._tenum.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tenum.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tenum.lua b/ThirdParty/tolua-5.2.4/src/tests/._tenum.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tenum.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tenum.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tenum.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tenum.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tfunction.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tfunction.h b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tfunction.lua b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tfunction.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tfunction.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.h b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.lua b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tinheritance.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tmodule.c b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.c Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.c diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tmodule.h b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tmodule.lua b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tmodule.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tmodule.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.h b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.lua b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tnamespace.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tpeer.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tpeer.h b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tpeer.lua b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tpeer.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tpeer.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvararg.cpp b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.cpp Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.cpp diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvararg.h b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvararg.lua b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvararg.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvararg.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvariable.c b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.c Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.c diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvariable.h b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.h Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.h diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvariable.lua b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.lua Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.lua diff --git a/ThirdParty/tolua-5.2.4/src/tests/._tvariable.pkg b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.pkg Binary files differnew file mode 100644 index 0000000..313e184 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/._tvariable.pkg diff --git a/ThirdParty/tolua-5.2.4/src/tests/Makefile b/ThirdParty/tolua-5.2.4/src/tests/Makefile new file mode 100644 index 0000000..cca823c --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/Makefile @@ -0,0 +1,89 @@ +# makefile for tolua executable + +TOLUA=../.. +TOLUAEXE = tolua + +include $(TOLUA)/config + +LIBS = -ltolua -llua + +EXE = tmodule tnamespace tclass tpeer tinheritance tconstant tvariable tfunction tarray tdirective tenum tvararg + +all: $(EXE) + ./tmodule; ./tnamespace; ./tclass; ./tpeer; ./tinheritance; ./tconstant; ./tvariable; ./tfunction; ./tarray; ./tdirective; ./tfunction; ./tenum; ./tvararg + +tarray: tarray.o tarraybind.o + $(CC) $(CFLAGS) -o $@ tarray.o tarraybind.o $(TLIB) $(LIB) $(LIBS) +tarraybind.c: tarray.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tvariable: tvariable.o tvariablebind.o + $(CC) $(CFLAGS) -o $@ tvariable.o tvariablebind.o $(TLIB) $(LIB) $(LIBS) +tvariablebind.c: tvariable.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tmodule: tmodule.o tmodulebind.o + $(CC) $(CFLAGS) -o $@ tmodule.o tmodulebind.o $(TLIB) $(LIB) $(LIBS) +tmodulebind.c: tmodule.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tnamespace: tnamespace.o tnamespacebind.o + $(CCPP) $(CFLAGS) -o $@ tnamespace.o tnamespacebind.o $(TLIB) $(LIB) $(LIBS) +tnamespacebind.cpp: tnamespace.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tdirective: tdirectivebind.o + $(CC) $(CFLAGS) -o $@ tdirectivebind.o $(TLIB) $(LIB) $(LIBS) +tdirectivebind.c: tdirective.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tfunction: tfunction.o tfunctionbind.o + $(CCPP) $(CPPFLAGS) -o $@ tfunction.o tfunctionbind.o $(TLIB) $(LIB) $(LIBS) +tfunctionbind.cpp: tfunction.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tconstant: tconstant.o tconstantbind.o + $(CCPP) $(CPPFLAGS) -o $@ tconstant.o tconstantbind.o $(TLIB) $(LIB) $(LIBS) +tconstantbind.cpp: tconstant.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tclass: tclass.o tclassbind.o + $(CCPP) $(CPPFLAGS) -o $@ tclass.o tclassbind.o $(TLIB) $(LIB) $(LIBS) +tclassbind.cpp: tclass.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tpeer: tpeer.o tpeerbind.o + $(CCPP) $(CPPFLAGS) -o $@ tpeer.o tpeerbind.o $(TLIB) $(LIB) $(LIBS) +tpeerbind.cpp: tpeer.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tinheritance: tinheritance.o tinheritancebind.o + $(CCPP) $(CPPFLAGS) -o $@ tinheritance.o tinheritancebind.o $(TLIB) $(LIB) $(LIBS) +tinheritancebind.cpp: tinheritance.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tenum: tenum.o tenumbind.o + $(CC) $(CPPFLAGS) -o $@ tenum.o tenumbind.o $(TLIB) $(LIB) $(LIBS) +tenumbind.c: tenum.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +tvararg: tvararg.o tvarargbind.o + $(CCPP) $(CPPFLAGS) -o $@ tvararg.o tvarargbind.o $(TLIB) $(LIB) $(LIBS) +tvarargbind.cpp: tvararg.pkg + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +.cpp.o: + $(CCPP) -c $(CPPFLAGS) -o $@ $< + +.pkg.cpp: + $(TOLUA)/bin/$(TOLUAEXE) -o $@ $< + +clean: + rm -f t*bind.* + rm -f *.o + +klean: + rm -f $(EXE) + + + diff --git a/ThirdParty/tolua-5.2.4/src/tests/myassert.lua b/ThirdParty/tolua-5.2.4/src/tests/myassert.lua new file mode 100644 index 0000000..a4d5ebd --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/myassert.lua @@ -0,0 +1,6 @@ +function assert (status,msg) + if not status then + print("ERROR: " .. (msg or "assertion failed")) error() + end +end + diff --git a/ThirdParty/tolua-5.2.4/src/tests/t.pkg b/ThirdParty/tolua-5.2.4/src/tests/t.pkg new file mode 100644 index 0000000..a8d2b02 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/t.pkg @@ -0,0 +1,3 @@ +$typedef T* M; + +M* f (); diff --git a/ThirdParty/tolua-5.2.4/src/tests/tarray.c b/ThirdParty/tolua-5.2.4/src/tests/tarray.c new file mode 100644 index 0000000..91580c1 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tarray.c @@ -0,0 +1,45 @@ +#include "lualib.h" +#include "lauxlib.h" + +#include "tarray.h" + + +int a[10] = {1,2,3,4,5,6,7,8,9,10}; +Point p[10] = {{0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{8,9},{9,10}}; +Point* pp[10]; + +int ma[10]; +Point mp[10]; +Point* mpp[10]; + +Array array; +Array* parray = &array; + +int main (void) +{ + int tolua_tarray_open (lua_State*); + lua_State* L = luaL_newstate(); + int i; + + for (i=0; i<10; ++i) + { + pp[i] = &p[i]; + + ma[i] = a[i]; + mp[i] = p[i]; + mpp[i] = pp[i]; + + array.a[i] = a[i]; + array.p[i] = p[i]; + array.pp[i] = pp[i]; + } + + luaL_openlibs(L); + tolua_tarray_open(L); + + luaL_dofile(L,"tarray.lua"); + + lua_close(L); + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tarray.h b/ThirdParty/tolua-5.2.4/src/tests/tarray.h new file mode 100644 index 0000000..6964ef7 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tarray.h @@ -0,0 +1,28 @@ + +typedef struct Point Point; +struct Point +{ + float x; + float y; +}; + + +extern int a[10]; +extern Point p[10]; +extern Point* pp[10]; + + +extern int ma[10]; +extern Point mp[10]; +extern Point* mpp[10]; + +typedef struct Array Array; +struct Array +{ + int a[10]; + Point p[10]; + Point* pp[10]; +}; + +extern Array array; +extern Array* parray; diff --git a/ThirdParty/tolua-5.2.4/src/tests/tarray.lua b/ThirdParty/tolua-5.2.4/src/tests/tarray.lua new file mode 100644 index 0000000..1fd3657 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tarray.lua @@ -0,0 +1,39 @@ +dofile("myassert.lua") + +for i=1,10 do + assert(a[i]==i) +end + +for i=2,10 do + assert(p[i-1].y==p[i].x) +end + +for i=1,10 do + assert(M.a[i]==i) +end + +for i=2,10 do + assert(M.p[i-1].y==M.p[i].x) +end + +for i=1,10 do + assert(pp[i].x==M.p[i].x and p[i].y == M.pp[i].y) +end + +for i=1,10 do + assert(array.a[i] == parray.a[i]) + assert(array.p[i].x == parray.pp[i].x and array.p[i].y == parray.pp[i].y) +end + +for i=1,10 do + array.a[i] = a[10-i+1] + M.a[i] = 10-i+1 + assert(array.a[i]==M.a[i]) +end + +for i=2,10 do + array.p[i] = array.pp[1] + assert(array.p[i].x==0 and array.p[i].y==1) +end + +print("Array test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tarray.pkg b/ThirdParty/tolua-5.2.4/src/tests/tarray.pkg new file mode 100644 index 0000000..32859c9 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tarray.pkg @@ -0,0 +1,29 @@ +$#include "tarray.h" + +struct Point +{ + float x; + float y; +}; + + +extern int a[10]; +extern const Point p[10]; +extern Point* pp[10]; + + +module M { +extern int ma[10]@a; +extern const Point mp[10]@p; +extern Point* mpp[10]@pp; +} + +struct Array +{ + int a[10]; + Point p[10]; + Point* pp[10]; +}; + +extern Array array; +extern Array* parray; diff --git a/ThirdParty/tolua-5.2.4/src/tests/tclass.cpp b/ThirdParty/tolua-5.2.4/src/tests/tclass.cpp new file mode 100644 index 0000000..feeba34 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tclass.cpp @@ -0,0 +1,33 @@ +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tclass.h" + + +#include <stdlib.h> + +Tst_A* Tst_A::last; +Tst_B* Tst_B::last; +Tst_C* Tst_C::last; + + +int main () +{ + Tst_B* b = new Tst_B; // instance used in Lua code + int tolua_tclass_open (lua_State*); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tclass_open(L); + if (luaL_dofile(L,"tclass.lua")) { + printf("Error: %s\n",lua_tostring(L,-1)); + } + lua_close(L); + + delete b; + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tclass.h b/ThirdParty/tolua-5.2.4/src/tests/tclass.h new file mode 100644 index 0000000..d439b08 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tclass.h @@ -0,0 +1,67 @@ +#include <stdio.h> + +class Tst_Dummy +{ +}; + +class Tst_A +{ +public: + static Tst_A* last; + Tst_A () {last = this;} + virtual ~Tst_A() {} + virtual const char* a () { return "A"; } + class Tst_AA + { + public: + Tst_AA () {} + virtual ~Tst_AA () { } + const char* aa () { return "AA"; } + }; + class Tst_BB : public Tst_AA + { + public: + Tst_BB () {} + virtual ~Tst_BB () {} + Tst_AA* Base () { return this; } + const char* classname () const { + return "Tst_BB"; + } + }; +}; + +class Tst_B : public Tst_A +{ +public: + static Tst_B* last; + Tst_B () {last = this;} + virtual ~Tst_B () { } + virtual const char* b () { return "B"; } +}; + +class Tst_C : public Tst_B +{ + int i; +public: + static Tst_C* last; + Tst_C (int n) : i(n) {last = this;} + virtual ~Tst_C () { printf("deleting C: %d\n",i); } + virtual const char* c () { return "C"; } +}; + +inline Tst_A::Tst_AA* Tst_create_aa () +{ + return new Tst_A::Tst_AA(); +} + +inline bool Tst_is_aa (Tst_A::Tst_AA* obj) +{ + return true; +} + +class D // private destructor +{ + ~D () {} +public: + D () {} +}; diff --git a/ThirdParty/tolua-5.2.4/src/tests/tclass.lua b/ThirdParty/tolua-5.2.4/src/tests/tclass.lua new file mode 100644 index 0000000..ab6c704 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tclass.lua @@ -0,0 +1,52 @@ +dofile("myassert.lua") + +-- type convertion tests +assert(tolua.type(A.last) == 'Tst_A') -- first time the object is mapped +assert(tolua.type(B.last) == 'Tst_B') -- type convertion to specialized type +assert(tolua.type(A.last) == 'Tst_B') -- no convertion: obj already mapped as B + + +local a = A:new() +assert(tolua.type(A.last) == 'Tst_A') -- no type convertion: same type +local b = B:new() +assert(tolua.type(A.last) == 'Tst_B') -- no convertion: obj already mapped as B +local c = luaC:new(0) +assert(tolua.type(A.last) == 'Tst_C') -- no convertion: obj already mapped as C +assert(tolua.type(luaC.last) == 'Tst_C') +local aa = A.AA:new() +local bb = A.BB:new() +local xx = create_aa() + +-- casting test +local base = bb:Base(); +local derived = tolua.cast(base,"Tst_A::Tst_BB"); +assert(derived:classname()=="Tst_BB") + +-- method calling tests +assert(a:a() == 'A') +assert(b:a() == 'A') +assert(b:b() == 'B') +assert(c:a() == 'A') +assert(c:b() == 'B') +assert(c:c() == 'C') +assert(aa:aa() == 'AA') +assert(bb:aa() == bb:Base():aa()) +assert(xx:aa() == 'AA') +assert(is_aa(bb) == true) + +-- test ownershipping handling +-- should delete objects: 6 7 8 9 10 (it may vary!) +remark = [[ +local set = {} +for i=1,10 do + local c = luaC:new(i) + tolua.takeownership(c) + set[i] = c +end + +for i=1,5 do + tolua.releaseownership(set[i]) +end +--]] + +print("Class test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tclass.pkg b/ThirdParty/tolua-5.2.4/src/tests/tclass.pkg new file mode 100644 index 0000000..485253f --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tclass.pkg @@ -0,0 +1,50 @@ +$#include "tclass.h" + +$renaming ^Tst_ @ + +class Tst_Dummy; + +class Tst_A +{ + static Tst_A* last; + Tst_A (); + virtual const char* a (); + class Tst_AA + { + Tst_AA () {} + ~Tst_AA () {} + const char* aa () { return "AA"; } + }; + class Tst_BB : public Tst_AA + { + Tst_BB () {} + ~Tst_BB () {} + Tst_AA* Base () { return this; } + const char* classname () const { + return "Tst_BB"; + } + }; +}; + +class Tst_B : public Tst_A +{ + static Tst_B* last; + Tst_B (); + virtual const char* b (); +}; + +class Tst_C@luaC : public Tst_B +{ + static Tst_C* last; + Tst_C (int n); + ~Tst_C (); + virtual const char* c (); +}; + +class D // private destructor +{ + D () {} +}; + +Tst_A::Tst_AA* Tst_create_aa (); +bool Tst_is_aa (Tst_A::Tst_AA* obj); diff --git a/ThirdParty/tolua-5.2.4/src/tests/tconstant.cpp b/ThirdParty/tolua-5.2.4/src/tests/tconstant.cpp new file mode 100644 index 0000000..fa85882 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tconstant.cpp @@ -0,0 +1,22 @@ +extern "C" +{ +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tconstant.h" + + +int main (void) +{ + int tolua_tconstant_open (lua_State*); + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tconstant_open(L); + + luaL_dofile(L,"tconstant.lua"); + + lua_close(L); + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tconstant.h b/ThirdParty/tolua-5.2.4/src/tests/tconstant.h new file mode 100644 index 0000000..917ad0a --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tconstant.h @@ -0,0 +1,29 @@ +#define FIRST 1 +#define SECOND 2 + +enum { + ONE = 1, + TWO = 2 +}; + +#define M_FIRST 1 +#define M_SECOND 2 + +enum { + M_ONE = 1, + M_TWO = 2 +}; + +class A { +public: + + #define FIRST 1 + #define SECOND 2 + + enum { + ONE = 1, + TWO = 2 + }; +}; + + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tconstant.lua b/ThirdParty/tolua-5.2.4/src/tests/tconstant.lua new file mode 100644 index 0000000..4f6e12b --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tconstant.lua @@ -0,0 +1,13 @@ +dofile("myassert.lua") + +assert(FIRST==M.FIRST) +assert(FIRST==A.FIRST) +assert(SECOND==M.SECOND) +assert(SECOND==A.SECOND) + +assert(ONE==M.ONE) +assert(ONE==A.ONE) +assert(TWO==M.TWO) +assert(TWO==A.TWO) + +print("Constant test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tconstant.pkg b/ThirdParty/tolua-5.2.4/src/tests/tconstant.pkg new file mode 100644 index 0000000..ada3390 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tconstant.pkg @@ -0,0 +1,34 @@ +$#include "tconstant.h" + +#define FIRST 1 +#define SECOND 2 + +enum { + ONE = 1, + TWO = 2 +}; + +module M { + +#define M_FIRST@FIRST 1 +#define M_SECOND@SECOND 2 + +enum { + M_ONE@ONE = 1, + M_TWO@TWO = 2 +}; +} + +class A { +public: + + #define FIRST 1 + #define SECOND 2 + + enum { + ONE = 1, + TWO = 2 + }; +}; + + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tdirective.lua b/ThirdParty/tolua-5.2.4/src/tests/tdirective.lua new file mode 100644 index 0000000..011403f --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tdirective.lua @@ -0,0 +1,8 @@ +dofile("myassert.lua") + +assert(a==3) +assert(A==4) +assert(func()==5) + +print("Directive test OK") + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tdirective.pkg b/ThirdParty/tolua-5.2.4/src/tests/tdirective.pkg new file mode 100644 index 0000000..024c795 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tdirective.pkg @@ -0,0 +1,28 @@ +$#include "lualib.h" +$#include "lauxlib.h" + +$int a; +$extern int a; + +$int main (void) +${ +$ lua_State* L = luaL_newstate(); +$ luaopen_base(L); +$ tolua_tdirective_open(L); +$ luaL_dofile(L,"tdirective.lua"); +$ lua_close(L); +$ return 0; +$} + +$pfile "tdirectivepkg.pkg" + +$< + a = 3; +$> + +$[ +A = 4 +$] + +$lfile "tdirectivelua.lua" + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tdirectivelua.lua b/ThirdParty/tolua-5.2.4/src/tests/tdirectivelua.lua new file mode 100644 index 0000000..abdfd7a --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tdirectivelua.lua @@ -0,0 +1,5 @@ +dofile("myassert.lua") + +function func () + return 5 +end diff --git a/ThirdParty/tolua-5.2.4/src/tests/tdirectivepkg.pkg b/ThirdParty/tolua-5.2.4/src/tests/tdirectivepkg.pkg new file mode 100644 index 0000000..b15a66e --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tdirectivepkg.pkg @@ -0,0 +1,2 @@ +extern int a; + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tenum.c b/ThirdParty/tolua-5.2.4/src/tests/tenum.c new file mode 100644 index 0000000..3ecf4b6 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tenum.c @@ -0,0 +1,26 @@ +#include "lualib.h" +#include "lauxlib.h" + +#include "tenum.h" + +Status checkenum (Order o) +{ + if (o == FIRST) + return TRUE; + else + return FALSE; +} + +int main (void) +{ + int tolua_tenum_open (lua_State*); + lua_State* L = luaL_newstate(); + + luaL_openlibs(L); + tolua_tenum_open(L); + + luaL_dofile(L,"tenum.lua"); + + lua_close(L); + return 0; +} diff --git a/ThirdParty/tolua-5.2.4/src/tests/tenum.h b/ThirdParty/tolua-5.2.4/src/tests/tenum.h new file mode 100644 index 0000000..453f9aa --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tenum.h @@ -0,0 +1,17 @@ +#ifndef tenum_h +#define tenum_h + + +typedef enum { + FIRST, + SECOND +} Order; + +typedef enum { + FALSE, + TRUE +} Status; + +Status checkenum (Order o); + +#endif
\ No newline at end of file diff --git a/ThirdParty/tolua-5.2.4/src/tests/tenum.lua b/ThirdParty/tolua-5.2.4/src/tests/tenum.lua new file mode 100644 index 0000000..4082907 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tenum.lua @@ -0,0 +1,9 @@ +dofile("myassert.lua") + +local a = FIRST +local b = SECOND + +assert(checkenum(a)==TRUE) +assert(checkenum(b)==FALSE) + +print("Enum test OK")
\ No newline at end of file diff --git a/ThirdParty/tolua-5.2.4/src/tests/tenum.pkg b/ThirdParty/tolua-5.2.4/src/tests/tenum.pkg new file mode 100644 index 0000000..9e90cc4 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tenum.pkg @@ -0,0 +1,13 @@ +$#include "tenum.h" + +enum Order { + FIRST, + SECOND +}; + +typedef enum { + FALSE, + TRUE +} Status; + +Status checkenum (Order o); diff --git a/ThirdParty/tolua-5.2.4/src/tests/tfunction.cpp b/ThirdParty/tolua-5.2.4/src/tests/tfunction.cpp new file mode 100644 index 0000000..b4ecedb --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tfunction.cpp @@ -0,0 +1,22 @@ +extern "C" +{ +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tfunction.h" + + +int main (void) +{ + int tolua_tfunction_open (lua_State*); + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tfunction_open(L); + + luaL_dofile(L,"tfunction.lua"); + + lua_close(L); + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tfunction.h b/ThirdParty/tolua-5.2.4/src/tests/tfunction.h new file mode 100644 index 0000000..816c94b --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tfunction.h @@ -0,0 +1,215 @@ +#ifndef tfunction_h +#define tfunction_h + +#include <stdio.h> + +typedef enum { + FIRST = 1, + SECOND = 2 +} Order; + +class Point +{ + float m_x; + float m_y; + +public: + + enum Error { + SUCCESS = 0, + ERROR = 1 + }; + + Point (float x=0, float y=0) + : m_x(x), m_y(y) + { + } + virtual ~Point () + { + } + + void set (float x, float y) + { + m_x = x, m_y = y; + } + void set (float v[2]=0) + { + m_x = v[0], m_y=v[1]; + } + void setpointer (Point* p) + { + *this = *p; + } + void setref (Point& p) + { + *this = p; + } + void setvalue (Point p) + { + *this = p; + } + void setconst (const Point* p) + { + *this = *p; + } + + void get (float* x, float* y) const + { + *x = m_x, *y = m_y; + } + void get (float v[2]) const + { + v[0] = m_x, v[1] = m_y; + } + Point* getpointer () + { + return this; + } + Point& getref () + { + return *this; + } + Point getvalue () + { + return *this; + } + const Point* getconst () const + { + return this; + } + + Point operator+ (const Point& p) const + { + return Point(m_x+p.m_x,m_y+p.m_y); + } + Point operator- (const Point& p) const + { + return Point(m_x-p.m_x,m_y-p.m_y); + } + Point operator* (const Point& p) const + { + return Point(m_x*p.m_x,m_y*p.m_y); + } + Point operator/ (float n) const + { + return Point(m_x/n,m_y/n); + } + bool operator< (const Point& p) const + { + if (m_x < p.m_x) return true; + else if (m_x > p.m_x) return false; + else return m_y < p.m_y; + } + bool operator<= (const Point& p) const + { + return operator<(p) || operator==(p); + } + bool operator== (const Point& p) const + { + return m_x==p.m_x && m_y==p.m_y; + } + + int size () const + { + return 2; + } + + float operator[] (int i) const + { + return (i==0) ? m_x : m_y; + } + float& operator[] (int i) + { + return (i==0) ? m_x : m_y; + } + + static Error echo (Error e) + { + return e; + } + +}; + + +inline Point add (const Point& p1, const Point& p2) +{ + return p1+p2; +} +inline Point sub (const Point& p1, const Point& p2) +{ + return p1-p2; +} +inline Point mult (const Point& p1, const Point& p2) +{ + return p1*p2; +} +inline Point div (const Point& p1, float n) +{ + return p1/n; +} + +inline void getpoint (const Point* p, float* x, float* y) +{ + p->get(x,y); +} +inline void setpoint (Point* p, float x=0, float y=0) +{ + p->set(x,y); +} + +inline Point average (int n, Point v[]) +{ + Point p(0,0); + for (int i=0; i<n; ++i) + p = p+v[i]; + return p/n; +} + +inline Point averagepointer (int n, Point* v[]) +{ + Point p(0,0); + for (int i=0; i<n; ++i) + p = p+(*v[i]); + return p/n; +} + +inline void copyvector (int n, const Point v[], Point u[]) +{ + for (int i=0; i<n; ++i) + u[i] = v[i]; +} + +inline Order invert (Order o) +{ + if (o==FIRST) + return SECOND; + else + return FIRST; +} + + +class ColorPoint : public Point //tolua_export +{ //tolua_export + float r, g, b; +public: + +//tolua_begin + ColorPoint (float px, float py, float cr=0.0f, float cg=0.0f, float cb=0.0f) + : Point(px,py), r(cr), g(cg), b(cb) + { + } + virtual ~ColorPoint () { } + + virtual void getcolor (float* red, float *green, float *blue) const + { + *red = r; + *green = g; + *blue = b; + } + static ColorPoint* MakeRed (float x, float y) + { + return new ColorPoint(x,y,1,0,0); + } +}; +//tolua_end +#endif diff --git a/ThirdParty/tolua-5.2.4/src/tests/tfunction.lua b/ThirdParty/tolua-5.2.4/src/tests/tfunction.lua new file mode 100644 index 0000000..4cccc97 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tfunction.lua @@ -0,0 +1,104 @@ +dofile("myassert.lua") + +local p = Point:new(1,2) +local q = Point:new() + +local x, y = p:get() +local c = {}; q:get(c) + +assert(x==1 and y==2) +assert(c[1]==0 and c[2]==0) + +q:set(4,5) +p:setconst(q) +local r = p:getpointer(); +x,y = r:get() +assert(x==4 and y==5) + +local s = Point:new() +s:setref(r) +local t = s:getref() +t:set(5,6) -- t is s +x,y = s:get() +assert(x==5 and y==6) + +local u = s:getvalue() +u:set(4,1) -- u represents a copy of s +x,y = s:get() +assert(x~=4 and y~=1) + +local x1,y1 = getpoint(u) +local x2,y2 = getpoint(s) + +local p1 = alg.add(u,s) +x,y = p1:get() +assert(x==x1+x2 and y==y1+y2) + +local p2 = alg.sub(u,s) +x,y = p2:get() +assert(x==x1-x2 and y==y1-y2) + +local p3 = alg.mult(u,s) +x,y = p3:get() +assert(x==x1*x2 and y==y1*y2) + +local p4 = alg.div(s,2) +x,y = p4:get() +assert(x==x2/2 and y==y2/2) + +setpoint(p4) +x,y = p4:get() +assert(x==0 and y==0) + +local cp = ColorPoint:MakeRed(3,4) +local p = cp+cp +x,y = p:get() +assert(x==6 and y==8) +local q = p-cp +x,y = q:get() +assert(x==3 and y==4) +local r = p/2 +x,y = r:get() +assert(x==3 and y==4) +local t = r*cp +x,y = t:get() +assert(x==9 and y==16) +assert(t==r*r) +-- assert(q==cp) -- the eq does not deal with different metatables +assert(t~=q) +assert(q<t) +assert(q<=t) +assert(t>q) +assert(t>=q) + +local p = Point:new(1,2) +assert(p[1]==1 and p[2]==2) +p[1]=3; p[2] = p[2]+2 +local x, y = p:get() +assert(x==3 and y==4) +assert(#p==2) + +local n = 3 +local v = {Point:new(0,1), Point:new(2,3), Point:new(4,5)} + +local m = average(n,v) +local c = averagepointer(n,v) +local t = {} +copyvector(n,v,t) + +local l = Point:new() +for i=1,n do + assert(v[i]==t[i]) + l[1] = l[1] + v[i][1] + l[2] = l[2] + v[i][2] +end +l = l/n +assert(m==l) +assert(c==l) + +assert(Point.SUCCESS==Point:echo(Point.SUCCESS)) +assert(Point.ERROR==Point:echo(Point.ERROR)) +assert(FIRST==invert(SECOND)) +assert(SECOND==invert(FIRST)) + +print("Function test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tfunction.pkg b/ThirdParty/tolua-5.2.4/src/tests/tfunction.pkg new file mode 100644 index 0000000..1e4eae0 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tfunction.pkg @@ -0,0 +1,73 @@ +$#include "tfunction.h" + +typedef enum { + FIRST = 1, + SECOND = 2 +} Order; + +class Point +{ + enum Error { + SUCCESS = 0, + ERROR = 1 + }; + + Point (float x=0, float y=0); + virtual ~Point (); + + void set (float x, float y); + void set (float v[2]=0); + void setpointer (Point* p); + void setref (Point& p); + void setvalue (Point p); + void setconst (const Point* p); + + void get (float* x=0, float* y=0) const; + void get (float v[2]=0) const; + Point* getpointer (); + Point& getref (); + Point getvalue (); + const Point* getconst () const; + + Point operator+ (const Point& p) const; + Point operator- (const Point& p) const; + Point operator* (const Point& p) const; + Point operator/ (float n) const; + bool operator< (const Point& p) const; + bool operator<= (const Point& p) const; + bool operator== (const Point& p) const; + + tolua_len size () const; + float operator[] (int i) const; + float& operator[] (int i); + + static Error echo (Error e); +}; + +module alg +{ + Point add (const Point& p1, const Point& p2); + Point sub (const Point& p1, const Point& p2); + Point mult (const Point& p1, const Point& p2); + Point div (const Point& p1, float n); +} + +void getpoint (const Point* p, float* x=0, float* y=0); +void setpoint (Point* p, float x=0, float y=0); +inline Point average (int n, Point v[n]); +inline Point averagepointer (int n, Point* v[n]); +inline void copyvector (int n, const Point v[n], Point u[n]=(u+i)); + +inline Order invert (Order o); + +$cfile "tfunction.h" + +/* +class ColorPoint : public Point +{ + ColorPoint (float px, float py, float cr=0.0f, float cg=0.0f, float cb=0.0f); + virtual ~ColorPoint (); + virtual void getcolor (float* red, float *green, float *blue) const; + static const Point* MakeRed (float x, float y); +}; +*/ diff --git a/ThirdParty/tolua-5.2.4/src/tests/tinheritance.cpp b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.cpp new file mode 100644 index 0000000..4396a7e --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.cpp @@ -0,0 +1,21 @@ +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +int main () +{ + int tolua_tinheritance_open (lua_State*); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tinheritance_open(L); + + luaL_dofile(L,"tinheritance.lua"); + + lua_close(L); + + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tinheritance.h b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.h new file mode 100644 index 0000000..d572abc --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.h @@ -0,0 +1,35 @@ +#include <stdio.h> + +class A +{ +public: + A () {} + virtual ~A() {} + virtual const char* aname () { return "A"; } + virtual const char* name () { return "A"; } +}; + +class B : public A +{ +public: + B () {} + virtual ~B() {} + virtual const char* name () { return "B"; } +}; + +class C : public B +{ +public: + C () {} + virtual ~C() {} + virtual const char* name () { return "C"; } +}; + +class D : public C +{ +public: + D () {} + virtual ~D() {} + virtual const char* name () { return "D"; } +}; + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tinheritance.lua b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.lua new file mode 100644 index 0000000..2df1f38 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.lua @@ -0,0 +1,16 @@ +dofile("myassert.lua") + +-- type convertion tests +local a = A:new() +local b = B:new() +local c = C:new() +local d = D:new() + +assert(b:name()=="B") +assert(b:aname()=="A") +assert(c:name()=="C") +assert(c:aname()=="A") +assert(d:name()=="D") +assert(d:aname()=="A") + +print("Inheritance test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tinheritance.pkg b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.pkg new file mode 100644 index 0000000..4a40de7 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tinheritance.pkg @@ -0,0 +1,35 @@ +$#include "tinheritance.h" + +class A +{ +public: + A () {} + virtual ~A() {} + virtual const char* aname () { return "A"; } + virtual const char* name () { return "A"; } +}; + +class B : public A +{ +public: + B () {} + virtual ~B() {} + virtual const char* name () { return "B"; } +}; + +class C : public B +{ +public: + C () {} + virtual ~C() {} + virtual const char* name () { return "C"; } +}; + +class D : public C +{ +public: + D () {} + virtual ~D() {} + virtual const char* name () { return "D"; } +}; + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tmodule.c b/ThirdParty/tolua-5.2.4/src/tests/tmodule.c new file mode 100644 index 0000000..c5e0d29 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tmodule.c @@ -0,0 +1,24 @@ +#include "lualib.h" +#include "lauxlib.h" + +#include "tmodule.h" + +int a = 1; +int b = 2; +int c = 3; +int d = 4; + +int main () +{ + int tolua_tmodule_open (lua_State*); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tmodule_open(L); + + luaL_dofile(L,"tmodule.lua"); + + lua_close(L); + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tmodule.h b/ThirdParty/tolua-5.2.4/src/tests/tmodule.h new file mode 100644 index 0000000..3766bc4 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tmodule.h @@ -0,0 +1,7 @@ +#include <stdio.h> + +extern int a; +extern int b; +extern int c; +extern int d; + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tmodule.lua b/ThirdParty/tolua-5.2.4/src/tests/tmodule.lua new file mode 100644 index 0000000..0593ee9 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tmodule.lua @@ -0,0 +1,19 @@ +dofile("myassert.lua") + +-- test valid access +assert(A.a==1) +assert(A.B.b==2) +assert(A.B.C.c==3) + +-- test invalid access +assert(A.B.a==nil) -- no inheritance +assert(A.B.C.a==nil) + +assert(A.b==nil) -- no access the inner module +assert(A.c==nil) +assert(A.B.c==nil) + +-- test variables appended to existing modules +assert(A.d==4) + +print("Module test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tmodule.pkg b/ThirdParty/tolua-5.2.4/src/tests/tmodule.pkg new file mode 100644 index 0000000..43d4306 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tmodule.pkg @@ -0,0 +1,16 @@ + +$#include "tmodule.h" + +module A { + extern int a; + module B { + extern int b; + module C { + extern int c; + } + } +} + +module A { + extern int d; +} diff --git a/ThirdParty/tolua-5.2.4/src/tests/tnamespace.cpp b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.cpp new file mode 100644 index 0000000..0884d35 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.cpp @@ -0,0 +1,25 @@ +extern "C" { +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tnamespace.h" + +int A::a = 1; +int A::B::b = 2; +int A::B::C::c = 3; + +int main () +{ + int tolua_tnamespace_open (lua_State*); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tnamespace_open(L); + + luaL_dofile(L,"tnamespace.lua"); + + lua_close(L); + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tnamespace.h b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.h new file mode 100644 index 0000000..8c15e41 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.h @@ -0,0 +1,11 @@ +namespace A { + enum {FIRST=1}; + extern int a; + namespace B { + extern int b; + namespace C { + extern int c; + } + } +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tnamespace.lua b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.lua new file mode 100644 index 0000000..f378bee --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.lua @@ -0,0 +1,16 @@ +dofile("myassert.lua") + +-- test valid access +assert(A.a==1) +assert(A.B.b==2) +assert(A.B.C.c==3) + +-- test invalid access +assert(A.B.a==nil) -- no inheritance +assert(A.B.C.a==nil) + +assert(A.b==nil) -- no access the inner module +assert(A.c==nil) +assert(A.B.c==nil) + +print("Namespace test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tnamespace.pkg b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.pkg new file mode 100644 index 0000000..0b58366 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tnamespace.pkg @@ -0,0 +1,13 @@ + +$#include "tnamespace.h" + +namespace A { + int a; + namespace B { + int b; + namespace C { + int c; + } + } +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tpeer.cpp b/ThirdParty/tolua-5.2.4/src/tests/tpeer.cpp new file mode 100644 index 0000000..1cc263a --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tpeer.cpp @@ -0,0 +1,24 @@ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tpeer.h" + +int main () +{ + int tolua_tpeer_open (lua_State*); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tpeer_open(L); + if (luaL_dofile(L,"tpeer.lua")) { + printf("Error: %s\n",lua_tostring(L,-1)); + } + lua_close(L); + + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tpeer.h b/ThirdParty/tolua-5.2.4/src/tests/tpeer.h new file mode 100644 index 0000000..b11d1a9 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tpeer.h @@ -0,0 +1,26 @@ +#include "tolua.h" + +class Point +{ + double m_x, m_y; +public: + Point (double x, double y) + : m_x(x), m_y(y) + { + } + double X () const + { + return m_x; + } + double Y () const + { + return m_y; + } + int gets (lua_State* L) const + { + tolua_pushnumber(L,m_x); + tolua_pushnumber(L,m_y); + return 2; + } +}; + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tpeer.lua b/ThirdParty/tolua-5.2.4/src/tests/tpeer.lua new file mode 100644 index 0000000..dc0e229 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tpeer.lua @@ -0,0 +1,23 @@ +local mt = { + __index = function (self,key) + if key == 1 then + return self._obj:X() + elseif key == 2 then + return self._obj:Y() + elseif key == "Sum" then + return function (self) return self:X() + self:Y() end + else + return nil + end + end +} +local p = Point:new(2,3) +local t = tolua.getpeertable(p) +t._obj = p +setmetatable(t,mt) +assert(p[1]+p[2] == p:Sum()) + +local x, y = p:gets() +assert(x==p[1] and y==p[2]) + +print("Peer test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tpeer.pkg b/ThirdParty/tolua-5.2.4/src/tests/tpeer.pkg new file mode 100644 index 0000000..d14c5fa --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tpeer.pkg @@ -0,0 +1,10 @@ +$#include "tpeer.h" + +class Point +{ + Point (double x, double y); + double X () const; + double Y () const; + tolua_multret gets (lua_State* L) const; +}; + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvararg.cpp b/ThirdParty/tolua-5.2.4/src/tests/tvararg.cpp new file mode 100644 index 0000000..9f58fb8 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvararg.cpp @@ -0,0 +1,42 @@ +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tvararg.h" + + +#include <assert.h> +#include <stdlib.h> + +int B::n = 0; + +static void check (void) +{ + assert(B::n == 0); +} + +int main () +{ + int tolua_tvararg_open (lua_State*); + + atexit(check); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + tolua_tvararg_open(L); + + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_setglobal(L, "ubox"); + + if (luaL_dofile(L,"tvararg.lua")) { + printf("Error: %s\n",lua_tostring(L,-1)); + } + + lua_close(L); + + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvararg.h b/ThirdParty/tolua-5.2.4/src/tests/tvararg.h new file mode 100644 index 0000000..76c5de0 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvararg.h @@ -0,0 +1,38 @@ +#include <stdio.h> + +struct B +{ + static int n; + B() {++n; } + ~B() {--n; } +}; + +class A +{ + double v[3]; +public: + A() { v[0]=1.0; v[1]=2.0; v[2]=3.0;} + double get (int i) + { + return v[i]; + } + int bounce (int i, int* j, int* k) + { + *k = i; + return i; + } + double add (lua_State* L) + { + double a = 0.0; + int n=2; + while (lua_isnumber(L, n)) { + a += lua_tonumber(L, n); + ++n; + } + return a; + } + B* GetB () + { + return new B(); + } +}; diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvararg.lua b/ThirdParty/tolua-5.2.4/src/tests/tvararg.lua new file mode 100644 index 0000000..7b42eec --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvararg.lua @@ -0,0 +1,14 @@ +local a = A:new() +local b = a:GetB() +local t = {} +for i = 1, 100 do + t[i] = a:GetB() + local a, b, c = a:bounce(i,i) + assert(a==i and b==i and c==i) +end + +t = nil +b = nil +collectgarbage("collect") +assert(B.n == 0) +print("VarArg OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvararg.pkg b/ThirdParty/tolua-5.2.4/src/tests/tvararg.pkg new file mode 100644 index 0000000..0ab6d88 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvararg.pkg @@ -0,0 +1,17 @@ +$#include "tvararg.h" + +struct B +{ + static int n; + B(); + ~B(); +}; + +class A +{ + A(); + double get (int i) ; + tolua_index bounce (tolua_index i, tolua_index *j, tolua_index* k=0); + double add (lua_State* L); + tolua_own B* GetB (); +}; diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvariable.c b/ThirdParty/tolua-5.2.4/src/tests/tvariable.c new file mode 100644 index 0000000..1ec97e4 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvariable.c @@ -0,0 +1,46 @@ +#include "lualib.h" +#include "lauxlib.h" + +#include "tvariable.h" + +int i = 1; +float f = 2.0f;; +double d = 3.0; +char* s = "Hello world"; +void* v = (void*)1; +char n[64] = "Hi there"; + +A a = {11,12.0f,13.0,"Hello world from class",(void*)1,"Hi there from class"}; +B* b; +U u; + +int mi = 21; +float mf = 22.0f; +double md = 23.0; +char* ms = "Hello world in module"; +void* mv = NULL; +char mn[64] = "Hi there in module"; +A ma = {31,32.0f,33.0,"Hello world from class in module", + NULL,"Hi there from class in module"}; +B* mb; + +int main (void) +{ + int tolua_tvariable_open (lua_State*); + lua_State* L = luaL_newstate(); + + B bb = {a,NULL}; + B bbb = {ma,&bb}; + b = &bb; + mb = &bbb; + + + luaL_openlibs(L); + tolua_tvariable_open(L); + + luaL_dofile(L,"tvariable.lua"); + + lua_close(L); + return 0; +} + diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvariable.h b/ThirdParty/tolua-5.2.4/src/tests/tvariable.h new file mode 100644 index 0000000..6363c48 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvariable.h @@ -0,0 +1,44 @@ +typedef struct A A; +typedef struct B B; +typedef union U U; + +struct A +{ + int i; + float f; + double d; + char* s; + void* v; + char n[64]; +}; + +union U +{ + int i; + float f; +}; + +struct B +{ + A a; + B* b; +}; + +extern int i; +extern float f; +extern double d; +extern char* s; +extern void* v; +extern char n[64]; +extern A a; +extern B* b; +extern U u; + +extern int mi; +extern float mf; +extern double md; +extern char* ms; +extern void* mv; +extern char mn[64]; +extern A ma; +extern B* mb; diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvariable.lua b/ThirdParty/tolua-5.2.4/src/tests/tvariable.lua new file mode 100644 index 0000000..6d3d963 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvariable.lua @@ -0,0 +1,75 @@ +dofile("myassert.lua") + +assert(i==1) +assert(f==2) +assert(d==3) +assert(s=="Hello world") +assert(n=="Hi there") +n = "Hello" +assert(n=="Hello") + +assert(a.i==11) +assert(a.f==12) +assert(a.d==13) +assert(a.s=="Hello world from class") +assert(a.n=="Hi there from class") +a.n = "Hello from class" +assert(a.n=="Hello from class") + +assert(v==a.v) + +u.i = 2 +assert(u.i==2) +u.f = 2 +assert(u.f==2) +assert(u.i~=2) + +assert(M.mi==21) +assert(M.mf==22) +assert(M.md==23) +assert(M.ms=="Hello world in module") +assert(M.mn=="Hi there in module") +M.mn = "Hello in module" +assert(M.mn=="Hello in module") +assert(M.mv==nil) + +assert(M.ma.i==31) +assert(M.ma.f==32) +assert(M.ma.d==33) +assert(M.ma.s=="Hello world from class in module") +assert(M.ma.n=="Hi there from class in module") +M.ma.n = "Hello from class in module" +assert(M.ma.n=="Hello from class in module") +assert(M.ma.v==nil) + +assert(a.i==b.a.i) +assert(a.f==b.a.f) +assert(a.d==b.a.d) +assert(a.s==b.a.s) +assert(a.v==b.a.v) +assert(b.b==nil) + +assert(M.ma.i==M.mb.a.i) +assert(M.ma.f==M.mb.a.f) +assert(M.ma.d==M.mb.a.d) +assert(M.ma.s==M.mb.a.s) +assert(M.ma.v==M.mb.a.v) + +assert(a.i==M.mb.b.a.i) +assert(a.f==M.mb.b.a.f) +assert(a.d==M.mb.b.a.d) +assert(a.s==M.mb.b.a.s) +assert(a.v==M.mb.b.a.v) +assert(M.mb.b.b==nil) + +assert(s~=rawget(_G,"s")) -- because s represents a C variable +s = "Hello" +assert(s==rawget(_G,"s")) -- because s is mapped as const + +f = 25.0 +assert(f~=rawget(_G,"f")) -- because f represents a C variable + +b.a.i = 5 +assert(b.a.i==M.mb.b.a.i) + +print("Variable test OK") diff --git a/ThirdParty/tolua-5.2.4/src/tests/tvariable.pkg b/ThirdParty/tolua-5.2.4/src/tests/tvariable.pkg new file mode 100644 index 0000000..a8a1539 --- /dev/null +++ b/ThirdParty/tolua-5.2.4/src/tests/tvariable.pkg @@ -0,0 +1,45 @@ +$#include "tvariable.h" + +struct A +{ + int i; + float f; + double d; + char* s; + void* v; + char n[64]; +}; + +struct B +{ + A a; + B* b; +}; + +union U +{ + int i; + float f; +}; + +extern int i; +extern float f; +extern double d; +extern const char* s; +extern void* v; +extern char n[64]; +extern A a; +extern B* b; +extern U u; + +module M { +extern int mi; +extern float mf; +extern double md; +extern const char* ms; +extern void* mv; +extern const char mn[64]; +extern A a; +extern A ma; +extern B* mb; +} |