From 96232c27c6b00ec420aca993ed0db1c46e53cd7a Mon Sep 17 00:00:00 2001 From: Alex Grant Benedict Date: Wed, 24 Nov 2021 15:32:57 -0700 Subject: [PATCH] Add in vendored depenedencies. --- third-party/lua-5.1.5/CMakeLists.txt | 7 + third-party/lua-5.1.5/COPYRIGHT | 34 + third-party/lua-5.1.5/HISTORY | 183 + third-party/lua-5.1.5/INSTALL | 99 + third-party/lua-5.1.5/Makefile | 128 + third-party/lua-5.1.5/README | 37 + third-party/lua-5.1.5/doc/contents.html | 497 + third-party/lua-5.1.5/doc/cover.png | Bin 0 -> 3305 bytes third-party/lua-5.1.5/doc/logo.gif | Bin 0 -> 4232 bytes third-party/lua-5.1.5/doc/lua.1 | 163 + third-party/lua-5.1.5/doc/lua.css | 83 + third-party/lua-5.1.5/doc/lua.html | 172 + third-party/lua-5.1.5/doc/luac.1 | 136 + third-party/lua-5.1.5/doc/luac.html | 145 + third-party/lua-5.1.5/doc/manual.css | 24 + third-party/lua-5.1.5/doc/manual.html | 8804 +++++++++++++++++ third-party/lua-5.1.5/doc/readme.html | 40 + third-party/lua-5.1.5/etc/Makefile | 44 + third-party/lua-5.1.5/etc/README | 37 + third-party/lua-5.1.5/etc/all.c | 38 + third-party/lua-5.1.5/etc/lua.hpp | 9 + third-party/lua-5.1.5/etc/lua.ico | Bin 0 -> 1078 bytes third-party/lua-5.1.5/etc/lua.pc | 31 + third-party/lua-5.1.5/etc/luavs.bat | 28 + third-party/lua-5.1.5/etc/min.c | 39 + third-party/lua-5.1.5/etc/noparser.c | 50 + third-party/lua-5.1.5/etc/strict.lua | 41 + third-party/lua-5.1.5/src/CMakeLists.txt | 62 + third-party/lua-5.1.5/src/Makefile | 182 + third-party/lua-5.1.5/src/lapi.c | 1087 ++ third-party/lua-5.1.5/src/lapi.h | 16 + third-party/lua-5.1.5/src/lauxlib.c | 652 ++ third-party/lua-5.1.5/src/lauxlib.h | 174 + third-party/lua-5.1.5/src/lbaselib.c | 653 ++ third-party/lua-5.1.5/src/lcode.c | 831 ++ third-party/lua-5.1.5/src/lcode.h | 76 + third-party/lua-5.1.5/src/ldblib.c | 398 + third-party/lua-5.1.5/src/ldebug.c | 638 ++ third-party/lua-5.1.5/src/ldebug.h | 33 + third-party/lua-5.1.5/src/ldo.c | 519 + third-party/lua-5.1.5/src/ldo.h | 57 + third-party/lua-5.1.5/src/ldump.c | 164 + third-party/lua-5.1.5/src/lfunc.c | 174 + third-party/lua-5.1.5/src/lfunc.h | 34 + third-party/lua-5.1.5/src/lgc.c | 710 ++ third-party/lua-5.1.5/src/lgc.h | 110 + third-party/lua-5.1.5/src/linit.c | 38 + third-party/lua-5.1.5/src/liolib.c | 556 ++ third-party/lua-5.1.5/src/llex.c | 463 + third-party/lua-5.1.5/src/llex.h | 81 + third-party/lua-5.1.5/src/llimits.h | 128 + third-party/lua-5.1.5/src/lmathlib.c | 263 + third-party/lua-5.1.5/src/lmem.c | 86 + third-party/lua-5.1.5/src/lmem.h | 49 + third-party/lua-5.1.5/src/loadlib.c | 666 ++ third-party/lua-5.1.5/src/lobject.c | 214 + third-party/lua-5.1.5/src/lobject.h | 381 + third-party/lua-5.1.5/src/lopcodes.c | 102 + third-party/lua-5.1.5/src/lopcodes.h | 268 + third-party/lua-5.1.5/src/loslib.c | 243 + third-party/lua-5.1.5/src/lparser.c | 1339 +++ third-party/lua-5.1.5/src/lparser.h | 82 + third-party/lua-5.1.5/src/lstate.c | 214 + third-party/lua-5.1.5/src/lstate.h | 169 + third-party/lua-5.1.5/src/lstring.c | 111 + third-party/lua-5.1.5/src/lstring.h | 31 + third-party/lua-5.1.5/src/lstrlib.c | 871 ++ third-party/lua-5.1.5/src/ltable.c | 588 ++ third-party/lua-5.1.5/src/ltable.h | 40 + third-party/lua-5.1.5/src/ltablib.c | 287 + third-party/lua-5.1.5/src/ltm.c | 75 + third-party/lua-5.1.5/src/ltm.h | 54 + third-party/lua-5.1.5/src/lua.c | 392 + third-party/lua-5.1.5/src/lua.h | 388 + third-party/lua-5.1.5/src/luac.c | 200 + third-party/lua-5.1.5/src/luaconf.h | 763 ++ third-party/lua-5.1.5/src/lualib.h | 53 + third-party/lua-5.1.5/src/lundump.c | 227 + third-party/lua-5.1.5/src/lundump.h | 36 + third-party/lua-5.1.5/src/lvm.c | 767 ++ third-party/lua-5.1.5/src/lvm.h | 36 + third-party/lua-5.1.5/src/lzio.c | 82 + third-party/lua-5.1.5/src/lzio.h | 67 + third-party/lua-5.1.5/src/print.c | 227 + third-party/lua-5.1.5/test/README | 26 + third-party/lua-5.1.5/test/bisect.lua | 27 + third-party/lua-5.1.5/test/cf.lua | 16 + third-party/lua-5.1.5/test/echo.lua | 5 + third-party/lua-5.1.5/test/env.lua | 7 + third-party/lua-5.1.5/test/factorial.lua | 32 + third-party/lua-5.1.5/test/fib.lua | 40 + third-party/lua-5.1.5/test/fibfor.lua | 13 + third-party/lua-5.1.5/test/globals.lua | 13 + third-party/lua-5.1.5/test/hello.lua | 3 + third-party/lua-5.1.5/test/life.lua | 111 + third-party/lua-5.1.5/test/luac.lua | 7 + third-party/lua-5.1.5/test/printf.lua | 7 + third-party/lua-5.1.5/test/readonly.lua | 12 + third-party/lua-5.1.5/test/sieve.lua | 29 + third-party/lua-5.1.5/test/sort.lua | 66 + third-party/lua-5.1.5/test/table.lua | 12 + third-party/lua-5.1.5/test/trace-calls.lua | 32 + third-party/lua-5.1.5/test/trace-globals.lua | 38 + third-party/lua-5.1.5/test/xd.lua | 14 + .../lua-5.1.5/toluapp-simple/CMakeLists.txt | 39 + .../lua-5.1.5/toluapp-simple/COPYRIGHT | 33 + .../lua-5.1.5/toluapp-simple/tolua++.h | 186 + third-party/lua-5.1.5/toluapp-simple/tolua.c | 169 + .../lua-5.1.5/toluapp-simple/tolua_event.c | 536 + .../lua-5.1.5/toluapp-simple/tolua_event.h | 24 + .../lua-5.1.5/toluapp-simple/tolua_is.c | 621 ++ .../lua-5.1.5/toluapp-simple/tolua_map.c | 704 ++ .../lua-5.1.5/toluapp-simple/tolua_push.c | 171 + .../lua-5.1.5/toluapp-simple/tolua_to.c | 133 + .../lua-5.1.5/toluapp-simple/toluabind.c | 8072 +++++++++++++++ .../lua-5.1.5/toluapp-simple/toluabind.h | 8 + .../toluapp-simple/toluabind_default.h | 8 + third-party/lua-5.1.5/toluapp/.travis.yml | 51 + third-party/lua-5.1.5/toluapp/CMakeLists.txt | 38 + third-party/lua-5.1.5/toluapp/INSTALL | 42 + third-party/lua-5.1.5/toluapp/README | 30 + third-party/lua-5.1.5/toluapp/README-5.1 | 50 + .../lua-5.1.5/toluapp/cmake/FindLua.cmake | 118 + .../lua-5.1.5/toluapp/cmake/dist.cmake | 321 + third-party/lua-5.1.5/toluapp/cmake/lua.cmake | 293 + third-party/lua-5.1.5/toluapp/dist.info | 14 + third-party/lua-5.1.5/toluapp/doc/index.html | 226 + .../lua-5.1.5/toluapp/doc/tolua++.html | 1956 ++++ third-party/lua-5.1.5/toluapp/doc/toluapp.gif | Bin 0 -> 5941 bytes .../lua-5.1.5/toluapp/include/tolua++.h | 186 + third-party/lua-5.1.5/toluapp/libtoluapp.def | 65 + .../lua-5.1.5/toluapp/simple_build/COPYRIGHT | 33 + .../toluapp/simple_build/bin/tolua.c | 169 + .../toluapp/simple_build/bin/toluabind.c | 8072 +++++++++++++++ .../toluapp/simple_build/bin/toluabind.h | 8 + .../simple_build/bin/toluabind_default.h | 8 + .../toluapp/simple_build/include/tolua++.h | 186 + .../toluapp/simple_build/lib/tolua_event.c | 536 + .../toluapp/simple_build/lib/tolua_event.h | 24 + .../toluapp/simple_build/lib/tolua_is.c | 621 ++ .../toluapp/simple_build/lib/tolua_map.c | 704 ++ .../toluapp/simple_build/lib/tolua_push.c | 171 + .../toluapp/simple_build/lib/tolua_to.c | 133 + third-party/lua-5.1.5/toluapp/src/bin/SCsub | 12 + .../lua-5.1.5/toluapp/src/bin/lua/all.lua | 30 + .../lua-5.1.5/toluapp/src/bin/lua/array.lua | 233 + .../lua-5.1.5/toluapp/src/bin/lua/basic.lua | 414 + .../lua-5.1.5/toluapp/src/bin/lua/class.lua | 202 + .../lua-5.1.5/toluapp/src/bin/lua/clean.lua | 79 + .../lua-5.1.5/toluapp/src/bin/lua/code.lua | 105 + .../toluapp/src/bin/lua/compat-5.1.lua | 57 + .../lua-5.1.5/toluapp/src/bin/lua/compat.lua | 193 + .../toluapp/src/bin/lua/container.lua | 786 ++ .../lua-5.1.5/toluapp/src/bin/lua/custom.lua | 45 + .../toluapp/src/bin/lua/declaration.lua | 579 ++ .../lua-5.1.5/toluapp/src/bin/lua/define.lua | 63 + .../lua-5.1.5/toluapp/src/bin/lua/doit.lua | 101 + .../toluapp/src/bin/lua/enumerate.lua | 106 + .../lua-5.1.5/toluapp/src/bin/lua/feature.lua | 139 + .../toluapp/src/bin/lua/function.lua | 577 ++ .../lua-5.1.5/toluapp/src/bin/lua/module.lua | 68 + .../toluapp/src/bin/lua/namespace.lua | 52 + .../toluapp/src/bin/lua/operator.lua | 220 + .../lua-5.1.5/toluapp/src/bin/lua/package.lua | 343 + .../toluapp/src/bin/lua/template_class.lua | 82 + .../lua-5.1.5/toluapp/src/bin/lua/typedef.lua | 71 + .../toluapp/src/bin/lua/variable.lua | 300 + .../toluapp/src/bin/lua/verbatim.lua | 78 + third-party/lua-5.1.5/toluapp/src/bin/tolua.c | 169 + .../lua-5.1.5/toluapp/src/bin/tolua_scons.pkg | 31 + .../lua-5.1.5/toluapp/src/bin/toluabind.c | 8072 +++++++++++++++ .../lua-5.1.5/toluapp/src/bin/toluabind.h | 8 + .../toluapp/src/bin/toluabind_default.c | 8009 +++++++++++++++ .../toluapp/src/bin/toluabind_default.h | 8 + third-party/lua-5.1.5/toluapp/src/lib/SCsub | 18 + .../lua-5.1.5/toluapp/src/lib/tolua_event.c | 536 + .../lua-5.1.5/toluapp/src/lib/tolua_event.h | 24 + .../lua-5.1.5/toluapp/src/lib/tolua_is.c | 621 ++ .../lua-5.1.5/toluapp/src/lib/tolua_map.c | 704 ++ .../lua-5.1.5/toluapp/src/lib/tolua_push.c | 171 + .../lua-5.1.5/toluapp/src/lib/tolua_to.c | 133 + third-party/lua-5.1.5/toluapp/src/tests/SCsub | 18 + .../lua-5.1.5/toluapp/src/tests/tarray.c | 45 + .../lua-5.1.5/toluapp/src/tests/tarray.h | 28 + .../lua-5.1.5/toluapp/src/tests/tarray.lua | 37 + .../lua-5.1.5/toluapp/src/tests/tarray.pkg | 29 + .../lua-5.1.5/toluapp/src/tests/tarraybind.c | 504 + .../lua-5.1.5/toluapp/src/tests/tclass.cpp | 32 + .../lua-5.1.5/toluapp/src/tests/tclass.h | 121 + .../lua-5.1.5/toluapp/src/tests/tclass.lua | 131 + .../lua-5.1.5/toluapp/src/tests/tclass.pkg | 97 + .../lua-5.1.5/toluapp/src/tests/tconstant.h | 29 + .../lua-5.1.5/toluapp/src/tests/tconstant.lua | 11 + .../lua-5.1.5/toluapp/src/tests/tconstant.pkg | 34 + .../toluapp/src/tests/tdirective.lua | 6 + .../toluapp/src/tests/tdirective.pkg | 28 + .../toluapp/src/tests/tdirectivebind.c | 85 + .../toluapp/src/tests/tdirectivelua.lua | 3 + .../toluapp/src/tests/tdirectivepkg.pkg | 2 + .../lua-5.1.5/toluapp/src/tests/tfunction.h | 220 + .../lua-5.1.5/toluapp/src/tests/tfunction.lua | 104 + .../lua-5.1.5/toluapp/src/tests/tfunction.pkg | 74 + .../lua-5.1.5/toluapp/src/tests/tmodule.c | 24 + .../lua-5.1.5/toluapp/src/tests/tmodule.h | 7 + .../lua-5.1.5/toluapp/src/tests/tmodule.lua | 17 + .../lua-5.1.5/toluapp/src/tests/tmodule.pkg | 16 + .../lua-5.1.5/toluapp/src/tests/tmodulebind.c | 124 + .../lua-5.1.5/toluapp/src/tests/tnamespace.h | 11 + .../toluapp/src/tests/tnamespace.lua | 14 + .../toluapp/src/tests/tnamespace.pkg | 13 + .../lua-5.1.5/toluapp/src/tests/tvariable.c | 46 + .../lua-5.1.5/toluapp/src/tests/tvariable.h | 44 + .../lua-5.1.5/toluapp/src/tests/tvariable.lua | 73 + .../lua-5.1.5/toluapp/src/tests/tvariable.pkg | 45 + .../toluapp/src/tests/tvariablebind.c | 631 ++ .../lua-5.1.5/toluapp/win32/vc7/toluapp.sln | 27 + .../toluapp/win32/vc7/toluapp.vcproj | 259 + 217 files changed, 79773 insertions(+) create mode 100644 third-party/lua-5.1.5/CMakeLists.txt create mode 100644 third-party/lua-5.1.5/COPYRIGHT create mode 100644 third-party/lua-5.1.5/HISTORY create mode 100644 third-party/lua-5.1.5/INSTALL create mode 100644 third-party/lua-5.1.5/Makefile create mode 100644 third-party/lua-5.1.5/README create mode 100644 third-party/lua-5.1.5/doc/contents.html create mode 100644 third-party/lua-5.1.5/doc/cover.png create mode 100644 third-party/lua-5.1.5/doc/logo.gif create mode 100644 third-party/lua-5.1.5/doc/lua.1 create mode 100644 third-party/lua-5.1.5/doc/lua.css create mode 100644 third-party/lua-5.1.5/doc/lua.html create mode 100644 third-party/lua-5.1.5/doc/luac.1 create mode 100644 third-party/lua-5.1.5/doc/luac.html create mode 100644 third-party/lua-5.1.5/doc/manual.css create mode 100644 third-party/lua-5.1.5/doc/manual.html create mode 100644 third-party/lua-5.1.5/doc/readme.html create mode 100644 third-party/lua-5.1.5/etc/Makefile create mode 100644 third-party/lua-5.1.5/etc/README create mode 100644 third-party/lua-5.1.5/etc/all.c create mode 100644 third-party/lua-5.1.5/etc/lua.hpp create mode 100644 third-party/lua-5.1.5/etc/lua.ico create mode 100644 third-party/lua-5.1.5/etc/lua.pc create mode 100644 third-party/lua-5.1.5/etc/luavs.bat create mode 100644 third-party/lua-5.1.5/etc/min.c create mode 100644 third-party/lua-5.1.5/etc/noparser.c create mode 100644 third-party/lua-5.1.5/etc/strict.lua create mode 100644 third-party/lua-5.1.5/src/CMakeLists.txt create mode 100644 third-party/lua-5.1.5/src/Makefile create mode 100644 third-party/lua-5.1.5/src/lapi.c create mode 100644 third-party/lua-5.1.5/src/lapi.h create mode 100644 third-party/lua-5.1.5/src/lauxlib.c create mode 100644 third-party/lua-5.1.5/src/lauxlib.h create mode 100644 third-party/lua-5.1.5/src/lbaselib.c create mode 100644 third-party/lua-5.1.5/src/lcode.c create mode 100644 third-party/lua-5.1.5/src/lcode.h create mode 100644 third-party/lua-5.1.5/src/ldblib.c create mode 100644 third-party/lua-5.1.5/src/ldebug.c create mode 100644 third-party/lua-5.1.5/src/ldebug.h create mode 100644 third-party/lua-5.1.5/src/ldo.c create mode 100644 third-party/lua-5.1.5/src/ldo.h create mode 100644 third-party/lua-5.1.5/src/ldump.c create mode 100644 third-party/lua-5.1.5/src/lfunc.c create mode 100644 third-party/lua-5.1.5/src/lfunc.h create mode 100644 third-party/lua-5.1.5/src/lgc.c create mode 100644 third-party/lua-5.1.5/src/lgc.h create mode 100644 third-party/lua-5.1.5/src/linit.c create mode 100644 third-party/lua-5.1.5/src/liolib.c create mode 100644 third-party/lua-5.1.5/src/llex.c create mode 100644 third-party/lua-5.1.5/src/llex.h create mode 100644 third-party/lua-5.1.5/src/llimits.h create mode 100644 third-party/lua-5.1.5/src/lmathlib.c create mode 100644 third-party/lua-5.1.5/src/lmem.c create mode 100644 third-party/lua-5.1.5/src/lmem.h create mode 100644 third-party/lua-5.1.5/src/loadlib.c create mode 100644 third-party/lua-5.1.5/src/lobject.c create mode 100644 third-party/lua-5.1.5/src/lobject.h create mode 100644 third-party/lua-5.1.5/src/lopcodes.c create mode 100644 third-party/lua-5.1.5/src/lopcodes.h create mode 100644 third-party/lua-5.1.5/src/loslib.c create mode 100644 third-party/lua-5.1.5/src/lparser.c create mode 100644 third-party/lua-5.1.5/src/lparser.h create mode 100644 third-party/lua-5.1.5/src/lstate.c create mode 100644 third-party/lua-5.1.5/src/lstate.h create mode 100644 third-party/lua-5.1.5/src/lstring.c create mode 100644 third-party/lua-5.1.5/src/lstring.h create mode 100644 third-party/lua-5.1.5/src/lstrlib.c create mode 100644 third-party/lua-5.1.5/src/ltable.c create mode 100644 third-party/lua-5.1.5/src/ltable.h create mode 100644 third-party/lua-5.1.5/src/ltablib.c create mode 100644 third-party/lua-5.1.5/src/ltm.c create mode 100644 third-party/lua-5.1.5/src/ltm.h create mode 100644 third-party/lua-5.1.5/src/lua.c create mode 100644 third-party/lua-5.1.5/src/lua.h create mode 100644 third-party/lua-5.1.5/src/luac.c create mode 100644 third-party/lua-5.1.5/src/luaconf.h create mode 100644 third-party/lua-5.1.5/src/lualib.h create mode 100644 third-party/lua-5.1.5/src/lundump.c create mode 100644 third-party/lua-5.1.5/src/lundump.h create mode 100644 third-party/lua-5.1.5/src/lvm.c create mode 100644 third-party/lua-5.1.5/src/lvm.h create mode 100644 third-party/lua-5.1.5/src/lzio.c create mode 100644 third-party/lua-5.1.5/src/lzio.h create mode 100644 third-party/lua-5.1.5/src/print.c create mode 100644 third-party/lua-5.1.5/test/README create mode 100644 third-party/lua-5.1.5/test/bisect.lua create mode 100644 third-party/lua-5.1.5/test/cf.lua create mode 100644 third-party/lua-5.1.5/test/echo.lua create mode 100644 third-party/lua-5.1.5/test/env.lua create mode 100644 third-party/lua-5.1.5/test/factorial.lua create mode 100644 third-party/lua-5.1.5/test/fib.lua create mode 100644 third-party/lua-5.1.5/test/fibfor.lua create mode 100644 third-party/lua-5.1.5/test/globals.lua create mode 100644 third-party/lua-5.1.5/test/hello.lua create mode 100644 third-party/lua-5.1.5/test/life.lua create mode 100644 third-party/lua-5.1.5/test/luac.lua create mode 100644 third-party/lua-5.1.5/test/printf.lua create mode 100644 third-party/lua-5.1.5/test/readonly.lua create mode 100644 third-party/lua-5.1.5/test/sieve.lua create mode 100644 third-party/lua-5.1.5/test/sort.lua create mode 100644 third-party/lua-5.1.5/test/table.lua create mode 100644 third-party/lua-5.1.5/test/trace-calls.lua create mode 100644 third-party/lua-5.1.5/test/trace-globals.lua create mode 100644 third-party/lua-5.1.5/test/xd.lua create mode 100644 third-party/lua-5.1.5/toluapp-simple/CMakeLists.txt create mode 100644 third-party/lua-5.1.5/toluapp-simple/COPYRIGHT create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua++.h create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua_event.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua_event.h create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua_is.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua_map.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua_push.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/tolua_to.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/toluabind.c create mode 100644 third-party/lua-5.1.5/toluapp-simple/toluabind.h create mode 100644 third-party/lua-5.1.5/toluapp-simple/toluabind_default.h create mode 100644 third-party/lua-5.1.5/toluapp/.travis.yml create mode 100644 third-party/lua-5.1.5/toluapp/CMakeLists.txt create mode 100644 third-party/lua-5.1.5/toluapp/INSTALL create mode 100644 third-party/lua-5.1.5/toluapp/README create mode 100755 third-party/lua-5.1.5/toluapp/README-5.1 create mode 100644 third-party/lua-5.1.5/toluapp/cmake/FindLua.cmake create mode 100644 third-party/lua-5.1.5/toluapp/cmake/dist.cmake create mode 100644 third-party/lua-5.1.5/toluapp/cmake/lua.cmake create mode 100644 third-party/lua-5.1.5/toluapp/dist.info create mode 100644 third-party/lua-5.1.5/toluapp/doc/index.html create mode 100644 third-party/lua-5.1.5/toluapp/doc/tolua++.html create mode 100644 third-party/lua-5.1.5/toluapp/doc/toluapp.gif create mode 100644 third-party/lua-5.1.5/toluapp/include/tolua++.h create mode 100644 third-party/lua-5.1.5/toluapp/libtoluapp.def create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/COPYRIGHT create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/bin/tolua.c create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind.c create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind.h create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind_default.h create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/include/tolua++.h create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.c create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.h create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_is.c create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_map.c create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_push.c create mode 100644 third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_to.c create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/SCsub create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/all.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/array.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/basic.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/class.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/clean.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/code.lua create mode 100755 third-party/lua-5.1.5/toluapp/src/bin/lua/compat-5.1.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/compat.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/container.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/custom.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/declaration.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/define.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/doit.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/enumerate.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/feature.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/function.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/module.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/namespace.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/operator.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/package.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/template_class.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/typedef.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/variable.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/lua/verbatim.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/tolua.c create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/tolua_scons.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/toluabind.c create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/toluabind.h create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.c create mode 100644 third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.h create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/SCsub create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/tolua_event.c create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/tolua_event.h create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/tolua_is.c create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/tolua_map.c create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/tolua_push.c create mode 100644 third-party/lua-5.1.5/toluapp/src/lib/tolua_to.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/SCsub create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tarray.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tarray.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tarray.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tarray.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tarraybind.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tclass.cpp create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tclass.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tclass.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tclass.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tconstant.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tconstant.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tconstant.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tdirective.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tdirective.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tdirectivebind.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tdirectivelua.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tdirectivepkg.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tfunction.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tfunction.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tfunction.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tmodule.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tmodule.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tmodule.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tmodule.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tmodulebind.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tnamespace.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tnamespace.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tnamespace.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tvariable.c create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tvariable.h create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tvariable.lua create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tvariable.pkg create mode 100644 third-party/lua-5.1.5/toluapp/src/tests/tvariablebind.c create mode 100755 third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.sln create mode 100755 third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.vcproj diff --git a/third-party/lua-5.1.5/CMakeLists.txt b/third-party/lua-5.1.5/CMakeLists.txt new file mode 100644 index 000000000..fca34eee3 --- /dev/null +++ b/third-party/lua-5.1.5/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) + +project(lua) + +add_subdirectory(src/) +add_subdirectory(toluapp-simple/) + diff --git a/third-party/lua-5.1.5/COPYRIGHT b/third-party/lua-5.1.5/COPYRIGHT new file mode 100644 index 000000000..a86026803 --- /dev/null +++ b/third-party/lua-5.1.5/COPYRIGHT @@ -0,0 +1,34 @@ +Lua License +----------- + +Lua is licensed under the terms of the MIT license reproduced below. +This means that Lua is free software and can be used for both academic +and commercial purposes at absolutely no cost. + +For details and rationale, see http://www.lua.org/license.html . + +=============================================================================== + +Copyright (C) 1994-2012 Lua.org, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=============================================================================== + +(end of COPYRIGHT) diff --git a/third-party/lua-5.1.5/HISTORY b/third-party/lua-5.1.5/HISTORY new file mode 100644 index 000000000..ce0c95bc6 --- /dev/null +++ b/third-party/lua-5.1.5/HISTORY @@ -0,0 +1,183 @@ +HISTORY for Lua 5.1 + +* Changes from version 5.0 to 5.1 + ------------------------------- + Language: + + new module system. + + new semantics for control variables of fors. + + new semantics for setn/getn. + + new syntax/semantics for varargs. + + new long strings and comments. + + new `mod' operator (`%') + + new length operator #t + + metatables for all types + API: + + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer. + + user supplies memory allocator (lua_open becomes lua_newstate). + + luaopen_* functions must be called through Lua. + Implementation: + + new configuration scheme via luaconf.h. + + incremental garbage collection. + + better handling of end-of-line in the lexer. + + fully reentrant parser (new Lua function `load') + + better support for 64-bit machines. + + native loadlib support for Mac OS X. + + standard distribution in only one library (lualib.a merged into lua.a) + +* Changes from version 4.0 to 5.0 + ------------------------------- + Language: + + lexical scoping. + + Lua coroutines. + + standard libraries now packaged in tables. + + tags replaced by metatables and tag methods replaced by metamethods, + stored in metatables. + + proper tail calls. + + each function can have its own global table, which can be shared. + + new __newindex metamethod, called when we insert a new key into a table. + + new block comments: --[[ ... ]]. + + new generic for. + + new weak tables. + + new boolean type. + + new syntax "local function". + + (f()) returns the first value returned by f. + + {f()} fills a table with all values returned by f. + + \n ignored in [[\n . + + fixed and-or priorities. + + more general syntax for function definition (e.g. function a.x.y:f()...end). + + more general syntax for function calls (e.g. (print or write)(9)). + + new functions (time/date, tmpfile, unpack, require, load*, etc.). + API: + + chunks are loaded by using lua_load; new luaL_loadfile and luaL_loadbuffer. + + introduced lightweight userdata, a simple "void*" without a metatable. + + new error handling protocol: the core no longer prints error messages; + all errors are reported to the caller on the stack. + + new lua_atpanic for host cleanup. + + new, signal-safe, hook scheme. + Implementation: + + new license: MIT. + + new, faster, register-based virtual machine. + + support for external multithreading and coroutines. + + new and consistent error message format. + + the core no longer needs "stdio.h" for anything (except for a single + use of sprintf to convert numbers to strings). + + lua.c now runs the environment variable LUA_INIT, if present. It can + be "@filename", to run a file, or the chunk itself. + + support for user extensions in lua.c. + sample implementation given for command line editing. + + new dynamic loading library, active by default on several platforms. + + safe garbage-collector metamethods. + + precompiled bytecodes checked for integrity (secure binary dostring). + + strings are fully aligned. + + position capture in string.find. + + read('*l') can read lines with embedded zeros. + +* Changes from version 3.2 to 4.0 + ------------------------------- + Language: + + new "break" and "for" statements (both numerical and for tables). + + uniform treatment of globals: globals are now stored in a Lua table. + + improved error messages. + + no more '$debug': full speed *and* full debug information. + + new read form: read(N) for next N bytes. + + general read patterns now deprecated. + (still available with -DCOMPAT_READPATTERNS.) + + all return values are passed as arguments for the last function + (old semantics still available with -DLUA_COMPAT_ARGRET) + + garbage collection tag methods for tables now deprecated. + + there is now only one tag method for order. + API: + + New API: fully re-entrant, simpler, and more efficient. + + New debug API. + Implementation: + + faster than ever: cleaner virtual machine and new hashing algorithm. + + non-recursive garbage-collector algorithm. + + reduced memory usage for programs with many strings. + + improved treatment for memory allocation errors. + + improved support for 16-bit machines (we hope). + + code now compiles unmodified as both ANSI C and C++. + + numbers in bases other than 10 are converted using strtoul. + + new -f option in Lua to support #! scripts. + + luac can now combine text and binaries. + +* Changes from version 3.1 to 3.2 + ------------------------------- + + redirected all output in Lua's core to _ERRORMESSAGE and _ALERT. + + increased limit on the number of constants and globals per function + (from 2^16 to 2^24). + + debugging info (lua_debug and hooks) moved into lua_state and new API + functions provided to get and set this info. + + new debug lib gives full debugging access within Lua. + + new table functions "foreachi", "sort", "tinsert", "tremove", "getn". + + new io functions "flush", "seek". + +* Changes from version 3.0 to 3.1 + ------------------------------- + + NEW FEATURE: anonymous functions with closures (via "upvalues"). + + new syntax: + - local variables in chunks. + - better scope control with DO block END. + - constructors can now be also written: { record-part; list-part }. + - more general syntax for function calls and lvalues, e.g.: + f(x).y=1 + o:f(x,y):g(z) + f"string" is sugar for f("string") + + strings may now contain arbitrary binary data (e.g., embedded zeros). + + major code re-organization and clean-up; reduced module interdependecies. + + no arbitrary limits on the total number of constants and globals. + + support for multiple global contexts. + + better syntax error messages. + + new traversal functions "foreach" and "foreachvar". + + the default for numbers is now double. + changing it to use floats or longs is easy. + + complete debug information stored in pre-compiled chunks. + + sample interpreter now prompts user when run interactively, and also + handles control-C interruptions gracefully. + +* Changes from version 2.5 to 3.0 + ------------------------------- + + NEW CONCEPT: "tag methods". + Tag methods replace fallbacks as the meta-mechanism for extending the + semantics of Lua. Whereas fallbacks had a global nature, tag methods + work on objects having the same tag (e.g., groups of tables). + Existing code that uses fallbacks should work without change. + + new, general syntax for constructors {[exp] = exp, ... }. + + support for handling variable number of arguments in functions (varargs). + + support for conditional compilation ($if ... $else ... $end). + + cleaner semantics in API simplifies host code. + + better support for writing libraries (auxlib.h). + + better type checking and error messages in the standard library. + + luac can now also undump. + +* Changes from version 2.4 to 2.5 + ------------------------------- + + io and string libraries are now based on pattern matching; + the old libraries are still available for compatibility + + dofile and dostring can now return values (via return statement) + + better support for 16- and 64-bit machines + + expanded documentation, with more examples + +* Changes from version 2.2 to 2.4 + ------------------------------- + + external compiler creates portable binary files that can be loaded faster + + interface for debugging and profiling + + new "getglobal" fallback + + new functions for handling references to Lua objects + + new functions in standard lib + + only one copy of each string is stored + + expanded documentation, with more examples + +* Changes from version 2.1 to 2.2 + ------------------------------- + + functions now may be declared with any "lvalue" as a name + + garbage collection of functions + + support for pipes + +* Changes from version 1.1 to 2.1 + ------------------------------- + + object-oriented support + + fallbacks + + simplified syntax for tables + + many internal improvements + +(end of HISTORY) diff --git a/third-party/lua-5.1.5/INSTALL b/third-party/lua-5.1.5/INSTALL new file mode 100644 index 000000000..17eb8aee8 --- /dev/null +++ b/third-party/lua-5.1.5/INSTALL @@ -0,0 +1,99 @@ +INSTALL for Lua 5.1 + +* Building Lua + ------------ + Lua is built in the src directory, but the build process can be + controlled from the top-level Makefile. + + Building Lua on Unix systems should be very easy. First do "make" and + see if your platform is listed. If so, just do "make xxx", where xxx + is your platform name. The platforms currently supported are: + aix ansi bsd freebsd generic linux macosx mingw posix solaris + + If your platform is not listed, try the closest one or posix, generic, + ansi, in this order. + + See below for customization instructions and for instructions on how + to build with other Windows compilers. + + If you want to check that Lua has been built correctly, do "make test" + after building Lua. Also, have a look at the example programs in test. + +* Installing Lua + -------------- + Once you have built Lua, you may want to install it in an official + place in your system. In this case, do "make install". The official + place and the way to install files are defined in Makefile. You must + have the right permissions to install files. + + If you want to build and install Lua in one step, do "make xxx install", + where xxx is your platform name. + + If you want to install Lua locally, then do "make local". This will + create directories bin, include, lib, man, and install Lua there as + follows: + + bin: lua luac + include: lua.h luaconf.h lualib.h lauxlib.h lua.hpp + lib: liblua.a + man/man1: lua.1 luac.1 + + These are the only directories you need for development. + + There are man pages for lua and luac, in both nroff and html, and a + reference manual in html in doc, some sample code in test, and some + useful stuff in etc. You don't need these directories for development. + + If you want to install Lua locally, but in some other directory, do + "make install INSTALL_TOP=xxx", where xxx is your chosen directory. + + See below for instructions for Windows and other systems. + +* Customization + ------------- + Three things can be customized by editing a file: + - Where and how to install Lua -- edit Makefile. + - How to build Lua -- edit src/Makefile. + - Lua features -- edit src/luaconf.h. + + You don't actually need to edit the Makefiles because you may set the + relevant variables when invoking make. + + On the other hand, if you need to select some Lua features, you'll need + to edit src/luaconf.h. The edited file will be the one installed, and + it will be used by any Lua clients that you build, to ensure consistency. + + We strongly recommend that you enable dynamic loading. This is done + automatically for all platforms listed above that have this feature + (and also Windows). See src/luaconf.h and also src/Makefile. + +* Building Lua on Windows and other systems + ----------------------------------------- + If you're not using the usual Unix tools, then the instructions for + building Lua depend on the compiler you use. You'll need to create + projects (or whatever your compiler uses) for building the library, + the interpreter, and the compiler, as follows: + + library: lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c + lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c + ltable.c ltm.c lundump.c lvm.c lzio.c + lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c + ltablib.c lstrlib.c loadlib.c linit.c + + interpreter: library, lua.c + + compiler: library, luac.c print.c + + If you use Visual Studio .NET, you can use etc/luavs.bat in its + "Command Prompt". + + If all you want is to build the Lua interpreter, you may put all .c files + in a single project, except for luac.c and print.c. Or just use etc/all.c. + + To use Lua as a library in your own programs, you'll need to know how to + create and use libraries with your compiler. + + As mentioned above, you may edit luaconf.h to select some features before + building Lua. + +(end of INSTALL) diff --git a/third-party/lua-5.1.5/Makefile b/third-party/lua-5.1.5/Makefile new file mode 100644 index 000000000..209a13244 --- /dev/null +++ b/third-party/lua-5.1.5/Makefile @@ -0,0 +1,128 @@ +# makefile for installing Lua +# see INSTALL for installation instructions +# see src/Makefile and src/luaconf.h for further customization + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= none + +# Where to install. The installation starts in the src and doc directories, +# so take care if INSTALL_TOP is not an absolute path. +INSTALL_TOP= /usr/local +INSTALL_BIN= $(INSTALL_TOP)/bin +INSTALL_INC= $(INSTALL_TOP)/include +INSTALL_LIB= $(INSTALL_TOP)/lib +INSTALL_MAN= $(INSTALL_TOP)/man/man1 +# +# You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with +# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc). +INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V +INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V + +# How to install. If your install program does not support "-p", then you +# may have to run ranlib on the installed liblua.a (do "make ranlib"). +INSTALL= install -p +INSTALL_EXEC= $(INSTALL) -m 0755 +INSTALL_DATA= $(INSTALL) -m 0644 +# +# If you don't have install you can use cp instead. +# INSTALL= cp -p +# INSTALL_EXEC= $(INSTALL) +# INSTALL_DATA= $(INSTALL) + +# Utilities. +MKDIR= mkdir -p +RANLIB= ranlib + +# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + +# Convenience platforms targets. +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + +# What to install. +TO_BIN= lua luac +TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp +TO_LIB= liblua.a +TO_MAN= lua.1 luac.1 + +# Lua version and release. +V= 5.1 +R= 5.1.5 + +all: $(PLAT) + +$(PLATS) clean: + cd src && $(MAKE) $@ + +test: dummy + src/lua test/hello.lua + +install: dummy + cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) + cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) + cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) + cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) + cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) + +ranlib: + cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB) + +local: + $(MAKE) install INSTALL_TOP=.. + +none: + @echo "Please do" + @echo " make PLATFORM" + @echo "where PLATFORM is one of these:" + @echo " $(PLATS)" + @echo "See INSTALL for complete instructions." + +# make may get confused with test/ and INSTALL in a case-insensitive OS +dummy: + +# echo config parameters +echo: + @echo "" + @echo "These are the parameters currently set in src/Makefile to build Lua $R:" + @echo "" + @cd src && $(MAKE) -s echo + @echo "" + @echo "These are the parameters currently set in Makefile to install Lua $R:" + @echo "" + @echo "PLAT = $(PLAT)" + @echo "INSTALL_TOP = $(INSTALL_TOP)" + @echo "INSTALL_BIN = $(INSTALL_BIN)" + @echo "INSTALL_INC = $(INSTALL_INC)" + @echo "INSTALL_LIB = $(INSTALL_LIB)" + @echo "INSTALL_MAN = $(INSTALL_MAN)" + @echo "INSTALL_LMOD = $(INSTALL_LMOD)" + @echo "INSTALL_CMOD = $(INSTALL_CMOD)" + @echo "INSTALL_EXEC = $(INSTALL_EXEC)" + @echo "INSTALL_DATA = $(INSTALL_DATA)" + @echo "" + @echo "See also src/luaconf.h ." + @echo "" + +# echo private config parameters +pecho: + @echo "V = $(V)" + @echo "R = $(R)" + @echo "TO_BIN = $(TO_BIN)" + @echo "TO_INC = $(TO_INC)" + @echo "TO_LIB = $(TO_LIB)" + @echo "TO_MAN = $(TO_MAN)" + +# echo config parameters as Lua code +# uncomment the last sed expression if you want nil instead of empty strings +lecho: + @echo "-- installation parameters for Lua $R" + @echo "VERSION = '$V'" + @echo "RELEASE = '$R'" + @$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/' + @echo "-- EOF" + +# list targets that do not create files (but not all makes understand .PHONY) +.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho + +# (end of Makefile) diff --git a/third-party/lua-5.1.5/README b/third-party/lua-5.1.5/README new file mode 100644 index 000000000..11b4dff70 --- /dev/null +++ b/third-party/lua-5.1.5/README @@ -0,0 +1,37 @@ +README for Lua 5.1 + +See INSTALL for installation instructions. +See HISTORY for a summary of changes since the last released version. + +* What is Lua? + ------------ + Lua is a powerful, light-weight programming language designed for extending + applications. Lua is also frequently used as a general-purpose, stand-alone + language. Lua is free software. + + For complete information, visit Lua's web site at http://www.lua.org/ . + For an executive summary, see http://www.lua.org/about.html . + + Lua has been used in many different projects around the world. + For a short list, see http://www.lua.org/uses.html . + +* Availability + ------------ + Lua is freely available for both academic and commercial purposes. + See COPYRIGHT and http://www.lua.org/license.html for details. + Lua can be downloaded at http://www.lua.org/download.html . + +* Installation + ------------ + Lua is implemented in pure ANSI C, and compiles unmodified in all known + platforms that have an ANSI C compiler. In most Unix-like platforms, simply + do "make" with a suitable target. See INSTALL for detailed instructions. + +* Origin + ------ + Lua is developed at Lua.org, a laboratory of the Department of Computer + Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro + in Brazil). + For more information about the authors, see http://www.lua.org/authors.html . + +(end of README) diff --git a/third-party/lua-5.1.5/doc/contents.html b/third-party/lua-5.1.5/doc/contents.html new file mode 100644 index 000000000..3d83da98a --- /dev/null +++ b/third-party/lua-5.1.5/doc/contents.html @@ -0,0 +1,497 @@ + + + +Lua 5.1 Reference Manual - contents + + + + + + + +
+

+ +Lua 5.1 Reference Manual +

+ +

+The reference manual is the official definition of the Lua language. +For a complete introduction to Lua programming, see the book +Programming in Lua. + +

+This manual is also available as a book: +

+ + + +Lua 5.1 Reference Manual +
by R. Ierusalimschy, L. H. de Figueiredo, W. Celes +
Lua.org, August 2006 +
ISBN 85-903798-3-3 +
+
+ +

+Buy a copy +of this book and +help to support +the Lua project. + +

+start +· +contents +· +index +· +other versions +


+ +Copyright © 2006–2012 Lua.org, PUC-Rio. +Freely available under the terms of the +Lua license. + + +

Contents

+ + +

Index

+ + + + + + + +
+

Lua functions

+_G
+_VERSION
+

+ +assert
+collectgarbage
+dofile
+error
+getfenv
+getmetatable
+ipairs
+load
+loadfile
+loadstring
+module
+next
+pairs
+pcall
+print
+rawequal
+rawget
+rawset
+require
+select
+setfenv
+setmetatable
+tonumber
+tostring
+type
+unpack
+xpcall
+

+ +coroutine.create
+coroutine.resume
+coroutine.running
+coroutine.status
+coroutine.wrap
+coroutine.yield
+

+ +debug.debug
+debug.getfenv
+debug.gethook
+debug.getinfo
+debug.getlocal
+debug.getmetatable
+debug.getregistry
+debug.getupvalue
+debug.setfenv
+debug.sethook
+debug.setlocal
+debug.setmetatable
+debug.setupvalue
+debug.traceback
+ +

+

 

+file:close
+file:flush
+file:lines
+file:read
+file:seek
+file:setvbuf
+file:write
+

+ +io.close
+io.flush
+io.input
+io.lines
+io.open
+io.output
+io.popen
+io.read
+io.stderr
+io.stdin
+io.stdout
+io.tmpfile
+io.type
+io.write
+

+ +math.abs
+math.acos
+math.asin
+math.atan
+math.atan2
+math.ceil
+math.cos
+math.cosh
+math.deg
+math.exp
+math.floor
+math.fmod
+math.frexp
+math.huge
+math.ldexp
+math.log
+math.log10
+math.max
+math.min
+math.modf
+math.pi
+math.pow
+math.rad
+math.random
+math.randomseed
+math.sin
+math.sinh
+math.sqrt
+math.tan
+math.tanh
+

+ +os.clock
+os.date
+os.difftime
+os.execute
+os.exit
+os.getenv
+os.remove
+os.rename
+os.setlocale
+os.time
+os.tmpname
+

+ +package.cpath
+package.loaded
+package.loaders
+package.loadlib
+package.path
+package.preload
+package.seeall
+

+ +string.byte
+string.char
+string.dump
+string.find
+string.format
+string.gmatch
+string.gsub
+string.len
+string.lower
+string.match
+string.rep
+string.reverse
+string.sub
+string.upper
+

+ +table.concat
+table.insert
+table.maxn
+table.remove
+table.sort
+ +

+

C API

+lua_Alloc
+lua_CFunction
+lua_Debug
+lua_Hook
+lua_Integer
+lua_Number
+lua_Reader
+lua_State
+lua_Writer
+

+ +lua_atpanic
+lua_call
+lua_checkstack
+lua_close
+lua_concat
+lua_cpcall
+lua_createtable
+lua_dump
+lua_equal
+lua_error
+lua_gc
+lua_getallocf
+lua_getfenv
+lua_getfield
+lua_getglobal
+lua_gethook
+lua_gethookcount
+lua_gethookmask
+lua_getinfo
+lua_getlocal
+lua_getmetatable
+lua_getstack
+lua_gettable
+lua_gettop
+lua_getupvalue
+lua_insert
+lua_isboolean
+lua_iscfunction
+lua_isfunction
+lua_islightuserdata
+lua_isnil
+lua_isnone
+lua_isnoneornil
+lua_isnumber
+lua_isstring
+lua_istable
+lua_isthread
+lua_isuserdata
+lua_lessthan
+lua_load
+lua_newstate
+lua_newtable
+lua_newthread
+lua_newuserdata
+lua_next
+lua_objlen
+lua_pcall
+lua_pop
+lua_pushboolean
+lua_pushcclosure
+lua_pushcfunction
+lua_pushfstring
+lua_pushinteger
+lua_pushlightuserdata
+lua_pushliteral
+lua_pushlstring
+lua_pushnil
+lua_pushnumber
+lua_pushstring
+lua_pushthread
+lua_pushvalue
+lua_pushvfstring
+lua_rawequal
+lua_rawget
+lua_rawgeti
+lua_rawset
+lua_rawseti
+lua_register
+lua_remove
+lua_replace
+lua_resume
+lua_setallocf
+lua_setfenv
+lua_setfield
+lua_setglobal
+lua_sethook
+lua_setlocal
+lua_setmetatable
+lua_settable
+lua_settop
+lua_setupvalue
+lua_status
+lua_toboolean
+lua_tocfunction
+lua_tointeger
+lua_tolstring
+lua_tonumber
+lua_topointer
+lua_tostring
+lua_tothread
+lua_touserdata
+lua_type
+lua_typename
+lua_upvalueindex
+lua_xmove
+lua_yield
+ +

+

auxiliary library

+luaL_Buffer
+luaL_Reg
+

+ +luaL_addchar
+luaL_addlstring
+luaL_addsize
+luaL_addstring
+luaL_addvalue
+luaL_argcheck
+luaL_argerror
+luaL_buffinit
+luaL_callmeta
+luaL_checkany
+luaL_checkint
+luaL_checkinteger
+luaL_checklong
+luaL_checklstring
+luaL_checknumber
+luaL_checkoption
+luaL_checkstack
+luaL_checkstring
+luaL_checktype
+luaL_checkudata
+luaL_dofile
+luaL_dostring
+luaL_error
+luaL_getmetafield
+luaL_getmetatable
+luaL_gsub
+luaL_loadbuffer
+luaL_loadfile
+luaL_loadstring
+luaL_newmetatable
+luaL_newstate
+luaL_openlibs
+luaL_optint
+luaL_optinteger
+luaL_optlong
+luaL_optlstring
+luaL_optnumber
+luaL_optstring
+luaL_prepbuffer
+luaL_pushresult
+luaL_ref
+luaL_register
+luaL_typename
+luaL_typerror
+luaL_unref
+luaL_where
+ +

+

+ +


+ +Last update: +Mon Feb 13 18:53:32 BRST 2012 + + + + + diff --git a/third-party/lua-5.1.5/doc/cover.png b/third-party/lua-5.1.5/doc/cover.png new file mode 100644 index 0000000000000000000000000000000000000000..2dbb198123f03a7250bfa57c8253739962d69afb GIT binary patch literal 3305 zcmVNc=P)V>IGcGYOVIUw=dB=aTYv^*htKxL4xjCf9X{I|EBQ!hu?+M>5oT>TE}0ye97P9R7S8qXycMFZ&6rBQl2xq6d5z1RT?1tMWggH(oGfxZ3MRwMW* zhWcm<0o+gGDNJLnwySJIYqTbnA(cT&JjHAh%b?&;aM%-PVunbF`4oU{acLCOU~~ed z=Xys9YZpo#i8bMPc#43D)u4sMGKqI^_da6LW&~0K*cO4+ z_PRNFEtj+pK65RYy#Eh+iK_)|A>ml%LRW(G?uWEPuP@)V__gB&q{E^1Drx0`;n)|1&{JZ#-e7eMcd1S~0(ChdB8 zS0!Ap-8R#X^0X5R7@pQ0wmH~jKhYj`l%C2tznfmz5?4vXD&s9-{r%L{8o|B1n{hn> zX-7F)1C|g{Fjw^QO3xSEM8WF{nF8))ijLB@AziK0j<-dAU&NHQAw-4j8oelO%2Dg_ z37hiyuBd>qbbcrr0xb~*rLW9q2cyBcq8kgCW9j_Jd}=!9R2g|I=9{KHXtr2}hFHKH zPZ!2Bg|$47mFu;Duqg$YQfQ4vD~-}9t!+atHYg~SbM=?ElxgB&vnLeLny@Jo1@}ra zw-%pO_5&GLRc)GAp8w;^w0pr+)}6{$xN2*=h1(z&s0B5@zOQ2Cj<++EgPm6D*KdLp^Jc$%i(A&wq1mn{*M;Pu$%2I-|s;8_q`68Jd zLJ$dITeas|8_h>+9GB??ksz(jj7@SsNq-j_f;Mf@l8W*L-v0vui)W9N64OhM7aV?n zo{!IxNC9-U@zPPgc8EYtsn)ggZ<}BOc#01{#gH6*gjm!cMXYMFiJ5! z$8SI7^a#mxl?1n2Bwr+veIkV`2fdd@*by0Naq>o!4A;Y!nrTV7gj#l-OAs* zvT_zQj8DKsyvuDrVn7=m8 z&;O0T{VN_DroW5Nu5jxvQZU%ZlLv@3)#xH@icfQd{R930nH<0P?=qQ<5s3ufc;l~s z^rLTdbhJn*9LK$Q@z$Gf{__VPoYQ~*AN<{S=xOJbXHXg;Sjdpd5Nq1FU!ZP(bkV*K z5BX<_uE(!VaN&B59T#f)0@ixmc3_}Kkful!<-+AYa=bk&rr9RA^GG2#cH|o2Jo3*;M^C0Z#I`l`S@(jjq^e|^t7&J*rAXei$y>%zrcxe zzKVokW{ylvDyoN%5F8rxOC(&6ljrfOA4aT&iHZA4RiB-iOg@n)*W;YNOgdZoU&C~Q zYvZ-d>YDjzn4Be*DQQDPBE@KZ$^kz7@cjMzsnv(*TI*A%M(*BC03b*t8J+ZR_jR(6 zttGy#T|b&jH^^6g-e(O?=xBjqSdb8D)Kd$tjjQa}6Izo*l=AOHBZzP@%TWj?-Z2yYmt`$ryp=SGWT>kg8zlLgEEs(4iVm;4Q>56I~!I5E_!W;Hjvwox?Uqoq) z@&EyI&Dg6UFbzN8)tb&2Y&=@c`Y|NW9`Pe8A!)AFN8A)Nk)Urp8ZM1e+_>zsWuw3Gwz#h*<|ZTYWyBV&rD^+OOrPXFnaE_T4H3gMI7NJvIPCeSU~lbZRURtjFJ3 zOtR_n9@p1NEV@-WX*<9pdwg@TE&lANPj7A1!>6YW%k<@shB-1^pOm#iGtfhChrf42 zsVsLR)XYafILOn7Dzbrs7oH##T<@vPK}ueH!cSN`F26lfqvKnrf9<;5xmTWYf?eG_ zeX!9}PBYlclLvflOw3@&T9Q?4=KSZAi+(6#NWSqr9j%R{qzT%*cARj9+M7Z={YZ`Z zkUIHTCXWs=UG`IipsSVd{5f`@zJAseNAl`14({FT2Xbx{9&lM)RVZ}_{lVes;w@a^N+fz49V zNXZM2^W9f`Rcp=JFX(8gt1f+0`B4G4?=d#PKzC_k7?Qz0y4x6=B$uz#sndjmeCtJC zJ5DgL%uYf!d*Z&jYQX0B2)f!R6lrVmT}CPC?c~T_GI?g_YxBM}hQWc|eD9k)^C*Fe z?D1?8AQoMD2D71Pn?G+{G@(R_)@FY(T|5yQo#5loxID%}wj5$qei{Hm5DK!lj~Ach z@X#`~XwB_uPF>*Z&(R#ISEvU#FA)Nz`TQED$+JgFvs?%)ll=n>_cNbnY=Y|(+?{11 zL&3o^iG=8GW2ldzK00F6PjxbRUOh&1<7lUfP!D<@?6{2FWT>x{XIvqi2CY#FPoWf2 zVo0P!tZu2v=D9u1zJZdTwyAHS9=M*uGC8uBNRUK|GgrvwmU;C8q`)+=EkZW7g=ru~ z6RQpkqkiq>Ru+?vAkXbSVK7dSLn?*gy_ zjjN{!SUh^+iEFRr=;K9At8qQ=c=~M}HT#)sT^Fg(`nT>?C{y%_^R>wBb&6$ nh%8`n`v3p{2XskIMF-Xh6%#iZwFs;u00000NkvXXu0mjfd@Wp4 literal 0 HcmV?d00001 diff --git a/third-party/lua-5.1.5/doc/logo.gif b/third-party/lua-5.1.5/doc/logo.gif new file mode 100644 index 0000000000000000000000000000000000000000..2f5e4ac2e742fbb7675e739879211553758aea9c GIT binary patch literal 4232 zcmeH``9G8i;K!fm@ywWE@XWZzZ5SF?A>^uN#>^O6HI%DVL*tw8h1>$H%uPC0$QQ=txe!o}PX)Ev+jn>*nFZ-TC=<^76WcLZL(=DJm)| zEiIKwrInSHXU?3duCC_u@5try#>U2`rlw1mF15F}U%!66tE;QKyIUmcDJ<+QF77*W zFJd#&)VAl)kJ6K zi<>tmZ{3>g>+2gB7#JQNe(>OdLh;A=`1q42PbMZNCMPF*dXxhLZw3aYhlZwyhu@Bj z%#4n{d-Q1b$&i4QMce4L#8^!oMdw{PDnm4D66&3*dxX=-YIX6DQL_g`jbzkd4k zZDCoLf=%jL&vIeE zO=XcZ9fxt`f}-DQ^%H*PHMUs(JN%UWkI|Y8h9#6~I$Cw@{RqzO4&P-x;jHCPJ6Ks2 zoU%foi)nXd_sdkiuJa@@5J4RrreKfWSnz5>eMa5yTP=)16uu)TIdx~Fhho))6jZl) z($*i>QrIX4u}u3>m{WSn_ehkUGQ& zs})aUlTH1Cj1g3ZE3=MPXsSniEwJ{e6C3N#HjD=B4`8rWIsz!a7ecYpec?WuH+y?Wsm18^$cS4WmHhH3_=r zh*ILlm*X1dB^E5($KVl&zT524%l}vpHg%;Y+LezV_&TAJCmH`idhuj-n$4FZ)UE|jXLayXa-&O3Q z?Iyo!x*$5hD_HfFnDfGYj-RD|eIb7I?%>Y_kf%}Nbd`BXb4l1(Pc+}zoUR|9%_!7f zum2T;wbx&pohtI+&@~wm3nH9xLbOYkg*`phY~TK5iC#3tZNXo9s`cahx+8j2)rh5C zQgZh6D7Ekgib|hpdhxYf{r!PTJc z!vsYG@{hA}l5kL)g)0N_)(nC<*L0qdUi*3fD5<0sn58>zklX@6Tyv3*X^}m=Cqc40 zQ6GfjG@kd1mFIm`qaubWunm_?P>WUZ`9|f_z%gGHi{n|uu(N8!L=aw5(qAcDj$-QK zu;D#j6e42OXTQD>)i zlvM$LX`$n9EEjxM$_QDF&a z7cme_rat}aXmiN&7`6Q98}dh4Z@8L_uAb#nK&GQiZOOUnA9kAEVb-csuN1AWL=sXt z{z9GCN%%l0N9QvJM;tl1nf?rrhT{*sE%4WqR?{0~aIrfCcCPxf4eh_*jjQ=`$p53Y z@_|Rsx2i}|3dNFetMQQ5y8agTK-E0D&7;@3-LUxfvZ7 z7~!p@&mFe^oca2^F|CBt+4Ly?^ViUVSAhAH>JH1GN{^TQb3QnM*x0ZiZgDyNI@_c3 z@{}(WH4*e3T~}n_^0}da4ElIxAf9B!IaL7z9X0Icvj@cIkE*~W--17&WN`Ea5)Gn> z#gpfRb#44;jVTOS{FuaZgd(-ZD848=fQzgST2MxR>wSLc1P=2HDvByz$B$IsNCC6L zCM?nK*OHj6JA9gz4|b<~2%RqelN^1Y)jIqnRs!mDKV^BQTfo@hOtz7*Ug}Ee^cbsj zNNlumRgAmt`1$b5MO;&X#5-EP<}AaY;52ihIpem&MTea$?3!DrwbYa?V`NjEfWF3z zUq5JY8Ch;L{kx&J<1K&Fe_Vn;8gk{%c;n?nA2(%(f%DCRHko3uT~VI7RE^JWEqaCq z)i|%nfj(*4|V*XhY3W%M# z*yn6SN4eUOHFxAD7B&9E_PO`G5bqgs^@J{9bk>&;PlUAiqo`j3rjQDgD!}mqLUtb` zCB}ZD@m@s#pf7bV4jreOC*JVfHZ|hyHkX!rauVdd_I9FL45d{gWH!DNYu;i(|8wVx z!)eLY6YXxZ2{Coae0xuTnxo1ACb5wtED?VJAz&@114$Ao6uG9YSy*!K;m5_mj=0^j zw%?b%AOs}ql@$TGC-!^^*_#RT5+y_kTzQG9?LPPZNAtt6cJ%d2$q(I)ws21*?xF%p zN+NeGnWRQ<5w70Rc(bl|S0Xr&5@WrmdurS|IgPB|EyuZO#=tf!35)G!HJ`E1jh^lH zTBu~rL#DhQO*XAWtBt}JHH$lc>3%r0yD|maW_(W=B_J+y164F>O4dO|@&@N3Z3p=B zmVl{|^Z&#atHY|9n&la)SBo}=3AFIF=_~LDJk6MTlA73CXtX+4bnn+c!}N}IPa5pp zwyqbqIkN|I3j_3vD6$zlu{Ps(N-J|*qzEt<$5Soh;s^AuKv_ z-Tz+O1_~6*9CJh4r}`}mbUtjbf#fX58RIIkP6&@*y9kI|5fK*_eZ%jv3U$5*x<>D_ za2M(TV8?XY+9xy>0En#Te<6X4$0&dbyd(go$~eq4u(u)EA2msyF<5ssLZ zDP|I}=~Bi_q)whWv=Ri~L1TYaNrR;5cMB@s78HF1{w&r(6GJ;_2@bD?#1p&P4n_?n0#9Vx~$qjMX=Lk?*!@aKo8m&$iPO7S{g3sFUwr`*<53(68xx7?z`2xf# zGSicy_zI(PJ|%qc2VxT+6bOE--a{k&aq7$<<= zFt)C<@|TPs`+eycPGoGL1Wn9|Ed&a2JyAmjnkm3DQBECX&`bt~odH9cUPq4M{#$-q?G3!)qO-it*&YHw+j-O* zYy78V*`4Q=kQ@^Yz*b6Tal4(Me7BGeS^;phWAW8+L^5A(=D)t?k!rLIwVAKtq=f7h z&^n&VX1-T$ScvN~639QLZ^d@niMaS{C-Q)8oHHBhwD*r~-1Ze#Q)GFOFptW32a-uF z;M@ux%i%a25NwIgXt*=GHX$3~aZfwovGL!}sf?j9TsVo^cn(%&a<--0mIXYqGe>c PWz_J}_#7St0k8iB@FZjZ literal 0 HcmV?d00001 diff --git a/third-party/lua-5.1.5/doc/lua.1 b/third-party/lua-5.1.5/doc/lua.1 new file mode 100644 index 000000000..24809cc6c --- /dev/null +++ b/third-party/lua-5.1.5/doc/lua.1 @@ -0,0 +1,163 @@ +.\" $Id: lua.man,v 1.11 2006/01/06 16:03:34 lhf Exp $ +.TH LUA 1 "$Date: 2006/01/06 16:03:34 $" +.SH NAME +lua \- Lua interpreter +.SH SYNOPSIS +.B lua +[ +.I options +] +[ +.I script +[ +.I args +] +] +.SH DESCRIPTION +.B lua +is the stand-alone Lua interpreter. +It loads and executes Lua programs, +either in textual source form or +in precompiled binary form. +(Precompiled binaries are output by +.BR luac , +the Lua compiler.) +.B lua +can be used as a batch interpreter and also interactively. +.LP +The given +.I options +(see below) +are executed and then +the Lua program in file +.I script +is loaded and executed. +The given +.I args +are available to +.I script +as strings in a global table named +.BR arg . +If these arguments contain spaces or other characters special to the shell, +then they should be quoted +(but note that the quotes will be removed by the shell). +The arguments in +.B arg +start at 0, +which contains the string +.RI ' script '. +The index of the last argument is stored in +.BR arg.n . +The arguments given in the command line before +.IR script , +including the name of the interpreter, +are available in negative indices in +.BR arg . +.LP +At the very start, +before even handling the command line, +.B lua +executes the contents of the environment variable +.BR LUA_INIT , +if it is defined. +If the value of +.B LUA_INIT +is of the form +.RI '@ filename ', +then +.I filename +is executed. +Otherwise, the string is assumed to be a Lua statement and is executed. +.LP +Options start with +.B '\-' +and are described below. +You can use +.B "'\--'" +to signal the end of options. +.LP +If no arguments are given, +then +.B "\-v \-i" +is assumed when the standard input is a terminal; +otherwise, +.B "\-" +is assumed. +.LP +In interactive mode, +.B lua +prompts the user, +reads lines from the standard input, +and executes them as they are read. +If a line does not contain a complete statement, +then a secondary prompt is displayed and +lines are read until a complete statement is formed or +a syntax error is found. +So, one way to interrupt the reading of an incomplete statement is +to force a syntax error: +adding a +.B ';' +in the middle of a statement is a sure way of forcing a syntax error +(except inside multiline strings and comments; these must be closed explicitly). +If a line starts with +.BR '=' , +then +.B lua +displays the values of all the expressions in the remainder of the +line. The expressions must be separated by commas. +The primary prompt is the value of the global variable +.BR _PROMPT , +if this value is a string; +otherwise, the default prompt is used. +Similarly, the secondary prompt is the value of the global variable +.BR _PROMPT2 . +So, +to change the prompts, +set the corresponding variable to a string of your choice. +You can do that after calling the interpreter +or on the command line +(but in this case you have to be careful with quotes +if the prompt string contains a space; otherwise you may confuse the shell.) +The default prompts are "> " and ">> ". +.SH OPTIONS +.TP +.B \- +load and execute the standard input as a file, +that is, +not interactively, +even when the standard input is a terminal. +.TP +.BI \-e " stat" +execute statement +.IR stat . +You need to quote +.I stat +if it contains spaces, quotes, +or other characters special to the shell. +.TP +.B \-i +enter interactive mode after +.I script +is executed. +.TP +.BI \-l " name" +call +.BI require(' name ') +before executing +.IR script . +Typically used to load libraries. +.TP +.B \-v +show version information. +.SH "SEE ALSO" +.BR luac (1) +.br +http://www.lua.org/ +.SH DIAGNOSTICS +Error messages should be self explanatory. +.SH AUTHORS +R. Ierusalimschy, +L. H. de Figueiredo, +and +W. Celes +.\" EOF diff --git a/third-party/lua-5.1.5/doc/lua.css b/third-party/lua-5.1.5/doc/lua.css new file mode 100644 index 000000000..7fafbb1bb --- /dev/null +++ b/third-party/lua-5.1.5/doc/lua.css @@ -0,0 +1,83 @@ +body { + color: #000000 ; + background-color: #FFFFFF ; + font-family: Helvetica, Arial, sans-serif ; + text-align: justify ; + margin-right: 30px ; + margin-left: 30px ; +} + +h1, h2, h3, h4 { + font-family: Verdana, Geneva, sans-serif ; + font-weight: normal ; + font-style: italic ; +} + +h2 { + padding-top: 0.4em ; + padding-bottom: 0.4em ; + padding-left: 30px ; + padding-right: 30px ; + margin-left: -30px ; + background-color: #E0E0FF ; +} + +h3 { + padding-left: 0.5em ; + border-left: solid #E0E0FF 1em ; +} + +table h3 { + padding-left: 0px ; + border-left: none ; +} + +a:link { + color: #000080 ; + background-color: inherit ; + text-decoration: none ; +} + +a:visited { + background-color: inherit ; + text-decoration: none ; +} + +a:link:hover, a:visited:hover { + color: #000080 ; + background-color: #E0E0FF ; +} + +a:link:active, a:visited:active { + color: #FF0000 ; +} + +hr { + border: 0 ; + height: 1px ; + color: #a0a0a0 ; + background-color: #a0a0a0 ; +} + +:target { + background-color: #F8F8F8 ; + padding: 8px ; + border: solid #a0a0a0 2px ; +} + +.footer { + color: gray ; + font-size: small ; +} + +input[type=text] { + border: solid #a0a0a0 2px ; + border-radius: 2em ; + -moz-border-radius: 2em ; + background-image: url('images/search.png') ; + background-repeat: no-repeat; + background-position: 4px center ; + padding-left: 20px ; + height: 2em ; +} + diff --git a/third-party/lua-5.1.5/doc/lua.html b/third-party/lua-5.1.5/doc/lua.html new file mode 100644 index 000000000..1d435ab02 --- /dev/null +++ b/third-party/lua-5.1.5/doc/lua.html @@ -0,0 +1,172 @@ + + + +LUA man page + + + + + +

NAME

+lua - Lua interpreter +

SYNOPSIS

+lua +[ +options +] +[ +script +[ +args +] +] +

DESCRIPTION

+lua +is the stand-alone Lua interpreter. +It loads and executes Lua programs, +either in textual source form or +in precompiled binary form. +(Precompiled binaries are output by +luac, +the Lua compiler.) +lua +can be used as a batch interpreter and also interactively. +

+The given +options +(see below) +are executed and then +the Lua program in file +script +is loaded and executed. +The given +args +are available to +script +as strings in a global table named +arg. +If these arguments contain spaces or other characters special to the shell, +then they should be quoted +(but note that the quotes will be removed by the shell). +The arguments in +arg +start at 0, +which contains the string +'script'. +The index of the last argument is stored in +arg.n. +The arguments given in the command line before +script, +including the name of the interpreter, +are available in negative indices in +arg. +

+At the very start, +before even handling the command line, +lua +executes the contents of the environment variable +LUA_INIT, +if it is defined. +If the value of +LUA_INIT +is of the form +'@filename', +then +filename +is executed. +Otherwise, the string is assumed to be a Lua statement and is executed. +

+Options start with +'-' +and are described below. +You can use +'--' +to signal the end of options. +

+If no arguments are given, +then +"-v -i" +is assumed when the standard input is a terminal; +otherwise, +"-" +is assumed. +

+In interactive mode, +lua +prompts the user, +reads lines from the standard input, +and executes them as they are read. +If a line does not contain a complete statement, +then a secondary prompt is displayed and +lines are read until a complete statement is formed or +a syntax error is found. +So, one way to interrupt the reading of an incomplete statement is +to force a syntax error: +adding a +';' +in the middle of a statement is a sure way of forcing a syntax error +(except inside multiline strings and comments; these must be closed explicitly). +If a line starts with +'=', +then +lua +displays the values of all the expressions in the remainder of the +line. The expressions must be separated by commas. +The primary prompt is the value of the global variable +_PROMPT, +if this value is a string; +otherwise, the default prompt is used. +Similarly, the secondary prompt is the value of the global variable +_PROMPT2. +So, +to change the prompts, +set the corresponding variable to a string of your choice. +You can do that after calling the interpreter +or on the command line +(but in this case you have to be careful with quotes +if the prompt string contains a space; otherwise you may confuse the shell.) +The default prompts are "> " and ">> ". +

OPTIONS

+

+- +load and execute the standard input as a file, +that is, +not interactively, +even when the standard input is a terminal. +

+-e stat +execute statement +stat. +You need to quote +stat +if it contains spaces, quotes, +or other characters special to the shell. +

+-i +enter interactive mode after +script +is executed. +

+-l name +call +require('name') +before executing +script. +Typically used to load libraries. +

+-v +show version information. +

SEE ALSO

+luac(1) +
+http://www.lua.org/ +

DIAGNOSTICS

+Error messages should be self explanatory. +

AUTHORS

+R. Ierusalimschy, +L. H. de Figueiredo, +and +W. Celes + + + diff --git a/third-party/lua-5.1.5/doc/luac.1 b/third-party/lua-5.1.5/doc/luac.1 new file mode 100644 index 000000000..d8146782d --- /dev/null +++ b/third-party/lua-5.1.5/doc/luac.1 @@ -0,0 +1,136 @@ +.\" $Id: luac.man,v 1.28 2006/01/06 16:03:34 lhf Exp $ +.TH LUAC 1 "$Date: 2006/01/06 16:03:34 $" +.SH NAME +luac \- Lua compiler +.SH SYNOPSIS +.B luac +[ +.I options +] [ +.I filenames +] +.SH DESCRIPTION +.B luac +is the Lua compiler. +It translates programs written in the Lua programming language +into binary files that can be later loaded and executed. +.LP +The main advantages of precompiling chunks are: +faster loading, +protecting source code from accidental user changes, +and +off-line syntax checking. +.LP +Pre-compiling does not imply faster execution +because in Lua chunks are always compiled into bytecodes before being executed. +.B luac +simply allows those bytecodes to be saved in a file for later execution. +.LP +Pre-compiled chunks are not necessarily smaller than the corresponding source. +The main goal in pre-compiling is faster loading. +.LP +The binary files created by +.B luac +are portable only among architectures with the same word size and byte order. +.LP +.B luac +produces a single output file containing the bytecodes +for all source files given. +By default, +the output file is named +.BR luac.out , +but you can change this with the +.B \-o +option. +.LP +In the command line, +you can mix +text files containing Lua source and +binary files containing precompiled chunks. +This is useful to combine several precompiled chunks, +even from different (but compatible) platforms, +into a single precompiled chunk. +.LP +You can use +.B "'\-'" +to indicate the standard input as a source file +and +.B "'\--'" +to signal the end of options +(that is, +all remaining arguments will be treated as files even if they start with +.BR "'\-'" ). +.LP +The internal format of the binary files produced by +.B luac +is likely to change when a new version of Lua is released. +So, +save the source files of all Lua programs that you precompile. +.LP +.SH OPTIONS +Options must be separate. +.TP +.B \-l +produce a listing of the compiled bytecode for Lua's virtual machine. +Listing bytecodes is useful to learn about Lua's virtual machine. +If no files are given, then +.B luac +loads +.B luac.out +and lists its contents. +.TP +.BI \-o " file" +output to +.IR file , +instead of the default +.BR luac.out . +(You can use +.B "'\-'" +for standard output, +but not on platforms that open standard output in text mode.) +The output file may be a source file because +all files are loaded before the output file is written. +Be careful not to overwrite precious files. +.TP +.B \-p +load files but do not generate any output file. +Used mainly for syntax checking and for testing precompiled chunks: +corrupted files will probably generate errors when loaded. +Lua always performs a thorough integrity test on precompiled chunks. +Bytecode that passes this test is completely safe, +in the sense that it will not break the interpreter. +However, +there is no guarantee that such code does anything sensible. +(None can be given, because the halting problem is unsolvable.) +If no files are given, then +.B luac +loads +.B luac.out +and tests its contents. +No messages are displayed if the file passes the integrity test. +.TP +.B \-s +strip debug information before writing the output file. +This saves some space in very large chunks, +but if errors occur when running a stripped chunk, +then the error messages may not contain the full information they usually do. +For instance, +line numbers and names of local variables are lost. +.TP +.B \-v +show version information. +.SH FILES +.TP 15 +.B luac.out +default output file +.SH "SEE ALSO" +.BR lua (1) +.br +http://www.lua.org/ +.SH DIAGNOSTICS +Error messages should be self explanatory. +.SH AUTHORS +L. H. de Figueiredo, +R. Ierusalimschy and +W. Celes +.\" EOF diff --git a/third-party/lua-5.1.5/doc/luac.html b/third-party/lua-5.1.5/doc/luac.html new file mode 100644 index 000000000..179ffe828 --- /dev/null +++ b/third-party/lua-5.1.5/doc/luac.html @@ -0,0 +1,145 @@ + + + +LUAC man page + + + + + +

NAME

+luac - Lua compiler +

SYNOPSIS

+luac +[ +options +] [ +filenames +] +

DESCRIPTION

+luac +is the Lua compiler. +It translates programs written in the Lua programming language +into binary files that can be later loaded and executed. +

+The main advantages of precompiling chunks are: +faster loading, +protecting source code from accidental user changes, +and +off-line syntax checking. +

+Precompiling does not imply faster execution +because in Lua chunks are always compiled into bytecodes before being executed. +luac +simply allows those bytecodes to be saved in a file for later execution. +

+Precompiled chunks are not necessarily smaller than the corresponding source. +The main goal in precompiling is faster loading. +

+The binary files created by +luac +are portable only among architectures with the same word size and byte order. +

+luac +produces a single output file containing the bytecodes +for all source files given. +By default, +the output file is named +luac.out, +but you can change this with the +-o +option. +

+In the command line, +you can mix +text files containing Lua source and +binary files containing precompiled chunks. +This is useful because several precompiled chunks, +even from different (but compatible) platforms, +can be combined into a single precompiled chunk. +

+You can use +'-' +to indicate the standard input as a source file +and +'--' +to signal the end of options +(that is, +all remaining arguments will be treated as files even if they start with +'-'). +

+The internal format of the binary files produced by +luac +is likely to change when a new version of Lua is released. +So, +save the source files of all Lua programs that you precompile. +

+

OPTIONS

+Options must be separate. +

+-l +produce a listing of the compiled bytecode for Lua's virtual machine. +Listing bytecodes is useful to learn about Lua's virtual machine. +If no files are given, then +luac +loads +luac.out +and lists its contents. +

+-o file +output to +file, +instead of the default +luac.out. +(You can use +'-' +for standard output, +but not on platforms that open standard output in text mode.) +The output file may be a source file because +all files are loaded before the output file is written. +Be careful not to overwrite precious files. +

+-p +load files but do not generate any output file. +Used mainly for syntax checking and for testing precompiled chunks: +corrupted files will probably generate errors when loaded. +Lua always performs a thorough integrity test on precompiled chunks. +Bytecode that passes this test is completely safe, +in the sense that it will not break the interpreter. +However, +there is no guarantee that such code does anything sensible. +(None can be given, because the halting problem is unsolvable.) +If no files are given, then +luac +loads +luac.out +and tests its contents. +No messages are displayed if the file passes the integrity test. +

+-s +strip debug information before writing the output file. +This saves some space in very large chunks, +but if errors occur when running a stripped chunk, +then the error messages may not contain the full information they usually do. +For instance, +line numbers and names of local variables are lost. +

+-v +show version information. +

FILES

+

+luac.out +default output file +

SEE ALSO

+lua(1) +
+http://www.lua.org/ +

DIAGNOSTICS

+Error messages should be self explanatory. +

AUTHORS

+L. H. de Figueiredo, +R. Ierusalimschy and +W. Celes + + + diff --git a/third-party/lua-5.1.5/doc/manual.css b/third-party/lua-5.1.5/doc/manual.css new file mode 100644 index 000000000..b49b36293 --- /dev/null +++ b/third-party/lua-5.1.5/doc/manual.css @@ -0,0 +1,24 @@ +h3 code { + font-family: inherit ; + font-size: inherit ; +} + +pre, code { + font-size: 12pt ; +} + +span.apii { + float: right ; + font-family: inherit ; + font-style: normal ; + font-size: small ; + color: gray ; +} + +p+h1, ul+h1 { + padding-top: 0.4em ; + padding-bottom: 0.4em ; + padding-left: 30px ; + margin-left: -30px ; + background-color: #E0E0FF ; +} diff --git a/third-party/lua-5.1.5/doc/manual.html b/third-party/lua-5.1.5/doc/manual.html new file mode 100644 index 000000000..4e41683d0 --- /dev/null +++ b/third-party/lua-5.1.5/doc/manual.html @@ -0,0 +1,8804 @@ + + + + +Lua 5.1 Reference Manual + + + + + + + +
+

+ +Lua 5.1 Reference Manual +

+ +by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes +

+ +Copyright © 2006–2012 Lua.org, PUC-Rio. +Freely available under the terms of the +Lua license. + +


+

+ +contents +· +index +· +other versions + + +

+ + + + + + +

1 - Introduction

+ +

+Lua is an extension programming language designed to support +general procedural programming with data description +facilities. +It also offers good support for object-oriented programming, +functional programming, and data-driven programming. +Lua is intended to be used as a powerful, light-weight +scripting language for any program that needs one. +Lua is implemented as a library, written in clean C +(that is, in the common subset of ANSI C and C++). + + +

+Being an extension language, Lua has no notion of a "main" program: +it only works embedded in a host client, +called the embedding program or simply the host. +This host program can invoke functions to execute a piece of Lua code, +can write and read Lua variables, +and can register C functions to be called by Lua code. +Through the use of C functions, Lua can be augmented to cope with +a wide range of different domains, +thus creating customized programming languages sharing a syntactical framework. +The Lua distribution includes a sample host program called lua, +which uses the Lua library to offer a complete, stand-alone Lua interpreter. + + +

+Lua is free software, +and is provided as usual with no guarantees, +as stated in its license. +The implementation described in this manual is available +at Lua's official web site, www.lua.org. + + +

+Like any other reference manual, +this document is dry in places. +For a discussion of the decisions behind the design of Lua, +see the technical papers available at Lua's web site. +For a detailed introduction to programming in Lua, +see Roberto's book, Programming in Lua (Second Edition). + + + +

2 - The Language

+ +

+This section describes the lexis, the syntax, and the semantics of Lua. +In other words, +this section describes +which tokens are valid, +how they can be combined, +and what their combinations mean. + + +

+The language constructs will be explained using the usual extended BNF notation, +in which +{a} means 0 or more a's, and +[a] means an optional a. +Non-terminals are shown like non-terminal, +keywords are shown like kword, +and other terminal symbols are shown like `=´. +The complete syntax of Lua can be found in §8 +at the end of this manual. + + + +

2.1 - Lexical Conventions

+ +

+Names +(also called identifiers) +in Lua can be any string of letters, +digits, and underscores, +not beginning with a digit. +This coincides with the definition of names in most languages. +(The definition of letter depends on the current locale: +any character considered alphabetic by the current locale +can be used in an identifier.) +Identifiers are used to name variables and table fields. + + +

+The following keywords are reserved +and cannot be used as names: + + +

+     and       break     do        else      elseif
+     end       false     for       function  if
+     in        local     nil       not       or
+     repeat    return    then      true      until     while
+
+ +

+Lua is a case-sensitive language: +and is a reserved word, but And and AND +are two different, valid names. +As a convention, names starting with an underscore followed by +uppercase letters (such as _VERSION) +are reserved for internal global variables used by Lua. + + +

+The following strings denote other tokens: + +

+     +     -     *     /     %     ^     #
+     ==    ~=    <=    >=    <     >     =
+     (     )     {     }     [     ]
+     ;     :     ,     .     ..    ...
+
+ +

+Literal strings +can be delimited by matching single or double quotes, +and can contain the following C-like escape sequences: +'\a' (bell), +'\b' (backspace), +'\f' (form feed), +'\n' (newline), +'\r' (carriage return), +'\t' (horizontal tab), +'\v' (vertical tab), +'\\' (backslash), +'\"' (quotation mark [double quote]), +and '\'' (apostrophe [single quote]). +Moreover, a backslash followed by a real newline +results in a newline in the string. +A character in a string can also be specified by its numerical value +using the escape sequence \ddd, +where ddd is a sequence of up to three decimal digits. +(Note that if a numerical escape is to be followed by a digit, +it must be expressed using exactly three digits.) +Strings in Lua can contain any 8-bit value, including embedded zeros, +which can be specified as '\0'. + + +

+Literal strings can also be defined using a long format +enclosed by long brackets. +We define an opening long bracket of level n as an opening +square bracket followed by n equal signs followed by another +opening square bracket. +So, an opening long bracket of level 0 is written as [[, +an opening long bracket of level 1 is written as [=[, +and so on. +A closing long bracket is defined similarly; +for instance, a closing long bracket of level 4 is written as ]====]. +A long string starts with an opening long bracket of any level and +ends at the first closing long bracket of the same level. +Literals in this bracketed form can run for several lines, +do not interpret any escape sequences, +and ignore long brackets of any other level. +They can contain anything except a closing bracket of the proper level. + + +

+For convenience, +when the opening long bracket is immediately followed by a newline, +the newline is not included in the string. +As an example, in a system using ASCII +(in which 'a' is coded as 97, +newline is coded as 10, and '1' is coded as 49), +the five literal strings below denote the same string: + +

+     a = 'alo\n123"'
+     a = "alo\n123\""
+     a = '\97lo\10\04923"'
+     a = [[alo
+     123"]]
+     a = [==[
+     alo
+     123"]==]
+
+ +

+A numerical constant can be written with an optional decimal part +and an optional decimal exponent. +Lua also accepts integer hexadecimal constants, +by prefixing them with 0x. +Examples of valid numerical constants are + +

+     3   3.0   3.1416   314.16e-2   0.31416E1   0xff   0x56
+
+ +

+A comment starts with a double hyphen (--) +anywhere outside a string. +If the text immediately after -- is not an opening long bracket, +the comment is a short comment, +which runs until the end of the line. +Otherwise, it is a long comment, +which runs until the corresponding closing long bracket. +Long comments are frequently used to disable code temporarily. + + + + + +

2.2 - Values and Types

+ +

+Lua is a dynamically typed language. +This means that +variables do not have types; only values do. +There are no type definitions in the language. +All values carry their own type. + + +

+All values in Lua are first-class values. +This means that all values can be stored in variables, +passed as arguments to other functions, and returned as results. + + +

+There are eight basic types in Lua: +nil, boolean, number, +string, function, userdata, +thread, and table. +Nil is the type of the value nil, +whose main property is to be different from any other value; +it usually represents the absence of a useful value. +Boolean is the type of the values false and true. +Both nil and false make a condition false; +any other value makes it true. +Number represents real (double-precision floating-point) numbers. +(It is easy to build Lua interpreters that use other +internal representations for numbers, +such as single-precision float or long integers; +see file luaconf.h.) +String represents arrays of characters. + +Lua is 8-bit clean: +strings can contain any 8-bit character, +including embedded zeros ('\0') (see §2.1). + + +

+Lua can call (and manipulate) functions written in Lua and +functions written in C +(see §2.5.8). + + +

+The type userdata is provided to allow arbitrary C data to +be stored in Lua variables. +This type corresponds to a block of raw memory +and has no pre-defined operations in Lua, +except assignment and identity test. +However, by using metatables, +the programmer can define operations for userdata values +(see §2.8). +Userdata values cannot be created or modified in Lua, +only through the C API. +This guarantees the integrity of data owned by the host program. + + +

+The type thread represents independent threads of execution +and it is used to implement coroutines (see §2.11). +Do not confuse Lua threads with operating-system threads. +Lua supports coroutines on all systems, +even those that do not support threads. + + +

+The type table implements associative arrays, +that is, arrays that can be indexed not only with numbers, +but with any value (except nil). +Tables can be heterogeneous; +that is, they can contain values of all types (except nil). +Tables are the sole data structuring mechanism in Lua; +they can be used to represent ordinary arrays, +symbol tables, sets, records, graphs, trees, etc. +To represent records, Lua uses the field name as an index. +The language supports this representation by +providing a.name as syntactic sugar for a["name"]. +There are several convenient ways to create tables in Lua +(see §2.5.7). + + +

+Like indices, +the value of a table field can be of any type (except nil). +In particular, +because functions are first-class values, +table fields can contain functions. +Thus tables can also carry methods (see §2.5.9). + + +

+Tables, functions, threads, and (full) userdata values are objects: +variables do not actually contain these values, +only references to them. +Assignment, parameter passing, and function returns +always manipulate references to such values; +these operations do not imply any kind of copy. + + +

+The library function type returns a string describing the type +of a given value. + + + +

2.2.1 - Coercion

+ +

+Lua provides automatic conversion between +string and number values at run time. +Any arithmetic operation applied to a string tries to convert +this string to a number, following the usual conversion rules. +Conversely, whenever a number is used where a string is expected, +the number is converted to a string, in a reasonable format. +For complete control over how numbers are converted to strings, +use the format function from the string library +(see string.format). + + + + + + + +

2.3 - Variables

+ +

+Variables are places that store values. + +There are three kinds of variables in Lua: +global variables, local variables, and table fields. + + +

+A single name can denote a global variable or a local variable +(or a function's formal parameter, +which is a particular kind of local variable): + +

+	var ::= Name
+

+Name denotes identifiers, as defined in §2.1. + + +

+Any variable is assumed to be global unless explicitly declared +as a local (see §2.4.7). +Local variables are lexically scoped: +local variables can be freely accessed by functions +defined inside their scope (see §2.6). + + +

+Before the first assignment to a variable, its value is nil. + + +

+Square brackets are used to index a table: + +

+	var ::= prefixexp `[´ exp `]´
+

+The meaning of accesses to global variables +and table fields can be changed via metatables. +An access to an indexed variable t[i] is equivalent to +a call gettable_event(t,i). +(See §2.8 for a complete description of the +gettable_event function. +This function is not defined or callable in Lua. +We use it here only for explanatory purposes.) + + +

+The syntax var.Name is just syntactic sugar for +var["Name"]: + +

+	var ::= prefixexp `.´ Name
+
+ +

+All global variables live as fields in ordinary Lua tables, +called environment tables or simply +environments (see §2.9). +Each function has its own reference to an environment, +so that all global variables in this function +will refer to this environment table. +When a function is created, +it inherits the environment from the function that created it. +To get the environment table of a Lua function, +you call getfenv. +To replace it, +you call setfenv. +(You can only manipulate the environment of C functions +through the debug library; (see §5.9).) + + +

+An access to a global variable x +is equivalent to _env.x, +which in turn is equivalent to + +

+     gettable_event(_env, "x")
+

+where _env is the environment of the running function. +(See §2.8 for a complete description of the +gettable_event function. +This function is not defined or callable in Lua. +Similarly, the _env variable is not defined in Lua. +We use them here only for explanatory purposes.) + + + + + +

2.4 - Statements

+ +

+Lua supports an almost conventional set of statements, +similar to those in Pascal or C. +This set includes +assignments, control structures, function calls, +and variable declarations. + + + +

2.4.1 - Chunks

+ +

+The unit of execution of Lua is called a chunk. +A chunk is simply a sequence of statements, +which are executed sequentially. +Each statement can be optionally followed by a semicolon: + +

+	chunk ::= {stat [`;´]}
+

+There are no empty statements and thus ';;' is not legal. + + +

+Lua handles a chunk as the body of an anonymous function +with a variable number of arguments +(see §2.5.9). +As such, chunks can define local variables, +receive arguments, and return values. + + +

+A chunk can be stored in a file or in a string inside the host program. +To execute a chunk, +Lua first pre-compiles the chunk into instructions for a virtual machine, +and then it executes the compiled code +with an interpreter for the virtual machine. + + +

+Chunks can also be pre-compiled into binary form; +see program luac for details. +Programs in source and compiled forms are interchangeable; +Lua automatically detects the file type and acts accordingly. + + + + + + +

2.4.2 - Blocks

+A block is a list of statements; +syntactically, a block is the same as a chunk: + +

+	block ::= chunk
+
+ +

+A block can be explicitly delimited to produce a single statement: + +

+	stat ::= do block end
+

+Explicit blocks are useful +to control the scope of variable declarations. +Explicit blocks are also sometimes used to +add a return or break statement in the middle +of another block (see §2.4.4). + + + + + +

2.4.3 - Assignment

+ +

+Lua allows multiple assignments. +Therefore, the syntax for assignment +defines a list of variables on the left side +and a list of expressions on the right side. +The elements in both lists are separated by commas: + +

+	stat ::= varlist `=´ explist
+	varlist ::= var {`,´ var}
+	explist ::= exp {`,´ exp}
+

+Expressions are discussed in §2.5. + + +

+Before the assignment, +the list of values is adjusted to the length of +the list of variables. +If there are more values than needed, +the excess values are thrown away. +If there are fewer values than needed, +the list is extended with as many nil's as needed. +If the list of expressions ends with a function call, +then all values returned by that call enter the list of values, +before the adjustment +(except when the call is enclosed in parentheses; see §2.5). + + +

+The assignment statement first evaluates all its expressions +and only then are the assignments performed. +Thus the code + +

+     i = 3
+     i, a[i] = i+1, 20
+

+sets a[3] to 20, without affecting a[4] +because the i in a[i] is evaluated (to 3) +before it is assigned 4. +Similarly, the line + +

+     x, y = y, x
+

+exchanges the values of x and y, +and + +

+     x, y, z = y, z, x
+

+cyclically permutes the values of x, y, and z. + + +

+The meaning of assignments to global variables +and table fields can be changed via metatables. +An assignment to an indexed variable t[i] = val is equivalent to +settable_event(t,i,val). +(See §2.8 for a complete description of the +settable_event function. +This function is not defined or callable in Lua. +We use it here only for explanatory purposes.) + + +

+An assignment to a global variable x = val +is equivalent to the assignment +_env.x = val, +which in turn is equivalent to + +

+     settable_event(_env, "x", val)
+

+where _env is the environment of the running function. +(The _env variable is not defined in Lua. +We use it here only for explanatory purposes.) + + + + + +

2.4.4 - Control Structures

+The control structures +if, while, and repeat have the usual meaning and +familiar syntax: + + + + +

+	stat ::= while exp do block end
+	stat ::= repeat block until exp
+	stat ::= if exp then block {elseif exp then block} [else block] end
+

+Lua also has a for statement, in two flavors (see §2.4.5). + + +

+The condition expression of a +control structure can return any value. +Both false and nil are considered false. +All values different from nil and false are considered true +(in particular, the number 0 and the empty string are also true). + + +

+In the repeatuntil loop, +the inner block does not end at the until keyword, +but only after the condition. +So, the condition can refer to local variables +declared inside the loop block. + + +

+The return statement is used to return values +from a function or a chunk (which is just a function). + +Functions and chunks can return more than one value, +and so the syntax for the return statement is + +

+	stat ::= return [explist]
+
+ +

+The break statement is used to terminate the execution of a +while, repeat, or for loop, +skipping to the next statement after the loop: + + +

+	stat ::= break
+

+A break ends the innermost enclosing loop. + + +

+The return and break +statements can only be written as the last statement of a block. +If it is really necessary to return or break in the +middle of a block, +then an explicit inner block can be used, +as in the idioms +do return end and do break end, +because now return and break are the last statements in +their (inner) blocks. + + + + + +

2.4.5 - For Statement

+ +

+ +The for statement has two forms: +one numeric and one generic. + + +

+The numeric for loop repeats a block of code while a +control variable runs through an arithmetic progression. +It has the following syntax: + +

+	stat ::= for Name `=´ exp `,´ exp [`,´ exp] do block end
+

+The block is repeated for name starting at the value of +the first exp, until it passes the second exp by steps of the +third exp. +More precisely, a for statement like + +

+     for v = e1, e2, e3 do block end
+

+is equivalent to the code: + +

+     do
+       local var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)
+       if not (var and limit and step) then error() end
+       while (step > 0 and var <= limit) or (step <= 0 and var >= limit) do
+         local v = var
+         block
+         var = var + step
+       end
+     end
+

+Note the following: + +

    + +
  • +All three control expressions are evaluated only once, +before the loop starts. +They must all result in numbers. +
  • + +
  • +var, limit, and step are invisible variables. +The names shown here are for explanatory purposes only. +
  • + +
  • +If the third expression (the step) is absent, +then a step of 1 is used. +
  • + +
  • +You can use break to exit a for loop. +
  • + +
  • +The loop variable v is local to the loop; +you cannot use its value after the for ends or is broken. +If you need this value, +assign it to another variable before breaking or exiting the loop. +
  • + +
+ +

+The generic for statement works over functions, +called iterators. +On each iteration, the iterator function is called to produce a new value, +stopping when this new value is nil. +The generic for loop has the following syntax: + +

+	stat ::= for namelist in explist do block end
+	namelist ::= Name {`,´ Name}
+

+A for statement like + +

+     for var_1, ···, var_n in explist do block end
+

+is equivalent to the code: + +

+     do
+       local f, s, var = explist
+       while true do
+         local var_1, ···, var_n = f(s, var)
+         var = var_1
+         if var == nil then break end
+         block
+       end
+     end
+

+Note the following: + +

    + +
  • +explist is evaluated only once. +Its results are an iterator function, +a state, +and an initial value for the first iterator variable. +
  • + +
  • +f, s, and var are invisible variables. +The names are here for explanatory purposes only. +
  • + +
  • +You can use break to exit a for loop. +
  • + +
  • +The loop variables var_i are local to the loop; +you cannot use their values after the for ends. +If you need these values, +then assign them to other variables before breaking or exiting the loop. +
  • + +
+ + + + +

2.4.6 - Function Calls as Statements

+To allow possible side-effects, +function calls can be executed as statements: + +

+	stat ::= functioncall
+

+In this case, all returned values are thrown away. +Function calls are explained in §2.5.8. + + + + + +

2.4.7 - Local Declarations

+Local variables can be declared anywhere inside a block. +The declaration can include an initial assignment: + +

+	stat ::= local namelist [`=´ explist]
+

+If present, an initial assignment has the same semantics +of a multiple assignment (see §2.4.3). +Otherwise, all variables are initialized with nil. + + +

+A chunk is also a block (see §2.4.1), +and so local variables can be declared in a chunk outside any explicit block. +The scope of such local variables extends until the end of the chunk. + + +

+The visibility rules for local variables are explained in §2.6. + + + + + + + +

2.5 - Expressions

+ +

+The basic expressions in Lua are the following: + +

+	exp ::= prefixexp
+	exp ::= nil | false | true
+	exp ::= Number
+	exp ::= String
+	exp ::= function
+	exp ::= tableconstructor
+	exp ::= `...´
+	exp ::= exp binop exp
+	exp ::= unop exp
+	prefixexp ::= var | functioncall | `(´ exp `)´
+
+ +

+Numbers and literal strings are explained in §2.1; +variables are explained in §2.3; +function definitions are explained in §2.5.9; +function calls are explained in §2.5.8; +table constructors are explained in §2.5.7. +Vararg expressions, +denoted by three dots ('...'), can only be used when +directly inside a vararg function; +they are explained in §2.5.9. + + +

+Binary operators comprise arithmetic operators (see §2.5.1), +relational operators (see §2.5.2), logical operators (see §2.5.3), +and the concatenation operator (see §2.5.4). +Unary operators comprise the unary minus (see §2.5.1), +the unary not (see §2.5.3), +and the unary length operator (see §2.5.5). + + +

+Both function calls and vararg expressions can result in multiple values. +If an expression is used as a statement +(only possible for function calls (see §2.4.6)), +then its return list is adjusted to zero elements, +thus discarding all returned values. +If an expression is used as the last (or the only) element +of a list of expressions, +then no adjustment is made +(unless the call is enclosed in parentheses). +In all other contexts, +Lua adjusts the result list to one element, +discarding all values except the first one. + + +

+Here are some examples: + +

+     f()                -- adjusted to 0 results
+     g(f(), x)          -- f() is adjusted to 1 result
+     g(x, f())          -- g gets x plus all results from f()
+     a,b,c = f(), x     -- f() is adjusted to 1 result (c gets nil)
+     a,b = ...          -- a gets the first vararg parameter, b gets
+                        -- the second (both a and b can get nil if there
+                        -- is no corresponding vararg parameter)
+     
+     a,b,c = x, f()     -- f() is adjusted to 2 results
+     a,b,c = f()        -- f() is adjusted to 3 results
+     return f()         -- returns all results from f()
+     return ...         -- returns all received vararg parameters
+     return x,y,f()     -- returns x, y, and all results from f()
+     {f()}              -- creates a list with all results from f()
+     {...}              -- creates a list with all vararg parameters
+     {f(), nil}         -- f() is adjusted to 1 result
+
+ +

+Any expression enclosed in parentheses always results in only one value. +Thus, +(f(x,y,z)) is always a single value, +even if f returns several values. +(The value of (f(x,y,z)) is the first value returned by f +or nil if f does not return any values.) + + + +

2.5.1 - Arithmetic Operators

+Lua supports the usual arithmetic operators: +the binary + (addition), +- (subtraction), * (multiplication), +/ (division), % (modulo), and ^ (exponentiation); +and unary - (negation). +If the operands are numbers, or strings that can be converted to +numbers (see §2.2.1), +then all operations have the usual meaning. +Exponentiation works for any exponent. +For instance, x^(-0.5) computes the inverse of the square root of x. +Modulo is defined as + +

+     a % b == a - math.floor(a/b)*b
+

+That is, it is the remainder of a division that rounds +the quotient towards minus infinity. + + + + + +

2.5.2 - Relational Operators

+The relational operators in Lua are + +

+     ==    ~=    <     >     <=    >=
+

+These operators always result in false or true. + + +

+Equality (==) first compares the type of its operands. +If the types are different, then the result is false. +Otherwise, the values of the operands are compared. +Numbers and strings are compared in the usual way. +Objects (tables, userdata, threads, and functions) +are compared by reference: +two objects are considered equal only if they are the same object. +Every time you create a new object +(a table, userdata, thread, or function), +this new object is different from any previously existing object. + + +

+You can change the way that Lua compares tables and userdata +by using the "eq" metamethod (see §2.8). + + +

+The conversion rules of §2.2.1 +do not apply to equality comparisons. +Thus, "0"==0 evaluates to false, +and t[0] and t["0"] denote different +entries in a table. + + +

+The operator ~= is exactly the negation of equality (==). + + +

+The order operators work as follows. +If both arguments are numbers, then they are compared as such. +Otherwise, if both arguments are strings, +then their values are compared according to the current locale. +Otherwise, Lua tries to call the "lt" or the "le" +metamethod (see §2.8). +A comparison a > b is translated to b < a +and a >= b is translated to b <= a. + + + + + +

2.5.3 - Logical Operators

+The logical operators in Lua are +and, or, and not. +Like the control structures (see §2.4.4), +all logical operators consider both false and nil as false +and anything else as true. + + +

+The negation operator not always returns false or true. +The conjunction operator and returns its first argument +if this value is false or nil; +otherwise, and returns its second argument. +The disjunction operator or returns its first argument +if this value is different from nil and false; +otherwise, or returns its second argument. +Both and and or use short-cut evaluation; +that is, +the second operand is evaluated only if necessary. +Here are some examples: + +

+     10 or 20            --> 10
+     10 or error()       --> 10
+     nil or "a"          --> "a"
+     nil and 10          --> nil
+     false and error()   --> false
+     false and nil       --> false
+     false or nil        --> nil
+     10 and 20           --> 20
+

+(In this manual, +--> indicates the result of the preceding expression.) + + + + + +

2.5.4 - Concatenation

+The string concatenation operator in Lua is +denoted by two dots ('..'). +If both operands are strings or numbers, then they are converted to +strings according to the rules mentioned in §2.2.1. +Otherwise, the "concat" metamethod is called (see §2.8). + + + + + +

2.5.5 - The Length Operator

+ +

+The length operator is denoted by the unary operator #. +The length of a string is its number of bytes +(that is, the usual meaning of string length when each +character is one byte). + + +

+The length of a table t is defined to be any +integer index n +such that t[n] is not nil and t[n+1] is nil; +moreover, if t[1] is nil, n can be zero. +For a regular array, with non-nil values from 1 to a given n, +its length is exactly that n, +the index of its last value. +If the array has "holes" +(that is, nil values between other non-nil values), +then #t can be any of the indices that +directly precedes a nil value +(that is, it may consider any such nil value as the end of +the array). + + + + + +

2.5.6 - Precedence

+Operator precedence in Lua follows the table below, +from lower to higher priority: + +

+     or
+     and
+     <     >     <=    >=    ~=    ==
+     ..
+     +     -
+     *     /     %
+     not   #     - (unary)
+     ^
+

+As usual, +you can use parentheses to change the precedences of an expression. +The concatenation ('..') and exponentiation ('^') +operators are right associative. +All other binary operators are left associative. + + + + + +

2.5.7 - Table Constructors

+Table constructors are expressions that create tables. +Every time a constructor is evaluated, a new table is created. +A constructor can be used to create an empty table +or to create a table and initialize some of its fields. +The general syntax for constructors is + +

+	tableconstructor ::= `{´ [fieldlist] `}´
+	fieldlist ::= field {fieldsep field} [fieldsep]
+	field ::= `[´ exp `]´ `=´ exp | Name `=´ exp | exp
+	fieldsep ::= `,´ | `;´
+
+ +

+Each field of the form [exp1] = exp2 adds to the new table an entry +with key exp1 and value exp2. +A field of the form name = exp is equivalent to +["name"] = exp. +Finally, fields of the form exp are equivalent to +[i] = exp, where i are consecutive numerical integers, +starting with 1. +Fields in the other formats do not affect this counting. +For example, + +

+     a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }
+

+is equivalent to + +

+     do
+       local t = {}
+       t[f(1)] = g
+       t[1] = "x"         -- 1st exp
+       t[2] = "y"         -- 2nd exp
+       t.x = 1            -- t["x"] = 1
+       t[3] = f(x)        -- 3rd exp
+       t[30] = 23
+       t[4] = 45          -- 4th exp
+       a = t
+     end
+
+ +

+If the last field in the list has the form exp +and the expression is a function call or a vararg expression, +then all values returned by this expression enter the list consecutively +(see §2.5.8). +To avoid this, +enclose the function call or the vararg expression +in parentheses (see §2.5). + + +

+The field list can have an optional trailing separator, +as a convenience for machine-generated code. + + + + + +

2.5.8 - Function Calls

+A function call in Lua has the following syntax: + +

+	functioncall ::= prefixexp args
+

+In a function call, +first prefixexp and args are evaluated. +If the value of prefixexp has type function, +then this function is called +with the given arguments. +Otherwise, the prefixexp "call" metamethod is called, +having as first parameter the value of prefixexp, +followed by the original call arguments +(see §2.8). + + +

+The form + +

+	functioncall ::= prefixexp `:´ Name args
+

+can be used to call "methods". +A call v:name(args) +is syntactic sugar for v.name(v,args), +except that v is evaluated only once. + + +

+Arguments have the following syntax: + +

+	args ::= `(´ [explist] `)´
+	args ::= tableconstructor
+	args ::= String
+

+All argument expressions are evaluated before the call. +A call of the form f{fields} is +syntactic sugar for f({fields}); +that is, the argument list is a single new table. +A call of the form f'string' +(or f"string" or f[[string]]) +is syntactic sugar for f('string'); +that is, the argument list is a single literal string. + + +

+As an exception to the free-format syntax of Lua, +you cannot put a line break before the '(' in a function call. +This restriction avoids some ambiguities in the language. +If you write + +

+     a = f
+     (g).x(a)
+

+Lua would see that as a single statement, a = f(g).x(a). +So, if you want two statements, you must add a semi-colon between them. +If you actually want to call f, +you must remove the line break before (g). + + +

+A call of the form return functioncall is called +a tail call. +Lua implements proper tail calls +(or proper tail recursion): +in a tail call, +the called function reuses the stack entry of the calling function. +Therefore, there is no limit on the number of nested tail calls that +a program can execute. +However, a tail call erases any debug information about the +calling function. +Note that a tail call only happens with a particular syntax, +where the return has one single function call as argument; +this syntax makes the calling function return exactly +the returns of the called function. +So, none of the following examples are tail calls: + +

+     return (f(x))        -- results adjusted to 1
+     return 2 * f(x)
+     return x, f(x)       -- additional results
+     f(x); return         -- results discarded
+     return x or f(x)     -- results adjusted to 1
+
+ + + + +

2.5.9 - Function Definitions

+ +

+The syntax for function definition is + +

+	function ::= function funcbody
+	funcbody ::= `(´ [parlist] `)´ block end
+
+ +

+The following syntactic sugar simplifies function definitions: + +

+	stat ::= function funcname funcbody
+	stat ::= local function Name funcbody
+	funcname ::= Name {`.´ Name} [`:´ Name]
+

+The statement + +

+     function f () body end
+

+translates to + +

+     f = function () body end
+

+The statement + +

+     function t.a.b.c.f () body end
+

+translates to + +

+     t.a.b.c.f = function () body end
+

+The statement + +

+     local function f () body end
+

+translates to + +

+     local f; f = function () body end
+

+not to + +

+     local f = function () body end
+

+(This only makes a difference when the body of the function +contains references to f.) + + +

+A function definition is an executable expression, +whose value has type function. +When Lua pre-compiles a chunk, +all its function bodies are pre-compiled too. +Then, whenever Lua executes the function definition, +the function is instantiated (or closed). +This function instance (or closure) +is the final value of the expression. +Different instances of the same function +can refer to different external local variables +and can have different environment tables. + + +

+Parameters act as local variables that are +initialized with the argument values: + +

+	parlist ::= namelist [`,´ `...´] | `...´
+

+When a function is called, +the list of arguments is adjusted to +the length of the list of parameters, +unless the function is a variadic or vararg function, +which is +indicated by three dots ('...') at the end of its parameter list. +A vararg function does not adjust its argument list; +instead, it collects all extra arguments and supplies them +to the function through a vararg expression, +which is also written as three dots. +The value of this expression is a list of all actual extra arguments, +similar to a function with multiple results. +If a vararg expression is used inside another expression +or in the middle of a list of expressions, +then its return list is adjusted to one element. +If the expression is used as the last element of a list of expressions, +then no adjustment is made +(unless that last expression is enclosed in parentheses). + + +

+As an example, consider the following definitions: + +

+     function f(a, b) end
+     function g(a, b, ...) end
+     function r() return 1,2,3 end
+

+Then, we have the following mapping from arguments to parameters and +to the vararg expression: + +

+     CALL            PARAMETERS
+     
+     f(3)             a=3, b=nil
+     f(3, 4)          a=3, b=4
+     f(3, 4, 5)       a=3, b=4
+     f(r(), 10)       a=1, b=10
+     f(r())           a=1, b=2
+     
+     g(3)             a=3, b=nil, ... -->  (nothing)
+     g(3, 4)          a=3, b=4,   ... -->  (nothing)
+     g(3, 4, 5, 8)    a=3, b=4,   ... -->  5  8
+     g(5, r())        a=5, b=1,   ... -->  2  3
+
+ +

+Results are returned using the return statement (see §2.4.4). +If control reaches the end of a function +without encountering a return statement, +then the function returns with no results. + + +

+The colon syntax +is used for defining methods, +that is, functions that have an implicit extra parameter self. +Thus, the statement + +

+     function t.a.b.c:f (params) body end
+

+is syntactic sugar for + +

+     t.a.b.c.f = function (self, params) body end
+
+ + + + + + +

2.6 - Visibility Rules

+ +

+ +Lua is a lexically scoped language. +The scope of variables begins at the first statement after +their declaration and lasts until the end of the innermost block that +includes the declaration. +Consider the following example: + +

+     x = 10                -- global variable
+     do                    -- new block
+       local x = x         -- new 'x', with value 10
+       print(x)            --> 10
+       x = x+1
+       do                  -- another block
+         local x = x+1     -- another 'x'
+         print(x)          --> 12
+       end
+       print(x)            --> 11
+     end
+     print(x)              --> 10  (the global one)
+
+ +

+Notice that, in a declaration like local x = x, +the new x being declared is not in scope yet, +and so the second x refers to the outside variable. + + +

+Because of the lexical scoping rules, +local variables can be freely accessed by functions +defined inside their scope. +A local variable used by an inner function is called +an upvalue, or external local variable, +inside the inner function. + + +

+Notice that each execution of a local statement +defines new local variables. +Consider the following example: + +

+     a = {}
+     local x = 20
+     for i=1,10 do
+       local y = 0
+       a[i] = function () y=y+1; return x+y end
+     end
+

+The loop creates ten closures +(that is, ten instances of the anonymous function). +Each of these closures uses a different y variable, +while all of them share the same x. + + + + + +

2.7 - Error Handling

+ +

+Because Lua is an embedded extension language, +all Lua actions start from C code in the host program +calling a function from the Lua library (see lua_pcall). +Whenever an error occurs during Lua compilation or execution, +control returns to C, +which can take appropriate measures +(such as printing an error message). + + +

+Lua code can explicitly generate an error by calling the +error function. +If you need to catch errors in Lua, +you can use the pcall function. + + + + + +

2.8 - Metatables

+ +

+Every value in Lua can have a metatable. +This metatable is an ordinary Lua table +that defines the behavior of the original value +under certain special operations. +You can change several aspects of the behavior +of operations over a value by setting specific fields in its metatable. +For instance, when a non-numeric value is the operand of an addition, +Lua checks for a function in the field "__add" in its metatable. +If it finds one, +Lua calls this function to perform the addition. + + +

+We call the keys in a metatable events +and the values metamethods. +In the previous example, the event is "add" +and the metamethod is the function that performs the addition. + + +

+You can query the metatable of any value +through the getmetatable function. + + +

+You can replace the metatable of tables +through the setmetatable +function. +You cannot change the metatable of other types from Lua +(except by using the debug library); +you must use the C API for that. + + +

+Tables and full userdata have individual metatables +(although multiple tables and userdata can share their metatables). +Values of all other types share one single metatable per type; +that is, there is one single metatable for all numbers, +one for all strings, etc. + + +

+A metatable controls how an object behaves in arithmetic operations, +order comparisons, concatenation, length operation, and indexing. +A metatable also can define a function to be called when a userdata +is garbage collected. +For each of these operations Lua associates a specific key +called an event. +When Lua performs one of these operations over a value, +it checks whether this value has a metatable with the corresponding event. +If so, the value associated with that key (the metamethod) +controls how Lua will perform the operation. + + +

+Metatables control the operations listed next. +Each operation is identified by its corresponding name. +The key for each operation is a string with its name prefixed by +two underscores, '__'; +for instance, the key for operation "add" is the +string "__add". +The semantics of these operations is better explained by a Lua function +describing how the interpreter executes the operation. + + +

+The code shown here in Lua is only illustrative; +the real behavior is hard coded in the interpreter +and it is much more efficient than this simulation. +All functions used in these descriptions +(rawget, tonumber, etc.) +are described in §5.1. +In particular, to retrieve the metamethod of a given object, +we use the expression + +

+     metatable(obj)[event]
+

+This should be read as + +

+     rawget(getmetatable(obj) or {}, event)
+

+ +That is, the access to a metamethod does not invoke other metamethods, +and the access to objects with no metatables does not fail +(it simply results in nil). + + + +

    + +
  • "add": +the + operation. + + + +

    +The function getbinhandler below defines how Lua chooses a handler +for a binary operation. +First, Lua tries the first operand. +If its type does not define a handler for the operation, +then Lua tries the second operand. + +

    +     function getbinhandler (op1, op2, event)
    +       return metatable(op1)[event] or metatable(op2)[event]
    +     end
    +

    +By using this function, +the behavior of the op1 + op2 is + +

    +     function add_event (op1, op2)
    +       local o1, o2 = tonumber(op1), tonumber(op2)
    +       if o1 and o2 then  -- both operands are numeric?
    +         return o1 + o2   -- '+' here is the primitive 'add'
    +       else  -- at least one of the operands is not numeric
    +         local h = getbinhandler(op1, op2, "__add")
    +         if h then
    +           -- call the handler with both operands
    +           return (h(op1, op2))
    +         else  -- no handler available: default behavior
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
  • "sub": +the - operation. + +Behavior similar to the "add" operation. +
  • + +
  • "mul": +the * operation. + +Behavior similar to the "add" operation. +
  • + +
  • "div": +the / operation. + +Behavior similar to the "add" operation. +
  • + +
  • "mod": +the % operation. + +Behavior similar to the "add" operation, +with the operation +o1 - floor(o1/o2)*o2 as the primitive operation. +
  • + +
  • "pow": +the ^ (exponentiation) operation. + +Behavior similar to the "add" operation, +with the function pow (from the C math library) +as the primitive operation. +
  • + +
  • "unm": +the unary - operation. + + +
    +     function unm_event (op)
    +       local o = tonumber(op)
    +       if o then  -- operand is numeric?
    +         return -o  -- '-' here is the primitive 'unm'
    +       else  -- the operand is not numeric.
    +         -- Try to get a handler from the operand
    +         local h = metatable(op).__unm
    +         if h then
    +           -- call the handler with the operand
    +           return (h(op))
    +         else  -- no handler available: default behavior
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
  • "concat": +the .. (concatenation) operation. + + +
    +     function concat_event (op1, op2)
    +       if (type(op1) == "string" or type(op1) == "number") and
    +          (type(op2) == "string" or type(op2) == "number") then
    +         return op1 .. op2  -- primitive string concatenation
    +       else
    +         local h = getbinhandler(op1, op2, "__concat")
    +         if h then
    +           return (h(op1, op2))
    +         else
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
  • "len": +the # operation. + + +
    +     function len_event (op)
    +       if type(op) == "string" then
    +         return strlen(op)         -- primitive string length
    +       elseif type(op) == "table" then
    +         return #op                -- primitive table length
    +       else
    +         local h = metatable(op).__len
    +         if h then
    +           -- call the handler with the operand
    +           return (h(op))
    +         else  -- no handler available: default behavior
    +           error(···)
    +         end
    +       end
    +     end
    +

    +See §2.5.5 for a description of the length of a table. +

  • + +
  • "eq": +the == operation. + +The function getcomphandler defines how Lua chooses a metamethod +for comparison operators. +A metamethod only is selected when both objects +being compared have the same type +and the same metamethod for the selected operation. + +
    +     function getcomphandler (op1, op2, event)
    +       if type(op1) ~= type(op2) then return nil end
    +       local mm1 = metatable(op1)[event]
    +       local mm2 = metatable(op2)[event]
    +       if mm1 == mm2 then return mm1 else return nil end
    +     end
    +

    +The "eq" event is defined as follows: + +

    +     function eq_event (op1, op2)
    +       if type(op1) ~= type(op2) then  -- different types?
    +         return false   -- different objects
    +       end
    +       if op1 == op2 then   -- primitive equal?
    +         return true   -- objects are equal
    +       end
    +       -- try metamethod
    +       local h = getcomphandler(op1, op2, "__eq")
    +       if h then
    +         return (h(op1, op2))
    +       else
    +         return false
    +       end
    +     end
    +

    +a ~= b is equivalent to not (a == b). +

  • + +
  • "lt": +the < operation. + + +
    +     function lt_event (op1, op2)
    +       if type(op1) == "number" and type(op2) == "number" then
    +         return op1 < op2   -- numeric comparison
    +       elseif type(op1) == "string" and type(op2) == "string" then
    +         return op1 < op2   -- lexicographic comparison
    +       else
    +         local h = getcomphandler(op1, op2, "__lt")
    +         if h then
    +           return (h(op1, op2))
    +         else
    +           error(···)
    +         end
    +       end
    +     end
    +

    +a > b is equivalent to b < a. +

  • + +
  • "le": +the <= operation. + + +
    +     function le_event (op1, op2)
    +       if type(op1) == "number" and type(op2) == "number" then
    +         return op1 <= op2   -- numeric comparison
    +       elseif type(op1) == "string" and type(op2) == "string" then
    +         return op1 <= op2   -- lexicographic comparison
    +       else
    +         local h = getcomphandler(op1, op2, "__le")
    +         if h then
    +           return (h(op1, op2))
    +         else
    +           h = getcomphandler(op1, op2, "__lt")
    +           if h then
    +             return not h(op2, op1)
    +           else
    +             error(···)
    +           end
    +         end
    +       end
    +     end
    +

    +a >= b is equivalent to b <= a. +Note that, in the absence of a "le" metamethod, +Lua tries the "lt", assuming that a <= b is +equivalent to not (b < a). +

  • + +
  • "index": +The indexing access table[key]. + + +
    +     function gettable_event (table, key)
    +       local h
    +       if type(table) == "table" then
    +         local v = rawget(table, key)
    +         if v ~= nil then return v end
    +         h = metatable(table).__index
    +         if h == nil then return nil end
    +       else
    +         h = metatable(table).__index
    +         if h == nil then
    +           error(···)
    +         end
    +       end
    +       if type(h) == "function" then
    +         return (h(table, key))     -- call the handler
    +       else return h[key]           -- or repeat operation on it
    +       end
    +     end
    +

    +

  • + +
  • "newindex": +The indexing assignment table[key] = value. + + +
    +     function settable_event (table, key, value)
    +       local h
    +       if type(table) == "table" then
    +         local v = rawget(table, key)
    +         if v ~= nil then rawset(table, key, value); return end
    +         h = metatable(table).__newindex
    +         if h == nil then rawset(table, key, value); return end
    +       else
    +         h = metatable(table).__newindex
    +         if h == nil then
    +           error(···)
    +         end
    +       end
    +       if type(h) == "function" then
    +         h(table, key,value)           -- call the handler
    +       else h[key] = value             -- or repeat operation on it
    +       end
    +     end
    +

    +

  • + +
  • "call": +called when Lua calls a value. + + +
    +     function function_event (func, ...)
    +       if type(func) == "function" then
    +         return func(...)   -- primitive call
    +       else
    +         local h = metatable(func).__call
    +         if h then
    +           return h(func, ...)
    +         else
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
+ + + + +

2.9 - Environments

+ +

+Besides metatables, +objects of types thread, function, and userdata +have another table associated with them, +called their environment. +Like metatables, environments are regular tables and +multiple objects can share the same environment. + + +

+Threads are created sharing the environment of the creating thread. +Userdata and C functions are created sharing the environment +of the creating C function. +Non-nested Lua functions +(created by loadfile, loadstring or load) +are created sharing the environment of the creating thread. +Nested Lua functions are created sharing the environment of +the creating Lua function. + + +

+Environments associated with userdata have no meaning for Lua. +It is only a convenience feature for programmers to associate a table to +a userdata. + + +

+Environments associated with threads are called +global environments. +They are used as the default environment for threads and +non-nested Lua functions created by the thread +and can be directly accessed by C code (see §3.3). + + +

+The environment associated with a C function can be directly +accessed by C code (see §3.3). +It is used as the default environment for other C functions +and userdata created by the function. + + +

+Environments associated with Lua functions are used to resolve +all accesses to global variables within the function (see §2.3). +They are used as the default environment for nested Lua functions +created by the function. + + +

+You can change the environment of a Lua function or the +running thread by calling setfenv. +You can get the environment of a Lua function or the running thread +by calling getfenv. +To manipulate the environment of other objects +(userdata, C functions, other threads) you must +use the C API. + + + + + +

2.10 - Garbage Collection

+ +

+Lua performs automatic memory management. +This means that +you have to worry neither about allocating memory for new objects +nor about freeing it when the objects are no longer needed. +Lua manages memory automatically by running +a garbage collector from time to time +to collect all dead objects +(that is, objects that are no longer accessible from Lua). +All memory used by Lua is subject to automatic management: +tables, userdata, functions, threads, strings, etc. + + +

+Lua implements an incremental mark-and-sweep collector. +It uses two numbers to control its garbage-collection cycles: +the garbage-collector pause and +the garbage-collector step multiplier. +Both use percentage points as units +(so that a value of 100 means an internal value of 1). + + +

+The garbage-collector pause +controls how long the collector waits before starting a new cycle. +Larger values make the collector less aggressive. +Values smaller than 100 mean the collector will not wait to +start a new cycle. +A value of 200 means that the collector waits for the total memory in use +to double before starting a new cycle. + + +

+The step multiplier +controls the relative speed of the collector relative to +memory allocation. +Larger values make the collector more aggressive but also increase +the size of each incremental step. +Values smaller than 100 make the collector too slow and +can result in the collector never finishing a cycle. +The default, 200, means that the collector runs at "twice" +the speed of memory allocation. + + +

+You can change these numbers by calling lua_gc in C +or collectgarbage in Lua. +With these functions you can also control +the collector directly (e.g., stop and restart it). + + + +

2.10.1 - Garbage-Collection Metamethods

+ +

+Using the C API, +you can set garbage-collector metamethods for userdata (see §2.8). +These metamethods are also called finalizers. +Finalizers allow you to coordinate Lua's garbage collection +with external resource management +(such as closing files, network or database connections, +or freeing your own memory). + + +

+Garbage userdata with a field __gc in their metatables are not +collected immediately by the garbage collector. +Instead, Lua puts them in a list. +After the collection, +Lua does the equivalent of the following function +for each userdata in that list: + +

+     function gc_event (udata)
+       local h = metatable(udata).__gc
+       if h then
+         h(udata)
+       end
+     end
+
+ +

+At the end of each garbage-collection cycle, +the finalizers for userdata are called in reverse +order of their creation, +among those collected in that cycle. +That is, the first finalizer to be called is the one associated +with the userdata created last in the program. +The userdata itself is freed only in the next garbage-collection cycle. + + + + + +

2.10.2 - Weak Tables

+ +

+A weak table is a table whose elements are +weak references. +A weak reference is ignored by the garbage collector. +In other words, +if the only references to an object are weak references, +then the garbage collector will collect this object. + + +

+A weak table can have weak keys, weak values, or both. +A table with weak keys allows the collection of its keys, +but prevents the collection of its values. +A table with both weak keys and weak values allows the collection of +both keys and values. +In any case, if either the key or the value is collected, +the whole pair is removed from the table. +The weakness of a table is controlled by the +__mode field of its metatable. +If the __mode field is a string containing the character 'k', +the keys in the table are weak. +If __mode contains 'v', +the values in the table are weak. + + +

+After you use a table as a metatable, +you should not change the value of its __mode field. +Otherwise, the weak behavior of the tables controlled by this +metatable is undefined. + + + + + + + +

2.11 - Coroutines

+ +

+Lua supports coroutines, +also called collaborative multithreading. +A coroutine in Lua represents an independent thread of execution. +Unlike threads in multithread systems, however, +a coroutine only suspends its execution by explicitly calling +a yield function. + + +

+You create a coroutine with a call to coroutine.create. +Its sole argument is a function +that is the main function of the coroutine. +The create function only creates a new coroutine and +returns a handle to it (an object of type thread); +it does not start the coroutine execution. + + +

+When you first call coroutine.resume, +passing as its first argument +a thread returned by coroutine.create, +the coroutine starts its execution, +at the first line of its main function. +Extra arguments passed to coroutine.resume are passed on +to the coroutine main function. +After the coroutine starts running, +it runs until it terminates or yields. + + +

+A coroutine can terminate its execution in two ways: +normally, when its main function returns +(explicitly or implicitly, after the last instruction); +and abnormally, if there is an unprotected error. +In the first case, coroutine.resume returns true, +plus any values returned by the coroutine main function. +In case of errors, coroutine.resume returns false +plus an error message. + + +

+A coroutine yields by calling coroutine.yield. +When a coroutine yields, +the corresponding coroutine.resume returns immediately, +even if the yield happens inside nested function calls +(that is, not in the main function, +but in a function directly or indirectly called by the main function). +In the case of a yield, coroutine.resume also returns true, +plus any values passed to coroutine.yield. +The next time you resume the same coroutine, +it continues its execution from the point where it yielded, +with the call to coroutine.yield returning any extra +arguments passed to coroutine.resume. + + +

+Like coroutine.create, +the coroutine.wrap function also creates a coroutine, +but instead of returning the coroutine itself, +it returns a function that, when called, resumes the coroutine. +Any arguments passed to this function +go as extra arguments to coroutine.resume. +coroutine.wrap returns all the values returned by coroutine.resume, +except the first one (the boolean error code). +Unlike coroutine.resume, +coroutine.wrap does not catch errors; +any error is propagated to the caller. + + +

+As an example, +consider the following code: + +

+     function foo (a)
+       print("foo", a)
+       return coroutine.yield(2*a)
+     end
+     
+     co = coroutine.create(function (a,b)
+           print("co-body", a, b)
+           local r = foo(a+1)
+           print("co-body", r)
+           local r, s = coroutine.yield(a+b, a-b)
+           print("co-body", r, s)
+           return b, "end"
+     end)
+            
+     print("main", coroutine.resume(co, 1, 10))
+     print("main", coroutine.resume(co, "r"))
+     print("main", coroutine.resume(co, "x", "y"))
+     print("main", coroutine.resume(co, "x", "y"))
+

+When you run it, it produces the following output: + +

+     co-body 1       10
+     foo     2
+     
+     main    true    4
+     co-body r
+     main    true    11      -9
+     co-body x       y
+     main    true    10      end
+     main    false   cannot resume dead coroutine
+
+ + + + +

3 - The Application Program Interface

+ +

+ +This section describes the C API for Lua, that is, +the set of C functions available to the host program to communicate +with Lua. +All API functions and related types and constants +are declared in the header file lua.h. + + +

+Even when we use the term "function", +any facility in the API may be provided as a macro instead. +All such macros use each of their arguments exactly once +(except for the first argument, which is always a Lua state), +and so do not generate any hidden side-effects. + + +

+As in most C libraries, +the Lua API functions do not check their arguments for validity or consistency. +However, you can change this behavior by compiling Lua +with a proper definition for the macro luai_apicheck, +in file luaconf.h. + + + +

3.1 - The Stack

+ +

+Lua uses a virtual stack to pass values to and from C. +Each element in this stack represents a Lua value +(nil, number, string, etc.). + + +

+Whenever Lua calls C, the called function gets a new stack, +which is independent of previous stacks and of stacks of +C functions that are still active. +This stack initially contains any arguments to the C function +and it is where the C function pushes its results +to be returned to the caller (see lua_CFunction). + + +

+For convenience, +most query operations in the API do not follow a strict stack discipline. +Instead, they can refer to any element in the stack +by using an index: +A positive index represents an absolute stack position +(starting at 1); +a negative index represents an offset relative to the top of the stack. +More specifically, if the stack has n elements, +then index 1 represents the first element +(that is, the element that was pushed onto the stack first) +and +index n represents the last element; +index -1 also represents the last element +(that is, the element at the top) +and index -n represents the first element. +We say that an index is valid +if it lies between 1 and the stack top +(that is, if 1 ≤ abs(index) ≤ top). + + + + + + +

3.2 - Stack Size

+ +

+When you interact with Lua API, +you are responsible for ensuring consistency. +In particular, +you are responsible for controlling stack overflow. +You can use the function lua_checkstack +to grow the stack size. + + +

+Whenever Lua calls C, +it ensures that at least LUA_MINSTACK stack positions are available. +LUA_MINSTACK is defined as 20, +so that usually you do not have to worry about stack space +unless your code has loops pushing elements onto the stack. + + +

+Most query functions accept as indices any value inside the +available stack space, that is, indices up to the maximum stack size +you have set through lua_checkstack. +Such indices are called acceptable indices. +More formally, we define an acceptable index +as follows: + +

+     (index < 0 && abs(index) <= top) ||
+     (index > 0 && index <= stackspace)
+

+Note that 0 is never an acceptable index. + + + + + +

3.3 - Pseudo-Indices

+ +

+Unless otherwise noted, +any function that accepts valid indices can also be called with +pseudo-indices, +which represent some Lua values that are accessible to C code +but which are not in the stack. +Pseudo-indices are used to access the thread environment, +the function environment, +the registry, +and the upvalues of a C function (see §3.4). + + +

+The thread environment (where global variables live) is +always at pseudo-index LUA_GLOBALSINDEX. +The environment of the running C function is always +at pseudo-index LUA_ENVIRONINDEX. + + +

+To access and change the value of global variables, +you can use regular table operations over an environment table. +For instance, to access the value of a global variable, do + +

+     lua_getfield(L, LUA_GLOBALSINDEX, varname);
+
+ + + + +

3.4 - C Closures

+ +

+When a C function is created, +it is possible to associate some values with it, +thus creating a C closure; +these values are called upvalues and are +accessible to the function whenever it is called +(see lua_pushcclosure). + + +

+Whenever a C function is called, +its upvalues are located at specific pseudo-indices. +These pseudo-indices are produced by the macro +lua_upvalueindex. +The first value associated with a function is at position +lua_upvalueindex(1), and so on. +Any access to lua_upvalueindex(n), +where n is greater than the number of upvalues of the +current function (but not greater than 256), +produces an acceptable (but invalid) index. + + + + + +

3.5 - Registry

+ +

+Lua provides a registry, +a pre-defined table that can be used by any C code to +store whatever Lua value it needs to store. +This table is always located at pseudo-index +LUA_REGISTRYINDEX. +Any C library can store data into this table, +but it should take care to choose keys different from those used +by other libraries, to avoid collisions. +Typically, you should use as key a string containing your library name +or a light userdata with the address of a C object in your code. + + +

+The integer keys in the registry are used by the reference mechanism, +implemented by the auxiliary library, +and therefore should not be used for other purposes. + + + + + +

3.6 - Error Handling in C

+ +

+Internally, Lua uses the C longjmp facility to handle errors. +(You can also choose to use exceptions if you use C++; +see file luaconf.h.) +When Lua faces any error +(such as memory allocation errors, type errors, syntax errors, +and runtime errors) +it raises an error; +that is, it does a long jump. +A protected environment uses setjmp +to set a recover point; +any error jumps to the most recent active recover point. + + +

+Most functions in the API can throw an error, +for instance due to a memory allocation error. +The documentation for each function indicates whether +it can throw errors. + + +

+Inside a C function you can throw an error by calling lua_error. + + + + + +

3.7 - Functions and Types

+ +

+Here we list all functions and types from the C API in +alphabetical order. +Each function has an indicator like this: +[-o, +p, x] + + +

+The first field, o, +is how many elements the function pops from the stack. +The second field, p, +is how many elements the function pushes onto the stack. +(Any function always pushes its results after popping its arguments.) +A field in the form x|y means the function can push (or pop) +x or y elements, +depending on the situation; +an interrogation mark '?' means that +we cannot know how many elements the function pops/pushes +by looking only at its arguments +(e.g., they may depend on what is on the stack). +The third field, x, +tells whether the function may throw errors: +'-' means the function never throws any error; +'m' means the function may throw an error +only due to not enough memory; +'e' means the function may throw other kinds of errors; +'v' means the function may throw an error on purpose. + + + +


lua_Alloc

+
typedef void * (*lua_Alloc) (void *ud,
+                             void *ptr,
+                             size_t osize,
+                             size_t nsize);
+ +

+The type of the memory-allocation function used by Lua states. +The allocator function must provide a +functionality similar to realloc, +but not exactly the same. +Its arguments are +ud, an opaque pointer passed to lua_newstate; +ptr, a pointer to the block being allocated/reallocated/freed; +osize, the original size of the block; +nsize, the new size of the block. +ptr is NULL if and only if osize is zero. +When nsize is zero, the allocator must return NULL; +if osize is not zero, +it should free the block pointed to by ptr. +When nsize is not zero, the allocator returns NULL +if and only if it cannot fill the request. +When nsize is not zero and osize is zero, +the allocator should behave like malloc. +When nsize and osize are not zero, +the allocator behaves like realloc. +Lua assumes that the allocator never fails when +osize >= nsize. + + +

+Here is a simple implementation for the allocator function. +It is used in the auxiliary library by luaL_newstate. + +

+     static void *l_alloc (void *ud, void *ptr, size_t osize,
+                                                size_t nsize) {
+       (void)ud;  (void)osize;  /* not used */
+       if (nsize == 0) {
+         free(ptr);
+         return NULL;
+       }
+       else
+         return realloc(ptr, nsize);
+     }
+

+This code assumes +that free(NULL) has no effect and that +realloc(NULL, size) is equivalent to malloc(size). +ANSI C ensures both behaviors. + + + + + +


lua_atpanic

+[-0, +0, -] +

lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);
+ +

+Sets a new panic function and returns the old one. + + +

+If an error happens outside any protected environment, +Lua calls a panic function +and then calls exit(EXIT_FAILURE), +thus exiting the host application. +Your panic function can avoid this exit by +never returning (e.g., doing a long jump). + + +

+The panic function can access the error message at the top of the stack. + + + + + +


lua_call

+[-(nargs + 1), +nresults, e] +

void lua_call (lua_State *L, int nargs, int nresults);
+ +

+Calls a function. + + +

+To call a function you must use the following protocol: +first, the function to be called is pushed onto the stack; +then, the arguments to the function are pushed +in direct order; +that is, the first argument is pushed first. +Finally you call lua_call; +nargs is the number of arguments that you pushed onto the stack. +All arguments and the function value are popped from the stack +when the function is called. +The function results are pushed onto the stack when the function returns. +The number of results is adjusted to nresults, +unless nresults is LUA_MULTRET. +In this case, all results from the function are pushed. +Lua takes care that the returned values fit into the stack space. +The function results are pushed onto the stack in direct order +(the first result is pushed first), +so that after the call the last result is on the top of the stack. + + +

+Any error inside the called function is propagated upwards +(with a longjmp). + + +

+The following example shows how the host program can do the +equivalent to this Lua code: + +

+     a = f("how", t.x, 14)
+

+Here it is in C: + +

+     lua_getfield(L, LUA_GLOBALSINDEX, "f"); /* function to be called */
+     lua_pushstring(L, "how");                        /* 1st argument */
+     lua_getfield(L, LUA_GLOBALSINDEX, "t");   /* table to be indexed */
+     lua_getfield(L, -1, "x");        /* push result of t.x (2nd arg) */
+     lua_remove(L, -2);                  /* remove 't' from the stack */
+     lua_pushinteger(L, 14);                          /* 3rd argument */
+     lua_call(L, 3, 1);     /* call 'f' with 3 arguments and 1 result */
+     lua_setfield(L, LUA_GLOBALSINDEX, "a");        /* set global 'a' */
+

+Note that the code above is "balanced": +at its end, the stack is back to its original configuration. +This is considered good programming practice. + + + + + +


lua_CFunction

+
typedef int (*lua_CFunction) (lua_State *L);
+ +

+Type for C functions. + + +

+In order to communicate properly with Lua, +a C function must use the following protocol, +which defines the way parameters and results are passed: +a C function receives its arguments from Lua in its stack +in direct order (the first argument is pushed first). +So, when the function starts, +lua_gettop(L) returns the number of arguments received by the function. +The first argument (if any) is at index 1 +and its last argument is at index lua_gettop(L). +To return values to Lua, a C function just pushes them onto the stack, +in direct order (the first result is pushed first), +and returns the number of results. +Any other value in the stack below the results will be properly +discarded by Lua. +Like a Lua function, a C function called by Lua can also return +many results. + + +

+As an example, the following function receives a variable number +of numerical arguments and returns their average and sum: + +

+     static int foo (lua_State *L) {
+       int n = lua_gettop(L);    /* number of arguments */
+       lua_Number sum = 0;
+       int i;
+       for (i = 1; i <= n; i++) {
+         if (!lua_isnumber(L, i)) {
+           lua_pushstring(L, "incorrect argument");
+           lua_error(L);
+         }
+         sum += lua_tonumber(L, i);
+       }
+       lua_pushnumber(L, sum/n);        /* first result */
+       lua_pushnumber(L, sum);         /* second result */
+       return 2;                   /* number of results */
+     }
+
+ + + + +

lua_checkstack

+[-0, +0, m] +

int lua_checkstack (lua_State *L, int extra);
+ +

+Ensures that there are at least extra free stack slots in the stack. +It returns false if it cannot grow the stack to that size. +This function never shrinks the stack; +if the stack is already larger than the new size, +it is left unchanged. + + + + + +


lua_close

+[-0, +0, -] +

void lua_close (lua_State *L);
+ +

+Destroys all objects in the given Lua state +(calling the corresponding garbage-collection metamethods, if any) +and frees all dynamic memory used by this state. +On several platforms, you may not need to call this function, +because all resources are naturally released when the host program ends. +On the other hand, long-running programs, +such as a daemon or a web server, +might need to release states as soon as they are not needed, +to avoid growing too large. + + + + + +


lua_concat

+[-n, +1, e] +

void lua_concat (lua_State *L, int n);
+ +

+Concatenates the n values at the top of the stack, +pops them, and leaves the result at the top. +If n is 1, the result is the single value on the stack +(that is, the function does nothing); +if n is 0, the result is the empty string. +Concatenation is performed following the usual semantics of Lua +(see §2.5.4). + + + + + +


lua_cpcall

+[-0, +(0|1), -] +

int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);
+ +

+Calls the C function func in protected mode. +func starts with only one element in its stack, +a light userdata containing ud. +In case of errors, +lua_cpcall returns the same error codes as lua_pcall, +plus the error object on the top of the stack; +otherwise, it returns zero, and does not change the stack. +All values returned by func are discarded. + + + + + +


lua_createtable

+[-0, +1, m] +

void lua_createtable (lua_State *L, int narr, int nrec);
+ +

+Creates a new empty table and pushes it onto the stack. +The new table has space pre-allocated +for narr array elements and nrec non-array elements. +This pre-allocation is useful when you know exactly how many elements +the table will have. +Otherwise you can use the function lua_newtable. + + + + + +


lua_dump

+[-0, +0, m] +

int lua_dump (lua_State *L, lua_Writer writer, void *data);
+ +

+Dumps a function as a binary chunk. +Receives a Lua function on the top of the stack +and produces a binary chunk that, +if loaded again, +results in a function equivalent to the one dumped. +As it produces parts of the chunk, +lua_dump calls function writer (see lua_Writer) +with the given data +to write them. + + +

+The value returned is the error code returned by the last +call to the writer; +0 means no errors. + + +

+This function does not pop the Lua function from the stack. + + + + + +


lua_equal

+[-0, +0, e] +

int lua_equal (lua_State *L, int index1, int index2);
+ +

+Returns 1 if the two values in acceptable indices index1 and +index2 are equal, +following the semantics of the Lua == operator +(that is, may call metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices is non valid. + + + + + +


lua_error

+[-1, +0, v] +

int lua_error (lua_State *L);
+ +

+Generates a Lua error. +The error message (which can actually be a Lua value of any type) +must be on the stack top. +This function does a long jump, +and therefore never returns. +(see luaL_error). + + + + + +


lua_gc

+[-0, +0, e] +

int lua_gc (lua_State *L, int what, int data);
+ +

+Controls the garbage collector. + + +

+This function performs several tasks, +according to the value of the parameter what: + +

    + +
  • LUA_GCSTOP: +stops the garbage collector. +
  • + +
  • LUA_GCRESTART: +restarts the garbage collector. +
  • + +
  • LUA_GCCOLLECT: +performs a full garbage-collection cycle. +
  • + +
  • LUA_GCCOUNT: +returns the current amount of memory (in Kbytes) in use by Lua. +
  • + +
  • LUA_GCCOUNTB: +returns the remainder of dividing the current amount of bytes of +memory in use by Lua by 1024. +
  • + +
  • LUA_GCSTEP: +performs an incremental step of garbage collection. +The step "size" is controlled by data +(larger values mean more steps) in a non-specified way. +If you want to control the step size +you must experimentally tune the value of data. +The function returns 1 if the step finished a +garbage-collection cycle. +
  • + +
  • LUA_GCSETPAUSE: +sets data as the new value +for the pause of the collector (see §2.10). +The function returns the previous value of the pause. +
  • + +
  • LUA_GCSETSTEPMUL: +sets data as the new value for the step multiplier of +the collector (see §2.10). +The function returns the previous value of the step multiplier. +
  • + +
+ + + + +

lua_getallocf

+[-0, +0, -] +

lua_Alloc lua_getallocf (lua_State *L, void **ud);
+ +

+Returns the memory-allocation function of a given state. +If ud is not NULL, Lua stores in *ud the +opaque pointer passed to lua_newstate. + + + + + +


lua_getfenv

+[-0, +1, -] +

void lua_getfenv (lua_State *L, int index);
+ +

+Pushes onto the stack the environment table of +the value at the given index. + + + + + +


lua_getfield

+[-0, +1, e] +

void lua_getfield (lua_State *L, int index, const char *k);
+ +

+Pushes onto the stack the value t[k], +where t is the value at the given valid index. +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.8). + + + + + +


lua_getglobal

+[-0, +1, e] +

void lua_getglobal (lua_State *L, const char *name);
+ +

+Pushes onto the stack the value of the global name. +It is defined as a macro: + +

+     #define lua_getglobal(L,s)  lua_getfield(L, LUA_GLOBALSINDEX, s)
+
+ + + + +

lua_getmetatable

+[-0, +(0|1), -] +

int lua_getmetatable (lua_State *L, int index);
+ +

+Pushes onto the stack the metatable of the value at the given +acceptable index. +If the index is not valid, +or if the value does not have a metatable, +the function returns 0 and pushes nothing on the stack. + + + + + +


lua_gettable

+[-1, +1, e] +

void lua_gettable (lua_State *L, int index);
+ +

+Pushes onto the stack the value t[k], +where t is the value at the given valid index +and k is the value at the top of the stack. + + +

+This function pops the key from the stack +(putting the resulting value in its place). +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.8). + + + + + +


lua_gettop

+[-0, +0, -] +

int lua_gettop (lua_State *L);
+ +

+Returns the index of the top element in the stack. +Because indices start at 1, +this result is equal to the number of elements in the stack +(and so 0 means an empty stack). + + + + + +


lua_insert

+[-1, +1, -] +

void lua_insert (lua_State *L, int index);
+ +

+Moves the top element into the given valid index, +shifting up the elements above this index to open space. +Cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


lua_Integer

+
typedef ptrdiff_t lua_Integer;
+ +

+The type used by the Lua API to represent integral values. + + +

+By default it is a ptrdiff_t, +which is usually the largest signed integral type the machine handles +"comfortably". + + + + + +


lua_isboolean

+[-0, +0, -] +

int lua_isboolean (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index has type boolean, +and 0 otherwise. + + + + + +


lua_iscfunction

+[-0, +0, -] +

int lua_iscfunction (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a C function, +and 0 otherwise. + + + + + +


lua_isfunction

+[-0, +0, -] +

int lua_isfunction (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a function +(either C or Lua), and 0 otherwise. + + + + + +


lua_islightuserdata

+[-0, +0, -] +

int lua_islightuserdata (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a light userdata, +and 0 otherwise. + + + + + +


lua_isnil

+[-0, +0, -] +

int lua_isnil (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is nil, +and 0 otherwise. + + + + + +


lua_isnone

+[-0, +0, -] +

int lua_isnone (lua_State *L, int index);
+ +

+Returns 1 if the given acceptable index is not valid +(that is, it refers to an element outside the current stack), +and 0 otherwise. + + + + + +


lua_isnoneornil

+[-0, +0, -] +

int lua_isnoneornil (lua_State *L, int index);
+ +

+Returns 1 if the given acceptable index is not valid +(that is, it refers to an element outside the current stack) +or if the value at this index is nil, +and 0 otherwise. + + + + + +


lua_isnumber

+[-0, +0, -] +

int lua_isnumber (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a number +or a string convertible to a number, +and 0 otherwise. + + + + + +


lua_isstring

+[-0, +0, -] +

int lua_isstring (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a string +or a number (which is always convertible to a string), +and 0 otherwise. + + + + + +


lua_istable

+[-0, +0, -] +

int lua_istable (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a table, +and 0 otherwise. + + + + + +


lua_isthread

+[-0, +0, -] +

int lua_isthread (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a thread, +and 0 otherwise. + + + + + +


lua_isuserdata

+[-0, +0, -] +

int lua_isuserdata (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a userdata +(either full or light), and 0 otherwise. + + + + + +


lua_lessthan

+[-0, +0, e] +

int lua_lessthan (lua_State *L, int index1, int index2);
+ +

+Returns 1 if the value at acceptable index index1 is smaller +than the value at acceptable index index2, +following the semantics of the Lua < operator +(that is, may call metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices is non valid. + + + + + +


lua_load

+[-0, +1, -] +

int lua_load (lua_State *L,
+              lua_Reader reader,
+              void *data,
+              const char *chunkname);
+ +

+Loads a Lua chunk. +If there are no errors, +lua_load pushes the compiled chunk as a Lua +function on top of the stack. +Otherwise, it pushes an error message. +The return values of lua_load are: + +

    + +
  • 0: no errors;
  • + +
  • LUA_ERRSYNTAX: +syntax error during pre-compilation;
  • + +
  • LUA_ERRMEM: +memory allocation error.
  • + +
+ +

+This function only loads a chunk; +it does not run it. + + +

+lua_load automatically detects whether the chunk is text or binary, +and loads it accordingly (see program luac). + + +

+The lua_load function uses a user-supplied reader function +to read the chunk (see lua_Reader). +The data argument is an opaque value passed to the reader function. + + +

+The chunkname argument gives a name to the chunk, +which is used for error messages and in debug information (see §3.8). + + + + + +


lua_newstate

+[-0, +0, -] +

lua_State *lua_newstate (lua_Alloc f, void *ud);
+ +

+Creates a new, independent state. +Returns NULL if cannot create the state +(due to lack of memory). +The argument f is the allocator function; +Lua does all memory allocation for this state through this function. +The second argument, ud, is an opaque pointer that Lua +simply passes to the allocator in every call. + + + + + +


lua_newtable

+[-0, +1, m] +

void lua_newtable (lua_State *L);
+ +

+Creates a new empty table and pushes it onto the stack. +It is equivalent to lua_createtable(L, 0, 0). + + + + + +


lua_newthread

+[-0, +1, m] +

lua_State *lua_newthread (lua_State *L);
+ +

+Creates a new thread, pushes it on the stack, +and returns a pointer to a lua_State that represents this new thread. +The new state returned by this function shares with the original state +all global objects (such as tables), +but has an independent execution stack. + + +

+There is no explicit function to close or to destroy a thread. +Threads are subject to garbage collection, +like any Lua object. + + + + + +


lua_newuserdata

+[-0, +1, m] +

void *lua_newuserdata (lua_State *L, size_t size);
+ +

+This function allocates a new block of memory with the given size, +pushes onto the stack a new full userdata with the block address, +and returns this address. + + +

+Userdata represent C values in Lua. +A full userdata represents a block of memory. +It is an object (like a table): +you must create it, it can have its own metatable, +and you can detect when it is being collected. +A full userdata is only equal to itself (under raw equality). + + +

+When Lua collects a full userdata with a gc metamethod, +Lua calls the metamethod and marks the userdata as finalized. +When this userdata is collected again then +Lua frees its corresponding memory. + + + + + +


lua_next

+[-1, +(2|0), e] +

int lua_next (lua_State *L, int index);
+ +

+Pops a key from the stack, +and pushes a key-value pair from the table at the given index +(the "next" pair after the given key). +If there are no more elements in the table, +then lua_next returns 0 (and pushes nothing). + + +

+A typical traversal looks like this: + +

+     /* table is in the stack at index 't' */
+     lua_pushnil(L);  /* first key */
+     while (lua_next(L, t) != 0) {
+       /* uses 'key' (at index -2) and 'value' (at index -1) */
+       printf("%s - %s\n",
+              lua_typename(L, lua_type(L, -2)),
+              lua_typename(L, lua_type(L, -1)));
+       /* removes 'value'; keeps 'key' for next iteration */
+       lua_pop(L, 1);
+     }
+
+ +

+While traversing a table, +do not call lua_tolstring directly on a key, +unless you know that the key is actually a string. +Recall that lua_tolstring changes +the value at the given index; +this confuses the next call to lua_next. + + + + + +


lua_Number

+
typedef double lua_Number;
+ +

+The type of numbers in Lua. +By default, it is double, but that can be changed in luaconf.h. + + +

+Through the configuration file you can change +Lua to operate with another type for numbers (e.g., float or long). + + + + + +


lua_objlen

+[-0, +0, -] +

size_t lua_objlen (lua_State *L, int index);
+ +

+Returns the "length" of the value at the given acceptable index: +for strings, this is the string length; +for tables, this is the result of the length operator ('#'); +for userdata, this is the size of the block of memory allocated +for the userdata; +for other values, it is 0. + + + + + +


lua_pcall

+[-(nargs + 1), +(nresults|1), -] +

int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
+ +

+Calls a function in protected mode. + + +

+Both nargs and nresults have the same meaning as +in lua_call. +If there are no errors during the call, +lua_pcall behaves exactly like lua_call. +However, if there is any error, +lua_pcall catches it, +pushes a single value on the stack (the error message), +and returns an error code. +Like lua_call, +lua_pcall always removes the function +and its arguments from the stack. + + +

+If errfunc is 0, +then the error message returned on the stack +is exactly the original error message. +Otherwise, errfunc is the stack index of an +error handler function. +(In the current implementation, this index cannot be a pseudo-index.) +In case of runtime errors, +this function will be called with the error message +and its return value will be the message returned on the stack by lua_pcall. + + +

+Typically, the error handler function is used to add more debug +information to the error message, such as a stack traceback. +Such information cannot be gathered after the return of lua_pcall, +since by then the stack has unwound. + + +

+The lua_pcall function returns 0 in case of success +or one of the following error codes +(defined in lua.h): + +

    + +
  • LUA_ERRRUN: +a runtime error. +
  • + +
  • LUA_ERRMEM: +memory allocation error. +For such errors, Lua does not call the error handler function. +
  • + +
  • LUA_ERRERR: +error while running the error handler function. +
  • + +
+ + + + +

lua_pop

+[-n, +0, -] +

void lua_pop (lua_State *L, int n);
+ +

+Pops n elements from the stack. + + + + + +


lua_pushboolean

+[-0, +1, -] +

void lua_pushboolean (lua_State *L, int b);
+ +

+Pushes a boolean value with value b onto the stack. + + + + + +


lua_pushcclosure

+[-n, +1, m] +

void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
+ +

+Pushes a new C closure onto the stack. + + +

+When a C function is created, +it is possible to associate some values with it, +thus creating a C closure (see §3.4); +these values are then accessible to the function whenever it is called. +To associate values with a C function, +first these values should be pushed onto the stack +(when there are multiple values, the first value is pushed first). +Then lua_pushcclosure +is called to create and push the C function onto the stack, +with the argument n telling how many values should be +associated with the function. +lua_pushcclosure also pops these values from the stack. + + +

+The maximum value for n is 255. + + + + + +


lua_pushcfunction

+[-0, +1, m] +

void lua_pushcfunction (lua_State *L, lua_CFunction f);
+ +

+Pushes a C function onto the stack. +This function receives a pointer to a C function +and pushes onto the stack a Lua value of type function that, +when called, invokes the corresponding C function. + + +

+Any function to be registered in Lua must +follow the correct protocol to receive its parameters +and return its results (see lua_CFunction). + + +

+lua_pushcfunction is defined as a macro: + +

+     #define lua_pushcfunction(L,f)  lua_pushcclosure(L,f,0)
+
+ + + + +

lua_pushfstring

+[-0, +1, m] +

const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
+ +

+Pushes onto the stack a formatted string +and returns a pointer to this string. +It is similar to the C function sprintf, +but has some important differences: + +

    + +
  • +You do not have to allocate space for the result: +the result is a Lua string and Lua takes care of memory allocation +(and deallocation, through garbage collection). +
  • + +
  • +The conversion specifiers are quite restricted. +There are no flags, widths, or precisions. +The conversion specifiers can only be +'%%' (inserts a '%' in the string), +'%s' (inserts a zero-terminated string, with no size restrictions), +'%f' (inserts a lua_Number), +'%p' (inserts a pointer as a hexadecimal numeral), +'%d' (inserts an int), and +'%c' (inserts an int as a character). +
  • + +
+ + + + +

lua_pushinteger

+[-0, +1, -] +

void lua_pushinteger (lua_State *L, lua_Integer n);
+ +

+Pushes a number with value n onto the stack. + + + + + +


lua_pushlightuserdata

+[-0, +1, -] +

void lua_pushlightuserdata (lua_State *L, void *p);
+ +

+Pushes a light userdata onto the stack. + + +

+Userdata represent C values in Lua. +A light userdata represents a pointer. +It is a value (like a number): +you do not create it, it has no individual metatable, +and it is not collected (as it was never created). +A light userdata is equal to "any" +light userdata with the same C address. + + + + + +


lua_pushliteral

+[-0, +1, m] +

void lua_pushliteral (lua_State *L, const char *s);
+ +

+This macro is equivalent to lua_pushlstring, +but can be used only when s is a literal string. +In these cases, it automatically provides the string length. + + + + + +


lua_pushlstring

+[-0, +1, m] +

void lua_pushlstring (lua_State *L, const char *s, size_t len);
+ +

+Pushes the string pointed to by s with size len +onto the stack. +Lua makes (or reuses) an internal copy of the given string, +so the memory at s can be freed or reused immediately after +the function returns. +The string can contain embedded zeros. + + + + + +


lua_pushnil

+[-0, +1, -] +

void lua_pushnil (lua_State *L);
+ +

+Pushes a nil value onto the stack. + + + + + +


lua_pushnumber

+[-0, +1, -] +

void lua_pushnumber (lua_State *L, lua_Number n);
+ +

+Pushes a number with value n onto the stack. + + + + + +


lua_pushstring

+[-0, +1, m] +

void lua_pushstring (lua_State *L, const char *s);
+ +

+Pushes the zero-terminated string pointed to by s +onto the stack. +Lua makes (or reuses) an internal copy of the given string, +so the memory at s can be freed or reused immediately after +the function returns. +The string cannot contain embedded zeros; +it is assumed to end at the first zero. + + + + + +


lua_pushthread

+[-0, +1, -] +

int lua_pushthread (lua_State *L);
+ +

+Pushes the thread represented by L onto the stack. +Returns 1 if this thread is the main thread of its state. + + + + + +


lua_pushvalue

+[-0, +1, -] +

void lua_pushvalue (lua_State *L, int index);
+ +

+Pushes a copy of the element at the given valid index +onto the stack. + + + + + +


lua_pushvfstring

+[-0, +1, m] +

const char *lua_pushvfstring (lua_State *L,
+                              const char *fmt,
+                              va_list argp);
+ +

+Equivalent to lua_pushfstring, except that it receives a va_list +instead of a variable number of arguments. + + + + + +


lua_rawequal

+[-0, +0, -] +

int lua_rawequal (lua_State *L, int index1, int index2);
+ +

+Returns 1 if the two values in acceptable indices index1 and +index2 are primitively equal +(that is, without calling metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices are non valid. + + + + + +


lua_rawget

+[-1, +1, -] +

void lua_rawget (lua_State *L, int index);
+ +

+Similar to lua_gettable, but does a raw access +(i.e., without metamethods). + + + + + +


lua_rawgeti

+[-0, +1, -] +

void lua_rawgeti (lua_State *L, int index, int n);
+ +

+Pushes onto the stack the value t[n], +where t is the value at the given valid index. +The access is raw; +that is, it does not invoke metamethods. + + + + + +


lua_rawset

+[-2, +0, m] +

void lua_rawset (lua_State *L, int index);
+ +

+Similar to lua_settable, but does a raw assignment +(i.e., without metamethods). + + + + + +


lua_rawseti

+[-1, +0, m] +

void lua_rawseti (lua_State *L, int index, int n);
+ +

+Does the equivalent of t[n] = v, +where t is the value at the given valid index +and v is the value at the top of the stack. + + +

+This function pops the value from the stack. +The assignment is raw; +that is, it does not invoke metamethods. + + + + + +


lua_Reader

+
typedef const char * (*lua_Reader) (lua_State *L,
+                                    void *data,
+                                    size_t *size);
+ +

+The reader function used by lua_load. +Every time it needs another piece of the chunk, +lua_load calls the reader, +passing along its data parameter. +The reader must return a pointer to a block of memory +with a new piece of the chunk +and set size to the block size. +The block must exist until the reader function is called again. +To signal the end of the chunk, +the reader must return NULL or set size to zero. +The reader function may return pieces of any size greater than zero. + + + + + +


lua_register

+[-0, +0, e] +

void lua_register (lua_State *L,
+                   const char *name,
+                   lua_CFunction f);
+ +

+Sets the C function f as the new value of global name. +It is defined as a macro: + +

+     #define lua_register(L,n,f) \
+            (lua_pushcfunction(L, f), lua_setglobal(L, n))
+
+ + + + +

lua_remove

+[-1, +0, -] +

void lua_remove (lua_State *L, int index);
+ +

+Removes the element at the given valid index, +shifting down the elements above this index to fill the gap. +Cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


lua_replace

+[-1, +0, -] +

void lua_replace (lua_State *L, int index);
+ +

+Moves the top element into the given position (and pops it), +without shifting any element +(therefore replacing the value at the given position). + + + + + +


lua_resume

+[-?, +?, -] +

int lua_resume (lua_State *L, int narg);
+ +

+Starts and resumes a coroutine in a given thread. + + +

+To start a coroutine, you first create a new thread +(see lua_newthread); +then you push onto its stack the main function plus any arguments; +then you call lua_resume, +with narg being the number of arguments. +This call returns when the coroutine suspends or finishes its execution. +When it returns, the stack contains all values passed to lua_yield, +or all values returned by the body function. +lua_resume returns +LUA_YIELD if the coroutine yields, +0 if the coroutine finishes its execution +without errors, +or an error code in case of errors (see lua_pcall). +In case of errors, +the stack is not unwound, +so you can use the debug API over it. +The error message is on the top of the stack. +To restart a coroutine, you put on its stack only the values to +be passed as results from yield, +and then call lua_resume. + + + + + +


lua_setallocf

+[-0, +0, -] +

void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+ +

+Changes the allocator function of a given state to f +with user data ud. + + + + + +


lua_setfenv

+[-1, +0, -] +

int lua_setfenv (lua_State *L, int index);
+ +

+Pops a table from the stack and sets it as +the new environment for the value at the given index. +If the value at the given index is +neither a function nor a thread nor a userdata, +lua_setfenv returns 0. +Otherwise it returns 1. + + + + + +


lua_setfield

+[-1, +0, e] +

void lua_setfield (lua_State *L, int index, const char *k);
+ +

+Does the equivalent to t[k] = v, +where t is the value at the given valid index +and v is the value at the top of the stack. + + +

+This function pops the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.8). + + + + + +


lua_setglobal

+[-1, +0, e] +

void lua_setglobal (lua_State *L, const char *name);
+ +

+Pops a value from the stack and +sets it as the new value of global name. +It is defined as a macro: + +

+     #define lua_setglobal(L,s)   lua_setfield(L, LUA_GLOBALSINDEX, s)
+
+ + + + +

lua_setmetatable

+[-1, +0, -] +

int lua_setmetatable (lua_State *L, int index);
+ +

+Pops a table from the stack and +sets it as the new metatable for the value at the given +acceptable index. + + + + + +


lua_settable

+[-2, +0, e] +

void lua_settable (lua_State *L, int index);
+ +

+Does the equivalent to t[k] = v, +where t is the value at the given valid index, +v is the value at the top of the stack, +and k is the value just below the top. + + +

+This function pops both the key and the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.8). + + + + + +


lua_settop

+[-?, +?, -] +

void lua_settop (lua_State *L, int index);
+ +

+Accepts any acceptable index, or 0, +and sets the stack top to this index. +If the new top is larger than the old one, +then the new elements are filled with nil. +If index is 0, then all stack elements are removed. + + + + + +


lua_State

+
typedef struct lua_State lua_State;
+ +

+Opaque structure that keeps the whole state of a Lua interpreter. +The Lua library is fully reentrant: +it has no global variables. +All information about a state is kept in this structure. + + +

+A pointer to this state must be passed as the first argument to +every function in the library, except to lua_newstate, +which creates a Lua state from scratch. + + + + + +


lua_status

+[-0, +0, -] +

int lua_status (lua_State *L);
+ +

+Returns the status of the thread L. + + +

+The status can be 0 for a normal thread, +an error code if the thread finished its execution with an error, +or LUA_YIELD if the thread is suspended. + + + + + +


lua_toboolean

+[-0, +0, -] +

int lua_toboolean (lua_State *L, int index);
+ +

+Converts the Lua value at the given acceptable index to a C boolean +value (0 or 1). +Like all tests in Lua, +lua_toboolean returns 1 for any Lua value +different from false and nil; +otherwise it returns 0. +It also returns 0 when called with a non-valid index. +(If you want to accept only actual boolean values, +use lua_isboolean to test the value's type.) + + + + + +


lua_tocfunction

+[-0, +0, -] +

lua_CFunction lua_tocfunction (lua_State *L, int index);
+ +

+Converts a value at the given acceptable index to a C function. +That value must be a C function; +otherwise, returns NULL. + + + + + +


lua_tointeger

+[-0, +0, -] +

lua_Integer lua_tointeger (lua_State *L, int index);
+ +

+Converts the Lua value at the given acceptable index +to the signed integral type lua_Integer. +The Lua value must be a number or a string convertible to a number +(see §2.2.1); +otherwise, lua_tointeger returns 0. + + +

+If the number is not an integer, +it is truncated in some non-specified way. + + + + + +


lua_tolstring

+[-0, +0, m] +

const char *lua_tolstring (lua_State *L, int index, size_t *len);
+ +

+Converts the Lua value at the given acceptable index to a C string. +If len is not NULL, +it also sets *len with the string length. +The Lua value must be a string or a number; +otherwise, the function returns NULL. +If the value is a number, +then lua_tolstring also +changes the actual value in the stack to a string. +(This change confuses lua_next +when lua_tolstring is applied to keys during a table traversal.) + + +

+lua_tolstring returns a fully aligned pointer +to a string inside the Lua state. +This string always has a zero ('\0') +after its last character (as in C), +but can contain other zeros in its body. +Because Lua has garbage collection, +there is no guarantee that the pointer returned by lua_tolstring +will be valid after the corresponding value is removed from the stack. + + + + + +


lua_tonumber

+[-0, +0, -] +

lua_Number lua_tonumber (lua_State *L, int index);
+ +

+Converts the Lua value at the given acceptable index +to the C type lua_Number (see lua_Number). +The Lua value must be a number or a string convertible to a number +(see §2.2.1); +otherwise, lua_tonumber returns 0. + + + + + +


lua_topointer

+[-0, +0, -] +

const void *lua_topointer (lua_State *L, int index);
+ +

+Converts the value at the given acceptable index to a generic +C pointer (void*). +The value can be a userdata, a table, a thread, or a function; +otherwise, lua_topointer returns NULL. +Different objects will give different pointers. +There is no way to convert the pointer back to its original value. + + +

+Typically this function is used only for debug information. + + + + + +


lua_tostring

+[-0, +0, m] +

const char *lua_tostring (lua_State *L, int index);
+ +

+Equivalent to lua_tolstring with len equal to NULL. + + + + + +


lua_tothread

+[-0, +0, -] +

lua_State *lua_tothread (lua_State *L, int index);
+ +

+Converts the value at the given acceptable index to a Lua thread +(represented as lua_State*). +This value must be a thread; +otherwise, the function returns NULL. + + + + + +


lua_touserdata

+[-0, +0, -] +

void *lua_touserdata (lua_State *L, int index);
+ +

+If the value at the given acceptable index is a full userdata, +returns its block address. +If the value is a light userdata, +returns its pointer. +Otherwise, returns NULL. + + + + + +


lua_type

+[-0, +0, -] +

int lua_type (lua_State *L, int index);
+ +

+Returns the type of the value in the given acceptable index, +or LUA_TNONE for a non-valid index +(that is, an index to an "empty" stack position). +The types returned by lua_type are coded by the following constants +defined in lua.h: +LUA_TNIL, +LUA_TNUMBER, +LUA_TBOOLEAN, +LUA_TSTRING, +LUA_TTABLE, +LUA_TFUNCTION, +LUA_TUSERDATA, +LUA_TTHREAD, +and +LUA_TLIGHTUSERDATA. + + + + + +


lua_typename

+[-0, +0, -] +

const char *lua_typename  (lua_State *L, int tp);
+ +

+Returns the name of the type encoded by the value tp, +which must be one the values returned by lua_type. + + + + + +


lua_Writer

+
typedef int (*lua_Writer) (lua_State *L,
+                           const void* p,
+                           size_t sz,
+                           void* ud);
+ +

+The type of the writer function used by lua_dump. +Every time it produces another piece of chunk, +lua_dump calls the writer, +passing along the buffer to be written (p), +its size (sz), +and the data parameter supplied to lua_dump. + + +

+The writer returns an error code: +0 means no errors; +any other value means an error and stops lua_dump from +calling the writer again. + + + + + +


lua_xmove

+[-?, +?, -] +

void lua_xmove (lua_State *from, lua_State *to, int n);
+ +

+Exchange values between different threads of the same global state. + + +

+This function pops n values from the stack from, +and pushes them onto the stack to. + + + + + +


lua_yield

+[-?, +?, -] +

int lua_yield  (lua_State *L, int nresults);
+ +

+Yields a coroutine. + + +

+This function should only be called as the +return expression of a C function, as follows: + +

+     return lua_yield (L, nresults);
+

+When a C function calls lua_yield in that way, +the running coroutine suspends its execution, +and the call to lua_resume that started this coroutine returns. +The parameter nresults is the number of values from the stack +that are passed as results to lua_resume. + + + + + + + +

3.8 - The Debug Interface

+ +

+Lua has no built-in debugging facilities. +Instead, it offers a special interface +by means of functions and hooks. +This interface allows the construction of different +kinds of debuggers, profilers, and other tools +that need "inside information" from the interpreter. + + + +


lua_Debug

+
typedef struct lua_Debug {
+  int event;
+  const char *name;           /* (n) */
+  const char *namewhat;       /* (n) */
+  const char *what;           /* (S) */
+  const char *source;         /* (S) */
+  int currentline;            /* (l) */
+  int nups;                   /* (u) number of upvalues */
+  int linedefined;            /* (S) */
+  int lastlinedefined;        /* (S) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  other fields
+} lua_Debug;
+ +

+A structure used to carry different pieces of +information about an active function. +lua_getstack fills only the private part +of this structure, for later use. +To fill the other fields of lua_Debug with useful information, +call lua_getinfo. + + +

+The fields of lua_Debug have the following meaning: + +

    + +
  • source: +If the function was defined in a string, +then source is that string. +If the function was defined in a file, +then source starts with a '@' followed by the file name. +
  • + +
  • short_src: +a "printable" version of source, to be used in error messages. +
  • + +
  • linedefined: +the line number where the definition of the function starts. +
  • + +
  • lastlinedefined: +the line number where the definition of the function ends. +
  • + +
  • what: +the string "Lua" if the function is a Lua function, +"C" if it is a C function, +"main" if it is the main part of a chunk, +and "tail" if it was a function that did a tail call. +In the latter case, +Lua has no other information about the function. +
  • + +
  • currentline: +the current line where the given function is executing. +When no line information is available, +currentline is set to -1. +
  • + +
  • name: +a reasonable name for the given function. +Because functions in Lua are first-class values, +they do not have a fixed name: +some functions can be the value of multiple global variables, +while others can be stored only in a table field. +The lua_getinfo function checks how the function was +called to find a suitable name. +If it cannot find a name, +then name is set to NULL. +
  • + +
  • namewhat: +explains the name field. +The value of namewhat can be +"global", "local", "method", +"field", "upvalue", or "" (the empty string), +according to how the function was called. +(Lua uses the empty string when no other option seems to apply.) +
  • + +
  • nups: +the number of upvalues of the function. +
  • + +
+ + + + +

lua_gethook

+[-0, +0, -] +

lua_Hook lua_gethook (lua_State *L);
+ +

+Returns the current hook function. + + + + + +


lua_gethookcount

+[-0, +0, -] +

int lua_gethookcount (lua_State *L);
+ +

+Returns the current hook count. + + + + + +


lua_gethookmask

+[-0, +0, -] +

int lua_gethookmask (lua_State *L);
+ +

+Returns the current hook mask. + + + + + +


lua_getinfo

+[-(0|1), +(0|1|2), m] +

int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
+ +

+Returns information about a specific function or function invocation. + + +

+To get information about a function invocation, +the parameter ar must be a valid activation record that was +filled by a previous call to lua_getstack or +given as argument to a hook (see lua_Hook). + + +

+To get information about a function you push it onto the stack +and start the what string with the character '>'. +(In that case, +lua_getinfo pops the function in the top of the stack.) +For instance, to know in which line a function f was defined, +you can write the following code: + +

+     lua_Debug ar;
+     lua_getfield(L, LUA_GLOBALSINDEX, "f");  /* get global 'f' */
+     lua_getinfo(L, ">S", &ar);
+     printf("%d\n", ar.linedefined);
+
+ +

+Each character in the string what +selects some fields of the structure ar to be filled or +a value to be pushed on the stack: + +

    + +
  • 'n': fills in the field name and namewhat; +
  • + +
  • 'S': +fills in the fields source, short_src, +linedefined, lastlinedefined, and what; +
  • + +
  • 'l': fills in the field currentline; +
  • + +
  • 'u': fills in the field nups; +
  • + +
  • 'f': +pushes onto the stack the function that is +running at the given level; +
  • + +
  • 'L': +pushes onto the stack a table whose indices are the +numbers of the lines that are valid on the function. +(A valid line is a line with some associated code, +that is, a line where you can put a break point. +Non-valid lines include empty lines and comments.) +
  • + +
+ +

+This function returns 0 on error +(for instance, an invalid option in what). + + + + + +


lua_getlocal

+[-0, +(0|1), -] +

const char *lua_getlocal (lua_State *L, lua_Debug *ar, int n);
+ +

+Gets information about a local variable of a given activation record. +The parameter ar must be a valid activation record that was +filled by a previous call to lua_getstack or +given as argument to a hook (see lua_Hook). +The index n selects which local variable to inspect +(1 is the first parameter or active local variable, and so on, +until the last active local variable). +lua_getlocal pushes the variable's value onto the stack +and returns its name. + + +

+Variable names starting with '(' (open parentheses) +represent internal variables +(loop control variables, temporaries, and C function locals). + + +

+Returns NULL (and pushes nothing) +when the index is greater than +the number of active local variables. + + + + + +


lua_getstack

+[-0, +0, -] +

int lua_getstack (lua_State *L, int level, lua_Debug *ar);
+ +

+Get information about the interpreter runtime stack. + + +

+This function fills parts of a lua_Debug structure with +an identification of the activation record +of the function executing at a given level. +Level 0 is the current running function, +whereas level n+1 is the function that has called level n. +When there are no errors, lua_getstack returns 1; +when called with a level greater than the stack depth, +it returns 0. + + + + + +


lua_getupvalue

+[-0, +(0|1), -] +

const char *lua_getupvalue (lua_State *L, int funcindex, int n);
+ +

+Gets information about a closure's upvalue. +(For Lua functions, +upvalues are the external local variables that the function uses, +and that are consequently included in its closure.) +lua_getupvalue gets the index n of an upvalue, +pushes the upvalue's value onto the stack, +and returns its name. +funcindex points to the closure in the stack. +(Upvalues have no particular order, +as they are active through the whole function. +So, they are numbered in an arbitrary order.) + + +

+Returns NULL (and pushes nothing) +when the index is greater than the number of upvalues. +For C functions, this function uses the empty string "" +as a name for all upvalues. + + + + + +


lua_Hook

+
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+ +

+Type for debugging hook functions. + + +

+Whenever a hook is called, its ar argument has its field +event set to the specific event that triggered the hook. +Lua identifies these events with the following constants: +LUA_HOOKCALL, LUA_HOOKRET, +LUA_HOOKTAILRET, LUA_HOOKLINE, +and LUA_HOOKCOUNT. +Moreover, for line events, the field currentline is also set. +To get the value of any other field in ar, +the hook must call lua_getinfo. +For return events, event can be LUA_HOOKRET, +the normal value, or LUA_HOOKTAILRET. +In the latter case, Lua is simulating a return from +a function that did a tail call; +in this case, it is useless to call lua_getinfo. + + +

+While Lua is running a hook, it disables other calls to hooks. +Therefore, if a hook calls back Lua to execute a function or a chunk, +this execution occurs without any calls to hooks. + + + + + +


lua_sethook

+[-0, +0, -] +

int lua_sethook (lua_State *L, lua_Hook f, int mask, int count);
+ +

+Sets the debugging hook function. + + +

+Argument f is the hook function. +mask specifies on which events the hook will be called: +it is formed by a bitwise or of the constants +LUA_MASKCALL, +LUA_MASKRET, +LUA_MASKLINE, +and LUA_MASKCOUNT. +The count argument is only meaningful when the mask +includes LUA_MASKCOUNT. +For each event, the hook is called as explained below: + +

    + +
  • The call hook: is called when the interpreter calls a function. +The hook is called just after Lua enters the new function, +before the function gets its arguments. +
  • + +
  • The return hook: is called when the interpreter returns from a function. +The hook is called just before Lua leaves the function. +You have no access to the values to be returned by the function. +
  • + +
  • The line hook: is called when the interpreter is about to +start the execution of a new line of code, +or when it jumps back in the code (even to the same line). +(This event only happens while Lua is executing a Lua function.) +
  • + +
  • The count hook: is called after the interpreter executes every +count instructions. +(This event only happens while Lua is executing a Lua function.) +
  • + +
+ +

+A hook is disabled by setting mask to zero. + + + + + +


lua_setlocal

+[-(0|1), +0, -] +

const char *lua_setlocal (lua_State *L, lua_Debug *ar, int n);
+ +

+Sets the value of a local variable of a given activation record. +Parameters ar and n are as in lua_getlocal +(see lua_getlocal). +lua_setlocal assigns the value at the top of the stack +to the variable and returns its name. +It also pops the value from the stack. + + +

+Returns NULL (and pops nothing) +when the index is greater than +the number of active local variables. + + + + + +


lua_setupvalue

+[-(0|1), +0, -] +

const char *lua_setupvalue (lua_State *L, int funcindex, int n);
+ +

+Sets the value of a closure's upvalue. +It assigns the value at the top of the stack +to the upvalue and returns its name. +It also pops the value from the stack. +Parameters funcindex and n are as in the lua_getupvalue +(see lua_getupvalue). + + +

+Returns NULL (and pops nothing) +when the index is greater than the number of upvalues. + + + + + + + +

4 - The Auxiliary Library

+ +

+ +The auxiliary library provides several convenient functions +to interface C with Lua. +While the basic API provides the primitive functions for all +interactions between C and Lua, +the auxiliary library provides higher-level functions for some +common tasks. + + +

+All functions from the auxiliary library +are defined in header file lauxlib.h and +have a prefix luaL_. + + +

+All functions in the auxiliary library are built on +top of the basic API, +and so they provide nothing that cannot be done with this API. + + +

+Several functions in the auxiliary library are used to +check C function arguments. +Their names are always luaL_check* or luaL_opt*. +All of these functions throw an error if the check is not satisfied. +Because the error message is formatted for arguments +(e.g., "bad argument #1"), +you should not use these functions for other stack values. + + + +

4.1 - Functions and Types

+ +

+Here we list all functions and types from the auxiliary library +in alphabetical order. + + + +


luaL_addchar

+[-0, +0, m] +

void luaL_addchar (luaL_Buffer *B, char c);
+ +

+Adds the character c to the buffer B +(see luaL_Buffer). + + + + + +


luaL_addlstring

+[-0, +0, m] +

void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
+ +

+Adds the string pointed to by s with length l to +the buffer B +(see luaL_Buffer). +The string may contain embedded zeros. + + + + + +


luaL_addsize

+[-0, +0, m] +

void luaL_addsize (luaL_Buffer *B, size_t n);
+ +

+Adds to the buffer B (see luaL_Buffer) +a string of length n previously copied to the +buffer area (see luaL_prepbuffer). + + + + + +


luaL_addstring

+[-0, +0, m] +

void luaL_addstring (luaL_Buffer *B, const char *s);
+ +

+Adds the zero-terminated string pointed to by s +to the buffer B +(see luaL_Buffer). +The string may not contain embedded zeros. + + + + + +


luaL_addvalue

+[-1, +0, m] +

void luaL_addvalue (luaL_Buffer *B);
+ +

+Adds the value at the top of the stack +to the buffer B +(see luaL_Buffer). +Pops the value. + + +

+This is the only function on string buffers that can (and must) +be called with an extra element on the stack, +which is the value to be added to the buffer. + + + + + +


luaL_argcheck

+[-0, +0, v] +

void luaL_argcheck (lua_State *L,
+                    int cond,
+                    int narg,
+                    const char *extramsg);
+ +

+Checks whether cond is true. +If not, raises an error with the following message, +where func is retrieved from the call stack: + +

+     bad argument #<narg> to <func> (<extramsg>)
+
+ + + + +

luaL_argerror

+[-0, +0, v] +

int luaL_argerror (lua_State *L, int narg, const char *extramsg);
+ +

+Raises an error with the following message, +where func is retrieved from the call stack: + +

+     bad argument #<narg> to <func> (<extramsg>)
+
+ +

+This function never returns, +but it is an idiom to use it in C functions +as return luaL_argerror(args). + + + + + +


luaL_Buffer

+
typedef struct luaL_Buffer luaL_Buffer;
+ +

+Type for a string buffer. + + +

+A string buffer allows C code to build Lua strings piecemeal. +Its pattern of use is as follows: + +

    + +
  • First you declare a variable b of type luaL_Buffer.
  • + +
  • Then you initialize it with a call luaL_buffinit(L, &b).
  • + +
  • +Then you add string pieces to the buffer calling any of +the luaL_add* functions. +
  • + +
  • +You finish by calling luaL_pushresult(&b). +This call leaves the final string on the top of the stack. +
  • + +
+ +

+During its normal operation, +a string buffer uses a variable number of stack slots. +So, while using a buffer, you cannot assume that you know where +the top of the stack is. +You can use the stack between successive calls to buffer operations +as long as that use is balanced; +that is, +when you call a buffer operation, +the stack is at the same level +it was immediately after the previous buffer operation. +(The only exception to this rule is luaL_addvalue.) +After calling luaL_pushresult the stack is back to its +level when the buffer was initialized, +plus the final string on its top. + + + + + +


luaL_buffinit

+[-0, +0, -] +

void luaL_buffinit (lua_State *L, luaL_Buffer *B);
+ +

+Initializes a buffer B. +This function does not allocate any space; +the buffer must be declared as a variable +(see luaL_Buffer). + + + + + +


luaL_callmeta

+[-0, +(0|1), e] +

int luaL_callmeta (lua_State *L, int obj, const char *e);
+ +

+Calls a metamethod. + + +

+If the object at index obj has a metatable and this +metatable has a field e, +this function calls this field and passes the object as its only argument. +In this case this function returns 1 and pushes onto the +stack the value returned by the call. +If there is no metatable or no metamethod, +this function returns 0 (without pushing any value on the stack). + + + + + +


luaL_checkany

+[-0, +0, v] +

void luaL_checkany (lua_State *L, int narg);
+ +

+Checks whether the function has an argument +of any type (including nil) at position narg. + + + + + +


luaL_checkint

+[-0, +0, v] +

int luaL_checkint (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number cast to an int. + + + + + +


luaL_checkinteger

+[-0, +0, v] +

lua_Integer luaL_checkinteger (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number cast to a lua_Integer. + + + + + +


luaL_checklong

+[-0, +0, v] +

long luaL_checklong (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number cast to a long. + + + + + +


luaL_checklstring

+[-0, +0, v] +

const char *luaL_checklstring (lua_State *L, int narg, size_t *l);
+ +

+Checks whether the function argument narg is a string +and returns this string; +if l is not NULL fills *l +with the string's length. + + +

+This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


luaL_checknumber

+[-0, +0, v] +

lua_Number luaL_checknumber (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number. + + + + + +


luaL_checkoption

+[-0, +0, v] +

int luaL_checkoption (lua_State *L,
+                      int narg,
+                      const char *def,
+                      const char *const lst[]);
+ +

+Checks whether the function argument narg is a string and +searches for this string in the array lst +(which must be NULL-terminated). +Returns the index in the array where the string was found. +Raises an error if the argument is not a string or +if the string cannot be found. + + +

+If def is not NULL, +the function uses def as a default value when +there is no argument narg or if this argument is nil. + + +

+This is a useful function for mapping strings to C enums. +(The usual convention in Lua libraries is +to use strings instead of numbers to select options.) + + + + + +


luaL_checkstack

+[-0, +0, v] +

void luaL_checkstack (lua_State *L, int sz, const char *msg);
+ +

+Grows the stack size to top + sz elements, +raising an error if the stack cannot grow to that size. +msg is an additional text to go into the error message. + + + + + +


luaL_checkstring

+[-0, +0, v] +

const char *luaL_checkstring (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a string +and returns this string. + + +

+This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


luaL_checktype

+[-0, +0, v] +

void luaL_checktype (lua_State *L, int narg, int t);
+ +

+Checks whether the function argument narg has type t. +See lua_type for the encoding of types for t. + + + + + +


luaL_checkudata

+[-0, +0, v] +

void *luaL_checkudata (lua_State *L, int narg, const char *tname);
+ +

+Checks whether the function argument narg is a userdata +of the type tname (see luaL_newmetatable). + + + + + +


luaL_dofile

+[-0, +?, m] +

int luaL_dofile (lua_State *L, const char *filename);
+ +

+Loads and runs the given file. +It is defined as the following macro: + +

+     (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0))
+

+It returns 0 if there are no errors +or 1 in case of errors. + + + + + +


luaL_dostring

+[-0, +?, m] +

int luaL_dostring (lua_State *L, const char *str);
+ +

+Loads and runs the given string. +It is defined as the following macro: + +

+     (luaL_loadstring(L, str) || lua_pcall(L, 0, LUA_MULTRET, 0))
+

+It returns 0 if there are no errors +or 1 in case of errors. + + + + + +


luaL_error

+[-0, +0, v] +

int luaL_error (lua_State *L, const char *fmt, ...);
+ +

+Raises an error. +The error message format is given by fmt +plus any extra arguments, +following the same rules of lua_pushfstring. +It also adds at the beginning of the message the file name and +the line number where the error occurred, +if this information is available. + + +

+This function never returns, +but it is an idiom to use it in C functions +as return luaL_error(args). + + + + + +


luaL_getmetafield

+[-0, +(0|1), m] +

int luaL_getmetafield (lua_State *L, int obj, const char *e);
+ +

+Pushes onto the stack the field e from the metatable +of the object at index obj. +If the object does not have a metatable, +or if the metatable does not have this field, +returns 0 and pushes nothing. + + + + + +


luaL_getmetatable

+[-0, +1, -] +

void luaL_getmetatable (lua_State *L, const char *tname);
+ +

+Pushes onto the stack the metatable associated with name tname +in the registry (see luaL_newmetatable). + + + + + +


luaL_gsub

+[-0, +1, m] +

const char *luaL_gsub (lua_State *L,
+                       const char *s,
+                       const char *p,
+                       const char *r);
+ +

+Creates a copy of string s by replacing +any occurrence of the string p +with the string r. +Pushes the resulting string on the stack and returns it. + + + + + +


luaL_loadbuffer

+[-0, +1, m] +

int luaL_loadbuffer (lua_State *L,
+                     const char *buff,
+                     size_t sz,
+                     const char *name);
+ +

+Loads a buffer as a Lua chunk. +This function uses lua_load to load the chunk in the +buffer pointed to by buff with size sz. + + +

+This function returns the same results as lua_load. +name is the chunk name, +used for debug information and error messages. + + + + + +


luaL_loadfile

+[-0, +1, m] +

int luaL_loadfile (lua_State *L, const char *filename);
+ +

+Loads a file as a Lua chunk. +This function uses lua_load to load the chunk in the file +named filename. +If filename is NULL, +then it loads from the standard input. +The first line in the file is ignored if it starts with a #. + + +

+This function returns the same results as lua_load, +but it has an extra error code LUA_ERRFILE +if it cannot open/read the file. + + +

+As lua_load, this function only loads the chunk; +it does not run it. + + + + + +


luaL_loadstring

+[-0, +1, m] +

int luaL_loadstring (lua_State *L, const char *s);
+ +

+Loads a string as a Lua chunk. +This function uses lua_load to load the chunk in +the zero-terminated string s. + + +

+This function returns the same results as lua_load. + + +

+Also as lua_load, this function only loads the chunk; +it does not run it. + + + + + +


luaL_newmetatable

+[-0, +1, m] +

int luaL_newmetatable (lua_State *L, const char *tname);
+ +

+If the registry already has the key tname, +returns 0. +Otherwise, +creates a new table to be used as a metatable for userdata, +adds it to the registry with key tname, +and returns 1. + + +

+In both cases pushes onto the stack the final value associated +with tname in the registry. + + + + + +


luaL_newstate

+[-0, +0, -] +

lua_State *luaL_newstate (void);
+ +

+Creates a new Lua state. +It calls lua_newstate with an +allocator based on the standard C realloc function +and then sets a panic function (see lua_atpanic) that prints +an error message to the standard error output in case of fatal +errors. + + +

+Returns the new state, +or NULL if there is a memory allocation error. + + + + + +


luaL_openlibs

+[-0, +0, m] +

void luaL_openlibs (lua_State *L);
+ +

+Opens all standard Lua libraries into the given state. + + + + + +


luaL_optint

+[-0, +0, v] +

int luaL_optint (lua_State *L, int narg, int d);
+ +

+If the function argument narg is a number, +returns this number cast to an int. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optinteger

+[-0, +0, v] +

lua_Integer luaL_optinteger (lua_State *L,
+                             int narg,
+                             lua_Integer d);
+ +

+If the function argument narg is a number, +returns this number cast to a lua_Integer. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optlong

+[-0, +0, v] +

long luaL_optlong (lua_State *L, int narg, long d);
+ +

+If the function argument narg is a number, +returns this number cast to a long. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optlstring

+[-0, +0, v] +

const char *luaL_optlstring (lua_State *L,
+                             int narg,
+                             const char *d,
+                             size_t *l);
+ +

+If the function argument narg is a string, +returns this string. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + +

+If l is not NULL, +fills the position *l with the results's length. + + + + + +


luaL_optnumber

+[-0, +0, v] +

lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);
+ +

+If the function argument narg is a number, +returns this number. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optstring

+[-0, +0, v] +

const char *luaL_optstring (lua_State *L,
+                            int narg,
+                            const char *d);
+ +

+If the function argument narg is a string, +returns this string. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_prepbuffer

+[-0, +0, -] +

char *luaL_prepbuffer (luaL_Buffer *B);
+ +

+Returns an address to a space of size LUAL_BUFFERSIZE +where you can copy a string to be added to buffer B +(see luaL_Buffer). +After copying the string into this space you must call +luaL_addsize with the size of the string to actually add +it to the buffer. + + + + + +


luaL_pushresult

+[-?, +1, m] +

void luaL_pushresult (luaL_Buffer *B);
+ +

+Finishes the use of buffer B leaving the final string on +the top of the stack. + + + + + +


luaL_ref

+[-1, +0, m] +

int luaL_ref (lua_State *L, int t);
+ +

+Creates and returns a reference, +in the table at index t, +for the object at the top of the stack (and pops the object). + + +

+A reference is a unique integer key. +As long as you do not manually add integer keys into table t, +luaL_ref ensures the uniqueness of the key it returns. +You can retrieve an object referred by reference r +by calling lua_rawgeti(L, t, r). +Function luaL_unref frees a reference and its associated object. + + +

+If the object at the top of the stack is nil, +luaL_ref returns the constant LUA_REFNIL. +The constant LUA_NOREF is guaranteed to be different +from any reference returned by luaL_ref. + + + + + +


luaL_Reg

+
typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+ +

+Type for arrays of functions to be registered by +luaL_register. +name is the function name and func is a pointer to +the function. +Any array of luaL_Reg must end with an sentinel entry +in which both name and func are NULL. + + + + + +


luaL_register

+[-(0|1), +1, m] +

void luaL_register (lua_State *L,
+                    const char *libname,
+                    const luaL_Reg *l);
+ +

+Opens a library. + + +

+When called with libname equal to NULL, +it simply registers all functions in the list l +(see luaL_Reg) into the table on the top of the stack. + + +

+When called with a non-null libname, +luaL_register creates a new table t, +sets it as the value of the global variable libname, +sets it as the value of package.loaded[libname], +and registers on it all functions in the list l. +If there is a table in package.loaded[libname] or in +variable libname, +reuses this table instead of creating a new one. + + +

+In any case the function leaves the table +on the top of the stack. + + + + + +


luaL_typename

+[-0, +0, -] +

const char *luaL_typename (lua_State *L, int index);
+ +

+Returns the name of the type of the value at the given index. + + + + + +


luaL_typerror

+[-0, +0, v] +

int luaL_typerror (lua_State *L, int narg, const char *tname);
+ +

+Generates an error with a message like the following: + +

+     location: bad argument narg to 'func' (tname expected, got rt)
+

+where location is produced by luaL_where, +func is the name of the current function, +and rt is the type name of the actual argument. + + + + + +


luaL_unref

+[-0, +0, -] +

void luaL_unref (lua_State *L, int t, int ref);
+ +

+Releases reference ref from the table at index t +(see luaL_ref). +The entry is removed from the table, +so that the referred object can be collected. +The reference ref is also freed to be used again. + + +

+If ref is LUA_NOREF or LUA_REFNIL, +luaL_unref does nothing. + + + + + +


luaL_where

+[-0, +1, m] +

void luaL_where (lua_State *L, int lvl);
+ +

+Pushes onto the stack a string identifying the current position +of the control at level lvl in the call stack. +Typically this string has the following format: + +

+     chunkname:currentline:
+

+Level 0 is the running function, +level 1 is the function that called the running function, +etc. + + +

+This function is used to build a prefix for error messages. + + + + + + + +

5 - Standard Libraries

+ +

+The standard Lua libraries provide useful functions +that are implemented directly through the C API. +Some of these functions provide essential services to the language +(e.g., type and getmetatable); +others provide access to "outside" services (e.g., I/O); +and others could be implemented in Lua itself, +but are quite useful or have critical performance requirements that +deserve an implementation in C (e.g., table.sort). + + +

+All libraries are implemented through the official C API +and are provided as separate C modules. +Currently, Lua has the following standard libraries: + +

    + +
  • basic library, which includes the coroutine sub-library;
  • + +
  • package library;
  • + +
  • string manipulation;
  • + +
  • table manipulation;
  • + +
  • mathematical functions (sin, log, etc.);
  • + +
  • input and output;
  • + +
  • operating system facilities;
  • + +
  • debug facilities.
  • + +

+Except for the basic and package libraries, +each library provides all its functions as fields of a global table +or as methods of its objects. + + +

+To have access to these libraries, +the C host program should call the luaL_openlibs function, +which opens all standard libraries. +Alternatively, +it can open them individually by calling +luaopen_base (for the basic library), +luaopen_package (for the package library), +luaopen_string (for the string library), +luaopen_table (for the table library), +luaopen_math (for the mathematical library), +luaopen_io (for the I/O library), +luaopen_os (for the Operating System library), +and luaopen_debug (for the debug library). +These functions are declared in lualib.h +and should not be called directly: +you must call them like any other Lua C function, +e.g., by using lua_call. + + + +

5.1 - Basic Functions

+ +

+The basic library provides some core functions to Lua. +If you do not include this library in your application, +you should check carefully whether you need to provide +implementations for some of its facilities. + + +

+


assert (v [, message])

+Issues an error when +the value of its argument v is false (i.e., nil or false); +otherwise, returns all its arguments. +message is an error message; +when absent, it defaults to "assertion failed!" + + + + +

+


collectgarbage ([opt [, arg]])

+ + +

+This function is a generic interface to the garbage collector. +It performs different functions according to its first argument, opt: + +

    + +
  • "collect": +performs a full garbage-collection cycle. +This is the default option. +
  • + +
  • "stop": +stops the garbage collector. +
  • + +
  • "restart": +restarts the garbage collector. +
  • + +
  • "count": +returns the total memory in use by Lua (in Kbytes). +
  • + +
  • "step": +performs a garbage-collection step. +The step "size" is controlled by arg +(larger values mean more steps) in a non-specified way. +If you want to control the step size +you must experimentally tune the value of arg. +Returns true if the step finished a collection cycle. +
  • + +
  • "setpause": +sets arg as the new value for the pause of +the collector (see §2.10). +Returns the previous value for pause. +
  • + +
  • "setstepmul": +sets arg as the new value for the step multiplier of +the collector (see §2.10). +Returns the previous value for step. +
  • + +
+ + + +

+


dofile ([filename])

+Opens the named file and executes its contents as a Lua chunk. +When called without arguments, +dofile executes the contents of the standard input (stdin). +Returns all values returned by the chunk. +In case of errors, dofile propagates the error +to its caller (that is, dofile does not run in protected mode). + + + + +

+


error (message [, level])

+Terminates the last protected function called +and returns message as the error message. +Function error never returns. + + +

+Usually, error adds some information about the error position +at the beginning of the message. +The level argument specifies how to get the error position. +With level 1 (the default), the error position is where the +error function was called. +Level 2 points the error to where the function +that called error was called; and so on. +Passing a level 0 avoids the addition of error position information +to the message. + + + + +

+


_G

+A global variable (not a function) that +holds the global environment (that is, _G._G = _G). +Lua itself does not use this variable; +changing its value does not affect any environment, +nor vice-versa. +(Use setfenv to change environments.) + + + + +

+


getfenv ([f])

+Returns the current environment in use by the function. +f can be a Lua function or a number +that specifies the function at that stack level: +Level 1 is the function calling getfenv. +If the given function is not a Lua function, +or if f is 0, +getfenv returns the global environment. +The default for f is 1. + + + + +

+


getmetatable (object)

+ + +

+If object does not have a metatable, returns nil. +Otherwise, +if the object's metatable has a "__metatable" field, +returns the associated value. +Otherwise, returns the metatable of the given object. + + + + +

+


ipairs (t)

+ + +

+Returns three values: an iterator function, the table t, and 0, +so that the construction + +

+     for i,v in ipairs(t) do body end
+

+will iterate over the pairs (1,t[1]), (2,t[2]), ···, +up to the first integer key absent from the table. + + + + +

+


load (func [, chunkname])

+ + +

+Loads a chunk using function func to get its pieces. +Each call to func must return a string that concatenates +with previous results. +A return of an empty string, nil, or no value signals the end of the chunk. + + +

+If there are no errors, +returns the compiled chunk as a function; +otherwise, returns nil plus the error message. +The environment of the returned function is the global environment. + + +

+chunkname is used as the chunk name for error messages +and debug information. +When absent, +it defaults to "=(load)". + + + + +

+


loadfile ([filename])

+ + +

+Similar to load, +but gets the chunk from file filename +or from the standard input, +if no file name is given. + + + + +

+


loadstring (string [, chunkname])

+ + +

+Similar to load, +but gets the chunk from the given string. + + +

+To load and run a given string, use the idiom + +

+     assert(loadstring(s))()
+
+ +

+When absent, +chunkname defaults to the given string. + + + + +

+


next (table [, index])

+ + +

+Allows a program to traverse all fields of a table. +Its first argument is a table and its second argument +is an index in this table. +next returns the next index of the table +and its associated value. +When called with nil as its second argument, +next returns an initial index +and its associated value. +When called with the last index, +or with nil in an empty table, +next returns nil. +If the second argument is absent, then it is interpreted as nil. +In particular, +you can use next(t) to check whether a table is empty. + + +

+The order in which the indices are enumerated is not specified, +even for numeric indices. +(To traverse a table in numeric order, +use a numerical for or the ipairs function.) + + +

+The behavior of next is undefined if, +during the traversal, +you assign any value to a non-existent field in the table. +You may however modify existing fields. +In particular, you may clear existing fields. + + + + +

+


pairs (t)

+ + +

+Returns three values: the next function, the table t, and nil, +so that the construction + +

+     for k,v in pairs(t) do body end
+

+will iterate over all key–value pairs of table t. + + +

+See function next for the caveats of modifying +the table during its traversal. + + + + +

+


pcall (f, arg1, ···)

+ + +

+Calls function f with +the given arguments in protected mode. +This means that any error inside f is not propagated; +instead, pcall catches the error +and returns a status code. +Its first result is the status code (a boolean), +which is true if the call succeeds without errors. +In such case, pcall also returns all results from the call, +after this first result. +In case of any error, pcall returns false plus the error message. + + + + +

+


print (···)

+Receives any number of arguments, +and prints their values to stdout, +using the tostring function to convert them to strings. +print is not intended for formatted output, +but only as a quick way to show a value, +typically for debugging. +For formatted output, use string.format. + + + + +

+


rawequal (v1, v2)

+Checks whether v1 is equal to v2, +without invoking any metamethod. +Returns a boolean. + + + + +

+


rawget (table, index)

+Gets the real value of table[index], +without invoking any metamethod. +table must be a table; +index may be any value. + + + + +

+


rawset (table, index, value)

+Sets the real value of table[index] to value, +without invoking any metamethod. +table must be a table, +index any value different from nil, +and value any Lua value. + + +

+This function returns table. + + + + +

+


select (index, ···)

+ + +

+If index is a number, +returns all arguments after argument number index. +Otherwise, index must be the string "#", +and select returns the total number of extra arguments it received. + + + + +

+


setfenv (f, table)

+ + +

+Sets the environment to be used by the given function. +f can be a Lua function or a number +that specifies the function at that stack level: +Level 1 is the function calling setfenv. +setfenv returns the given function. + + +

+As a special case, when f is 0 setfenv changes +the environment of the running thread. +In this case, setfenv returns no values. + + + + +

+


setmetatable (table, metatable)

+ + +

+Sets the metatable for the given table. +(You cannot change the metatable of other types from Lua, only from C.) +If metatable is nil, +removes the metatable of the given table. +If the original metatable has a "__metatable" field, +raises an error. + + +

+This function returns table. + + + + +

+


tonumber (e [, base])

+Tries to convert its argument to a number. +If the argument is already a number or a string convertible +to a number, then tonumber returns this number; +otherwise, it returns nil. + + +

+An optional argument specifies the base to interpret the numeral. +The base may be any integer between 2 and 36, inclusive. +In bases above 10, the letter 'A' (in either upper or lower case) +represents 10, 'B' represents 11, and so forth, +with 'Z' representing 35. +In base 10 (the default), the number can have a decimal part, +as well as an optional exponent part (see §2.1). +In other bases, only unsigned integers are accepted. + + + + +

+


tostring (e)

+Receives an argument of any type and +converts it to a string in a reasonable format. +For complete control of how numbers are converted, +use string.format. + + +

+If the metatable of e has a "__tostring" field, +then tostring calls the corresponding value +with e as argument, +and uses the result of the call as its result. + + + + +

+


type (v)

+Returns the type of its only argument, coded as a string. +The possible results of this function are +"nil" (a string, not the value nil), +"number", +"string", +"boolean", +"table", +"function", +"thread", +and "userdata". + + + + +

+


unpack (list [, i [, j]])

+Returns the elements from the given table. +This function is equivalent to + +
+     return list[i], list[i+1], ···, list[j]
+

+except that the above code can be written only for a fixed number +of elements. +By default, i is 1 and j is the length of the list, +as defined by the length operator (see §2.5.5). + + + + +

+


_VERSION

+A global variable (not a function) that +holds a string containing the current interpreter version. +The current contents of this variable is "Lua 5.1". + + + + +

+


xpcall (f, err)

+ + +

+This function is similar to pcall, +except that you can set a new error handler. + + +

+xpcall calls function f in protected mode, +using err as the error handler. +Any error inside f is not propagated; +instead, xpcall catches the error, +calls the err function with the original error object, +and returns a status code. +Its first result is the status code (a boolean), +which is true if the call succeeds without errors. +In this case, xpcall also returns all results from the call, +after this first result. +In case of any error, +xpcall returns false plus the result from err. + + + + + + + +

5.2 - Coroutine Manipulation

+ +

+The operations related to coroutines comprise a sub-library of +the basic library and come inside the table coroutine. +See §2.11 for a general description of coroutines. + + +

+


coroutine.create (f)

+ + +

+Creates a new coroutine, with body f. +f must be a Lua function. +Returns this new coroutine, +an object with type "thread". + + + + +

+


coroutine.resume (co [, val1, ···])

+ + +

+Starts or continues the execution of coroutine co. +The first time you resume a coroutine, +it starts running its body. +The values val1, ··· are passed +as the arguments to the body function. +If the coroutine has yielded, +resume restarts it; +the values val1, ··· are passed +as the results from the yield. + + +

+If the coroutine runs without any errors, +resume returns true plus any values passed to yield +(if the coroutine yields) or any values returned by the body function +(if the coroutine terminates). +If there is any error, +resume returns false plus the error message. + + + + +

+


coroutine.running ()

+ + +

+Returns the running coroutine, +or nil when called by the main thread. + + + + +

+


coroutine.status (co)

+ + +

+Returns the status of coroutine co, as a string: +"running", +if the coroutine is running (that is, it called status); +"suspended", if the coroutine is suspended in a call to yield, +or if it has not started running yet; +"normal" if the coroutine is active but not running +(that is, it has resumed another coroutine); +and "dead" if the coroutine has finished its body function, +or if it has stopped with an error. + + + + +

+


coroutine.wrap (f)

+ + +

+Creates a new coroutine, with body f. +f must be a Lua function. +Returns a function that resumes the coroutine each time it is called. +Any arguments passed to the function behave as the +extra arguments to resume. +Returns the same values returned by resume, +except the first boolean. +In case of error, propagates the error. + + + + +

+


coroutine.yield (···)

+ + +

+Suspends the execution of the calling coroutine. +The coroutine cannot be running a C function, +a metamethod, or an iterator. +Any arguments to yield are passed as extra results to resume. + + + + + + + +

5.3 - Modules

+ +

+The package library provides basic +facilities for loading and building modules in Lua. +It exports two of its functions directly in the global environment: +require and module. +Everything else is exported in a table package. + + +

+


module (name [, ···])

+ + +

+Creates a module. +If there is a table in package.loaded[name], +this table is the module. +Otherwise, if there is a global table t with the given name, +this table is the module. +Otherwise creates a new table t and +sets it as the value of the global name and +the value of package.loaded[name]. +This function also initializes t._NAME with the given name, +t._M with the module (t itself), +and t._PACKAGE with the package name +(the full module name minus last component; see below). +Finally, module sets t as the new environment +of the current function and the new value of package.loaded[name], +so that require returns t. + + +

+If name is a compound name +(that is, one with components separated by dots), +module creates (or reuses, if they already exist) +tables for each component. +For instance, if name is a.b.c, +then module stores the module table in field c of +field b of global a. + + +

+This function can receive optional options after +the module name, +where each option is a function to be applied over the module. + + + + +

+


require (modname)

+ + +

+Loads the given module. +The function starts by looking into the package.loaded table +to determine whether modname is already loaded. +If it is, then require returns the value stored +at package.loaded[modname]. +Otherwise, it tries to find a loader for the module. + + +

+To find a loader, +require is guided by the package.loaders array. +By changing this array, +we can change how require looks for a module. +The following explanation is based on the default configuration +for package.loaders. + + +

+First require queries package.preload[modname]. +If it has a value, +this value (which should be a function) is the loader. +Otherwise require searches for a Lua loader using the +path stored in package.path. +If that also fails, it searches for a C loader using the +path stored in package.cpath. +If that also fails, +it tries an all-in-one loader (see package.loaders). + + +

+Once a loader is found, +require calls the loader with a single argument, modname. +If the loader returns any value, +require assigns the returned value to package.loaded[modname]. +If the loader returns no value and +has not assigned any value to package.loaded[modname], +then require assigns true to this entry. +In any case, require returns the +final value of package.loaded[modname]. + + +

+If there is any error loading or running the module, +or if it cannot find any loader for the module, +then require signals an error. + + + + +

+


package.cpath

+ + +

+The path used by require to search for a C loader. + + +

+Lua initializes the C path package.cpath in the same way +it initializes the Lua path package.path, +using the environment variable LUA_CPATH +or a default path defined in luaconf.h. + + + + +

+ +


package.loaded

+ + +

+A table used by require to control which +modules are already loaded. +When you require a module modname and +package.loaded[modname] is not false, +require simply returns the value stored there. + + + + +

+


package.loaders

+ + +

+A table used by require to control how to load modules. + + +

+Each entry in this table is a searcher function. +When looking for a module, +require calls each of these searchers in ascending order, +with the module name (the argument given to require) as its +sole parameter. +The function can return another function (the module loader) +or a string explaining why it did not find that module +(or nil if it has nothing to say). +Lua initializes this table with four functions. + + +

+The first searcher simply looks for a loader in the +package.preload table. + + +

+The second searcher looks for a loader as a Lua library, +using the path stored at package.path. +A path is a sequence of templates separated by semicolons. +For each template, +the searcher will change each interrogation +mark in the template by filename, +which is the module name with each dot replaced by a +"directory separator" (such as "/" in Unix); +then it will try to open the resulting file name. +So, for instance, if the Lua path is the string + +

+     "./?.lua;./?.lc;/usr/local/?/init.lua"
+

+the search for a Lua file for module foo +will try to open the files +./foo.lua, ./foo.lc, and +/usr/local/foo/init.lua, in that order. + + +

+The third searcher looks for a loader as a C library, +using the path given by the variable package.cpath. +For instance, +if the C path is the string + +

+     "./?.so;./?.dll;/usr/local/?/init.so"
+

+the searcher for module foo +will try to open the files ./foo.so, ./foo.dll, +and /usr/local/foo/init.so, in that order. +Once it finds a C library, +this searcher first uses a dynamic link facility to link the +application with the library. +Then it tries to find a C function inside the library to +be used as the loader. +The name of this C function is the string "luaopen_" +concatenated with a copy of the module name where each dot +is replaced by an underscore. +Moreover, if the module name has a hyphen, +its prefix up to (and including) the first hyphen is removed. +For instance, if the module name is a.v1-b.c, +the function name will be luaopen_b_c. + + +

+The fourth searcher tries an all-in-one loader. +It searches the C path for a library for +the root name of the given module. +For instance, when requiring a.b.c, +it will search for a C library for a. +If found, it looks into it for an open function for +the submodule; +in our example, that would be luaopen_a_b_c. +With this facility, a package can pack several C submodules +into one single library, +with each submodule keeping its original open function. + + + + +

+


package.loadlib (libname, funcname)

+ + +

+Dynamically links the host program with the C library libname. +Inside this library, looks for a function funcname +and returns this function as a C function. +(So, funcname must follow the protocol (see lua_CFunction)). + + +

+This is a low-level function. +It completely bypasses the package and module system. +Unlike require, +it does not perform any path searching and +does not automatically adds extensions. +libname must be the complete file name of the C library, +including if necessary a path and extension. +funcname must be the exact name exported by the C library +(which may depend on the C compiler and linker used). + + +

+This function is not supported by ANSI C. +As such, it is only available on some platforms +(Windows, Linux, Mac OS X, Solaris, BSD, +plus other Unix systems that support the dlfcn standard). + + + + +

+


package.path

+ + +

+The path used by require to search for a Lua loader. + + +

+At start-up, Lua initializes this variable with +the value of the environment variable LUA_PATH or +with a default path defined in luaconf.h, +if the environment variable is not defined. +Any ";;" in the value of the environment variable +is replaced by the default path. + + + + +

+


package.preload

+ + +

+A table to store loaders for specific modules +(see require). + + + + +

+


package.seeall (module)

+ + +

+Sets a metatable for module with +its __index field referring to the global environment, +so that this module inherits values +from the global environment. +To be used as an option to function module. + + + + + + + +

5.4 - String Manipulation

+ +

+This library provides generic functions for string manipulation, +such as finding and extracting substrings, and pattern matching. +When indexing a string in Lua, the first character is at position 1 +(not at 0, as in C). +Indices are allowed to be negative and are interpreted as indexing backwards, +from the end of the string. +Thus, the last character is at position -1, and so on. + + +

+The string library provides all its functions inside the table +string. +It also sets a metatable for strings +where the __index field points to the string table. +Therefore, you can use the string functions in object-oriented style. +For instance, string.byte(s, i) +can be written as s:byte(i). + + +

+The string library assumes one-byte character encodings. + + +

+


string.byte (s [, i [, j]])

+Returns the internal numerical codes of the characters s[i], +s[i+1], ···, s[j]. +The default value for i is 1; +the default value for j is i. + + +

+Note that numerical codes are not necessarily portable across platforms. + + + + +

+


string.char (···)

+Receives zero or more integers. +Returns a string with length equal to the number of arguments, +in which each character has the internal numerical code equal +to its corresponding argument. + + +

+Note that numerical codes are not necessarily portable across platforms. + + + + +

+


string.dump (function)

+ + +

+Returns a string containing a binary representation of the given function, +so that a later loadstring on this string returns +a copy of the function. +function must be a Lua function without upvalues. + + + + +

+


string.find (s, pattern [, init [, plain]])

+Looks for the first match of +pattern in the string s. +If it finds a match, then find returns the indices of s +where this occurrence starts and ends; +otherwise, it returns nil. +A third, optional numerical argument init specifies +where to start the search; +its default value is 1 and can be negative. +A value of true as a fourth, optional argument plain +turns off the pattern matching facilities, +so the function does a plain "find substring" operation, +with no characters in pattern being considered "magic". +Note that if plain is given, then init must be given as well. + + +

+If the pattern has captures, +then in a successful match +the captured values are also returned, +after the two indices. + + + + +

+


string.format (formatstring, ···)

+Returns a formatted version of its variable number of arguments +following the description given in its first argument (which must be a string). +The format string follows the same rules as the printf family of +standard C functions. +The only differences are that the options/modifiers +*, l, L, n, p, +and h are not supported +and that there is an extra option, q. +The q option formats a string in a form suitable to be safely read +back by the Lua interpreter: +the string is written between double quotes, +and all double quotes, newlines, embedded zeros, +and backslashes in the string +are correctly escaped when written. +For instance, the call + +
+     string.format('%q', 'a string with "quotes" and \n new line')
+

+will produce the string: + +

+     "a string with \"quotes\" and \
+      new line"
+
+ +

+The options c, d, E, e, f, +g, G, i, o, u, X, and x all +expect a number as argument, +whereas q and s expect a string. + + +

+This function does not accept string values +containing embedded zeros, +except as arguments to the q option. + + + + +

+


string.gmatch (s, pattern)

+Returns an iterator function that, +each time it is called, +returns the next captures from pattern over string s. +If pattern specifies no captures, +then the whole match is produced in each call. + + +

+As an example, the following loop + +

+     s = "hello world from Lua"
+     for w in string.gmatch(s, "%a+") do
+       print(w)
+     end
+

+will iterate over all the words from string s, +printing one per line. +The next example collects all pairs key=value from the +given string into a table: + +

+     t = {}
+     s = "from=world, to=Lua"
+     for k, v in string.gmatch(s, "(%w+)=(%w+)") do
+       t[k] = v
+     end
+
+ +

+For this function, a '^' at the start of a pattern does not +work as an anchor, as this would prevent the iteration. + + + + +

+


string.gsub (s, pattern, repl [, n])

+Returns a copy of s +in which all (or the first n, if given) +occurrences of the pattern have been +replaced by a replacement string specified by repl, +which can be a string, a table, or a function. +gsub also returns, as its second value, +the total number of matches that occurred. + + +

+If repl is a string, then its value is used for replacement. +The character % works as an escape character: +any sequence in repl of the form %n, +with n between 1 and 9, +stands for the value of the n-th captured substring (see below). +The sequence %0 stands for the whole match. +The sequence %% stands for a single %. + + +

+If repl is a table, then the table is queried for every match, +using the first capture as the key; +if the pattern specifies no captures, +then the whole match is used as the key. + + +

+If repl is a function, then this function is called every time a +match occurs, with all captured substrings passed as arguments, +in order; +if the pattern specifies no captures, +then the whole match is passed as a sole argument. + + +

+If the value returned by the table query or by the function call +is a string or a number, +then it is used as the replacement string; +otherwise, if it is false or nil, +then there is no replacement +(that is, the original match is kept in the string). + + +

+Here are some examples: + +

+     x = string.gsub("hello world", "(%w+)", "%1 %1")
+     --> x="hello hello world world"
+     
+     x = string.gsub("hello world", "%w+", "%0 %0", 1)
+     --> x="hello hello world"
+     
+     x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
+     --> x="world hello Lua from"
+     
+     x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
+     --> x="home = /home/roberto, user = roberto"
+     
+     x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
+           return loadstring(s)()
+         end)
+     --> x="4+5 = 9"
+     
+     local t = {name="lua", version="5.1"}
+     x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
+     --> x="lua-5.1.tar.gz"
+
+ + + +

+


string.len (s)

+Receives a string and returns its length. +The empty string "" has length 0. +Embedded zeros are counted, +so "a\000bc\000" has length 5. + + + + +

+


string.lower (s)

+Receives a string and returns a copy of this string with all +uppercase letters changed to lowercase. +All other characters are left unchanged. +The definition of what an uppercase letter is depends on the current locale. + + + + +

+


string.match (s, pattern [, init])

+Looks for the first match of +pattern in the string s. +If it finds one, then match returns +the captures from the pattern; +otherwise it returns nil. +If pattern specifies no captures, +then the whole match is returned. +A third, optional numerical argument init specifies +where to start the search; +its default value is 1 and can be negative. + + + + +

+


string.rep (s, n)

+Returns a string that is the concatenation of n copies of +the string s. + + + + +

+


string.reverse (s)

+Returns a string that is the string s reversed. + + + + +

+


string.sub (s, i [, j])

+Returns the substring of s that +starts at i and continues until j; +i and j can be negative. +If j is absent, then it is assumed to be equal to -1 +(which is the same as the string length). +In particular, +the call string.sub(s,1,j) returns a prefix of s +with length j, +and string.sub(s, -i) returns a suffix of s +with length i. + + + + +

+


string.upper (s)

+Receives a string and returns a copy of this string with all +lowercase letters changed to uppercase. +All other characters are left unchanged. +The definition of what a lowercase letter is depends on the current locale. + + + +

5.4.1 - Patterns

+ + +

Character Class:

+A character class is used to represent a set of characters. +The following combinations are allowed in describing a character class: + +

    + +
  • x: +(where x is not one of the magic characters +^$()%.[]*+-?) +represents the character x itself. +
  • + +
  • .: (a dot) represents all characters.
  • + +
  • %a: represents all letters.
  • + +
  • %c: represents all control characters.
  • + +
  • %d: represents all digits.
  • + +
  • %l: represents all lowercase letters.
  • + +
  • %p: represents all punctuation characters.
  • + +
  • %s: represents all space characters.
  • + +
  • %u: represents all uppercase letters.
  • + +
  • %w: represents all alphanumeric characters.
  • + +
  • %x: represents all hexadecimal digits.
  • + +
  • %z: represents the character with representation 0.
  • + +
  • %x: (where x is any non-alphanumeric character) +represents the character x. +This is the standard way to escape the magic characters. +Any punctuation character (even the non magic) +can be preceded by a '%' +when used to represent itself in a pattern. +
  • + +
  • [set]: +represents the class which is the union of all +characters in set. +A range of characters can be specified by +separating the end characters of the range with a '-'. +All classes %x described above can also be used as +components in set. +All other characters in set represent themselves. +For example, [%w_] (or [_%w]) +represents all alphanumeric characters plus the underscore, +[0-7] represents the octal digits, +and [0-7%l%-] represents the octal digits plus +the lowercase letters plus the '-' character. + + +

    +The interaction between ranges and classes is not defined. +Therefore, patterns like [%a-z] or [a-%%] +have no meaning. +

  • + +
  • [^set]: +represents the complement of set, +where set is interpreted as above. +
  • + +

+For all classes represented by single letters (%a, %c, etc.), +the corresponding uppercase letter represents the complement of the class. +For instance, %S represents all non-space characters. + + +

+The definitions of letter, space, and other character groups +depend on the current locale. +In particular, the class [a-z] may not be equivalent to %l. + + + + + +

Pattern Item:

+A pattern item can be + +

    + +
  • +a single character class, +which matches any single character in the class; +
  • + +
  • +a single character class followed by '*', +which matches 0 or more repetitions of characters in the class. +These repetition items will always match the longest possible sequence; +
  • + +
  • +a single character class followed by '+', +which matches 1 or more repetitions of characters in the class. +These repetition items will always match the longest possible sequence; +
  • + +
  • +a single character class followed by '-', +which also matches 0 or more repetitions of characters in the class. +Unlike '*', +these repetition items will always match the shortest possible sequence; +
  • + +
  • +a single character class followed by '?', +which matches 0 or 1 occurrence of a character in the class; +
  • + +
  • +%n, for n between 1 and 9; +such item matches a substring equal to the n-th captured string +(see below); +
  • + +
  • +%bxy, where x and y are two distinct characters; +such item matches strings that start with x, end with y, +and where the x and y are balanced. +This means that, if one reads the string from left to right, +counting +1 for an x and -1 for a y, +the ending y is the first y where the count reaches 0. +For instance, the item %b() matches expressions with +balanced parentheses. +
  • + +
+ + + + +

Pattern:

+A pattern is a sequence of pattern items. +A '^' at the beginning of a pattern anchors the match at the +beginning of the subject string. +A '$' at the end of a pattern anchors the match at the +end of the subject string. +At other positions, +'^' and '$' have no special meaning and represent themselves. + + + + + +

Captures:

+A pattern can contain sub-patterns enclosed in parentheses; +they describe captures. +When a match succeeds, the substrings of the subject string +that match captures are stored (captured) for future use. +Captures are numbered according to their left parentheses. +For instance, in the pattern "(a*(.)%w(%s*))", +the part of the string matching "a*(.)%w(%s*)" is +stored as the first capture (and therefore has number 1); +the character matching "." is captured with number 2, +and the part matching "%s*" has number 3. + + +

+As a special case, the empty capture () captures +the current string position (a number). +For instance, if we apply the pattern "()aa()" on the +string "flaaap", there will be two captures: 3 and 5. + + +

+A pattern cannot contain embedded zeros. Use %z instead. + + + + + + + + + + + +

5.5 - Table Manipulation

+This library provides generic functions for table manipulation. +It provides all its functions inside the table table. + + +

+Most functions in the table library assume that the table +represents an array or a list. +For these functions, when we talk about the "length" of a table +we mean the result of the length operator. + + +

+


table.concat (table [, sep [, i [, j]]])

+Given an array where all elements are strings or numbers, +returns table[i]..sep..table[i+1] ··· sep..table[j]. +The default value for sep is the empty string, +the default for i is 1, +and the default for j is the length of the table. +If i is greater than j, returns the empty string. + + + + +

+


table.insert (table, [pos,] value)

+ + +

+Inserts element value at position pos in table, +shifting up other elements to open space, if necessary. +The default value for pos is n+1, +where n is the length of the table (see §2.5.5), +so that a call table.insert(t,x) inserts x at the end +of table t. + + + + +

+


table.maxn (table)

+ + +

+Returns the largest positive numerical index of the given table, +or zero if the table has no positive numerical indices. +(To do its job this function does a linear traversal of +the whole table.) + + + + +

+


table.remove (table [, pos])

+ + +

+Removes from table the element at position pos, +shifting down other elements to close the space, if necessary. +Returns the value of the removed element. +The default value for pos is n, +where n is the length of the table, +so that a call table.remove(t) removes the last element +of table t. + + + + +

+


table.sort (table [, comp])

+Sorts table elements in a given order, in-place, +from table[1] to table[n], +where n is the length of the table. +If comp is given, +then it must be a function that receives two table elements, +and returns true +when the first is less than the second +(so that not comp(a[i+1],a[i]) will be true after the sort). +If comp is not given, +then the standard Lua operator < is used instead. + + +

+The sort algorithm is not stable; +that is, elements considered equal by the given order +may have their relative positions changed by the sort. + + + + + + + +

5.6 - Mathematical Functions

+ +

+This library is an interface to the standard C math library. +It provides all its functions inside the table math. + + +

+


math.abs (x)

+ + +

+Returns the absolute value of x. + + + + +

+


math.acos (x)

+ + +

+Returns the arc cosine of x (in radians). + + + + +

+


math.asin (x)

+ + +

+Returns the arc sine of x (in radians). + + + + +

+


math.atan (x)

+ + +

+Returns the arc tangent of x (in radians). + + + + +

+


math.atan2 (y, x)

+ + +

+Returns the arc tangent of y/x (in radians), +but uses the signs of both parameters to find the +quadrant of the result. +(It also handles correctly the case of x being zero.) + + + + +

+


math.ceil (x)

+ + +

+Returns the smallest integer larger than or equal to x. + + + + +

+


math.cos (x)

+ + +

+Returns the cosine of x (assumed to be in radians). + + + + +

+


math.cosh (x)

+ + +

+Returns the hyperbolic cosine of x. + + + + +

+


math.deg (x)

+ + +

+Returns the angle x (given in radians) in degrees. + + + + +

+


math.exp (x)

+ + +

+Returns the value ex. + + + + +

+


math.floor (x)

+ + +

+Returns the largest integer smaller than or equal to x. + + + + +

+


math.fmod (x, y)

+ + +

+Returns the remainder of the division of x by y +that rounds the quotient towards zero. + + + + +

+


math.frexp (x)

+ + +

+Returns m and e such that x = m2e, +e is an integer and the absolute value of m is +in the range [0.5, 1) +(or zero when x is zero). + + + + +

+


math.huge

+ + +

+The value HUGE_VAL, +a value larger than or equal to any other numerical value. + + + + +

+


math.ldexp (m, e)

+ + +

+Returns m2e (e should be an integer). + + + + +

+


math.log (x)

+ + +

+Returns the natural logarithm of x. + + + + +

+


math.log10 (x)

+ + +

+Returns the base-10 logarithm of x. + + + + +

+


math.max (x, ···)

+ + +

+Returns the maximum value among its arguments. + + + + +

+


math.min (x, ···)

+ + +

+Returns the minimum value among its arguments. + + + + +

+


math.modf (x)

+ + +

+Returns two numbers, +the integral part of x and the fractional part of x. + + + + +

+


math.pi

+ + +

+The value of pi. + + + + +

+


math.pow (x, y)

+ + +

+Returns xy. +(You can also use the expression x^y to compute this value.) + + + + +

+


math.rad (x)

+ + +

+Returns the angle x (given in degrees) in radians. + + + + +

+


math.random ([m [, n]])

+ + +

+This function is an interface to the simple +pseudo-random generator function rand provided by ANSI C. +(No guarantees can be given for its statistical properties.) + + +

+When called without arguments, +returns a uniform pseudo-random real number +in the range [0,1). +When called with an integer number m, +math.random returns +a uniform pseudo-random integer in the range [1, m]. +When called with two integer numbers m and n, +math.random returns a uniform pseudo-random +integer in the range [m, n]. + + + + +

+


math.randomseed (x)

+ + +

+Sets x as the "seed" +for the pseudo-random generator: +equal seeds produce equal sequences of numbers. + + + + +

+


math.sin (x)

+ + +

+Returns the sine of x (assumed to be in radians). + + + + +

+


math.sinh (x)

+ + +

+Returns the hyperbolic sine of x. + + + + +

+


math.sqrt (x)

+ + +

+Returns the square root of x. +(You can also use the expression x^0.5 to compute this value.) + + + + +

+


math.tan (x)

+ + +

+Returns the tangent of x (assumed to be in radians). + + + + +

+


math.tanh (x)

+ + +

+Returns the hyperbolic tangent of x. + + + + + + + +

5.7 - Input and Output Facilities

+ +

+The I/O library provides two different styles for file manipulation. +The first one uses implicit file descriptors; +that is, there are operations to set a default input file and a +default output file, +and all input/output operations are over these default files. +The second style uses explicit file descriptors. + + +

+When using implicit file descriptors, +all operations are supplied by table io. +When using explicit file descriptors, +the operation io.open returns a file descriptor +and then all operations are supplied as methods of the file descriptor. + + +

+The table io also provides +three predefined file descriptors with their usual meanings from C: +io.stdin, io.stdout, and io.stderr. +The I/O library never closes these files. + + +

+Unless otherwise stated, +all I/O functions return nil on failure +(plus an error message as a second result and +a system-dependent error code as a third result) +and some value different from nil on success. + + +

+


io.close ([file])

+ + +

+Equivalent to file:close(). +Without a file, closes the default output file. + + + + +

+


io.flush ()

+ + +

+Equivalent to file:flush over the default output file. + + + + +

+


io.input ([file])

+ + +

+When called with a file name, it opens the named file (in text mode), +and sets its handle as the default input file. +When called with a file handle, +it simply sets this file handle as the default input file. +When called without parameters, +it returns the current default input file. + + +

+In case of errors this function raises the error, +instead of returning an error code. + + + + +

+


io.lines ([filename])

+ + +

+Opens the given file name in read mode +and returns an iterator function that, +each time it is called, +returns a new line from the file. +Therefore, the construction + +

+     for line in io.lines(filename) do body end
+

+will iterate over all lines of the file. +When the iterator function detects the end of file, +it returns nil (to finish the loop) and automatically closes the file. + + +

+The call io.lines() (with no file name) is equivalent +to io.input():lines(); +that is, it iterates over the lines of the default input file. +In this case it does not close the file when the loop ends. + + + + +

+


io.open (filename [, mode])

+ + +

+This function opens a file, +in the mode specified in the string mode. +It returns a new file handle, +or, in case of errors, nil plus an error message. + + +

+The mode string can be any of the following: + +

    +
  • "r": read mode (the default);
  • +
  • "w": write mode;
  • +
  • "a": append mode;
  • +
  • "r+": update mode, all previous data is preserved;
  • +
  • "w+": update mode, all previous data is erased;
  • +
  • "a+": append update mode, previous data is preserved, + writing is only allowed at the end of file.
  • +

+The mode string can also have a 'b' at the end, +which is needed in some systems to open the file in binary mode. +This string is exactly what is used in the +standard C function fopen. + + + + +

+


io.output ([file])

+ + +

+Similar to io.input, but operates over the default output file. + + + + +

+


io.popen (prog [, mode])

+ + +

+Starts program prog in a separated process and returns +a file handle that you can use to read data from this program +(if mode is "r", the default) +or to write data to this program +(if mode is "w"). + + +

+This function is system dependent and is not available +on all platforms. + + + + +

+


io.read (···)

+ + +

+Equivalent to io.input():read. + + + + +

+


io.tmpfile ()

+ + +

+Returns a handle for a temporary file. +This file is opened in update mode +and it is automatically removed when the program ends. + + + + +

+


io.type (obj)

+ + +

+Checks whether obj is a valid file handle. +Returns the string "file" if obj is an open file handle, +"closed file" if obj is a closed file handle, +or nil if obj is not a file handle. + + + + +

+


io.write (···)

+ + +

+Equivalent to io.output():write. + + + + +

+


file:close ()

+ + +

+Closes file. +Note that files are automatically closed when +their handles are garbage collected, +but that takes an unpredictable amount of time to happen. + + + + +

+


file:flush ()

+ + +

+Saves any written data to file. + + + + +

+


file:lines ()

+ + +

+Returns an iterator function that, +each time it is called, +returns a new line from the file. +Therefore, the construction + +

+     for line in file:lines() do body end
+

+will iterate over all lines of the file. +(Unlike io.lines, this function does not close the file +when the loop ends.) + + + + +

+


file:read (···)

+ + +

+Reads the file file, +according to the given formats, which specify what to read. +For each format, +the function returns a string (or a number) with the characters read, +or nil if it cannot read data with the specified format. +When called without formats, +it uses a default format that reads the entire next line +(see below). + + +

+The available formats are + +

    + +
  • "*n": +reads a number; +this is the only format that returns a number instead of a string. +
  • + +
  • "*a": +reads the whole file, starting at the current position. +On end of file, it returns the empty string. +
  • + +
  • "*l": +reads the next line (skipping the end of line), +returning nil on end of file. +This is the default format. +
  • + +
  • number: +reads a string with up to this number of characters, +returning nil on end of file. +If number is zero, +it reads nothing and returns an empty string, +or nil on end of file. +
  • + +
+ + + +

+


file:seek ([whence] [, offset])

+ + +

+Sets and gets the file position, +measured from the beginning of the file, +to the position given by offset plus a base +specified by the string whence, as follows: + +

    +
  • "set": base is position 0 (beginning of the file);
  • +
  • "cur": base is current position;
  • +
  • "end": base is end of file;
  • +

+In case of success, function seek returns the final file position, +measured in bytes from the beginning of the file. +If this function fails, it returns nil, +plus a string describing the error. + + +

+The default value for whence is "cur", +and for offset is 0. +Therefore, the call file:seek() returns the current +file position, without changing it; +the call file:seek("set") sets the position to the +beginning of the file (and returns 0); +and the call file:seek("end") sets the position to the +end of the file, and returns its size. + + + + +

+


file:setvbuf (mode [, size])

+ + +

+Sets the buffering mode for an output file. +There are three available modes: + +

    + +
  • "no": +no buffering; the result of any output operation appears immediately. +
  • + +
  • "full": +full buffering; output operation is performed only +when the buffer is full (or when you explicitly flush the file +(see io.flush)). +
  • + +
  • "line": +line buffering; output is buffered until a newline is output +or there is any input from some special files +(such as a terminal device). +
  • + +

+For the last two cases, size +specifies the size of the buffer, in bytes. +The default is an appropriate size. + + + + +

+


file:write (···)

+ + +

+Writes the value of each of its arguments to +the file. +The arguments must be strings or numbers. +To write other values, +use tostring or string.format before write. + + + + + + + +

5.8 - Operating System Facilities

+ +

+This library is implemented through table os. + + +

+


os.clock ()

+ + +

+Returns an approximation of the amount in seconds of CPU time +used by the program. + + + + +

+


os.date ([format [, time]])

+ + +

+Returns a string or a table containing date and time, +formatted according to the given string format. + + +

+If the time argument is present, +this is the time to be formatted +(see the os.time function for a description of this value). +Otherwise, date formats the current time. + + +

+If format starts with '!', +then the date is formatted in Coordinated Universal Time. +After this optional character, +if format is the string "*t", +then date returns a table with the following fields: +year (four digits), month (1--12), day (1--31), +hour (0--23), min (0--59), sec (0--61), +wday (weekday, Sunday is 1), +yday (day of the year), +and isdst (daylight saving flag, a boolean). + + +

+If format is not "*t", +then date returns the date as a string, +formatted according to the same rules as the C function strftime. + + +

+When called without arguments, +date returns a reasonable date and time representation that depends on +the host system and on the current locale +(that is, os.date() is equivalent to os.date("%c")). + + + + +

+


os.difftime (t2, t1)

+ + +

+Returns the number of seconds from time t1 to time t2. +In POSIX, Windows, and some other systems, +this value is exactly t2-t1. + + + + +

+


os.execute ([command])

+ + +

+This function is equivalent to the C function system. +It passes command to be executed by an operating system shell. +It returns a status code, which is system-dependent. +If command is absent, then it returns nonzero if a shell is available +and zero otherwise. + + + + +

+


os.exit ([code])

+ + +

+Calls the C function exit, +with an optional code, +to terminate the host program. +The default value for code is the success code. + + + + +

+


os.getenv (varname)

+ + +

+Returns the value of the process environment variable varname, +or nil if the variable is not defined. + + + + +

+


os.remove (filename)

+ + +

+Deletes the file or directory with the given name. +Directories must be empty to be removed. +If this function fails, it returns nil, +plus a string describing the error. + + + + +

+


os.rename (oldname, newname)

+ + +

+Renames file or directory named oldname to newname. +If this function fails, it returns nil, +plus a string describing the error. + + + + +

+


os.setlocale (locale [, category])

+ + +

+Sets the current locale of the program. +locale is a string specifying a locale; +category is an optional string describing which category to change: +"all", "collate", "ctype", +"monetary", "numeric", or "time"; +the default category is "all". +The function returns the name of the new locale, +or nil if the request cannot be honored. + + +

+If locale is the empty string, +the current locale is set to an implementation-defined native locale. +If locale is the string "C", +the current locale is set to the standard C locale. + + +

+When called with nil as the first argument, +this function only returns the name of the current locale +for the given category. + + + + +

+


os.time ([table])

+ + +

+Returns the current time when called without arguments, +or a time representing the date and time specified by the given table. +This table must have fields year, month, and day, +and may have fields hour, min, sec, and isdst +(for a description of these fields, see the os.date function). + + +

+The returned value is a number, whose meaning depends on your system. +In POSIX, Windows, and some other systems, this number counts the number +of seconds since some given start time (the "epoch"). +In other systems, the meaning is not specified, +and the number returned by time can be used only as an argument to +date and difftime. + + + + +

+


os.tmpname ()

+ + +

+Returns a string with a file name that can +be used for a temporary file. +The file must be explicitly opened before its use +and explicitly removed when no longer needed. + + +

+On some systems (POSIX), +this function also creates a file with that name, +to avoid security risks. +(Someone else might create the file with wrong permissions +in the time between getting the name and creating the file.) +You still have to open the file to use it +and to remove it (even if you do not use it). + + +

+When possible, +you may prefer to use io.tmpfile, +which automatically removes the file when the program ends. + + + + + + + +

5.9 - The Debug Library

+ +

+This library provides +the functionality of the debug interface to Lua programs. +You should exert care when using this library. +The functions provided here should be used exclusively for debugging +and similar tasks, such as profiling. +Please resist the temptation to use them as a +usual programming tool: +they can be very slow. +Moreover, several of these functions +violate some assumptions about Lua code +(e.g., that variables local to a function +cannot be accessed from outside or +that userdata metatables cannot be changed by Lua code) +and therefore can compromise otherwise secure code. + + +

+All functions in this library are provided +inside the debug table. +All functions that operate over a thread +have an optional first argument which is the +thread to operate over. +The default is always the current thread. + + +

+


debug.debug ()

+ + +

+Enters an interactive mode with the user, +running each string that the user enters. +Using simple commands and other debug facilities, +the user can inspect global and local variables, +change their values, evaluate expressions, and so on. +A line containing only the word cont finishes this function, +so that the caller continues its execution. + + +

+Note that commands for debug.debug are not lexically nested +within any function, and so have no direct access to local variables. + + + + +

+


debug.getfenv (o)

+Returns the environment of object o. + + + + +

+


debug.gethook ([thread])

+ + +

+Returns the current hook settings of the thread, as three values: +the current hook function, the current hook mask, +and the current hook count +(as set by the debug.sethook function). + + + + +

+


debug.getinfo ([thread,] function [, what])

+ + +

+Returns a table with information about a function. +You can give the function directly, +or you can give a number as the value of function, +which means the function running at level function of the call stack +of the given thread: +level 0 is the current function (getinfo itself); +level 1 is the function that called getinfo; +and so on. +If function is a number larger than the number of active functions, +then getinfo returns nil. + + +

+The returned table can contain all the fields returned by lua_getinfo, +with the string what describing which fields to fill in. +The default for what is to get all information available, +except the table of valid lines. +If present, +the option 'f' +adds a field named func with the function itself. +If present, +the option 'L' +adds a field named activelines with the table of +valid lines. + + +

+For instance, the expression debug.getinfo(1,"n").name returns +a table with a name for the current function, +if a reasonable name can be found, +and the expression debug.getinfo(print) +returns a table with all available information +about the print function. + + + + +

+


debug.getlocal ([thread,] level, local)

+ + +

+This function returns the name and the value of the local variable +with index local of the function at level level of the stack. +(The first parameter or local variable has index 1, and so on, +until the last active local variable.) +The function returns nil if there is no local +variable with the given index, +and raises an error when called with a level out of range. +(You can call debug.getinfo to check whether the level is valid.) + + +

+Variable names starting with '(' (open parentheses) +represent internal variables +(loop control variables, temporaries, and C function locals). + + + + +

+


debug.getmetatable (object)

+ + +

+Returns the metatable of the given object +or nil if it does not have a metatable. + + + + +

+


debug.getregistry ()

+ + +

+Returns the registry table (see §3.5). + + + + +

+


debug.getupvalue (func, up)

+ + +

+This function returns the name and the value of the upvalue +with index up of the function func. +The function returns nil if there is no upvalue with the given index. + + + + +

+


debug.setfenv (object, table)

+ + +

+Sets the environment of the given object to the given table. +Returns object. + + + + +

+


debug.sethook ([thread,] hook, mask [, count])

+ + +

+Sets the given function as a hook. +The string mask and the number count describe +when the hook will be called. +The string mask may have the following characters, +with the given meaning: + +

    +
  • "c": the hook is called every time Lua calls a function;
  • +
  • "r": the hook is called every time Lua returns from a function;
  • +
  • "l": the hook is called every time Lua enters a new line of code.
  • +

+With a count different from zero, +the hook is called after every count instructions. + + +

+When called without arguments, +debug.sethook turns off the hook. + + +

+When the hook is called, its first parameter is a string +describing the event that has triggered its call: +"call", "return" (or "tail return", +when simulating a return from a tail call), +"line", and "count". +For line events, +the hook also gets the new line number as its second parameter. +Inside a hook, +you can call getinfo with level 2 to get more information about +the running function +(level 0 is the getinfo function, +and level 1 is the hook function), +unless the event is "tail return". +In this case, Lua is only simulating the return, +and a call to getinfo will return invalid data. + + + + +

+


debug.setlocal ([thread,] level, local, value)

+ + +

+This function assigns the value value to the local variable +with index local of the function at level level of the stack. +The function returns nil if there is no local +variable with the given index, +and raises an error when called with a level out of range. +(You can call getinfo to check whether the level is valid.) +Otherwise, it returns the name of the local variable. + + + + +

+


debug.setmetatable (object, table)

+ + +

+Sets the metatable for the given object to the given table +(which can be nil). + + + + +

+


debug.setupvalue (func, up, value)

+ + +

+This function assigns the value value to the upvalue +with index up of the function func. +The function returns nil if there is no upvalue +with the given index. +Otherwise, it returns the name of the upvalue. + + + + +

+


debug.traceback ([thread,] [message [, level]])

+ + +

+Returns a string with a traceback of the call stack. +An optional message string is appended +at the beginning of the traceback. +An optional level number tells at which level +to start the traceback +(default is 1, the function calling traceback). + + + + + + + +

6 - Lua Stand-alone

+ +

+Although Lua has been designed as an extension language, +to be embedded in a host C program, +it is also frequently used as a stand-alone language. +An interpreter for Lua as a stand-alone language, +called simply lua, +is provided with the standard distribution. +The stand-alone interpreter includes +all standard libraries, including the debug library. +Its usage is: + +

+     lua [options] [script [args]]
+

+The options are: + +

    +
  • -e stat: executes string stat;
  • +
  • -l mod: "requires" mod;
  • +
  • -i: enters interactive mode after running script;
  • +
  • -v: prints version information;
  • +
  • --: stops handling options;
  • +
  • -: executes stdin as a file and stops handling options.
  • +

+After handling its options, lua runs the given script, +passing to it the given args as string arguments. +When called without arguments, +lua behaves as lua -v -i +when the standard input (stdin) is a terminal, +and as lua - otherwise. + + +

+Before running any argument, +the interpreter checks for an environment variable LUA_INIT. +If its format is @filename, +then lua executes the file. +Otherwise, lua executes the string itself. + + +

+All options are handled in order, except -i. +For instance, an invocation like + +

+     $ lua -e'a=1' -e 'print(a)' script.lua
+

+will first set a to 1, then print the value of a (which is '1'), +and finally run the file script.lua with no arguments. +(Here $ is the shell prompt. Your prompt may be different.) + + +

+Before starting to run the script, +lua collects all arguments in the command line +in a global table called arg. +The script name is stored at index 0, +the first argument after the script name goes to index 1, +and so on. +Any arguments before the script name +(that is, the interpreter name plus the options) +go to negative indices. +For instance, in the call + +

+     $ lua -la b.lua t1 t2
+

+the interpreter first runs the file a.lua, +then creates a table + +

+     arg = { [-2] = "lua", [-1] = "-la",
+             [0] = "b.lua",
+             [1] = "t1", [2] = "t2" }
+

+and finally runs the file b.lua. +The script is called with arg[1], arg[2], ··· +as arguments; +it can also access these arguments with the vararg expression '...'. + + +

+In interactive mode, +if you write an incomplete statement, +the interpreter waits for its completion +by issuing a different prompt. + + +

+If the global variable _PROMPT contains a string, +then its value is used as the prompt. +Similarly, if the global variable _PROMPT2 contains a string, +its value is used as the secondary prompt +(issued during incomplete statements). +Therefore, both prompts can be changed directly on the command line +or in any Lua programs by assigning to _PROMPT. +See the next example: + +

+     $ lua -e"_PROMPT='myprompt> '" -i
+

+(The outer pair of quotes is for the shell, +the inner pair is for Lua.) +Note the use of -i to enter interactive mode; +otherwise, +the program would just end silently +right after the assignment to _PROMPT. + + +

+To allow the use of Lua as a +script interpreter in Unix systems, +the stand-alone interpreter skips +the first line of a chunk if it starts with #. +Therefore, Lua scripts can be made into executable programs +by using chmod +x and the #! form, +as in + +

+     #!/usr/local/bin/lua
+

+(Of course, +the location of the Lua interpreter may be different in your machine. +If lua is in your PATH, +then + +

+     #!/usr/bin/env lua
+

+is a more portable solution.) + + + +

7 - Incompatibilities with the Previous Version

+ +

+Here we list the incompatibilities that you may find when moving a program +from Lua 5.0 to Lua 5.1. +You can avoid most of the incompatibilities compiling Lua with +appropriate options (see file luaconf.h). +However, +all these compatibility options will be removed in the next version of Lua. + + + +

7.1 - Changes in the Language

+
    + +
  • +The vararg system changed from the pseudo-argument arg with a +table with the extra arguments to the vararg expression. +(See compile-time option LUA_COMPAT_VARARG in luaconf.h.) +
  • + +
  • +There was a subtle change in the scope of the implicit +variables of the for statement and for the repeat statement. +
  • + +
  • +The long string/long comment syntax ([[string]]) +does not allow nesting. +You can use the new syntax ([=[string]=]) in these cases. +(See compile-time option LUA_COMPAT_LSTR in luaconf.h.) +
  • + +
+ + + + +

7.2 - Changes in the Libraries

+
    + +
  • +Function string.gfind was renamed string.gmatch. +(See compile-time option LUA_COMPAT_GFIND in luaconf.h.) +
  • + +
  • +When string.gsub is called with a function as its +third argument, +whenever this function returns nil or false the +replacement string is the whole match, +instead of the empty string. +
  • + +
  • +Function table.setn was deprecated. +Function table.getn corresponds +to the new length operator (#); +use the operator instead of the function. +(See compile-time option LUA_COMPAT_GETN in luaconf.h.) +
  • + +
  • +Function loadlib was renamed package.loadlib. +(See compile-time option LUA_COMPAT_LOADLIB in luaconf.h.) +
  • + +
  • +Function math.mod was renamed math.fmod. +(See compile-time option LUA_COMPAT_MOD in luaconf.h.) +
  • + +
  • +Functions table.foreach and table.foreachi are deprecated. +You can use a for loop with pairs or ipairs instead. +
  • + +
  • +There were substantial changes in function require due to +the new module system. +However, the new behavior is mostly compatible with the old, +but require gets the path from package.path instead +of from LUA_PATH. +
  • + +
  • +Function collectgarbage has different arguments. +Function gcinfo is deprecated; +use collectgarbage("count") instead. +
  • + +
+ + + + +

7.3 - Changes in the API

+
    + +
  • +The luaopen_* functions (to open libraries) +cannot be called directly, +like a regular C function. +They must be called through Lua, +like a Lua function. +
  • + +
  • +Function lua_open was replaced by lua_newstate to +allow the user to set a memory-allocation function. +You can use luaL_newstate from the standard library to +create a state with a standard allocation function +(based on realloc). +
  • + +
  • +Functions luaL_getn and luaL_setn +(from the auxiliary library) are deprecated. +Use lua_objlen instead of luaL_getn +and nothing instead of luaL_setn. +
  • + +
  • +Function luaL_openlib was replaced by luaL_register. +
  • + +
  • +Function luaL_checkudata now throws an error when the given value +is not a userdata of the expected type. +(In Lua 5.0 it returned NULL.) +
  • + +
+ + + + +

8 - The Complete Syntax of Lua

+ +

+Here is the complete syntax of Lua in extended BNF. +(It does not describe operator precedences.) + + + + +

+
+	chunk ::= {stat [`;´]} [laststat [`;´]]
+
+	block ::= chunk
+
+	stat ::=  varlist `=´ explist | 
+		 functioncall | 
+		 do block end | 
+		 while exp do block end | 
+		 repeat block until exp | 
+		 if exp then block {elseif exp then block} [else block] end | 
+		 for Name `=´ exp `,´ exp [`,´ exp] do block end | 
+		 for namelist in explist do block end | 
+		 function funcname funcbody | 
+		 local function Name funcbody | 
+		 local namelist [`=´ explist] 
+
+	laststat ::= return [explist] | break
+
+	funcname ::= Name {`.´ Name} [`:´ Name]
+
+	varlist ::= var {`,´ var}
+
+	var ::=  Name | prefixexp `[´ exp `]´ | prefixexp `.´ Name 
+
+	namelist ::= Name {`,´ Name}
+
+	explist ::= {exp `,´} exp
+
+	exp ::=  nil | false | true | Number | String | `...´ | function | 
+		 prefixexp | tableconstructor | exp binop exp | unop exp 
+
+	prefixexp ::= var | functioncall | `(´ exp `)´
+
+	functioncall ::=  prefixexp args | prefixexp `:´ Name args 
+
+	args ::=  `(´ [explist] `)´ | tableconstructor | String 
+
+	function ::= function funcbody
+
+	funcbody ::= `(´ [parlist] `)´ block end
+
+	parlist ::= namelist [`,´ `...´] | `...´
+
+	tableconstructor ::= `{´ [fieldlist] `}´
+
+	fieldlist ::= field {fieldsep field} [fieldsep]
+
+	field ::= `[´ exp `]´ `=´ exp | Name `=´ exp | exp
+
+	fieldsep ::= `,´ | `;´
+
+	binop ::= `+´ | `-´ | `*´ | `/´ | `^´ | `%´ | `..´ | 
+		 `<´ | `<=´ | `>´ | `>=´ | `==´ | `~=´ | 
+		 and | or
+
+	unop ::= `-´ | not | `#´
+
+
+ +

+ + + + + + + +


+ +Last update: +Mon Feb 13 18:54:19 BRST 2012 + + + + + diff --git a/third-party/lua-5.1.5/doc/readme.html b/third-party/lua-5.1.5/doc/readme.html new file mode 100644 index 000000000..3ed6a8189 --- /dev/null +++ b/third-party/lua-5.1.5/doc/readme.html @@ -0,0 +1,40 @@ + + +Lua documentation + + + + + +
+

+Lua +Documentation +

+ +This is the documentation included in the source distribution of Lua 5.1.5. + + + +Lua's +official web site +contains updated documentation, +especially the +reference manual. +

+ +


+ +Last update: +Fri Feb 3 09:44:42 BRST 2012 + + + + diff --git a/third-party/lua-5.1.5/etc/Makefile b/third-party/lua-5.1.5/etc/Makefile new file mode 100644 index 000000000..6d00008d9 --- /dev/null +++ b/third-party/lua-5.1.5/etc/Makefile @@ -0,0 +1,44 @@ +# makefile for Lua etc + +TOP= .. +LIB= $(TOP)/src +INC= $(TOP)/src +BIN= $(TOP)/src +SRC= $(TOP)/src +TST= $(TOP)/test + +CC= gcc +CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS) +MYCFLAGS= +MYLDFLAGS= -Wl,-E +MYLIBS= -lm +#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses +RM= rm -f + +default: + @echo 'Please choose a target: min noparser one strict clean' + +min: min.c + $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS) + echo 'print"Hello there!"' | ./a.out + +noparser: noparser.o + $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS) + $(BIN)/luac $(TST)/hello.lua + -./a.out luac.out + -./a.out -e'a=1' + +one: + $(CC) $(CFLAGS) all.c $(MYLIBS) + ./a.out $(TST)/hello.lua + +strict: + -$(BIN)/lua -e 'print(a);b=2' + -$(BIN)/lua -lstrict -e 'print(a)' + -$(BIN)/lua -e 'function f() b=2 end f()' + -$(BIN)/lua -lstrict -e 'function f() b=2 end f()' + +clean: + $(RM) a.out core core.* *.o luac.out + +.PHONY: default min noparser one strict clean diff --git a/third-party/lua-5.1.5/etc/README b/third-party/lua-5.1.5/etc/README new file mode 100644 index 000000000..5149fc91d --- /dev/null +++ b/third-party/lua-5.1.5/etc/README @@ -0,0 +1,37 @@ +This directory contains some useful files and code. +Unlike the code in ../src, everything here is in the public domain. + +If any of the makes fail, you're probably not using the same libraries +used to build Lua. Set MYLIBS in Makefile accordingly. + +all.c + Full Lua interpreter in a single file. + Do "make one" for a demo. + +lua.hpp + Lua header files for C++ using 'extern "C"'. + +lua.ico + A Lua icon for Windows (and web sites: save as favicon.ico). + Drawn by hand by Markus Gritsch . + +lua.pc + pkg-config data for Lua + +luavs.bat + Script to build Lua under "Visual Studio .NET Command Prompt". + Run it from the toplevel as etc\luavs.bat. + +min.c + A minimal Lua interpreter. + Good for learning and for starting your own. + Do "make min" for a demo. + +noparser.c + Linking with noparser.o avoids loading the parsing modules in lualib.a. + Do "make noparser" for a demo. + +strict.lua + Traps uses of undeclared global variables. + Do "make strict" for a demo. + diff --git a/third-party/lua-5.1.5/etc/all.c b/third-party/lua-5.1.5/etc/all.c new file mode 100644 index 000000000..dab68fac5 --- /dev/null +++ b/third-party/lua-5.1.5/etc/all.c @@ -0,0 +1,38 @@ +/* +* all.c -- Lua core, libraries and interpreter in a single file +*/ + +#define luaall_c + +#include "lapi.c" +#include "lcode.c" +#include "ldebug.c" +#include "ldo.c" +#include "ldump.c" +#include "lfunc.c" +#include "lgc.c" +#include "llex.c" +#include "lmem.c" +#include "lobject.c" +#include "lopcodes.c" +#include "lparser.c" +#include "lstate.c" +#include "lstring.c" +#include "ltable.c" +#include "ltm.c" +#include "lundump.c" +#include "lvm.c" +#include "lzio.c" + +#include "lauxlib.c" +#include "lbaselib.c" +#include "ldblib.c" +#include "liolib.c" +#include "linit.c" +#include "lmathlib.c" +#include "loadlib.c" +#include "loslib.c" +#include "lstrlib.c" +#include "ltablib.c" + +#include "lua.c" diff --git a/third-party/lua-5.1.5/etc/lua.hpp b/third-party/lua-5.1.5/etc/lua.hpp new file mode 100644 index 000000000..ec417f594 --- /dev/null +++ b/third-party/lua-5.1.5/etc/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/third-party/lua-5.1.5/etc/lua.ico b/third-party/lua-5.1.5/etc/lua.ico new file mode 100644 index 0000000000000000000000000000000000000000..ccbabc4e2004683f29598a991006d7caff6d837d GIT binary patch literal 1078 zcma)5y>7xl4E|D3VJbX9VX7GW1~6FSw!BIQq_T0tNo32b^bxZ4H5fZGR7xh?&v!Y3 zDh3=J`#b+#Yy%W{!g4u>(a#g`Mme7+yefc~5wPOflDr`o81qe{?|t$BfABsDzNw;V z8cH*0{6W<;G9Np#7ik(qoR4aR5-A@{5)}DJ9&}FRBA#X_5+im4-kQSzMF^)-t2(Vi ztw-^|Sn8@O_lM9`oos+0wMZGt&`Bq(aK&XCv1Gfr&Jtd6%lKPdD{s=unqGWyb3%y{X9SS{jB~HMh0oKMISQrDC zJ;K?)>ElnpmN^UNE-rXxtyk{c#rCe~`P=qnFT7 bCxwx*w%~s~=?o*z_6Fk4@7l(poWF`cPpA(! literal 0 HcmV?d00001 diff --git a/third-party/lua-5.1.5/etc/lua.pc b/third-party/lua-5.1.5/etc/lua.pc new file mode 100644 index 000000000..07e2852b0 --- /dev/null +++ b/third-party/lua-5.1.5/etc/lua.pc @@ -0,0 +1,31 @@ +# lua.pc -- pkg-config data for Lua + +# vars from install Makefile + +# grep '^V=' ../Makefile +V= 5.1 +# grep '^R=' ../Makefile +R= 5.1.5 + +# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' +prefix= /usr/local +INSTALL_BIN= ${prefix}/bin +INSTALL_INC= ${prefix}/include +INSTALL_LIB= ${prefix}/lib +INSTALL_MAN= ${prefix}/man/man1 +INSTALL_LMOD= ${prefix}/share/lua/${V} +INSTALL_CMOD= ${prefix}/lib/lua/${V} + +# canonical vars +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: Lua +Description: An Extensible Extension Language +Version: ${R} +Requires: +Libs: -L${libdir} -llua -lm +Cflags: -I${includedir} + +# (end of lua.pc) diff --git a/third-party/lua-5.1.5/etc/luavs.bat b/third-party/lua-5.1.5/etc/luavs.bat new file mode 100644 index 000000000..08c2beddf --- /dev/null +++ b/third-party/lua-5.1.5/etc/luavs.bat @@ -0,0 +1,28 @@ +@rem Script to build Lua under "Visual Studio .NET Command Prompt". +@rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . +@rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. +@rem (contributed by David Manura and Mike Pall) + +@setlocal +@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE +@set MYLINK=link /nologo +@set MYMT=mt /nologo + +cd src +%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c +del lua.obj luac.obj +%MYLINK% /DLL /out:lua51.dll l*.obj +if exist lua51.dll.manifest^ + %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 +%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c +%MYLINK% /out:lua.exe lua.obj lua51.lib +if exist lua.exe.manifest^ + %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe +%MYCOMPILE% l*.c print.c +del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ + loslib.obj ltablib.obj lstrlib.obj loadlib.obj +%MYLINK% /out:luac.exe *.obj +if exist luac.exe.manifest^ + %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe +del *.obj *.manifest +cd .. diff --git a/third-party/lua-5.1.5/etc/min.c b/third-party/lua-5.1.5/etc/min.c new file mode 100644 index 000000000..6a85a4d10 --- /dev/null +++ b/third-party/lua-5.1.5/etc/min.c @@ -0,0 +1,39 @@ +/* +* min.c -- a minimal Lua interpreter +* loads stdin only with minimal error handling. +* no interaction, and no standard library, only a "print" function. +*/ + +#include + +#include "lua.h" +#include "lauxlib.h" + +static int print(lua_State *L) +{ + int n=lua_gettop(L); + int i; + for (i=1; i<=n; i++) + { + if (i>1) printf("\t"); + if (lua_isstring(L,i)) + printf("%s",lua_tostring(L,i)); + else if (lua_isnil(L,i)) + printf("%s","nil"); + else if (lua_isboolean(L,i)) + printf("%s",lua_toboolean(L,i) ? "true" : "false"); + else + printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i)); + } + printf("\n"); + return 0; +} + +int main(void) +{ + lua_State *L=lua_open(); + lua_register(L,"print",print); + if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1)); + lua_close(L); + return 0; +} diff --git a/third-party/lua-5.1.5/etc/noparser.c b/third-party/lua-5.1.5/etc/noparser.c new file mode 100644 index 000000000..13ba54623 --- /dev/null +++ b/third-party/lua-5.1.5/etc/noparser.c @@ -0,0 +1,50 @@ +/* +* The code below can be used to make a Lua core that does not contain the +* parsing modules (lcode, llex, lparser), which represent 35% of the total core. +* You'll only be able to load binary files and strings, precompiled with luac. +* (Of course, you'll have to build luac with the original parsing modules!) +* +* To use this module, simply compile it ("make noparser" does that) and list +* its object file before the Lua libraries. The linker should then not load +* the parsing modules. To try it, do "make luab". +* +* If you also want to avoid the dump module (ldump.o), define NODUMP. +* #define NODUMP +*/ + +#define LUA_CORE + +#include "llex.h" +#include "lparser.h" +#include "lzio.h" + +LUAI_FUNC void luaX_init (lua_State *L) { + UNUSED(L); +} + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + UNUSED(z); + UNUSED(buff); + UNUSED(name); + lua_pushliteral(L,"parser not loaded"); + lua_error(L); + return NULL; +} + +#ifdef NODUMP +#include "lundump.h" + +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) { + UNUSED(f); + UNUSED(w); + UNUSED(data); + UNUSED(strip); +#if 1 + UNUSED(L); + return 0; +#else + lua_pushliteral(L,"dumper not loaded"); + lua_error(L); +#endif +} +#endif diff --git a/third-party/lua-5.1.5/etc/strict.lua b/third-party/lua-5.1.5/etc/strict.lua new file mode 100644 index 000000000..604619dd2 --- /dev/null +++ b/third-party/lua-5.1.5/etc/strict.lua @@ -0,0 +1,41 @@ +-- +-- strict.lua +-- checks uses of undeclared global variables +-- All global variables must be 'declared' through a regular assignment +-- (even assigning nil will do) in a main chunk before being used +-- anywhere or assigned to inside a function. +-- + +local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget + +local mt = getmetatable(_G) +if mt == nil then + mt = {} + setmetatable(_G, mt) +end + +mt.__declared = {} + +local function what () + local d = getinfo(3, "S") + return d and d.what or "C" +end + +mt.__newindex = function (t, n, v) + if not mt.__declared[n] then + local w = what() + if w ~= "main" and w ~= "C" then + error("assign to undeclared variable '"..n.."'", 2) + end + mt.__declared[n] = true + end + rawset(t, n, v) +end + +mt.__index = function (t, n) + if not mt.__declared[n] and what() ~= "C" then + error("variable '"..n.."' is not declared", 2) + end + return rawget(t, n) +end + diff --git a/third-party/lua-5.1.5/src/CMakeLists.txt b/third-party/lua-5.1.5/src/CMakeLists.txt new file mode 100644 index 000000000..bbe27234c --- /dev/null +++ b/third-party/lua-5.1.5/src/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.1) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + +set(LUA_LIB_SRC + "lapi.c" + "lcode.c" + "ldebug.c" + "ldo.c" + "ldump.c" + "lfunc.c" + "lgc.c" + "llex.c" + "lmem.c" + "lobject.c" + "lopcodes.c" + "lparser.c" + "lstate.c" + "lstring.c" + "ltable.c" + "ltm.c" + "lundump.c" + "lvm.c" + "lzio.c" + "lauxlib.c" + "lbaselib.c" + "ldblib.c" + "liolib.c" + "lmathlib.c" + "loslib.c" + "ltablib.c" + "lstrlib.c" + "loadlib.c" + "linit.c" +) + +set(LUA_SRC "lua.c") + +add_library(lua51_static STATIC "${LUA_LIB_SRC}") +set_target_properties(lua51_static PROPERTIES OUTPUT_NAME "lua51") + +add_executable(lua51 "${LUA_SRC}" "${LUA_LIB_SRC}") + +if(UNIX) +target_compile_definitions(lua51_static PUBLIC "LUA_USE_DLOPEN") +target_compile_definitions(lua51 PUBLIC "LUA_USE_DLOPEN") +target_link_libraries(lua51 PUBLIC dl) +target_link_libraries(lua51_static PUBLIC dl) +endif() + +set_target_properties(lua51_static PROPERTIES LINKER_LANGUAGE CXX) +set_target_properties(lua51 PROPERTIES LINKER_LANGUAGE CXX) + +set_target_properties(lua51 PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} + ) + +add_custom_command(TARGET lua51_static POST_BUILD COMMAND cp -t ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luaconf.h" "${PROJECT_SOURCE_DIR}/src/lualib.h" "${PROJECT_SOURCE_DIR}/src/lauxlib.h") diff --git a/third-party/lua-5.1.5/src/Makefile b/third-party/lua-5.1.5/src/Makefile new file mode 100644 index 000000000..e0d4c9fa6 --- /dev/null +++ b/third-party/lua-5.1.5/src/Makefile @@ -0,0 +1,182 @@ +# makefile for building Lua +# see ../INSTALL for installation instructions +# see ../Makefile and luaconf.h for further customization + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= none + +CC= gcc +CFLAGS= -O2 -Wall $(MYCFLAGS) +AR= ar rcu +RANLIB= ranlib +RM= rm -f +LIBS= -lm $(MYLIBS) + +MYCFLAGS= +MYLDFLAGS= +MYLIBS= + +# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + +LUA_A= liblua.a +CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ + lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ + lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ + lstrlib.o loadlib.o linit.o + +LUA_T= lua +LUA_O= lua.o + +LUAC_T= luac +LUAC_O= luac.o print.o + +ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) +ALL_A= $(LUA_A) + +default: $(PLAT) + +all: $(ALL_T) + +o: $(ALL_O) + +a: $(ALL_A) + +$(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files + $(RANLIB) $@ + +$(LUA_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +$(LUAC_T): $(LUAC_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + +clean: + $(RM) $(ALL_T) $(ALL_O) + +depend: + @$(CC) $(CFLAGS) -MM l*.c print.c + +echo: + @echo "PLAT = $(PLAT)" + @echo "CC = $(CC)" + @echo "CFLAGS = $(CFLAGS)" + @echo "AR = $(AR)" + @echo "RANLIB = $(RANLIB)" + @echo "RM = $(RM)" + @echo "MYCFLAGS = $(MYCFLAGS)" + @echo "MYLDFLAGS = $(MYLDFLAGS)" + @echo "MYLIBS = $(MYLIBS)" + +# convenience targets for popular platforms + +none: + @echo "Please choose a platform:" + @echo " $(PLATS)" + +aix: + $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + +ansi: + $(MAKE) all MYCFLAGS=-DLUA_ANSI + +bsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + +generic: + $(MAKE) all MYCFLAGS= + +linux: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + +macosx: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" +# use this on Mac OS X 10.3- +# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX + +mingw: + $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ + "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ + "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe + +posix: + $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX + +solaris: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" + +# list targets that do not create files (but not all makes understand .PHONY) +.PHONY: all $(PLATS) default o a clean depend echo none + +# DO NOT DELETE + +lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ + lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ + lundump.h lvm.h +lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h +lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h +lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ + ltable.h +ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h +ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ + llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ + ltable.h lundump.h lvm.h +ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ + lstate.h ltm.h lzio.h +lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h +linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h +liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h +llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h +lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h +lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h +loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h +lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h +lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h +loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h +lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h +lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h +lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ + ltm.h lzio.h lstring.h lgc.h +lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h +ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h +ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h +ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ + lmem.h lstring.h lgc.h ltable.h +lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h +luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ + lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ + lundump.h +lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h +lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h +lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ + lzio.h +print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h lopcodes.h lundump.h + +# (end of Makefile) diff --git a/third-party/lua-5.1.5/src/lapi.c b/third-party/lua-5.1.5/src/lapi.c new file mode 100644 index 000000000..5d5145d2e --- /dev/null +++ b/third-party/lua-5.1.5/src/lapi.c @@ -0,0 +1,1087 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + diff --git a/third-party/lua-5.1.5/src/lapi.h b/third-party/lua-5.1.5/src/lapi.h new file mode 100644 index 000000000..2c3fab244 --- /dev/null +++ b/third-party/lua-5.1.5/src/lapi.h @@ -0,0 +1,16 @@ +/* +** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "lobject.h" + + +LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); + +#endif diff --git a/third-party/lua-5.1.5/src/lauxlib.c b/third-party/lua-5.1.5/src/lauxlib.c new file mode 100644 index 000000000..10f14e2c0 --- /dev/null +++ b/third-party/lua-5.1.5/src/lauxlib.c @@ -0,0 +1,652 @@ +/* +** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff --git a/third-party/lua-5.1.5/src/lauxlib.h b/third-party/lua-5.1.5/src/lauxlib.h new file mode 100644 index 000000000..34258235d --- /dev/null +++ b/third-party/lua-5.1.5/src/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/third-party/lua-5.1.5/src/lbaselib.c b/third-party/lua-5.1.5/src/lbaselib.c new file mode 100644 index 000000000..2ab550bd4 --- /dev/null +++ b/third-party/lua-5.1.5/src/lbaselib.c @@ -0,0 +1,653 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxiliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + diff --git a/third-party/lua-5.1.5/src/lcode.c b/third-party/lua-5.1.5/src/lcode.c new file mode 100644 index 000000000..679cb9cfd --- /dev/null +++ b/third-party/lua-5.1.5/src/lcode.c @@ -0,0 +1,831 @@ +/* +** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/third-party/lua-5.1.5/src/lcode.h b/third-party/lua-5.1.5/src/lcode.h new file mode 100644 index 000000000..b941c6072 --- /dev/null +++ b/third-party/lua-5.1.5/src/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/third-party/lua-5.1.5/src/ldblib.c b/third-party/lua-5.1.5/src/ldblib.c new file mode 100644 index 000000000..2027eda59 --- /dev/null +++ b/third-party/lua-5.1.5/src/ldblib.c @@ -0,0 +1,398 @@ +/* +** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + luaL_checkany(L, 1); + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + diff --git a/third-party/lua-5.1.5/src/ldebug.c b/third-party/lua-5.1.5/src/ldebug.c new file mode 100644 index 000000000..50ad3d380 --- /dev/null +++ b/third-party/lua-5.1.5/src/ldebug.c @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff --git a/third-party/lua-5.1.5/src/ldebug.h b/third-party/lua-5.1.5/src/ldebug.h new file mode 100644 index 000000000..ba28a9724 --- /dev/null +++ b/third-party/lua-5.1.5/src/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff --git a/third-party/lua-5.1.5/src/ldo.c b/third-party/lua-5.1.5/src/ldo.c new file mode 100644 index 000000000..d1bf786cb --- /dev/null +++ b/third-party/lua-5.1.5/src/ldo.c @@ -0,0 +1,519 @@ +/* +** $Id: ldo.c,v 2.38.1.4 2012/01/18 02:27:10 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + luaD_checkstack(L, p->maxstacksize); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + diff --git a/third-party/lua-5.1.5/src/ldo.h b/third-party/lua-5.1.5/src/ldo.h new file mode 100644 index 000000000..98fddac59 --- /dev/null +++ b/third-party/lua-5.1.5/src/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff --git a/third-party/lua-5.1.5/src/ldump.c b/third-party/lua-5.1.5/src/ldump.c new file mode 100644 index 000000000..c9d3d4870 --- /dev/null +++ b/third-party/lua-5.1.5/src/ldump.c @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} diff --git a/third-party/lua-5.1.5/src/lfunc.c b/third-party/lua-5.1.5/src/lfunc.c new file mode 100644 index 000000000..813e88f58 --- /dev/null +++ b/third-party/lua-5.1.5/src/lfunc.c @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/third-party/lua-5.1.5/src/lfunc.h b/third-party/lua-5.1.5/src/lfunc.h new file mode 100644 index 000000000..a68cf5151 --- /dev/null +++ b/third-party/lua-5.1.5/src/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/third-party/lua-5.1.5/src/lgc.c b/third-party/lua-5.1.5/src/lgc.c new file mode 100644 index 000000000..e909c79a9 --- /dev/null +++ b/third-party/lua-5.1.5/src/lgc.c @@ -0,0 +1,710 @@ +/* +** $Id: lgc.c,v 2.38.1.2 2011/03/18 18:05:38 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + diff --git a/third-party/lua-5.1.5/src/lgc.h b/third-party/lua-5.1.5/src/lgc.h new file mode 100644 index 000000000..5a8dc605b --- /dev/null +++ b/third-party/lua-5.1.5/src/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff --git a/third-party/lua-5.1.5/src/linit.c b/third-party/lua-5.1.5/src/linit.c new file mode 100644 index 000000000..c1f90dfab --- /dev/null +++ b/third-party/lua-5.1.5/src/linit.c @@ -0,0 +1,38 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + diff --git a/third-party/lua-5.1.5/src/liolib.c b/third-party/lua-5.1.5/src/liolib.c new file mode 100644 index 000000000..649f9a595 --- /dev/null +++ b/third-party/lua-5.1.5/src/liolib.c @@ -0,0 +1,556 @@ +/* +** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else { + lua_pushnil(L); /* "result" to be removed */ + return 0; /* read fails */ + } +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + diff --git a/third-party/lua-5.1.5/src/llex.c b/third-party/lua-5.1.5/src/llex.c new file mode 100644 index 000000000..88c6790c0 --- /dev/null +++ b/third-party/lua-5.1.5/src/llex.c @@ -0,0 +1,463 @@ +/* +** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) { + setbvalue(o, 1); /* make sure `str' will not be collected */ + luaC_checkGC(L); + } + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + diff --git a/third-party/lua-5.1.5/src/llex.h b/third-party/lua-5.1.5/src/llex.h new file mode 100644 index 000000000..a9201cee4 --- /dev/null +++ b/third-party/lua-5.1.5/src/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/third-party/lua-5.1.5/src/llimits.h b/third-party/lua-5.1.5/src/llimits.h new file mode 100644 index 000000000..ca8dcb722 --- /dev/null +++ b/third-party/lua-5.1.5/src/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff --git a/third-party/lua-5.1.5/src/lmathlib.c b/third-party/lua-5.1.5/src/lmathlib.c new file mode 100644 index 000000000..441fbf736 --- /dev/null +++ b/third-party/lua-5.1.5/src/lmathlib.c @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff --git a/third-party/lua-5.1.5/src/lmem.c b/third-party/lua-5.1.5/src/lmem.c new file mode 100644 index 000000000..ae7d8c965 --- /dev/null +++ b/third-party/lua-5.1.5/src/lmem.c @@ -0,0 +1,86 @@ +/* +** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + diff --git a/third-party/lua-5.1.5/src/lmem.h b/third-party/lua-5.1.5/src/lmem.h new file mode 100644 index 000000000..7c2dcb322 --- /dev/null +++ b/third-party/lua-5.1.5/src/lmem.h @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff --git a/third-party/lua-5.1.5/src/loadlib.c b/third-party/lua-5.1.5/src/loadlib.c new file mode 100644 index 000000000..6158c5353 --- /dev/null +++ b/third-party/lua-5.1.5/src/loadlib.c @@ -0,0 +1,666 @@ +/* +** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} + diff --git a/third-party/lua-5.1.5/src/lobject.c b/third-party/lua-5.1.5/src/lobject.c new file mode 100644 index 000000000..4ff50732a --- /dev/null +++ b/third-party/lua-5.1.5/src/lobject.c @@ -0,0 +1,214 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} diff --git a/third-party/lua-5.1.5/src/lobject.h b/third-party/lua-5.1.5/src/lobject.h new file mode 100644 index 000000000..f1e447ef3 --- /dev/null +++ b/third-party/lua-5.1.5/src/lobject.h @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/third-party/lua-5.1.5/src/lopcodes.c b/third-party/lua-5.1.5/src/lopcodes.c new file mode 100644 index 000000000..4cc745230 --- /dev/null +++ b/third-party/lua-5.1.5/src/lopcodes.c @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + diff --git a/third-party/lua-5.1.5/src/lopcodes.h b/third-party/lua-5.1.5/src/lopcodes.h new file mode 100644 index 000000000..41224d6ee --- /dev/null +++ b/third-party/lua-5.1.5/src/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/third-party/lua-5.1.5/src/loslib.c b/third-party/lua-5.1.5/src/loslib.c new file mode 100644 index 000000000..da06a572a --- /dev/null +++ b/third-party/lua-5.1.5/src/loslib.c @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + diff --git a/third-party/lua-5.1.5/src/lparser.c b/third-party/lua-5.1.5/src/lparser.c new file mode 100644 index 000000000..dda7488dc --- /dev/null +++ b/third-party/lua-5.1.5/src/lparser.c @@ -0,0 +1,1339 @@ +/* +** $Id: lparser.c,v 2.42.1.4 2011/10/21 19:31:42 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); + L->top -= 2; /* remove table and prototype from the stack */ +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ diff --git a/third-party/lua-5.1.5/src/lparser.h b/third-party/lua-5.1.5/src/lparser.h new file mode 100644 index 000000000..18836afd1 --- /dev/null +++ b/third-party/lua-5.1.5/src/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff --git a/third-party/lua-5.1.5/src/lstate.c b/third-party/lua-5.1.5/src/lstate.c new file mode 100644 index 000000000..4313b83a0 --- /dev/null +++ b/third-party/lua-5.1.5/src/lstate.c @@ -0,0 +1,214 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} + diff --git a/third-party/lua-5.1.5/src/lstate.h b/third-party/lua-5.1.5/src/lstate.h new file mode 100644 index 000000000..3bc575b6b --- /dev/null +++ b/third-party/lua-5.1.5/src/lstate.h @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff --git a/third-party/lua-5.1.5/src/lstring.c b/third-party/lua-5.1.5/src/lstring.c new file mode 100644 index 000000000..49113151c --- /dev/null +++ b/third-party/lua-5.1.5/src/lstring.c @@ -0,0 +1,111 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + diff --git a/third-party/lua-5.1.5/src/lstring.h b/third-party/lua-5.1.5/src/lstring.h new file mode 100644 index 000000000..73a2ff8b3 --- /dev/null +++ b/third-party/lua-5.1.5/src/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff --git a/third-party/lua-5.1.5/src/lstrlib.c b/third-party/lua-5.1.5/src/lstrlib.c new file mode 100644 index 000000000..7a03489be --- /dev/null +++ b/third-party/lua-5.1.5/src/lstrlib.c @@ -0,0 +1,871 @@ +/* +** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int top = lua_gettop(L); + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + if (++arg > top) + luaL_argerror(L, arg, "no value"); + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + diff --git a/third-party/lua-5.1.5/src/ltable.c b/third-party/lua-5.1.5/src/ltable.c new file mode 100644 index 000000000..ec84f4fab --- /dev/null +++ b/third-party/lua-5.1.5/src/ltable.c @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif diff --git a/third-party/lua-5.1.5/src/ltable.h b/third-party/lua-5.1.5/src/ltable.h new file mode 100644 index 000000000..f5b9d5ead --- /dev/null +++ b/third-party/lua-5.1.5/src/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/third-party/lua-5.1.5/src/ltablib.c b/third-party/lua-5.1.5/src/ltablib.c new file mode 100644 index 000000000..b6d9cb4ac --- /dev/null +++ b/third-party/lua-5.1.5/src/ltablib.c @@ -0,0 +1,287 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff --git a/third-party/lua-5.1.5/src/ltm.h b/third-party/lua-5.1.5/src/ltm.h new file mode 100644 index 000000000..64343b781 --- /dev/null +++ b/third-party/lua-5.1.5/src/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/third-party/lua-5.1.5/src/lua.c b/third-party/lua-5.1.5/src/lua.c new file mode 100644 index 000000000..3a4660932 --- /dev/null +++ b/third-party/lua-5.1.5/src/lua.c @@ -0,0 +1,392 @@ +/* +** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua stand-alone interpreter +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lua_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static lua_State *globalL = NULL; + +static const char *progname = LUA_PROGNAME; + + + +static void lstop (lua_State *L, lua_Debug *ar) { + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "interrupted!"); +} + + +static void laction (int i) { + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + + +static void print_usage (void) { + fprintf(stderr, + "usage: %s [options] [script [args]].\n" + "Available options are:\n" + " -e stat execute string " LUA_QL("stat") "\n" + " -l name require library " LUA_QL("name") "\n" + " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -v show version information\n" + " -- stop handling options\n" + " - execute stdin and stop handling options\n" + , + progname); + fflush(stderr); +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + + +static int report (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + + +static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + + +static int docall (lua_State *L, int narg, int clear) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + signal(SIGINT, laction); + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + signal(SIGINT, SIG_DFL); + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + + +static void print_version (void) { + l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); +} + + +static int getargs (lua_State *L, char **argv, int n) { + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i=n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i=0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + + +static int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dostring (lua_State *L, const char *s, const char *name) { + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dolibrary (lua_State *L, const char *name) { + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + + +static const char *get_prompt (lua_State *L, int firstline) { + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); + lua_pop(L, 1); /* remove global */ + return p; +} + + +static int incomplete (lua_State *L, int status) { + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + + +static int pushline (lua_State *L, int firstline) { + char buffer[LUA_MAXINPUT]; + char *b = buffer; + size_t l; + const char *prmt = get_prompt(L, firstline); + if (lua_readline(L, b, prmt) == 0) + return 0; /* no input */ + l = strlen(b); + if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ + b[l-1] = '\0'; /* remove it */ + if (firstline && b[0] == '=') /* first line starts with `=' ? */ + lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ + else + lua_pushstring(L, b); + lua_freeline(L, b); + return 1; +} + + +static int loadline (lua_State *L) { + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_saveline(L, 1); + lua_remove(L, 1); /* remove line */ + return status; +} + + +static void dotty (lua_State *L) { + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, lua_pushfstring(L, + "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + + +static int handle_script (lua_State *L, char **argv, int n) { + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + + +static int collectargs (char **argv, int *pi, int *pv, int *pe) { + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* not an option? */ + return i; + switch (argv[i][1]) { /* option */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *pi = 1; /* go through */ + case 'v': + notail(argv[i]); + *pv = 1; + break; + case 'e': + *pe = 1; /* go through */ + case 'l': + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + + +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + default: break; + } + } + return 0; +} + + +static int handle_luainit (lua_State *L) { + const char *init = getenv(LUA_INIT); + if (init == NULL) return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + + +struct Smain { + int argc; + char **argv; + int status; +}; + + +static int pmain (lua_State *L) { + struct Smain *s = (struct Smain *)lua_touserdata(L, 1); + char **argv = s->argv; + int script; + int has_i = 0, has_v = 0, has_e = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + s->status = handle_luainit(L); + if (s->status != 0) return 0; + script = collectargs(argv, &has_i, &has_v, &has_e); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if (has_v) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + if (has_i) + dotty(L); + else if (script == 0 && !has_e && !has_v) { + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + return 0; +} + + +int main (int argc, char **argv) { + int status; + struct Smain s; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + s.argc = argc; + s.argv = argv; + status = lua_cpcall(L, &pmain, &s); + report(L, status); + lua_close(L); + return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/third-party/lua-5.1.5/src/lua.h b/third-party/lua-5.1.5/src/lua.h new file mode 100644 index 000000000..a4b73e743 --- /dev/null +++ b/third-party/lua-5.1.5/src/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.5" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/third-party/lua-5.1.5/src/luac.c b/third-party/lua-5.1.5/src/luac.c new file mode 100644 index 000000000..d07017391 --- /dev/null +++ b/third-party/lua-5.1.5/src/luac.c @@ -0,0 +1,200 @@ +/* +** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ +** Lua compiler (saves bytecodes to files; also list bytecodes) +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include + +#define luac_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstring.h" +#include "lundump.h" + +#define PROGNAME "luac" /* default program name */ +#define OUTPUT PROGNAME ".out" /* default output file */ + +static int listing=0; /* list bytecodes? */ +static int dumping=1; /* dump bytecodes? */ +static int stripping=0; /* strip debug information? */ +static char Output[]={ OUTPUT }; /* default output file name */ +static const char* output=Output; /* actual output file name */ +static const char* progname=PROGNAME; /* actual program name */ + +static void fatal(const char* message) +{ + fprintf(stderr,"%s: %s\n",progname,message); + exit(EXIT_FAILURE); +} + +static void cannot(const char* what) +{ + fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); + exit(EXIT_FAILURE); +} + +static void usage(const char* message) +{ + if (*message=='-') + fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); + else + fprintf(stderr,"%s: %s\n",progname,message); + fprintf(stderr, + "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -l list\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", + progname,Output); + exit(EXIT_FAILURE); +} + +#define IS(s) (strcmp(argv[i],s)==0) + +static int doargs(int argc, char* argv[]) +{ + int i; + int version=0; + if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; + for (i=1; itop+(i))->l.p) + +static const Proto* combine(lua_State* L, int n) +{ + if (n==1) + return toproto(L,-1); + else + { + int i,pc; + Proto* f=luaF_newproto(L); + setptvalue2s(L,L->top,f); incr_top(L); + f->source=luaS_newliteral(L,"=(" PROGNAME ")"); + f->maxstacksize=1; + pc=2*n+1; + f->code=luaM_newvector(L,pc,Instruction); + f->sizecode=pc; + f->p=luaM_newvector(L,n,Proto*); + f->sizep=n; + pc=0; + for (i=0; ip[i]=toproto(L,i-n-1); + f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); + f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); + } + f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); + return f; + } +} + +static int writer(lua_State* L, const void* p, size_t size, void* u) +{ + UNUSED(L); + return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); +} + +struct Smain { + int argc; + char** argv; +}; + +static int pmain(lua_State* L) +{ + struct Smain* s = (struct Smain*)lua_touserdata(L, 1); + int argc=s->argc; + char** argv=s->argv; + const Proto* f; + int i; + if (!lua_checkstack(L,argc)) fatal("too many input files"); + for (i=0; i1); + if (dumping) + { + FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); + if (D==NULL) cannot("open"); + lua_lock(L); + luaU_dump(L,f,writer,D,stripping); + lua_unlock(L); + if (ferror(D)) cannot("write"); + if (fclose(D)) cannot("close"); + } + return 0; +} + +int main(int argc, char* argv[]) +{ + lua_State* L; + struct Smain s; + int i=doargs(argc,argv); + argc-=i; argv+=i; + if (argc<=0) usage("no input files given"); + L=lua_open(); + if (L==NULL) fatal("not enough memory for state"); + s.argc=argc; + s.argv=argv; + if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); + lua_close(L); + return EXIT_SUCCESS; +} diff --git a/third-party/lua-5.1.5/src/luaconf.h b/third-party/lua-5.1.5/src/luaconf.h new file mode 100644 index 000000000..e2cb26163 --- /dev/null +++ b/third-party/lua-5.1.5/src/luaconf.h @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/third-party/lua-5.1.5/src/lualib.h b/third-party/lua-5.1.5/src/lualib.h new file mode 100644 index 000000000..469417f67 --- /dev/null +++ b/third-party/lua-5.1.5/src/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/third-party/lua-5.1.5/src/lundump.c b/third-party/lua-5.1.5/src/lundump.c new file mode 100644 index 000000000..8010a4579 --- /dev/null +++ b/third-party/lua-5.1.5/src/lundump.c @@ -0,0 +1,227 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} diff --git a/third-party/lua-5.1.5/src/lundump.h b/third-party/lua-5.1.5/src/lundump.h new file mode 100644 index 000000000..c80189dbf --- /dev/null +++ b/third-party/lua-5.1.5/src/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff --git a/third-party/lua-5.1.5/src/lvm.c b/third-party/lua-5.1.5/src/lvm.c new file mode 100644 index 000000000..e0a0cd852 --- /dev/null +++ b/third-party/lua-5.1.5/src/lvm.c @@ -0,0 +1,767 @@ +/* +** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + TValue temp; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + h->flags = 0; + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + /* else repeat with `tm' */ + setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */ + t = &temp; + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + diff --git a/third-party/lua-5.1.5/src/lvm.h b/third-party/lua-5.1.5/src/lvm.h new file mode 100644 index 000000000..bfe4f5678 --- /dev/null +++ b/third-party/lua-5.1.5/src/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff --git a/third-party/lua-5.1.5/src/lzio.c b/third-party/lua-5.1.5/src/lzio.c new file mode 100644 index 000000000..293edd59b --- /dev/null +++ b/third-party/lua-5.1.5/src/lzio.c @@ -0,0 +1,82 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff --git a/third-party/lua-5.1.5/src/lzio.h b/third-party/lua-5.1.5/src/lzio.h new file mode 100644 index 000000000..51d695d8c --- /dev/null +++ b/third-party/lua-5.1.5/src/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/third-party/lua-5.1.5/src/print.c b/third-party/lua-5.1.5/src/print.c new file mode 100644 index 000000000..e240cfc3c --- /dev/null +++ b/third-party/lua-5.1.5/src/print.c @@ -0,0 +1,227 @@ +/* +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lundump.h" + +#define PrintFunction luaU_print + +#define Sizeof(x) ((int)sizeof(x)) +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + putchar('"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); + break; + case iABx: + if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); + break; + case iAsBx: + if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); + break; + case OP_GETGLOBAL: + case OP_SETGLOBAL: + printf("\t; %s",svalue(&f->k[bx])); + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); + else printf("\t; %d",c); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) (x==1)?"":"s" +#define S(x) x,SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=getstr(f->source); + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + f->numparams,f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->nups)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintConstants(const Proto* f) +{ + int i,n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } +} + +static void PrintUpvalues(const Proto* f) +{ + int i,n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + if (f->upvalues==NULL) return; + for (i=0; iupvalues[i])); + } +} + +void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) + { + PrintConstants(f); + PrintLocals(f); + PrintUpvalues(f); + } + for (i=0; ip[i],full); +} diff --git a/third-party/lua-5.1.5/test/README b/third-party/lua-5.1.5/test/README new file mode 100644 index 000000000..0c7f38bc2 --- /dev/null +++ b/third-party/lua-5.1.5/test/README @@ -0,0 +1,26 @@ +These are simple tests for Lua. Some of them contain useful code. +They are meant to be run to make sure Lua is built correctly and also +to be read, to see how Lua programs look. + +Here is a one-line summary of each program: + + bisect.lua bisection method for solving non-linear equations + cf.lua temperature conversion table (celsius to farenheit) + echo.lua echo command line arguments + env.lua environment variables as automatic global variables + factorial.lua factorial without recursion + fib.lua fibonacci function with cache + fibfor.lua fibonacci numbers with coroutines and generators + globals.lua report global variable usage + hello.lua the first program in every language + life.lua Conway's Game of Life + luac.lua bare-bones luac + printf.lua an implementation of printf + readonly.lua make global variables readonly + sieve.lua the sieve of of Eratosthenes programmed with coroutines + sort.lua two implementations of a sort function + table.lua make table, grouping all data for the same item + trace-calls.lua trace calls + trace-globals.lua trace assigments to global variables + xd.lua hex dump + diff --git a/third-party/lua-5.1.5/test/bisect.lua b/third-party/lua-5.1.5/test/bisect.lua new file mode 100644 index 000000000..f91e69bfb --- /dev/null +++ b/third-party/lua-5.1.5/test/bisect.lua @@ -0,0 +1,27 @@ +-- bisection method for solving non-linear equations + +delta=1e-6 -- tolerance + +function bisect(f,a,b,fa,fb) + local c=(a+b)/2 + io.write(n," c=",c," a=",a," b=",b,"\n") + if c==a or c==b or math.abs(a-b) posted to lua-l +-- modified to use ANSI terminal escape sequences +-- modified to use for instead of while + +local write=io.write + +ALIVE="・" DEAD="" +ALIVE="O" DEAD="-" + +function delay() -- NOTE: SYSTEM-DEPENDENT, adjust as necessary + for i=1,10000 do end + -- local i=os.clock()+1 while(os.clock() 0 do + local xm1,x,xp1,xi=self.w-1,self.w,1,self.w + while xi > 0 do + local sum = self[ym1][xm1] + self[ym1][x] + self[ym1][xp1] + + self[y][xm1] + self[y][xp1] + + self[yp1][xm1] + self[yp1][x] + self[yp1][xp1] + next[y][x] = ((sum==2) and self[y][x]) or ((sum==3) and 1) or 0 + xm1,x,xp1,xi = x,xp1,xp1+1,xi-1 + end + ym1,y,yp1,yi = y,yp1,yp1+1,yi-1 + end +end + +-- output the array to screen +function _CELLS:draw() + local out="" -- accumulate to reduce flicker + for y=1,self.h do + for x=1,self.w do + out=out..(((self[y][x]>0) and ALIVE) or DEAD) + end + out=out.."\n" + end + write(out) +end + +-- constructor +function CELLS(w,h) + local c = ARRAY2D(w,h) + c.spawn = _CELLS.spawn + c.evolve = _CELLS.evolve + c.draw = _CELLS.draw + return c +end + +-- +-- shapes suitable for use with spawn() above +-- +HEART = { 1,0,1,1,0,1,1,1,1; w=3,h=3 } +GLIDER = { 0,0,1,1,0,1,0,1,1; w=3,h=3 } +EXPLODE = { 0,1,0,1,1,1,1,0,1,0,1,0; w=3,h=4 } +FISH = { 0,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0; w=5,h=4 } +BUTTERFLY = { 1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1; w=5,h=5 } + +-- the main routine +function LIFE(w,h) + -- create two arrays + local thisgen = CELLS(w,h) + local nextgen = CELLS(w,h) + + -- create some life + -- about 1000 generations of fun, then a glider steady-state + thisgen:spawn(GLIDER,5,4) + thisgen:spawn(EXPLODE,25,10) + thisgen:spawn(FISH,4,12) + + -- run until break + local gen=1 + write("\027[2J") -- ANSI clear screen + while 1 do + thisgen:evolve(nextgen) + thisgen,nextgen = nextgen,thisgen + write("\027[H") -- ANSI home cursor + thisgen:draw() + write("Life - generation ",gen,"\n") + gen=gen+1 + if gen>2000 then break end + --delay() -- no delay + end +end + +LIFE(40,20) diff --git a/third-party/lua-5.1.5/test/luac.lua b/third-party/lua-5.1.5/test/luac.lua new file mode 100644 index 000000000..96a0a97ce --- /dev/null +++ b/third-party/lua-5.1.5/test/luac.lua @@ -0,0 +1,7 @@ +-- bare-bones luac in Lua +-- usage: lua luac.lua file.lua + +assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") +f=assert(io.open("luac.out","wb")) +assert(f:write(string.dump(assert(loadfile(arg[1]))))) +assert(f:close()) diff --git a/third-party/lua-5.1.5/test/printf.lua b/third-party/lua-5.1.5/test/printf.lua new file mode 100644 index 000000000..58c63ff51 --- /dev/null +++ b/third-party/lua-5.1.5/test/printf.lua @@ -0,0 +1,7 @@ +-- an implementation of printf + +function printf(...) + io.write(string.format(...)) +end + +printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) diff --git a/third-party/lua-5.1.5/test/readonly.lua b/third-party/lua-5.1.5/test/readonly.lua new file mode 100644 index 000000000..85c0b4e01 --- /dev/null +++ b/third-party/lua-5.1.5/test/readonly.lua @@ -0,0 +1,12 @@ +-- make global variables readonly + +local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end +local g={} +local G=getfenv() +setmetatable(g,{__index=G,__newindex=f}) +setfenv(1,g) + +-- an example +rawset(g,"x",3) +x=2 +y=1 -- cannot redefine `y' diff --git a/third-party/lua-5.1.5/test/sieve.lua b/third-party/lua-5.1.5/test/sieve.lua new file mode 100644 index 000000000..0871bb212 --- /dev/null +++ b/third-party/lua-5.1.5/test/sieve.lua @@ -0,0 +1,29 @@ +-- the sieve of of Eratosthenes programmed with coroutines +-- typical usage: lua -e N=1000 sieve.lua | column + +-- generate all the numbers from 2 to n +function gen (n) + return coroutine.wrap(function () + for i=2,n do coroutine.yield(i) end + end) +end + +-- filter the numbers generated by `g', removing multiples of `p' +function filter (p, g) + return coroutine.wrap(function () + while 1 do + local n = g() + if n == nil then return end + if math.mod(n, p) ~= 0 then coroutine.yield(n) end + end + end) +end + +N=N or 1000 -- from command line +x = gen(N) -- generate primes up to N +while 1 do + local n = x() -- pick a number until done + if n == nil then break end + print(n) -- must be a prime number + x = filter(n, x) -- now remove its multiples +end diff --git a/third-party/lua-5.1.5/test/sort.lua b/third-party/lua-5.1.5/test/sort.lua new file mode 100644 index 000000000..0bcb15f83 --- /dev/null +++ b/third-party/lua-5.1.5/test/sort.lua @@ -0,0 +1,66 @@ +-- two implementations of a sort function +-- this is an example only. Lua has now a built-in function "sort" + +-- extracted from Programming Pearls, page 110 +function qsort(x,l,u,f) + if ly end) + show("after reverse selection sort",x) + qsort(x,1,n,function (x,y) return x>> ",string.rep(" ",level)) + if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end + t=debug.getinfo(2) + if event=="call" then + level=level+1 + else + level=level-1 if level<0 then level=0 end + end + if t.what=="main" then + if event=="call" then + io.write("begin ",t.short_src) + else + io.write("end ",t.short_src) + end + elseif t.what=="Lua" then +-- table.foreach(t,print) + io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") + else + io.write(event," ",t.name or "(C)"," [",t.what,"] ") + end + io.write("\n") +end + +debug.sethook(hook,"cr") +level=0 diff --git a/third-party/lua-5.1.5/test/trace-globals.lua b/third-party/lua-5.1.5/test/trace-globals.lua new file mode 100644 index 000000000..295e670ca --- /dev/null +++ b/third-party/lua-5.1.5/test/trace-globals.lua @@ -0,0 +1,38 @@ +-- trace assigments to global variables + +do + -- a tostring that quotes strings. note the use of the original tostring. + local _tostring=tostring + local tostring=function(a) + if type(a)=="string" then + return string.format("%q",a) + else + return _tostring(a) + end + end + + local log=function (name,old,new) + local t=debug.getinfo(3,"Sl") + local line=t.currentline + io.write(t.short_src) + if line>=0 then io.write(":",line) end + io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") + end + + local g={} + local set=function (t,name,value) + log(name,g[name],value) + g[name]=value + end + setmetatable(getfenv(),{__index=g,__newindex=set}) +end + +-- an example + +a=1 +b=2 +a=10 +b=20 +b=nil +b=200 +print(a,b,c) diff --git a/third-party/lua-5.1.5/test/xd.lua b/third-party/lua-5.1.5/test/xd.lua new file mode 100644 index 000000000..ebc3effc0 --- /dev/null +++ b/third-party/lua-5.1.5/test/xd.lua @@ -0,0 +1,14 @@ +-- hex dump +-- usage: lua xd.lua < file + +local offset=0 +while true do + local s=io.read(16) + if s==nil then return end + io.write(string.format("%08X ",offset)) + string.gsub(s,"(.)", + function (c) io.write(string.format("%02X ",string.byte(c))) end) + io.write(string.rep(" ",3*(16-string.len(s)))) + io.write(" ",string.gsub(s,"%c","."),"\n") + offset=offset+16 +end diff --git a/third-party/lua-5.1.5/toluapp-simple/CMakeLists.txt b/third-party/lua-5.1.5/toluapp-simple/CMakeLists.txt new file mode 100644 index 000000000..10b495633 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.1) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + +set(TOLUA_BIN_SRC +tolua.c +toluabind.c +) + +set(TOLUA_LIB_SRC +tolua_event.c +tolua_is.c +tolua_map.c +tolua_push.c +tolua_to.c +) + + +add_library(toluapp51 STATIC "${TOLUA_LIB_SRC}") +add_executable(toluapp "${TOLUA_BIN_SRC}" "${TOLUA_LIB_SRC}") + +target_link_libraries(toluapp51 PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a") +target_link_libraries(toluapp PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a") + + +add_custom_command(TARGET toluapp51 POST_BUILD COMMAND cp "${PROJECT_SOURCE_DIR}/toluapp-simple/tolua++.h" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + +set_target_properties(toluapp PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} + ) + +set_target_properties(toluapp51 PROPERTIES LINKER_LANGUAGE CXX) +set_target_properties(toluapp PROPERTIES LINKER_LANGUAGE CXX) + +include_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) diff --git a/third-party/lua-5.1.5/toluapp-simple/COPYRIGHT b/third-party/lua-5.1.5/toluapp-simple/COPYRIGHT new file mode 100644 index 000000000..9e99e0080 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/COPYRIGHT @@ -0,0 +1,33 @@ +tolua++ License +--------------- + +tolua++ is based on toLua (www.tecgraf.puc-rio.br/~celes/tolua), and +it's licensed under the terms of the MIT license reproduced below. +This means that Lua is free software and can be used for both academic +and commercial purposes at absolutely no cost. + +=============================================================================== + +Copyright (C) 2009 Ariel Manzur. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=============================================================================== + +(end of COPYRIGHT) diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua++.h b/third-party/lua-5.1.5/toluapp-simple/tolua++.h new file mode 100644 index 000000000..ed5344926 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua++.h @@ -0,0 +1,186 @@ +/* tolua +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + + +#ifndef TOLUA_H +#define TOLUA_H + +#ifndef TOLUA_API +#define TOLUA_API extern +#endif + +#define TOLUA_VERSION "tolua++-1.0.92" + +#ifdef __cplusplus +extern "C" { +#endif + +#define tolua_pushcppstring(x,y) tolua_pushstring(x,y.c_str()) +#define tolua_iscppstring tolua_isstring + +#define tolua_iscppstringarray tolua_isstringarray +#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str()) + +#ifndef TEMPLATE_BIND + #define TEMPLATE_BIND(p) +#endif + +#define TOLUA_TEMPLATE_BIND(p) + +#define TOLUA_PROTECTED_DESTRUCTOR +#define TOLUA_PROPERTY_TYPE(p) + +typedef int lua_Object; + +#include "lua.h" +#include "lauxlib.h" + +struct tolua_Error +{ + int index; + int array; + const char* type; +}; +typedef struct tolua_Error tolua_Error; + +#define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */ + +TOLUA_API const char* tolua_typename (lua_State* L, int lo); +TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err); +TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err); +TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err); +TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err); +TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err); +TOLUA_API int tolua_isvaluearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isbooleanarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isnumberarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isstringarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_istablearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isuserdataarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isusertypearray + (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err); + +TOLUA_API void tolua_open (lua_State* L); + +TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size); +TOLUA_API int tolua_register_gc (lua_State* L, int lo); +TOLUA_API int tolua_default_collect (lua_State* tolua_S); + +TOLUA_API void tolua_usertype (lua_State* L, const char* type); +TOLUA_API void tolua_beginmodule (lua_State* L, const char* name); +TOLUA_API void tolua_endmodule (lua_State* L); +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar); +TOLUA_API void tolua_class (lua_State* L, const char* name, const char* base); +TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col); +TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func); +TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value); +TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set); +TOLUA_API void tolua_array (lua_State* L,const char* name, lua_CFunction get, lua_CFunction set); + +/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */ +/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */ + +TOLUA_API void tolua_pushvalue (lua_State* L, int lo); +TOLUA_API void tolua_pushboolean (lua_State* L, int value); +TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value); +TOLUA_API void tolua_pushstring (lua_State* L, const char* value); +TOLUA_API void tolua_pushuserdata (lua_State* L, void* value); +TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type); +TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type); +TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v); +TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v); +TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v); +TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v); +TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v); +TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type); +TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type); + +TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def); +TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def); +TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def); +TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def); +TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def); +TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def); +TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def); +TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def); +TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def); +TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def); +TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def); +TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def); + +TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name); + +TOLUA_API int class_gc_event (lua_State* L); + +#ifdef __cplusplus +static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) { + + const char* s = tolua_tostring(L, narg, def); + return s?s:""; +}; + +static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) { + + const char* s = tolua_tofieldstring(L, lo, index, def); + return s?s:""; +}; + +#else +#define tolua_tocppstring tolua_tostring +#define tolua_tofieldcppstring tolua_tofieldstring +#endif + +TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index); + +#ifndef Mtolua_new +#define Mtolua_new(EXP) new EXP +#endif + +#ifndef Mtolua_delete +#define Mtolua_delete(EXP) delete EXP +#endif + +#ifndef Mtolua_new_dim +#define Mtolua_new_dim(EXP, len) new EXP[len] +#endif + +#ifndef Mtolua_delete_dim +#define Mtolua_delete_dim(EXP) delete [] EXP +#endif + +#ifndef tolua_outside +#define tolua_outside +#endif + +#ifndef tolua_owned +#define tolua_owned +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua.c b/third-party/lua-5.1.5/toluapp-simple/tolua.c new file mode 100644 index 000000000..cc9f9adcd --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua.c @@ -0,0 +1,169 @@ +/* tolua +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Aug 2003 +** $Id:$ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" + +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" + +#include +#include +#include + + +static void help (void) +{ + fprintf(stderr,"\n" + "usage: tolua++ [options] input_file\n" + "\n" + "Command line options are:\n" + " -v : print version information.\n" + " -o file : set output file; default is stdout.\n" + " -H file : create include file.\n" + " -n name : set package name; default is input file root name.\n" + " -p : parse only.\n" + " -P : parse and print structure information (for debug).\n" + " -S : disable support for c++ strings.\n" + " -1 : substract 1 to operator[] index (for compatibility with tolua5).\n" + " -L file : run lua file (with dofile()) before doing anything.\n" + " -D : disable automatic exporting of destructors for classes that have\n" + " constructors (for compatibility with tolua5)\n" + " -W : disable warnings for unsupported features (for compatibility\n" + " with tolua5)\n" + " -C : disable cleanup of included lua code (for easier debugging)\n" + " -E value[=value] : add extra values to the luastate\n" + " -t : export a list of types asociates with the C++ typeid name\n" + " -q : don't print warnings to the console\n" + " -h : print this message.\n" + "Should the input file be omitted, stdin is assumed;\n" + "in that case, the package name must be explicitly set.\n\n" + ); +} + +static void version (void) +{ + fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n",TOLUA_VERSION); +} + +static void setfield (lua_State* L, int table, char* f, char* v) +{ + lua_pushstring(L,f); + lua_pushstring(L,v); + lua_settable(L,table); +} + +static void add_extra (lua_State* L, char* value) { + int len; + lua_getglobal(L, "_extra_parameters"); + len = luaL_getn(L, -1); + lua_pushstring(L, value); + lua_rawseti(L, -2, len+1); + lua_pop(L, 1); +}; + +static void error (char* o) +{ + fprintf(stderr,"tolua: unknown option '%s'\n",o); + help(); + exit(1); +} + +int main (int argc, char* argv[]) +{ + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + #else + lua_State* L = lua_open(); + luaopen_base(L); + luaopen_io(L); + luaopen_string(L); + luaopen_table(L); + luaopen_math(L); + luaopen_debug(L); + #endif + + lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION"); + lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION"); + + if (argc==1) + { + help(); + return 0; + } + else + { + int i, t; + lua_newtable(L); + lua_setglobal(L, "_extra_parameters"); + lua_newtable(L); + lua_pushvalue(L,-1); + lua_setglobal(L,"flags"); + t = lua_gettop(L); + for (i=1; i + +#include "tolua++.h" + +/* Store at ubox + * It stores, creating the corresponding table if needed, + * the pair key/value in the corresponding ubox table +*/ +static void storeatubox (lua_State* L, int lo) +{ + #ifdef LUA_VERSION_NUM + lua_getfenv(L, lo); + if (lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pop(L, 1); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setfenv(L, lo); /* stack: k,v,table */ + }; + lua_insert(L, -3); + lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */ + lua_pop(L, 1); + #else + /* stack: key value (to be stored) */ + lua_pushstring(L,"tolua_peers"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: k v ubox */ + lua_pushvalue(L,lo); + lua_rawget(L,-2); /* stack: k v ubox ubox[u] */ + if (!lua_istable(L,-1)) + { + lua_pop(L,1); /* stack: k v ubox */ + lua_newtable(L); /* stack: k v ubox table */ + lua_pushvalue(L,1); + lua_pushvalue(L,-2); /* stack: k v ubox table u table */ + lua_rawset(L,-4); /* stack: k v ubox ubox[u]=table */ + } + lua_insert(L,-4); /* put table before k */ + lua_pop(L,1); /* pop ubox */ + lua_rawset(L,-3); /* store at table */ + lua_pop(L,1); /* pop ubox[u] */ + #endif +} + +/* Module index function +*/ +static int module_index_event (lua_State* L) +{ + lua_pushstring(L,".get"); + lua_rawget(L,-3); + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { + lua_call(L,0,1); + return 1; + } + else if (lua_istable(L,-1)) + return 1; + } + /* call old index meta event */ + if (lua_getmetatable(L,1)) + { + lua_pushstring(L,"__index"); + lua_rawget(L,-2); + lua_pushvalue(L,1); + lua_pushvalue(L,2); + if (lua_isfunction(L,-1)) + { + lua_call(L,2,1); + return 1; + } + else if (lua_istable(L,-1)) + { + lua_gettable(L,-3); + return 1; + } + } + lua_pushnil(L); + return 1; +} + +/* Module newindex function +*/ +static int module_newindex_event (lua_State* L) +{ + lua_pushstring(L,".set"); + lua_rawget(L,-4); + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); /* only to be compatible with non-static vars */ + lua_pushvalue(L,3); /* value */ + lua_call(L,2,0); + return 0; + } + } + /* call old newindex meta event */ + if (lua_getmetatable(L,1) && lua_getmetatable(L,-1)) + { + lua_pushstring(L,"__newindex"); + lua_rawget(L,-2); + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_pushvalue(L,3); + lua_call(L,3,0); + } + } + lua_settop(L,3); + lua_rawset(L,-3); + return 0; +} + +/* Class index function + * If the object is a userdata (ie, an object), it searches the field in + * the alternative table stored in the corresponding "ubox" table. +*/ +static int class_index_event (lua_State* L) +{ + int t = lua_type(L,1); + if (t == LUA_TUSERDATA) + { + /* Access alternative table */ + #ifdef LUA_VERSION_NUM /* new macro on version 5.1 */ + lua_getfenv(L,1); + if (!lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pushvalue(L, 2); /* key */ + lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */ + if (!lua_isnil(L, -1)) + return 1; + }; + #else + lua_pushstring(L,"tolua_peers"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: obj key ubox */ + lua_pushvalue(L,1); + lua_rawget(L,-2); /* stack: obj key ubox ubox[u] */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* stack: obj key ubox ubox[u] value */ + if (!lua_isnil(L,-1)) + return 1; + } + #endif + lua_settop(L,2); /* stack: obj key */ + /* Try metatables */ + lua_pushvalue(L,1); /* stack: obj key obj */ + while (lua_getmetatable(L,-1)) + { /* stack: obj key obj mt */ + lua_remove(L,-2); /* stack: obj key mt */ + if (lua_isnumber(L,2)) /* check if key is a numeric value */ + { + /* try operator[] */ + lua_pushstring(L,".geti"); + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + } + else + { + lua_pushvalue(L,2); /* stack: obj key mt key */ + lua_rawget(L,-2); /* stack: obj key mt value */ + if (!lua_isnil(L,-1)) + return 1; + else + lua_pop(L,1); + /* try C/C++ variable */ + lua_pushstring(L,".get"); + lua_rawget(L,-2); /* stack: obj key mt tget */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); + lua_rawget(L,-2); /* stack: obj key mt value */ + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + else if (lua_istable(L,-1)) + { + /* deal with array: create table to be returned and cache it in ubox */ + void* u = *((void**)lua_touserdata(L,1)); + lua_newtable(L); /* stack: obj key mt value table */ + lua_pushstring(L,".self"); + lua_pushlightuserdata(L,u); + lua_rawset(L,-3); /* store usertype in ".self" */ + lua_insert(L,-2); /* stack: obj key mt table value */ + lua_setmetatable(L,-2); /* set stored value as metatable */ + lua_pushvalue(L,-1); /* stack: obj key met table table */ + lua_pushvalue(L,2); /* stack: obj key mt table table key */ + lua_insert(L,-2); /* stack: obj key mt table key table */ + storeatubox(L,1); /* stack: obj key mt table */ + return 1; + } + } + } + lua_settop(L,3); + } + lua_pushnil(L); + return 1; + } + else if (t== LUA_TTABLE) + { + module_index_event(L); + return 1; + } + lua_pushnil(L); + return 1; +} + +/* Newindex function + * It first searches for a C/C++ varaible to be set. + * Then, it either stores it in the alternative ubox table (in the case it is + * an object) or in the own table (that represents the class or module). +*/ +static int class_newindex_event (lua_State* L) +{ + int t = lua_type(L,1); + if (t == LUA_TUSERDATA) + { + /* Try accessing a C/C++ variable to be set */ + lua_getmetatable(L,1); + while (lua_istable(L,-1)) /* stack: t k v mt */ + { + if (lua_isnumber(L,2)) /* check if key is a numeric value */ + { + /* try operator[] */ + lua_pushstring(L,".seti"); + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_pushvalue(L,3); + lua_call(L,3,0); + return 0; + } + } + else + { + lua_pushstring(L,".set"); + lua_rawget(L,-2); /* stack: t k v mt tset */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); + lua_rawget(L,-2); /* stack: t k v mt tset func */ + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,3); + lua_call(L,2,0); + return 0; + } + lua_pop(L,1); /* stack: t k v mt tset */ + } + lua_pop(L,1); /* stack: t k v mt */ + if (!lua_getmetatable(L,-1)) /* stack: t k v mt mt */ + lua_pushnil(L); + lua_remove(L,-2); /* stack: t k v mt */ + } + } + lua_settop(L,3); /* stack: t k v */ + + /* then, store as a new field */ + storeatubox(L,1); + } + else if (t== LUA_TTABLE) + { + module_newindex_event(L); + } + return 0; +} + +static int class_call_event(lua_State* L) { + + if (lua_istable(L, 1)) { + lua_pushstring(L, ".call"); + lua_rawget(L, 1); + if (lua_isfunction(L, -1)) { + + lua_insert(L, 1); + lua_call(L, lua_gettop(L)-1, 1); + + return 1; + }; + }; + tolua_error(L,"Attempt to call a non-callable object.",NULL); + return 0; +}; + +static int do_operator (lua_State* L, const char* op) +{ + if (lua_isuserdata(L,1)) + { + /* Try metatables */ + lua_pushvalue(L,1); /* stack: op1 op2 */ + while (lua_getmetatable(L,-1)) + { /* stack: op1 op2 op1 mt */ + lua_remove(L,-2); /* stack: op1 op2 mt */ + lua_pushstring(L,op); /* stack: op1 op2 mt key */ + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + lua_settop(L,3); + } + } + tolua_error(L,"Attempt to perform operation on an invalid operand",NULL); + return 0; +} + +static int class_add_event (lua_State* L) +{ + return do_operator(L,".add"); +} + +static int class_sub_event (lua_State* L) +{ + return do_operator(L,".sub"); +} + +static int class_mul_event (lua_State* L) +{ + return do_operator(L,".mul"); +} + +static int class_div_event (lua_State* L) +{ + return do_operator(L,".div"); +} + +static int class_lt_event (lua_State* L) +{ + return do_operator(L,".lt"); +} + +static int class_le_event (lua_State* L) +{ + return do_operator(L,".le"); +} + +static int class_eq_event (lua_State* L) +{ + /* copying code from do_operator here to return false when no operator is found */ + if (lua_isuserdata(L,1)) + { + /* Try metatables */ + lua_pushvalue(L,1); /* stack: op1 op2 */ + while (lua_getmetatable(L,-1)) + { /* stack: op1 op2 op1 mt */ + lua_remove(L,-2); /* stack: op1 op2 mt */ + lua_pushstring(L,".eq"); /* stack: op1 op2 mt key */ + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + lua_settop(L,3); + } + } + + lua_settop(L, 3); + lua_pushboolean(L, 0); + return 1; +} + +/* +static int class_gc_event (lua_State* L) +{ + void* u = *((void**)lua_touserdata(L,1)); + fprintf(stderr, "collecting: looking at %p\n", u); + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_call(L,1,0); + lua_pushlightuserdata(L,u); + lua_pushnil(L); + lua_rawset(L,-3); + } + lua_pop(L,2); + return 0; +} +*/ +TOLUA_API int class_gc_event (lua_State* L) +{ + void* u = *((void**)lua_touserdata(L,1)); + int top; + /*fprintf(stderr, "collecting: looking at %p\n", u);*/ + /* + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + */ + lua_pushvalue(L, lua_upvalueindex(1)); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); /* stack: gc umt */ + lua_getmetatable(L,1); /* stack: gc umt mt */ + /*fprintf(stderr, "checking type\n");*/ + top = lua_gettop(L); + if (tolua_fast_isa(L,top,top-1, lua_upvalueindex(2))) /* make sure we collect correct type */ + { + /*fprintf(stderr, "Found type!\n");*/ + /* get gc function */ + lua_pushliteral(L,".collector"); + lua_rawget(L,-2); /* stack: gc umt mt collector */ + if (lua_isfunction(L,-1)) { + /*fprintf(stderr, "Found .collector!\n");*/ + } + else { + lua_pop(L,1); + /*fprintf(stderr, "Using default cleanup\n");*/ + lua_pushcfunction(L,tolua_default_collect); + } + + lua_pushvalue(L,1); /* stack: gc umt mt collector u */ + lua_call(L,1,0); + + lua_pushlightuserdata(L,u); /* stack: gc umt mt u */ + lua_pushnil(L); /* stack: gc umt mt u nil */ + lua_rawset(L,-5); /* stack: gc umt mt */ + } + lua_pop(L,3); + return 0; +} + + +/* Register module events + * It expects the metatable on the top of the stack +*/ +TOLUA_API void tolua_moduleevents (lua_State* L) +{ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,module_index_event); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,module_newindex_event); + lua_rawset(L,-3); +} + +/* Check if the object on the top has a module metatable +*/ +TOLUA_API int tolua_ismodulemetatable (lua_State* L) +{ + int r = 0; + if (lua_getmetatable(L,-1)) + { + lua_pushstring(L,"__index"); + lua_rawget(L,-2); + r = (lua_tocfunction(L,-1) == module_index_event); + lua_pop(L,2); + } + return r; +} + +/* Register class events + * It expects the metatable on the top of the stack +*/ +TOLUA_API void tolua_classevents (lua_State* L) +{ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,class_index_event); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,class_newindex_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__add"); + lua_pushcfunction(L,class_add_event); + lua_rawset(L,-3); + lua_pushstring(L,"__sub"); + lua_pushcfunction(L,class_sub_event); + lua_rawset(L,-3); + lua_pushstring(L,"__mul"); + lua_pushcfunction(L,class_mul_event); + lua_rawset(L,-3); + lua_pushstring(L,"__div"); + lua_pushcfunction(L,class_div_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__lt"); + lua_pushcfunction(L,class_lt_event); + lua_rawset(L,-3); + lua_pushstring(L,"__le"); + lua_pushcfunction(L,class_le_event); + lua_rawset(L,-3); + lua_pushstring(L,"__eq"); + lua_pushcfunction(L,class_eq_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__call"); + lua_pushcfunction(L,class_call_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__gc"); + lua_pushstring(L, "tolua_gc_event"); + lua_rawget(L, LUA_REGISTRYINDEX); + /*lua_pushcfunction(L,class_gc_event);*/ + lua_rawset(L,-3); +} + diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua_event.h b/third-party/lua-5.1.5/toluapp-simple/tolua_event.h new file mode 100644 index 000000000..898f33dfc --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua_event.h @@ -0,0 +1,24 @@ +/* tolua: event functions +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#ifndef TOLUA_EVENT_H +#define TOLUA_EVENT_H + +#include "tolua++.h" + +TOLUA_API void tolua_moduleevents (lua_State* L); +TOLUA_API int tolua_ismodulemetatable (lua_State* L); +TOLUA_API void tolua_classevents (lua_State* L); + +#endif diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua_is.c b/third-party/lua-5.1.5/toluapp-simple/tolua_is.c new file mode 100644 index 000000000..add337d19 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua_is.c @@ -0,0 +1,621 @@ +/* tolua: functions to check types. +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "lauxlib.h" + +#include +#include + +/* a fast check if a is b, without parameter validation + i.e. if b is equal to a or a superclass of a. */ +TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index) +{ + int result; + if (lua_rawequal(L,mt_indexa,mt_indexb)) + result = 1; + else + { + if (super_index) { + lua_pushvalue(L, super_index); + } else { + lua_pushliteral(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ + }; + lua_pushvalue(L,mt_indexa); /* stack: super mta */ + lua_rawget(L,-2); /* stack: super super[mta] */ + lua_pushvalue(L,mt_indexb); /* stack: super super[mta] mtb */ + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super super[mta] typenameB */ + lua_rawget(L,-2); /* stack: super super[mta] bool */ + result = lua_toboolean(L,-1); + lua_pop(L,3); + } + return result; +} + +/* Push and returns the corresponding object typename */ +TOLUA_API const char* tolua_typename (lua_State* L, int lo) +{ + int tag = lua_type(L,lo); + if (tag == LUA_TNONE) + lua_pushstring(L,"[no object]"); + else if (tag != LUA_TUSERDATA && tag != LUA_TTABLE) + lua_pushstring(L,lua_typename(L,tag)); + else if (tag == LUA_TUSERDATA) + { + if (!lua_getmetatable(L,lo)) + lua_pushstring(L,lua_typename(L,tag)); + else + { + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isstring(L,-1)) + { + lua_pop(L,1); + lua_pushstring(L,"[undefined]"); + } + } + } + else /* is table */ + { + lua_pushvalue(L,lo); + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isstring(L,-1)) + { + lua_pop(L,1); + lua_pushstring(L,"table"); + } + else + { + lua_pushstring(L,"class "); + lua_insert(L,-2); + lua_concat(L,2); + } + } + return lua_tostring(L,-1); +} + +TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err) +{ + if (msg[0] == '#') + { + const char* expected = err->type; + const char* provided = tolua_typename(L,err->index); + if (msg[1]=='f') + { + int narg = err->index; + if (err->array) + luaL_error(L,"%s\n argument #%d is array of '%s'; array of '%s' expected.\n", + msg+2,narg,provided,expected); + else + luaL_error(L,"%s\n argument #%d is '%s'; '%s' expected.\n", + msg+2,narg,provided,expected); + } + else if (msg[1]=='v') + { + if (err->array) + luaL_error(L,"%s\n value is array of '%s'; array of '%s' expected.\n", + msg+2,provided,expected); + else + luaL_error(L,"%s\n value is '%s'; '%s' expected.\n", + msg+2,provided,expected); + } + } + else + luaL_error(L,msg); +} + +/* the equivalent of lua_is* for usertable */ +static int lua_isusertable (lua_State* L, int lo, const const char* type) +{ + int r = 0; + if (lo < 0) lo = lua_gettop(L)+lo+1; + lua_pushvalue(L,lo); + lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[t] */ + if (lua_isstring(L,-1)) + { + r = strcmp(lua_tostring(L,-1),type)==0; + if (!r) + { + /* try const */ + lua_pushstring(L,"const "); + lua_insert(L,-2); + lua_concat(L,2); + r = lua_isstring(L,-1) && strcmp(lua_tostring(L,-1),type)==0; + } + } + lua_pop(L, 1); + return r; +} + +int push_table_instance(lua_State* L, int lo) { + + if (lua_istable(L, lo)) { + + lua_pushstring(L, ".c_instance"); + lua_gettable(L, lo); + if (lua_isuserdata(L, -1)) { + + lua_replace(L, lo); + return 1; + } else { + + lua_pop(L, 1); + return 0; + }; + } else { + return 0; + }; + + return 0; +}; + +/* the equivalent of lua_is* for usertype */ +static int lua_isusertype (lua_State* L, int lo, const char* type) +{ + if (!lua_isuserdata(L,lo)) { + if (!push_table_instance(L, lo)) { + return 0; + }; + }; + { + /* check if it is of the same type */ + int r; + const char *tn; + if (lua_getmetatable(L,lo)) /* if metatable? */ + { + lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[mt] */ + tn = lua_tostring(L,-1); + r = tn && (strcmp(tn,type) == 0); + lua_pop(L, 1); + if (r) + return 1; + else + { + /* check if it is a specialized class */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* get super */ + lua_getmetatable(L,lo); + lua_rawget(L,-2); /* get super[mt] */ + if (lua_istable(L,-1)) + { + int b; + lua_pushstring(L,type); + lua_rawget(L,-2); /* get super[mt][type] */ + b = lua_toboolean(L,-1); + lua_pop(L,3); + if (b) + return 1; + } + } + } + } + return 0; +} + +TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err) +{ + if (lua_gettop(L)index = lo; + err->array = 0; + err->type = "[no object]"; + return 0; +} + +TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "boolean"; + return 0; +} + +TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "number"; + return 0; +} + +TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "string"; + return 0; +} + +TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "table"; + return 0; +} + +TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = type; + return 0; +} + + +TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "userdata"; + return 0; +} + +TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) { + + if (lua_gettop(L)index = lo; + err->array = 0; + err->type = "value"; + return 1; +}; + +TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def || abs(lo)<=lua_gettop(L)) /* any valid index */ + return 1; + err->index = lo; + err->array = 0; + err->type = "value"; + return 0; +} + +TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = type; + return 0; +} + +TOLUA_API int tolua_isvaluearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + return 1; +} + +TOLUA_API int tolua_isbooleanarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "boolean"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isnumberarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!lua_isnumber(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "number"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isstringarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "string"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_istablearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (! lua_istable(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "table"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isuserdataarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "userdata"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isusertypearray + (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->type = type; + err->array = 1; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +#if 0 +int tolua_isbooleanfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "boolean"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isnumberfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!lua_isnumber(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "number"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isstringfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "string"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_istablefield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i+1); + lua_gettable(L,lo); + if (! lua_istable(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "table"; + return 0; + } + lua_pop(L,1); +} + +int tolua_isusertablefield + (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (! lua_isusertable(L,-1,type) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = type; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isuserdatafield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "userdata"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isusertypefield + (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isusertype(L,-1,type)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->type = type; + err->array = 1; + return 0; + } + lua_pop(L,1); + return 1; +} + +#endif diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua_map.c b/third-party/lua-5.1.5/toluapp-simple/tolua_map.c new file mode 100644 index 000000000..d00e7069b --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua_map.c @@ -0,0 +1,704 @@ +/* tolua: functions to map features +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "tolua_event.h" +#include "lauxlib.h" + +#include +#include +#include +#include + + +/* Create metatable + * Create and register new metatable +*/ +static int tolua_newmetatable (lua_State* L, char* name) +{ + int r = luaL_newmetatable(L,name); + + #ifdef LUA_VERSION_NUM /* only lua 5.1 */ + if (r) { + lua_pushvalue(L, -1); + lua_pushstring(L, name); + lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */ + }; + #endif + + if (r) + tolua_classevents(L); /* set meta events */ + lua_pop(L,1); + return r; +} + +/* Map super classes + * It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name' +*/ +static void mapsuper (lua_State* L, const char* name, const char* base) +{ + /* push registry.super */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ + luaL_getmetatable(L,name); /* stack: super mt */ + lua_rawget(L,-2); /* stack: super table */ + if (lua_isnil(L,-1)) + { + /* create table */ + lua_pop(L,1); + lua_newtable(L); /* stack: super table */ + luaL_getmetatable(L,name); /* stack: super table mt */ + lua_pushvalue(L,-2); /* stack: super table mt table */ + lua_rawset(L,-4); /* stack: super table */ + } + + /* set base as super class */ + lua_pushstring(L,base); + lua_pushboolean(L,1); + lua_rawset(L,-3); /* stack: super table */ + + /* set all super class of base as super class of name */ + luaL_getmetatable(L,base); /* stack: super table base_mt */ + lua_rawget(L,-3); /* stack: super table base_table */ + if (lua_istable(L,-1)) + { + /* traverse base table */ + lua_pushnil(L); /* first key */ + while (lua_next(L,-2) != 0) + { + /* stack: ... base_table key value */ + lua_pushvalue(L,-2); /* stack: ... base_table key value key */ + lua_insert(L,-2); /* stack: ... base_table key key value */ + lua_rawset(L,-5); /* stack: ... base_table key */ + } + } + lua_pop(L,3); /* stack: */ +} + +/* creates a 'tolua_ubox' table for base clases, and +// expects the metatable and base metatable on the stack */ +static void set_ubox(lua_State* L) { + + /* mt basemt */ + if (!lua_isnil(L, -1)) { + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L,-2); + } else { + lua_pushnil(L); + }; + /* mt basemt base_ubox */ + if (!lua_isnil(L,-1)) { + lua_pushstring(L, "tolua_ubox"); + lua_insert(L, -2); + /* mt basemt key ubox */ + lua_rawset(L,-4); + /* (mt with ubox) basemt */ + } else { + /* mt basemt nil */ + lua_pop(L, 1); + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be + garbage-collected */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ + lua_setmetatable(L, -2); /* stack:mt basemt string ubox */ + lua_rawset(L,-4); + }; + +}; + +/* Map inheritance + * It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name' +*/ +static void mapinheritance (lua_State* L, const char* name, const char* base) +{ + /* set metatable inheritance */ + luaL_getmetatable(L,name); + + if (base && *base) + luaL_getmetatable(L,base); + else { + + if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */ + lua_pop(L, 2); + return; + }; + luaL_getmetatable(L,"tolua_commonclass"); + }; + + set_ubox(L); + + lua_setmetatable(L,-2); + lua_pop(L,1); +} + +/* Object type +*/ +static int tolua_bnd_type (lua_State* L) +{ + tolua_typename(L,lua_gettop(L)); + return 1; +} + +/* Take ownership +*/ +static int tolua_bnd_takeownership (lua_State* L) +{ + int success = 0; + if (lua_isuserdata(L,1)) + { + if (lua_getmetatable(L,1)) /* if metatable? */ + { + lua_pop(L,1); /* clear metatable off stack */ + /* force garbage collection to avoid C to reuse a to-be-collected address */ + #ifdef LUA_VERSION_NUM + lua_gc(L, LUA_GCCOLLECT, 0); + #else + lua_setgcthreshold(L,0); + #endif + + success = tolua_register_gc(L,1); + } + } + lua_pushboolean(L,success!=0); + return 1; +} + +/* Release ownership +*/ +static int tolua_bnd_releaseownership (lua_State* L) +{ + int done = 0; + if (lua_isuserdata(L,1)) + { + void* u = *((void**)lua_touserdata(L,1)); + /* force garbage collection to avoid releasing a to-be-collected address */ + #ifdef LUA_VERSION_NUM + lua_gc(L, LUA_GCCOLLECT, 0); + #else + lua_setgcthreshold(L,0); + #endif + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); + lua_getmetatable(L,1); + if (lua_rawequal(L,-1,-2)) /* check that we are releasing the correct type */ + { + lua_pushlightuserdata(L,u); + lua_pushnil(L); + lua_rawset(L,-5); + done = 1; + } + } + lua_pushboolean(L,done!=0); + return 1; +} + +/* Type casting +*/ +static int tolua_bnd_cast (lua_State* L) +{ + +/* // old code + void* v = tolua_tousertype(L,1,NULL); + const char* s = tolua_tostring(L,2,NULL); + if (v && s) + tolua_pushusertype(L,v,s); + else + lua_pushnil(L); + return 1; +*/ + + void* v; + const char* s; + if (lua_islightuserdata(L, 1)) { + v = tolua_touserdata(L, 1, NULL); + } else { + v = tolua_tousertype(L, 1, 0); + }; + + s = tolua_tostring(L,2,NULL); + if (v && s) + tolua_pushusertype(L,v,s); + else + lua_pushnil(L); + return 1; +} + +/* Inheritance +*/ +static int tolua_bnd_inherit (lua_State* L) { + + /* stack: lua object, c object */ + lua_pushstring(L, ".c_instance"); + lua_pushvalue(L, -2); + lua_rawset(L, -4); + /* l_obj[".c_instance"] = c_obj */ + + return 0; +}; + +#ifdef LUA_VERSION_NUM /* lua 5.1 */ +static int tolua_bnd_setpeer(lua_State* L) { + + /* stack: userdata, table */ + if (!lua_isuserdata(L, -2)) { + lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected."); + lua_error(L); + }; + + if (lua_isnil(L, -1)) { + + lua_pop(L, 1); + lua_pushvalue(L, TOLUA_NOPEER); + }; + lua_setfenv(L, -2); + + return 0; +}; + +static int tolua_bnd_getpeer(lua_State* L) { + + /* stack: userdata */ + lua_getfenv(L, -1); + if (lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pop(L, 1); + lua_pushnil(L); + }; + return 1; +}; +#endif + +/* static int class_gc_event (lua_State* L); */ + +TOLUA_API void tolua_open (lua_State* L) +{ + int top = lua_gettop(L); + lua_pushstring(L,"tolua_opened"); + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isboolean(L,-1)) + { + lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX); + + #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */ + /* create peer object table */ + lua_pushstring(L, "tolua_peers"); lua_newtable(L); + /* make weak key metatable for peers indexed by userdata object */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3); /* stack: string peers mt */ + lua_setmetatable(L, -2); /* stack: string peers */ + lua_rawset(L,LUA_REGISTRYINDEX); + #endif + + /* create object ptr -> udata mapping table */ + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be + garbage-collected */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ + lua_setmetatable(L, -2); /* stack: string ubox */ + lua_rawset(L,LUA_REGISTRYINDEX); + + lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX); + lua_pushstring(L,"tolua_gc"); lua_newtable(L);lua_rawset(L,LUA_REGISTRYINDEX); + + /* create gc_event closure */ + lua_pushstring(L, "tolua_gc_event"); + lua_pushstring(L, "tolua_gc"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushstring(L, "tolua_super"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushcclosure(L, class_gc_event, 2); + lua_rawset(L, LUA_REGISTRYINDEX); + + tolua_newmetatable(L,"tolua_commonclass"); + + tolua_module(L,NULL,0); + tolua_beginmodule(L,NULL); + tolua_module(L,"tolua",0); + tolua_beginmodule(L,"tolua"); + tolua_function(L,"type",tolua_bnd_type); + tolua_function(L,"takeownership",tolua_bnd_takeownership); + tolua_function(L,"releaseownership",tolua_bnd_releaseownership); + tolua_function(L,"cast",tolua_bnd_cast); + tolua_function(L,"inherit", tolua_bnd_inherit); + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + tolua_function(L, "setpeer", tolua_bnd_setpeer); + tolua_function(L, "getpeer", tolua_bnd_getpeer); + #endif + + tolua_endmodule(L); + tolua_endmodule(L); + } + lua_settop(L,top); +} + +/* Copy a C object +*/ +TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size) +{ + void* clone = (void*)malloc(size); + if (clone) + memcpy(clone,value,size); + else + tolua_error(L,"insuficient memory",NULL); + return clone; +} + +/* Default collect function +*/ +TOLUA_API int tolua_default_collect (lua_State* tolua_S) +{ + void* self = tolua_tousertype(tolua_S,1,0); + free(self); + return 0; +} + +/* Do clone +*/ +TOLUA_API int tolua_register_gc (lua_State* L, int lo) +{ + int success = 1; + void *value = *(void **)lua_touserdata(L,lo); + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,value); + lua_rawget(L,-2); + if (!lua_isnil(L,-1)) /* make sure that object is not already owned */ + success = 0; + else + { + lua_pushlightuserdata(L,value); + lua_getmetatable(L,lo); + lua_rawset(L,-4); + } + lua_pop(L,2); + return success; +} + +/* Register a usertype + * It creates the correspoding metatable in the registry, for both 'type' and 'const type'. + * It maps 'const type' as being also a 'type' +*/ +TOLUA_API void tolua_usertype (lua_State* L, const char* type) +{ + char ctype[128] = "const "; + strncat(ctype,type,120); + + /* create both metatables */ + if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type)) + mapsuper(L,type,ctype); /* 'type' is also a 'const type' */ +} + + +/* Begin module + * It pushes the module (or class) table on the stack +*/ +TOLUA_API void tolua_beginmodule (lua_State* L, const char* name) +{ + if (name) + { + lua_pushstring(L,name); + lua_rawget(L,-2); + } + else + lua_pushvalue(L,LUA_GLOBALSINDEX); +} + +/* End module + * It pops the module (or class) from the stack +*/ +TOLUA_API void tolua_endmodule (lua_State* L) +{ + lua_pop(L,1); +} + +/* Map module + * It creates a new module +*/ +#if 1 +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) +{ + if (name) + { + /* tolua module */ + lua_pushstring(L,name); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) /* check if module already exists */ + { + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,name); + lua_pushvalue(L,-2); + lua_rawset(L,-4); /* assing module into module */ + } + } + else + { + /* global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + } + if (hasvar) + { + if (!tolua_ismodulemetatable(L)) /* check if it already has a module metatable */ + { + /* create metatable to get/set C/C++ variable */ + lua_newtable(L); + tolua_moduleevents(L); + if (lua_getmetatable(L,-2)) + lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ + lua_setmetatable(L,-2); + } + } + lua_pop(L,1); /* pop module */ +} +#else +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) +{ + if (name) + { + /* tolua module */ + lua_pushstring(L,name); + lua_newtable(L); + } + else + { + /* global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + } + if (hasvar) + { + /* create metatable to get/set C/C++ variable */ + lua_newtable(L); + tolua_moduleevents(L); + if (lua_getmetatable(L,-2)) + lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ + lua_setmetatable(L,-2); + } + if (name) + lua_rawset(L,-3); /* assing module into module */ + else + lua_pop(L,1); /* pop global table */ +} +#endif + +static void push_collector(lua_State* L, const char* type, lua_CFunction col) { + + /* push collector function, but only if it's not NULL, or if there's no + collector already */ + if (!col) return; + luaL_getmetatable(L,type); + lua_pushstring(L,".collector"); + /* + if (!col) { + lua_pushvalue(L, -1); + lua_rawget(L, -3); + if (!lua_isnil(L, -1)) { + lua_pop(L, 3); + return; + }; + lua_pop(L, 1); + }; + // */ + lua_pushcfunction(L,col); + + lua_rawset(L,-3); + lua_pop(L, 1); +}; + +/* Map C class + * It maps a C class, setting the appropriate inheritance and super classes. +*/ +TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col) +{ + char cname[128] = "const "; + char cbase[128] = "const "; + strncat(cname,name,120); + strncat(cbase,base,120); + + mapinheritance(L,name,base); + mapinheritance(L,cname,name); + + mapsuper(L,cname,cbase); + mapsuper(L,name,base); + + lua_pushstring(L,lname); + + push_collector(L, name, col); + /* + luaL_getmetatable(L,name); + lua_pushstring(L,".collector"); + lua_pushcfunction(L,col); + + lua_rawset(L,-3); + */ + + luaL_getmetatable(L,name); + lua_rawset(L,-3); /* assign class metatable to module */ + + /* now we also need to store the collector table for the const + instances of the class */ + push_collector(L, cname, col); + /* + luaL_getmetatable(L,cname); + lua_pushstring(L,".collector"); + lua_pushcfunction(L,col); + lua_rawset(L,-3); + lua_pop(L,1); + */ + + +} + +/* Add base + * It adds additional base classes to a class (for multiple inheritance) + * (not for now) +TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) { + + char cname[128] = "const "; + char cbase[128] = "const "; + strncat(cname,name,120); + strncat(cbase,base,120); + + mapsuper(L,cname,cbase); + mapsuper(L,name,base); +}; +*/ + +/* Map function + * It assigns a function into the current module (or class) +*/ +TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func) +{ + lua_pushstring(L,name); + lua_pushcfunction(L,func); + lua_rawset(L,-3); +} + +/* sets the __call event for the class (expects the class' main table on top) */ +/* never really worked :( +TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) { + + lua_getmetatable(L, -1); + //luaL_getmetatable(L, type); + lua_pushstring(L,"__call"); + lua_pushcfunction(L,func); + lua_rawset(L,-3); + lua_pop(L, 1); +}; +*/ + +/* Map constant number + * It assigns a constant number into the current module (or class) +*/ +TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value) +{ + lua_pushstring(L,name); + tolua_pushnumber(L,value); + lua_rawset(L,-3); +} + + +/* Map variable + * It assigns a variable into the current module (or class) +*/ +TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) +{ + /* get func */ + lua_pushstring(L,".get"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .get table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".get"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + lua_pushcfunction(L,get); + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .get table */ + + /* set func */ + if (set) + { + lua_pushstring(L,".set"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .set table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".set"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + lua_pushcfunction(L,set); + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .set table */ + } +} + +/* Access const array + * It reports an error when trying to write into a const array +*/ +static int const_array (lua_State* L) +{ + luaL_error(L,"value of const array cannot be changed"); + return 0; +} + +/* Map an array + * It assigns an array into the current module (or class) +*/ +TOLUA_API void tolua_array (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) +{ + lua_pushstring(L,".get"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .get table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".get"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + + lua_newtable(L); /* create array metatable */ + lua_pushvalue(L,-1); + lua_setmetatable(L,-2); /* set the own table as metatable (for modules) */ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,get); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,set?set:const_array); + lua_rawset(L,-3); + + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .get table */ +} + + +TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) { + + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0); + #else + lua_dobuffer(L, B, size, name); + #endif +}; + diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua_push.c b/third-party/lua-5.1.5/toluapp-simple/tolua_push.c new file mode 100644 index 000000000..639414755 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua_push.c @@ -0,0 +1,171 @@ +/* tolua: functions to push C values. +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "lauxlib.h" + +#include + +TOLUA_API void tolua_pushvalue (lua_State* L, int lo) +{ + lua_pushvalue(L,lo); +} + +TOLUA_API void tolua_pushboolean (lua_State* L, int value) +{ + lua_pushboolean(L,value); +} + +TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value) +{ + lua_pushnumber(L,value); +} + +TOLUA_API void tolua_pushstring (lua_State* L, const char* value) +{ + if (value == NULL) + lua_pushnil(L); + else + lua_pushstring(L,value); +} + +TOLUA_API void tolua_pushuserdata (lua_State* L, void* value) +{ + if (value == NULL) + lua_pushnil(L); + else + lua_pushlightuserdata(L,value); +} + +TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type) +{ + if (value == NULL) + lua_pushnil(L); + else + { + luaL_getmetatable(L, type); + lua_pushstring(L,"tolua_ubox"); + lua_rawget(L,-2); /* stack: mt ubox */ + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L, LUA_REGISTRYINDEX); + }; + lua_pushlightuserdata(L,value); + lua_rawget(L,-2); /* stack: mt ubox ubox[u] */ + if (lua_isnil(L,-1)) + { + lua_pop(L,1); /* stack: mt ubox */ + lua_pushlightuserdata(L,value); + *(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox u newud */ + lua_pushvalue(L,-1); /* stack: mt ubox u newud newud */ + lua_insert(L,-4); /* stack: mt newud ubox u newud */ + lua_rawset(L,-3); /* stack: mt newud ubox */ + lua_pop(L,1); /* stack: mt newud */ + /*luaL_getmetatable(L,type);*/ + lua_pushvalue(L, -2); /* stack: mt newud mt */ + lua_setmetatable(L,-2); /* stack: mt newud */ + + #ifdef LUA_VERSION_NUM + lua_pushvalue(L, TOLUA_NOPEER); + lua_setfenv(L, -2); + #endif + } + else + { + /* check the need of updating the metatable to a more specialized class */ + lua_insert(L,-2); /* stack: mt ubox[u] ubox */ + lua_pop(L,1); /* stack: mt ubox[u] */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */ + lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */ + if (lua_istable(L,-1)) + { + lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */ + if (lua_toboolean(L,-1) == 1) /* if true */ + { + lua_pop(L,3); /* mt ubox[u]*/ + lua_remove(L, -2); + return; + } + } + /* type represents a more specilized type */ + /*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */ + lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */ + lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */ + lua_pop(L,3); /* stack: mt ubox[u] */ + } + lua_remove(L, -2); /* stack: ubox[u]*/ + } +} + +TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type) +{ + tolua_pushusertype(L,value,type); + tolua_register_gc(L,lua_gettop(L)); +} + +TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v) +{ + lua_pushnumber(L,index); + lua_pushvalue(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v) +{ + lua_pushnumber(L,index); + lua_pushboolean(L,v); + lua_settable(L,lo); +} + + +TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v) +{ + lua_pushnumber(L,index); + tolua_pushnumber(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v) +{ + lua_pushnumber(L,index); + tolua_pushstring(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v) +{ + lua_pushnumber(L,index); + tolua_pushuserdata(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type) +{ + lua_pushnumber(L,index); + tolua_pushusertype(L,v,type); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type) +{ + lua_pushnumber(L,index); + tolua_pushusertype(L,v,type); + tolua_register_gc(L,lua_gettop(L)); + lua_settable(L,lo); +} + diff --git a/third-party/lua-5.1.5/toluapp-simple/tolua_to.c b/third-party/lua-5.1.5/toluapp-simple/tolua_to.c new file mode 100644 index 000000000..542ca67d1 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/tolua_to.c @@ -0,0 +1,133 @@ +/* tolua: funcitons to convert to C types +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" + +#include +#include + +TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def) +{ + return lua_gettop(L)= 501 + TOLUA_API int luaopen_tolua (lua_State* tolua_S) { + return tolua_tolua_open(tolua_S); +}; +#endif + diff --git a/third-party/lua-5.1.5/toluapp-simple/toluabind.h b/third-party/lua-5.1.5/toluapp-simple/toluabind.h new file mode 100644 index 000000000..7f1f018c9 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/toluabind.h @@ -0,0 +1,8 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.92 on Sun Feb 15 22:29:48 2009. +*/ + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + diff --git a/third-party/lua-5.1.5/toluapp-simple/toluabind_default.h b/third-party/lua-5.1.5/toluapp-simple/toluabind_default.h new file mode 100644 index 000000000..c31a14875 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp-simple/toluabind_default.h @@ -0,0 +1,8 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.8pre2 on Tue Dec 13 01:43:55 2005. +*/ + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + diff --git a/third-party/lua-5.1.5/toluapp/.travis.yml b/third-party/lua-5.1.5/toluapp/.travis.yml new file mode 100644 index 000000000..57493ebbc --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/.travis.yml @@ -0,0 +1,51 @@ +# +# LuaDist Travis-CI Hook +# + +# We assume C build environments +language: C + +# Try using multiple Lua Implementations +env: + - TOOL="gcc" # Use native compiler (GCC usually) + - TOOL="clang" # Use clang + - TOOL="i686-w64-mingw32" # 32bit MinGW + - TOOL="x86_64-w64-mingw32" # 64bit MinGW + - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux + +# Crosscompile builds may fail +matrix: + allow_failures: + - env: TOOL="i686-w64-mingw32" + - env: TOOL="x86_64-w64-mingw32" + - env: TOOL="arm-linux-gnueabihf" + +# Install dependencies +install: + - git clone git://github.com/LuaDist/Tools.git ~/_tools + - ~/_tools/travis/travis install + +# Bootstap +before_script: + - ~/_tools/travis/travis bootstrap + +# Build the module +script: + - ~/_tools/travis/travis build + +# Execute additional tests or commands +after_script: + - ~/_tools/travis/travis test + +# Only watch the master branch +branches: + only: + - master + +# Notify the LuaDist Dev group if needed +notifications: + recipients: + - luadist-dev@googlegroups.com + email: + on_success: change + on_failure: always diff --git a/third-party/lua-5.1.5/toluapp/CMakeLists.txt b/third-party/lua-5.1.5/toluapp/CMakeLists.txt new file mode 100644 index 000000000..e102edcb5 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright (C) 2007-2012 LuaDist. +# Created by Peter Kapec +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Please note that the package source code is licensed under its own license. +include ( cmake/dist.cmake ) + +if(BUILD_VENDORED_LUA) +set(${LUA_LIBRARIES} "${PROJECT_BINARY_DIR}/liblua51.a" ) +set(${LUA_INCLUDE_DIR} "${PROJECT_BINARY_DIR}") +else() +find_package ( Lua REQUIRED ) +endif() + +include_directories ( include src/lib ${LUA_INCLUDE_DIR} ) + +# Build lib +file ( GLOB SRC_LIBTOLUAPP src/lib/*.c ) +if ( MSVC ) + set ( DEF_FILE libtoluapp.def ) +endif ( ) + +add_library ( toluapp_lib ${SRC_LIBTOLUAPP} ${DEF_FILE} ) +target_link_libraries ( toluapp_lib ${LUA_LIBRARIES} ) +set_target_properties ( toluapp_lib PROPERTIES OUTPUT_NAME toluapp CLEAN_DIRECT_OUTPUT + 1 ) + +# Build app +include_directories ( src/bin ) +set ( SRC_TOLUA src/bin/tolua.c src/bin/toluabind.c ) +add_executable ( toluapp ${SRC_TOLUA} ) +target_link_libraries ( toluapp toluapp_lib ${LUA_LIBRARIES} ) + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set_target_properties(toluapp PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} + ) diff --git a/third-party/lua-5.1.5/toluapp/INSTALL b/third-party/lua-5.1.5/toluapp/INSTALL new file mode 100644 index 000000000..5ee408f9e --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/INSTALL @@ -0,0 +1,42 @@ +This version of tolua++ uses SCons to compile (http://www.scons.org). SCons uses +pythin. If you don't want to install python, check "Installation without scons" +below. + +* Installation + + 1. Edit the "config" file for your platform to suit your environment, + if at all necessary (for cygwin, mingw, BSD and mac OSX use + 'config_posix') + 2. Then, type "scons". + + You can use 'scons -h' to see a list of available command line options. + +* What you get + + If "scons" succeeds, you get: + * an executable to generate binding code in ./bin; + * the C library to be linked in your application in ./lib; + * the include file needed to compile your application in ./include. + These are the only directories you need for development, besides Lua. + + You can use 'scons install' to install the files, see the 'prefix' option. + +* Installation without scons + + The instructions for building tolua++ without scons depend on the particular + compiler you are using. + The simplest way is to create a folder with all .c and .h files except + 'toluabind_default.c', and then create a project for the executable and the + library, as follows: + + tolua.exe: all *.c *.h in src/bin (except toluabind_default.c) + tolua.lib: all *.c *.h in src/lib. + +* Installation with Microsoft Visual Studio + + The directory 'win32' contains project files for Microsoft Visual Studio 7 + (contributed by Makoto Hamanaka). The project has 4 different build options: + withLua50_Release, withLua51_Release, withLua50_Debug and withLua51_Debug. + They all expect the lua library names used by the LuaBinaries packages + (http://luabinaries.luaforge.net/). The resulting files are built on /lib and + /bin (for the library and tolua++.exe). diff --git a/third-party/lua-5.1.5/toluapp/README b/third-party/lua-5.1.5/toluapp/README new file mode 100644 index 000000000..cee381fb3 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/README @@ -0,0 +1,30 @@ +This is tolua++-1.0 + +* What is tolua++? + tolua++ is an extension of toLua, a tool to integrate C/C++ code with + Lua. tolua++ includes new features oriented to c++, such as class + templates. + + tolua is a tool that greatly simplifies the integration of C/C++ code + with Lua. Based on a "cleaned" header file, tolua automatically generates + the binding code to access C/C++ features from Lua. Using Lua-5.0 API and + metamethod facilities, the current version automatically maps C/C++ + constants, external variables, functions, namespace, classes, and methods + to Lua. It also provides facilities to create Lua modules. + +* Availability + + tolua++ is freely available for both academic and commercial purposes. + See COPYRIGHT for details. + + tolua++ can be downloaded from the sites below: + http://www.codenix.com/~tolua/ + +* Installation + See INSTALL. + +* Contacting the author + tolua has been designed and implemented by Waldemar Celes. + tolua++ is maintained by Ariel Manzur. + Send your comments, bug reports and anything else to + tolua@codenix.com diff --git a/third-party/lua-5.1.5/toluapp/README-5.1 b/third-party/lua-5.1.5/toluapp/README-5.1 new file mode 100755 index 000000000..f06f785e3 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/README-5.1 @@ -0,0 +1,50 @@ +Compiling for lua 5.1 +--------------------- + +Starting from version 1.0.8pre1, tolua++ can be compiled with both lua 5.0 and +5.1. Both versions will output the same code, and the C API (tolua++.h) is the +same. + +The build system is not yet ready to detect/decide when to compile for 5.1, +the easiest way right now is to add a file called 'custom.py' on the root of +the package, with the following: + +## BEGIN custom.py + +CCFLAGS = ['-I/usr/local/include/lua5.1', '-O2', '-ansi'] +LIBPATH = ['/usr/local/lib'] +LIBS = ['lua5.1', 'dl', 'm'] +tolua_bin = 'tolua++5.1' +tolua_lib = 'tolua++5.1' +TOLUAPP = 'tolua++5.1' + +## END custom.py + +This will build the binary as 'tolua++5.1' and the library as 'libtolua++5.1.a' +(taken from tolua_bin and tolua_lib), and take the lua headers and libraries +from /usr/local/include/lua5.1 and /usr/local/lib. It will also link with +'-llua5.1'. Modify the parameters acording to your system. + +Compatibility +------------- + +There are a couple of things to keep in mind when running code inside tolua +using the -L option: + +* `...' and arg: you can still use 'arg' on 5.1, this is done automatically by +adding the 'arg' declaration to functions on files loaded with dofile. + +For example, the line: + +function foo( ... ) + +becomes + +function foo( ... ) local arg = {n=select('#', ...), ...}; + +This lets you use the same code on both versions without having to make any +modifications. + +* keep in mind that there are slight differences on the way string.gsub works, +and the original version of the function is always kept, so it will behave +diffently depending on which version of lua you're using. diff --git a/third-party/lua-5.1.5/toluapp/cmake/FindLua.cmake b/third-party/lua-5.1.5/toluapp/cmake/FindLua.cmake new file mode 100644 index 000000000..7fb7ca3f4 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/cmake/FindLua.cmake @@ -0,0 +1,118 @@ +# Locate Lua library +# This module defines +# LUA_EXECUTABLE, if found +# LUA_FOUND, if false, do not try to link to Lua +# LUA_LIBRARIES +# LUA_INCLUDE_DIR, where to find lua.h +# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) +# +# Note that the expected include convention is +# #include "lua.h" +# and not +# #include +# This is because, the lua location is not standardized and may exist +# in locations other than lua/ + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# Modified to support Lua 5.2 by LuaDist 2012 +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +# +# The required version of Lua can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Lua 5.1) +# Otherwise the module will search for any available Lua implementation + +# Always search for non-versioned lua first (recommended) +SET(_POSSIBLE_LUA_INCLUDE include include/lua) +SET(_POSSIBLE_LUA_EXECUTABLE lua) +SET(_POSSIBLE_LUA_LIBRARY lua) + +# Determine possible naming suffixes (there is no standard for this) +IF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR) + SET(_POSSIBLE_SUFFIXES "${Lua_FIND_VERSION_MAJOR}${Lua_FIND_VERSION_MINOR}" "${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}" "-${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}") +ELSE(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR) + SET(_POSSIBLE_SUFFIXES "52" "5.2" "-5.2" "51" "5.1" "-5.1") +ENDIF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR) + +# Set up possible search names and locations +FOREACH(_SUFFIX ${_POSSIBLE_SUFFIXES}) + LIST(APPEND _POSSIBLE_LUA_INCLUDE "include/lua${_SUFFIX}") + LIST(APPEND _POSSIBLE_LUA_EXECUTABLE "lua${_SUFFIX}") + LIST(APPEND _POSSIBLE_LUA_LIBRARY "lua${_SUFFIX}") +ENDFOREACH(_SUFFIX) + +# Find the lua executable +FIND_PROGRAM(LUA_EXECUTABLE + NAMES ${_POSSIBLE_LUA_EXECUTABLE} +) + +# Find the lua header +FIND_PATH(LUA_INCLUDE_DIR lua.h + HINTS + $ENV{LUA_DIR} + PATH_SUFFIXES ${_POSSIBLE_LUA_INCLUDE} + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +# Find the lua library +FIND_LIBRARY(LUA_LIBRARY + NAMES ${_POSSIBLE_LUA_LIBRARY} + HINTS + $ENV{LUA_DIR} + PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +IF(LUA_LIBRARY) + # include the math library for Unix + IF(UNIX AND NOT APPLE) + FIND_LIBRARY(LUA_MATH_LIBRARY m) + SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries") + # For Windows and Mac, don't need to explicitly include the math library + ELSE(UNIX AND NOT APPLE) + SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries") + ENDIF(UNIX AND NOT APPLE) +ENDIF(LUA_LIBRARY) + +# Determine Lua version +IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") + FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"") + + STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}") + UNSET(lua_version_str) +ENDIF() + +INCLUDE(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if +# all listed variables are TRUE +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua + REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR + VERSION_VAR LUA_VERSION_STRING) + +MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE) + diff --git a/third-party/lua-5.1.5/toluapp/cmake/dist.cmake b/third-party/lua-5.1.5/toluapp/cmake/dist.cmake new file mode 100644 index 000000000..310ef94cc --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/cmake/dist.cmake @@ -0,0 +1,321 @@ +# LuaDist CMake utility library. +# Provides sane project defaults and macros common to LuaDist CMake builds. +# +# Copyright (C) 2007-2012 LuaDist. +# by David Manura, Peter Drahoナ。 +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Please note that the package source code is licensed under its own license. + +## Extract information from dist.info +if ( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dist.info ) + message ( FATAL_ERROR + "Missing dist.info file (${CMAKE_CURRENT_SOURCE_DIR}/dist.info)." ) +endif () +file ( READ ${CMAKE_CURRENT_SOURCE_DIR}/dist.info DIST_INFO ) +if ( "${DIST_INFO}" STREQUAL "" ) + message ( FATAL_ERROR "Failed to load dist.info." ) +endif () +# Reads field `name` from dist.info string `DIST_INFO` into variable `var`. +macro ( _parse_dist_field name var ) + string ( REGEX REPLACE ".*${name}[ \t]?=[ \t]?[\"']([^\"']+)[\"'].*" "\\1" + ${var} "${DIST_INFO}" ) + if ( ${var} STREQUAL DIST_INFO ) + message ( FATAL_ERROR "Failed to extract \"${var}\" from dist.info" ) + endif () +endmacro () +# +_parse_dist_field ( name DIST_NAME ) +_parse_dist_field ( version DIST_VERSION ) +_parse_dist_field ( license DIST_LICENSE ) +_parse_dist_field ( author DIST_AUTHOR ) +_parse_dist_field ( maintainer DIST_MAINTAINER ) +_parse_dist_field ( url DIST_URL ) +_parse_dist_field ( desc DIST_DESC ) +message ( "DIST_NAME: ${DIST_NAME}") +message ( "DIST_VERSION: ${DIST_VERSION}") +message ( "DIST_LICENSE: ${DIST_LICENSE}") +message ( "DIST_AUTHOR: ${DIST_AUTHOR}") +message ( "DIST_MAINTAINER: ${DIST_MAINTAINER}") +message ( "DIST_URL: ${DIST_URL}") +message ( "DIST_DESC: ${DIST_DESC}") +string ( REGEX REPLACE ".*depends[ \t]?=[ \t]?[\"']([^\"']+)[\"'].*" "\\1" + DIST_DEPENDS ${DIST_INFO} ) +if ( DIST_DEPENDS STREQUAL DIST_INFO ) + set ( DIST_DEPENDS "" ) +endif () +message ( "DIST_DEPENDS: ${DIST_DEPENDS}") +## 2DO: Parse DIST_DEPENDS and try to install Dependencies with automatically using externalproject_add + + +## INSTALL DEFAULTS (Relative to CMAKE_INSTALL_PREFIX) +# Primary paths +set ( INSTALL_BIN bin CACHE PATH "Where to install binaries to." ) +set ( INSTALL_LIB lib CACHE PATH "Where to install libraries to." ) +set ( INSTALL_INC include CACHE PATH "Where to install headers to." ) +set ( INSTALL_ETC etc CACHE PATH "Where to store configuration files" ) +set ( INSTALL_SHARE share CACHE PATH "Directory for shared data." ) + +# Secondary paths +option ( INSTALL_VERSION + "Install runtime libraries and executables with version information." OFF) +set ( INSTALL_DATA ${INSTALL_SHARE}/${DIST_NAME} CACHE PATH + "Directory the package can store documentation, tests or other data in.") +set ( INSTALL_DOC ${INSTALL_DATA}/doc CACHE PATH + "Recommended directory to install documentation into.") +set ( INSTALL_EXAMPLE ${INSTALL_DATA}/example CACHE PATH + "Recommended directory to install examples into.") +set ( INSTALL_TEST ${INSTALL_DATA}/test CACHE PATH + "Recommended directory to install tests into.") +set ( INSTALL_FOO ${INSTALL_DATA}/etc CACHE PATH + "Where to install additional files") + +# Tweaks and other defaults +# Setting CMAKE to use loose block and search for find modules in source directory +set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) +set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} ) +option ( BUILD_SHARED_LIBS "Build shared libraries" ON ) + +# In MSVC, prevent warnings that can occur when using standard libraries. +if ( MSVC ) + add_definitions ( -D_CRT_SECURE_NO_WARNINGS ) +endif () + +# RPath and relative linking +option ( USE_RPATH "Use relative linking." ON) +if ( USE_RPATH ) + string ( REGEX REPLACE "[^!/]+" ".." UP_DIR ${INSTALL_BIN} ) + set ( CMAKE_SKIP_BUILD_RPATH FALSE CACHE STRING "" FORCE ) + set ( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE CACHE STRING "" FORCE ) + set ( CMAKE_INSTALL_RPATH $ORIGIN/${UP_DIR}/${INSTALL_LIB} + CACHE STRING "" FORCE ) + set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE STRING "" FORCE ) + set ( CMAKE_INSTALL_NAME_DIR @executable_path/${UP_DIR}/${INSTALL_LIB} + CACHE STRING "" FORCE ) +endif () + +## MACROS +# Parser macro +macro ( parse_arguments prefix arg_names option_names) + set ( DEFAULT_ARGS ) + foreach ( arg_name ${arg_names} ) + set ( ${prefix}_${arg_name} ) + endforeach () + foreach ( option ${option_names} ) + set ( ${prefix}_${option} FALSE ) + endforeach () + + set ( current_arg_name DEFAULT_ARGS ) + set ( current_arg_list ) + foreach ( arg ${ARGN} ) + set ( larg_names ${arg_names} ) + list ( FIND larg_names "${arg}" is_arg_name ) + if ( is_arg_name GREATER -1 ) + set ( ${prefix}_${current_arg_name} ${current_arg_list} ) + set ( current_arg_name ${arg} ) + set ( current_arg_list ) + else () + set ( loption_names ${option_names} ) + list ( FIND loption_names "${arg}" is_option ) + if ( is_option GREATER -1 ) + set ( ${prefix}_${arg} TRUE ) + else () + set ( current_arg_list ${current_arg_list} ${arg} ) + endif () + endif () + endforeach () + set ( ${prefix}_${current_arg_name} ${current_arg_list} ) +endmacro () + + +# install_executable ( executable_targets ) +# Installs any executables generated using "add_executable". +# USE: install_executable ( lua ) +# NOTE: subdirectories are NOT supported +set ( CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "${DIST_NAME} Runtime" ) +set ( CPACK_COMPONENT_RUNTIME_DESCRIPTION + "Executables and runtime libraries. Installed into ${INSTALL_BIN}." ) +macro ( install_executable ) + foreach ( _file ${ARGN} ) + if ( INSTALL_VERSION ) + set_target_properties ( ${_file} PROPERTIES VERSION ${DIST_VERSION} + SOVERSION ${DIST_VERSION} ) + endif () + install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} + COMPONENT Runtime ) + endforeach() +endmacro () + +# install_library ( library_targets ) +# Installs any libraries generated using "add_library" into apropriate places. +# USE: install_library ( libexpat ) +# NOTE: subdirectories are NOT supported +set ( CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "${DIST_NAME} Development Libraries" ) +set ( CPACK_COMPONENT_LIBRARY_DESCRIPTION + "Static and import libraries needed for development. Installed into ${INSTALL_LIB} or ${INSTALL_BIN}." ) +macro ( install_library ) + foreach ( _file ${ARGN} ) + if ( INSTALL_VERSION ) + set_target_properties ( ${_file} PROPERTIES VERSION ${DIST_VERSION} + SOVERSION ${DIST_VERSION} ) + endif () + install ( TARGETS ${_file} + RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT Runtime + LIBRARY DESTINATION ${INSTALL_LIB} COMPONENT Runtime + ARCHIVE DESTINATION ${INSTALL_LIB} COMPONENT Library ) + endforeach() +endmacro () + +# helper function for various install_* functions, for PATTERN/REGEX args. +macro ( _complete_install_args ) + if ( NOT("${_ARG_PATTERN}" STREQUAL "") ) + set ( _ARG_PATTERN PATTERN ${_ARG_PATTERN} ) + endif () + if ( NOT("${_ARG_REGEX}" STREQUAL "") ) + set ( _ARG_REGEX REGEX ${_ARG_REGEX} ) + endif () +endmacro () + +# install_header ( files/directories [INTO destination] ) +# Install a directories or files into header destination. +# USE: install_header ( lua.h luaconf.h ) or install_header ( GL ) +# USE: install_header ( mylib.h INTO mylib ) +# For directories, supports optional PATTERN/REGEX arguments like install(). +set ( CPACK_COMPONENT_HEADER_DISPLAY_NAME "${DIST_NAME} Development Headers" ) +set ( CPACK_COMPONENT_HEADER_DESCRIPTION + "Headers needed for development. Installed into ${INSTALL_INC}." ) +macro ( install_header ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} + COMPONENT Header ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} + COMPONENT Header ) + endif () + endforeach() +endmacro () + +# install_data ( files/directories [INTO destination] ) +# This installs additional data files or directories. +# USE: install_data ( extra data.dat ) +# USE: install_data ( image1.png image2.png INTO images ) +# For directories, supports optional PATTERN/REGEX arguments like install(). +set ( CPACK_COMPONENT_DATA_DISPLAY_NAME "${DIST_NAME} Data" ) +set ( CPACK_COMPONENT_DATA_DESCRIPTION + "Application data. Installed into ${INSTALL_DATA}." ) +macro ( install_data ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} + DESTINATION ${INSTALL_DATA}/${_ARG_INTO} + COMPONENT Data ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} + COMPONENT Data ) + endif () + endforeach() +endmacro () + +# INSTALL_DOC ( files/directories [INTO destination] ) +# This installs documentation content +# USE: install_doc ( doc/ doc.pdf ) +# USE: install_doc ( index.html INTO html ) +# For directories, supports optional PATTERN/REGEX arguments like install(). +set ( CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "${DIST_NAME} Documentation" ) +set ( CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION + "Application documentation. Installed into ${INSTALL_DOC}." ) +macro ( install_doc ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} + COMPONENT Documentation ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} + COMPONENT Documentation ) + endif () + endforeach() +endmacro () + +# install_example ( files/directories [INTO destination] ) +# This installs additional examples +# USE: install_example ( examples/ exampleA ) +# USE: install_example ( super_example super_data INTO super) +# For directories, supports optional PATTERN/REGEX argument like install(). +set ( CPACK_COMPONENT_EXAMPLE_DISPLAY_NAME "${DIST_NAME} Examples" ) +set ( CPACK_COMPONENT_EXAMPLE_DESCRIPTION + "Examples and their associated data. Installed into ${INSTALL_EXAMPLE}." ) +macro ( install_example ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} + COMPONENT Example ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} + COMPONENT Example ) + endif () + endforeach() +endmacro () + +# install_test ( files/directories [INTO destination] ) +# This installs tests and test files, DOES NOT EXECUTE TESTS +# USE: install_test ( my_test data.sql ) +# USE: install_test ( feature_x_test INTO x ) +# For directories, supports optional PATTERN/REGEX argument like install(). +set ( CPACK_COMPONENT_TEST_DISPLAY_NAME "${DIST_NAME} Tests" ) +set ( CPACK_COMPONENT_TEST_DESCRIPTION + "Tests and associated data. Installed into ${INSTALL_TEST}." ) +macro ( install_test ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} + COMPONENT Test ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} + COMPONENT Test ) + endif () + endforeach() +endmacro () + +# install_foo ( files/directories [INTO destination] ) +# This installs optional or otherwise unneeded content +# USE: install_foo ( etc/ example.doc ) +# USE: install_foo ( icon.png logo.png INTO icons) +# For directories, supports optional PATTERN/REGEX argument like install(). +set ( CPACK_COMPONENT_OTHER_DISPLAY_NAME "${DIST_NAME} Unspecified Content" ) +set ( CPACK_COMPONENT_OTHER_DESCRIPTION + "Other unspecified content. Installed into ${INSTALL_FOO}." ) +macro ( install_foo ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} + COMPONENT Other ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} + COMPONENT Other ) + endif () + endforeach() +endmacro () + +## CTest defaults + +## CPack defaults +set ( CPACK_GENERATOR "ZIP" ) +set ( CPACK_STRIP_FILES TRUE ) +set ( CPACK_PACKAGE_NAME "${DIST_NAME}" ) +set ( CPACK_PACKAGE_VERSION "${DIST_VERSION}") +set ( CPACK_PACKAGE_VENDOR "LuaDist" ) +set ( CPACK_COMPONENTS_ALL Runtime Library Header Data Documentation Example Other ) +include ( CPack ) diff --git a/third-party/lua-5.1.5/toluapp/cmake/lua.cmake b/third-party/lua-5.1.5/toluapp/cmake/lua.cmake new file mode 100644 index 000000000..80bbc5f35 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/cmake/lua.cmake @@ -0,0 +1,293 @@ +# LuaDist CMake utility library for Lua. +# +# Copyright (C) 2007-2012 LuaDist. +# by David Manura, Peter Drahos +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Please note that the package source code is licensed under its own license. + +set ( INSTALL_LMOD ${INSTALL_LIB}/lua + CACHE PATH "Directory to install Lua modules." ) +set ( INSTALL_CMOD ${INSTALL_LIB}/lua + CACHE PATH "Directory to install Lua binary modules." ) + +option ( SKIP_LUA_WRAPPER + "Do not build and install Lua executable wrappers." OFF) + +# List of (Lua module name, file path) pairs. +# Used internally by add_lua_test. Built by add_lua_module. +set ( _lua_modules ) + +# utility function: appends path `path` to path `basepath`, properly +# handling cases when `path` may be relative or absolute. +macro ( _append_path basepath path result ) + if ( IS_ABSOLUTE "${path}" ) + set ( ${result} "${path}" ) + else () + set ( ${result} "${basepath}/${path}" ) + endif () +endmacro () + +# install_lua_executable ( target source ) +# Automatically generate a binary if srlua package is available +# The application or its source will be placed into /bin +# If the application source did not have .lua suffix then it will be added +# USE: lua_executable ( sputnik src/sputnik.lua ) +macro ( install_lua_executable _name _source ) + get_filename_component ( _source_name ${_source} NAME_WE ) + # Find srlua and glue + find_program( SRLUA_EXECUTABLE NAMES srlua ) + find_program( GLUE_EXECUTABLE NAMES glue ) + # Executable output + set ( _exe ${CMAKE_CURRENT_BINARY_DIR}/${_name}${CMAKE_EXECUTABLE_SUFFIX} ) + if ( NOT SKIP_LUA_WRAPPER AND SRLUA_EXECUTABLE AND GLUE_EXECUTABLE ) + # Generate binary gluing the lua code to srlua, this is a robuust approach for most systems + add_custom_command( + OUTPUT ${_exe} + COMMAND ${GLUE_EXECUTABLE} + ARGS ${SRLUA_EXECUTABLE} ${_source} ${_exe} + DEPENDS ${_source} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + ) + # Make sure we have a target associated with the binary + add_custom_target(${_name} ALL + DEPENDS ${_exe} + ) + # Install with run permissions + install ( PROGRAMS ${_exe} DESTINATION ${INSTALL_BIN} COMPONENT Runtime) + # Also install source as optional resurce + install ( FILES ${_source} DESTINATION ${INSTALL_FOO} COMPONENT Other ) + else() + # Install into bin as is but without the lua suffix, we assume the executable uses UNIX shebang/hash-bang magic + install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN} + RENAME ${_source_name} + COMPONENT Runtime + ) + endif() +endmacro () + +macro ( _lua_module_helper is_install _name ) + parse_arguments ( _MODULE "LINK;ALL_IN_ONE" "" ${ARGN} ) + # _target is CMake-compatible target name for module (e.g. socket_core). + # _module is relative path of target (e.g. socket/core), + # without extension (e.g. .lua/.so/.dll). + # _MODULE_SRC is list of module source files (e.g. .lua and .c files). + # _MODULE_NAMES is list of module names (e.g. socket.core). + if ( _MODULE_ALL_IN_ONE ) + string ( REGEX REPLACE "\\..*" "" _target "${_name}" ) + string ( REGEX REPLACE "\\..*" "" _module "${_name}" ) + set ( _target "${_target}_all_in_one") + set ( _MODULE_SRC ${_MODULE_ALL_IN_ONE} ) + set ( _MODULE_NAMES ${_name} ${_MODULE_DEFAULT_ARGS} ) + else () + string ( REPLACE "." "_" _target "${_name}" ) + string ( REPLACE "." "/" _module "${_name}" ) + set ( _MODULE_SRC ${_MODULE_DEFAULT_ARGS} ) + set ( _MODULE_NAMES ${_name} ) + endif () + if ( NOT _MODULE_SRC ) + message ( FATAL_ERROR "no module sources specified" ) + endif () + list ( GET _MODULE_SRC 0 _first_source ) + + get_filename_component ( _ext ${_first_source} EXT ) + if ( _ext STREQUAL ".lua" ) # Lua source module + list ( LENGTH _MODULE_SRC _len ) + if ( _len GREATER 1 ) + message ( FATAL_ERROR "more than one source file specified" ) + endif () + + set ( _module "${_module}.lua" ) + + get_filename_component ( _module_dir ${_module} PATH ) + get_filename_component ( _module_filename ${_module} NAME ) + _append_path ( "${CMAKE_CURRENT_SOURCE_DIR}" "${_first_source}" _module_path ) + list ( APPEND _lua_modules "${_name}" "${_module_path}" ) + + if ( ${is_install} ) + install ( FILES ${_first_source} DESTINATION ${INSTALL_LMOD}/${_module_dir} + RENAME ${_module_filename} + COMPONENT Runtime + ) + endif () + else () # Lua C binary module + enable_language ( C ) + find_package ( Lua REQUIRED ) + include_directories ( ${LUA_INCLUDE_DIR} ) + + set ( _module "${_module}${CMAKE_SHARED_MODULE_SUFFIX}" ) + + get_filename_component ( _module_dir ${_module} PATH ) + get_filename_component ( _module_filenamebase ${_module} NAME_WE ) + foreach ( _thisname ${_MODULE_NAMES} ) + list ( APPEND _lua_modules "${_thisname}" + "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_CFG_INTDIR}/${_module}" ) + endforeach () + + add_library( ${_target} MODULE ${_MODULE_SRC}) + target_link_libraries ( ${_target} ${LUA_LIBRARY} ${_MODULE_LINK} ) + set_target_properties ( ${_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY + "${_module_dir}" PREFIX "" OUTPUT_NAME "${_module_filenamebase}" ) + if ( ${is_install} ) + install ( TARGETS ${_target} DESTINATION ${INSTALL_CMOD}/${_module_dir} COMPONENT Runtime) + endif () + endif () +endmacro () + +# add_lua_module +# Builds a Lua source module into a destination locatable by Lua +# require syntax. +# Binary modules are also supported where this function takes sources and +# libraries to compile separated by LINK keyword. +# USE: add_lua_module ( socket.http src/http.lua ) +# USE2: add_lua_module ( mime.core src/mime.c ) +# USE3: add_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} ) +# USE4: add_lua_module ( ssl.context ssl.core ALL_IN_ONE src/context.c src/ssl.c ) +# This form builds an "all-in-one" module (e.g. ssl.so or ssl.dll containing +# both modules ssl.context and ssl.core). The CMake target name will be +# ssl_all_in_one. +# Also sets variable _module_path (relative path where module typically +# would be installed). +macro ( add_lua_module ) + _lua_module_helper ( 0 ${ARGN} ) +endmacro () + + +# install_lua_module +# This is the same as `add_lua_module` but also installs the module. +# USE: install_lua_module ( socket.http src/http.lua ) +# USE2: install_lua_module ( mime.core src/mime.c ) +# USE3: install_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} ) +macro ( install_lua_module ) + _lua_module_helper ( 1 ${ARGN} ) +endmacro () + +# Builds string representing Lua table mapping Lua modules names to file +# paths. Used internally. +macro ( _make_module_table _outvar ) + set ( ${_outvar} ) + list ( LENGTH _lua_modules _n ) + if ( ${_n} GREATER 0 ) # avoids cmake complaint + foreach ( _i RANGE 1 ${_n} 2 ) + list ( GET _lua_modules ${_i} _path ) + math ( EXPR _ii ${_i}-1 ) + list ( GET _lua_modules ${_ii} _name ) + set ( ${_outvar} "${_table} ['${_name}'] = '${_path}'\;\n") + endforeach () + endif () + set ( ${_outvar} +"local modules = { +${_table}}" ) +endmacro () + +# add_lua_test ( _testfile [ WORKING_DIRECTORY _working_dir ] ) +# Runs Lua script `_testfile` under CTest tester. +# Optional named argument `WORKING_DIRECTORY` is current working directory to +# run test under (defaults to ${CMAKE_CURRENT_BINARY_DIR}). +# Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}. +# Any modules previously defined with install_lua_module are automatically +# preloaded (via package.preload) prior to running the test script. +# Under LuaDist, set test=true in config.lua to enable testing. +# USE: add_lua_test ( test/test1.lua [args...] [WORKING_DIRECTORY dir]) +macro ( add_lua_test _testfile ) + if ( NOT SKIP_TESTING ) + parse_arguments ( _ARG "WORKING_DIRECTORY" "" ${ARGN} ) + include ( CTest ) + find_program ( LUA NAMES lua lua.bat ) + get_filename_component ( TESTFILEABS ${_testfile} ABSOLUTE ) + get_filename_component ( TESTFILENAME ${_testfile} NAME ) + get_filename_component ( TESTFILEBASE ${_testfile} NAME_WE ) + + # Write wrapper script. + # Note: One simple way to allow the script to find modules is + # to just put them in package.preload. + set ( TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME} ) + _make_module_table ( _table ) + set ( TESTWRAPPERSOURCE +"local CMAKE_CFG_INTDIR = ... or '.' +${_table} +local function preload_modules(modules) + for name, path in pairs(modules) do + if path:match'%.lua' then + package.preload[name] = assert(loadfile(path)) + else + local name = name:gsub('.*%-', '') -- remove any hyphen prefix + local symbol = 'luaopen_' .. name:gsub('%.', '_') + --improve: generalize to support all-in-one loader? + local path = path:gsub('%$%{CMAKE_CFG_INTDIR%}', CMAKE_CFG_INTDIR) + package.preload[name] = assert(package.loadlib(path, symbol)) + end + end +end +preload_modules(modules) +arg[0] = '${TESTFILEABS}' +table.remove(arg, 1) +return assert(loadfile '${TESTFILEABS}')(unpack(arg)) +" ) + if ( _ARG_WORKING_DIRECTORY ) + get_filename_component ( + TESTCURRENTDIRABS ${_ARG_WORKING_DIRECTORY} ABSOLUTE ) + # note: CMake 2.6 (unlike 2.8) lacks WORKING_DIRECTORY parameter. + set ( _pre ${CMAKE_COMMAND} -E chdir "${TESTCURRENTDIRABS}" ) + endif () + file ( WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE}) + add_test ( NAME ${TESTFILEBASE} COMMAND ${_pre} ${LUA} + ${TESTWRAPPER} "${CMAKE_CFG_INTDIR}" + ${_ARG_DEFAULT_ARGS} ) + endif () + # see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake + # Note: ${CMAKE_CFG_INTDIR} is a command-line argument to allow proper + # expansion by the native build tool. +endmacro () + + +# Converts Lua source file `_source` to binary string embedded in C source +# file `_target`. Optionally compiles Lua source to byte code (not available +# under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua +# versions of bin2c [1] and luac [2] may be passed respectively as additional +# arguments. +# +# [1] http://lua-users.org/wiki/BinToCee +# [2] http://lua-users.org/wiki/LuaCompilerInLua +function ( add_lua_bin2c _target _source ) + find_program ( LUA NAMES lua lua.bat ) + execute_process ( COMMAND ${LUA} -e "string.dump(function()end)" + RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET ) + if ( NOT ${_LUA_DUMP_RESULT} ) + SET ( HAVE_LUA_DUMP true ) + endif () + message ( "-- string.dump=${HAVE_LUA_DUMP}" ) + + if ( ARGV2 ) + get_filename_component ( BIN2C ${ARGV2} ABSOLUTE ) + set ( BIN2C ${LUA} ${BIN2C} ) + else () + find_program ( BIN2C NAMES bin2c bin2c.bat ) + endif () + if ( HAVE_LUA_DUMP ) + if ( ARGV3 ) + get_filename_component ( LUAC ${ARGV3} ABSOLUTE ) + set ( LUAC ${LUA} ${LUAC} ) + else () + find_program ( LUAC NAMES luac luac.bat ) + endif () + endif ( HAVE_LUA_DUMP ) + message ( "-- bin2c=${BIN2C}" ) + message ( "-- luac=${LUAC}" ) + + get_filename_component ( SOURCEABS ${_source} ABSOLUTE ) + if ( HAVE_LUA_DUMP ) + get_filename_component ( SOURCEBASE ${_source} NAME_WE ) + add_custom_command ( + OUTPUT ${_target} DEPENDS ${_source} + COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo + ${SOURCEABS} + COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo + ">${_target}" ) + else () + add_custom_command ( + OUTPUT ${_target} DEPENDS ${SOURCEABS} + COMMAND ${BIN2C} ${_source} ">${_target}" ) + endif () +endfunction() diff --git a/third-party/lua-5.1.5/toluapp/dist.info b/third-party/lua-5.1.5/toluapp/dist.info new file mode 100644 index 000000000..d1f0a0539 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/dist.info @@ -0,0 +1,14 @@ +--- This file is part of LuaDist project + +name = "toluapp" +version = "1.0.93" + +desc = "tolua++ is an extension of toLua, a tool to integrate C/Cpp code with Lua." +author = "Waldemar Celes, Ariel Manzur" +license = "as-is" +url = "http://www.codenix.com/~tolua/" +maintainer = "Peter Kapec" + +depends = { + "lua ~> 5.1" +} diff --git a/third-party/lua-5.1.5/toluapp/doc/index.html b/third-party/lua-5.1.5/toluapp/doc/index.html new file mode 100644 index 000000000..c51633619 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/doc/index.html @@ -0,0 +1,226 @@ + +toLua++ - binding c/c++ code to lua + + + + +

+tolua++ - Home

+

+ +news - +download - documentation - installing - +contact - lua_qt - Codenix +
+ +


+ +tolua++ is an extended version of tolua, a tool to integrate +C/C++ code with Lua. tolua++ +includes new features oriented to c++ such as: +

+ +

    +
  • Support for std::string as a basic type (this can be turned off by a command line option).
  • +
  • Support for class templates
  • +
+

+ +As well as other features and bugfixes. + +


+ +

News:

+

+ +15/02/09: Version 1.0.93 released. Some bugfixes and new features: +

+

    +
  • Build process bootstraps. +
  • Added hooks to handle custom types. +
  • Added hooks to handle exceptions. +
  • Fixed issues with newer GCC compilers. +
  • Changed to MIT license. See COPYRIGHT file for details. +
+ +27/04/06: Version 1.0.92 released. Some bugfixes and new features: +

+

    +
  • Fixed garbage collector bug for C objects. +
  • Fixed problems with C compilers (including microsoft's) +
  • Added a .proj file to build with Visual Studio 7 (contributed by Makoto Hamanaka). +
  • New command line option: -E to define extra values +
  • New command line option: -t to associate C++ types with their lua names (see the manual for details) +
+ +25/02/06: Version 1.0.91 released. This version contains a small garbage collection bugfix for 1.0.90 (thanks to Rolf E. Thorup for the report), everyone should upgrade. +

+ +18/02/06: Version 1.0.90 released. Some bugfixes and new features: +

+

    +
  • lua 5.1 support (see README-5.1) +
  • Support for casting operators (for example operator const char();) +
  • New utility functions, tolua.setpeer and tolua.getpeer, for easier (and faster) inheritance from C/C++ objects (only for lua 5.1) +
  • Some small API changes (see the compatibility section of the manual) +
+

+ +18/10/05: Version 1.0.7 released. Some bugfixes and new features: +

+

    +
  • New command line option: -C, to disable the cleanup of included lua code (for easier debugging). +
  • Merged Mildred's patch: embedded lua chunks have better names, code on package initializer function is nested. +
  • New hook: parser_hook, allows modifications to the behavior of the main parser. +
  • Objects can be private (or protected). This doesn't affect the normal usage (everything is public by default), but it's useful to declare types that don't export any code, but serve +as 'support' for other declarations. +
  • Misc bugfixes. +
+

+ +01/9/05: Version 1.0.6 released. Several bugfixes and new features: +

+

    +
  • Classes can have properties, using the 'tolua_property' keyboard. Property types are customizable. +
  • Added a command line flag -D, to disable automatic generation of destructors for all classes with constructors (for compatibility with tolua5) +
  • Classes with protected or private destructors can be tagged individually using the "TOLUA_PROTECTED_DESTRUCTOR" macro. +
  • Added utility function "tolua.inherit", to allow a lua table to "inherit" from an instance of a C/C++ class +
  • Fixed class constructor bug (it is now possible to use 'ClassName()' to create a lua-owned instance of the class without problems) +
  • Misc bugfixes. +
+

+ +10/4/05: Version 1.0.5 released. This version contains some minor bugfixes and a new feature, +the tolua_outside keyword, used to specify regular functions as methods of classes or structs. This release is also paired with lua_qt +version 0.0.1a. +

+ +1/2/05: version 1.0.4 released. This version contains some bugfixes and new features: +

+

    +
  • Ability to customize tolua++'s behaviour to add functionality. +
  • Basic support for multiple inheritance. +
  • Several bugfixes on the parser. +
  • Debian package available for download. +
+

+ +Most of the changes on this version were added for lua_qt, a package +to bind the Qt toolkit to lua. +

+ +20/9/04: version 1.0.3 released. This version contains major bugfixes: +

+

    +
  • Fixed bugs in object tracking (the 'memory address' bug; there's still some work left, but people should be able to use unions with no problems)
  • +
  • Fixed parser bugs, functions with template parameters should work, also functions with default parameters that call constructos and with commas on them should work.
  • +
  • Added a __call method for class names, to replace new_local to create instances owned by lua. +
  • Fixed other minor bugs.
  • +
  • Removed the link to win32 binaries, since I aparently don't know what the hell I'm doing with a microsoft compiler ;-)
  • +
+

+ +Everyone should upgrade. +

+ +23/10/03: version 1.0.2 released. This version contains major bugfixes: +

+

    +
  • Fixed bugs in gargabe collection (thanks to Christian Vogler for doing all the work :-)
  • +
  • namespaces and nested types are now fully supported.
  • +
  • Fixed other minor bugs.
  • +
+

+ +Everyone should upgrade. + +


+ + +

Downloading

+ +The latest development version of the code is available through SVN from tolua++'s BerliOS project page. You can checkout using: + +svn checkout svn://svn.berlios.de/toluapp/trunk + +The tolua++ source is freely available by http. +The software provided under the terms of the MIT license. See the COPYRIGHT file distributed +with the source. +

+ +Current version is 1.0.93, older versions: +

+

  • tolua++-1.0.93.tar.bz2 +
  • tolua++-1.0.92.tar.bz2 +
  • tolua++-1.0.91.tar.bz2 +
  • tolua++_1.0.7-1.tar.gz [deb] +
  • tolua++_1.0.6-1.tar.gz [deb] +
  • tolua++_1.0.5-1.tar.gz [deb] +
  • tolua++-1.0.4.tar.bz2 [deb] +
  • tolua++-1.0.3.tar.bz2 +
  • tolua++-1.0.2.tar.bz2 +
  • tolua++-1.0.tar.bz2 + +
    + + +

    Documentation

    +

    +You can find the manual here or under the doc/ directory +on the distribution. +

    + +I'll also be adding interesting addons/examples to my page +on the lua-users wiki. + +


    + + +

    Instalation

    +

    + +tolua++ uses SCons to build. SCons is based on +python, you can get a stand-alone version on +their website. After you have SCons, follow this simple instructions: +

    + +

  • Type 'scons all' to compile.
  • +
  • Type 'scons install'. The default install prefix is /usr/local, so if you are +on a POSIX system, it should work. On other systems, you can change it with the +'prefix' option on command line. +

    + +scons prefix=/usr install +

    +or on windows +

    +scons "prefix=c:\Program Files\Visual C" install +

    + +Use scons -h to see a list of available command line options. + +

    +The files you need (in case you want to do a manual install) are: +

      +
    • bin/tolua++[.exe] - the main binary +
    • include/tolua++.h - the header file +
    • lib/libtolua++.a or lib/tolua++.lib - the library +
    + +
  • See INSTALL for instructions on how to install without SCons. There are also instructions on how +to build without scons at the lua-users wiki +(if you know the author of this, contact me)
  • + +
  • For lua 5.1, see README-5.1 + +
    + +tolua++ and this website are maintained by Ariel Manzur.
    +Contact us with any +bugs, fixes, suggestions, or questions about this package. + +
    + + + + diff --git a/third-party/lua-5.1.5/toluapp/doc/tolua++.html b/third-party/lua-5.1.5/toluapp/doc/tolua++.html new file mode 100644 index 000000000..4f2166e9c --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/doc/tolua++.html @@ -0,0 +1,1956 @@ + + + + + + + tolua++ reference manual + + + +

    +tolua++ - Reference Manual

    +by Waldemar Celes, Ariel Manzur. + +

    + +

    + +
    + +tolua++ is an extended version of tolua, a tool to integrate +C/C++ code with Lua. tolua++ +includes new features oriented to c++ such as: +

    + +

      +
    • Support for std::string as a basic type (this can be turned off by a command line option).
    • +
    • Support for class templates
    • +
    +

    + +As well as other features and bugfixes. +

    + + +tolua is a tool that greatly simplifies the integration of C/C++ +code with Lua. Based on +a cleaned header file (or extracts from real header files), +tolua automatically generates +the binding code to access C/C++ features from Lua. Using Lua API and tag +method facilities, tolua maps C/C++ constants, external variables, +functions, classes, and methods to Lua. +

    This manual is for tolua++ version 1.0 and is implemented upon Lua +5.0 and based on tolua 5.0. See Compatibility +for details on switching from older versions. +

    The sections below describe how to use tolua. Please contact us +with bug reports, suggestions, and comments. +

    + +
    +

    +How tolua works

    +To use tolua, we create a package file, a C/C++ cleaned header +file, listing the constants, variables, functions, classes, and +methods we want to export to the Lua environment. Then tolua parses +this file and creates a C/C++ file that automatically binds the C/C++ code +to Lua. If we link the created file with our application, the specified +C/C++ code can be accessed from Lua.
    +A package file can also include regular header files, other package files, +or lua files.
    +

    Let's start with some examples. If we specify as input the following +C-like header file to tolua: +

    #define FALSE 0
    +#define TRUE 1
    +
    +enum { 
    + POINT = 100, 
    + LINE, 
    + POLYGON
    +}
    + +
    Object* createObejct (int type);
    +void drawObject (Object* obj, double red, double green, double blue);
    +int isSelected (Object* obj);
    +A C file that binds such a code to Lua is automatically generated. Therefore, +in Lua code, we can access the C code, writing, for instance: +
    ...
    +myLine = createObject(LINE)
    +...
    +if isSelected(myLine) == TRUE then
    +  drawObject(myLine, 1.0, 0.0, 0.0);
    +else
    +  drawObject(myLine, 1.0, 1.0, 1.0);
    +end
    +...
    +Also, consider a C++-like header file: +
    #define FALSE 0
    +#define TRUE 1
    + +
    class Shape
    +{
    +  void draw (void);
    +  void draw (double red, double green, double blue);
    +  int isSelected (void);
    +};
    + +
    class Line : public Shape
    +{
    + Line (double x1, double y1, double x2, double y2);
    + ~Line (void);
    +};
    +If this file is used as input to tolua, a C++ file is automatically +generated proving access to such a code from Lua. Therefore, it would be +valid to write Lua statements like: +
    ...
    +myLine = Line:new (0,0,1,1)
    +...
    +if myLine:isSelected() == TRUE then
    + myLine:draw(1.0,0.0,0.0)
    +else
    + myLine:draw()
    +end
    +...
    +myLine:delete()
    +...
    +The package file (usually with extension .pkg) passed to tolua +is not the real C/C++ header file, but a cleaned version of it. +tolua +does not implement a complete parse to interpret C/C++ code, but it understands +a few declarations that are used to describe the features that are to be +exported to Lua. Regular header files can be included into packages files; tolua +will extract the code specified by the user to parse from the header (see Basic Concepts). +

    +How to use toLua

    +tolua is composed by two pieces of code: an executable and a library. +The executable represents the parser that reads a package file and output +a C/C++ code that implements the binding to access the C/C++ features from +Lua. If the package file is a C++ like code (i.e., includes class definitions), +a C++ code is generated. If the cleaned header file is a C like code (i.e., +without classes), a C code is generated. tolua accepts a set of +options. Running "tolua -h" displays the current accepted options. +For instance, to parse a file called myfile.pkg +generating the +binding code in myfile.c, we do: +

    tolua -o myfile.c myfile.pkg +

    The generated code must be compiled and linked with the application +to provide the desired access from Lua. Each parsed file represents a package +being exported to Lua. By default, the package name is the input file root +name (myfile in the example). The user can specify a different +name for the package: +

    tolua -n pkgname -o myfile.c myfile.pkg +

    The package should also be explicitly initialized. To initialize the +package from our C/C++ code, we must declare and call the initialization +function. The initialization function is defined as +

    int tolua_pkgname_open (lua_State*); +

    where pkgname represents the name of the package being +bound. If we are using C++, we can opt for automatic initialization: +

    tolua -a -n pkgname -o myfile.c myfile.pkg +

    In that case, the initialization function is automatically called. However, +if we are planning to use multiple Lua states, automatic initialization +does not work, because the order static variables are initialized in C++ +is not defined. + +

    Optionally, the prototype of the open function +can be outputted to a header file, which name is given by the -H +option. +

    The binding code generated by tolua uses a set of functions defined +in the tolua library. Thus, this library also has to be linked with +the application. The file tolua.h is also necessary to compile +the generated code. +

    An application can use tolua object oriented framework (see exported +utility functions) without binding any package. In that case, the application +must call tolua initialization function (this function is called +by any package file initialization function): +

    int tolua_open (void); + +

    +Basic Concepts

    +The first step in using tolua is to create the package file. Starting +with the real header files, we clean them by declaring the features we +want to access from Lua in a format that tolua can understand. The +format tolua understands is simple C/C++ declarations as described +below. + +

    Including files

    + +A package file may include other package file. The general format +to do that is: +

    +$pfile "include_file" +

    +A package file may also include regular C/C++ header files, using the hfile +or cfile directive: +

    + +$cfile "example.h" +

    +In which case, tolua will extract the code enclosed between tolua_begin +and tolua_end, or or tolua_export for a single line. Consider this C++ header as example: + +

    +
    +#ifndef EXAMPLE_H
    +#define EXAMPLE_H
    +
    +class Example { // tolua_export
    +
    +private:
    +
    +	string name;
    +	int number;
    +
    +public:
    +
    +	void set_number(int number);
    +
    +	//tolua_begin
    +
    +	string get_name();
    +	int get_number();
    +};
    +// tolua_end
    +
    +#endif
    +
    + +

    +In this case, the code that's not supported by tolua (the +private part of the class), along with the function set_number +is left outside of the package that includes this header. +

    + +Finally, lua files can be included on a package file, using $lfile: +

    + +$lfile "example.lua" +

    + +New on tolua++: an extra way to include source files is available since +version 1.0.4 of tolua++, using ifile: +

    + +$ifile "filename" +

    + +ifile also takes extra optional parameters after the filename, for example: +

    + + +$ifile "widget.h", GUI
    +$ifile "vector.h", math, 3d +
    +

    + +ifile's default behaviour is to include the whole file, untouched. However, +the contents of the file and the extra parameters are put through the include_file_hook +function before being included into the package (see Customizing tolua++ +for more details). +

    + +

    +Basic types

    +tolua automatically maps C/C++ basic types to Lua basic types. Thus, +char, +int, +float, and double are mapped to the Lua type number; +char* is mapped to string; and void* is mapped to +userdata. Types may be preceded by modifiers (unsigned, +static, short, const, etc.); however, be aware +that tolua ignores the modifier const if applied to basic +types. Thus, if we pass a constant basic type to Lua and then pass it back +to C/C++ code where a non constant is expected, the constant to non constant +conversion will be silently done. +

    Functions in C/C++ can also manipulate Lua objects explicitly. Thus +lua_Object +is also considered a basic type. In this case, any Lua value matches it. +

    + +New on tolua++: The C++ type string is also considered a basic type, and is passed as +a value to lua (using the c_str() method). This feature can be turned off +with the command line option -S. + +

    +User defined types

    +All other types that appear in the package file being processed are considered +user defined types. These are mapped to tagged userdata type in Lua. Lua +can only store pointers to user defined types; although, tolua +automatically +makes the necessary arrangement to deal with references and values. For +instance, if a function or method returns a value of user defined type, +tolua +allocates +a clone object when returning it to Lua and sets the garbage collection +tag method to automatically free the allocated object when no longer in +use by Lua. +

    For user defined types, constness is preserved. Thus passing a non constant +user defined type to a function that expects constant type generates an +type mismatching error. +

    +NULL and nil

    +C/C++ NULL or 0 pointers are mapped to Lua +nil type; +conversely, nil may be specified wherever a C/C++ pointer is expected. +This is valid for any type: char*, +void*, and pointers +to user defined types. +

    +Typedefs

    +tolua also accepts simple typedef's inside the package files. +Any occurrence of a type after its definition is mapped by tolua +to +the base type. They are useful because several packages redefine the basic +C/C++ types to their own types. For instance, one can define the type real +to +represent a double. In that case, real +can be used to +specify the variable types inside the package file interpreted by tolua, +but only if we include the following definition before any use of the type +real. +

    typedef double real; +

    Otherwise, real would be interpreted as a user defined type +and would not be mapped to Lua numbers. +

    +Including real header files

    +In the package file, we must specify which are the real header files that +should be included so that the generated code can access the constants, +variables, functions, and classes we are binding. Any line in the package +file beginning with a $ (except $[hclp]file, $[ , and $] lines) is +inserted into the generated binding C/C++ code without any change, but the +elimination of the $ itself. We use this feature to include the +real header files. So, our package files will usually start with a set +of $ beginning lines specifying the files that must be included, +that is, the files the package file is based on. +
    /* specify the files to be included */
    + +
    $#include "header1.h"                 // include first header
    +$#include "header2.h"                 // include second header
    +As illustrated, tolua also accepts comments, using C or C++ convention, +inside the package file. Nested C-like comments can also be used. +

    +Also note that files included with $cfile or $hfile don't +need to be included using this method, this is done automatically by tolua. + +

    In the following sections, we describe how to specify the C/C++ code +we want to bind to Lua. The formats are simplified valid C/C++ statements. + +

    +Binding constants

    +To bind constants, tolua accepts both define's and enum's. For define's +the general format is: +
    #define NAME [ VALUE ]
    +The value, as showed above, is optional. If such a code is inserted inside +the file being processed, tolua generates a code that allows the +use of NAME as a Lua global variable that has the corresponding +C/C++ constant value. Only numeric constants are accepted. +

    +New on tolua++: All other preprocessor directives are ignored. +

    For enum's, the general format is: +

    enum {
    +  NAME1 [ = VALUE1 ] ,
    +  NAME2 [ = VALUE2 ] ,
    +  ...
    +  NAMEn [ = VALUEn ]
    +};
    +Similarly, tolua creates a set of global variables, named NAMEi, +with their corresponding values. +

    +Binding external variables

    +Global extern variables can also be exported. In the cleaned header file +they are specified as: +
    [extern] type var;
    +tolua binds such declarations to Lua global variables. Thus, in +Lua, we can access the C/C++ variable naturally. If the variable is non +constant, we can also assign the variable a new value from Lua. Global +variables that represent arrays of value can also be bound to Lua. Arrays +can be of any type. The corresponding Lua objects for arrays are Lua tables +indexed with numeric values; however, be aware that index 1 in Lua is mapped +to index 0 in an C/C++ array. Arrays must be pre dimensioned. For instance: +

    double v[10]; + +

    +New on tolua++: External variables can use the tolua_readonly modifier (see Additional Features) + +

    +Binding functions

    +Functions are also specified as conventional C/C++ declarations: +
    type funcname (type1 par1[, type2 par2[,...typeN parN]]);
    +The returned type can be void, meaning no value is returned. A +function can also have no parameter. In that case, void may be +specified in the place of the list of parameters. The parameter types must +follow the rules already posted. tolua creates a Lua function binding +the C/C++ function. When calling a function from Lua, the parameter types +must match the corresponding C/C++ types, otherwise, tolua +generates +an error and reports which parameter is wrongly specified. If a parameter +name is omitted, tolua names it automatically, but its type should +be a basic type or user type previously used. +

    +Arrays

    +tolua also deals with function or method parameters that represent +arrays of values. The nice thing about arrays is that the corresponding +Lua tables have their values updated if the C/C++ function changes the +array contents. +

    The arrays must be pre dimensioned. For instance: +

    void func (double a[3]); +

    is a valid function declaration for tolua and calling this function +from Lua would be done by, for instance: +

    p = {1.0,1.5,8.6} +
    func (p) +

    The array dimension need not be a constant expression; the dimension +can also be specified by any expression that can be evaluated in run time. +For instance: +

    void func (int n, int m, double image[n*m]); +

    is also valid since the expression n*m is valid in the binding +function scope. However, be aware that tolua uses dynamic allocation +for binding this function, what can degrade the performance. +

    Despite the dimension specification, it is important to know that all +arrays passed to the actual C/C++ function are in the local scope of the +binding function. So, if the C/C++ function being called needs to hold +the array pointer for later use, the binding code will not work +properly. +

    +Overloaded functions

    +Overloaded functions are accepted. Remember that the distinction between +two functions with the same name is made based on the parameter types that +are mapped to Lua. So, although +

    void func (int a); +
    void func (double a); +

    represent two different functions in C++, they are the same function +for tolua, because both int and double are mapped +to the same Lua type: number. +

    Another tricky situation occurs when expecting pointers. Suppose: +

    void func (char* s);
    +void func (void* p);
    +void func (Object1* ptr);
    +void func (Object2* prt);
    +Although these four functions represent different functions in C++, a Lua +statement like: +
    func(nil)
    +matches all of them. +

    It is important to know that tolua decides which function will +be called in run-time, trying to match each provided function. tolua +first +tries to call the last specified function; if it fails, tolua +then +tries the previous one. This process is repeated until one function matches +the calling code or the first function is reached. For that reason, the +mismatching error message, when it occurs, is based on the first function +specification. When performance is important, we can specify the most used +function as the last one, because it will be tried first. +

    tolua allows the use of overloaded functions in C, see Renaming +for +details. +

    +Default parameter values

    +The last function parameters can have associated default values. In that +case, if the function is called with fewer parameters, the default values +are assumed. The format to specify the default values is the same as the +one used in C++ code: +

    type funcname (..., typeN-1 parN-1 +[= valueN-1], typeN parN [= valueN]); +

    toLua implements this feature without using any C++ mechanism; +so, it can be used also to bind C functions. +

    We can also specify default values for the elements of an array (there +is no way to specify a default value for the array itself, though). For +instance: +

    void func (int a[5]=0); +

    sets the default element values to zero, thus the function can be called +from Lua with an uninitialized table. +

    For Lua object types (lua_Object), tolua defines a constant +that can be used to specify nil as default value: +

    void func (lua_Object lo = TOLUA_NIL); +

    + +New on tolua++: C++ class constructors are valid +as default parameters. For example: +

    +void set_color(const Color& color = Color(0,0,0)); +

    + +

    +Multiple returned values

    +In Lua, a function may return any number of values. tolua uses this +feature to simulate values passed by reference. If a function parameter +is specified as a pointer to or reference of a basic type or a pointer +to or reference of a pointer to an user defined type, tolua accepts +the corresponding type as input and returns, besides the conventional function +returned value, if any, the updated parameter value. +

    For instance, consider a C function that swaps two values: +

    void swap (double* x, double* y); +

    or +

    void swap (double& x, double& y); +

    If such a function is declared in the package file, tolua binds +it as a function receiving two numbers as input and returning two numbers. +So, a valid Lua code would be: +

    x,y = swap(x,y) +

    If the input values are not used, the use of default parameter value +allows calling the function from Lua without specifying them: +

    void getBox (double* xmin=0, double* xmax=0, double* ymin=0, double* +ymax=0); +

    In Lua: +

    xmin, xmax, ymin, ymax = getBox() +

    With user defined types, we would have for instance: +

    void update (Point** p); +

    or +

    void update (Point*& p); +

    +Binding struct fields

    +User defined types are nicely bound by tolua. For each variable +or function type that does not correspond to a basic type, tolua automatically +creates a tagged userdata to represent the C/C++ type. If the type corresponds +to a struct, the struct fields can be directly accessed from Lua, indexing +a variable that holds an object of such a type. In C code, these types +are commonly defined using typedef's: +
    typedef struct [name] {
    +   type1 fieldname1;
    +   type2 fieldname2;
    +   ...
    +   typeN fieldnameN;
    +} typename;
    +If such a code is inserted in the package file being processed, tolua +allows +any variable that holds an object of type typename to access +any listed field indexing the variable by the field name. For instance, +if var holds a such object, var.fieldnamei accesses +the field named fieldnamei. +

    Fields that represent arrays of values can also be mapped: +

    typedef struct { +
      int x[10]; +
      int y[10]; +
    } Example; +
      +

    +Binding classes and methods

    +C++ class definitions are also supported by tolua. Actually, the +tolua +deals +with single inheritance and polymorphism in a natural way. The subsections +below describe what can be exported by a class definition. +

    +Specifying inheritance

    +If var is a Lua variable that holds an object of a derived class, +var +can +be used wherever its base class type is expected and var +can access +any method of its base class. For this mechanism to take effect, we must +indicate that the derived class actually inherits the base class. This +is done in the conventional way: +
    class classname : public basename
    +{
    + +
     /* class definition */
    + +
    };
    +

    + +In this case, the definition of basename needs to appear before classname +if the inheritance properties are to be taken advantage of from lua. + +

    Multiple inheritance

    + +tolua++ (starting from version 1.0.4) supports multiple inheritance by allowing you +to access the extra parents 'manually'. +

    +For example, consider the following class: +

    + +

    +class Slider : public Widget, public Range {
    +	...
    +};
    +
    +

    + +An object of type 'Slider' will fully retain its inheritance with Widget, +and will contain a 'member' of type Range, which will return the object +cast to the correct base type. +

    + +For example: +

    + +

    +slider = Slider:new()
    +slider:show() -- a Widget method
    +
    +slider:set_range(0, 100) -- this won't work, because
    +                         -- set_range is a method from Range
    +
    +slider.__Range__:set_range(0, 100) -- this is the correct way
    +
    + +

    + +This is an experimental feature. +

    + +

    +Specifying exported members and methods

    +As for struct fields, class fields, static or not, can be exported. Class +methods and class static methods can also be exported. Of course, they +must be declared as public in the actual C++ code (the +public:keyword may appear in the package files, it will be ignored by tolua). +

    For each bound class, tolua creates a Lua table and stores it +at a variable which name is the name of the C++ class. This tables may contain other +tables that represent other tables, the way C++ classes may contain other classes and structs. +Static exported +fields are accessed by indexing this table with the field names (similar +to struct fields). Static methods are also called using this table, with a colon. +Non static exported fields are accessed by indexing +the variable that holds the object. Class methods follow the format of +the function declaration showed above. They can be accessed from Lua code +using the conventional way Lua uses to call methods, applied of course +to a variable that holds the appropriate object or to the class table, +for static methods. +

    There are a few special methods that are also supported by tolua. +Constructors are called as static methods, named new, new_local (on tolua++), +or calling the class name directly (also on tolua++, see below for the difference betwheen these methods). Destructors +are called as a conventional method called delete. +

    Note that tolua does support overload. This applies even for +constructors. Also note that the virtual keyword has no effect +in the package file. +

    The following code exemplifies class definitions that can be interpreted +by tolua. +

    class Point {
    +   static int n;    // represents the total number of created Points
    +   static int get_n();    // static method
    +
    +   double x;        // represents the x coordinate
    +   double y;        // represents the y coordinate
    + +
       static char* className (void);   // returns the name of the class
    + +
       Point (void);                          // constructor 1
    +   Point (double px, double py);          // constructor 2
    +   ~Point (void);                         // destructor
    + +
       Point add (Point& other);              // add points, returning another one
    +};
    + +
    class ColorPoint : public Color {
    +   int red;      // red color component [0 - 255]
    +   int green;    // green color component [0 - 255]
    +   int blue;     // blue color component [0 - 255]
    + +
       ColorPoint (double px, double py, int r, int g, int b);
    +};
    +If this segment of code is processed by tolua, we would be able +to write the following Lua statements: +
    p1 = Point:new(0.0,1.0)
    +p2 = ColorPoint:new(1.5,2.2,0,0,255)
    +print(Point.n)                     -- would print 2
    +print(Point:get_n())               -- would also print 2
    +p3 = p1:add(p2)
    +local p4 = ColorPoint()
    +print(p3.x,p3.y)                   -- would print 1.5 and 3.2
    +print(p2.red,p2.green,p2.blue)     -- would print 0, 0, and 255
    +p1:delete()                        -- call destructor
    +p2:delete()                        -- call destructor
    + +Note that we can only explicitly delete objects that we explicitly create. +In the example above, the point p3 will be garbage-collected by +tolua +automatically; +we cannot delete it. +

    +New on tolua++: Also note that p4 is created by calling the class name directly (ColorPoint()); this has the same effect as calling new_local, which +leaves the object to be deleted by the garbaje collector, and it should not be +deleted using delete. For each constructor on the pkg, one new, +new_local and .call callback for the class is created. +

    Of course, we need to specify only the methods and members we want to +access from Lua. Sometimes, it will be necessary to declare a class with +no member or method just for the sake of not breaking a chain of inheritances. + +

    Using Regular functions as class methods

    +

    + +tolua++ (starting from version 1.0.5) uses the keyword tolua_outside to specify regular functions +as methods and static methods of a class or struct. For example: + +

    
    +/////////////// position.h:
    +
    +typedef struct {
    +
    +	int x;
    +	int y;
    +} Position;
    +
    +Position* position_create();
    +void position_set(Position* pos, int x, int y);
    +
    +/////////////// position.pkg:
    +
    +struct Position {
    +
    +	int x;
    +	int y;
    +
    +	static tolua_outside Position* position_create @ create();
    +	tolua_outside void position_set @ set(int x, int y);
    +};
    +
    +--------------- position.lua
    +
    +local pos = Position:create()
    +
    +pos:set(10, 10)
    +
    +
    + +Note that the position_set method takes a pointer to Position as its first parameter, +this is ommited on the tolua_outside declaration. Also note that we cannot name our methods +new or new_local, or as overloaded operators (see next section), this will result in +undefined behaviour. + + +

    +Overloaded operators

    +tolua automatically binds the following binary operators: +
      +
      operator+   operator-   operator*   operator/ 
      +operator<   operator>=  operator==  operator[]
      +
    +For the relational operators, toLua also automatically converts +a returned 0 value into nil, so false in C becomes +false +in +Lua. +

    As an example, suppose that in the code above, instead of having: +

       Point add (Point& other);              // add points, returning another one
    +we had: +
       Point operator+ (Point& other);        // add points, returning another one
    +In that case, in Lua, we could simply write: +
    p3 = p1 + p2
    +The indexing operator (operator[]) when receiving a numeric parameter +can also be exported to Lua. In this case, tolua accepts reference +as returned value, even for basic types. Then if a reference is returned, +from Lua, the programmer can either get or set the value. If the returned +value is not a reference, the programmer can only get the value. An example +may clarify: suppose we have a vector class and bind the following operator: +
       double& operator[] (int index);
    +In this case, in Lua, we would be able to write: value = myVector[i] +and also myVector[i] = value, which updates the C++ object. However, +if the bound operator was: +
       double operator[] (int index);
    +we would only be able to write: value = myVector[i]. +

    Free functions (i.e., not class members) that overload operators are +not supported. + +

    + +

    +Cast operators

    + +New on tolua++ (versions 1.0.90 and up): casting operators are also supported. +For example: + +
    +/////////////// node.h
    +
    +// a class that holds a value that can be of type int, double, string or Object*
    +class Node { // tolua_export
    +
    +private:
    +	union {
    +		int int_value;
    +		double double_value;
    +		string string_value;
    +		Object* object_value;
    +	};
    +
    +// tolua_begin
    +public:
    +
    +	enum Type {
    +		T_INT,
    +		T_DOUBLE,
    +		T_STRING,
    +		T_OBJECT,
    +		T_MAX,
    +	};
    +
    +	Type get_type();
    +
    +	operator int();
    +	operator double();
    +	operator string();
    +	operator Object*();
    +};
    +// tolua_end
    +
    + +tolua++ will produce code that calls the operators by casting the object Node (using C++ static_cast), +and register them inside the class as ".typename". For example: + +
    +-- node.lua
    +
    +local node = list.get_node("some_node") -- returns a Node object
    +
    +if node.get_type() == Node.T_STRING then
    +
    +	print("node is "..node[".string"]())
    +
    +elseif node.get_type() == Node.T_OBJECT then
    +
    +	local object = node[".Object*"]()
    +	object:method()
    +end
    +
    +
    + +

    Binding Properties

    + +tolua++ (starting from version 1.0.6) supports declaration of class propeties, +using the tolua_property keyword. A +property will look like a 'field' of the class, but it's value will be retrieved +using class methods. For example: + +
    +/////////////// label.h
    +
    +class Label {
    +
    +public:
    +
    +	string get_name();
    +	void set_name(string p_name);
    +
    +	Widget* get_parent();
    +};
    +
    +/////////////// label.pkg
    +class Label {
    +
    +	tolua_property string name;
    +
    +	tolua_readonly tolua_property Widget* parent;
    +};
    +
    +--------------- label.lua
    +
    +local label = Label()
    +
    +label.name = "hello"
    +print(label.name)
    +
    +label.parent:show()
    +
    +
    + +

    Property types

    +

    + +A property can have differt types, which determine how it's value will be set and retrieved. +tolua++ comes with 3 different built-in types: +

    + +

  • default will use 'get_name' and 'set_name' methods to access a property called 'name' +
  • qt will use 'name' and 'setName' +
  • overload will use 'name' and 'name' (as in 'string name(void);' to get and 'void name(string);' to set) +

    + +The property type can be appended at the end of the 'tolua_property' keyword on the declaration: + +

      tolua_property__qt string name;
    + +When no type is specified, default will be used, but this can be changed (see below). +

    + +

    Changing the default property type

    +

    + +The default property type can be changed using the 'TOLUA_PROPERTY_TYPE' macro. This will change the +default type from the point of its invocation, until the end of the block that contains it. For example: +

    + +

    +
    +TOLUA_PROPERTY_TYPE(default); // default type for the 'global' scope
    +
    +namespace GUI {
    +
    +	class Point {
    +
    +		tolua_property int x; // will use get_x/set_x
    +		tolua_property int y; // will use get_y/set_y
    +	};
    +
    +	TOLUA_PROPERTY_TYPE(qt); // changes default type to 'qt' for the rest of the 'GUI' namespace
    +
    +	class Label {
    +
    +		tolua_property string name; // will use name/setName
    +	};
    +};
    +
    +class Sprite {
    +
    +	tolua_property GUI::Point position; // will use get_position/set_position
    +
    +	tolua_property__overload string name; // will use name/name
    +};
    +
    +
    + +

    Adding custom property types

    +

    + +Custom property types can be added by redefining the function "get_property_methods_hook" +(see Customizing tolua++ for more details). The functions takes +the property type and the name, and returns the setter and getter function names. For example: +

    + +

    +
    +/////////////// custom.lua
    +
    +function get_property_methods_hook(ptype, name)
    +
    +	if ptype == "hungarian_string" then
    +
    +		return "sGet"..name, "Set"..name
    +	end
    +
    +	if ptype == "hungarian_int" then
    +
    +		return "iGet"..name, "Set"..name
    +	end
    +	-- etc
    +end
    +
    +/////////////// label.pkg
    +class Label {
    +
    +	tolua_property__hungarian_string string Name; // uses 'sGetName' and 'SetName'
    +
    +	tolua_property__hungarian_int string Type; // uses 'iGetType' and 'SetType'
    +};
    +
    +
    + +

    Class Templates

    + +One of the additional features of tolua++ is the support for class templates, +by using the TOLUA_TEMPLATE_BIND directive. For example: + +
    +class vector {
    +
    +	TOLUA_TEMPLATE_BIND(T, int, string, Vector3D, double)
    +
    +	void clear();
    +	int size() const;
    +
    +	const T& operator[](int index) const;
    +	T& operator[](int index);
    +	void push_back(T val);
    +
    +	vector();
    +	~vector();
    +};
    +
    + +The TOLUA_TEMPLATE_BIND directive has to be the first thing on the class declaration, otherwise it will be ignored. +This code will create 4 versions of the class vector, one for each type +specified on the TOLUA_TEMPLATE_BIND parameters, each replacing the macro T +(specified as the first argument of TOLUA_TEMPLATE_BIND). +Thus, the functions operator[], &operator[] and push_back +will have different signatures on each version of the object. The objects will be +recognized as vector<type> on further declarations, and the name of +the table on Lua will be vector_type_. Thus, the following Lua code could be used: + +
    +string_vector = vector_string_:new_local()
    +string_vector:push_back("hello")
    +string_vector:push_back("world")
    +print(string_vector[0].." "..string_vector[1])
    +
    + +Similarily, a template with more than 1 macro could be bound, and it could also +inherit from another template: + +
    +class hash_map : public map<K,V> {
    +
    +	TOLUA_TEMPLATE_BIND(K V, int string, string vector<double>)
    +
    +	V get_element(K key);
    +	void set_element(K key, V value);
    +
    +	hash_map();
    +	~hash_map();
    +};
    +
    + +In this example, one of the objects has another template as one of its types, so +it will be recognized as hash_map<string,vector<double> > while +its constructor will be on the Lua table hash_map_string_vector_double___ (see +Type Renaming for a better way to access these objects). +

    + +Note that due to the complexity in the definition of some templates, you should be +careful on how you declare them. For example, if you create an object with type +hash_map<string,vector<double> > and then declare a variable +with type hash_map<string, vector<double> > (note the space +between string and vector), the type of the variable will not be recognized. The +safest way is to declare a typedef, and use that to use each type (this is also a +common practice on C++ programming). For example, using the previous declaration of +vector: +

    + +

    +typedef vector VectorInt;
    +
    +VectorInt variable;
    +
    + +TOLUA_TEMPLATE_BIND can be used with more than one parenthesis to open and close, +in order to be valid as a macro inside a regular .h file. The TOLUA_TEMPLATE_BIND +macro is declared on tolua.h as: +

    +#define TOLUA_TEMPLATE_BIND(x) +

    + +Also, the parameters can have double quotes. Thus, the following uses are valid: +

    + +

    +TOLUA_TEMPLATE_BIND((T, int, float)) // to be used inside a real header file
    +TOLUA_TEMPLATE_BIND("K V", "string string", int double)
    +
    + +Function templates are not supported on this version. + +

    +Module definition

    +tolua allows us to group constants, variables, and functions in +a module. The module itself is mapped to a table in Lua, and its constants, +variables, and functions are mapped to fields in that table. The general +format to specify a module is: +

    module name +
    { +
          ... // constant, variable, and function +declarations +
    } +

    Thus, if we bound the following module declaration: +

    module mod +
    { +
     #define N +
     extern int var; +
     int func (...): +
    } +

    In Lua we would be able to access such features by indexing the module: +mod.N, +mod.var, +mod.func. +

    +Renaming constants, variables and functions

    +When exporting constants, variable, and functions (members of a class or +not), we can rename them, such that they will be bound with a different +name from their C/C++ counterparts. To do that, we write the name they +will be referenced in Lua after the character @. For instance: +

    extern int cvar @ lvar; +

    #define CNAME @ LNAME +

    enum { +
      CITEM1 @ LITEM1, +
      CITEM2 @ LITEM2, +
      ... +
    }; +

    void cfunc @ lfunc (...); +

    class T +
    { +
       double cfield @ lfield; +
       void cmeth @ lmeth (...); +
       ... +
    }; +

    In such a case, the global variable cvar would be identified +in Lua by lvar, the constant CNAME by LNAME, +and so on. Note that class cannot be renamed, because they represent types +in C. +

    This renaming feature allows function overload in C, because we can +choose to export two different C functions with a same Lua name: +

    void glVertex3d @ glVertex (double x, double y, double z=0.0); +
    void glVertexdv @ glVertex (double v[3]=0.0); + +

    Renaming Types

    + +Types can be renamed using the $renaming directive on pkg files, using the +format: +

    + +$renaming real_name @ new_name +

    + +The parameters to renaming can be Lua patterns. For example: +

    + +

    +$renaming ^_+ @
    +$renaming hash_map<string,vector<double> > @ StringHash
    +
    + +The first example will remove all underscores at the beginning of all types, +the second will rename the template type hash_map<string,vector<double> > +to StringHash. Once renamed, the Lua table for each type can be accessed only by their +new name, for example: StringHash:new() + +

    Storing additional fields

    +Finally, it is important to know that even though the variables that hold +C/C++ objects are actually tagged userdata for Lua, tolua creates +a mechanism that allows us to store any additional field attached to these +objects. That is, these objects can be seen as conventional Lua tables. +
    obj = ClassName:new()
    + +
    obj.myfield = 1  -- even though "myfield" does not represent a field of ClassName
    +Such a construction is possible because, if needed, tolua automatically +creates a Lua table and associates it with the object. So that, the object +can store additional fields not mapped to C/C++, but actually stored in +the conjugate table. The Lua programmer accesses the C/C++ features and +these additional fields in an uniform way. Note that, in fact, these additional +fields overwrite C/C++ fields or methods when the names are the same. + + + +

    Additional features on tolua++

    + +

    Multiple variable declarations

    + +Multiple variables of the same type can be declared at the same time, for example: +

    +float x,y,z; +

    +will create 3 different variables of type float. Make sure you don't leave any +spaces between the commas, as that will raise a parse error. +

    + +

    tolua_readonly

    + +Any variable declaration can use the tolua_readonly modifier, to ensure +that the variable is read-only, even when its type is not const. Example: + +
    +class Widget {
    +
    +	tolua_readonly string name;
    +};
    +
    + +This feature could be used to 'hack' the support for other unsupported things like +operator->. Consider this example pkg file: + +
    +$hfile "node.h"
    +$#define __operator_arrow operator->()
    +$#define __get_name get_name()
    +
    + +And on the file node.h: + +
    +template class<T>
    +class Node { // tolua_export
    +
    +private:
    +	string name;
    +	T* value;
    +
    +public:
    +
    +	T* operator->() {return value;};
    +	string get_name() {return name;};
    +
    +	// tolua_begin
    +
    +	#if 0
    +	TOLUA_TEMPLATE_BIND(T, Vector3D)
    +
    +	tolua_readonly __operator_arrow @ p;
    +	tolua_readonly __get_name @ name;
    +	#endif
    +
    +
    +	Node* next;
    +	Node* prev;
    +
    +	void set_name(string p_name) {name = p_name;};
    +
    +	Node();
    +};
    +// tolua_end
    +
    + +While not a pretty thing to do to a header file, this accomplishes a number of +things: +

    + +

  • The method operator->() can be used from Lua by calling the variable +p on the object.
  • +
  • The method get_name() can be using from Lua by calling the variable +name on the boject.
  • + +Example lua usage: + +
    +node = Node_Vector3D_:new_local()
    +-- do something with the node here --
    +print("node name is "..node.name)
    +print("node value is ".. node.p.x ..", ".. node.p.y ..", ".. node.p.z)
    +
    + +Since tolua++ ignores all preprocessor directives (except for #define), node.h +remains a valid C++ header file, and also a valid source for tolua++, +eliminating the need to maintain 2 different files, even for objects with +unusual features such as these ones. + +

    + +The ability to rename functions as variables might be expanded on future versions. + +

    Defining values on command line

    + +Starting from version 1.0.92, the command line option -E allows +you to introduce values into to the luastate where tolua++ runs, +similar to GCC's -D. For example: +

    + +

    $ tolua++ -E VERSION=5.1 -E HAVE_ZLIB package.pkg > package_bind.cpp
    + +

    +This will add 2 fields to the global table _extra_parameters: +"VERSION", with the string value "5.1", and "HAVE_ZLIB" with the boolean value +true. For the moment, there is no way to 'use' these values, except +in custom scripts defined by the user (see +customizing tolua++ for details). + +

    Using C++ typeid

    + +Starting from version 1.0.92, the command line option -t is available, +which generates a list of calls to the empty macro Mtolua_typeid, with its +C++ type_info object, and the name used by tolua++ to identify the type. For example, +if you have a package that binds 2 classes, Foo and Bar, using -t +will produce the following output: + +
    +#ifndef Mtolua_typeid
    +#define Mtolua_typeid(L,TI,T)
    +#endif
    + Mtolua_typeid(tolua_S,typeid(Foo), "Foo");
    + Mtolua_typeid(tolua_S,typeid(Bar), "Bar");
    +
    + +The implementation of Mtolua_typename is left as an exercise to the user. + +

    +Exported utility functions

    +tolua uses itself to export some utility functions to Lua, including +its object-oriented framework. The package file used by tolua is + +shown below: +

    module tolua +
    { +
     char* tolua_bnd_type @ type (lua_Object lo); + +
     void tolua_bnd_takeownership @ takeownership (lua_Object lo); +
     void tolua_bnd_releaseownership @ releaseownership (lua_Object lo); + +
     lua_Object tolua_bnd_cast @ cast (lua_Object lo, char* type); + +
     void tolua_bnd_inherit @ inherit (lua_Object table, lua_Object instance); +

    +/* for lua 5.1 */ +
     void tolua_bnd_setpeer @ setpeer (lua_Object object, lua_Object peer_table); +
     void tolua_bnd_getpeer @ getpeer (lua_Object object); + +
    } + +

    +tolua.type (var)

    +Returns a string representing the object type. For instance, tolua.type(tolua) +returns the string table and tolua.type(tolua.type) +returns cfunction. Similarly, if var is a variable holding +a user defined type T, tolua.type(var) would return +const +T or T, depending whether it is a constant reference. +

    + +

    tolua.takeownership (var)

    + +Takes ownership of the object referenced var. This means that when all references +to that object are lost, the objects itself will be deleted by lua. +

    + +

    tolua.releaseownership (var)

    + +Releases ownership of the object referenced by var. +

    + +

    tolua.cast (var, type)

    + +Changes the metatable of var in order to make it of type type. type needs +to be a string with the complete C type of the object (including namespaces, etc). + +

    tolua.inherit (table, var)

    (new on tolua++) + +Causes tolua++ to recognise table as an object with the same type as var, +and to use var when necesary. For example, consider this method: +

    + +

      void set_parent(Widget* p_parent);
    +

    + +A lua object could be used like this: +

    + +

    +local w = Widget()
    +local lua_widget = {}
    +tolua.inherit(lua_widget, w)
    +
    +set_parent(lua_widget);
    +
    +
    + +Remember that this will only cause the table to be recognised as type 'Widget' when +necesary. To be able to access Widget's methods, you'll have to implement your own +object system. A simple example: +

    + +

    +
    +lua_widget.show = Widget.show
    +
    +lua_widget:show() -- this will call the 'show' method from 'Widget', using the lua
    +                  -- table as 'self'. Since lua_widget inherits from a widget instance,
    +                  -- tolua++ will recognise 'self' as a 'Widget', and call the method
    +
    +
    +

    + +Of course a better way would be to add a __index metamethod for the lua object. +

    + +Similarily, to implement virtual functions, you'll need to create a c++ object that inherits +from the desired type, implement its virtual functions, and use that to inherit from lua. The +object would have a reference to the lua table, and call its methods from the c++ virtual +methods. +

    + +Note: the current implementation (as of version 1.0.6) stores the C instance +inside the lua table on the field ".c_instance", and looks that up when necesary. This +might change in the future, so it is recommended to use an alternative way to store the +C instance to use with your own object system. + +

    tolua.setpeer (object, peer_table) (lua 5.1 only)

    + +Sets the table as the object's peer table (can be nil). The peer table is where all the custom +lua fields for the object are stored. When compiled with lua 5.1, tolua++ stores the +peer as the object's envirnment table, and uses uses lua_gettable/settable (instead of +lua_rawget/set for lua 5.0) to retrieve and store fields on it. This allows us to implement our own +object system on our table (using metatables), and use it as a way to inherit from the userdata object. +Consider an alternative to the previous example: + +
    +-- a 'LuaWidget' class
    +LuaWidget = {}
    +LuaWidget.__index = LuaWidget
    +
    +function LuaWidget:add_button(caption)
    +
    +	-- add a button to our widget here. 'self' will be the userdata Widget
    +end
    +
    +
    +local w = Widget()
    +local t = {}
    +setmetatable(t, LuaWidget) -- make 't' an instance of LuaWidget
    +
    +tolua.setpeer(w, t) -- make 't' the peer table of 'w'
    +
    +set_parent(w) -- we use 'w' as the object now
    +
    +w:show() -- a method from 'Widget'
    +w:add_button("Quit") -- a method from LuaWidget (but we still use 'w' to call it)
    +
    + +When indexing our object, the peer table (if present) will be consulted first, so we +don't need to implement our own __index metamethod to call the C++ functions. + +

    tolua.getpeer (object) (lua 5.1 only)

    + +Retrieves the peer table from the object (can be nil). + + + +

    +Embedded Lua code

    +tolua allows us to embed Lua code in the C/C++ generated code. To +do that, it compiles the specified Lua code and creates a C constant string, +storing the corresponding bytecodes, in the generated code.  When +the package is opened, such a string is executed. The format to embed Lua +code is: +

    $[ +

    embedded Lua code +
    ... +

    $] +

    As an example consider the following .pkg excerpt: +

    /* Bind a Point class */ +
    class Point +
    { +
     Point (int x, int y); +
     ~Point (); +
     void print (); +
     ... +
    } CPoint; +

    $[ +

    -- Create a Point constructor +
    function Point (self) +
     local cobj = CPoint:new(self.x or 0, self.y or 0) +
     tolua.takeownership(cobj) +
     return cobj +
    end +

    $] +

    Binding such a code would allow us to write the following Lua code: +

    p = Point{ x=2, y=3 } +
    p:print() +
    ... +
      + +

    Customizing tolua++

    +

    + +tolua++ calls empty functions at specific points of its execution. This functions +can be redefined on a separate lua file (and included using the -L command line option) +and be used to control the way tolua++ behaves. This is the list of functions +(taken from basic.lua on the tolua++ source): +

    + +

    +
    +-- called right after processing the $[ichl]file directives,
    +-- right before processing anything else
    +-- takes the package object as the parameter
    +function preprocess_hook(p)
    +	-- p.code has all the input code from the pkg
    +end
    +
    +
    +-- called for every $ifile directive
    +-- takes a table with a string called 'code' inside, the filename, and any extra arguments
    +-- passed to $ifile. no return value
    +function include_file_hook(t, filename, ...)
    +
    +end
    +
    +-- called after processing anything that's not code (like '$renaming', comments, etc)
    +-- and right before parsing the actual code.
    +-- takes the Package object with all the code on the 'code' key. no return value
    +function preparse_hook(package)
    +
    +end
    +
    +
    +-- called after writing all the output.
    +-- takes the Package object
    +function post_output_hook(package)
    +
    +end
    +
    +-- called at the beginning of the main parser function, with the code being parsed as a parameter
    +-- it can return nil if nothing was foind, or the contents of 'code', modified by the function
    +-- Usually a parser hook will search the beginning of the string for a token, and if it finds
    +-- anything, return the string without that token (after doing whatever it has to do with the token).
    +function parser_hook(code)
    +
    +end
    +
    +
    +-- called from classFunction:supcode, before the call to the function is output
    +-- the classFunction object is passed.
    +function pre_call_hook(f)
    +
    +end
    +
    +-- called from classFunction:supcode, after the call to the function is output
    +-- the classFunction object is passed.
    +function post_call_hook(f)
    +
    +end
    +
    +-- called before the register code is output
    +function pre_register_hook(package)
    +
    +end
    +
    +-- called to output an error message
    +function output_error_hook(...)
    +	return string.format(...)
    +end
    +
    +
    +
    +

    + +

    Handling custom types

    + +Starting from version 1.0.93, it is possible to specify custom functions to handle certain types. There are 3 +types of functions: a 'push function', used to push the C value onto the Lua stack, a 'to function', +used to retrieve the value from the Lua stack, and return it as a C value, and an 'is function', used to +check if the value on the stack is valid (or convertible to a C value by the to function). These functions are modelled upon +tolua_pushusertype, tolua_tousertype and tolua_isusertype, declared in tolua++.h. +

    +A number of arrays found in basic.lua are used to specify these functions: +

    + +

    +-- for specific types
    +_push_functions = {}
    +_is_functions = {}
    +_to_functions = {}
    +
    +-- for base types
    +_base_push_functions = {}
    +_base_is_functions = {}
    +_base_to_functions = {}
    +
    + +Example (using the -L command line option): +

    + +

    +_is_functions['Vector3'] = 'custom_is_vector3' -- checks for a 3d vector
    +                                               -- (either userdata, or a table with 3 values)
    +_to_functions['Vector3'] = 'custom_to_vector3' -- convertes the eventual table to a Vector3
    +
    +_base_push_functions['Widget'] = 'custom_push_widget' -- pushes anything that inherits from Widget
    +
    + +The _base tables are used to lookup functions for types that are up in the inheritance chain. + +

    Access

    + +Starting from version 1.0.7, all objects have a an access flag, which determines the object's access +inside its container. Container objects also have a member called curr_member_access, which determines +the access of each child object at the moment of its addition to the container. If the access flag has +the value nil (default), false or 0, the object is public. Otherwise, the object +is not public, and tolua++ will not export any code for that object (and any objects it may contain). +

    + +Another 'interesting' function is extract_code, defined on basic.lua, which +extracs the code from files included with $cfile and $hfile (by looking for tolua_begin/end and tolua_export). +

    + +

    Compatibility with older versions.

    + +

    tolua++ <1.0.90

    +

    +Version 1.0.90 of tolua++ introduces 2 small API changes the might be incompatible +with older versions on some cases: +

    +TEMPLATE_BIND +

    +TEMPLATE_BIND is deprecated. Use TOLUA_TEMPLATE_BIND instead. Also, when +declaring a template, the TOLUA_TEMPLATE_BIND statement has to be the first thing +inside the class declaration, otherwise it will be ignored. This fixes a possible problem +with nested template declarations. +

    + +Retrieving Objects +

    + +When passing a full userdata to a function that accepts light userdata parameters (void*), +the tolua++ library function tolua_touserdata will detect the full userdata and dereference +the void** pointer if necesary. This is a change on the function's behaviour (which used to return the pointer as-is). This allows us to pass pointers to objects to a function that accepts +void* pointers. Note that this was a problem when switching from toLua version 4 to version 5 (and tolua++ versions < 1.0.90). + +

    toLua 4

    +

    + +Retrieving Objects +

    + +Users switching from tolua v4 should know that tolua++ stores the objects as +void** on Lua, so when retrieving an object from the luastate using lua_touserdata, +the pointer should be dereferenced. The library function tolua_tousertype +should work as expected. Example: +

    + +

    +lua_pushglobal(lua_state, "get_Object");
    +lua_call(lua_state, 0, 1);  // calling a function that returns an Object
    +
    +Object *new_object = (Object*)(*lua_touserdata(lua_state, -1));
    +or
    +Object *new_object = (Object*)tolua_tousertype(lua_state, -1, NULL);
    +
    + +C++ Strings +

    + +tolua++ binds the c++ type std::string as a basic type, passing it +to Lua as a regular string (using the method c_str()). This feature can be +turned off with the command line option -S. +

    + +Operators +

    + +The list of supported operators has changed, see Binding classes and methods +for more information. +

    + +

    toLua 5

    +

    + +Class destructors. +

    + +With every class constructor, tolua++ exports a 'local' constructor, to create an instance +of the class that is owned by the lua state. To implement this, tolua++ will also export +a function that will delete the class. There are 2 options to prevent this: +

    + +Using the -D command line option will turn this off completely. Destructor functions will +only be exported when a destructor for the class is explicitly declared, or when there is a function +or method that returns an object of the type by value (this is compatible with tolua's behaviour). +

    + +Using the TOLUA_PROTECTED_DESTRUCTOR directive inside the class declaration, to specify that the +class has a private or protected destructor. In this case, no destructor will be exported for that class. +

    + +operator[] index +

    + +Users switching from tolua v5 should know that tolua 5 substracts 1 +from the index on operator[] functions, for compatibility with lua's method for indexing arrays +(1 is the first element). This feature is turned off by default on tolua++ +(making it compatible with tolua 4). It can be turned back on with the +command line option -1 +

    + +C++ Strings +

    + +(see c++ strings on tolua 4 below) + + +

    +Changes since v. 3.0

    + +
      + +
    • +Support for binding arrays as variables and struct/class fields;
    • + +
    • +Support for embedding Lua code into the generated binding code;
    • + +
    • +New utility functions: cast and takeownership;
    • + +
    • +Option to create the corresponding header file of the binding code;
    • + +
    • +New "close" package function;
    • + +
    • +Fixed bug on cloning objects in C++;
    • + +
    • +Fixed bug on enum and struct parsing;
    • +
    +

    +Changes since v. 2.0

    +
      + +
    • +There is a new executable parser;
    • + +
    • +Support for multiple Lua states is provided;
    • + +
    • +Support for module definition is provided;
    • + +
    • +Global variables is now directly bound to Lua global variables;
    • + +
    • +Constness of user defined types is preserved in Lua;
    • + +
    • +Support for multiple returned values from C/C++ is provided (simulating +parameters passed by reference);
    • + +
    • +Constants, variables, and functions bound to Lua can have different names +from their C/C++ counterparts;
    • + +
    • +Object-oriented framework (and other utility functions) used in tolua +is +now exported for Lua programmers;
    • + +

      +Incompatibilities

      +Lua code based on tolua v2.* should run with no change on tolua +v3.0. +Although, it may be necessary to change the .pkg file in order to get the +same behavior. The following incompatibilities exist: +
        +
      • +Parameters defined as pointer to basic types are no longer converted to +arrays of dimension one; they are now considered parameters passed by reference.
      • + +
      • +Automatic initialization for C++ code must be explicitly requested when +using the new parser;
      • + +
      • +Global variables are no longer mapped to a table; the definition of a module +including the global variables may be used to simulate the old behavior;
      • + +
      • +The initialization function is no longer toLua_package_open but +tolua_package_open, without the capital letter (sorry!).
      • +
      +
    +

    +Changes since v. 1.*

    + +
      +
    • +The binding code should run much faster;
    • + +
    • +The cleaned header file extension should now be .pkg instead +of .L;
    • + +
    • +Type modifiers is now accepted (though the current version ignores +const's);
    • + +
    • +Returning object by value is accepted and memory allocation is controlled +by Lua garbage collection;
    • + +
    • +Overloaded functions/methods are accepted;
    • + +
    • +Parameters with default values are accepted;
    • + +
    • +Some overloaded operators are automatically bound.
    • +
    + +

    +Credits

    +Luiz Henrique de Figueiredo had the idea of creating a tool to automatically +bind C code to Lua. L.H.F. wrote the very first version of such a tool +(that bound C functions, variables, and constants) in awk. At that +time, Waldemar Celes (now the main author) was only responsible for the C code that supported the generated +binding code. +

    +While working at NGD Studios, Ariel Manzur made some changes to tolua4 for their +game engine. After the release of tolua5, having left NGD, enough changes were +made to tolua to justify a separate release (with Waldemar's blessing :-) +
      +

    +Availability

    +tolua++ is freely available by http. +The software provided hereunder is on an "as is" basis, and the author +has no obligation to provide maintenance, support, updates, enhancements, +or modifications. +

    +


    This document was created by Waldemar Celes +With modifications by Ariel Manzur/ +
    Last update: Sept 2003 + + diff --git a/third-party/lua-5.1.5/toluapp/doc/toluapp.gif b/third-party/lua-5.1.5/toluapp/doc/toluapp.gif new file mode 100644 index 0000000000000000000000000000000000000000..b9f6f346d4297a006281a20b0414649abff5f807 GIT binary patch literal 5941 zcmb_gL1+|L82)G6mB|V+sGHNOqeyEfY4Om)*7h)_u_k+{+3jqM(t}+rNXWqyS}5&d zRw7-rTVinwg&s6zWp}M&gn$>VqQ+3@rI4bu2fIk2?JdxQScd-Z&Ad17?ab_&)IIDl zlYQU&|L^<$|9_JMqi<(le}4?d;GY4YA3c-F02ly!ve_(v1@JDwQGgSf%yf}_CX2;S zr=~sxI0-PD$y76$Z?oA-Hrpr`zb+ORrlxL8Pv5SR&s??oL%rU(c=39*`cu7r|6=`@ zn>TLXyzyvpacOb!*M|>&TU`9(;e)^1?LXV?m8Vbtr2(w{YsZs>qQC$Q5(ttLtaooM zPc9s}Jbr1F7iYB#yd9K7Yg(sXS#^M9LGry`iMf%?Jok?~9E6Ki2|eBe=J5IrA0 z2j$#VHA5H+oc}FdvTPYT9DPOu#7cJ(Q8c(3 zBg?ZC9VLdKki-mHZE?!E-D)0*QHB_dzSPr=L0!vLM~U%*!I)qoR{8GIQDSIHBr^z< zU#)W3`3N!Cz+KV>gRmo{qvl{7%zA7w>CylW6^o!aU6}NgaC|}NC5WD^+edbYA%;oE zf)G(~cTpDl6Q7vqen~eX$x{@Un}pnY6-lI{2I@wP3`0>g2I@PGik$354AoQT!AP-C zuwzUQ6=80P_7nSML@XVcL91cPd0M%m@?BvZpLB6Sq>E(~*ulkmtgd|a3cC|E3-zzb z1@%gd)>>jE-?X>$Qo1HJ3AyNyyI2(UNyBcvgXZ@%L+K)-;Mj36L^`W^?({m1OXn9z z6ipn(;3XV5W@kFL+z0$88dshNG44wz_clf-5~Gx@xvz3{v$}V?uK5N)exmy&L2-la z0~j@5w|CcarwU5mEavLGP@bk@P z({2?icYZ&ig0DRDkK8X)9k!S9(_zML+8P#;>HtyBrECYK5ojj2YY`NsQxdSXmb=#n zs$wz!L`~tz1j@)GlkSw7}w>6Dge!8ZvWW9Ea`O!E%sGAfzCcKk9l(-ihKBU5MpQ$%R<_ z!PhBWbV-DA=_MUqAP;ylQ@f42&XjoVhF%TgwUXnMm6Nq1gD((E=Bc}Mf>_@CV^uDU zy4YNTjd)@4Q%dl+XIRerWvG409I!jR;#Z=loEzFAESCHeU%KJ?wZON6o!CRUf1z}~ zSTm)9=;^t_Yg%8#a>jvtN+FGzvOL_*HwXK1-TcHL$t>UOhXlqsHn>Ggl;%fJx#80M z1VfP}r|q2vQF8GNVWtx$a;YV;VHR6S!0~AqX&jslyI@vCgJuMl8FPYM0MiJ6~L0?{Uv07f&f(|LU)$0KTxdC15sR)%Dt> zVi7_|mKEK{RN>3iQr|9;S*Xg9bC2aSxg?Nn!MWP7VJ5c#1}@Om!bgy(;9X|7fwTB8 za5Y_ftc0AyN}{sAu7Y8nKdtPsFu|ke3onC)Y%9&ZpbpoMfN9q5mk20Pu+uo6bR}_WVk0N+b!*5D2xq<_qB=AcG%i5%Xj<3Oxh_D|kGr~`Kmrm3{ zXOlZ(a6>JRV4QaqyxXQPtt&g$rpg_56p#m>_tdkY+%PFN!jLV3OGGfDbgUT$3*_bg z9YJAlbu1T&^UiGp6n?(MpRkIOMmfuqJQR+nY|_bZd^EFeFig6*VG#r>p~$Bc;l-FX zAd%1@GZKptS>9qwK21VqxUN$iN~VdsEH n>3AtcP$3ydKq3FXl-!GdJKlSJtaPEaA`vUTkY66(2XFib>)Voo literal 0 HcmV?d00001 diff --git a/third-party/lua-5.1.5/toluapp/include/tolua++.h b/third-party/lua-5.1.5/toluapp/include/tolua++.h new file mode 100644 index 000000000..ed5344926 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/include/tolua++.h @@ -0,0 +1,186 @@ +/* tolua +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + + +#ifndef TOLUA_H +#define TOLUA_H + +#ifndef TOLUA_API +#define TOLUA_API extern +#endif + +#define TOLUA_VERSION "tolua++-1.0.92" + +#ifdef __cplusplus +extern "C" { +#endif + +#define tolua_pushcppstring(x,y) tolua_pushstring(x,y.c_str()) +#define tolua_iscppstring tolua_isstring + +#define tolua_iscppstringarray tolua_isstringarray +#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str()) + +#ifndef TEMPLATE_BIND + #define TEMPLATE_BIND(p) +#endif + +#define TOLUA_TEMPLATE_BIND(p) + +#define TOLUA_PROTECTED_DESTRUCTOR +#define TOLUA_PROPERTY_TYPE(p) + +typedef int lua_Object; + +#include "lua.h" +#include "lauxlib.h" + +struct tolua_Error +{ + int index; + int array; + const char* type; +}; +typedef struct tolua_Error tolua_Error; + +#define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */ + +TOLUA_API const char* tolua_typename (lua_State* L, int lo); +TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err); +TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err); +TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err); +TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err); +TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err); +TOLUA_API int tolua_isvaluearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isbooleanarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isnumberarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isstringarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_istablearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isuserdataarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isusertypearray + (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err); + +TOLUA_API void tolua_open (lua_State* L); + +TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size); +TOLUA_API int tolua_register_gc (lua_State* L, int lo); +TOLUA_API int tolua_default_collect (lua_State* tolua_S); + +TOLUA_API void tolua_usertype (lua_State* L, const char* type); +TOLUA_API void tolua_beginmodule (lua_State* L, const char* name); +TOLUA_API void tolua_endmodule (lua_State* L); +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar); +TOLUA_API void tolua_class (lua_State* L, const char* name, const char* base); +TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col); +TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func); +TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value); +TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set); +TOLUA_API void tolua_array (lua_State* L,const char* name, lua_CFunction get, lua_CFunction set); + +/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */ +/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */ + +TOLUA_API void tolua_pushvalue (lua_State* L, int lo); +TOLUA_API void tolua_pushboolean (lua_State* L, int value); +TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value); +TOLUA_API void tolua_pushstring (lua_State* L, const char* value); +TOLUA_API void tolua_pushuserdata (lua_State* L, void* value); +TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type); +TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type); +TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v); +TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v); +TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v); +TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v); +TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v); +TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type); +TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type); + +TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def); +TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def); +TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def); +TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def); +TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def); +TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def); +TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def); +TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def); +TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def); +TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def); +TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def); +TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def); + +TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name); + +TOLUA_API int class_gc_event (lua_State* L); + +#ifdef __cplusplus +static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) { + + const char* s = tolua_tostring(L, narg, def); + return s?s:""; +}; + +static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) { + + const char* s = tolua_tofieldstring(L, lo, index, def); + return s?s:""; +}; + +#else +#define tolua_tocppstring tolua_tostring +#define tolua_tofieldcppstring tolua_tofieldstring +#endif + +TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index); + +#ifndef Mtolua_new +#define Mtolua_new(EXP) new EXP +#endif + +#ifndef Mtolua_delete +#define Mtolua_delete(EXP) delete EXP +#endif + +#ifndef Mtolua_new_dim +#define Mtolua_new_dim(EXP, len) new EXP[len] +#endif + +#ifndef Mtolua_delete_dim +#define Mtolua_delete_dim(EXP) delete [] EXP +#endif + +#ifndef tolua_outside +#define tolua_outside +#endif + +#ifndef tolua_owned +#define tolua_owned +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/third-party/lua-5.1.5/toluapp/libtoluapp.def b/third-party/lua-5.1.5/toluapp/libtoluapp.def new file mode 100644 index 000000000..824a9c949 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/libtoluapp.def @@ -0,0 +1,65 @@ +EXPORTS +class_gc_event +push_table_instance +tolua_array +tolua_beginmodule +tolua_cclass +tolua_classevents +tolua_constant +tolua_copy +tolua_default_collect +tolua_dobuffer +tolua_endmodule +tolua_error +tolua_fast_isa +tolua_function +tolua_getfieldboolean +tolua_isboolean +tolua_isbooleanarray +tolua_ismodulemetatable +tolua_isnoobj +tolua_isnumber +tolua_isnumberarray +tolua_isstring +tolua_isstringarray +tolua_istable +tolua_istablearray +tolua_isuserdata +tolua_isuserdataarray +tolua_isusertable +tolua_isusertype +tolua_isusertypearray +tolua_isvalue +tolua_isvaluearray +tolua_module +tolua_moduleevents +tolua_open +tolua_pushboolean +tolua_pushfieldboolean +tolua_pushfieldnumber +tolua_pushfieldstring +tolua_pushfielduserdata +tolua_pushfieldusertype +tolua_pushfieldusertype_and_takeownership +tolua_pushfieldvalue +tolua_pushnumber +tolua_pushstring +tolua_pushuserdata +tolua_pushusertype +tolua_pushusertype_and_takeownership +tolua_pushvalue +tolua_register_gc +tolua_toboolean +tolua_tofieldnumber +tolua_tofieldstring +tolua_tofielduserdata +tolua_tofieldusertype +tolua_tofieldvalue +tolua_tonumber +tolua_tostring +tolua_touserdata +tolua_tousertype +tolua_tovalue +tolua_typename +tolua_usertype +tolua_variable diff --git a/third-party/lua-5.1.5/toluapp/simple_build/COPYRIGHT b/third-party/lua-5.1.5/toluapp/simple_build/COPYRIGHT new file mode 100644 index 000000000..9e99e0080 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/COPYRIGHT @@ -0,0 +1,33 @@ +tolua++ License +--------------- + +tolua++ is based on toLua (www.tecgraf.puc-rio.br/~celes/tolua), and +it's licensed under the terms of the MIT license reproduced below. +This means that Lua is free software and can be used for both academic +and commercial purposes at absolutely no cost. + +=============================================================================== + +Copyright (C) 2009 Ariel Manzur. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=============================================================================== + +(end of COPYRIGHT) diff --git a/third-party/lua-5.1.5/toluapp/simple_build/bin/tolua.c b/third-party/lua-5.1.5/toluapp/simple_build/bin/tolua.c new file mode 100644 index 000000000..cc9f9adcd --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/bin/tolua.c @@ -0,0 +1,169 @@ +/* tolua +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Aug 2003 +** $Id:$ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" + +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" + +#include +#include +#include + + +static void help (void) +{ + fprintf(stderr,"\n" + "usage: tolua++ [options] input_file\n" + "\n" + "Command line options are:\n" + " -v : print version information.\n" + " -o file : set output file; default is stdout.\n" + " -H file : create include file.\n" + " -n name : set package name; default is input file root name.\n" + " -p : parse only.\n" + " -P : parse and print structure information (for debug).\n" + " -S : disable support for c++ strings.\n" + " -1 : substract 1 to operator[] index (for compatibility with tolua5).\n" + " -L file : run lua file (with dofile()) before doing anything.\n" + " -D : disable automatic exporting of destructors for classes that have\n" + " constructors (for compatibility with tolua5)\n" + " -W : disable warnings for unsupported features (for compatibility\n" + " with tolua5)\n" + " -C : disable cleanup of included lua code (for easier debugging)\n" + " -E value[=value] : add extra values to the luastate\n" + " -t : export a list of types asociates with the C++ typeid name\n" + " -q : don't print warnings to the console\n" + " -h : print this message.\n" + "Should the input file be omitted, stdin is assumed;\n" + "in that case, the package name must be explicitly set.\n\n" + ); +} + +static void version (void) +{ + fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n",TOLUA_VERSION); +} + +static void setfield (lua_State* L, int table, char* f, char* v) +{ + lua_pushstring(L,f); + lua_pushstring(L,v); + lua_settable(L,table); +} + +static void add_extra (lua_State* L, char* value) { + int len; + lua_getglobal(L, "_extra_parameters"); + len = luaL_getn(L, -1); + lua_pushstring(L, value); + lua_rawseti(L, -2, len+1); + lua_pop(L, 1); +}; + +static void error (char* o) +{ + fprintf(stderr,"tolua: unknown option '%s'\n",o); + help(); + exit(1); +} + +int main (int argc, char* argv[]) +{ + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + #else + lua_State* L = lua_open(); + luaopen_base(L); + luaopen_io(L); + luaopen_string(L); + luaopen_table(L); + luaopen_math(L); + luaopen_debug(L); + #endif + + lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION"); + lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION"); + + if (argc==1) + { + help(); + return 0; + } + else + { + int i, t; + lua_newtable(L); + lua_setglobal(L, "_extra_parameters"); + lua_newtable(L); + lua_pushvalue(L,-1); + lua_setglobal(L,"flags"); + t = lua_gettop(L); + for (i=1; i= 501 + TOLUA_API int luaopen_tolua (lua_State* tolua_S) { + return tolua_tolua_open(tolua_S); +}; +#endif + diff --git a/third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind.h b/third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind.h new file mode 100644 index 000000000..7f1f018c9 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind.h @@ -0,0 +1,8 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.92 on Sun Feb 15 22:29:48 2009. +*/ + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + diff --git a/third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind_default.h b/third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind_default.h new file mode 100644 index 000000000..c31a14875 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/bin/toluabind_default.h @@ -0,0 +1,8 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.8pre2 on Tue Dec 13 01:43:55 2005. +*/ + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + diff --git a/third-party/lua-5.1.5/toluapp/simple_build/include/tolua++.h b/third-party/lua-5.1.5/toluapp/simple_build/include/tolua++.h new file mode 100644 index 000000000..ed5344926 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/include/tolua++.h @@ -0,0 +1,186 @@ +/* tolua +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + + +#ifndef TOLUA_H +#define TOLUA_H + +#ifndef TOLUA_API +#define TOLUA_API extern +#endif + +#define TOLUA_VERSION "tolua++-1.0.92" + +#ifdef __cplusplus +extern "C" { +#endif + +#define tolua_pushcppstring(x,y) tolua_pushstring(x,y.c_str()) +#define tolua_iscppstring tolua_isstring + +#define tolua_iscppstringarray tolua_isstringarray +#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str()) + +#ifndef TEMPLATE_BIND + #define TEMPLATE_BIND(p) +#endif + +#define TOLUA_TEMPLATE_BIND(p) + +#define TOLUA_PROTECTED_DESTRUCTOR +#define TOLUA_PROPERTY_TYPE(p) + +typedef int lua_Object; + +#include "lua.h" +#include "lauxlib.h" + +struct tolua_Error +{ + int index; + int array; + const char* type; +}; +typedef struct tolua_Error tolua_Error; + +#define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */ + +TOLUA_API const char* tolua_typename (lua_State* L, int lo); +TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err); +TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err); +TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err); +TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err); +TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err); +TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err); +TOLUA_API int tolua_isvaluearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isbooleanarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isnumberarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isstringarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_istablearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isuserdataarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err); +TOLUA_API int tolua_isusertypearray + (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err); + +TOLUA_API void tolua_open (lua_State* L); + +TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size); +TOLUA_API int tolua_register_gc (lua_State* L, int lo); +TOLUA_API int tolua_default_collect (lua_State* tolua_S); + +TOLUA_API void tolua_usertype (lua_State* L, const char* type); +TOLUA_API void tolua_beginmodule (lua_State* L, const char* name); +TOLUA_API void tolua_endmodule (lua_State* L); +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar); +TOLUA_API void tolua_class (lua_State* L, const char* name, const char* base); +TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col); +TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func); +TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value); +TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set); +TOLUA_API void tolua_array (lua_State* L,const char* name, lua_CFunction get, lua_CFunction set); + +/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */ +/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */ + +TOLUA_API void tolua_pushvalue (lua_State* L, int lo); +TOLUA_API void tolua_pushboolean (lua_State* L, int value); +TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value); +TOLUA_API void tolua_pushstring (lua_State* L, const char* value); +TOLUA_API void tolua_pushuserdata (lua_State* L, void* value); +TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type); +TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type); +TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v); +TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v); +TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v); +TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v); +TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v); +TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type); +TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type); + +TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def); +TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def); +TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def); +TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def); +TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def); +TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def); +TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def); +TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def); +TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def); +TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def); +TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def); +TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def); + +TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name); + +TOLUA_API int class_gc_event (lua_State* L); + +#ifdef __cplusplus +static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) { + + const char* s = tolua_tostring(L, narg, def); + return s?s:""; +}; + +static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) { + + const char* s = tolua_tofieldstring(L, lo, index, def); + return s?s:""; +}; + +#else +#define tolua_tocppstring tolua_tostring +#define tolua_tofieldcppstring tolua_tofieldstring +#endif + +TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index); + +#ifndef Mtolua_new +#define Mtolua_new(EXP) new EXP +#endif + +#ifndef Mtolua_delete +#define Mtolua_delete(EXP) delete EXP +#endif + +#ifndef Mtolua_new_dim +#define Mtolua_new_dim(EXP, len) new EXP[len] +#endif + +#ifndef Mtolua_delete_dim +#define Mtolua_delete_dim(EXP) delete [] EXP +#endif + +#ifndef tolua_outside +#define tolua_outside +#endif + +#ifndef tolua_owned +#define tolua_owned +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.c b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.c new file mode 100644 index 000000000..8258867b4 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.c @@ -0,0 +1,536 @@ +/* tolua: event functions +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include + +#include "tolua++.h" + +/* Store at ubox + * It stores, creating the corresponding table if needed, + * the pair key/value in the corresponding ubox table +*/ +static void storeatubox (lua_State* L, int lo) +{ + #ifdef LUA_VERSION_NUM + lua_getfenv(L, lo); + if (lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pop(L, 1); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setfenv(L, lo); /* stack: k,v,table */ + }; + lua_insert(L, -3); + lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */ + lua_pop(L, 1); + #else + /* stack: key value (to be stored) */ + lua_pushstring(L,"tolua_peers"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: k v ubox */ + lua_pushvalue(L,lo); + lua_rawget(L,-2); /* stack: k v ubox ubox[u] */ + if (!lua_istable(L,-1)) + { + lua_pop(L,1); /* stack: k v ubox */ + lua_newtable(L); /* stack: k v ubox table */ + lua_pushvalue(L,1); + lua_pushvalue(L,-2); /* stack: k v ubox table u table */ + lua_rawset(L,-4); /* stack: k v ubox ubox[u]=table */ + } + lua_insert(L,-4); /* put table before k */ + lua_pop(L,1); /* pop ubox */ + lua_rawset(L,-3); /* store at table */ + lua_pop(L,1); /* pop ubox[u] */ + #endif +} + +/* Module index function +*/ +static int module_index_event (lua_State* L) +{ + lua_pushstring(L,".get"); + lua_rawget(L,-3); + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { + lua_call(L,0,1); + return 1; + } + else if (lua_istable(L,-1)) + return 1; + } + /* call old index meta event */ + if (lua_getmetatable(L,1)) + { + lua_pushstring(L,"__index"); + lua_rawget(L,-2); + lua_pushvalue(L,1); + lua_pushvalue(L,2); + if (lua_isfunction(L,-1)) + { + lua_call(L,2,1); + return 1; + } + else if (lua_istable(L,-1)) + { + lua_gettable(L,-3); + return 1; + } + } + lua_pushnil(L); + return 1; +} + +/* Module newindex function +*/ +static int module_newindex_event (lua_State* L) +{ + lua_pushstring(L,".set"); + lua_rawget(L,-4); + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); /* only to be compatible with non-static vars */ + lua_pushvalue(L,3); /* value */ + lua_call(L,2,0); + return 0; + } + } + /* call old newindex meta event */ + if (lua_getmetatable(L,1) && lua_getmetatable(L,-1)) + { + lua_pushstring(L,"__newindex"); + lua_rawget(L,-2); + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_pushvalue(L,3); + lua_call(L,3,0); + } + } + lua_settop(L,3); + lua_rawset(L,-3); + return 0; +} + +/* Class index function + * If the object is a userdata (ie, an object), it searches the field in + * the alternative table stored in the corresponding "ubox" table. +*/ +static int class_index_event (lua_State* L) +{ + int t = lua_type(L,1); + if (t == LUA_TUSERDATA) + { + /* Access alternative table */ + #ifdef LUA_VERSION_NUM /* new macro on version 5.1 */ + lua_getfenv(L,1); + if (!lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pushvalue(L, 2); /* key */ + lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */ + if (!lua_isnil(L, -1)) + return 1; + }; + #else + lua_pushstring(L,"tolua_peers"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: obj key ubox */ + lua_pushvalue(L,1); + lua_rawget(L,-2); /* stack: obj key ubox ubox[u] */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* stack: obj key ubox ubox[u] value */ + if (!lua_isnil(L,-1)) + return 1; + } + #endif + lua_settop(L,2); /* stack: obj key */ + /* Try metatables */ + lua_pushvalue(L,1); /* stack: obj key obj */ + while (lua_getmetatable(L,-1)) + { /* stack: obj key obj mt */ + lua_remove(L,-2); /* stack: obj key mt */ + if (lua_isnumber(L,2)) /* check if key is a numeric value */ + { + /* try operator[] */ + lua_pushstring(L,".geti"); + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + } + else + { + lua_pushvalue(L,2); /* stack: obj key mt key */ + lua_rawget(L,-2); /* stack: obj key mt value */ + if (!lua_isnil(L,-1)) + return 1; + else + lua_pop(L,1); + /* try C/C++ variable */ + lua_pushstring(L,".get"); + lua_rawget(L,-2); /* stack: obj key mt tget */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); + lua_rawget(L,-2); /* stack: obj key mt value */ + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + else if (lua_istable(L,-1)) + { + /* deal with array: create table to be returned and cache it in ubox */ + void* u = *((void**)lua_touserdata(L,1)); + lua_newtable(L); /* stack: obj key mt value table */ + lua_pushstring(L,".self"); + lua_pushlightuserdata(L,u); + lua_rawset(L,-3); /* store usertype in ".self" */ + lua_insert(L,-2); /* stack: obj key mt table value */ + lua_setmetatable(L,-2); /* set stored value as metatable */ + lua_pushvalue(L,-1); /* stack: obj key met table table */ + lua_pushvalue(L,2); /* stack: obj key mt table table key */ + lua_insert(L,-2); /* stack: obj key mt table key table */ + storeatubox(L,1); /* stack: obj key mt table */ + return 1; + } + } + } + lua_settop(L,3); + } + lua_pushnil(L); + return 1; + } + else if (t== LUA_TTABLE) + { + module_index_event(L); + return 1; + } + lua_pushnil(L); + return 1; +} + +/* Newindex function + * It first searches for a C/C++ varaible to be set. + * Then, it either stores it in the alternative ubox table (in the case it is + * an object) or in the own table (that represents the class or module). +*/ +static int class_newindex_event (lua_State* L) +{ + int t = lua_type(L,1); + if (t == LUA_TUSERDATA) + { + /* Try accessing a C/C++ variable to be set */ + lua_getmetatable(L,1); + while (lua_istable(L,-1)) /* stack: t k v mt */ + { + if (lua_isnumber(L,2)) /* check if key is a numeric value */ + { + /* try operator[] */ + lua_pushstring(L,".seti"); + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_pushvalue(L,3); + lua_call(L,3,0); + return 0; + } + } + else + { + lua_pushstring(L,".set"); + lua_rawget(L,-2); /* stack: t k v mt tset */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); + lua_rawget(L,-2); /* stack: t k v mt tset func */ + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,3); + lua_call(L,2,0); + return 0; + } + lua_pop(L,1); /* stack: t k v mt tset */ + } + lua_pop(L,1); /* stack: t k v mt */ + if (!lua_getmetatable(L,-1)) /* stack: t k v mt mt */ + lua_pushnil(L); + lua_remove(L,-2); /* stack: t k v mt */ + } + } + lua_settop(L,3); /* stack: t k v */ + + /* then, store as a new field */ + storeatubox(L,1); + } + else if (t== LUA_TTABLE) + { + module_newindex_event(L); + } + return 0; +} + +static int class_call_event(lua_State* L) { + + if (lua_istable(L, 1)) { + lua_pushstring(L, ".call"); + lua_rawget(L, 1); + if (lua_isfunction(L, -1)) { + + lua_insert(L, 1); + lua_call(L, lua_gettop(L)-1, 1); + + return 1; + }; + }; + tolua_error(L,"Attempt to call a non-callable object.",NULL); + return 0; +}; + +static int do_operator (lua_State* L, const char* op) +{ + if (lua_isuserdata(L,1)) + { + /* Try metatables */ + lua_pushvalue(L,1); /* stack: op1 op2 */ + while (lua_getmetatable(L,-1)) + { /* stack: op1 op2 op1 mt */ + lua_remove(L,-2); /* stack: op1 op2 mt */ + lua_pushstring(L,op); /* stack: op1 op2 mt key */ + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + lua_settop(L,3); + } + } + tolua_error(L,"Attempt to perform operation on an invalid operand",NULL); + return 0; +} + +static int class_add_event (lua_State* L) +{ + return do_operator(L,".add"); +} + +static int class_sub_event (lua_State* L) +{ + return do_operator(L,".sub"); +} + +static int class_mul_event (lua_State* L) +{ + return do_operator(L,".mul"); +} + +static int class_div_event (lua_State* L) +{ + return do_operator(L,".div"); +} + +static int class_lt_event (lua_State* L) +{ + return do_operator(L,".lt"); +} + +static int class_le_event (lua_State* L) +{ + return do_operator(L,".le"); +} + +static int class_eq_event (lua_State* L) +{ + /* copying code from do_operator here to return false when no operator is found */ + if (lua_isuserdata(L,1)) + { + /* Try metatables */ + lua_pushvalue(L,1); /* stack: op1 op2 */ + while (lua_getmetatable(L,-1)) + { /* stack: op1 op2 op1 mt */ + lua_remove(L,-2); /* stack: op1 op2 mt */ + lua_pushstring(L,".eq"); /* stack: op1 op2 mt key */ + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + lua_settop(L,3); + } + } + + lua_settop(L, 3); + lua_pushboolean(L, 0); + return 1; +} + +/* +static int class_gc_event (lua_State* L) +{ + void* u = *((void**)lua_touserdata(L,1)); + fprintf(stderr, "collecting: looking at %p\n", u); + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_call(L,1,0); + lua_pushlightuserdata(L,u); + lua_pushnil(L); + lua_rawset(L,-3); + } + lua_pop(L,2); + return 0; +} +*/ +TOLUA_API int class_gc_event (lua_State* L) +{ + void* u = *((void**)lua_touserdata(L,1)); + int top; + /*fprintf(stderr, "collecting: looking at %p\n", u);*/ + /* + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + */ + lua_pushvalue(L, lua_upvalueindex(1)); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); /* stack: gc umt */ + lua_getmetatable(L,1); /* stack: gc umt mt */ + /*fprintf(stderr, "checking type\n");*/ + top = lua_gettop(L); + if (tolua_fast_isa(L,top,top-1, lua_upvalueindex(2))) /* make sure we collect correct type */ + { + /*fprintf(stderr, "Found type!\n");*/ + /* get gc function */ + lua_pushliteral(L,".collector"); + lua_rawget(L,-2); /* stack: gc umt mt collector */ + if (lua_isfunction(L,-1)) { + /*fprintf(stderr, "Found .collector!\n");*/ + } + else { + lua_pop(L,1); + /*fprintf(stderr, "Using default cleanup\n");*/ + lua_pushcfunction(L,tolua_default_collect); + } + + lua_pushvalue(L,1); /* stack: gc umt mt collector u */ + lua_call(L,1,0); + + lua_pushlightuserdata(L,u); /* stack: gc umt mt u */ + lua_pushnil(L); /* stack: gc umt mt u nil */ + lua_rawset(L,-5); /* stack: gc umt mt */ + } + lua_pop(L,3); + return 0; +} + + +/* Register module events + * It expects the metatable on the top of the stack +*/ +TOLUA_API void tolua_moduleevents (lua_State* L) +{ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,module_index_event); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,module_newindex_event); + lua_rawset(L,-3); +} + +/* Check if the object on the top has a module metatable +*/ +TOLUA_API int tolua_ismodulemetatable (lua_State* L) +{ + int r = 0; + if (lua_getmetatable(L,-1)) + { + lua_pushstring(L,"__index"); + lua_rawget(L,-2); + r = (lua_tocfunction(L,-1) == module_index_event); + lua_pop(L,2); + } + return r; +} + +/* Register class events + * It expects the metatable on the top of the stack +*/ +TOLUA_API void tolua_classevents (lua_State* L) +{ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,class_index_event); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,class_newindex_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__add"); + lua_pushcfunction(L,class_add_event); + lua_rawset(L,-3); + lua_pushstring(L,"__sub"); + lua_pushcfunction(L,class_sub_event); + lua_rawset(L,-3); + lua_pushstring(L,"__mul"); + lua_pushcfunction(L,class_mul_event); + lua_rawset(L,-3); + lua_pushstring(L,"__div"); + lua_pushcfunction(L,class_div_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__lt"); + lua_pushcfunction(L,class_lt_event); + lua_rawset(L,-3); + lua_pushstring(L,"__le"); + lua_pushcfunction(L,class_le_event); + lua_rawset(L,-3); + lua_pushstring(L,"__eq"); + lua_pushcfunction(L,class_eq_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__call"); + lua_pushcfunction(L,class_call_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__gc"); + lua_pushstring(L, "tolua_gc_event"); + lua_rawget(L, LUA_REGISTRYINDEX); + /*lua_pushcfunction(L,class_gc_event);*/ + lua_rawset(L,-3); +} + diff --git a/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.h b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.h new file mode 100644 index 000000000..898f33dfc --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_event.h @@ -0,0 +1,24 @@ +/* tolua: event functions +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#ifndef TOLUA_EVENT_H +#define TOLUA_EVENT_H + +#include "tolua++.h" + +TOLUA_API void tolua_moduleevents (lua_State* L); +TOLUA_API int tolua_ismodulemetatable (lua_State* L); +TOLUA_API void tolua_classevents (lua_State* L); + +#endif diff --git a/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_is.c b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_is.c new file mode 100644 index 000000000..add337d19 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_is.c @@ -0,0 +1,621 @@ +/* tolua: functions to check types. +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "lauxlib.h" + +#include +#include + +/* a fast check if a is b, without parameter validation + i.e. if b is equal to a or a superclass of a. */ +TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index) +{ + int result; + if (lua_rawequal(L,mt_indexa,mt_indexb)) + result = 1; + else + { + if (super_index) { + lua_pushvalue(L, super_index); + } else { + lua_pushliteral(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ + }; + lua_pushvalue(L,mt_indexa); /* stack: super mta */ + lua_rawget(L,-2); /* stack: super super[mta] */ + lua_pushvalue(L,mt_indexb); /* stack: super super[mta] mtb */ + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super super[mta] typenameB */ + lua_rawget(L,-2); /* stack: super super[mta] bool */ + result = lua_toboolean(L,-1); + lua_pop(L,3); + } + return result; +} + +/* Push and returns the corresponding object typename */ +TOLUA_API const char* tolua_typename (lua_State* L, int lo) +{ + int tag = lua_type(L,lo); + if (tag == LUA_TNONE) + lua_pushstring(L,"[no object]"); + else if (tag != LUA_TUSERDATA && tag != LUA_TTABLE) + lua_pushstring(L,lua_typename(L,tag)); + else if (tag == LUA_TUSERDATA) + { + if (!lua_getmetatable(L,lo)) + lua_pushstring(L,lua_typename(L,tag)); + else + { + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isstring(L,-1)) + { + lua_pop(L,1); + lua_pushstring(L,"[undefined]"); + } + } + } + else /* is table */ + { + lua_pushvalue(L,lo); + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isstring(L,-1)) + { + lua_pop(L,1); + lua_pushstring(L,"table"); + } + else + { + lua_pushstring(L,"class "); + lua_insert(L,-2); + lua_concat(L,2); + } + } + return lua_tostring(L,-1); +} + +TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err) +{ + if (msg[0] == '#') + { + const char* expected = err->type; + const char* provided = tolua_typename(L,err->index); + if (msg[1]=='f') + { + int narg = err->index; + if (err->array) + luaL_error(L,"%s\n argument #%d is array of '%s'; array of '%s' expected.\n", + msg+2,narg,provided,expected); + else + luaL_error(L,"%s\n argument #%d is '%s'; '%s' expected.\n", + msg+2,narg,provided,expected); + } + else if (msg[1]=='v') + { + if (err->array) + luaL_error(L,"%s\n value is array of '%s'; array of '%s' expected.\n", + msg+2,provided,expected); + else + luaL_error(L,"%s\n value is '%s'; '%s' expected.\n", + msg+2,provided,expected); + } + } + else + luaL_error(L,msg); +} + +/* the equivalent of lua_is* for usertable */ +static int lua_isusertable (lua_State* L, int lo, const const char* type) +{ + int r = 0; + if (lo < 0) lo = lua_gettop(L)+lo+1; + lua_pushvalue(L,lo); + lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[t] */ + if (lua_isstring(L,-1)) + { + r = strcmp(lua_tostring(L,-1),type)==0; + if (!r) + { + /* try const */ + lua_pushstring(L,"const "); + lua_insert(L,-2); + lua_concat(L,2); + r = lua_isstring(L,-1) && strcmp(lua_tostring(L,-1),type)==0; + } + } + lua_pop(L, 1); + return r; +} + +int push_table_instance(lua_State* L, int lo) { + + if (lua_istable(L, lo)) { + + lua_pushstring(L, ".c_instance"); + lua_gettable(L, lo); + if (lua_isuserdata(L, -1)) { + + lua_replace(L, lo); + return 1; + } else { + + lua_pop(L, 1); + return 0; + }; + } else { + return 0; + }; + + return 0; +}; + +/* the equivalent of lua_is* for usertype */ +static int lua_isusertype (lua_State* L, int lo, const char* type) +{ + if (!lua_isuserdata(L,lo)) { + if (!push_table_instance(L, lo)) { + return 0; + }; + }; + { + /* check if it is of the same type */ + int r; + const char *tn; + if (lua_getmetatable(L,lo)) /* if metatable? */ + { + lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[mt] */ + tn = lua_tostring(L,-1); + r = tn && (strcmp(tn,type) == 0); + lua_pop(L, 1); + if (r) + return 1; + else + { + /* check if it is a specialized class */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* get super */ + lua_getmetatable(L,lo); + lua_rawget(L,-2); /* get super[mt] */ + if (lua_istable(L,-1)) + { + int b; + lua_pushstring(L,type); + lua_rawget(L,-2); /* get super[mt][type] */ + b = lua_toboolean(L,-1); + lua_pop(L,3); + if (b) + return 1; + } + } + } + } + return 0; +} + +TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err) +{ + if (lua_gettop(L)index = lo; + err->array = 0; + err->type = "[no object]"; + return 0; +} + +TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "boolean"; + return 0; +} + +TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "number"; + return 0; +} + +TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "string"; + return 0; +} + +TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "table"; + return 0; +} + +TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = type; + return 0; +} + + +TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "userdata"; + return 0; +} + +TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) { + + if (lua_gettop(L)index = lo; + err->array = 0; + err->type = "value"; + return 1; +}; + +TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def || abs(lo)<=lua_gettop(L)) /* any valid index */ + return 1; + err->index = lo; + err->array = 0; + err->type = "value"; + return 0; +} + +TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = type; + return 0; +} + +TOLUA_API int tolua_isvaluearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + return 1; +} + +TOLUA_API int tolua_isbooleanarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "boolean"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isnumberarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!lua_isnumber(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "number"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isstringarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "string"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_istablearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (! lua_istable(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "table"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isuserdataarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "userdata"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isusertypearray + (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->type = type; + err->array = 1; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +#if 0 +int tolua_isbooleanfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "boolean"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isnumberfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!lua_isnumber(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "number"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isstringfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "string"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_istablefield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i+1); + lua_gettable(L,lo); + if (! lua_istable(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "table"; + return 0; + } + lua_pop(L,1); +} + +int tolua_isusertablefield + (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (! lua_isusertable(L,-1,type) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = type; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isuserdatafield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "userdata"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isusertypefield + (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isusertype(L,-1,type)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->type = type; + err->array = 1; + return 0; + } + lua_pop(L,1); + return 1; +} + +#endif diff --git a/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_map.c b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_map.c new file mode 100644 index 000000000..d00e7069b --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_map.c @@ -0,0 +1,704 @@ +/* tolua: functions to map features +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "tolua_event.h" +#include "lauxlib.h" + +#include +#include +#include +#include + + +/* Create metatable + * Create and register new metatable +*/ +static int tolua_newmetatable (lua_State* L, char* name) +{ + int r = luaL_newmetatable(L,name); + + #ifdef LUA_VERSION_NUM /* only lua 5.1 */ + if (r) { + lua_pushvalue(L, -1); + lua_pushstring(L, name); + lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */ + }; + #endif + + if (r) + tolua_classevents(L); /* set meta events */ + lua_pop(L,1); + return r; +} + +/* Map super classes + * It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name' +*/ +static void mapsuper (lua_State* L, const char* name, const char* base) +{ + /* push registry.super */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ + luaL_getmetatable(L,name); /* stack: super mt */ + lua_rawget(L,-2); /* stack: super table */ + if (lua_isnil(L,-1)) + { + /* create table */ + lua_pop(L,1); + lua_newtable(L); /* stack: super table */ + luaL_getmetatable(L,name); /* stack: super table mt */ + lua_pushvalue(L,-2); /* stack: super table mt table */ + lua_rawset(L,-4); /* stack: super table */ + } + + /* set base as super class */ + lua_pushstring(L,base); + lua_pushboolean(L,1); + lua_rawset(L,-3); /* stack: super table */ + + /* set all super class of base as super class of name */ + luaL_getmetatable(L,base); /* stack: super table base_mt */ + lua_rawget(L,-3); /* stack: super table base_table */ + if (lua_istable(L,-1)) + { + /* traverse base table */ + lua_pushnil(L); /* first key */ + while (lua_next(L,-2) != 0) + { + /* stack: ... base_table key value */ + lua_pushvalue(L,-2); /* stack: ... base_table key value key */ + lua_insert(L,-2); /* stack: ... base_table key key value */ + lua_rawset(L,-5); /* stack: ... base_table key */ + } + } + lua_pop(L,3); /* stack: */ +} + +/* creates a 'tolua_ubox' table for base clases, and +// expects the metatable and base metatable on the stack */ +static void set_ubox(lua_State* L) { + + /* mt basemt */ + if (!lua_isnil(L, -1)) { + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L,-2); + } else { + lua_pushnil(L); + }; + /* mt basemt base_ubox */ + if (!lua_isnil(L,-1)) { + lua_pushstring(L, "tolua_ubox"); + lua_insert(L, -2); + /* mt basemt key ubox */ + lua_rawset(L,-4); + /* (mt with ubox) basemt */ + } else { + /* mt basemt nil */ + lua_pop(L, 1); + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be + garbage-collected */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ + lua_setmetatable(L, -2); /* stack:mt basemt string ubox */ + lua_rawset(L,-4); + }; + +}; + +/* Map inheritance + * It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name' +*/ +static void mapinheritance (lua_State* L, const char* name, const char* base) +{ + /* set metatable inheritance */ + luaL_getmetatable(L,name); + + if (base && *base) + luaL_getmetatable(L,base); + else { + + if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */ + lua_pop(L, 2); + return; + }; + luaL_getmetatable(L,"tolua_commonclass"); + }; + + set_ubox(L); + + lua_setmetatable(L,-2); + lua_pop(L,1); +} + +/* Object type +*/ +static int tolua_bnd_type (lua_State* L) +{ + tolua_typename(L,lua_gettop(L)); + return 1; +} + +/* Take ownership +*/ +static int tolua_bnd_takeownership (lua_State* L) +{ + int success = 0; + if (lua_isuserdata(L,1)) + { + if (lua_getmetatable(L,1)) /* if metatable? */ + { + lua_pop(L,1); /* clear metatable off stack */ + /* force garbage collection to avoid C to reuse a to-be-collected address */ + #ifdef LUA_VERSION_NUM + lua_gc(L, LUA_GCCOLLECT, 0); + #else + lua_setgcthreshold(L,0); + #endif + + success = tolua_register_gc(L,1); + } + } + lua_pushboolean(L,success!=0); + return 1; +} + +/* Release ownership +*/ +static int tolua_bnd_releaseownership (lua_State* L) +{ + int done = 0; + if (lua_isuserdata(L,1)) + { + void* u = *((void**)lua_touserdata(L,1)); + /* force garbage collection to avoid releasing a to-be-collected address */ + #ifdef LUA_VERSION_NUM + lua_gc(L, LUA_GCCOLLECT, 0); + #else + lua_setgcthreshold(L,0); + #endif + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); + lua_getmetatable(L,1); + if (lua_rawequal(L,-1,-2)) /* check that we are releasing the correct type */ + { + lua_pushlightuserdata(L,u); + lua_pushnil(L); + lua_rawset(L,-5); + done = 1; + } + } + lua_pushboolean(L,done!=0); + return 1; +} + +/* Type casting +*/ +static int tolua_bnd_cast (lua_State* L) +{ + +/* // old code + void* v = tolua_tousertype(L,1,NULL); + const char* s = tolua_tostring(L,2,NULL); + if (v && s) + tolua_pushusertype(L,v,s); + else + lua_pushnil(L); + return 1; +*/ + + void* v; + const char* s; + if (lua_islightuserdata(L, 1)) { + v = tolua_touserdata(L, 1, NULL); + } else { + v = tolua_tousertype(L, 1, 0); + }; + + s = tolua_tostring(L,2,NULL); + if (v && s) + tolua_pushusertype(L,v,s); + else + lua_pushnil(L); + return 1; +} + +/* Inheritance +*/ +static int tolua_bnd_inherit (lua_State* L) { + + /* stack: lua object, c object */ + lua_pushstring(L, ".c_instance"); + lua_pushvalue(L, -2); + lua_rawset(L, -4); + /* l_obj[".c_instance"] = c_obj */ + + return 0; +}; + +#ifdef LUA_VERSION_NUM /* lua 5.1 */ +static int tolua_bnd_setpeer(lua_State* L) { + + /* stack: userdata, table */ + if (!lua_isuserdata(L, -2)) { + lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected."); + lua_error(L); + }; + + if (lua_isnil(L, -1)) { + + lua_pop(L, 1); + lua_pushvalue(L, TOLUA_NOPEER); + }; + lua_setfenv(L, -2); + + return 0; +}; + +static int tolua_bnd_getpeer(lua_State* L) { + + /* stack: userdata */ + lua_getfenv(L, -1); + if (lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pop(L, 1); + lua_pushnil(L); + }; + return 1; +}; +#endif + +/* static int class_gc_event (lua_State* L); */ + +TOLUA_API void tolua_open (lua_State* L) +{ + int top = lua_gettop(L); + lua_pushstring(L,"tolua_opened"); + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isboolean(L,-1)) + { + lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX); + + #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */ + /* create peer object table */ + lua_pushstring(L, "tolua_peers"); lua_newtable(L); + /* make weak key metatable for peers indexed by userdata object */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3); /* stack: string peers mt */ + lua_setmetatable(L, -2); /* stack: string peers */ + lua_rawset(L,LUA_REGISTRYINDEX); + #endif + + /* create object ptr -> udata mapping table */ + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be + garbage-collected */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ + lua_setmetatable(L, -2); /* stack: string ubox */ + lua_rawset(L,LUA_REGISTRYINDEX); + + lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX); + lua_pushstring(L,"tolua_gc"); lua_newtable(L);lua_rawset(L,LUA_REGISTRYINDEX); + + /* create gc_event closure */ + lua_pushstring(L, "tolua_gc_event"); + lua_pushstring(L, "tolua_gc"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushstring(L, "tolua_super"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushcclosure(L, class_gc_event, 2); + lua_rawset(L, LUA_REGISTRYINDEX); + + tolua_newmetatable(L,"tolua_commonclass"); + + tolua_module(L,NULL,0); + tolua_beginmodule(L,NULL); + tolua_module(L,"tolua",0); + tolua_beginmodule(L,"tolua"); + tolua_function(L,"type",tolua_bnd_type); + tolua_function(L,"takeownership",tolua_bnd_takeownership); + tolua_function(L,"releaseownership",tolua_bnd_releaseownership); + tolua_function(L,"cast",tolua_bnd_cast); + tolua_function(L,"inherit", tolua_bnd_inherit); + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + tolua_function(L, "setpeer", tolua_bnd_setpeer); + tolua_function(L, "getpeer", tolua_bnd_getpeer); + #endif + + tolua_endmodule(L); + tolua_endmodule(L); + } + lua_settop(L,top); +} + +/* Copy a C object +*/ +TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size) +{ + void* clone = (void*)malloc(size); + if (clone) + memcpy(clone,value,size); + else + tolua_error(L,"insuficient memory",NULL); + return clone; +} + +/* Default collect function +*/ +TOLUA_API int tolua_default_collect (lua_State* tolua_S) +{ + void* self = tolua_tousertype(tolua_S,1,0); + free(self); + return 0; +} + +/* Do clone +*/ +TOLUA_API int tolua_register_gc (lua_State* L, int lo) +{ + int success = 1; + void *value = *(void **)lua_touserdata(L,lo); + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,value); + lua_rawget(L,-2); + if (!lua_isnil(L,-1)) /* make sure that object is not already owned */ + success = 0; + else + { + lua_pushlightuserdata(L,value); + lua_getmetatable(L,lo); + lua_rawset(L,-4); + } + lua_pop(L,2); + return success; +} + +/* Register a usertype + * It creates the correspoding metatable in the registry, for both 'type' and 'const type'. + * It maps 'const type' as being also a 'type' +*/ +TOLUA_API void tolua_usertype (lua_State* L, const char* type) +{ + char ctype[128] = "const "; + strncat(ctype,type,120); + + /* create both metatables */ + if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type)) + mapsuper(L,type,ctype); /* 'type' is also a 'const type' */ +} + + +/* Begin module + * It pushes the module (or class) table on the stack +*/ +TOLUA_API void tolua_beginmodule (lua_State* L, const char* name) +{ + if (name) + { + lua_pushstring(L,name); + lua_rawget(L,-2); + } + else + lua_pushvalue(L,LUA_GLOBALSINDEX); +} + +/* End module + * It pops the module (or class) from the stack +*/ +TOLUA_API void tolua_endmodule (lua_State* L) +{ + lua_pop(L,1); +} + +/* Map module + * It creates a new module +*/ +#if 1 +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) +{ + if (name) + { + /* tolua module */ + lua_pushstring(L,name); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) /* check if module already exists */ + { + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,name); + lua_pushvalue(L,-2); + lua_rawset(L,-4); /* assing module into module */ + } + } + else + { + /* global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + } + if (hasvar) + { + if (!tolua_ismodulemetatable(L)) /* check if it already has a module metatable */ + { + /* create metatable to get/set C/C++ variable */ + lua_newtable(L); + tolua_moduleevents(L); + if (lua_getmetatable(L,-2)) + lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ + lua_setmetatable(L,-2); + } + } + lua_pop(L,1); /* pop module */ +} +#else +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) +{ + if (name) + { + /* tolua module */ + lua_pushstring(L,name); + lua_newtable(L); + } + else + { + /* global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + } + if (hasvar) + { + /* create metatable to get/set C/C++ variable */ + lua_newtable(L); + tolua_moduleevents(L); + if (lua_getmetatable(L,-2)) + lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ + lua_setmetatable(L,-2); + } + if (name) + lua_rawset(L,-3); /* assing module into module */ + else + lua_pop(L,1); /* pop global table */ +} +#endif + +static void push_collector(lua_State* L, const char* type, lua_CFunction col) { + + /* push collector function, but only if it's not NULL, or if there's no + collector already */ + if (!col) return; + luaL_getmetatable(L,type); + lua_pushstring(L,".collector"); + /* + if (!col) { + lua_pushvalue(L, -1); + lua_rawget(L, -3); + if (!lua_isnil(L, -1)) { + lua_pop(L, 3); + return; + }; + lua_pop(L, 1); + }; + // */ + lua_pushcfunction(L,col); + + lua_rawset(L,-3); + lua_pop(L, 1); +}; + +/* Map C class + * It maps a C class, setting the appropriate inheritance and super classes. +*/ +TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col) +{ + char cname[128] = "const "; + char cbase[128] = "const "; + strncat(cname,name,120); + strncat(cbase,base,120); + + mapinheritance(L,name,base); + mapinheritance(L,cname,name); + + mapsuper(L,cname,cbase); + mapsuper(L,name,base); + + lua_pushstring(L,lname); + + push_collector(L, name, col); + /* + luaL_getmetatable(L,name); + lua_pushstring(L,".collector"); + lua_pushcfunction(L,col); + + lua_rawset(L,-3); + */ + + luaL_getmetatable(L,name); + lua_rawset(L,-3); /* assign class metatable to module */ + + /* now we also need to store the collector table for the const + instances of the class */ + push_collector(L, cname, col); + /* + luaL_getmetatable(L,cname); + lua_pushstring(L,".collector"); + lua_pushcfunction(L,col); + lua_rawset(L,-3); + lua_pop(L,1); + */ + + +} + +/* Add base + * It adds additional base classes to a class (for multiple inheritance) + * (not for now) +TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) { + + char cname[128] = "const "; + char cbase[128] = "const "; + strncat(cname,name,120); + strncat(cbase,base,120); + + mapsuper(L,cname,cbase); + mapsuper(L,name,base); +}; +*/ + +/* Map function + * It assigns a function into the current module (or class) +*/ +TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func) +{ + lua_pushstring(L,name); + lua_pushcfunction(L,func); + lua_rawset(L,-3); +} + +/* sets the __call event for the class (expects the class' main table on top) */ +/* never really worked :( +TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) { + + lua_getmetatable(L, -1); + //luaL_getmetatable(L, type); + lua_pushstring(L,"__call"); + lua_pushcfunction(L,func); + lua_rawset(L,-3); + lua_pop(L, 1); +}; +*/ + +/* Map constant number + * It assigns a constant number into the current module (or class) +*/ +TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value) +{ + lua_pushstring(L,name); + tolua_pushnumber(L,value); + lua_rawset(L,-3); +} + + +/* Map variable + * It assigns a variable into the current module (or class) +*/ +TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) +{ + /* get func */ + lua_pushstring(L,".get"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .get table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".get"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + lua_pushcfunction(L,get); + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .get table */ + + /* set func */ + if (set) + { + lua_pushstring(L,".set"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .set table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".set"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + lua_pushcfunction(L,set); + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .set table */ + } +} + +/* Access const array + * It reports an error when trying to write into a const array +*/ +static int const_array (lua_State* L) +{ + luaL_error(L,"value of const array cannot be changed"); + return 0; +} + +/* Map an array + * It assigns an array into the current module (or class) +*/ +TOLUA_API void tolua_array (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) +{ + lua_pushstring(L,".get"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .get table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".get"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + + lua_newtable(L); /* create array metatable */ + lua_pushvalue(L,-1); + lua_setmetatable(L,-2); /* set the own table as metatable (for modules) */ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,get); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,set?set:const_array); + lua_rawset(L,-3); + + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .get table */ +} + + +TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) { + + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0); + #else + lua_dobuffer(L, B, size, name); + #endif +}; + diff --git a/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_push.c b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_push.c new file mode 100644 index 000000000..639414755 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_push.c @@ -0,0 +1,171 @@ +/* tolua: functions to push C values. +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "lauxlib.h" + +#include + +TOLUA_API void tolua_pushvalue (lua_State* L, int lo) +{ + lua_pushvalue(L,lo); +} + +TOLUA_API void tolua_pushboolean (lua_State* L, int value) +{ + lua_pushboolean(L,value); +} + +TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value) +{ + lua_pushnumber(L,value); +} + +TOLUA_API void tolua_pushstring (lua_State* L, const char* value) +{ + if (value == NULL) + lua_pushnil(L); + else + lua_pushstring(L,value); +} + +TOLUA_API void tolua_pushuserdata (lua_State* L, void* value) +{ + if (value == NULL) + lua_pushnil(L); + else + lua_pushlightuserdata(L,value); +} + +TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type) +{ + if (value == NULL) + lua_pushnil(L); + else + { + luaL_getmetatable(L, type); + lua_pushstring(L,"tolua_ubox"); + lua_rawget(L,-2); /* stack: mt ubox */ + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L, LUA_REGISTRYINDEX); + }; + lua_pushlightuserdata(L,value); + lua_rawget(L,-2); /* stack: mt ubox ubox[u] */ + if (lua_isnil(L,-1)) + { + lua_pop(L,1); /* stack: mt ubox */ + lua_pushlightuserdata(L,value); + *(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox u newud */ + lua_pushvalue(L,-1); /* stack: mt ubox u newud newud */ + lua_insert(L,-4); /* stack: mt newud ubox u newud */ + lua_rawset(L,-3); /* stack: mt newud ubox */ + lua_pop(L,1); /* stack: mt newud */ + /*luaL_getmetatable(L,type);*/ + lua_pushvalue(L, -2); /* stack: mt newud mt */ + lua_setmetatable(L,-2); /* stack: mt newud */ + + #ifdef LUA_VERSION_NUM + lua_pushvalue(L, TOLUA_NOPEER); + lua_setfenv(L, -2); + #endif + } + else + { + /* check the need of updating the metatable to a more specialized class */ + lua_insert(L,-2); /* stack: mt ubox[u] ubox */ + lua_pop(L,1); /* stack: mt ubox[u] */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */ + lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */ + if (lua_istable(L,-1)) + { + lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */ + if (lua_toboolean(L,-1) == 1) /* if true */ + { + lua_pop(L,3); /* mt ubox[u]*/ + lua_remove(L, -2); + return; + } + } + /* type represents a more specilized type */ + /*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */ + lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */ + lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */ + lua_pop(L,3); /* stack: mt ubox[u] */ + } + lua_remove(L, -2); /* stack: ubox[u]*/ + } +} + +TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type) +{ + tolua_pushusertype(L,value,type); + tolua_register_gc(L,lua_gettop(L)); +} + +TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v) +{ + lua_pushnumber(L,index); + lua_pushvalue(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v) +{ + lua_pushnumber(L,index); + lua_pushboolean(L,v); + lua_settable(L,lo); +} + + +TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v) +{ + lua_pushnumber(L,index); + tolua_pushnumber(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v) +{ + lua_pushnumber(L,index); + tolua_pushstring(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v) +{ + lua_pushnumber(L,index); + tolua_pushuserdata(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type) +{ + lua_pushnumber(L,index); + tolua_pushusertype(L,v,type); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type) +{ + lua_pushnumber(L,index); + tolua_pushusertype(L,v,type); + tolua_register_gc(L,lua_gettop(L)); + lua_settable(L,lo); +} + diff --git a/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_to.c b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_to.c new file mode 100644 index 000000000..542ca67d1 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/simple_build/lib/tolua_to.c @@ -0,0 +1,133 @@ +/* tolua: funcitons to convert to C types +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" + +#include +#include + +TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def) +{ + return lua_gettop(L)'..self.name..'[tolua_index]' + else + return self.name..'[tolua_index]' + end +end + +-- Write binding functions +function classArray:supcode () + local class = self:inclass() + + -- get function ------------------------------------------------ + if class then + output("/* get function:",self.name," of class ",class," */") + else + output("/* get function:",self.name," */") + end + self.cgetname = self:cfuncname("tolua_get") + output("#ifndef TOLUA_DISABLE_"..self.cgetname) + output("\nstatic int",self.cgetname,"(lua_State* tolua_S)") + output("{") + output(" int tolua_index;") + + -- declare self, if the case + local _,_,static = strfind(self.mod,'^%s*(static)') + if class and static==nil then + output(' ',self.parent.type,'*','self;') + output(' lua_pushstring(tolua_S,".self");') + output(' lua_rawget(tolua_S,1);') + output(' self = ') + output('(',self.parent.type,'*) ') + output('lua_touserdata(tolua_S,-1);') + elseif static then + _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') + end + + -- check index + output('#ifndef TOLUA_RELEASE\n') + output(' {') + output(' tolua_Error tolua_err;') + output(' if (!tolua_isnumber(tolua_S,2,0,&tolua_err))') + output(' tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);') + output(' }') + output('#endif\n') + if flags['1'] then -- for compatibility with tolua5 ? + output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;') + else + output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);') + end + output('#ifndef TOLUA_RELEASE\n') + if self.dim and self.dim ~= '' then + output(' if (tolua_index<0 || tolua_index>='..self.dim..')') + else + output(' if (tolua_index<0)') + end + output(' tolua_error(tolua_S,"array indexing out of range.",NULL);') + output('#endif\n') + + -- return value + local t,ct = isbasic(self.type) + local push_func = get_push_function(t) + if t then + output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');') + else + t = self.type + if self.ptr == '&' or self.ptr == '' then + output(' ',push_func,'(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");') + else + output(' ',push_func,'(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");') + end + end + output(' return 1;') + output('}') + output('#endif //#ifndef TOLUA_DISABLE\n') + output('\n') + + -- set function ------------------------------------------------ + if not strfind(self.type,'const') then + if class then + output("/* set function:",self.name," of class ",class," */") + else + output("/* set function:",self.name," */") + end + self.csetname = self:cfuncname("tolua_set") + output("#ifndef TOLUA_DISABLE_"..self.csetname) + output("\nstatic int",self.csetname,"(lua_State* tolua_S)") + output("{") + + -- declare index + output(' int tolua_index;') + + -- declare self, if the case + local _,_,static = strfind(self.mod,'^%s*(static)') + if class and static==nil then + output(' ',self.parent.type,'*','self;') + output(' lua_pushstring(tolua_S,".self");') + output(' lua_rawget(tolua_S,1);') + output(' self = ') + output('(',self.parent.type,'*) ') + output('lua_touserdata(tolua_S,-1);') + elseif static then + _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') + end + + -- check index + output('#ifndef TOLUA_RELEASE\n') + output(' {') + output(' tolua_Error tolua_err;') + output(' if (!tolua_isnumber(tolua_S,2,0,&tolua_err))') + output(' tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);') + output(' }') + output('#endif\n') + + if flags['1'] then -- for compatibility with tolua5 ? + output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;') + else + output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);') + end + + output('#ifndef TOLUA_RELEASE\n') + if self.dim and self.dim ~= '' then + output(' if (tolua_index<0 || tolua_index>='..self.dim..')') + else + output(' if (tolua_index<0)') + end + output(' tolua_error(tolua_S,"array indexing out of range.",NULL);') + output('#endif\n') + + -- assign value + local ptr = '' + if self.ptr~='' then ptr = '*' end + output(' ') + if class and static then + output(class..'::'..self.name..'[tolua_index]') + elseif class then + output('self->'..self.name..'[tolua_index]') + else + output(self.name..'[tolua_index]') + end + local t = isbasic(self.type) + output(' = ') + if not t and ptr=='' then output('*') end + output('((',self.mod,self.type) + if not t then + output('*') + end + output(') ') + local def = 0 + if self.def ~= '' then def = self.def end + if t then + output('tolua_to'..t,'(tolua_S,3,',def,'));') + else + local to_func = get_to_function(self.type) + output(to_func,'(tolua_S,3,',def,'));') + end + output(' return 0;') + output('}') + output('#endif //#ifndef TOLUA_DISABLE\n') + output('\n') + end + +end + +function classArray:register (pre) + if not self:check_public_access() then + return + end + + pre = pre or '' + if self.csetname then + output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');') + else + output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);') + end +end + +-- Internal constructor +function _Array (t) + setmetatable(t,classArray) + append(t) + return t +end + +-- Constructor +-- Expects a string representing the variable declaration. +function Array (s) + return _Array (Declaration(s,'var')) +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/basic.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/basic.lua new file mode 100644 index 000000000..f651f1fe6 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/basic.lua @@ -0,0 +1,414 @@ +-- tolua: basic utility functions +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- Last update: Apr 2003 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Basic C types and their corresponding Lua types +-- All occurrences of "char*" will be replaced by "_cstring", +-- and all occurrences of "void*" will be replaced by "_userdata" +_basic = { + ['void'] = '', + ['char'] = 'number', + ['int'] = 'number', + ['short'] = 'number', + ['long'] = 'number', + ['unsigned'] = 'number', + ['float'] = 'number', + ['double'] = 'number', + ['_cstring'] = 'string', + ['_userdata'] = 'userdata', + ['char*'] = 'string', + ['void*'] = 'userdata', + ['bool'] = 'boolean', + ['lua_Object'] = 'value', + ['LUA_VALUE'] = 'value', -- for compatibility with tolua 4.0 + ['lua_State*'] = 'state', + ['_lstate'] = 'state', + ['lua_Function'] = 'value', +} + +_basic_ctype = { + number = "lua_Number", + string = "const char*", + userdata = "void*", + boolean = "bool", + value = "int", + state = "lua_State*", +} + +-- functions the are used to do a 'raw push' of basic types +_basic_raw_push = {} + +-- List of user defined types +-- Each type corresponds to a variable name that stores its tag value. +_usertype = {} + +-- List of types that have to be collected +_collect = {} + +-- List of types +_global_types = {n=0} +_global_types_hash = {} + +-- list of classes +_global_classes = {} + +-- List of enum constants +_global_enums = {} + +-- List of auto renaming +_renaming = {} +function appendrenaming (s) + local b,e,old,new = strfind(s,"%s*(.-)%s*@%s*(.-)%s*$") + if not b then + error("#Invalid renaming syntax; it should be of the form: pattern@pattern") + end + tinsert(_renaming,{old=old, new=new}) +end + +function applyrenaming (s) + for i=1,getn(_renaming) do + local m,n = gsub(s,_renaming[i].old,_renaming[i].new) + if n ~= 0 then + return m + end + end + return nil +end + +-- Error handler +function tolua_error (s,f) +if _curr_code then + print("***curr code for error is "..tostring(_curr_code)) + print(debug.traceback()) +end + local out = _OUTPUT + _OUTPUT = _STDERR + if strsub(s,1,1) == '#' then + write("\n** tolua: "..strsub(s,2)..".\n\n") + if _curr_code then + local _,_,s = strfind(_curr_code,"^%s*(.-\n)") -- extract first line + if s==nil then s = _curr_code end + s = gsub(s,"_userdata","void*") -- return with 'void*' + s = gsub(s,"_cstring","char*") -- return with 'char*' + s = gsub(s,"_lstate","lua_State*") -- return with 'lua_State*' + write("Code being processed:\n"..s.."\n") + end + else + if not f then f = "(f is nil)" end + print("\n** tolua internal error: "..f..s..".\n\n") + return + end + _OUTPUT = out +end + +function warning (msg) + if flags.q then return end + local out = _OUTPUT + _OUTPUT = _STDERR + write("\n** tolua warning: "..msg..".\n\n") + _OUTPUT = out +end + +-- register an user defined type: returns full type +function regtype (t) + --if isbasic(t) then + -- return t + --end + local ft = findtype(t) + + if not _usertype[ft] then + return appendusertype(t) + end + return ft +end + +-- return type name: returns full type +function typevar(type) + if type == '' or type == 'void' then + return type + else + local ft = findtype(type) + if ft then + return ft + end + _usertype[type] = type + return type + end +end + +-- check if basic type +function isbasic (type) + local t = gsub(type,'const ','') + local m,t = applytypedef('', t) + local b = _basic[t] + if b then + return b,_basic_ctype[b] + end + return nil +end + +-- split string using a token +function split (s,t) + local l = {n=0} + local f = function (s) + l.n = l.n + 1 + l[l.n] = s + return "" + end + local p = "%s*(.-)%s*"..t.."%s*" + s = gsub(s,"^%s+","") + s = gsub(s,"%s+$","") + s = gsub(s,p,f) + l.n = l.n + 1 + l[l.n] = gsub(s,"(%s%s*)$","") + return l +end + +-- splits a string using a pattern, considering the spacial cases of C code (templates, function parameters, etc) +-- pattern can't contain the '^' (as used to identify the begining of the line) +-- also strips whitespace +function split_c_tokens(s, pat) + + s = string.gsub(s, "^%s*", "") + s = string.gsub(s, "%s*$", "") + + local token_begin = 1 + local token_end = 1 + local ofs = 1 + local ret = {n=0} + + function add_token(ofs) + + local t = string.sub(s, token_begin, ofs) + t = string.gsub(t, "^%s*", "") + t = string.gsub(t, "%s*$", "") + ret.n = ret.n + 1 + ret[ret.n] = t + end + + while ofs <= string.len(s) do + + local sub = string.sub(s, ofs, -1) + local b,e = string.find(sub, "^"..pat) + if b then + add_token(ofs-1) + ofs = ofs+e + token_begin = ofs + else + local char = string.sub(s, ofs, ofs) + if char == "(" or char == "<" then + + local block + if char == "(" then block = "^%b()" end + if char == "<" then block = "^%b<>" end + + b,e = string.find(sub, block) + if not b then + -- unterminated block? + ofs = ofs+1 + else + ofs = ofs + e + end + + else + ofs = ofs+1 + end + end + + end + add_token(ofs) + --if ret.n == 0 then + + -- ret.n=1 + -- ret[1] = "" + --end + + return ret + +end + +-- concatenate strings of a table +function concat (t,f,l,jstr) + jstr = jstr or " " + local s = '' + local i=f + while i<=l do + s = s..t[i] + i = i+1 + if i <= l then s = s..jstr end + end + return s +end + +-- concatenate all parameters, following output rules +function concatparam (line, ...) + local i=1 + while i<=arg.n do + if _cont and not strfind(_cont,'[%(,"]') and + strfind(arg[i],"^[%a_~]") then + line = line .. ' ' + end + line = line .. arg[i] + if arg[i] ~= '' then + _cont = strsub(arg[i],-1,-1) + end + i = i+1 + end + if strfind(arg[arg.n],"[%/%)%;%{%}]$") then + _cont=nil line = line .. '\n' + end + return line +end + +-- output line +function output (...) + local i=1 + while i<=arg.n do + if _cont and not strfind(_cont,'[%(,"]') and + strfind(arg[i],"^[%a_~]") then + write(' ') + end + write(arg[i]) + if arg[i] ~= '' then + _cont = strsub(arg[i],-1,-1) + end + i = i+1 + end + if strfind(arg[arg.n],"[%/%)%;%{%}]$") then + _cont=nil write('\n') + end +end + +function get_property_methods(ptype, name) + + if get_property_methods_hook and get_property_methods_hook(ptype,name) then + return get_property_methods_hook(ptype, name) + end + + if ptype == "default" then -- get_name, set_name + return "get_"..name, "set_"..name + end + + if ptype == "qt" then -- name, setName + return name, "set"..string.upper(string.sub(name, 1, 1))..string.sub(name, 2, -1) + end + + if ptype == "overload" then -- name, name + return name,name + end + + return nil +end + +-------------- the hooks + +-- called right after processing the $[ichl]file directives, +-- right before processing anything else +-- takes the package object as the parameter +function preprocess_hook(p) + -- p.code has all the input code from the pkg +end + + +-- called for every $ifile directive +-- takes a table with a string called 'code' inside, the filename, and any extra arguments +-- passed to $ifile. no return value +function include_file_hook(t, filename, ...) + +end + +-- called after processing anything that's not code (like '$renaming', comments, etc) +-- and right before parsing the actual code. +-- takes the Package object with all the code on the 'code' key. no return value +function preparse_hook(package) + +end + +-- called before starting output +function pre_output_hook(package) + +end + +-- called after writing all the output. +-- takes the Package object +function post_output_hook(package) + +end + + +-- called from 'get_property_methods' to get the methods to retrieve a property +-- according to its type +function get_property_methods_hook(property_type, name) + +end + +-- called from ClassContainer:doparse with the string being parsed +-- return nil, or a substring +function parser_hook(s) + + return nil +end + +-- called from classFunction:supcode, before the call to the function is output +function pre_call_hook(f) + +end + +-- called from classFunction:supcode, after the call to the function is output +function post_call_hook(f) + +end + +-- called before the register code is output +function pre_register_hook(package) + +end + +-- called to output an error message +function output_error_hook(...) + return string.format(...) +end + +-- custom pushers + +_push_functions = {} +_is_functions = {} +_to_functions = {} + +_base_push_functions = {} +_base_is_functions = {} +_base_to_functions = {} + +local function search_base(t, funcs) + + local class = _global_classes[t] + + while class do + if funcs[class.type] then + return funcs[class.type] + end + class = _global_classes[class.btype] + end + return nil +end + +function get_push_function(t) + return _push_functions[t] or search_base(t, _base_push_functions) or "tolua_pushusertype" +end + +function get_to_function(t) + return _to_functions[t] or search_base(t, _base_to_functions) or "tolua_tousertype" +end + +function get_is_function(t) + return _is_functions[t] or search_base(t, _base_is_functions) or "tolua_isusertype" +end diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/class.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/class.lua new file mode 100644 index 000000000..592705282 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/class.lua @@ -0,0 +1,202 @@ +-- tolua: class class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Class class +-- Represents a class definition. +-- Stores the following fields: +-- name = class name +-- base = class base, if any (only single inheritance is supported) +-- {i} = list of members +classClass = { + classtype = 'class', + name = '', + base = '', + type = '', + btype = '', + ctype = '', +} +classClass.__index = classClass +setmetatable(classClass,classContainer) + + +-- register class +function classClass:register (pre) + + if not self:check_public_access() then + return + end + + pre = pre or '' + push(self) + if _collect[self.type] then + output(pre,'#ifdef __cplusplus\n') + output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",'.._collect[self.type]..');') + output(pre,'#else\n') + output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);') + output(pre,'#endif\n') + else + output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);') + end + if self.extra_bases then + for k,base in ipairs(self.extra_bases) do + -- not now + --output(pre..' tolua_addbase(tolua_S, "'..self.type..'", "'..base..'");') + end + end + output(pre..'tolua_beginmodule(tolua_S,"'..self.lname..'");') + local i=1 + while self[i] do + self[i]:register(pre..' ') + i = i+1 + end + output(pre..'tolua_endmodule(tolua_S);') + pop() +end + +-- return collection requirement +function classClass:requirecollection (t) + if self.flags.protected_destructor or (not self:check_public_access()) then + return false + end + push(self) + local r = false + local i=1 + while self[i] do + r = self[i]:requirecollection(t) or r + i = i+1 + end + pop() + -- only class that exports destructor can be appropriately collected + -- classes that export constructors need to have a collector (overrided by -D flag on command line) + if self._delete or ((not flags['D']) and self._new) then + --t[self.type] = "tolua_collect_" .. gsub(self.type,"::","_") + t[self.type] = "tolua_collect_" .. clean_template(self.type) + r = true + end + return r +end + +-- output tags +function classClass:decltype () + push(self) + self.type = regtype(self.original_name or self.name) + self.btype = typevar(self.base) + self.ctype = 'const '..self.type + if self.extra_bases then + for i=1,table.getn(self.extra_bases) do + self.extra_bases[i] = typevar(self.extra_bases[i]) + end + end + local i=1 + while self[i] do + self[i]:decltype() + i = i+1 + end + pop() +end + + +-- Print method +function classClass:print (ident,close) + print(ident.."Class{") + print(ident.." name = '"..self.name.."',") + print(ident.." base = '"..self.base.."';") + print(ident.." lname = '"..self.lname.."',") + print(ident.." type = '"..self.type.."',") + print(ident.." btype = '"..self.btype.."',") + print(ident.." ctype = '"..self.ctype.."',") + local i=1 + while self[i] do + self[i]:print(ident.." ",",") + i = i+1 + end + print(ident.."}"..close) +end + +function classClass:set_protected_destructor(p) + self.flags.protected_destructor = self.flags.protected_destructor or p +end + +-- Internal constructor +function _Class (t) + setmetatable(t,classClass) + t:buildnames() + append(t) + return t +end + +-- Constructor +-- Expects the name, the base (array) and the body of the class. +function Class (n,p,b) + + if table.getn(p) > 1 then + b = string.sub(b, 1, -2) + for i=2,table.getn(p),1 do + b = b.."\n tolua_inherits "..p[i].." __"..p[i].."__;\n" + end + b = b.."\n}" + end + + -- check for template + b = string.gsub(b, "^{%s*TEMPLATE_BIND", "{\nTOLUA_TEMPLATE_BIND") + local t,_,T,I = string.find(b, '^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+') + if t then + + -- remove quotes + I = string.gsub(I, "\"", "") + T = string.gsub(T, "\"", "") + -- get type list + local types = split_c_tokens(I, ",") + -- remove TEMPLATE_BIND line + local bs = string.gsub(b, "^{%s*TOLUA_TEMPLATE_BIND[^\n]*\n", "{\n") + + local Tl = split(T, " ") + local tc = TemplateClass(n, p, bs, Tl) + + + tc:throw(types, true) + --for i=1,types.n do + -- tc:throw(split_c_tokens(types[i], " "), true) + --end + return + end + + local mbase + + if p then + mbase = table.remove(p, 1) + if not p[1] then p = nil end + end + + mbase = mbase and resolve_template_types(mbase) + + local c + local oname = string.gsub(n, "@.*$", "") + oname = getnamespace(classContainer.curr)..oname + + if _global_classes[oname] then + c = _global_classes[oname] + if mbase and ((not c.base) or c.base == "") then + c.base = mbase + end + else + c = _Class(_Container{name=n, base=mbase, extra_bases=p}) + + local ft = getnamespace(c.parent)..c.original_name + append_global_type(ft, c) + end + + push(c) + c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces + pop() +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/clean.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/clean.lua new file mode 100644 index 000000000..fd5b7b635 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/clean.lua @@ -0,0 +1,79 @@ +-- mark up comments and strings +STR1 = "\001" +STR2 = "\002" +STR3 = "\003" +STR4 = "\004" +REM = "\005" +ANY = "([\001-\005])" +ESC1 = "\006" +ESC2 = "\007" + +MASK = { -- the substitution order is important + {ESC1, "\\'"}, + {ESC2, '\\"'}, + {STR1, "'"}, + {STR2, '"'}, + {STR3, "%[%["}, + {STR4, "%]%]"}, + {REM , "%-%-"}, +} + +function mask (s) + for i = 1,getn(MASK) do + s = gsub(s,MASK[i][2],MASK[i][1]) + end + return s +end + +function unmask (s) + for i = 1,getn(MASK) do + s = gsub(s,MASK[i][1],MASK[i][2]) + end + return s +end + +function clean (s) + -- check for compilation error + local code = "return function ()\n" .. s .. "\n end" + if not dostring(code) then + return nil + end + + if flags['C'] then + return s + end + + local S = "" -- saved string + + s = mask(s) + + -- remove blanks and comments + while 1 do + local b,e,d = strfind(s,ANY) + if b then + S = S..strsub(s,1,b-1) + s = strsub(s,b+1) + if d==STR1 or d==STR2 then + e = strfind(s,d) + S = S ..d..strsub(s,1,e) + s = strsub(s,e+1) + elseif d==STR3 then + e = strfind(s,STR4) + S = S..d..strsub(s,1,e) + s = strsub(s,e+1) + elseif d==REM then + s = gsub(s,"[^\n]*(\n?)","%1",1) + end + else + S = S..s + break + end + end + -- eliminate unecessary spaces + S = gsub(S,"[ \t]+"," ") + S = gsub(S,"[ \t]*\n[ \t]*","\n") + S = gsub(S,"\n+","\n") + S = unmask(S) + return S +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/code.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/code.lua new file mode 100644 index 000000000..5e19b6bbf --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/code.lua @@ -0,0 +1,105 @@ +-- tolua: code class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1999 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + +-- global +code_n = 1 + +-- Code class +-- Represents Lua code to be compiled and included +-- in the initialization function. +-- The following fields are stored: +-- text = text code +classCode = { + text = '', +} +classCode.__index = classCode +setmetatable(classCode,classFeature) + +-- register code +function classCode:register (pre) + pre = pre or '' + -- clean Lua code + local s = clean(self.text) + if not s then + --print(self.text) + error("parser error in embedded code") + end + + -- get first line + local _, _, first_line=string.find(self.text, "^([^\n\r]*)") + if string.find(first_line, "^%s*%-%-") then + if string.find(first_line, "^%-%-##") then + first_line = string.gsub(first_line, "^%-%-##", "") + if flags['C'] then + s = string.gsub(s, "^%-%-##[^\n\r]*\n", "") + end + end + else + first_line = "" + end + + -- pad to 16 bytes + local npad = 16 - (#s % 16) + local spad = "" + for i=1,npad do + spad = spad .. "-" + end + s = s..spad + + -- convert to C + output('\n'..pre..'{ /* begin embedded lua code */\n') + output(pre..' int top = lua_gettop(tolua_S);') + output(pre..' static const unsigned char B[] = {\n ') + local t={n=0} + + local b = gsub(s,'(.)',function (c) + local e = '' + t.n=t.n+1 if t.n==15 then t.n=0 e='\n'..pre..' ' end + return format('%3u,%s',strbyte(c),e) + end + ) + output(b..strbyte(" ")) + output('\n'..pre..' };\n') + if first_line and first_line ~= "" then + output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: '..first_line..'");') + else + output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code '..code_n..'");') + end + output(pre..' lua_settop(tolua_S, top);') + output(pre..'} /* end of embedded lua code */\n\n') + code_n = code_n +1 +end + + +-- Print method +function classCode:print (ident,close) + print(ident.."Code{") + print(ident.." text = [["..self.text.."]],") + print(ident.."}"..close) +end + + +-- Internal constructor +function _Code (t) + setmetatable(t,classCode) + append(t) + return t +end + +-- Constructor +-- Expects a string representing the code text +function Code (l) + return _Code { + text = l + } +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/compat-5.1.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/compat-5.1.lua new file mode 100755 index 000000000..c2642d3a6 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/compat-5.1.lua @@ -0,0 +1,57 @@ +if string.find(_VERSION, "5%.0") then + return +end + +-- "loadfile" +local function pp_dofile(path) + + local loaded = false + local getfile = function() + + if loaded then + return + else + local file,err = io.open(path) + if not file then + error("error loading file "..path..": "..err) + end + local ret = file:read("*a") + file:close() + + ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};") + + loaded = true + return ret + end + end + + local f = load(getfile, path) + if not f then + + error("error loading file "..path) + end + return f() +end + +old_dofile = dofile +dofile = pp_dofile + + +-- string.gsub +--[[ +local ogsub = string.gsub +local function compgsub(a,b,c,d) + if type(c) == "function" then + local oc = c + c = function (...) return oc(...) or '' end + end + return ogsub(a,b,c,d) +end +string.repl = ogsub +--]] + +--string.gsub = compgsub + + + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/compat.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/compat.lua new file mode 100644 index 000000000..45d6ae1ba --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/compat.lua @@ -0,0 +1,193 @@ +------------------------------------------------------------------- +-- Real globals +-- _ALERT +-- _ERRORMESSAGE +-- _VERSION +-- _G +-- assert +-- error +-- metatable +-- next +-- print +-- require +-- tonumber +-- tostring +-- type +-- unpack + +------------------------------------------------------------------- +-- collectgarbage +-- gcinfo + +-- globals + +-- call -> protect(f, err) +-- loadfile +-- loadstring + +-- rawget +-- rawset + +-- getargs = Main.getargs ?? + +rawtype = type + +function do_ (f, err) + if not f then print(err); return end + local a,b = pcall(f) + if not a then print(b); return nil + else return b or true + end +end + +function dostring(s) return do_(loadstring(s)) end +-- function dofile(s) return do_(loadfile(s)) end + +------------------------------------------------------------------- +-- Table library +local tab = table +foreach = tab.foreach +foreachi = tab.foreachi +getn = tab.getn +tinsert = tab.insert +tremove = tab.remove +sort = tab.sort + +------------------------------------------------------------------- +-- Debug library +local dbg = debug +getinfo = dbg.getinfo +getlocal = dbg.getlocal +setcallhook = function () error"`setcallhook' is deprecated" end +setlinehook = function () error"`setlinehook' is deprecated" end +setlocal = dbg.setlocal + +------------------------------------------------------------------- +-- math library +local math = math +abs = math.abs +acos = function (x) return math.deg(math.acos(x)) end +asin = function (x) return math.deg(math.asin(x)) end +atan = function (x) return math.deg(math.atan(x)) end +atan2 = function (x,y) return math.deg(math.atan2(x,y)) end +ceil = math.ceil +cos = function (x) return math.cos(math.rad(x)) end +deg = math.deg +exp = math.exp +floor = math.floor +frexp = math.frexp +ldexp = math.ldexp +log = math.log +log10 = math.log10 +max = math.max +min = math.min +mod = math.mod +PI = math.pi +--??? pow = math.pow +rad = math.rad +random = math.random +randomseed = math.randomseed +sin = function (x) return math.sin(math.rad(x)) end +sqrt = math.sqrt +tan = function (x) return math.tan(math.rad(x)) end + +------------------------------------------------------------------- +-- string library +local str = string +strbyte = str.byte +strchar = str.char +strfind = str.find +format = str.format +gsub = str.gsub +strlen = str.len +strlower = str.lower +strrep = str.rep +strsub = str.sub +strupper = str.upper + +------------------------------------------------------------------- +-- os library +clock = os.clock +date = os.date +difftime = os.difftime +execute = os.execute --? +exit = os.exit +getenv = os.getenv +remove = os.remove +rename = os.rename +setlocale = os.setlocale +time = os.time +tmpname = os.tmpname + +------------------------------------------------------------------- +-- compatibility only +getglobal = function (n) return _G[n] end +setglobal = function (n,v) _G[n] = v end + +------------------------------------------------------------------- + +local io, tab = io, table + +-- IO library (files) +_STDIN = io.stdin +_STDERR = io.stderr +_STDOUT = io.stdout +_INPUT = io.stdin +_OUTPUT = io.stdout +seek = io.stdin.seek -- sick ;-) +tmpfile = io.tmpfile +closefile = io.close +openfile = io.open + +function flush (f) + if f then f:flush() + else _OUTPUT:flush() + end +end + +function readfrom (name) + if name == nil then + local f, err, cod = io.close(_INPUT) + _INPUT = io.stdin + return f, err, cod + else + local f, err, cod = io.open(name, "r") + _INPUT = f or _INPUT + return f, err, cod + end +end + +function writeto (name) + if name == nil then + local f, err, cod = io.close(_OUTPUT) + _OUTPUT = io.stdout + return f, err, cod + else + local f, err, cod = io.open(name, "w") + _OUTPUT = f or _OUTPUT + return f, err, cod + end +end + +function appendto (name) + local f, err, cod = io.open(name, "a") + _OUTPUT = f or _OUTPUT + return f, err, cod +end + +function read (...) + local f = _INPUT + if rawtype(arg[1]) == 'userdata' then + f = tab.remove(arg, 1) + end + return f:read(unpack(arg)) +end + +function write (...) + local f = _OUTPUT + if rawtype(arg[1]) == 'userdata' then + f = tab.remove(arg, 1) + end + return f:write(unpack(arg)) +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/container.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/container.lua new file mode 100644 index 000000000..2d11db7df --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/container.lua @@ -0,0 +1,786 @@ +-- tolua: container abstract class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + +-- table to store namespaced typedefs/enums in global scope +global_typedefs = {} +global_enums = {} + +-- Container class +-- Represents a container of features to be bound +-- to lua. +classContainer = +{ + curr = nil, +} +classContainer.__index = classContainer +setmetatable(classContainer,classFeature) + +-- output tags +function classContainer:decltype () + push(self) + local i=1 + while self[i] do + self[i]:decltype() + i = i+1 + end + pop() +end + + +-- write support code +function classContainer:supcode () + + if not self:check_public_access() then + return + end + + push(self) + local i=1 + while self[i] do + if self[i]:check_public_access() then + self[i]:supcode() + end + i = i+1 + end + pop() +end + +function classContainer:hasvar () + local i=1 + while self[i] do + if self[i]:isvariable() then + return 1 + end + i = i+1 + end + return 0 +end + +-- Internal container constructor +function _Container (self) + setmetatable(self,classContainer) + self.n = 0 + self.typedefs = {tolua_n=0} + self.usertypes = {} + self.enums = {tolua_n=0} + self.lnames = {} + return self +end + +-- push container +function push (t) + t.prox = classContainer.curr + classContainer.curr = t +end + +-- pop container +function pop () +--print("name",classContainer.curr.name) +--foreach(classContainer.curr.usertypes,print) +--print("______________") + classContainer.curr = classContainer.curr.prox +end + +-- get current namespace +function getcurrnamespace () + return getnamespace(classContainer.curr) +end + +-- append to current container +function append (t) + return classContainer.curr:append(t) +end + +-- append typedef to current container +function appendtypedef (t) + return classContainer.curr:appendtypedef(t) +end + +-- append usertype to current container +function appendusertype (t) + return classContainer.curr:appendusertype(t) +end + +-- append enum to current container +function appendenum (t) + return classContainer.curr:appendenum(t) +end + +-- substitute typedef +function applytypedef (mod,type) + return classContainer.curr:applytypedef(mod,type) +end + +-- check if is type +function findtype (type) + local t = classContainer.curr:findtype(type) + return t +end + +-- check if is typedef +function istypedef (type) + return classContainer.curr:istypedef(type) +end + +-- get fulltype (with namespace) +function fulltype (t) + local curr = classContainer.curr + while curr do + if curr then + if curr.typedefs and curr.typedefs[t] then + return curr.typedefs[t] + elseif curr.usertypes and curr.usertypes[t] then + return curr.usertypes[t] + end + end + curr = curr.prox + end + return t +end + +-- checks if it requires collection +function classContainer:requirecollection (t) + push(self) + local i=1 + local r = false + while self[i] do + r = self[i]:requirecollection(t) or r + i = i+1 + end + pop() + return r +end + + +-- get namesapce +function getnamespace (curr) + local namespace = '' + while curr do + if curr and + ( curr.classtype == 'class' or curr.classtype == 'namespace') + then + namespace = (curr.original_name or curr.name) .. '::' .. namespace + --namespace = curr.name .. '::' .. namespace + end + curr = curr.prox + end + return namespace +end + +-- get namespace (only namespace) +function getonlynamespace () + local curr = classContainer.curr + local namespace = '' + while curr do + if curr.classtype == 'class' then + return namespace + elseif curr.classtype == 'namespace' then + namespace = curr.name .. '::' .. namespace + end + curr = curr.prox + end + return namespace +end + +-- check if is enum +function isenum (type) + return classContainer.curr:isenum(type) +end + +-- append feature to container +function classContainer:append (t) + self.n = self.n + 1 + self[self.n] = t + t.parent = self +end + +-- append typedef +function classContainer:appendtypedef (t) + local namespace = getnamespace(classContainer.curr) + self.typedefs.tolua_n = self.typedefs.tolua_n + 1 + self.typedefs[self.typedefs.tolua_n] = t + self.typedefs[t.utype] = namespace .. t.utype + global_typedefs[namespace..t.utype] = t + t.ftype = findtype(t.type) or t.type + --print("appending typedef "..t.utype.." as "..namespace..t.utype.." with ftype "..t.ftype) + append_global_type(namespace..t.utype) + if t.ftype and isenum(t.ftype) then + + global_enums[namespace..t.utype] = true + end +end + +-- append usertype: return full type +function classContainer:appendusertype (t) + local container + if t == (self.original_name or self.name) then + container = self.prox + else + container = self + end + local ft = getnamespace(container) .. t + container.usertypes[t] = ft + _usertype[ft] = ft + return ft +end + +-- append enum +function classContainer:appendenum (t) + local namespace = getnamespace(classContainer.curr) + self.enums.tolua_n = self.enums.tolua_n + 1 + self.enums[self.enums.tolua_n] = t + global_enums[namespace..t.name] = t +end + +-- determine lua function name overload +function classContainer:overload (lname) + if not self.lnames[lname] then + self.lnames[lname] = 0 + else + self.lnames[lname] = self.lnames[lname] + 1 + end + return format("%02d",self.lnames[lname]) +end + +-- applies typedef: returns the 'the facto' modifier and type +function classContainer:applytypedef (mod,type) + if global_typedefs[type] then + --print("found typedef "..global_typedefs[type].type) + local mod1, type1 = global_typedefs[type].mod, global_typedefs[type].ftype + local mod2, type2 = applytypedef(mod.." "..mod1, type1) + --return mod2 .. ' ' .. mod1, type2 + return mod2, type2 + end + do return mod,type end +end + +-- check if it is a typedef +function classContainer:istypedef (type) + local env = self + while env do + if env.typedefs then + local i=1 + while env.typedefs[i] do + if env.typedefs[i].utype == type then + return type + end + i = i+1 + end + end + env = env.parent + end + return nil +end + +function find_enum_var(var) + + if tonumber(var) then return var end + + local c = classContainer.curr + while c do + local ns = getnamespace(c) + for k,v in pairs(_global_enums) do + if match_type(var, v, ns) then + return v + end + end + if c.base and c.base ~= '' then + c = _global_classes[c:findtype(c.base)] + else + c = nil + end + end + + return var +end + +-- check if is a registered type: return full type or nil +function classContainer:findtype (t) + + t = string.gsub(t, "=.*", "") + if _basic[t] then + return t + end + + local _,_,em = string.find(t, "([&%*])%s*$") + t = string.gsub(t, "%s*([&%*])%s*$", "") + p = self + while p and type(p)=='table' do + local st = getnamespace(p) + + for i=_global_types.n,1,-1 do -- in reverse order + + if match_type(t, _global_types[i], st) then + return _global_types[i]..(em or "") + end + end + if p.base and p.base ~= '' and p.base ~= t then + --print("type is "..t..", p is "..p.base.." self.type is "..self.type.." self.name is "..self.name) + p = _global_classes[p:findtype(p.base)] + else + p = nil + end + end + + return nil +end + +function append_global_type(t, class) + _global_types.n = _global_types.n +1 + _global_types[_global_types.n] = t + _global_types_hash[t] = 1 + if class then append_class_type(t, class) end +end + +function append_class_type(t,class) + if _global_classes[t] then + class.flags = _global_classes[t].flags + class.lnames = _global_classes[t].lnames + if _global_classes[t].base and (_global_classes[t].base ~= '') then + class.base = _global_classes[t].base or class.base + end + end + _global_classes[t] = class + class.flags = class.flags or {} +end + +function match_type(childtype, regtype, st) +--print("findtype "..childtype..", "..regtype..", "..st) + local b,e = string.find(regtype, childtype, -string.len(childtype), true) + if b then + + if e == string.len(regtype) and + (b == 1 or (string.sub(regtype, b-1, b-1) == ':' and + string.sub(regtype, 1, b-1) == string.sub(st, 1, b-1))) then + return true + end + end + + return false +end + +function findtype_on_childs(self, t) + + local tchild + if self.classtype == 'class' or self.classtype == 'namespace' then + for k,v in ipairs(self) do + if v.classtype == 'class' or v.classtype == 'namespace' then + if v.typedefs and v.typedefs[t] then + return v.typedefs[t] + elseif v.usertypes and v.usertypes[t] then + return v.usertypes[t] + end + tchild = findtype_on_childs(v, t) + if tchild then return tchild end + end + end + end + return nil + +end + +function classContainer:isenum (type) + if global_enums[type] then + return type + else + return false + end + + local basetype = gsub(type,"^.*::","") + local env = self + while env do + if env.enums then + local i=1 + while env.enums[i] do + if env.enums[i].name == basetype then + return true + end + i = i+1 + end + end + env = env.parent + end + return false +end + +methodisvirtual = false -- a global + +-- parse chunk +function classContainer:doparse (s) +--print ("parse "..s) + + -- try the parser hook + do + local sub = parser_hook(s) + if sub then + return sub + end + end + + -- try the null statement + do + local b,e,code = string.find(s, "^%s*;") + if b then + return strsub(s,e+1) + end + end + + -- try empty verbatim line + do + local b,e,code = string.find(s, "^%s*$\n") + if b then + return strsub(s,e+1) + end + end + + -- try Lua code + do + local b,e,code = strfind(s,"^%s*(%b\1\2)") + if b then + Code(strsub(code,2,-2)) + return strsub(s,e+1) + end + end + + -- try C code + do + local b,e,code = strfind(s,"^%s*(%b\3\4)") + if b then + code = '{'..strsub(code,2,-2)..'\n}\n' + Verbatim(code,'r') -- verbatim code for 'r'egister fragment + return strsub(s,e+1) + end + end + + -- try C code for preamble section + do + local b,e,code = string.find(s, "^%s*(%b\5\6)") + if b then + code = string.sub(code, 2, -2).."\n" + Verbatim(code, '') + return string.sub(s, e+1) + end + end + + -- try default_property directive + do + local b,e,ptype = strfind(s, "^%s*TOLUA_PROPERTY_TYPE%s*%(+%s*([^%)%s]*)%s*%)+%s*;?") + if b then + if not ptype or ptype == "" then + ptype = "default" + end + self:set_property_type(ptype) + return strsub(s, e+1) + end + end + + -- try protected_destructor directive + do + local b,e = string.find(s, "^%s*TOLUA_PROTECTED_DESTRUCTOR%s*;?") + if b then + if self.set_protected_destructor then + self:set_protected_destructor(true) + end + return strsub(s, e+1) + end + end + + -- try 'extern' keyword + do + local b,e = string.find(s, "^%s*extern%s+") + if b then + -- do nothing + return strsub(s, e+1) + end + end + + -- try 'virtual' keyworkd + do + local b,e = string.find(s, "^%s*virtual%s+") + if b then + methodisvirtual = true + return strsub(s, e+1) + end + end + + -- try labels (public, private, etc) + do + local b,e = string.find(s, "^%s*%w*%s*:[^:]") + if b then + return strsub(s, e) -- preserve the [^:] + end + end + + -- try module + do + local b,e,name,body = strfind(s,"^%s*module%s%s*([_%w][_%w]*)%s*(%b{})%s*") + if b then + _curr_code = strsub(s,b,e) + Module(name,body) + return strsub(s,e+1) + end + end + + -- try namesapce + do + local b,e,name,body = strfind(s,"^%s*namespace%s%s*([_%w][_%w]*)%s*(%b{})%s*;?") + if b then + _curr_code = strsub(s,b,e) + Namespace(name,body) + return strsub(s,e+1) + end + end + + -- try define + do + local b,e,name = strfind(s,"^%s*#define%s%s*([^%s]*)[^\n]*\n%s*") + if b then + _curr_code = strsub(s,b,e) + Define(name) + return strsub(s,e+1) + end + end + + -- try enumerates + + do + local b,e,name,body,varname = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*([^%s;]*)%s*;?%s*") + if b then + --error("#Sorry, declaration of enums and variables on the same statement is not supported.\nDeclare your variable separately (example: '"..name.." "..varname..";')") + _curr_code = strsub(s,b,e) + Enumerate(name,body,varname) + return strsub(s,e+1) + end + end + +-- do +-- local b,e,name,body = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*;?%s*") +-- if b then +-- _curr_code = strsub(s,b,e) +-- Enumerate(name,body) +-- return strsub(s,e+1) +-- end +-- end + + do + local b,e,body,name = strfind(s,"^%s*typedef%s+enum[^{]*(%b{})%s*([%w_][^%s]*)%s*;%s*") + if b then + _curr_code = strsub(s,b,e) + Enumerate(name,body) + return strsub(s,e+1) + end + end + + -- try operator + do + local b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)%s*;%s*") + if not b then + -- try inline + b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)[%s\n]*%b{}%s*;?%s*") + end + if not b then + -- try cast operator + b,e,decl,kind,arg,const = strfind(s, "^%s*(operator)%s+([%w_:%d<>%*%&%s]+)%s*(%b())%s*(c?o?n?s?t?)"); + if b then + local _,ie = string.find(s, "^%s*%b{}", e+1) + if ie then + e = ie + end + end + end + if b then + _curr_code = strsub(s,b,e) + Operator(decl,kind,arg,const) + return strsub(s,e+1) + end + end + + -- try function + do + --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w])%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*") + local b,e,decl,arg,const,virt = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)%s*(=?%s*0?)%s*;%s*") + if not b then + -- try function with template + b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w]%b<>)%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*") + end + if not b then + -- try a single letter function name + b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*;%s*") + end + if not b then + -- try function pointer + b,e,decl,arg,const = strfind(s,"^%s*([^%(;\n]+%b())%s*(%b())%s*;%s*") + if b then + decl = string.gsub(decl, "%(%s*%*([^%)]*)%s*%)", " %1 ") + end + end + if b then + if virt and string.find(virt, "[=0]") then + if self.flags then + self.flags.pure_virtual = true + end + end + _curr_code = strsub(s,b,e) + Function(decl,arg,const) + return strsub(s,e+1) + end + end + + -- try inline function + do + local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)[^;{]*%b{}%s*;?%s*") + --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w>])%s*(%b())%s*(c?o?n?s?t?)[^;]*%b{}%s*;?%s*") + if not b then + -- try a single letter function name + b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?).-%b{}%s*;?%s*") + end + if b then + _curr_code = strsub(s,b,e) + Function(decl,arg,const) + return strsub(s,e+1) + end + end + + -- try class + do + local b,e,name,base,body + base = '' body = '' + b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;") -- dummy class + local dummy = false + if not b then + b,e,name = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*;") -- dummy struct + if not b then + b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*([^{]-)%s*(%b{})%s*") + if not b then + b,e,name,base,body = strfind(s,"^%s*struct%s+([_%w][_%w@]*)%s*([^{]-)%s*(%b{})%s*") + if not b then + b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*([^{]-)%s*(%b{})%s*") + if not b then + base = '' + b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;") + end + end + end + else dummy = 1 end + else dummy = 1 end + if b then + if base ~= '' then + base = string.gsub(base, "^%s*:%s*", "") + base = string.gsub(base, "%s*public%s*", "") + base = split(base, ",") + --local b,e + --b,e,base = strfind(base,".-([_%w][_%w<>,:]*)$") + else + base = {} + end + _curr_code = strsub(s,b,e) + Class(name,base,body) + if not dummy then + varb,vare,varname = string.find(s, "^%s*([_%w]+)%s*;", e+1) + if varb then + Variable(name.." "..varname) + e = vare + end + end + return strsub(s,e+1) + end + end + + -- try typedef + do + local b,e,types = strfind(s,"^%s*typedef%s%s*(.-)%s*;%s*") + if b then + _curr_code = strsub(s,b,e) + Typedef(types) + return strsub(s,e+1) + end + end + + -- try variable + do + local b,e,decl = strfind(s,"^%s*([_%w][_@%s%w%d%*&:<>,]*[_%w%d])%s*;%s*") + if b then + _curr_code = strsub(s,b,e) + + local list = split_c_tokens(decl, ",") + Variable(list[1]) + if list.n > 1 then + local _,_,type = strfind(list[1], "(.-)%s+([^%s]*)$"); + + local i =2; + while list[i] do + Variable(type.." "..list[i]) + i=i+1 + end + end + --Variable(decl) + return strsub(s,e+1) + end + end + + -- try string + do + local b,e,decl = strfind(s,"^%s*([_%w]?[_%s%w%d]-char%s+[_@%w%d]*%s*%[%s*%S+%s*%])%s*;%s*") + if b then + _curr_code = strsub(s,b,e) + Variable(decl) + return strsub(s,e+1) + end + end + + -- try array + do + local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:<>]*[]_%w%d])%s*;%s*") + if b then + _curr_code = strsub(s,b,e) + Array(decl) + return strsub(s,e+1) + end + end + + -- no matching + if gsub(s,"%s%s*","") ~= "" then + _curr_code = s + error("#parse error") + else + return "" + end + +end + +function classContainer:parse (s) + + --self.curr_member_access = nil + + while s ~= '' do + s = self:doparse(s) + methodisvirtual = false + end +end + + +-- property types + +function get_property_type() + + return classContainer.curr:get_property_type() +end + +function classContainer:set_property_type(ptype) + ptype = string.gsub(ptype, "^%s*", "") + ptype = string.gsub(ptype, "%s*$", "") + + self.property_type = ptype +end + +function classContainer:get_property_type() + return self.property_type or (self.parent and self.parent:get_property_type()) or "default" +end diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/custom.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/custom.lua new file mode 100644 index 000000000..293175ef9 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/custom.lua @@ -0,0 +1,45 @@ + +function extract_code(fn,s) + local code = "" + if fn then + code = '\n$#include "'..fn..'"\n' + end + s= "\n" .. s .. "\n" -- add blank lines as sentinels + local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n") + while e do + t = strlower(t) + if t == "bind_begin" then + _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e) + if not e then + tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file") + end + end + if t == "bind_class" or t == "bind_block" then + local b + _,e,c,b = string.find(s, "([^{]-)(%b{})", e) + c = c..'{\n'..extract_code(nil, b)..'\n};\n' + end + code = code .. c .. "\n" + _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e) + end + return code +end + +function preprocess_hook(p) +end + +function preparse_hook(p) +end + +function include_file_hook(p, filename) + do return end +--print("FILENAME is "..filename) + p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal") + p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "") + p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "") + p.code = string.gsub(p.code, "DECLSPEC", "") + p.code = string.gsub(p.code, "SDLCALL", "") + p.code = string.gsub(p.code, "DLLINTERFACE", "") + p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n") +--print("code is "..p.code) +end diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/declaration.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/declaration.lua new file mode 100644 index 000000000..73bbe910e --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/declaration.lua @@ -0,0 +1,579 @@ +-- tolua: declaration class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Declaration class +-- Represents variable, function, or argument declaration. +-- Stores the following fields: +-- mod = type modifiers +-- type = type +-- ptr = "*" or "&", if representing a pointer or a reference +-- name = name +-- dim = dimension, if a vector +-- def = default value, if any (only for arguments) +-- ret = "*" or "&", if value is to be returned (only for arguments) +classDeclaration = { + mod = '', + type = '', + ptr = '', + name = '', + dim = '', + ret = '', + def = '' +} +classDeclaration.__index = classDeclaration +setmetatable(classDeclaration,classFeature) + +-- Create an unique variable name +function create_varname () + if not _varnumber then _varnumber = 0 end + _varnumber = _varnumber + 1 + return "tolua_var_".._varnumber +end + +-- Check declaration name +-- It also identifies default values +function classDeclaration:checkname () + + if strsub(self.name,1,1) == '[' and not findtype(self.type) then + self.name = self.type..self.name + local m = split(self.mod,'%s%s*') + self.type = m[m.n] + self.mod = concat(m,1,m.n-1) + end + + local t = split(self.name,'=') + if t.n==2 then + self.name = t[1] + self.def = find_enum_var(t[t.n]) + end + + local b,e,d = strfind(self.name,"%[(.-)%]") + if b then + self.name = strsub(self.name,1,b-1) + self.dim = find_enum_var(d) + end + + + if self.type ~= '' and self.type ~= 'void' and self.name == '' then + self.name = create_varname() + elseif self.kind=='var' then + if self.type=='' and self.name~='' then + self.type = self.type..self.name + self.name = create_varname() + elseif findtype(self.name) then + if self.type=='' then self.type = self.name + else self.type = self.type..' '..self.name end + self.name = create_varname() + end + end + + -- adjust type of string + if self.type == 'char' and self.dim ~= '' then + self.type = 'char*' + end + + if self.kind and self.kind == 'var' then + self.name = string.gsub(self.name, ":.*$", "") -- ??? + end +end + +-- Check declaration type +-- Substitutes typedef's. +function classDeclaration:checktype () + + -- check if there is a pointer to basic type + local basic = isbasic(self.type) + if self.kind == 'func' and basic=='number' and string.find(self.ptr, "%*") then + self.type = '_userdata' + self.ptr = "" + end + if basic and self.ptr~='' then + self.ret = self.ptr + self.ptr = nil + if isbasic(self.type) == 'number' then + self.return_userdata = true + end + end + + -- check if there is array to be returned + if self.dim~='' and self.ret~='' then + error('#invalid parameter: cannot return an array of values') + end + -- restore 'void*' and 'string*' + if self.type == '_userdata' then self.type = 'void*' + elseif self.type == '_cstring' then self.type = 'char*' + elseif self.type == '_lstate' then self.type = 'lua_State*' + end + + -- resolve types inside the templates + if self.type then + self.type = resolve_template_types(self.type) + end + +-- +-- -- if returning value, automatically set default value +-- if self.ret ~= '' and self.def == '' then +-- self.def = '0' +-- end +-- + +end + +function resolve_template_types(type) + + if isbasic(type) then + return type + end + local b,_,m = string.find(type, "(%b<>)") + if b then + + m = split_c_tokens(string.sub(m, 2, -2), ",") + for i=1, table.getn(m) do + m[i] = string.gsub(m[i],"%s*([%*&])", "%1") + if not isbasic(m[i]) then + if not isenum(m[i]) then _, m[i] = applytypedef("", m[i]) end + m[i] = findtype(m[i]) or m[i] + m[i] = resolve_template_types(m[i]) + end + end + + local b,i + type,b,i = break_template(type) +--print("concat is ",concat(m, 1, m.n)) + local template_part = "<"..concat(m, 1, m.n, ",")..">" + type = rebuild_template(type, b, template_part) + type = string.gsub(type, ">>", "> >") + end + return type +end + +function break_template(s) + local b,e,timpl = string.find(s, "(%b<>)") + if timpl then + s = string.gsub(s, "%b<>", "") + return s, b, timpl + else + return s, 0, nil + end +end + +function rebuild_template(s, b, timpl) + + if b == 0 then + return s + end + + return string.sub(s, 1, b-1)..timpl..string.sub(s, b, -1) +end + +-- Print method +function classDeclaration:print (ident,close) + print(ident.."Declaration{") + print(ident.." mod = '"..self.mod.."',") + print(ident.." type = '"..self.type.."',") + print(ident.." ptr = '"..self.ptr.."',") + print(ident.." name = '"..self.name.."',") + print(ident.." dim = '"..self.dim.."',") + print(ident.." def = '"..self.def.."',") + print(ident.." ret = '"..self.ret.."',") + print(ident.."}"..close) +end + +-- check if array of values are returned to Lua +function classDeclaration:requirecollection (t) + if self.mod ~= 'const' and + self.dim and self.dim ~= '' and + not isbasic(self.type) and + self.ptr == '' and self:check_public_access() then + local type = gsub(self.type,"%s*const%s+","") + t[type] = "tolua_collect_" .. clean_template(type) + return true + end + return false +end + +-- declare tag +function classDeclaration:decltype () + + self.type = typevar(self.type) + if strfind(self.mod,'const') then + self.type = 'const '..self.type + self.mod = gsub(self.mod,'const%s*','') + end +end + + +-- output type checking +function classDeclaration:outchecktype (narg) + local def + local t = isbasic(self.type) + if self.def~='' then + def = 1 + else + def = 0 + end + if self.dim ~= '' then + --if t=='string' then + -- return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)' + --else + return '!tolua_istable(tolua_S,'..narg..',0,&tolua_err)' + --end + elseif t then + return '!tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)' + else + local is_func = get_is_function(self.type) + if self.ptr == '&' or self.ptr == '' then + return '(tolua_isvaluenil(tolua_S,'..narg..',&tolua_err) || !'..is_func..'(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err))' + else + return '!'..is_func..'(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)' + end + end +end + +function classDeclaration:builddeclaration (narg, cplusplus) + local array = self.dim ~= '' and tonumber(self.dim)==nil + local line = "" + local ptr = '' + local mod + local type = self.type + local nctype = gsub(self.type,'const%s+','') + if self.dim ~= '' then + type = gsub(self.type,'const%s+','') -- eliminates const modifier for arrays + end + if self.ptr~='' and not isbasic(type) then ptr = '*' end + line = concatparam(line," ",self.mod,type,ptr) + if array then + line = concatparam(line,'*') + end + line = concatparam(line,self.name) + if self.dim ~= '' then + if tonumber(self.dim)~=nil then + line = concatparam(line,'[',self.dim,'];') + else + if cplusplus then + line = concatparam(line,' = Mtolua_new_dim(',type,ptr,', '..self.dim..');') + else + line = concatparam(line,' = (',type,ptr,'*)', + 'malloc((',self.dim,')*sizeof(',type,ptr,'));') + end + end + else + local t = isbasic(type) + line = concatparam(line,' = ') + if t == 'state' then + line = concatparam(line, 'tolua_S;') + else + --print("t is "..tostring(t)..", ptr is "..tostring(self.ptr)) + if t == 'number' and string.find(self.ptr, "%*") then + t = 'userdata' + end + if not t and ptr=='' then line = concatparam(line,'*') end + line = concatparam(line,'((',self.mod,type) + if not t then + line = concatparam(line,'*') + end + line = concatparam(line,') ') + if isenum(nctype) then + line = concatparam(line,'(int) ') + end + local def = 0 + if self.def ~= '' then + def = self.def + if (ptr == '' or self.ptr == '&') and not t then + def = "(void*)&(const "..type..")"..def + end + end + if t then + line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));') + else + local to_func = get_to_function(type) + line = concatparam(line,to_func..'(tolua_S,',narg,',',def,'));') + end + end + end + return line +end + +-- Declare variable +function classDeclaration:declare (narg) + if self.dim ~= '' and tonumber(self.dim)==nil then + output('#ifdef __cplusplus\n') + output(self:builddeclaration(narg,true)) + output('#else\n') + output(self:builddeclaration(narg,false)) + output('#endif\n') + else + output(self:builddeclaration(narg,false)) + end +end + +-- Get parameter value +function classDeclaration:getarray (narg) + if self.dim ~= '' then + local type = gsub(self.type,'const ','') + output(' {') + output('#ifndef TOLUA_RELEASE\n') + local def; if self.def~='' then def=1 else def=0 end + local t = isbasic(type) + if (t) then + output(' if (!tolua_is'..t..'array(tolua_S,',narg,',',self.dim,',',def,',&tolua_err))') + else + output(' if (!tolua_isusertypearray(tolua_S,',narg,',"',type,'",',self.dim,',',def,',&tolua_err))') + end + output(' goto tolua_lerror;') + output(' else\n') + output('#endif\n') + output(' {') + output(' int i;') + output(' for(i=0; i<'..self.dim..';i++)') + local t = isbasic(type) + local ptr = '' + if self.ptr~='' then ptr = '*' end + output(' ',self.name..'[i] = ') + if not t and ptr=='' then output('*') end + output('((',type) + if not t then + output('*') + end + output(') ') + local def = 0 + if self.def ~= '' then def = self.def end + if t then + output('tolua_tofield'..t..'(tolua_S,',narg,',i+1,',def,'));') + else + output('tolua_tofieldusertype(tolua_S,',narg,',i+1,',def,'));') + end + output(' }') + output(' }') + end +end + +-- Get parameter value +function classDeclaration:setarray (narg) + if not strfind(self.type,'const%s+') and self.dim ~= '' then + local type = gsub(self.type,'const ','') + output(' {') + output(' int i;') + output(' for(i=0; i<'..self.dim..';i++)') + local t,ct = isbasic(type) + if t then + output(' tolua_pushfield'..t..'(tolua_S,',narg,',i+1,(',ct,')',self.name,'[i]);') + else + if self.ptr == '' then + output(' {') + output('#ifdef __cplusplus\n') + output(' void* tolua_obj = Mtolua_new((',type,')(',self.name,'[i]));') + output(' tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");') + output('#else\n') + output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&',self.name,'[i],sizeof(',type,'));') + output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,tolua_obj,"',type,'");') + output('#endif\n') + output(' }') + else + output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,(void*)',self.name,'[i],"',type,'");') + end + end + output(' }') + end +end + +-- Free dynamically allocated array +function classDeclaration:freearray () + if self.dim ~= '' and tonumber(self.dim)==nil then + output('#ifdef __cplusplus\n') + output(' Mtolua_delete_dim(',self.name,');') + output('#else\n') + output(' free(',self.name,');') + output('#endif\n') + end +end + +-- Pass parameter +function classDeclaration:passpar () + if self.ptr=='&' and not isbasic(self.type) then + output('*'..self.name) + elseif self.ret=='*' then + output('&'..self.name) + else + output(self.name) + end +end + +-- Return parameter value +function classDeclaration:retvalue () + if self.ret ~= '' then + local t,ct = isbasic(self.type) + if t and t~='' then + output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');') + else + local push_func = get_push_function(self.type) + output(' ',push_func,'(tolua_S,(void*)'..self.name..',"',self.type,'");') + end + return 1 + end + return 0 +end + +-- Internal constructor +function _Declaration (t) + + setmetatable(t,classDeclaration) + t:buildnames() + t:checkname() + t:checktype() + local ft = findtype(t.type) or t.type + if not isenum(ft) then + t.mod, t.type = applytypedef(t.mod, ft) + end + + if t.kind=="var" and (string.find(t.mod, "tolua_property%s") or string.find(t.mod, "tolua_property$")) then + t.mod = string.gsub(t.mod, "tolua_property", "tolua_property__"..get_property_type()) + end + + return t +end + +-- Constructor +-- Expects the string declaration. +-- The kind of declaration can be "var" or "func". +function Declaration (s,kind,is_parameter) + + -- eliminate spaces if default value is provided + s = gsub(s,"%s*=%s*","=") + s = gsub(s, "%s*<", "<") + + local defb,tmpdef + defb,_,tmpdef = string.find(s, "(=.*)$") + if defb then + s = string.gsub(s, "=.*$", "") + else + tmpdef = '' + end + if kind == "var" then + -- check the form: void + if s == '' or s == 'void' then + return _Declaration{type = 'void', kind = kind, is_parameter = is_parameter} + end + end + + -- check the form: mod type*& name + local t = split_c_tokens(s,'%*%s*&') + if t.n == 2 then + if kind == 'func' then + error("#invalid function return type: "..s) + end + --local m = split(t[1],'%s%s*') + local m = split_c_tokens(t[1],'%s+') + return _Declaration{ + name = t[2]..tmpdef, + ptr = '*', + ret = '&', + --type = rebuild_template(m[m.n], tb, timpl), + type = m[m.n], + mod = concat(m,1,m.n-1), + is_parameter = is_parameter, + kind = kind + } + end + + -- check the form: mod type** name + t = split_c_tokens(s,'%*%s*%*') + if t.n == 2 then + if kind == 'func' then + error("#invalid function return type: "..s) + end + --local m = split(t[1],'%s%s*') + local m = split_c_tokens(t[1],'%s+') + return _Declaration{ + name = t[2]..tmpdef, + ptr = '*', + ret = '*', + --type = rebuild_template(m[m.n], tb, timpl), + type = m[m.n], + mod = concat(m,1,m.n-1), + is_parameter = is_parameter, + kind = kind + } + end + + -- check the form: mod type& name + t = split_c_tokens(s,'&') + if t.n == 2 then + --local m = split(t[1],'%s%s*') + local m = split_c_tokens(t[1],'%s+') + return _Declaration{ + name = t[2]..tmpdef, + ptr = '&', + --type = rebuild_template(m[m.n], tb, timpl), + type = m[m.n], + mod = concat(m,1,m.n-1), + is_parameter = is_parameter, + kind = kind + } + end + + -- check the form: mod type* name + local s1 = gsub(s,"(%b\[\])",function (n) return gsub(n,'%*','\1') end) + t = split_c_tokens(s1,'%*') + if t.n == 2 then + t[2] = gsub(t[2],'\1','%*') -- restore * in dimension expression + --local m = split(t[1],'%s%s*') + local m = split_c_tokens(t[1],'%s+') + return _Declaration{ + name = t[2]..tmpdef, + ptr = '*', + type = m[m.n], + --type = rebuild_template(m[m.n], tb, timpl), + mod = concat(m,1,m.n-1) , + is_parameter = is_parameter, + kind = kind + } + end + + if kind == 'var' then + -- check the form: mod type name + --t = split(s,'%s%s*') + t = split_c_tokens(s,'%s+') + local v + if findtype(t[t.n]) then v = create_varname() else v = t[t.n]; t.n = t.n-1 end + return _Declaration{ + name = v..tmpdef, + --type = rebuild_template(t[t.n], tb, timpl), + type = t[t.n], + mod = concat(t,1,t.n-1), + is_parameter = is_parameter, + kind = kind + } + + else -- kind == "func" + + -- check the form: mod type name + --t = split(s,'%s%s*') + t = split_c_tokens(s,'%s+') + local v = t[t.n] -- last word is the function name + local tp,md + if t.n>1 then + tp = t[t.n-1] + md = concat(t,1,t.n-2) + end + --if tp then tp = rebuild_template(tp, tb, timpl) end + return _Declaration{ + name = v, + type = tp, + mod = md, + is_parameter = is_parameter, + kind = kind + } + end + +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/define.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/define.lua new file mode 100644 index 000000000..96a28d878 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/define.lua @@ -0,0 +1,63 @@ +-- tolua: define class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: define.lua,v 1.2 1999/07/28 22:21:08 celes Exp $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Define class +-- Represents a numeric const definition +-- The following filds are stored: +-- name = constant name +classDefine = { + name = '', +} +classDefine.__index = classDefine +setmetatable(classDefine,classFeature) + +-- register define +function classDefine:register (pre) + if not self:check_public_access() then + return + end + + pre = pre or '' + output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');') +end + +-- Print method +function classDefine:print (ident,close) + print(ident.."Define{") + print(ident.." name = '"..self.name.."',") + print(ident.." lname = '"..self.lname.."',") + print(ident.."}"..close) +end + + +-- Internal constructor +function _Define (t) + setmetatable(t,classDefine) + t:buildnames() + + if t.name == '' then + error("#invalid define") + end + + append(t) + return t +end + +-- Constructor +-- Expects a string representing the constant name +function Define (n) + return _Define{ + name = n + } +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/doit.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/doit.lua new file mode 100644 index 000000000..4ddfc61fa --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/doit.lua @@ -0,0 +1,101 @@ +-- Generate binding code +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- Last update: Apr 2003 +-- $Id: $ + + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + +function parse_extra() + + for k,v in ipairs(_extra_parameters or {}) do + + local b,e,name,value = string.find(v, "^([^=]*)=(.*)$") + if b then + _extra_parameters[name] = value + else + _extra_parameters[v] = true + end + end +end + +function doit () + -- define package name, if not provided + if not flags.n then + if flags.f then + flags.n = gsub(flags.f,"%..*$","") + _,_,flags.n = string.find(flags.n, "([^/\\]*)$") + else + error("#no package name nor input file provided") + end + end + + -- parse table with extra paramters + parse_extra() + + -- do this after setting the package name + if flags['L'] then + dofile(flags['L']) + end + + -- add cppstring + if not flags['S'] then + _basic['string'] = 'cppstring' + _basic['std::string'] = 'cppstring' + _basic_ctype.cppstring = 'const char*' + end + + -- proccess package + local p = Package(flags.n,flags.f) + + if flags.p then + return -- only parse + end + + if flags.o then + local st,msg = writeto(flags.o) + if not st then + error('#'..msg) + end + end + + p:decltype() + if flags.P then + p:print() + else + push(p) + pre_output_hook(p) + pop() + p:preamble() + p:supcode() + push(p) + pre_register_hook(p) + pop() + p:register() + push(p) + post_output_hook(p) + pop() + end + + if flags.o then + writeto() + end + + -- write header file + if not flags.P then + if flags.H then + local st,msg = writeto(flags.H) + if not st then + error('#'..msg) + end + p:header() + writeto() + end + end +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/enumerate.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/enumerate.lua new file mode 100644 index 000000000..99fe74629 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/enumerate.lua @@ -0,0 +1,106 @@ +-- tolua: enumerate class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: enumerate.lua,v 1.3 2000/01/24 20:41:15 celes Exp $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Enumerate class +-- Represents enumeration +-- The following fields are stored: +-- {i} = list of constant names +classEnumerate = { +} +classEnumerate.__index = classEnumerate +setmetatable(classEnumerate,classFeature) + +-- register enumeration +function classEnumerate:register (pre) + if not self:check_public_access() then + return + end + pre = pre or '' + local nspace = getnamespace(classContainer.curr) + local i=1 + while self[i] do + if self.lnames[i] and self.lnames[i] ~= "" then + + output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');') + end + i = i+1 + end +end + +-- Print method +function classEnumerate:print (ident,close) + print(ident.."Enumerate{") + print(ident.." name = "..self.name) + local i=1 + while self[i] do + print(ident.." '"..self[i].."'("..self.lnames[i].."),") + i = i+1 + end + print(ident.."}"..close) +end + +-- Internal constructor +function _Enumerate (t,varname) + setmetatable(t,classEnumerate) + append(t) + appendenum(t) + if varname and varname ~= "" then + if t.name ~= "" then + Variable(t.name.." "..varname) + else + local ns = getcurrnamespace() + warning("Variable "..ns..varname.." of type is declared as read-only") + Variable("tolua_readonly int "..varname) + end + end + local parent = classContainer.curr + if parent then + t.access = parent.curr_member_access + t.global_access = t:check_public_access() + end +return t +end + +-- Constructor +-- Expects a string representing the enumerate body +function Enumerate (n,b,varname) + b = string.gsub(b, ",[%s\n]*}", "\n}") -- eliminate last ',' + local t = split(strsub(b,2,-2),',') -- eliminate braces + local i = 1 + local e = {n=0} + while t[i] do + local tt = split(t[i],'=') -- discard initial value + e.n = e.n + 1 + e[e.n] = tt[1] + i = i+1 + end + -- set lua names + i = 1 + e.lnames = {} + local ns = getcurrnamespace() + while e[i] do + local t = split(e[i],'@') + e[i] = t[1] + if not t[2] then + t[2] = applyrenaming(t[1]) + end + e.lnames[i] = t[2] or t[1] + _global_enums[ ns..e[i] ] = (ns..e[i]) + i = i+1 + end + e.name = n + if n ~= "" then + Typedef("int "..n) + end + return _Enumerate(e, varname) +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/feature.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/feature.lua new file mode 100644 index 000000000..042b5d28e --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/feature.lua @@ -0,0 +1,139 @@ +-- tolua: abstract feature class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Feature class +-- Represents the base class of all mapped feature. +classFeature = { +} +classFeature.__index = classFeature + +-- write support code +function classFeature:supcode () +end + +-- output tag +function classFeature:decltype () +end + +-- register feature +function classFeature:register (pre) +end + +-- translate verbatim +function classFeature:preamble () +end + +-- check if it is a variable +function classFeature:isvariable () + return false +end + +-- check if it requires collection +function classFeature:requirecollection (t) + return false +end + +-- build names +function classFeature:buildnames () + if self.name and self.name~='' then + local n = split(self.name,'@') + self.name = n[1] + self.name = string.gsub(self.name, ":%d*$", "") + if not n[2] then + n[2] = applyrenaming(n[1]) + end + self.lname = n[2] or gsub(n[1],"%[.-%]","") + self.lname = string.gsub(self.lname, ":%d*$", "") + self.original_name = self.name + self.lname = clean_template(self.lname) + end + if not self.is_parameter then + self.name = getonlynamespace() .. self.name + end + + local parent = classContainer.curr + if parent then + self.access = parent.curr_member_access + self.global_access = self:check_public_access() + else + end +end + +function classFeature:check_public_access() + + if type(self.global_access) == "boolean" then + return self.global_access + end + + if self.access and self.access ~= 0 then + return false + end + + local parent = classContainer.curr + while parent do + if parent.access and parent.access ~= 0 then + return false + end + parent = parent.prox + end + return true +end + +function clean_template(t) + + return string.gsub(t, "[<>:, %*]", "_") +end + +-- check if feature is inside a container definition +-- it returns the container class name or nil. +function classFeature:incontainer (which) + if self.parent then + local parent = self.parent + while parent do + if parent.classtype == which then + return parent.name + end + parent = parent.parent + end + end + return nil +end + +function classFeature:inclass () + return self:incontainer('class') +end + +function classFeature:inmodule () + return self:incontainer('module') +end + +function classFeature:innamespace () + return self:incontainer('namespace') +end + +-- return C binding function name based on name +-- the client specifies a prefix +function classFeature:cfuncname (n) + + if self.parent then + n = self.parent:cfuncname(n) + end + + local fname = self.lname + if not fname or fname == '' then + fname = self.name + end + n = string.gsub(n..'_'.. (fname), "[<>:, \.%*&]", "_") + + return n +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/function.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/function.lua new file mode 100644 index 000000000..2358e9ff7 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/function.lua @@ -0,0 +1,577 @@ +-- tolua: function class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + + +-- Function class +-- Represents a function or a class method. +-- The following fields are stored: +-- mod = type modifiers +-- type = type +-- ptr = "*" or "&", if representing a pointer or a reference +-- name = name +-- lname = lua name +-- args = list of argument declarations +-- const = if it is a method receiving a const "this". +classFunction = { + mod = '', + type = '', + ptr = '', + name = '', + args = {n=0}, + const = '', +} +classFunction.__index = classFunction +setmetatable(classFunction,classFeature) + +-- declare tags +function classFunction:decltype () + self.type = typevar(self.type) + if strfind(self.mod,'const') then + self.type = 'const '..self.type + self.mod = gsub(self.mod,'const','') + end + local i=1 + while self.args[i] do + self.args[i]:decltype() + i = i+1 + end +end + + +-- Write binding function +-- Outputs C/C++ binding function. +function classFunction:supcode (local_constructor) + + local overload = strsub(self.cname,-2,-1) - 1 -- indicate overloaded func + local nret = 0 -- number of returned values + local class = self:inclass() + local _,_,static = strfind(self.mod,'^%s*(static)') + if class then + + if self.name == 'new' and self.parent.flags.pure_virtual then + -- no constructor for classes with pure virtual methods + return + end + + if local_constructor then + output("/* method: new_local of class ",class," */") + else + output("/* method:",self.name," of class ",class," */") + end + else + output("/* function:",self.name," */") + end + + if local_constructor then + output("#ifndef TOLUA_DISABLE_"..self.cname.."_local") + output("\nstatic int",self.cname.."_local","(lua_State* tolua_S)") + else + output("#ifndef TOLUA_DISABLE_"..self.cname) + output("\nstatic int",self.cname,"(lua_State* tolua_S)") + end + output("{") + + -- check types + if overload < 0 then + output('#ifndef TOLUA_RELEASE\n') + end + output(' tolua_Error tolua_err;') + output(' if (\n') + -- check self + local narg + if class then narg=2 else narg=1 end + if class then + local func = get_is_function(self.parent.type) + local type = self.parent.type + if self.name=='new' or static~=nil then + func = 'tolua_isusertable' + type = self.parent.type + end + if self.const ~= '' then + type = "const "..type + end + output(' !'..func..'(tolua_S,1,"'..type..'",0,&tolua_err) ||\n') + end + -- check args + if self.args[1].type ~= 'void' then + local i=1 + while self.args[i] do + local btype = isbasic(self.args[i].type) + if btype ~= 'value' and btype ~= 'state' then + output(' '..self.args[i]:outchecktype(narg)..' ||\n') + end + if btype ~= 'state' then + narg = narg+1 + end + i = i+1 + end + end + -- check end of list + output(' !tolua_isnoobj(tolua_S,'..narg..',&tolua_err)\n )') + output(' goto tolua_lerror;') + + output(' else\n') + if overload < 0 then + output('#endif\n') + end + output(' {') + + -- declare self, if the case + local narg + if class then narg=2 else narg=1 end + if class and self.name~='new' and static==nil then + output(' ',self.const,self.parent.type,'*','self = ') + output('(',self.const,self.parent.type,'*) ') + local to_func = get_to_function(self.parent.type) + output(to_func,'(tolua_S,1,0);') + elseif static then + _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') + end + -- declare parameters + if self.args[1].type ~= 'void' then + local i=1 + while self.args[i] do + self.args[i]:declare(narg) + if isbasic(self.args[i].type) ~= "state" then + narg = narg+1 + end + i = i+1 + end + end + + -- check self + if class and self.name~='new' and static==nil then + output('#ifndef TOLUA_RELEASE\n') + output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'", NULL);'); + output('#endif\n') + end + + -- get array element values + if class then narg=2 else narg=1 end + if self.args[1].type ~= 'void' then + local i=1 + while self.args[i] do + self.args[i]:getarray(narg) + narg = narg+1 + i = i+1 + end + end + + pre_call_hook(self) + + local out = string.find(self.mod, "tolua_outside") + -- call function + if class and self.name=='delete' then + output(' Mtolua_delete(self);') + elseif class and self.name == 'operator&[]' then + if flags['1'] then -- for compatibility with tolua5 ? + output(' self->operator[](',self.args[1].name,'-1) = ',self.args[2].name,';') + else + output(' self->operator[](',self.args[1].name,') = ',self.args[2].name,';') + end + else + output(' {') + if self.type ~= '' and self.type ~= 'void' then + output(' ',self.mod,self.type,self.ptr,'tolua_ret = ') + output('(',self.mod,self.type,self.ptr,') ') + else + output(' ') + end + if class and self.name=='new' then + output('Mtolua_new((',self.type,')(') + elseif class and static then + if out then + output(self.name,'(') + else + output(class..'::'..self.name,'(') + end + elseif class then + if out then + output(self.name,'(') + else + if self.cast_operator then + --output('static_cast<',self.mod,self.type,self.ptr,' >(*self') + output('self->operator ',self.mod,self.type,'(') + else + output('self->'..self.name,'(') + end + end + else + output(self.name,'(') + end + + if out and not static then + output('self') + if self.args[1] and self.args[1].name ~= '' then + output(',') + end + end + -- write parameters + local i=1 + while self.args[i] do + self.args[i]:passpar() + i = i+1 + if self.args[i] then + output(',') + end + end + + if class and self.name == 'operator[]' and flags['1'] then + output('-1);') + else + if class and self.name=='new' then + output('));') -- close Mtolua_new( + else + output(');') + end + end + + -- return values + if self.type ~= '' and self.type ~= 'void' then + nret = nret + 1 + local t,ct = isbasic(self.type) + if t and self.name ~= "new" then + if self.cast_operator and _basic_raw_push[t] then + output(' ',_basic_raw_push[t],'(tolua_S,(',ct,')tolua_ret);') + else + output(' tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);') + end + else + t = self.type + new_t = string.gsub(t, "const%s+", "") + local owned = false + if string.find(self.mod, "tolua_owned") then + owned = true + end + local push_func = get_push_function(t) + if self.ptr == '' then + output(' {') + output('#ifdef __cplusplus\n') + output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));') + output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') + output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') + output('#else\n') + output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));') + output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') + output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') + output('#endif\n') + output(' }') + elseif self.ptr == '&' then + output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");') + else + output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");') + if owned or local_constructor then + output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') + end + end + end + end + local i=1 + while self.args[i] do + nret = nret + self.args[i]:retvalue() + i = i+1 + end + output(' }') + + -- set array element values + if class then narg=2 else narg=1 end + if self.args[1].type ~= 'void' then + local i=1 + while self.args[i] do + self.args[i]:setarray(narg) + narg = narg+1 + i = i+1 + end + end + + -- free dynamically allocated array + if self.args[1].type ~= 'void' then + local i=1 + while self.args[i] do + self.args[i]:freearray() + i = i+1 + end + end + end + + post_call_hook(self) + + output(' }') + output(' return '..nret..';') + + -- call overloaded function or generate error + if overload < 0 then + + output('#ifndef TOLUA_RELEASE\n') + output('tolua_lerror:\n') + output(' tolua_error(tolua_S,"'..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);') + output(' return 0;') + output('#endif\n') + else + local _local = "" + if local_constructor then + _local = "_local" + end + output('tolua_lerror:\n') + output(' return '..strsub(self.cname,1,-3)..format("%02d",overload).._local..'(tolua_S);') + end + output('}') + output('#endif //#ifndef TOLUA_DISABLE\n') + output('\n') + + -- recursive call to write local constructor + if class and self.name=='new' and not local_constructor then + + self:supcode(1) + end + +end + + +-- register function +function classFunction:register (pre) + + if not self:check_public_access() then + return + end + + if self.name == 'new' and self.parent.flags.pure_virtual then + -- no constructor for classes with pure virtual methods + return + end + + output(pre..'tolua_function(tolua_S,"'..self.lname..'",'..self.cname..');') + if self.name == 'new' then + output(pre..'tolua_function(tolua_S,"new_local",'..self.cname..'_local);') + output(pre..'tolua_function(tolua_S,".call",'..self.cname..'_local);') + --output(' tolua_set_call_event(tolua_S,'..self.cname..'_local, "'..self.parent.type..'");') + end +end + +-- Print method +function classFunction:print (ident,close) + print(ident.."Function{") + print(ident.." mod = '"..self.mod.."',") + print(ident.." type = '"..self.type.."',") + print(ident.." ptr = '"..self.ptr.."',") + print(ident.." name = '"..self.name.."',") + print(ident.." lname = '"..self.lname.."',") + print(ident.." const = '"..self.const.."',") + print(ident.." cname = '"..self.cname.."',") + print(ident.." lname = '"..self.lname.."',") + print(ident.." args = {") + local i=1 + while self.args[i] do + self.args[i]:print(ident.." ",",") + i = i+1 + end + print(ident.." }") + print(ident.."}"..close) +end + +-- check if it returns an object by value +function classFunction:requirecollection (t) + local r = false + if self.type ~= '' and not isbasic(self.type) and self.ptr=='' then + local type = gsub(self.type,"%s*const%s+","") + t[type] = "tolua_collect_" .. clean_template(type) + r = true + end + local i=1 + while self.args[i] do + r = self.args[i]:requirecollection(t) or r + i = i+1 + end + return r +end + +-- determine lua function name overload +function classFunction:overload () + return self.parent:overload(self.lname) +end + + +function param_object(par) -- returns true if the parameter has an object as its default value + + if not string.find(par, '=') then return false end -- it has no default value + + local _,_,def = string.find(par, "=(.*)$") + + if string.find(par, "|") then -- a list of flags + + return true + end + + if string.find(par, "%*") then -- it's a pointer with a default value + + if string.find(par, '=%s*new') or string.find(par, "%(") then -- it's a pointer with an instance as default parameter.. is that valid? + return true + end + return false -- default value is 'NULL' or something + end + + + if string.find(par, "[%(&]") then + return true + end -- default value is a constructor call (most likely for a const reference) + + --if string.find(par, "&") then + + -- if string.find(def, ":") or string.find(def, "^%s*new%s+") then + + -- -- it's a reference with default to something like Class::member, or 'new Class' + -- return true + -- end + --end + + return false -- ? +end + +function strip_last_arg(all_args, last_arg) -- strips the default value from the last argument + + local _,_,s_arg = string.find(last_arg, "^([^=]+)") + last_arg = string.gsub(last_arg, "([%%%(%)])", "%%%1"); + all_args = string.gsub(all_args, "%s*,%s*"..last_arg.."%s*%)%s*$", ")") + return all_args, s_arg +end + + + +-- Internal constructor +function _Function (t) + setmetatable(t,classFunction) + + if t.const ~= 'const' and t.const ~= '' then + error("#invalid 'const' specification") + end + + append(t) + if t:inclass() then + --print ('t.name is '..t.name..', parent.name is '..t.parent.name) + if string.gsub(t.name, "%b<>", "") == string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then + t.name = 'new' + t.lname = 'new' + t.parent._new = true + t.type = t.parent.name + t.ptr = '*' + elseif string.gsub(t.name, "%b<>", "") == '~'..string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then + t.name = 'delete' + t.lname = 'delete' + t.parent._delete = true + end + end + t.cname = t:cfuncname("tolua")..t:overload(t) + return t +end + +-- Constructor +-- Expects three strings: one representing the function declaration, +-- another representing the argument list, and the third representing +-- the "const" or empty string. +function Function (d,a,c) + --local t = split(strsub(a,2,-2),',') -- eliminate braces + --local t = split_params(strsub(a,2,-2)) + + if not flags['W'] and string.find(a, "%.%.%.%s*%)") then + + warning("Functions with variable arguments (`...') are not supported. Ignoring "..d..a..c) + return nil + end + + + local i=1 + local l = {n=0} + + a = string.gsub(a, "%s*([%(%)])%s*", "%1") + local t,strip,last = strip_pars(strsub(a,2,-2)); + if strip then + --local ns = string.sub(strsub(a,1,-2), 1, -(string.len(last)+1)) + local ns = join(t, ",", 1, last-1) + + ns = "("..string.gsub(ns, "%s*,%s*$", "")..')' + --ns = strip_defaults(ns) + + local f = Function(d, ns, c) + for i=1,last do + t[i] = string.gsub(t[i], "=.*$", "") + end + end + + while t[i] do + l.n = l.n+1 + l[l.n] = Declaration(t[i],'var',true) + i = i+1 + end + local f = Declaration(d,'func') + f.args = l + f.const = c + return _Function(f) +end + +function join(t, sep, first, last) + + first = first or 1 + last = last or table.getn(t) + local lsep = "" + local ret = "" + local loop = false + for i = first,last do + + ret = ret..lsep..t[i] + lsep = sep + loop = true + end + if not loop then + return "" + end + + return ret +end + +function strip_pars(s) + + local t = split_c_tokens(s, ',') + local strip = false + local last + + for i=t.n,1,-1 do + + if not strip and param_object(t[i]) then + last = i + strip = true + end + --if strip then + -- t[i] = string.gsub(t[i], "=.*$", "") + --end + end + + return t,strip,last + +end + +function strip_defaults(s) + + s = string.gsub(s, "^%(", "") + s = string.gsub(s, "%)$", "") + + local t = split_c_tokens(s, ",") + local sep, ret = "","" + for i=1,t.n do + t[i] = string.gsub(t[i], "=.*$", "") + ret = ret..sep..t[i] + sep = "," + end + + return "("..ret..")" +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/module.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/module.lua new file mode 100644 index 000000000..57dceb7d5 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/module.lua @@ -0,0 +1,68 @@ +-- tolua: module class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + + +-- Module class +-- Represents module. +-- The following fields are stored: +-- {i} = list of objects in the module. +classModule = { + classtype = 'module' +} +classModule.__index = classModule +setmetatable(classModule,classContainer) + +-- register module +function classModule:register (pre) + pre = pre or '' + push(self) + output(pre..'tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');') + output(pre..'tolua_beginmodule(tolua_S,"'..self.name..'");') + local i=1 + while self[i] do + self[i]:register(pre..' ') + i = i+1 + end + output(pre..'tolua_endmodule(tolua_S);') + pop() +end + +-- Print method +function classModule:print (ident,close) + print(ident.."Module{") + print(ident.." name = '"..self.name.."';") + local i=1 + while self[i] do + self[i]:print(ident.." ",",") + i = i+1 + end + print(ident.."}"..close) +end + +-- Internal constructor +function _Module (t) + setmetatable(t,classModule) + append(t) + return t +end + +-- Constructor +-- Expects two string representing the module name and body. +function Module (n,b) + local t = _Module(_Container{name=n}) + push(t) + t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces + pop() + return t +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/namespace.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/namespace.lua new file mode 100644 index 000000000..6ca80e6e3 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/namespace.lua @@ -0,0 +1,52 @@ +-- tolua: namespace class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 2003 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Namespace class +-- Represents a namesapce definition. +-- Stores the following fields: +-- name = class name +-- {i} = list of members +classNamespace = { + classtype = 'namespace', + name = '', +} +classNamespace.__index = classNamespace +setmetatable(classNamespace,classModule) + +-- Print method +function classNamespace:print (ident,close) + print(ident.."Namespace{") + print(ident.." name = '"..self.name.."',") + local i=1 + while self[i] do + self[i]:print(ident.." ",",") + i = i+1 + end + print(ident.."}"..close) +end + +-- Internal constructor +function _Namespace (t) + setmetatable(t,classNamespace) + append(t) + return t +end + +-- Constructor +-- Expects the name and the body of the namespace. +function Namespace (n,b) + local c = _Namespace(_Container{name=n}) + push(c) + c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces + pop() +end + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/operator.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/operator.lua new file mode 100644 index 000000000..675027cd7 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/operator.lua @@ -0,0 +1,220 @@ +-- tolua: operator class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Operator class +-- Represents an operator function or a class operator method. +-- It stores the same fields as functions do plus: +-- kind = set of character representing the operator (as it appers in C++ code) +classOperator = { + kind = '', +} +classOperator.__index = classOperator +setmetatable(classOperator,classFunction) + +-- table to transform operator kind into the appropriate tag method name +_TM = {['+'] = 'add', + ['-'] = 'sub', + ['*'] = 'mul', + ['/'] = 'div', + ['<'] = 'lt', + ['<='] = 'le', + ['=='] = 'eq', + ['[]'] = 'geti', + ['&[]'] = 'seti', + --['->'] = 'flechita', + } + + +-- Print method +function classOperator:print (ident,close) + print(ident.."Operator{") + print(ident.." kind = '"..self.kind.."',") + print(ident.." mod = '"..self.mod.."',") + print(ident.." type = '"..self.type.."',") + print(ident.." ptr = '"..self.ptr.."',") + print(ident.." name = '"..self.name.."',") + print(ident.." const = '"..self.const.."',") + print(ident.." cname = '"..self.cname.."',") + print(ident.." lname = '"..self.lname.."',") + print(ident.." args = {") + local i=1 + while self.args[i] do + self.args[i]:print(ident.." ",",") + i = i+1 + end + print(ident.." }") + print(ident.."}"..close) +end + +function classOperator:supcode_tmp() + + if not _TM[self.kind] then + return classFunction.supcode(self) + end + + -- no overload, no parameters, always inclass + output("/* method:",self.name," of class ",self:inclass()," */") + + output("#ifndef TOLUA_DISABLE_"..self.cname) + output("\nstatic int",self.cname,"(lua_State* tolua_S)") + + if overload < 0 then + output('#ifndef TOLUA_RELEASE\n') + end + output(' tolua_Error tolua_err;') + output(' if (\n') + -- check self + local is_func = get_is_function(self.parent.type) + output(' !'..is_func..'(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n') + output(' !tolua_isnoobj(tolua_S,2,&tolua_err)\n )') + output(' goto tolua_lerror;') + + output(' else\n') + output('#endif\n') -- tolua_release + output(' {') + + -- declare self + output(' ',self.const,self.parent.type,'*','self = ') + output('(',self.const,self.parent.type,'*) ') + local to_func = get_to_func(self.parent.type) + output(to_func,'(tolua_S,1,0);') + + -- check self + output('#ifndef TOLUA_RELEASE\n') + output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'",NULL);'); + output('#endif\n') + + -- cast self + output(' ',self.mod,self.type,self.ptr,'tolua_ret = ') + output('(',self.mod,self.type,self.ptr,')(*self);') + + -- return value + local t,ct = isbasic(self.type) + if t then + output(' tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);') + else + t = self.type + local push_func = get_push_function(t) + new_t = string.gsub(t, "const%s+", "") + if self.ptr == '' then + output(' {') + output('#ifdef __cplusplus\n') + output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));') + output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') + output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') + output('#else\n') + output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));') + output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') + output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') + output('#endif\n') + output(' }') + elseif self.ptr == '&' then + output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");') + else + if local_constructor then + output(' ',push_func,'(tolua_S,(void *)tolua_ret,"',t,'");') + output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') + else + output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");') + end + end + end + + output(' }') + output(' return 1;') + + output('#ifndef TOLUA_RELEASE\n') + output('tolua_lerror:\n') + output(' tolua_error(tolua_S,"'..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);') + output(' return 0;') + output('#endif\n') + + + output('}') + output('#endif //#ifndef TOLUA_DISABLE\n') + output('\n') +end + +-- Internal constructor +function _Operator (t) + setmetatable(t,classOperator) + + if t.const ~= 'const' and t.const ~= '' then + error("#invalid 'const' specification") + end + + append(t) + if not t:inclass() then + error("#operator can only be defined as class member") + end + + --t.name = t.name .. "_" .. (_TM[t.kind] or t.kind) + t.cname = t:cfuncname("tolua")..t:overload(t) + t.name = "operator" .. t.kind -- set appropriate calling name + return t +end + +-- Constructor +function Operator (d,k,a,c) + + local op_k = string.gsub(k, "^%s*", "") + op_k = string.gsub(k, "%s*$", "") + --if string.find(k, "^[%w_:%d<>%*%&]+$") then + if d == "operator" and k ~= '' then + + d = k.." operator" + elseif not _TM[op_k] then + + if flags['W'] then + error("tolua: no support for operator" .. f.kind) + else + warning("No support for operator "..op_k..", ignoring") + return nil + end + end + + local ref = '' + local t = split_c_tokens(strsub(a,2,strlen(a)-1),',') -- eliminate braces + local i=1 + local l = {n=0} + while t[i] do + l.n = l.n+1 + l[l.n] = Declaration(t[i],'var') + i = i+1 + end + if k == '[]' then + local _ + _, _, ref = strfind(d,'(&)') + d = gsub(d,'&','') + elseif k=='&[]' then + l.n = l.n+1 + l[l.n] = Declaration(d,'var') + l[l.n].name = 'tolua_value' + end + local f = Declaration(d,'func') + if k == '[]' and (l[1]==nil or isbasic(l[1].type)~='number') then + error('operator[] can only be defined for numeric index.') + end + f.args = l + f.const = c + f.kind = op_k + f.lname = "."..(_TM[f.kind] or f.kind) + if not _TM[f.kind] then + f.cast_operator = true + end + if f.kind == '[]' and ref=='&' and f.const~='const' then + Operator(d,'&'..k,a,c) -- create correspoding set operator + end + return _Operator(f) +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/package.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/package.lua new file mode 100644 index 000000000..eec136904 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/package.lua @@ -0,0 +1,343 @@ +-- tolua: package class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + + +-- Package class +-- Represents the whole package being bound. +-- The following fields are stored: +-- {i} = list of objects in the package. +classPackage = { + classtype = 'package' +} +classPackage.__index = classPackage +setmetatable(classPackage,classContainer) + +-- Print method +function classPackage:print () + print("Package: "..self.name) + local i=1 + while self[i] do + self[i]:print("","") + i = i+1 + end +end + +function classPackage:preprocess () + + -- avoid preprocessing embedded Lua code + local L = {} + self.code = gsub(self.code,"\n%s*%$%[","\1") -- deal with embedded lua code + self.code = gsub(self.code,"\n%s*%$%]","\2") + self.code = gsub(self.code,"(%b\1\2)", function (c) + tinsert(L,c) + return "\n#["..getn(L).."]#" + end) + -- avoid preprocessing embedded C code + local C = {} + self.code = gsub(self.code,"\n%s*%$%<","\3") -- deal with embedded C code + self.code = gsub(self.code,"\n%s*%$%>","\4") + self.code = gsub(self.code,"(%b\3\4)", function (c) + tinsert(C,c) + return "\n#<"..getn(C)..">#" + end) + -- avoid preprocessing embedded C code + self.code = gsub(self.code,"\n%s*%$%{","\5") -- deal with embedded C code + self.code = gsub(self.code,"\n%s*%$%}","\6") + self.code = gsub(self.code,"(%b\5\6)", function (c) + tinsert(C,c) + return "\n#<"..getn(C)..">#" + end) + + --self.code = gsub(self.code,"\n%s*#[^d][^\n]*\n", "\n\n") -- eliminate preprocessor directives that don't start with 'd' + self.code = gsub(self.code,"\n[ \t]*#[ \t]*[^d%<%[]", "\n//") -- eliminate preprocessor directives that don't start with 'd' + + -- avoid preprocessing verbatim lines + local V = {} + self.code = gsub(self.code,"\n(%s*%$[^%[%]][^\n]*)",function (v) + tinsert(V,v) + return "\n#"..getn(V).."#" + end) + + -- perform global substitution + + self.code = gsub(self.code,"(//[^\n]*)","") -- eliminate C++ comments + self.code = gsub(self.code,"/%*","\1") + self.code = gsub(self.code,"%*/","\2") + self.code = gsub(self.code,"%b\1\2","") + self.code = gsub(self.code,"\1","/%*") + self.code = gsub(self.code,"\2","%*/") + self.code = gsub(self.code,"%s*@%s*","@") -- eliminate spaces beside @ + self.code = gsub(self.code,"%s?inline(%s)","%1") -- eliminate 'inline' keyword + --self.code = gsub(self.code,"%s?extern(%s)","%1") -- eliminate 'extern' keyword + --self.code = gsub(self.code,"%s?virtual(%s)","%1") -- eliminate 'virtual' keyword + --self.code = gsub(self.code,"public:","") -- eliminate 'public:' keyword + self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*' + self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*' + self.code = gsub(self.code,"([^%w_])char%s*%*","%1_cstring ") -- substitute 'char*' + self.code = gsub(self.code,"([^%w_])lua_State%s*%*","%1_lstate ") -- substitute 'lua_State*' + + -- restore embedded Lua code + self.code = gsub(self.code,"%#%[(%d+)%]%#",function (n) + return L[tonumber(n)] + end) + -- restore embedded C code + self.code = gsub(self.code,"%#%<(%d+)%>%#",function (n) + return C[tonumber(n)] + end) + -- restore verbatim lines + self.code = gsub(self.code,"%#(%d+)%#",function (n) + return V[tonumber(n)] + end) + + self.code = string.gsub(self.code, "\n%s*%$([^\n]+)", function (l) + Verbatim(l.."\n") + return "\n" + end) +end + +-- translate verbatim +function classPackage:preamble () + output('/*\n') + output('** Lua binding: '..self.name..'\n') + output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n') + output('*/\n\n') + + output('#ifndef __cplusplus\n') + output('#include "stdlib.h"\n') + output('#endif\n') + output('#include "string.h"\n\n') + output('#include "tolua++.h"\n\n') + + if not flags.h then + output('/* Exported function */') + output('TOLUA_API int tolua_'..self.name..'_open (lua_State* tolua_S);') + output('\n') + end + + local i=1 + while self[i] do + self[i]:preamble() + i = i+1 + end + + if self:requirecollection(_collect) then + output('\n') + output('/* function to release collected object via destructor */') + output('#ifdef __cplusplus\n') + for i,v in pairs(_collect) do + output('\nstatic int '..v..' (lua_State* tolua_S)') + output('{') + output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);') + output(' Mtolua_delete(self);') + output(' return 0;') + output('}') + end + output('#endif\n\n') + end + + output('\n') + output('/* function to register type */') + output('static void tolua_reg_types (lua_State* tolua_S)') + output('{') + + if flags.t then + output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n") + end + foreach(_usertype,function(n,v) + if (not _global_classes[v]) or _global_classes[v]:check_public_access() then + output(' tolua_usertype(tolua_S,"',v,'");') + if flags.t then + output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");') + end + end + end) + output('}') + output('\n') +end + +-- register package +-- write package open function +function classPackage:register (pre) + pre = pre or '' + push(self) + output(pre.."/* Open function */") + output(pre.."TOLUA_API int tolua_"..self.name.."_open (lua_State* tolua_S)") + output(pre.."{") + output(pre.." tolua_open(tolua_S);") + output(pre.." tolua_reg_types(tolua_S);") + output(pre.." tolua_module(tolua_S,NULL,",self:hasvar(),");") + output(pre.." tolua_beginmodule(tolua_S,NULL);") + local i=1 + while self[i] do + self[i]:register(pre.." ") + i = i+1 + end + output(pre.." tolua_endmodule(tolua_S);") + output(pre.." return 1;") + output(pre.."}") + + output("\n\n") + output("#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501\n"); + output(pre.."TOLUA_API int luaopen_"..self.name.." (lua_State* tolua_S) {") + output(pre.." return tolua_"..self.name.."_open(tolua_S);") + output(pre.."};") + output("#endif\n\n") + + pop() +end + +-- write header file +function classPackage:header () + output('/*\n') output('** Lua binding: '..self.name..'\n') + output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n') + output('*/\n\n') + + if not flags.h then + output('/* Exported function */') + output('TOLUA_API int tolua_'..self.name..'_open (lua_State* tolua_S);') + output('\n') + end +end + +-- Internal constructor +function _Package (self) + setmetatable(self,classPackage) + return self +end + +-- Parse C header file with tolua directives +-- *** Thanks to Ariel Manzur for fixing bugs in nested directives *** +function extract_code(fn,s) + local code = '\n$#include "'..fn..'"\n' + s= "\n" .. s .. "\n" -- add blank lines as sentinels + local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n") + while e do + t = strlower(t) + if t == "begin" then + _,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e) + if not e then + tolua_error("Unbalanced 'tolua_begin' directive in header file") + end + end + code = code .. c .. "\n" + _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e) + end + return code +end + +-- Constructor +-- Expects the package name, the file extension, and the file text. +function Package (name,fn) + local ext = "pkg" + + -- open input file, if any + local st,msg + if fn then + st, msg = readfrom(flags.f) + if not st then + error('#'..msg) + end + local _; _, _, ext = strfind(fn,".*%.(.*)$") + end + local code + if ext == 'pkg' then + code = prep(st) + else + code = "\n" .. read('*a') + if ext == 'h' or ext == 'hpp' then + code = extract_code(fn,code) + end + end + + -- close file + if fn then + readfrom() + end + + -- deal with include directive + local nsubst + repeat + code,nsubst = gsub(code,'\n%s*%$(.)file%s*"(.-)"([^\n]*)\n', + function (kind,fn,extra) + local _, _, ext = strfind(fn,".*%.(.*)$") + local fp,msg = openfile(fn,'r') + if not fp then + error('#'..msg..': '..fn) + end + if kind == 'p' then + local s = prep(fp) + closefile(fp) + return s + end + local s = read(fp,'*a') + closefile(fp) + if kind == 'c' or kind == 'h' then + return extract_code(fn,s) + elseif kind == 'l' then + return "\n$[--##"..fn.."\n" .. s .. "\n$]\n" + elseif kind == 'i' then + local t = {code=s} + extra = string.gsub(extra, "^%s*,%s*", "") + local pars = split_c_tokens(extra, ",") + include_file_hook(t, fn, unpack(pars)) + return "\n\n" .. t.code + else + error('#Invalid include directive (use $cfile, $pfile, $lfile or $ifile)') + end + end) + until nsubst==0 + + -- deal with renaming directive + repeat -- I don't know why this is necesary + code,nsubst = gsub(code,'\n%s*%$renaming%s*(.-)%s*\n', function (r) appendrenaming(r) return "\n" end) + until nsubst == 0 + + local t = _Package(_Container{name=name, code=code}) + push(t) + preprocess_hook(t) + t:preprocess() + preparse_hook(t) + t:parse(t.code) + pop() + return t +end + + +setmetatable(_extra_parameters, { __index = _G }) + +function prep(file) + + local chunk = {'local __ret = {"\\n"}\n'} + for line in file:lines() do + if string.find(line, "^##") then + table.insert(chunk, string.sub(line, 3) .. "\n") + else + local last = 1 + for text, expr, index in string.gfind(line, "(.-)$(%b())()") do + last = index + if text ~= "" then + table.insert(chunk, string.format('table.insert(__ret, %q )', text)) + end + table.insert(chunk, string.format('table.insert(__ret, %s )', expr)) + end + table.insert(chunk, string.format('table.insert(__ret, %q)\n', + string.sub(line, last).."\n")) + end + end + table.insert(chunk, '\nreturn table.concat(__ret)\n') + local f,e = loadstring(table.concat(chunk)) + if e then + error("#"..e) + end + setfenv(f, _extra_parameters) + return f() +end diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/template_class.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/template_class.lua new file mode 100644 index 000000000..b1ed05abe --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/template_class.lua @@ -0,0 +1,82 @@ + +_global_templates = {} + +classTemplateClass = { + + name = '', + body = '', + parents = {}, + args = {}, -- the template arguments +} + +classTemplateClass.__index = classTemplateClass + + +function classTemplateClass:throw(types, local_scope) + + --if table.getn(types) ~= table.getn(self.args) then + -- error("#invalid parameter count") + --end + + -- replace + for i =1 , types.n do + + local Il = split_c_tokens(types[i], " ") + if table.getn(Il) ~= table.getn(self.args) then + error("#invalid parameter count for "..types[i]) + end + local bI = self.body + local pI = {} + for j = 1,self.args.n do + --Tl[j] = findtype(Tl[j]) or Tl[j] + bI = string.gsub(bI, "([^_%w])"..self.args[j].."([^_%w])", "%1"..Il[j].."%2") + if self.parents then + for i=1,table.getn(self.parents) do + pI[i] = string.gsub(self.parents[i], "([^_%w]?)"..self.args[j].."([^_%w]?)", "%1"..Il[j].."%2") + end + end + end + --local append = "<"..string.gsub(types[i], "%s+", ",")..">" + local append = "<"..concat(Il, 1, table.getn(Il), ",")..">" + append = string.gsub(append, "%s*,%s*", ",") + append = string.gsub(append, ">>", "> >") + for i=1,table.getn(pI) do + --pI[i] = string.gsub(pI[i], ">>", "> >") + pI[i] = resolve_template_types(pI[i]) + end + bI = string.gsub(bI, ">>", "> >") + local n = self.name + if local_scope then + n = self.local_name + end + + Class(n..append, pI, bI) + end +end + + +function TemplateClass(name, parents, body, parameters) + + local o = { + + parents = parents, + body = body, + args = parameters, + } + + local oname = string.gsub(name, "@.*$", "") + oname = getnamespace(classContainer.curr)..oname + o.name = oname + + o.local_name = name + + setmetatable(o, classTemplateClass) + + if _global_templates[oname] then + warning("Duplicate declaration of template "..oname) + else + _global_templates[oname] = o + end + + return o +end diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/typedef.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/typedef.lua new file mode 100644 index 000000000..a78a84155 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/typedef.lua @@ -0,0 +1,71 @@ +-- tolua: typedef class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + + +-- Typedef class +-- Represents a type synonym. +-- The 'de facto' type replaces the typedef before the +-- remaining code is parsed. +-- The following fields are stored: +-- utype = typedef name +-- type = 'the facto' type +-- mod = modifiers to the 'de facto' type +classTypedef = { + utype = '', + mod = '', + type = '' +} +classTypedef.__index = classTypedef + +-- Print method +function classTypedef:print (ident,close) + print(ident.."Typedef{") + print(ident.." utype = '"..self.utype.."',") + print(ident.." mod = '"..self.mod.."',") + print(ident.." type = '"..self.type.."',") + print(ident.."}"..close) +end + +-- Return it's not a variable +function classTypedef:isvariable () + return false +end + +-- Internal constructor +function _Typedef (t) + setmetatable(t,classTypedef) + t.type = resolve_template_types(t.type) + appendtypedef(t) + return t +end + +-- Constructor +-- Expects one string representing the type definition. +function Typedef (s) + if strfind(string.gsub(s, '%b<>', ''),'[%*&]') then + tolua_error("#invalid typedef: pointers (and references) are not supported") + end + local o = {mod = ''} + if string.find(s, "[<>]") then + _,_,o.type,o.utype = string.find(s, "^%s*([^<>]+%b<>[^%s]*)%s+(.-)$") + else + local t = split(gsub(s,"%s%s*"," ")," ") + o = { + utype = t[t.n], + type = t[t.n-1], + mod = concat(t,1,t.n-2), + } + end + return _Typedef(o) +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/variable.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/variable.lua new file mode 100644 index 000000000..fbc705dd8 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/variable.lua @@ -0,0 +1,300 @@ +-- tolua: variable class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + +-- Variable class +-- Represents a extern variable or a public member of a class. +-- Stores all fields present in a declaration. +classVariable = { + _get = {}, -- mapped get functions + _set = {}, -- mapped set functions +} +classVariable.__index = classVariable +setmetatable(classVariable,classDeclaration) + +-- Print method +function classVariable:print (ident,close) + print(ident.."Variable{") + print(ident.." mod = '"..self.mod.."',") + print(ident.." type = '"..self.type.."',") + print(ident.." ptr = '"..self.ptr.."',") + print(ident.." name = '"..self.name.."',") + if self.dim then print(ident.." dim = '"..self.dim.."',") end + print(ident.." def = '"..self.def.."',") + print(ident.." ret = '"..self.ret.."',") + print(ident.."}"..close) +end + +-- Generates C function name +function classVariable:cfuncname (prefix) + local parent = "" + local unsigned = "" + local ptr = "" + + local p = self:inmodule() or self:innamespace() or self:inclass() + + if p then + if self.parent.classtype == 'class' then + parent = "_" .. self.parent.type + else + parent = "_" .. p + end + end + + if strfind(self.mod,"(unsigned)") then + unsigned = "_unsigned" + end + + if self.ptr == "*" then ptr = "_ptr" + elseif self.ptr == "&" then ptr = "_ref" + end + + local name = prefix .. parent .. unsigned .. "_" .. gsub(self.lname or self.name,".*::","") .. ptr + + name = clean_template(name) + return name + +end + +-- check if it is a variable +function classVariable:isvariable () + return true +end + +-- get variable value +function classVariable:getvalue (class,static, prop_get) + + local name + if prop_get then + + name = prop_get.."()" + else + name = self.name + end + + if class and static then + return self.parent.type..'::'..name + elseif class then + return 'self->'..name + else + return name + end +end + +-- get variable pointer value +function classVariable:getpointervalue (class,static) + if class and static then + return class..'::p' + elseif class then + return 'self->p' + else + return 'p' + end +end + +-- Write binding functions +function classVariable:supcode () + + local class = self:inclass() + + local prop_get,prop_set + if string.find(self.mod, 'tolua_property') then + + local _,_,type = string.find(self.mod, "tolua_property__([^%s]*)") + type = type or "default" + prop_get,prop_set = get_property_methods(type, self.name) + self.mod = string.gsub(self.mod, "tolua_property[^%s]*", "") + end + + -- get function ------------------------------------------------ + if class then + output("/* get function:",self.name," of class ",class," */") + else + output("/* get function:",self.name," */") + end + self.cgetname = self:cfuncname("tolua_get") + output("#ifndef TOLUA_DISABLE_"..self.cgetname) + output("\nstatic int",self.cgetname,"(lua_State* tolua_S)") + output("{") + + -- declare self, if the case + local _,_,static = strfind(self.mod,'^%s*(static)') + if class and static==nil then + output(' ',self.parent.type,'*','self = ') + output('(',self.parent.type,'*) ') + local to_func = get_to_function(self.parent.type) + output(to_func,'(tolua_S,1,0);') + elseif static then + _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') + end + + + -- check self value + if class and static==nil then + output('#ifndef TOLUA_RELEASE\n') + output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in accessing variable \'%s\'", self.name)..'",NULL);'); + output('#endif\n') + end + + -- return value + if string.find(self.mod, 'tolua_inherits') then + local push_func = get_push_function(self.type) + output('#ifdef __cplusplus\n') + output(' ',push_func,'(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");') + output('#else\n') + output(' ',push_func,'(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");') + output('#endif\n') + else + local t,ct = isbasic(self.type) + if t then + output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static,prop_get)..');') + else + local push_func = get_push_function(self.type) + t = self.type + if self.ptr == '&' or self.ptr == '' then + output(' ',push_func,'(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");') + else + output(' ',push_func,'(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");') + end + end + end + output(' return 1;') + output('}') + output('#endif //#ifndef TOLUA_DISABLE\n') + output('\n') + + -- set function ------------------------------------------------ + if not (strfind(self.type,'const%s+') or string.find(self.mod, 'tolua_readonly') or string.find(self.mod, 'tolua_inherits')) then + if class then + output("/* set function:",self.name," of class ",class," */") + else + output("/* set function:",self.name," */") + end + self.csetname = self:cfuncname("tolua_set") + output("#ifndef TOLUA_DISABLE_"..self.csetname) + output("\nstatic int",self.csetname,"(lua_State* tolua_S)") + output("{") + + -- declare self, if the case + if class and static==nil then + output(' ',self.parent.type,'*','self = ') + output('(',self.parent.type,'*) ') + local to_func = get_to_function(self.parent.type) + output(to_func,'(tolua_S,1,0);') + -- check self value + end + -- check types + output('#ifndef TOLUA_RELEASE\n') + output(' tolua_Error tolua_err;') + if class and static==nil then + output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in accessing variable \'%s\'", self.name)..'",NULL);'); + elseif static then + _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') + end + + -- check variable type + output(' if ('..self:outchecktype(2)..')') + output(' tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);') + output('#endif\n') + + -- assign value + local def = 0 + if self.def ~= '' then def = self.def end + if self.type == 'char*' and self.dim ~= '' then -- is string + output(' strncpy((char*)') + if class and static then + output(self.parent.type..'::'..self.name) + elseif class then + output('self->'..self.name) + else + output(self.name) + end + output(',(const char*)tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);') + else + local ptr = '' + if self.ptr~='' then ptr = '*' end + output(' ') + local name = prop_set or self.name + if class and static then + output(self.parent.type..'::'..name) + elseif class then + output('self->'..name) + else + output(name) + end + local t = isbasic(self.type) + if prop_set then + output('(') + else + output(' = ') + end + if not t and ptr=='' then output('*') end + output('((',self.mod,self.type) + if not t then + output('*') + end + output(') ') + if t then + if isenum(self.type) then + output('(int) ') + end + output('tolua_to'..t,'(tolua_S,2,',def,'))') + else + local to_func = get_to_function(self.type) + output(to_func,'(tolua_S,2,',def,'))') + end + if prop_set then + output(")") + end + output(";") + end + output(' return 0;') + output('}') + output('#endif //#ifndef TOLUA_DISABLE\n') + output('\n') + end + +end + +function classVariable:register (pre) + + if not self:check_public_access() then + return + end + pre = pre or '' + local parent = self:inmodule() or self:innamespace() or self:inclass() + if not parent then + if classVariable._warning==nil then + warning("Mapping variable to global may degrade performance") + classVariable._warning = 1 + end + end + if self.csetname then + output(pre..'tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');') + else + output(pre..'tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);') + end +end + +-- Internal constructor +function _Variable (t) + setmetatable(t,classVariable) + append(t) + return t +end + +-- Constructor +-- Expects a string representing the variable declaration. +function Variable (s) + return _Variable (Declaration(s,'var')) +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/lua/verbatim.lua b/third-party/lua-5.1.5/toluapp/src/bin/lua/verbatim.lua new file mode 100644 index 000000000..fd3b29b35 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/lua/verbatim.lua @@ -0,0 +1,78 @@ +-- tolua: verbatim class +-- Written by Waldemar Celes +-- TeCGraf/PUC-Rio +-- Jul 1998 +-- $Id: verbatim.lua,v 1.3 2000/01/24 20:41:16 celes Exp $ + +-- This code is free software; you can redistribute it and/or modify it. +-- The software provided hereunder is on an "as is" basis, and +-- the author has no obligation to provide maintenance, support, updates, +-- enhancements, or modifications. + + + +-- Verbatim class +-- Represents a line translated directed to the binding file. +-- The following filds are stored: +-- line = line text +classVerbatim = { + line = '', + cond = nil, -- condition: where to generate the code (s=suport, r=register) +} +classVerbatim.__index = classVerbatim +setmetatable(classVerbatim,classFeature) + +-- preamble verbatim +function classVerbatim:preamble () + if self.cond == '' then + write(self.line) + end +end + +-- support code +function classVerbatim:supcode () + if strfind(self.cond,'s') then + write(self.line) + write('\n') + end +end + +-- register code +function classVerbatim:register (pre) + if strfind(self.cond,'r') then + write(self.line) + end +end + + +-- Print method +function classVerbatim:print (ident,close) + print(ident.."Verbatim{") + print(ident.." line = '"..self.line.."',") + print(ident.."}"..close) +end + + +-- Internal constructor +function _Verbatim (t) + setmetatable(t,classVerbatim) + append(t) + return t +end + +-- Constructor +-- Expects a string representing the text line +function Verbatim (l,cond) + if strsub(l,1,1) == "'" then + l = strsub(l,2) + elseif strsub(l,1,1) == '$' then + cond = 'sr' -- generates in both suport and register fragments + l = strsub(l,2) + end + return _Verbatim { + line = l, + cond = cond or '', + } +end + + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/tolua.c b/third-party/lua-5.1.5/toluapp/src/bin/tolua.c new file mode 100644 index 000000000..cc9f9adcd --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/tolua.c @@ -0,0 +1,169 @@ +/* tolua +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Aug 2003 +** $Id:$ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" + +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" + +#include +#include +#include + + +static void help (void) +{ + fprintf(stderr,"\n" + "usage: tolua++ [options] input_file\n" + "\n" + "Command line options are:\n" + " -v : print version information.\n" + " -o file : set output file; default is stdout.\n" + " -H file : create include file.\n" + " -n name : set package name; default is input file root name.\n" + " -p : parse only.\n" + " -P : parse and print structure information (for debug).\n" + " -S : disable support for c++ strings.\n" + " -1 : substract 1 to operator[] index (for compatibility with tolua5).\n" + " -L file : run lua file (with dofile()) before doing anything.\n" + " -D : disable automatic exporting of destructors for classes that have\n" + " constructors (for compatibility with tolua5)\n" + " -W : disable warnings for unsupported features (for compatibility\n" + " with tolua5)\n" + " -C : disable cleanup of included lua code (for easier debugging)\n" + " -E value[=value] : add extra values to the luastate\n" + " -t : export a list of types asociates with the C++ typeid name\n" + " -q : don't print warnings to the console\n" + " -h : print this message.\n" + "Should the input file be omitted, stdin is assumed;\n" + "in that case, the package name must be explicitly set.\n\n" + ); +} + +static void version (void) +{ + fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n",TOLUA_VERSION); +} + +static void setfield (lua_State* L, int table, char* f, char* v) +{ + lua_pushstring(L,f); + lua_pushstring(L,v); + lua_settable(L,table); +} + +static void add_extra (lua_State* L, char* value) { + int len; + lua_getglobal(L, "_extra_parameters"); + len = luaL_getn(L, -1); + lua_pushstring(L, value); + lua_rawseti(L, -2, len+1); + lua_pop(L, 1); +}; + +static void error (char* o) +{ + fprintf(stderr,"tolua: unknown option '%s'\n",o); + help(); + exit(1); +} + +int main (int argc, char* argv[]) +{ + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + #else + lua_State* L = lua_open(); + luaopen_base(L); + luaopen_io(L); + luaopen_string(L); + luaopen_table(L); + luaopen_math(L); + luaopen_debug(L); + #endif + + lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION"); + lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION"); + + if (argc==1) + { + help(); + return 0; + } + else + { + int i, t; + lua_newtable(L); + lua_setglobal(L, "_extra_parameters"); + lua_newtable(L); + lua_pushvalue(L,-1); + lua_setglobal(L,"flags"); + t = lua_gettop(L); + for (i=1; i= 501 + TOLUA_API int luaopen_tolua (lua_State* tolua_S) { + return tolua_tolua_open(tolua_S); +}; +#endif + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/toluabind.h b/third-party/lua-5.1.5/toluapp/src/bin/toluabind.h new file mode 100644 index 000000000..7f1f018c9 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/toluabind.h @@ -0,0 +1,8 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.92 on Sun Feb 15 22:29:48 2009. +*/ + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.c b/third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.c new file mode 100644 index 000000000..b5db813bf --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.c @@ -0,0 +1,8009 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.92 on Fri Dec 28 21:37:36 2007. +*/ + +#ifndef __cplusplus +#include "stdlib.h" +#endif +#include "string.h" + +#include "tolua++.h" + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + + +/* function to register type */ +static void tolua_reg_types (lua_State* tolua_S) +{ +} + +/* Open function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,0); + tolua_beginmodule(tolua_S,NULL); + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, + 95, 86, 69, 82, 83, 73, 79, 78, 44, 32, 34, 53, 37, 46, 48, + 34, 41, 32,116,104,101,110, 13, 10, 9,114,101,116,117,114, + 110, 13, 10,101,110,100, 13, 10, 13, 10, 45, 45, 32, 34,108, + 111, 97,100,102,105,108,101, 34, 13, 10,108,111, 99, 97,108, + 32,102,117,110, 99,116,105,111,110, 32,112,112, 95,100,111, + 102,105,108,101, 40,112, 97,116,104, 41, 13, 10, 13, 10, 9, + 108,111, 99, 97,108, 32,108,111, 97,100,101,100, 32, 61, 32, + 102, 97,108,115,101, 13, 10, 9,108,111, 99, 97,108, 32,103, + 101,116,102,105,108,101, 32, 61, 32,102,117,110, 99,116,105, + 111,110, 40, 41, 13, 10, 13, 10, 9, 9,105,102, 32,108,111, + 97,100,101,100, 32,116,104,101,110, 13, 10, 9, 9, 9,114, + 101,116,117,114,110, 13, 10, 9, 9,101,108,115,101, 13, 10, + 9, 9, 9,108,111, 99, 97,108, 32,102,105,108,101, 44,101, + 114,114, 32, 61, 32,105,111, 46,111,112,101,110, 40,112, 97, + 116,104, 41, 13, 10, 9, 9, 9,105,102, 32,110,111,116, 32, + 102,105,108,101, 32,116,104,101,110, 13, 10, 9, 9, 9, 9, + 101,114,114,111,114, 40, 34,101,114,114,111,114, 32,108,111, + 97,100,105,110,103, 32,102,105,108,101, 32, 34, 46, 46,112, + 97,116,104, 46, 46, 34, 58, 32, 34, 46, 46,101,114,114, 41, + 13, 10, 9, 9, 9,101,110,100, 13, 10, 9, 9, 9,108,111, + 99, 97,108, 32,114,101,116, 32, 61, 32,102,105,108,101, 58, + 114,101, 97,100, 40, 34, 42, 97, 34, 41, 13, 10, 9, 9, 9, + 102,105,108,101, 58, 99,108,111,115,101, 40, 41, 13, 10, 13, + 10, 9, 9, 9,114,101,116, 32, 61, 32,115,116,114,105,110, + 103, 46,103,115,117, 98, 40,114,101,116, 44, 32, 34, 37, 46, + 37, 46, 37, 46, 37,115, 42, 37, 41, 34, 44, 32, 34, 46, 46, + 46, 41, 32,108,111, 99, 97,108, 32, 97,114,103, 32, 61, 32, + 123,110, 61,115,101,108,101, 99,116, 40, 39, 35, 39, 44, 32, + 46, 46, 46, 41, 44, 32, 46, 46, 46,125, 59, 34, 41, 13, 10, + 13, 10, 9, 9, 9,108,111, 97,100,101,100, 32, 61, 32,116, + 114,117,101, 13, 10, 9, 9, 9,114,101,116,117,114,110, 32, + 114,101,116, 13, 10, 9, 9,101,110,100, 13, 10, 9,101,110, + 100, 13, 10, 13, 10, 9,108,111, 99, 97,108, 32,102, 32, 61, + 32,108,111, 97,100, 40,103,101,116,102,105,108,101, 44, 32, + 112, 97,116,104, 41, 13, 10, 9,105,102, 32,110,111,116, 32, + 102, 32,116,104,101,110, 13, 10, 9, 13, 10, 9, 9,101,114, + 114,111,114, 40, 34,101,114,114,111,114, 32,108,111, 97,100, + 105,110,103, 32,102,105,108,101, 32, 34, 46, 46,112, 97,116, + 104, 41, 13, 10, 9,101,110,100, 13, 10, 9,114,101,116,117, + 114,110, 32,102, 40, 41, 13, 10,101,110,100, 13, 10, 13, 10, + 111,108,100, 95,100,111,102,105,108,101, 32, 61, 32,100,111, + 102,105,108,101, 13, 10,100,111,102,105,108,101, 32, 61, 32, + 112,112, 95,100,111,102,105,108,101, 13, 10, 13, 10, 13, 10, + 45, 45, 32,115,116,114,105,110,103, 46,103,115,117, 98, 13, + 10, 45, 45, 91, 91, 13, 10,108,111, 99, 97,108, 32,111,103, + 115,117, 98, 32, 61, 32,115,116,114,105,110,103, 46,103,115, + 117, 98, 13, 10,108,111, 99, 97,108, 32,102,117,110, 99,116, + 105,111,110, 32, 99,111,109,112,103,115,117, 98, 40, 97, 44, + 98, 44, 99, 44,100, 41, 13, 10, 32, 32,105,102, 32,116,121, + 112,101, 40, 99, 41, 32, 61, 61, 32, 34,102,117,110, 99,116, + 105,111,110, 34, 32,116,104,101,110, 13, 10, 32, 32, 32, 32, + 108,111, 99, 97,108, 32,111, 99, 32, 61, 32, 99, 13, 10, 32, + 32, 32, 32, 99, 32, 61, 32,102,117,110, 99,116,105,111,110, + 32, 40, 46, 46, 46, 41, 32,114,101,116,117,114,110, 32,111, + 99, 40, 46, 46, 46, 41, 32,111,114, 32, 39, 39, 32,101,110, + 100, 13, 10, 32, 32,101,110,100, 13, 10, 32, 32,114,101,116, + 117,114,110, 32,111,103,115,117, 98, 40, 97, 44, 98, 44, 99, + 44,100, 41, 13, 10,101,110,100, 13, 10,115,116,114,105,110, + 103, 46,114,101,112,108, 32, 61, 32,111,103,115,117, 98, 13, + 10, 45, 45, 93, 93, 13, 10, 13, 10, 45, 45,115,116,114,105, + 110,103, 46,103,115,117, 98, 32, 61, 32, 99,111,109,112,103, + 115,117, 98, 13,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/compat-5.1.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 82,101, 97,108, + 32,103,108,111, 98, 97,108,115, 10, 45, 45, 32, 95, 65, 76, + 69, 82, 84, 10, 45, 45, 32, 95, 69, 82, 82, 79, 82, 77, 69, + 83, 83, 65, 71, 69, 10, 45, 45, 32, 95, 86, 69, 82, 83, 73, + 79, 78, 10, 45, 45, 32, 95, 71, 10, 45, 45, 32, 97,115,115, + 101,114,116, 10, 45, 45, 32,101,114,114,111,114, 10, 45, 45, + 32,109,101,116, 97,116, 97, 98,108,101, 10, 45, 45, 32,110, + 101,120,116, 10, 45, 45, 32,112,114,105,110,116, 10, 45, 45, + 32,114,101,113,117,105,114,101, 10, 45, 45, 32,116,111,110, + 117,109, 98,101,114, 10, 45, 45, 32,116,111,115,116,114,105, + 110,103, 10, 45, 45, 32,116,121,112,101, 10, 45, 45, 32,117, + 110,112, 97, 99,107, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, + 45, 45, 32, 99,111,108,108,101, 99,116,103, 97,114, 98, 97, + 103,101, 10, 45, 45, 32,103, 99,105,110,102,111, 10, 10, 45, + 45, 32,103,108,111, 98, 97,108,115, 10, 10, 45, 45, 32, 99, + 97,108,108, 32, 32, 32, 45, 62, 32,112,114,111,116,101, 99, + 116, 40,102, 44, 32,101,114,114, 41, 10, 45, 45, 32,108,111, + 97,100,102,105,108,101, 10, 45, 45, 32,108,111, 97,100,115, + 116,114,105,110,103, 10, 10, 45, 45, 32,114, 97,119,103,101, + 116, 10, 45, 45, 32,114, 97,119,115,101,116, 10, 10, 45, 45, + 32,103,101,116, 97,114,103,115, 32, 61, 32, 77, 97,105,110, + 46,103,101,116, 97,114,103,115, 32, 63, 63, 10, 10,114, 97, + 119,116,121,112,101, 32, 61, 32,116,121,112,101, 10, 10,102, + 117,110, 99,116,105,111,110, 32,100,111, 95, 32, 40,102, 44, + 32,101,114,114, 41, 10, 32, 32,105,102, 32,110,111,116, 32, + 102, 32,116,104,101,110, 32,112,114,105,110,116, 40,101,114, + 114, 41, 59, 32,114,101,116,117,114,110, 32,101,110,100, 10, + 32, 32,108,111, 99, 97,108, 32, 97, 44, 98, 32, 61, 32,112, + 99, 97,108,108, 40,102, 41, 10, 32, 32,105,102, 32,110,111, + 116, 32, 97, 32,116,104,101,110, 32,112,114,105,110,116, 40, + 98, 41, 59, 32,114,101,116,117,114,110, 32,110,105,108, 10, + 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 98, + 32,111,114, 32,116,114,117,101, 10, 32, 32,101,110,100, 10, + 101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,100, + 111,115,116,114,105,110,103, 40,115, 41, 32,114,101,116,117, + 114,110, 32,100,111, 95, 40,108,111, 97,100,115,116,114,105, + 110,103, 40,115, 41, 41, 32,101,110,100, 10, 45, 45, 32,102, + 117,110, 99,116,105,111,110, 32,100,111,102,105,108,101, 40, + 115, 41, 32,114,101,116,117,114,110, 32,100,111, 95, 40,108, + 111, 97,100,102,105,108,101, 40,115, 41, 41, 32,101,110,100, + 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 84, 97, + 98,108,101, 32,108,105, 98,114, 97,114,121, 10,108,111, 99, + 97,108, 32,116, 97, 98, 32, 61, 32,116, 97, 98,108,101, 10, + 102,111,114,101, 97, 99,104, 32, 61, 32,116, 97, 98, 46,102, + 111,114,101, 97, 99,104, 10,102,111,114,101, 97, 99,104,105, + 32, 61, 32,116, 97, 98, 46,102,111,114,101, 97, 99,104,105, + 10,103,101,116,110, 32, 61, 32,116, 97, 98, 46,103,101,116, + 110, 10,116,105,110,115,101,114,116, 32, 61, 32,116, 97, 98, + 46,105,110,115,101,114,116, 10,116,114,101,109,111,118,101, + 32, 61, 32,116, 97, 98, 46,114,101,109,111,118,101, 10,115, + 111,114,116, 32, 61, 32,116, 97, 98, 46,115,111,114,116, 10, + 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 98, + 117,103, 32,108,105, 98,114, 97,114,121, 10,108,111, 99, 97, + 108, 32,100, 98,103, 32, 61, 32,100,101, 98,117,103, 10,103, + 101,116,105,110,102,111, 32, 61, 32,100, 98,103, 46,103,101, + 116,105,110,102,111, 10,103,101,116,108,111, 99, 97,108, 32, + 61, 32,100, 98,103, 46,103,101,116,108,111, 99, 97,108, 10, + 115,101,116, 99, 97,108,108,104,111,111,107, 32, 61, 32,102, + 117,110, 99,116,105,111,110, 32, 40, 41, 32,101,114,114,111, + 114, 34, 96,115,101,116, 99, 97,108,108,104,111,111,107, 39, + 32,105,115, 32,100,101,112,114,101, 99, 97,116,101,100, 34, + 32,101,110,100, 10,115,101,116,108,105,110,101,104,111,111, + 107, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, 41, + 32,101,114,114,111,114, 34, 96,115,101,116,108,105,110,101, + 104,111,111,107, 39, 32,105,115, 32,100,101,112,114,101, 99, + 97,116,101,100, 34, 32,101,110,100, 10,115,101,116,108,111, + 99, 97,108, 32, 61, 32,100, 98,103, 46,115,101,116,108,111, + 99, 97,108, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, + 32,109, 97,116,104, 32,108,105, 98,114, 97,114,121, 10,108, + 111, 99, 97,108, 32,109, 97,116,104, 32, 61, 32,109, 97,116, + 104, 10, 97, 98,115, 32, 61, 32,109, 97,116,104, 46, 97, 98, + 115, 10, 97, 99,111,115, 32, 61, 32,102,117,110, 99,116,105, + 111,110, 32, 40,120, 41, 32,114,101,116,117,114,110, 32,109, + 97,116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97, 99, + 111,115, 40,120, 41, 41, 32,101,110,100, 10, 97,115,105,110, + 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,120, 41, + 32,114,101,116,117,114,110, 32,109, 97,116,104, 46,100,101, + 103, 40,109, 97,116,104, 46, 97,115,105,110, 40,120, 41, 41, + 32,101,110,100, 10, 97,116, 97,110, 32, 61, 32,102,117,110, + 99,116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114, + 110, 32,109, 97,116,104, 46,100,101,103, 40,109, 97,116,104, + 46, 97,116, 97,110, 40,120, 41, 41, 32,101,110,100, 10, 97, + 116, 97,110, 50, 32, 61, 32,102,117,110, 99,116,105,111,110, + 32, 40,120, 44,121, 41, 32,114,101,116,117,114,110, 32,109, + 97,116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97,116, + 97,110, 50, 40,120, 44,121, 41, 41, 32,101,110,100, 10, 99, + 101,105,108, 32, 61, 32,109, 97,116,104, 46, 99,101,105,108, + 10, 99,111,115, 32, 61, 32,102,117,110, 99,116,105,111,110, + 32, 40,120, 41, 32,114,101,116,117,114,110, 32,109, 97,116, + 104, 46, 99,111,115, 40,109, 97,116,104, 46,114, 97,100, 40, + 120, 41, 41, 32,101,110,100, 10,100,101,103, 32, 61, 32,109, + 97,116,104, 46,100,101,103, 10,101,120,112, 32, 61, 32,109, + 97,116,104, 46,101,120,112, 10,102,108,111,111,114, 32, 61, + 32,109, 97,116,104, 46,102,108,111,111,114, 10,102,114,101, + 120,112, 32, 61, 32,109, 97,116,104, 46,102,114,101,120,112, + 10,108,100,101,120,112, 32, 61, 32,109, 97,116,104, 46,108, + 100,101,120,112, 10,108,111,103, 32, 61, 32,109, 97,116,104, + 46,108,111,103, 10,108,111,103, 49, 48, 32, 61, 32,109, 97, + 116,104, 46,108,111,103, 49, 48, 10,109, 97,120, 32, 61, 32, + 109, 97,116,104, 46,109, 97,120, 10,109,105,110, 32, 61, 32, + 109, 97,116,104, 46,109,105,110, 10,109,111,100, 32, 61, 32, + 109, 97,116,104, 46,109,111,100, 10, 80, 73, 32, 61, 32,109, + 97,116,104, 46,112,105, 10, 45, 45, 63, 63, 63, 32,112,111, + 119, 32, 61, 32,109, 97,116,104, 46,112,111,119, 32, 32, 10, + 114, 97,100, 32, 61, 32,109, 97,116,104, 46,114, 97,100, 10, + 114, 97,110,100,111,109, 32, 61, 32,109, 97,116,104, 46,114, + 97,110,100,111,109, 10,114, 97,110,100,111,109,115,101,101, + 100, 32, 61, 32,109, 97,116,104, 46,114, 97,110,100,111,109, + 115,101,101,100, 10,115,105,110, 32, 61, 32,102,117,110, 99, + 116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,110, + 32,109, 97,116,104, 46,115,105,110, 40,109, 97,116,104, 46, + 114, 97,100, 40,120, 41, 41, 32,101,110,100, 10,115,113,114, + 116, 32, 61, 32,109, 97,116,104, 46,115,113,114,116, 10,116, + 97,110, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, + 120, 41, 32,114,101,116,117,114,110, 32,109, 97,116,104, 46, + 116, 97,110, 40,109, 97,116,104, 46,114, 97,100, 40,120, 41, + 41, 32,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, + 45, 45, 32,115,116,114,105,110,103, 32,108,105, 98,114, 97, + 114,121, 10,108,111, 99, 97,108, 32,115,116,114, 32, 61, 32, + 115,116,114,105,110,103, 10,115,116,114, 98,121,116,101, 32, + 61, 32,115,116,114, 46, 98,121,116,101, 10,115,116,114, 99, + 104, 97,114, 32, 61, 32,115,116,114, 46, 99,104, 97,114, 10, + 115,116,114,102,105,110,100, 32, 61, 32,115,116,114, 46,102, + 105,110,100, 10,102,111,114,109, 97,116, 32, 61, 32,115,116, + 114, 46,102,111,114,109, 97,116, 10,103,115,117, 98, 32, 61, + 32,115,116,114, 46,103,115,117, 98, 10,115,116,114,108,101, + 110, 32, 61, 32,115,116,114, 46,108,101,110, 10,115,116,114, + 108,111,119,101,114, 32, 61, 32,115,116,114, 46,108,111,119, + 101,114, 10,115,116,114,114,101,112, 32, 61, 32,115,116,114, + 46,114,101,112, 10,115,116,114,115,117, 98, 32, 61, 32,115, + 116,114, 46,115,117, 98, 10,115,116,114,117,112,112,101,114, + 32, 61, 32,115,116,114, 46,117,112,112,101,114, 10, 10, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,111,115, 32,108,105, + 98,114, 97,114,121, 10, 99,108,111, 99,107, 32, 61, 32,111, + 115, 46, 99,108,111, 99,107, 10,100, 97,116,101, 32, 61, 32, + 111,115, 46,100, 97,116,101, 10,100,105,102,102,116,105,109, + 101, 32, 61, 32,111,115, 46,100,105,102,102,116,105,109,101, + 10,101,120,101, 99,117,116,101, 32, 61, 32,111,115, 46,101, + 120,101, 99,117,116,101, 32, 45, 45, 63, 10,101,120,105,116, + 32, 61, 32,111,115, 46,101,120,105,116, 10,103,101,116,101, + 110,118, 32, 61, 32,111,115, 46,103,101,116,101,110,118, 10, + 114,101,109,111,118,101, 32, 61, 32,111,115, 46,114,101,109, + 111,118,101, 10,114,101,110, 97,109,101, 32, 61, 32,111,115, + 46,114,101,110, 97,109,101, 10,115,101,116,108,111, 99, 97, + 108,101, 32, 61, 32,111,115, 46,115,101,116,108,111, 99, 97, + 108,101, 10,116,105,109,101, 32, 61, 32,111,115, 46,116,105, + 109,101, 10,116,109,112,110, 97,109,101, 32, 61, 32,111,115, + 46,116,109,112,110, 97,109,101, 10, 10, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 10, 45, 45, 32, 99,111,109,112, 97,116,105, 98,105, + 108,105,116,121, 32,111,110,108,121, 10,103,101,116,103,108, + 111, 98, 97,108, 32, 61, 32,102,117,110, 99,116,105,111,110, + 32, 40,110, 41, 32,114,101,116,117,114,110, 32, 95, 71, 91, + 110, 93, 32,101,110,100, 10,115,101,116,103,108,111, 98, 97, + 108, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,110, + 44,118, 41, 32, 95, 71, 91,110, 93, 32, 61, 32,118, 32,101, + 110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10,108,111, + 99, 97,108, 32,105,111, 44, 32,116, 97, 98, 32, 61, 32,105, + 111, 44, 32,116, 97, 98,108,101, 10, 10, 45, 45, 32, 73, 79, + 32,108,105, 98,114, 97,114,121, 32, 40,102,105,108,101,115, + 41, 10, 95, 83, 84, 68, 73, 78, 32, 61, 32,105,111, 46,115, + 116,100,105,110, 10, 95, 83, 84, 68, 69, 82, 82, 32, 61, 32, + 105,111, 46,115,116,100,101,114,114, 10, 95, 83, 84, 68, 79, + 85, 84, 32, 61, 32,105,111, 46,115,116,100,111,117,116, 10, + 95, 73, 78, 80, 85, 84, 32, 61, 32,105,111, 46,115,116,100, + 105,110, 10, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,105,111, + 46,115,116,100,111,117,116, 10,115,101,101,107, 32, 61, 32, + 105,111, 46,115,116,100,105,110, 46,115,101,101,107, 32, 32, + 32, 45, 45, 32,115,105, 99,107, 32, 59, 45, 41, 10,116,109, + 112,102,105,108,101, 32, 61, 32,105,111, 46,116,109,112,102, + 105,108,101, 10, 99,108,111,115,101,102,105,108,101, 32, 61, + 32,105,111, 46, 99,108,111,115,101, 10,111,112,101,110,102, + 105,108,101, 32, 61, 32,105,111, 46,111,112,101,110, 10, 10, + 102,117,110, 99,116,105,111,110, 32,102,108,117,115,104, 32, + 40,102, 41, 10, 32, 32,105,102, 32,102, 32,116,104,101,110, + 32,102, 58,102,108,117,115,104, 40, 41, 10, 32, 32,101,108, + 115,101, 32, 95, 79, 85, 84, 80, 85, 84, 58,102,108,117,115, + 104, 40, 41, 10, 32, 32,101,110,100, 10,101,110,100, 10, 10, + 102,117,110, 99,116,105,111,110, 32,114,101, 97,100,102,114, + 111,109, 32, 40,110, 97,109,101, 41, 10, 32, 32,105,102, 32, + 110, 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101, + 110, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 44, 32, + 101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46, 99, + 108,111,115,101, 40, 95, 73, 78, 80, 85, 84, 41, 10, 32, 32, + 32, 32, 95, 73, 78, 80, 85, 84, 32, 61, 32,105,111, 46,115, + 116,100,105,110, 10, 32, 32, 32, 32,114,101,116,117,114,110, + 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, 32, 32, + 101,108,115,101, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, + 102, 44, 32,101,114,114, 44, 32, 99,111,100, 32, 61, 32,105, + 111, 46,111,112,101,110, 40,110, 97,109,101, 44, 32, 34,114, + 34, 41, 10, 32, 32, 32, 32, 95, 73, 78, 80, 85, 84, 32, 61, + 32,102, 32,111,114, 32, 95, 73, 78, 80, 85, 84, 10, 32, 32, + 32, 32,114,101,116,117,114,110, 32,102, 44, 32,101,114,114, + 44, 32, 99,111,100, 10, 32, 32,101,110,100, 10,101,110,100, + 10, 10,102,117,110, 99,116,105,111,110, 32,119,114,105,116, + 101,116,111, 32, 40,110, 97,109,101, 41, 10, 32, 32,105,102, + 32,110, 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104, + 101,110, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 44, + 32,101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46, + 99,108,111,115,101, 40, 95, 79, 85, 84, 80, 85, 84, 41, 10, + 32, 32, 32, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,105, + 111, 46,115,116,100,111,117,116, 10, 32, 32, 32, 32,114,101, + 116,117,114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111, + 100, 10, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,108,111, + 99, 97,108, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, + 32, 61, 32,105,111, 46,111,112,101,110, 40,110, 97,109,101, + 44, 32, 34,119, 34, 41, 10, 32, 32, 32, 32, 95, 79, 85, 84, + 80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 79, 85, 84, + 80, 85, 84, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, + 102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, 32, 32,101, + 110,100, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111, + 110, 32, 97,112,112,101,110,100,116,111, 32, 40,110, 97,109, + 101, 41, 10, 32, 32,108,111, 99, 97,108, 32,102, 44, 32,101, + 114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46,111,112, + 101,110, 40,110, 97,109,101, 44, 32, 34, 97, 34, 41, 10, 32, + 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,102, 32,111,114, + 32, 95, 79, 85, 84, 80, 85, 84, 10, 32, 32,114,101,116,117, + 114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, + 101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,114, + 101, 97,100, 32, 40, 46, 46, 46, 41, 10, 32, 32,108,111, 99, + 97,108, 32,102, 32, 61, 32, 95, 73, 78, 80, 85, 84, 10, 32, + 32,105,102, 32,114, 97,119,116,121,112,101, 40, 97,114,103, + 91, 49, 93, 41, 32, 61, 61, 32, 39,117,115,101,114,100, 97, + 116, 97, 39, 32,116,104,101,110, 10, 32, 32, 32, 32,102, 32, + 61, 32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114, + 103, 44, 32, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,114, + 101,116,117,114,110, 32,102, 58,114,101, 97,100, 40,117,110, + 112, 97, 99,107, 40, 97,114,103, 41, 41, 10,101,110,100, 10, + 10,102,117,110, 99,116,105,111,110, 32,119,114,105,116,101, + 32, 40, 46, 46, 46, 41, 10, 32, 32,108,111, 99, 97,108, 32, + 102, 32, 61, 32, 95, 79, 85, 84, 80, 85, 84, 10, 32, 32,105, + 102, 32,114, 97,119,116,121,112,101, 40, 97,114,103, 91, 49, + 93, 41, 32, 61, 61, 32, 39,117,115,101,114,100, 97,116, 97, + 39, 32,116,104,101,110, 10, 32, 32, 32, 32,102, 32, 61, 32, + 116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103, 44, + 32, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,114,101,116, + 117,114,110, 32,102, 58,119,114,105,116,101, 40,117,110,112, + 97, 99,107, 40, 97,114,103, 41, 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/compat.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32, 98, 97,115,105, 99, + 32,117,116,105,108,105,116,121, 32,102,117,110, 99,116,105, + 111,110,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, 32, + 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,108, + 101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, 80, + 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, 49, + 57, 57, 56, 10, 45, 45, 32, 76, 97,115,116, 32,117,112,100, + 97,116,101, 58, 32, 65,112,114, 32, 50, 48, 48, 51, 10, 45, + 45, 32, 36, 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104, + 105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101, + 32,115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32, + 99, 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116, + 101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100, + 105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32, + 115,111,102,116,119, 97,114,101, 32,112,114,111,118,105,100, + 101,100, 32,104,101,114,101,117,110,100,101,114, 32,105,115, + 32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, + 98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116, + 104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110, + 111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111, + 32,112,114,111,118,105,100,101, 32,109, 97,105,110,116,101, + 110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44, + 32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110, + 104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32, + 109,111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10, + 10, 10, 45, 45, 32, 66, 97,115,105, 99, 32, 67, 32,116,121, + 112,101,115, 32, 97,110,100, 32,116,104,101,105,114, 32, 99, + 111,114,114,101,115,112,111,110,100,105,110,103, 32, 76,117, + 97, 32,116,121,112,101,115, 10, 45, 45, 32, 65,108,108, 32, + 111, 99, 99,117,114,114,101,110, 99,101,115, 32,111,102, 32, + 34, 99,104, 97,114, 42, 34, 32,119,105,108,108, 32, 98,101, + 32,114,101,112,108, 97, 99,101,100, 32, 98,121, 32, 34, 95, + 99,115,116,114,105,110,103, 34, 44, 10, 45, 45, 32, 97,110, + 100, 32, 97,108,108, 32,111, 99, 99,117,114,114,101,110, 99, + 101,115, 32,111,102, 32, 34,118,111,105,100, 42, 34, 32,119, + 105,108,108, 32, 98,101, 32,114,101,112,108, 97, 99,101,100, + 32, 98,121, 32, 34, 95,117,115,101,114,100, 97,116, 97, 34, + 10, 95, 98, 97,115,105, 99, 32, 61, 32,123, 10, 32, 91, 39, + 118,111,105,100, 39, 93, 32, 61, 32, 39, 39, 44, 10, 32, 91, + 39, 99,104, 97,114, 39, 93, 32, 61, 32, 39,110,117,109, 98, + 101,114, 39, 44, 10, 32, 91, 39,105,110,116, 39, 93, 32, 61, + 32, 39,110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39,115, + 104,111,114,116, 39, 93, 32, 61, 32, 39,110,117,109, 98,101, + 114, 39, 44, 10, 32, 91, 39,108,111,110,103, 39, 93, 32, 61, + 32, 39,110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39,117, + 110,115,105,103,110,101,100, 39, 93, 32, 61, 32, 39,110,117, + 109, 98,101,114, 39, 44, 10, 32, 91, 39,102,108,111, 97,116, + 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44, 10, + 32, 91, 39,100,111,117, 98,108,101, 39, 93, 32, 61, 32, 39, + 110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39, 95, 99,115, + 116,114,105,110,103, 39, 93, 32, 61, 32, 39,115,116,114,105, + 110,103, 39, 44, 10, 32, 91, 39, 95,117,115,101,114,100, 97, + 116, 97, 39, 93, 32, 61, 32, 39,117,115,101,114,100, 97,116, + 97, 39, 44, 10, 32, 91, 39, 99,104, 97,114, 42, 39, 93, 32, + 61, 32, 39,115,116,114,105,110,103, 39, 44, 10, 32, 91, 39, + 118,111,105,100, 42, 39, 93, 32, 61, 32, 39,117,115,101,114, + 100, 97,116, 97, 39, 44, 10, 32, 91, 39, 98,111,111,108, 39, + 93, 32, 61, 32, 39, 98,111,111,108,101, 97,110, 39, 44, 10, + 32, 91, 39,108,117, 97, 95, 79, 98,106,101, 99,116, 39, 93, + 32, 61, 32, 39,118, 97,108,117,101, 39, 44, 10, 32, 91, 39, + 76, 85, 65, 95, 86, 65, 76, 85, 69, 39, 93, 32, 61, 32, 39, + 118, 97,108,117,101, 39, 44, 32, 32, 32, 32, 45, 45, 32,102, + 111,114, 32, 99,111,109,112, 97,116,105, 98,105,108,105,116, + 121, 32,119,105,116,104, 32,116,111,108,117, 97, 32, 52, 46, + 48, 10, 32, 91, 39,108,117, 97, 95, 83,116, 97,116,101, 42, + 39, 93, 32, 61, 32, 39,115,116, 97,116,101, 39, 44, 10, 32, + 91, 39, 95,108,115,116, 97,116,101, 39, 93, 32, 61, 32, 39, + 115,116, 97,116,101, 39, 44, 10, 32, 91, 39,108,117, 97, 95, + 70,117,110, 99,116,105,111,110, 39, 93, 32, 61, 32, 39,118, + 97,108,117,101, 39, 44, 10,125, 10, 10, 95, 98, 97,115,105, + 99, 95, 99,116,121,112,101, 32, 61, 32,123, 10, 32,110,117, + 109, 98,101,114, 32, 61, 32, 34,108,117, 97, 95, 78,117,109, + 98,101,114, 34, 44, 10, 32,115,116,114,105,110,103, 32, 61, + 32, 34, 99,111,110,115,116, 32, 99,104, 97,114, 42, 34, 44, + 10, 32,117,115,101,114,100, 97,116, 97, 32, 61, 32, 34,118, + 111,105,100, 42, 34, 44, 10, 32, 98,111,111,108,101, 97,110, + 32, 61, 32, 34, 98,111,111,108, 34, 44, 10, 32,118, 97,108, + 117,101, 32, 61, 32, 34,105,110,116, 34, 44, 10, 32,115,116, + 97,116,101, 32, 61, 32, 34,108,117, 97, 95, 83,116, 97,116, + 101, 42, 34, 44, 10,125, 10, 10, 45, 45, 32,102,117,110, 99, + 116,105,111,110,115, 32,116,104,101, 32, 97,114,101, 32,117, + 115,101,100, 32,116,111, 32,100,111, 32, 97, 32, 39,114, 97, + 119, 32,112,117,115,104, 39, 32,111,102, 32, 98, 97,115,105, + 99, 32,116,121,112,101,115, 10, 95, 98, 97,115,105, 99, 95, + 114, 97,119, 95,112,117,115,104, 32, 61, 32,123,125, 10, 10, + 45, 45, 32, 76,105,115,116, 32,111,102, 32,117,115,101,114, + 32,100,101,102,105,110,101,100, 32,116,121,112,101,115, 10, + 45, 45, 32, 69, 97, 99,104, 32,116,121,112,101, 32, 99,111, + 114,114,101,115,112,111,110,100,115, 32,116,111, 32, 97, 32, + 118, 97,114,105, 97, 98,108,101, 32,110, 97,109,101, 32,116, + 104, 97,116, 32,115,116,111,114,101,115, 32,105,116,115, 32, + 116, 97,103, 32,118, 97,108,117,101, 46, 10, 95,117,115,101, + 114,116,121,112,101, 32, 61, 32,123,125, 10, 10, 45, 45, 32, + 76,105,115,116, 32,111,102, 32,116,121,112,101,115, 32,116, + 104, 97,116, 32,104, 97,118,101, 32,116,111, 32, 98,101, 32, + 99,111,108,108,101, 99,116,101,100, 10, 95, 99,111,108,108, + 101, 99,116, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,105, + 115,116, 32,111,102, 32,116,121,112,101,115, 10, 95,103,108, + 111, 98, 97,108, 95,116,121,112,101,115, 32, 61, 32,123,110, + 61, 48,125, 10, 95,103,108,111, 98, 97,108, 95,116,121,112, + 101,115, 95,104, 97,115,104, 32, 61, 32,123,125, 10, 10, 45, + 45, 32,108,105,115,116, 32,111,102, 32, 99,108, 97,115,115, + 101,115, 10, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115, + 115,101,115, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,105, + 115,116, 32,111,102, 32,101,110,117,109, 32, 99,111,110,115, + 116, 97,110,116,115, 10, 95,103,108,111, 98, 97,108, 95,101, + 110,117,109,115, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76, + 105,115,116, 32,111,102, 32, 97,117,116,111, 32,114,101,110, + 97,109,105,110,103, 10, 95,114,101,110, 97,109,105,110,103, + 32, 61, 32,123,125, 10,102,117,110, 99,116,105,111,110, 32, + 97,112,112,101,110,100,114,101,110, 97,109,105,110,103, 32, + 40,115, 41, 10, 32,108,111, 99, 97,108, 32, 98, 44,101, 44, + 111,108,100, 44,110,101,119, 32, 61, 32,115,116,114,102,105, + 110,100, 40,115, 44, 34, 37,115, 42, 40, 46, 45, 41, 37,115, + 42, 64, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 36, 34, 41, + 10, 9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, + 10, 9, 32,101,114,114,111,114, 40, 34, 35, 73,110,118, 97, + 108,105,100, 32,114,101,110, 97,109,105,110,103, 32,115,121, + 110,116, 97,120, 59, 32,105,116, 32,115,104,111,117,108,100, + 32, 98,101, 32,111,102, 32,116,104,101, 32,102,111,114,109, + 58, 32,112, 97,116,116,101,114,110, 64,112, 97,116,116,101, + 114,110, 34, 41, 10, 9,101,110,100, 10, 9,116,105,110,115, + 101,114,116, 40, 95,114,101,110, 97,109,105,110,103, 44,123, + 111,108,100, 61,111,108,100, 44, 32,110,101,119, 61,110,101, + 119,125, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105, + 111,110, 32, 97,112,112,108,121,114,101,110, 97,109,105,110, + 103, 32, 40,115, 41, 10, 9,102,111,114, 32,105, 61, 49, 44, + 103,101,116,110, 40, 95,114,101,110, 97,109,105,110,103, 41, + 32,100,111, 10, 9, 32,108,111, 99, 97,108, 32,109, 44,110, + 32, 61, 32,103,115,117, 98, 40,115, 44, 95,114,101,110, 97, + 109,105,110,103, 91,105, 93, 46,111,108,100, 44, 95,114,101, + 110, 97,109,105,110,103, 91,105, 93, 46,110,101,119, 41, 10, + 9, 9,105,102, 32,110, 32,126, 61, 32, 48, 32,116,104,101, + 110, 10, 9, 9, 32,114,101,116,117,114,110, 32,109, 10, 9, + 9,101,110,100, 10, 9,101,110,100, 10, 9,114,101,116,117, + 114,110, 32,110,105,108, 10,101,110,100, 10, 10, 45, 45, 32, + 69,114,114,111,114, 32,104, 97,110,100,108,101,114, 10,102, + 117,110, 99,116,105,111,110, 32,116,111,108,117, 97, 95,101, + 114,114,111,114, 32, 40,115, 44,102, 41, 10,105,102, 32, 95, + 99,117,114,114, 95, 99,111,100,101, 32,116,104,101,110, 10, + 9,112,114,105,110,116, 40, 34, 42, 42, 42, 99,117,114,114, + 32, 99,111,100,101, 32,102,111,114, 32,101,114,114,111,114, + 32,105,115, 32, 34, 46, 46,116,111,115,116,114,105,110,103, + 40, 95, 99,117,114,114, 95, 99,111,100,101, 41, 41, 10, 9, + 112,114,105,110,116, 40,100,101, 98,117,103, 46,116,114, 97, + 99,101, 98, 97, 99,107, 40, 41, 41, 10,101,110,100, 10, 32, + 108,111, 99, 97,108, 32,111,117,116, 32, 61, 32, 95, 79, 85, + 84, 80, 85, 84, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, + 32, 95, 83, 84, 68, 69, 82, 82, 10, 32,105,102, 32,115,116, + 114,115,117, 98, 40,115, 44, 49, 44, 49, 41, 32, 61, 61, 32, + 39, 35, 39, 32,116,104,101,110, 10, 32, 32,119,114,105,116, + 101, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, 58, 32, + 34, 46, 46,115,116,114,115,117, 98, 40,115, 44, 50, 41, 46, + 46, 34, 46, 92,110, 92,110, 34, 41, 10, 32, 32,105,102, 32, + 95, 99,117,114,114, 95, 99,111,100,101, 32,116,104,101,110, + 10, 32, 32, 32,108,111, 99, 97,108, 32, 95, 44, 95, 44,115, + 32, 61, 32,115,116,114,102,105,110,100, 40, 95, 99,117,114, + 114, 95, 99,111,100,101, 44, 34, 94, 37,115, 42, 40, 46, 45, + 92,110, 41, 34, 41, 32, 45, 45, 32,101,120,116,114, 97, 99, + 116, 32,102,105,114,115,116, 32,108,105,110,101, 10, 32, 32, + 32,105,102, 32,115, 61, 61,110,105,108, 32,116,104,101,110, + 32,115, 32, 61, 32, 95, 99,117,114,114, 95, 99,111,100,101, + 32,101,110,100, 10, 32, 32, 32,115, 32, 61, 32,103,115,117, + 98, 40,115, 44, 34, 95,117,115,101,114,100, 97,116, 97, 34, + 44, 34,118,111,105,100, 42, 34, 41, 32, 45, 45, 32,114,101, + 116,117,114,110, 32,119,105,116,104, 32, 39,118,111,105,100, + 42, 39, 10, 32, 32, 32,115, 32, 61, 32,103,115,117, 98, 40, + 115, 44, 34, 95, 99,115,116,114,105,110,103, 34, 44, 34, 99, + 104, 97,114, 42, 34, 41, 32, 32, 45, 45, 32,114,101,116,117, + 114,110, 32,119,105,116,104, 32, 39, 99,104, 97,114, 42, 39, + 10, 32, 32, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44, + 34, 95,108,115,116, 97,116,101, 34, 44, 34,108,117, 97, 95, + 83,116, 97,116,101, 42, 34, 41, 32, 32, 45, 45, 32,114,101, + 116,117,114,110, 32,119,105,116,104, 32, 39,108,117, 97, 95, + 83,116, 97,116,101, 42, 39, 10, 32, 32, 32,119,114,105,116, + 101, 40, 34, 67,111,100,101, 32, 98,101,105,110,103, 32,112, + 114,111, 99,101,115,115,101,100, 58, 92,110, 34, 46, 46,115, + 46, 46, 34, 92,110, 34, 41, 10, 32, 32,101,110,100, 10, 32, + 101,108,115,101, 10, 32,105,102, 32,110,111,116, 32,102, 32, + 116,104,101,110, 32,102, 32, 61, 32, 34, 40,102, 32,105,115, + 32,110,105,108, 41, 34, 32,101,110,100, 10, 32, 32,112,114, + 105,110,116, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, + 32,105,110,116,101,114,110, 97,108, 32,101,114,114,111,114, + 58, 32, 34, 46, 46,102, 46, 46,115, 46, 46, 34, 46, 92,110, + 92,110, 34, 41, 10, 32, 32,114,101,116,117,114,110, 10, 32, + 101,110,100, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32, + 111,117,116, 10,101,110,100, 10, 10,102,117,110, 99,116,105, + 111,110, 32,119, 97,114,110,105,110,103, 32, 40,109,115,103, + 41, 10, 32,105,102, 32,102,108, 97,103,115, 46,113, 32,116, + 104,101,110, 32,114,101,116,117,114,110, 32,101,110,100, 10, + 32,108,111, 99, 97,108, 32,111,117,116, 32, 61, 32, 95, 79, + 85, 84, 80, 85, 84, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, + 61, 32, 95, 83, 84, 68, 69, 82, 82, 10, 32,119,114,105,116, + 101, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, 32,119, + 97,114,110,105,110,103, 58, 32, 34, 46, 46,109,115,103, 46, + 46, 34, 46, 92,110, 92,110, 34, 41, 10, 32, 95, 79, 85, 84, + 80, 85, 84, 32, 61, 32,111,117,116, 10,101,110,100, 10, 10, + 45, 45, 32,114,101,103,105,115,116,101,114, 32, 97,110, 32, + 117,115,101,114, 32,100,101,102,105,110,101,100, 32,116,121, + 112,101, 58, 32,114,101,116,117,114,110,115, 32,102,117,108, + 108, 32,116,121,112,101, 10,102,117,110, 99,116,105,111,110, + 32,114,101,103,116,121,112,101, 32, 40,116, 41, 10, 9, 45, + 45,105,102, 32,105,115, 98, 97,115,105, 99, 40,116, 41, 32, + 116,104,101,110, 10, 9, 45, 45, 9,114,101,116,117,114,110, + 32,116, 10, 9, 45, 45,101,110,100, 10, 9,108,111, 99, 97, + 108, 32,102,116, 32, 61, 32,102,105,110,100,116,121,112,101, + 40,116, 41, 10, 10, 9,105,102, 32,110,111,116, 32, 95,117, + 115,101,114,116,121,112,101, 91,102,116, 93, 32,116,104,101, + 110, 10, 9, 9,114,101,116,117,114,110, 32, 97,112,112,101, + 110,100,117,115,101,114,116,121,112,101, 40,116, 41, 10, 9, + 101,110,100, 10, 9,114,101,116,117,114,110, 32,102,116, 10, + 101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,110, 32, + 116,121,112,101, 32,110, 97,109,101, 58, 32,114,101,116,117, + 114,110,115, 32,102,117,108,108, 32,116,121,112,101, 10,102, + 117,110, 99,116,105,111,110, 32,116,121,112,101,118, 97,114, + 40,116,121,112,101, 41, 10, 9,105,102, 32,116,121,112,101, + 32, 61, 61, 32, 39, 39, 32,111,114, 32,116,121,112,101, 32, + 61, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10, + 9, 9,114,101,116,117,114,110, 32,116,121,112,101, 10, 9, + 101,108,115,101, 10, 9, 9,108,111, 99, 97,108, 32,102,116, + 32, 61, 32,102,105,110,100,116,121,112,101, 40,116,121,112, + 101, 41, 10, 9, 9,105,102, 32,102,116, 32,116,104,101,110, + 10, 9, 9, 9,114,101,116,117,114,110, 32,102,116, 10, 9, + 9,101,110,100, 10, 9, 9, 95,117,115,101,114,116,121,112, + 101, 91,116,121,112,101, 93, 32, 61, 32,116,121,112,101, 10, + 9, 9,114,101,116,117,114,110, 32,116,121,112,101, 10, 9, + 101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, + 99,107, 32,105,102, 32, 98, 97,115,105, 99, 32,116,121,112, + 101, 10,102,117,110, 99,116,105,111,110, 32,105,115, 98, 97, + 115,105, 99, 32, 40,116,121,112,101, 41, 10, 32,108,111, 99, + 97,108, 32,116, 32, 61, 32,103,115,117, 98, 40,116,121,112, + 101, 44, 39, 99,111,110,115,116, 32, 39, 44, 39, 39, 41, 10, + 32,108,111, 99, 97,108, 32,109, 44,116, 32, 61, 32, 97,112, + 112,108,121,116,121,112,101,100,101,102, 40, 39, 39, 44, 32, + 116, 41, 10, 32,108,111, 99, 97,108, 32, 98, 32, 61, 32, 95, + 98, 97,115,105, 99, 91,116, 93, 10, 32,105,102, 32, 98, 32, + 116,104,101,110, 10, 32, 32,114,101,116,117,114,110, 32, 98, + 44, 95, 98, 97,115,105, 99, 95, 99,116,121,112,101, 91, 98, + 93, 10, 32,101,110,100, 10, 32,114,101,116,117,114,110, 32, + 110,105,108, 10,101,110,100, 10, 10, 45, 45, 32,115,112,108, + 105,116, 32,115,116,114,105,110,103, 32,117,115,105,110,103, + 32, 97, 32,116,111,107,101,110, 10,102,117,110, 99,116,105, + 111,110, 32,115,112,108,105,116, 32, 40,115, 44,116, 41, 10, + 32,108,111, 99, 97,108, 32,108, 32, 61, 32,123,110, 61, 48, + 125, 10, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,102,117, + 110, 99,116,105,111,110, 32, 40,115, 41, 10, 32, 32,108, 46, + 110, 32, 61, 32,108, 46,110, 32, 43, 32, 49, 10, 32, 32,108, + 91,108, 46,110, 93, 32, 61, 32,115, 10, 32, 32,114,101,116, + 117,114,110, 32, 34, 34, 10, 32,101,110,100, 10, 32,108,111, + 99, 97,108, 32,112, 32, 61, 32, 34, 37,115, 42, 40, 46, 45, + 41, 37,115, 42, 34, 46, 46,116, 46, 46, 34, 37,115, 42, 34, + 10, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44, 34, 94, + 37,115, 43, 34, 44, 34, 34, 41, 10, 32,115, 32, 61, 32,103, + 115,117, 98, 40,115, 44, 34, 37,115, 43, 36, 34, 44, 34, 34, + 41, 10, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44,112, + 44,102, 41, 10, 32,108, 46,110, 32, 61, 32,108, 46,110, 32, + 43, 32, 49, 10, 32,108, 91,108, 46,110, 93, 32, 61, 32,103, + 115,117, 98, 40,115, 44, 34, 40, 37,115, 37,115, 42, 41, 36, + 34, 44, 34, 34, 41, 10, 32,114,101,116,117,114,110, 32,108, + 10,101,110,100, 10, 10, 45, 45, 32,115,112,108,105,116,115, + 32, 97, 32,115,116,114,105,110,103, 32,117,115,105,110,103, + 32, 97, 32,112, 97,116,116,101,114,110, 44, 32, 99,111,110, + 115,105,100,101,114,105,110,103, 32,116,104,101, 32,115,112, + 97, 99,105, 97,108, 32, 99, 97,115,101,115, 32,111,102, 32, + 67, 32, 99,111,100,101, 32, 40,116,101,109,112,108, 97,116, + 101,115, 44, 32,102,117,110, 99,116,105,111,110, 32,112, 97, + 114, 97,109,101,116,101,114,115, 44, 32,101,116, 99, 41, 10, + 45, 45, 32,112, 97,116,116,101,114,110, 32, 99, 97,110, 39, + 116, 32, 99,111,110,116, 97,105,110, 32,116,104,101, 32, 39, + 94, 39, 32, 40, 97,115, 32,117,115,101,100, 32,116,111, 32, + 105,100,101,110,116,105,102,121, 32,116,104,101, 32, 98,101, + 103,105,110,105,110,103, 32,111,102, 32,116,104,101, 32,108, + 105,110,101, 41, 10, 45, 45, 32, 97,108,115,111, 32,115,116, + 114,105,112,115, 32,119,104,105,116,101,115,112, 97, 99,101, + 10,102,117,110, 99,116,105,111,110, 32,115,112,108,105,116, + 95, 99, 95,116,111,107,101,110,115, 40,115, 44, 32,112, 97, + 116, 41, 10, 10, 9,115, 32, 61, 32,115,116,114,105,110,103, + 46,103,115,117, 98, 40,115, 44, 32, 34, 94, 37,115, 42, 34, + 44, 32, 34, 34, 41, 10, 9,115, 32, 61, 32,115,116,114,105, + 110,103, 46,103,115,117, 98, 40,115, 44, 32, 34, 37,115, 42, + 36, 34, 44, 32, 34, 34, 41, 10, 10, 9,108,111, 99, 97,108, + 32,116,111,107,101,110, 95, 98,101,103,105,110, 32, 61, 32, + 49, 10, 9,108,111, 99, 97,108, 32,116,111,107,101,110, 95, + 101,110,100, 32, 61, 32, 49, 10, 9,108,111, 99, 97,108, 32, + 111,102,115, 32, 61, 32, 49, 10, 9,108,111, 99, 97,108, 32, + 114,101,116, 32, 61, 32,123,110, 61, 48,125, 10, 10, 9,102, + 117,110, 99,116,105,111,110, 32, 97,100,100, 95,116,111,107, + 101,110, 40,111,102,115, 41, 10, 10, 9, 9,108,111, 99, 97, + 108, 32,116, 32, 61, 32,115,116,114,105,110,103, 46,115,117, + 98, 40,115, 44, 32,116,111,107,101,110, 95, 98,101,103,105, + 110, 44, 32,111,102,115, 41, 10, 9, 9,116, 32, 61, 32,115, + 116,114,105,110,103, 46,103,115,117, 98, 40,116, 44, 32, 34, + 94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10, 9, 9,116, 32, + 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116, + 44, 32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 10, 9, + 9,114,101,116, 46,110, 32, 61, 32,114,101,116, 46,110, 32, + 43, 32, 49, 10, 9, 9,114,101,116, 91,114,101,116, 46,110, + 93, 32, 61, 32,116, 10, 9,101,110,100, 10, 10, 9,119,104, + 105,108,101, 32,111,102,115, 32, 60, 61, 32,115,116,114,105, + 110,103, 46,108,101,110, 40,115, 41, 32,100,111, 10, 10, 9, + 9,108,111, 99, 97,108, 32,115,117, 98, 32, 61, 32,115,116, + 114,105,110,103, 46,115,117, 98, 40,115, 44, 32,111,102,115, + 44, 32, 45, 49, 41, 10, 9, 9,108,111, 99, 97,108, 32, 98, + 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110, + 100, 40,115,117, 98, 44, 32, 34, 94, 34, 46, 46,112, 97,116, + 41, 10, 9, 9,105,102, 32, 98, 32,116,104,101,110, 10, 9, + 9, 9, 97,100,100, 95,116,111,107,101,110, 40,111,102,115, + 45, 49, 41, 10, 9, 9, 9,111,102,115, 32, 61, 32,111,102, + 115, 43,101, 10, 9, 9, 9,116,111,107,101,110, 95, 98,101, + 103,105,110, 32, 61, 32,111,102,115, 10, 9, 9,101,108,115, + 101, 10, 9, 9, 9,108,111, 99, 97,108, 32, 99,104, 97,114, + 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,115, + 44, 32,111,102,115, 44, 32,111,102,115, 41, 10, 9, 9, 9, + 105,102, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 40, 34, 32, + 111,114, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 60, 34, 32, + 116,104,101,110, 10, 10, 9, 9, 9, 9,108,111, 99, 97,108, + 32, 98,108,111, 99,107, 10, 9, 9, 9, 9,105,102, 32, 99, + 104, 97,114, 32, 61, 61, 32, 34, 40, 34, 32,116,104,101,110, + 32, 98,108,111, 99,107, 32, 61, 32, 34, 94, 37, 98, 40, 41, + 34, 32,101,110,100, 10, 9, 9, 9, 9,105,102, 32, 99,104, + 97,114, 32, 61, 61, 32, 34, 60, 34, 32,116,104,101,110, 32, + 98,108,111, 99,107, 32, 61, 32, 34, 94, 37, 98, 60, 62, 34, + 32,101,110,100, 10, 10, 9, 9, 9, 9, 98, 44,101, 32, 61, + 32,115,116,114,105,110,103, 46,102,105,110,100, 40,115,117, + 98, 44, 32, 98,108,111, 99,107, 41, 10, 9, 9, 9, 9,105, + 102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10, 9, 9, + 9, 9, 9, 45, 45, 32,117,110,116,101,114,109,105,110, 97, + 116,101,100, 32, 98,108,111, 99,107, 63, 10, 9, 9, 9, 9, + 9,111,102,115, 32, 61, 32,111,102,115, 43, 49, 10, 9, 9, + 9, 9,101,108,115,101, 10, 9, 9, 9, 9, 9,111,102,115, + 32, 61, 32,111,102,115, 32, 43, 32,101, 10, 9, 9, 9, 9, + 101,110,100, 10, 10, 9, 9, 9,101,108,115,101, 10, 9, 9, + 9, 9,111,102,115, 32, 61, 32,111,102,115, 43, 49, 10, 9, + 9, 9,101,110,100, 10, 9, 9,101,110,100, 10, 10, 9,101, + 110,100, 10, 9, 97,100,100, 95,116,111,107,101,110, 40,111, + 102,115, 41, 10, 9, 45, 45,105,102, 32,114,101,116, 46,110, + 32, 61, 61, 32, 48, 32,116,104,101,110, 10, 10, 9, 45, 45, + 9,114,101,116, 46,110, 61, 49, 10, 9, 45, 45, 9,114,101, + 116, 91, 49, 93, 32, 61, 32, 34, 34, 10, 9, 45, 45,101,110, + 100, 10, 10, 9,114,101,116,117,114,110, 32,114,101,116, 10, + 10,101,110,100, 10, 10, 45, 45, 32, 99,111,110, 99, 97,116, + 101,110, 97,116,101, 32,115,116,114,105,110,103,115, 32,111, + 102, 32, 97, 32,116, 97, 98,108,101, 10,102,117,110, 99,116, + 105,111,110, 32, 99,111,110, 99, 97,116, 32, 40,116, 44,102, + 44,108, 44,106,115,116,114, 41, 10, 9,106,115,116,114, 32, + 61, 32,106,115,116,114, 32,111,114, 32, 34, 32, 34, 10, 32, + 108,111, 99, 97,108, 32,115, 32, 61, 32, 39, 39, 10, 32,108, + 111, 99, 97,108, 32,105, 61,102, 10, 32,119,104,105,108,101, + 32,105, 60, 61,108, 32,100,111, 10, 32, 32,115, 32, 61, 32, + 115, 46, 46,116, 91,105, 93, 10, 32, 32,105, 32, 61, 32,105, + 43, 49, 10, 32, 32,105,102, 32,105, 32, 60, 61, 32,108, 32, + 116,104,101,110, 32,115, 32, 61, 32,115, 46, 46,106,115,116, + 114, 32,101,110,100, 10, 32,101,110,100, 10, 32,114,101,116, + 117,114,110, 32,115, 10,101,110,100, 10, 10, 45, 45, 32, 99, + 111,110, 99, 97,116,101,110, 97,116,101, 32, 97,108,108, 32, + 112, 97,114, 97,109,101,116,101,114,115, 44, 32,102,111,108, + 108,111,119,105,110,103, 32,111,117,116,112,117,116, 32,114, + 117,108,101,115, 10,102,117,110, 99,116,105,111,110, 32, 99, + 111,110, 99, 97,116,112, 97,114, 97,109, 32, 40,108,105,110, + 101, 44, 32, 46, 46, 46, 41, 10, 32,108,111, 99, 97,108, 32, + 105, 61, 49, 10, 32,119,104,105,108,101, 32,105, 60, 61, 97, + 114,103, 46,110, 32,100,111, 10, 32, 32,105,102, 32, 95, 99, + 111,110,116, 32, 97,110,100, 32,110,111,116, 32,115,116,114, + 102,105,110,100, 40, 95, 99,111,110,116, 44, 39, 91, 37, 40, + 44, 34, 93, 39, 41, 32, 97,110,100, 10, 32, 32, 32, 32, 32, + 115,116,114,102,105,110,100, 40, 97,114,103, 91,105, 93, 44, + 34, 94, 91, 37, 97, 95,126, 93, 34, 41, 32,116,104,101,110, + 10, 9, 32, 32, 32, 32,108,105,110,101, 32, 61, 32,108,105, + 110,101, 32, 46, 46, 32, 39, 32, 39, 10, 32, 32,101,110,100, + 10, 32, 32,108,105,110,101, 32, 61, 32,108,105,110,101, 32, + 46, 46, 32, 97,114,103, 91,105, 93, 10, 32, 32,105,102, 32, + 97,114,103, 91,105, 93, 32,126, 61, 32, 39, 39, 32,116,104, + 101,110, 10, 32, 32, 32, 95, 99,111,110,116, 32, 61, 32,115, + 116,114,115,117, 98, 40, 97,114,103, 91,105, 93, 44, 45, 49, + 44, 45, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,105, 32, + 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,105,102, 32, + 115,116,114,102,105,110,100, 40, 97,114,103, 91, 97,114,103, + 46,110, 93, 44, 34, 91, 37, 47, 37, 41, 37, 59, 37,123, 37, + 125, 93, 36, 34, 41, 32,116,104,101,110, 10, 32, 32, 95, 99, + 111,110,116, 61,110,105,108, 32,108,105,110,101, 32, 61, 32, + 108,105,110,101, 32, 46, 46, 32, 39, 92,110, 39, 10, 32,101, + 110,100, 10, 9,114,101,116,117,114,110, 32,108,105,110,101, + 10,101,110,100, 10, 10, 45, 45, 32,111,117,116,112,117,116, + 32,108,105,110,101, 10,102,117,110, 99,116,105,111,110, 32, + 111,117,116,112,117,116, 32, 40, 46, 46, 46, 41, 10, 32,108, + 111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,101, + 32,105, 60, 61, 97,114,103, 46,110, 32,100,111, 10, 32, 32, + 105,102, 32, 95, 99,111,110,116, 32, 97,110,100, 32,110,111, + 116, 32,115,116,114,102,105,110,100, 40, 95, 99,111,110,116, + 44, 39, 91, 37, 40, 44, 34, 93, 39, 41, 32, 97,110,100, 10, + 32, 32, 32, 32, 32,115,116,114,102,105,110,100, 40, 97,114, + 103, 91,105, 93, 44, 34, 94, 91, 37, 97, 95,126, 93, 34, 41, + 32,116,104,101,110, 10, 9, 32, 32, 32, 32,119,114,105,116, + 101, 40, 39, 32, 39, 41, 10, 32, 32,101,110,100, 10, 32, 32, + 119,114,105,116,101, 40, 97,114,103, 91,105, 93, 41, 10, 32, + 32,105,102, 32, 97,114,103, 91,105, 93, 32,126, 61, 32, 39, + 39, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,111,110,116, + 32, 61, 32,115,116,114,115,117, 98, 40, 97,114,103, 91,105, + 93, 44, 45, 49, 44, 45, 49, 41, 10, 32, 32,101,110,100, 10, + 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, + 32,105,102, 32,115,116,114,102,105,110,100, 40, 97,114,103, + 91, 97,114,103, 46,110, 93, 44, 34, 91, 37, 47, 37, 41, 37, + 59, 37,123, 37,125, 93, 36, 34, 41, 32,116,104,101,110, 10, + 32, 32, 95, 99,111,110,116, 61,110,105,108, 32,119,114,105, + 116,101, 40, 39, 92,110, 39, 41, 10, 32,101,110,100, 10,101, + 110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,103,101, + 116, 95,112,114,111,112,101,114,116,121, 95,109,101,116,104, + 111,100,115, 40,112,116,121,112,101, 44, 32,110, 97,109,101, + 41, 10, 10, 9,105,102, 32,103,101,116, 95,112,114,111,112, + 101,114,116,121, 95,109,101,116,104,111,100,115, 95,104,111, + 111,107, 32, 97,110,100, 32,103,101,116, 95,112,114,111,112, + 101,114,116,121, 95,109,101,116,104,111,100,115, 95,104,111, + 111,107, 40,112,116,121,112,101, 44,110, 97,109,101, 41, 32, + 116,104,101,110, 10, 9, 9,114,101,116,117,114,110, 32,103, + 101,116, 95,112,114,111,112,101,114,116,121, 95,109,101,116, + 104,111,100,115, 95,104,111,111,107, 40,112,116,121,112,101, + 44, 32,110, 97,109,101, 41, 10, 9,101,110,100, 10, 10, 9, + 105,102, 32,112,116,121,112,101, 32, 61, 61, 32, 34,100,101, + 102, 97,117,108,116, 34, 32,116,104,101,110, 32, 45, 45, 32, + 103,101,116, 95,110, 97,109,101, 44, 32,115,101,116, 95,110, + 97,109,101, 10, 9, 9,114,101,116,117,114,110, 32, 34,103, + 101,116, 95, 34, 46, 46,110, 97,109,101, 44, 32, 34,115,101, + 116, 95, 34, 46, 46,110, 97,109,101, 10, 9,101,110,100, 10, + 10, 9,105,102, 32,112,116,121,112,101, 32, 61, 61, 32, 34, + 113,116, 34, 32,116,104,101,110, 32, 45, 45, 32,110, 97,109, + 101, 44, 32,115,101,116, 78, 97,109,101, 10, 9, 9,114,101, + 116,117,114,110, 32,110, 97,109,101, 44, 32, 34,115,101,116, + 34, 46, 46,115,116,114,105,110,103, 46,117,112,112,101,114, + 40,115,116,114,105,110,103, 46,115,117, 98, 40,110, 97,109, + 101, 44, 32, 49, 44, 32, 49, 41, 41, 46, 46,115,116,114,105, + 110,103, 46,115,117, 98, 40,110, 97,109,101, 44, 32, 50, 44, + 32, 45, 49, 41, 10, 9,101,110,100, 10, 10, 9,105,102, 32, + 112,116,121,112,101, 32, 61, 61, 32, 34,111,118,101,114,108, + 111, 97,100, 34, 32,116,104,101,110, 32, 45, 45, 32,110, 97, + 109,101, 44, 32,110, 97,109,101, 10, 9, 9,114,101,116,117, + 114,110, 32,110, 97,109,101, 44,110, 97,109,101, 10, 9,101, + 110,100, 10, 10, 9,114,101,116,117,114,110, 32,110,105,108, + 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 32,116,104,101, 32,104,111,111,107,115, + 10, 10, 45, 45, 32, 99, 97,108,108,101,100, 32,114,105,103, + 104,116, 32, 97,102,116,101,114, 32,112,114,111, 99,101,115, + 115,105,110,103, 32,116,104,101, 32, 36, 91,105, 99,104,108, + 93,102,105,108,101, 32,100,105,114,101, 99,116,105,118,101, + 115, 44, 10, 45, 45, 32,114,105,103,104,116, 32, 98,101,102, + 111,114,101, 32,112,114,111, 99,101,115,115,105,110,103, 32, + 97,110,121,116,104,105,110,103, 32,101,108,115,101, 10, 45, + 45, 32,116, 97,107,101,115, 32,116,104,101, 32,112, 97, 99, + 107, 97,103,101, 32,111, 98,106,101, 99,116, 32, 97,115, 32, + 116,104,101, 32,112, 97,114, 97,109,101,116,101,114, 10,102, + 117,110, 99,116,105,111,110, 32,112,114,101,112,114,111, 99, + 101,115,115, 95,104,111,111,107, 40,112, 41, 10, 9, 45, 45, + 32,112, 46, 99,111,100,101, 32,104, 97,115, 32, 97,108,108, + 32,116,104,101, 32,105,110,112,117,116, 32, 99,111,100,101, + 32,102,114,111,109, 32,116,104,101, 32,112,107,103, 10,101, + 110,100, 10, 10, 10, 45, 45, 32, 99, 97,108,108,101,100, 32, + 102,111,114, 32,101,118,101,114,121, 32, 36,105,102,105,108, + 101, 32,100,105,114,101, 99,116,105,118,101, 10, 45, 45, 32, + 116, 97,107,101,115, 32, 97, 32,116, 97, 98,108,101, 32,119, + 105,116,104, 32, 97, 32,115,116,114,105,110,103, 32, 99, 97, + 108,108,101,100, 32, 39, 99,111,100,101, 39, 32,105,110,115, + 105,100,101, 44, 32,116,104,101, 32,102,105,108,101,110, 97, + 109,101, 44, 32, 97,110,100, 32, 97,110,121, 32,101,120,116, + 114, 97, 32, 97,114,103,117,109,101,110,116,115, 10, 45, 45, + 32,112, 97,115,115,101,100, 32,116,111, 32, 36,105,102,105, + 108,101, 46, 32,110,111, 32,114,101,116,117,114,110, 32,118, + 97,108,117,101, 10,102,117,110, 99,116,105,111,110, 32,105, + 110, 99,108,117,100,101, 95,102,105,108,101, 95,104,111,111, + 107, 40,116, 44, 32,102,105,108,101,110, 97,109,101, 44, 32, + 46, 46, 46, 41, 10, 10,101,110,100, 10, 10, 45, 45, 32, 99, + 97,108,108,101,100, 32, 97,102,116,101,114, 32,112,114,111, + 99,101,115,115,105,110,103, 32, 97,110,121,116,104,105,110, + 103, 32,116,104, 97,116, 39,115, 32,110,111,116, 32, 99,111, + 100,101, 32, 40,108,105,107,101, 32, 39, 36,114,101,110, 97, + 109,105,110,103, 39, 44, 32, 99,111,109,109,101,110,116,115, + 44, 32,101,116, 99, 41, 10, 45, 45, 32, 97,110,100, 32,114, + 105,103,104,116, 32, 98,101,102,111,114,101, 32,112, 97,114, + 115,105,110,103, 32,116,104,101, 32, 97, 99,116,117, 97,108, + 32, 99,111,100,101, 46, 10, 45, 45, 32,116, 97,107,101,115, + 32,116,104,101, 32, 80, 97, 99,107, 97,103,101, 32,111, 98, + 106,101, 99,116, 32,119,105,116,104, 32, 97,108,108, 32,116, + 104,101, 32, 99,111,100,101, 32,111,110, 32,116,104,101, 32, + 39, 99,111,100,101, 39, 32,107,101,121, 46, 32,110,111, 32, + 114,101,116,117,114,110, 32,118, 97,108,117,101, 10,102,117, + 110, 99,116,105,111,110, 32,112,114,101,112, 97,114,115,101, + 95,104,111,111,107, 40,112, 97, 99,107, 97,103,101, 41, 10, + 10,101,110,100, 10, 10, 10, 45, 45, 32, 99, 97,108,108,101, + 100, 32, 97,102,116,101,114, 32,119,114,105,116,105,110,103, + 32, 97,108,108, 32,116,104,101, 32,111,117,116,112,117,116, + 46, 10, 45, 45, 32,116, 97,107,101,115, 32,116,104,101, 32, + 80, 97, 99,107, 97,103,101, 32,111, 98,106,101, 99,116, 10, + 102,117,110, 99,116,105,111,110, 32,112,111,115,116, 95,111, + 117,116,112,117,116, 95,104,111,111,107, 40,112, 97, 99,107, + 97,103,101, 41, 10, 10,101,110,100, 10, 10, 10, 45, 45, 32, + 99, 97,108,108,101,100, 32,102,114,111,109, 32, 39,103,101, + 116, 95,112,114,111,112,101,114,116,121, 95,109,101,116,104, + 111,100,115, 39, 32,116,111, 32,103,101,116, 32,116,104,101, + 32,109,101,116,104,111,100,115, 32,116,111, 32,114,101,116, + 114,105,101,118,101, 32, 97, 32,112,114,111,112,101,114,116, + 121, 10, 45, 45, 32, 97, 99, 99,111,114,100,105,110,103, 32, + 116,111, 32,105,116,115, 32,116,121,112,101, 10,102,117,110, + 99,116,105,111,110, 32,103,101,116, 95,112,114,111,112,101, + 114,116,121, 95,109,101,116,104,111,100,115, 95,104,111,111, + 107, 40,112,114,111,112,101,114,116,121, 95,116,121,112,101, + 44, 32,110, 97,109,101, 41, 10, 10,101,110,100, 10, 10, 45, + 45, 32, 99, 97,108,108,101,100, 32,102,114,111,109, 32, 67, + 108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,100, + 111,112, 97,114,115,101, 32,119,105,116,104, 32,116,104,101, + 32,115,116,114,105,110,103, 32, 98,101,105,110,103, 32,112, + 97,114,115,101,100, 10, 45, 45, 32,114,101,116,117,114,110, + 32,110,105,108, 44, 32,111,114, 32, 97, 32,115,117, 98,115, + 116,114,105,110,103, 10,102,117,110, 99,116,105,111,110, 32, + 112, 97,114,115,101,114, 95,104,111,111,107, 40,115, 41, 10, + 10, 9,114,101,116,117,114,110, 32,110,105,108, 10,101,110, + 100, 10, 10, 45, 45, 32, 99,117,115,116,111,109, 32,112,117, + 115,104,101,114,115, 10, 10, 95,112,117,115,104, 95,102,117, + 110, 99,116,105,111,110,115, 32, 61, 32,123,125, 10, 95,105, + 115, 95,102,117,110, 99,116,105,111,110,115, 32, 61, 32,123, + 125, 10, 95,116,111, 95,102,117,110, 99,116,105,111,110,115, + 32, 61, 32,123,125, 10, 10, 95, 98, 97,115,101, 95,112,117, + 115,104, 95,102,117,110, 99,116,105,111,110,115, 32, 61, 32, + 123,125, 10, 95, 98, 97,115,101, 95,105,115, 95,102,117,110, + 99,116,105,111,110,115, 32, 61, 32,123,125, 10, 95, 98, 97, + 115,101, 95,116,111, 95,102,117,110, 99,116,105,111,110,115, + 32, 61, 32,123,125, 10, 10,108,111, 99, 97,108, 32,102,117, + 110, 99,116,105,111,110, 32,115,101, 97,114, 99,104, 95, 98, + 97,115,101, 40,116, 44, 32,102,117,110, 99,115, 41, 10, 10, + 9,108,111, 99, 97,108, 32, 99,108, 97,115,115, 32, 61, 32, + 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, + 91,116, 93, 10, 10, 9,119,104,105,108,101, 32, 99,108, 97, + 115,115, 32,100,111, 10, 9, 9,105,102, 32,102,117,110, 99, + 115, 91, 99,108, 97,115,115, 46,116,121,112,101, 93, 32,116, + 104,101,110, 10, 9, 9, 9,114,101,116,117,114,110, 32,102, + 117,110, 99,115, 91, 99,108, 97,115,115, 46,116,121,112,101, + 93, 10, 9, 9,101,110,100, 10, 9, 9, 99,108, 97,115,115, + 32, 61, 32, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115, + 115,101,115, 91, 99,108, 97,115,115, 46, 98,116,121,112,101, + 93, 10, 9,101,110,100, 10, 9,114,101,116,117,114,110, 32, + 110,105,108, 10,101,110,100, 10, 10,102,117,110, 99,116,105, + 111,110, 32,103,101,116, 95,112,117,115,104, 95,102,117,110, + 99,116,105,111,110, 40,116, 41, 10, 9,114,101,116,117,114, + 110, 32, 95,112,117,115,104, 95,102,117,110, 99,116,105,111, + 110,115, 91,116, 93, 32,111,114, 32,115,101, 97,114, 99,104, + 95, 98, 97,115,101, 40,116, 44, 32, 95, 98, 97,115,101, 95, + 112,117,115,104, 95,102,117,110, 99,116,105,111,110,115, 41, + 32,111,114, 32, 34,116,111,108,117, 97, 95,112,117,115,104, + 117,115,101,114,116,121,112,101, 34, 10,101,110,100, 10, 10, + 102,117,110, 99,116,105,111,110, 32,103,101,116, 95,116,111, + 95,102,117,110, 99,116,105,111,110, 40,116, 41, 10, 9,114, + 101,116,117,114,110, 32, 95,116,111, 95,102,117,110, 99,116, + 105,111,110,115, 91,116, 93, 32,111,114, 32,115,101, 97,114, + 99,104, 95, 98, 97,115,101, 40,116, 44, 32, 95, 98, 97,115, + 101, 95,116,111, 95,102,117,110, 99,116,105,111,110,115, 41, + 32,111,114, 32, 34,116,111,108,117, 97, 95,116,111,117,115, + 101,114,116,121,112,101, 34, 10,101,110,100, 10, 10,102,117, + 110, 99,116,105,111,110, 32,103,101,116, 95,105,115, 95,102, + 117,110, 99,116,105,111,110, 40,116, 41, 10, 9,114,101,116, + 117,114,110, 32, 95,105,115, 95,102,117,110, 99,116,105,111, + 110,115, 91,116, 93, 32,111,114, 32,115,101, 97,114, 99,104, + 95, 98, 97,115,101, 40,116, 44, 32, 95, 98, 97,115,101, 95, + 105,115, 95,102,117,110, 99,116,105,111,110,115, 41, 32,111, + 114, 32, 34,116,111,108,117, 97, 95,105,115,117,115,101,114, + 116,121,112,101, 34, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/basic.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32, 97, 98,115,116,114, + 97, 99,116, 32,102,101, 97,116,117,114,101, 32, 99,108, 97, + 115,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, 32, 98, + 121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,108,101, + 115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, 80, 85, + 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, 49, 57, + 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10, 10, 45, + 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,105,115, 32, + 102,114,101,101, 32,115,111,102,116,119, 97,114,101, 59, 32, + 121,111,117, 32, 99, 97,110, 32,114,101,100,105,115,116,114, + 105, 98,117,116,101, 32,105,116, 32, 97,110,100, 47,111,114, + 32,109,111,100,105,102,121, 32,105,116, 46, 10, 45, 45, 32, + 84,104,101, 32,115,111,102,116,119, 97,114,101, 32,112,114, + 111,118,105,100,101,100, 32,104,101,114,101,117,110,100,101, + 114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, 97,115, 32, + 105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,110,100, 10, + 45, 45, 32,116,104,101, 32, 97,117,116,104,111,114, 32,104, + 97,115, 32,110,111, 32,111, 98,108,105,103, 97,116,105,111, + 110, 32,116,111, 32,112,114,111,118,105,100,101, 32,109, 97, + 105,110,116,101,110, 97,110, 99,101, 44, 32,115,117,112,112, + 111,114,116, 44, 32,117,112,100, 97,116,101,115, 44, 10, 45, + 45, 32,101,110,104, 97,110, 99,101,109,101,110,116,115, 44, + 32,111,114, 32,109,111,100,105,102,105, 99, 97,116,105,111, + 110,115, 46, 10, 10, 10, 45, 45, 32, 70,101, 97,116,117,114, + 101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114, + 101,115,101,110,116,115, 32,116,104,101, 32, 98, 97,115,101, + 32, 99,108, 97,115,115, 32,111,102, 32, 97,108,108, 32,109, + 97,112,112,101,100, 32,102,101, 97,116,117,114,101, 46, 10, + 99,108, 97,115,115, 70,101, 97,116,117,114,101, 32, 61, 32, + 123, 10,125, 10, 99,108, 97,115,115, 70,101, 97,116,117,114, + 101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97, + 115,115, 70,101, 97,116,117,114,101, 10, 10, 45, 45, 32,119, + 114,105,116,101, 32,115,117,112,112,111,114,116, 32, 99,111, + 100,101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 70,101, 97,116,117,114,101, 58,115,117,112, 99,111, + 100,101, 32, 40, 41, 10,101,110,100, 10, 10, 45, 45, 32,111, + 117,116,112,117,116, 32,116, 97,103, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114, + 101, 58,100,101, 99,108,116,121,112,101, 32, 40, 41, 10,101, + 110,100, 10, 10, 45, 45, 32,114,101,103,105,115,116,101,114, + 32,102,101, 97,116,117,114,101, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, + 58,114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41, + 10,101,110,100, 10, 10, 45, 45, 32,116,114, 97,110,115,108, + 97,116,101, 32,118,101,114, 98, 97,116,105,109, 10,102,117, + 110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97, + 116,117,114,101, 58,112,114,101, 97,109, 98,108,101, 32, 40, + 41, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, + 32,105,102, 32,105,116, 32,105,115, 32, 97, 32,118, 97,114, + 105, 97, 98,108,101, 10,102,117,110, 99,116,105,111,110, 32, + 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,105,115, + 118, 97,114,105, 97, 98,108,101, 32, 40, 41, 10, 32,114,101, + 116,117,114,110, 32,102, 97,108,115,101, 10,101,110,100, 10, + 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,105,116, + 32,114,101,113,117,105,114,101,115, 32, 99,111,108,108,101, + 99,116,105,111,110, 10,102,117,110, 99,116,105,111,110, 32, + 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,114,101, + 113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,110, + 32, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,102, 97, + 108,115,101, 10,101,110,100, 10, 10, 45, 45, 32, 98,117,105, + 108,100, 32,110, 97,109,101,115, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, + 58, 98,117,105,108,100,110, 97,109,101,115, 32, 40, 41, 10, + 32,105,102, 32,115,101,108,102, 46,110, 97,109,101, 32, 97, + 110,100, 32,115,101,108,102, 46,110, 97,109,101,126, 61, 39, + 39, 32,116,104,101,110, 10, 32, 32,108,111, 99, 97,108, 32, + 110, 32, 61, 32,115,112,108,105,116, 40,115,101,108,102, 46, + 110, 97,109,101, 44, 39, 64, 39, 41, 10, 32, 32,115,101,108, + 102, 46,110, 97,109,101, 32, 61, 32,110, 91, 49, 93, 10, 32, + 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 32,115,116, + 114,105,110,103, 46,103,115,117, 98, 40,115,101,108,102, 46, + 110, 97,109,101, 44, 32, 34, 58, 37,100, 42, 36, 34, 44, 32, + 34, 34, 41, 10, 32, 32,105,102, 32,110,111,116, 32,110, 91, + 50, 93, 32,116,104,101,110, 10, 32, 32, 32,110, 91, 50, 93, + 32, 61, 32, 97,112,112,108,121,114,101,110, 97,109,105,110, + 103, 40,110, 91, 49, 93, 41, 10, 32, 32,101,110,100, 10, 32, + 32,115,101,108,102, 46,108,110, 97,109,101, 32, 61, 32,110, + 91, 50, 93, 32,111,114, 32,103,115,117, 98, 40,110, 91, 49, + 93, 44, 34, 37, 91, 46, 45, 37, 93, 34, 44, 34, 34, 41, 10, + 32, 32,115,101,108,102, 46,108,110, 97,109,101, 32, 61, 32, + 115,116,114,105,110,103, 46,103,115,117, 98, 40,115,101,108, + 102, 46,108,110, 97,109,101, 44, 32, 34, 58, 37,100, 42, 36, + 34, 44, 32, 34, 34, 41, 10, 32, 32,115,101,108,102, 46,111, + 114,105,103,105,110, 97,108, 95,110, 97,109,101, 32, 61, 32, + 115,101,108,102, 46,110, 97,109,101, 10, 32, 32,115,101,108, + 102, 46,108,110, 97,109,101, 32, 61, 32, 99,108,101, 97,110, + 95,116,101,109,112,108, 97,116,101, 40,115,101,108,102, 46, + 108,110, 97,109,101, 41, 10, 32,101,110,100, 10, 32,105,102, + 32,110,111,116, 32,115,101,108,102, 46,105,115, 95,112, 97, + 114, 97,109,101,116,101,114, 32,116,104,101,110, 10, 9, 32, + 115,101,108,102, 46,110, 97,109,101, 32, 61, 32,103,101,116, + 111,110,108,121,110, 97,109,101,115,112, 97, 99,101, 40, 41, + 32, 46, 46, 32,115,101,108,102, 46,110, 97,109,101, 10, 32, + 101,110,100, 10, 10, 32,108,111, 99, 97,108, 32,112, 97,114, + 101,110,116, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116, + 97,105,110,101,114, 46, 99,117,114,114, 10, 32,105,102, 32, + 112, 97,114,101,110,116, 32,116,104,101,110, 10, 32, 9,115, + 101,108,102, 46, 97, 99, 99,101,115,115, 32, 61, 32,112, 97, + 114,101,110,116, 46, 99,117,114,114, 95,109,101,109, 98,101, + 114, 95, 97, 99, 99,101,115,115, 10, 9,115,101,108,102, 46, + 103,108,111, 98, 97,108, 95, 97, 99, 99,101,115,115, 32, 61, + 32,115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, 98, + 108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 10, 32,101, + 108,115,101, 10, 32,101,110,100, 10,101,110,100, 10, 10,102, + 117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, + 97,116,117,114,101, 58, 99,104,101, 99,107, 95,112,117, 98, + 108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 10, 10, 9, + 105,102, 32,116,121,112,101, 40,115,101,108,102, 46,103,108, + 111, 98, 97,108, 95, 97, 99, 99,101,115,115, 41, 32, 61, 61, + 32, 34, 98,111,111,108,101, 97,110, 34, 32,116,104,101,110, + 10, 9, 9,114,101,116,117,114,110, 32,115,101,108,102, 46, + 103,108,111, 98, 97,108, 95, 97, 99, 99,101,115,115, 10, 9, + 101,110,100, 10, 10, 9,105,102, 32,115,101,108,102, 46, 97, + 99, 99,101,115,115, 32, 97,110,100, 32,115,101,108,102, 46, + 97, 99, 99,101,115,115, 32,126, 61, 32, 48, 32,116,104,101, + 110, 10, 9, 9,114,101,116,117,114,110, 32,102, 97,108,115, + 101, 10, 9,101,110,100, 10, 10, 9,108,111, 99, 97,108, 32, + 112, 97,114,101,110,116, 32, 61, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 10, 9, + 119,104,105,108,101, 32,112, 97,114,101,110,116, 32,100,111, + 10, 9, 9,105,102, 32,112, 97,114,101,110,116, 46, 97, 99, + 99,101,115,115, 32, 97,110,100, 32,112, 97,114,101,110,116, + 46, 97, 99, 99,101,115,115, 32,126, 61, 32, 48, 32,116,104, + 101,110, 10, 9, 9, 9,114,101,116,117,114,110, 32,102, 97, + 108,115,101, 10, 9, 9,101,110,100, 10, 9, 9,112, 97,114, + 101,110,116, 32, 61, 32,112, 97,114,101,110,116, 46,112,114, + 111,120, 10, 9,101,110,100, 10, 9,114,101,116,117,114,110, + 32,116,114,117,101, 10,101,110,100, 10, 10,102,117,110, 99, + 116,105,111,110, 32, 99,108,101, 97,110, 95,116,101,109,112, + 108, 97,116,101, 40,116, 41, 10, 10, 9,114,101,116,117,114, + 110, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116, + 44, 32, 34, 91, 60, 62, 58, 44, 32, 37, 42, 93, 34, 44, 32, + 34, 95, 34, 41, 10,101,110,100, 10, 10, 45, 45, 32, 99,104, + 101, 99,107, 32,105,102, 32,102,101, 97,116,117,114,101, 32, + 105,115, 32,105,110,115,105,100,101, 32, 97, 32, 99,111,110, + 116, 97,105,110,101,114, 32,100,101,102,105,110,105,116,105, + 111,110, 10, 45, 45, 32,105,116, 32,114,101,116,117,114,110, + 115, 32,116,104,101, 32, 99,111,110,116, 97,105,110,101,114, + 32, 99,108, 97,115,115, 32,110, 97,109,101, 32,111,114, 32, + 110,105,108, 46, 10,102,117,110, 99,116,105,111,110, 32, 99, + 108, 97,115,115, 70,101, 97,116,117,114,101, 58,105,110, 99, + 111,110,116, 97,105,110,101,114, 32, 40,119,104,105, 99,104, + 41, 10, 32,105,102, 32,115,101,108,102, 46,112, 97,114,101, + 110,116, 32,116,104,101,110, 10, 32, 32,108,111, 99, 97,108, + 32,112, 97,114,101,110,116, 32, 61, 32,115,101,108,102, 46, + 112, 97,114,101,110,116, 10, 32, 32,119,104,105,108,101, 32, + 112, 97,114,101,110,116, 32,100,111, 10, 32, 32, 32,105,102, + 32,112, 97,114,101,110,116, 46, 99,108, 97,115,115,116,121, + 112,101, 32, 61, 61, 32,119,104,105, 99,104, 32,116,104,101, + 110, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,112, 97, + 114,101,110,116, 46,110, 97,109,101, 10, 32, 32, 32,101,110, + 100, 10, 32, 32, 32,112, 97,114,101,110,116, 32, 61, 32,112, + 97,114,101,110,116, 46,112, 97,114,101,110,116, 10, 32, 32, + 101,110,100, 10, 32,101,110,100, 10, 32,114,101,116,117,114, + 110, 32,110,105,108, 10,101,110,100, 10, 10,102,117,110, 99, + 116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117, + 114,101, 58,105,110, 99,108, 97,115,115, 32, 40, 41, 10, 32, + 114,101,116,117,114,110, 32,115,101,108,102, 58,105,110, 99, + 111,110,116, 97,105,110,101,114, 40, 39, 99,108, 97,115,115, + 39, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58, + 105,110,109,111,100,117,108,101, 32, 40, 41, 10, 32,114,101, + 116,117,114,110, 32,115,101,108,102, 58,105,110, 99,111,110, + 116, 97,105,110,101,114, 40, 39,109,111,100,117,108,101, 39, + 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, + 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,105, + 110,110, 97,109,101,115,112, 97, 99,101, 32, 40, 41, 10, 32, + 114,101,116,117,114,110, 32,115,101,108,102, 58,105,110, 99, + 111,110,116, 97,105,110,101,114, 40, 39,110, 97,109,101,115, + 112, 97, 99,101, 39, 41, 10,101,110,100, 10, 10, 45, 45, 32, + 114,101,116,117,114,110, 32, 67, 32, 98,105,110,100,105,110, + 103, 32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101, + 32, 98, 97,115,101,100, 32,111,110, 32,110, 97,109,101, 10, + 45, 45, 32,116,104,101, 32, 99,108,105,101,110,116, 32,115, + 112,101, 99,105,102,105,101,115, 32, 97, 32,112,114,101,102, + 105,120, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 70,101, 97,116,117,114,101, 58, 99,102,117,110, 99, + 110, 97,109,101, 32, 40,110, 41, 10, 10, 32,105,102, 32,115, + 101,108,102, 46,112, 97,114,101,110,116, 32,116,104,101,110, + 10, 32, 32,110, 32, 61, 32,115,101,108,102, 46,112, 97,114, + 101,110,116, 58, 99,102,117,110, 99,110, 97,109,101, 40,110, + 41, 10, 32,101,110,100, 10, 10, 32,108,111, 99, 97,108, 32, + 102,110, 97,109,101, 32, 61, 32,115,101,108,102, 46,108,110, + 97,109,101, 10, 32,105,102, 32,110,111,116, 32,102,110, 97, + 109,101, 32,111,114, 32,102,110, 97,109,101, 32, 61, 61, 32, + 39, 39, 32,116,104,101,110, 10, 32, 9,102,110, 97,109,101, + 32, 61, 32,115,101,108,102, 46,110, 97,109,101, 10, 32,101, + 110,100, 10, 32, 32,110, 32, 61, 32,115,116,114,105,110,103, + 46,103,115,117, 98, 40,110, 46, 46, 39, 95, 39, 46, 46, 32, + 40,102,110, 97,109,101, 41, 44, 32, 34, 91, 60, 62, 58, 44, + 32, 92, 46, 37, 42, 38, 93, 34, 44, 32, 34, 95, 34, 41, 10, + 10, 32, 32,114,101,116,117,114,110, 32,110, 10,101,110,100, + 32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/feature.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,118,101,114, 98, 97, + 116,105,109, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114, + 105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, + 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, + 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, + 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73, + 100, 58, 32,118,101,114, 98, 97,116,105,109, 46,108,117, 97, + 44,118, 32, 49, 46, 51, 32, 50, 48, 48, 48, 47, 48, 49, 47, + 50, 52, 32, 50, 48, 58, 52, 49, 58, 49, 54, 32, 99,101,108, + 101,115, 32, 69,120,112, 32, 36, 10, 10, 45, 45, 32, 84,104, + 105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101, + 32,115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32, + 99, 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116, + 101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100, + 105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32, + 115,111,102,116,119, 97,114,101, 32,112,114,111,118,105,100, + 101,100, 32,104,101,114,101,117,110,100,101,114, 32,105,115, + 32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, + 98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116, + 104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110, + 111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111, + 32,112,114,111,118,105,100,101, 32,109, 97,105,110,116,101, + 110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44, + 32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110, + 104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32, + 109,111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10, + 10, 10, 10, 45, 45, 32, 86,101,114, 98, 97,116,105,109, 32, + 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,115, + 101,110,116,115, 32, 97, 32,108,105,110,101, 32,116,114, 97, + 110,115,108, 97,116,101,100, 32,100,105,114,101, 99,116,101, + 100, 32,116,111, 32,116,104,101, 32, 98,105,110,100,105,110, + 103, 32,102,105,108,101, 46, 10, 45, 45, 32, 84,104,101, 32, + 102,111,108,108,111,119,105,110,103, 32,102,105,108,100,115, + 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10, 45, 45, + 32, 32, 32,108,105,110,101, 32, 61, 32,108,105,110,101, 32, + 116,101,120,116, 10, 99,108, 97,115,115, 86,101,114, 98, 97, + 116,105,109, 32, 61, 32,123, 10, 32,108,105,110,101, 32, 61, + 32, 39, 39, 44, 10, 9, 99,111,110,100, 32, 61, 32,110,105, + 108, 44, 32, 32, 32, 32, 45, 45, 32, 99,111,110,100,105,116, + 105,111,110, 58, 32,119,104,101,114,101, 32,116,111, 32,103, + 101,110,101,114, 97,116,101, 32,116,104,101, 32, 99,111,100, + 101, 32, 40,115, 61,115,117,112,111,114,116, 44, 32,114, 61, + 114,101,103,105,115,116,101,114, 41, 10,125, 10, 99,108, 97, + 115,115, 86,101,114, 98, 97,116,105,109, 46, 95, 95,105,110, + 100,101,120, 32, 61, 32, 99,108, 97,115,115, 86,101,114, 98, + 97,116,105,109, 10,115,101,116,109,101,116, 97,116, 97, 98, + 108,101, 40, 99,108, 97,115,115, 86,101,114, 98, 97,116,105, + 109, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 41, + 10, 10, 45, 45, 32,112,114,101, 97,109, 98,108,101, 32,118, + 101,114, 98, 97,116,105,109, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,109, + 58,112,114,101, 97,109, 98,108,101, 32, 40, 41, 10, 32,105, + 102, 32,115,101,108,102, 46, 99,111,110,100, 32, 61, 61, 32, + 39, 39, 32,116,104,101,110, 10, 32, 32,119,114,105,116,101, + 40,115,101,108,102, 46,108,105,110,101, 41, 10, 32,101,110, + 100, 10,101,110,100, 10, 10, 45, 45, 32,115,117,112,112,111, + 114,116, 32, 99,111,100,101, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,109, + 58,115,117,112, 99,111,100,101, 32, 40, 41, 10, 32,105,102, + 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46, 99, + 111,110,100, 44, 39,115, 39, 41, 32,116,104,101,110, 10, 32, + 32,119,114,105,116,101, 40,115,101,108,102, 46,108,105,110, + 101, 41, 10, 32, 32,119,114,105,116,101, 40, 39, 92,110, 39, + 41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, + 114,101,103,105,115,116,101,114, 32, 99,111,100,101, 10,102, + 117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 86,101, + 114, 98, 97,116,105,109, 58,114,101,103,105,115,116,101,114, + 32, 40,112,114,101, 41, 10, 32,105,102, 32,115,116,114,102, + 105,110,100, 40,115,101,108,102, 46, 99,111,110,100, 44, 39, + 114, 39, 41, 32,116,104,101,110, 10, 32, 32,119,114,105,116, + 101, 40,115,101,108,102, 46,108,105,110,101, 41, 10, 32,101, + 110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80,114,105, + 110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116, + 105,109, 58,112,114,105,110,116, 32, 40,105,100,101,110,116, + 44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40, + 105,100,101,110,116, 46, 46, 34, 86,101,114, 98, 97,116,105, + 109,123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 32,108,105,110,101, 32, 61, 32, 39, 34, + 46, 46,115,101,108,102, 46,108,105,110,101, 46, 46, 34, 39, + 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110, + 116, 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10, + 101,110,100, 10, 10, 10, 45, 45, 32, 73,110,116,101,114,110, + 97,108, 32, 99,111,110,115,116,114,117, 99,116,111,114, 10, + 102,117,110, 99,116,105,111,110, 32, 95, 86,101,114, 98, 97, + 116,105,109, 32, 40,116, 41, 10, 32,115,101,116,109,101,116, + 97,116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 86, + 101,114, 98, 97,116,105,109, 41, 10, 32, 97,112,112,101,110, + 100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,116, 10, + 101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,114,117, + 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,116,115, + 32, 97, 32,115,116,114,105,110,103, 32,114,101,112,114,101, + 115,101,110,116,105,110,103, 32,116,104,101, 32,116,101,120, + 116, 32,108,105,110,101, 10,102,117,110, 99,116,105,111,110, + 32, 86,101,114, 98, 97,116,105,109, 32, 40,108, 44, 99,111, + 110,100, 41, 10, 32,105,102, 32,115,116,114,115,117, 98, 40, + 108, 44, 49, 44, 49, 41, 32, 61, 61, 32, 34, 39, 34, 32,116, + 104,101,110, 10, 32, 32,108, 32, 61, 32,115,116,114,115,117, + 98, 40,108, 44, 50, 41, 10, 32,101,108,115,101,105,102, 32, + 115,116,114,115,117, 98, 40,108, 44, 49, 44, 49, 41, 32, 61, + 61, 32, 39, 36, 39, 32,116,104,101,110, 10, 32, 32, 99,111, + 110,100, 32, 61, 32, 39,115,114, 39, 32, 32, 32, 32, 32, 32, + 32, 45, 45, 32,103,101,110,101,114, 97,116,101,115, 32,105, + 110, 32, 98,111,116,104, 32,115,117,112,111,114,116, 32, 97, + 110,100, 32,114,101,103,105,115,116,101,114, 32,102,114, 97, + 103,109,101,110,116,115, 10, 32, 32,108, 32, 61, 32,115,116, + 114,115,117, 98, 40,108, 44, 50, 41, 10, 32,101,110,100, 10, + 32,114,101,116,117,114,110, 32, 95, 86,101,114, 98, 97,116, + 105,109, 32,123, 10, 32, 32,108,105,110,101, 32, 61, 32,108, + 44, 10, 32, 32, 99,111,110,100, 32, 61, 32, 99,111,110,100, + 32,111,114, 32, 39, 39, 44, 10, 32,125, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/verbatim.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32, 99,111,100,101, 32, + 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,101, + 110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67, + 101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, + 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, + 32, 49, 57, 57, 57, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, + 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32, + 105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114, + 101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105, + 115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100, + 47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10, + 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101, + 32,112,114,111,118,105,100,101,100, 32,104,101,114,101,117, + 110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, + 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97, + 110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111, + 114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97, + 116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,101, + 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115, + 117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115, + 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110, + 116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97, + 116,105,111,110,115, 46, 10, 10, 45, 45, 32,103,108,111, 98, + 97,108, 10, 99,111,100,101, 95,110, 32, 61, 32, 49, 10, 10, + 45, 45, 32, 67,111,100,101, 32, 99,108, 97,115,115, 10, 45, + 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 76,117, + 97, 32, 99,111,100,101, 32,116,111, 32, 98,101, 32, 99,111, + 109,112,105,108,101,100, 32, 97,110,100, 32,105,110, 99,108, + 117,100,101,100, 10, 45, 45, 32,105,110, 32,116,104,101, 32, + 105,110,105,116,105, 97,108,105,122, 97,116,105,111,110, 32, + 102,117,110, 99,116,105,111,110, 46, 10, 45, 45, 32, 84,104, + 101, 32,102,111,108,108,111,119,105,110,103, 32,102,105,101, + 108,100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, + 10, 45, 45, 32, 32, 32,116,101,120,116, 32, 61, 32,116,101, + 120,116, 32, 99,111,100,101, 10, 99,108, 97,115,115, 67,111, + 100,101, 32, 61, 32,123, 10, 32,116,101,120,116, 32, 61, 32, + 39, 39, 44, 10,125, 10, 99,108, 97,115,115, 67,111,100,101, + 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115, + 115, 67,111,100,101, 10,115,101,116,109,101,116, 97,116, 97, + 98,108,101, 40, 99,108, 97,115,115, 67,111,100,101, 44, 99, + 108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10, 10, 45, + 45, 32,114,101,103,105,115,116,101,114, 32, 99,111,100,101, + 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, + 67,111,100,101, 58,114,101,103,105,115,116,101,114, 32, 40, + 112,114,101, 41, 10, 32,112,114,101, 32, 61, 32,112,114,101, + 32,111,114, 32, 39, 39, 10, 32, 45, 45, 32, 99,108,101, 97, + 110, 32, 76,117, 97, 32, 99,111,100,101, 10, 32,108,111, 99, + 97,108, 32,115, 32, 61, 32, 99,108,101, 97,110, 40,115,101, + 108,102, 46,116,101,120,116, 41, 10, 32,105,102, 32,110,111, + 116, 32,115, 32,116,104,101,110, 10, 32, 32, 45, 45,112,114, + 105,110,116, 40,115,101,108,102, 46,116,101,120,116, 41, 10, + 32, 32,101,114,114,111,114, 40, 34,112, 97,114,115,101,114, + 32,101,114,114,111,114, 32,105,110, 32,101,109, 98,101,100, + 100,101,100, 32, 99,111,100,101, 34, 41, 10, 32,101,110,100, + 10, 10, 32, 45, 45, 32,103,101,116, 32,102,105,114,115,116, + 32,108,105,110,101, 10, 32,108,111, 99, 97,108, 32, 95, 44, + 32, 95, 44, 32,102,105,114,115,116, 95,108,105,110,101, 61, + 115,116,114,105,110,103, 46,102,105,110,100, 40,115,101,108, + 102, 46,116,101,120,116, 44, 32, 34, 94, 40, 91, 94, 92,110, + 92,114, 93, 42, 41, 34, 41, 10, 32,105,102, 32,115,116,114, + 105,110,103, 46,102,105,110,100, 40,102,105,114,115,116, 95, + 108,105,110,101, 44, 32, 34, 94, 37,115, 42, 37, 45, 37, 45, + 34, 41, 32,116,104,101,110, 10, 9, 32,105,102, 32,115,116, + 114,105,110,103, 46,102,105,110,100, 40,102,105,114,115,116, + 95,108,105,110,101, 44, 32, 34, 94, 37, 45, 37, 45, 35, 35, + 34, 41, 32,116,104,101,110, 10, 9, 9,102,105,114,115,116, + 95,108,105,110,101, 32, 61, 32,115,116,114,105,110,103, 46, + 103,115,117, 98, 40,102,105,114,115,116, 95,108,105,110,101, + 44, 32, 34, 94, 37, 45, 37, 45, 35, 35, 34, 44, 32, 34, 34, + 41, 10, 9, 9,105,102, 32,102,108, 97,103,115, 91, 39, 67, + 39, 93, 32,116,104,101,110, 10, 9, 9, 9,115, 32, 61, 32, + 115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32, + 34, 94, 37, 45, 37, 45, 35, 35, 91, 94, 92,110, 92,114, 93, + 42, 92,110, 34, 44, 32, 34, 34, 41, 10, 9, 9,101,110,100, + 10, 9, 32,101,110,100, 10, 32,101,108,115,101, 10, 32, 9, + 102,105,114,115,116, 95,108,105,110,101, 32, 61, 32, 34, 34, + 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,111,110,118, + 101,114,116, 32,116,111, 32, 67, 10, 32,111,117,116,112,117, + 116, 40, 39, 92,110, 39, 46, 46,112,114,101, 46, 46, 39,123, + 32, 47, 42, 32, 98,101,103,105,110, 32,101,109, 98,101,100, + 100,101,100, 32,108,117, 97, 32, 99,111,100,101, 32, 42, 47, + 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40,112,114, + 101, 46, 46, 39, 32,105,110,116, 32,116,111,112, 32, 61, 32, + 108,117, 97, 95,103,101,116,116,111,112, 40,116,111,108,117, + 97, 95, 83, 41, 59, 39, 41, 10, 32,111,117,116,112,117,116, + 40,112,114,101, 46, 46, 39, 32,115,116, 97,116,105, 99, 32, + 117,110,115,105,103,110,101,100, 32, 99,104, 97,114, 32, 66, + 91, 93, 32, 61, 32,123, 92,110, 32, 32, 32, 39, 41, 10, 32, + 108,111, 99, 97,108, 32,116, 61,123,110, 61, 48,125, 10, 32, + 108,111, 99, 97,108, 32, 98, 32, 61, 32,103,115,117, 98, 40, + 115, 44, 39, 40, 46, 41, 39, 44,102,117,110, 99,116,105,111, + 110, 32, 40, 99, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,108,111, 99, 97,108, 32,101, 32, 61, 32, 39, 39, 10, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32,116, 46,110, 61,116, 46, + 110, 43, 49, 32,105,102, 32,116, 46,110, 61, 61, 49, 53, 32, + 116,104,101,110, 32,116, 46,110, 61, 48, 32,101, 61, 39, 92, + 110, 39, 46, 46,112,114,101, 46, 46, 39, 32, 32, 39, 32,101, + 110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101, + 116,117,114,110, 32,102,111,114,109, 97,116, 40, 39, 37, 51, + 117, 44, 37,115, 39, 44,115,116,114, 98,121,116,101, 40, 99, + 41, 44,101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101, + 110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 41, 10, 32,111,117,116,112,117,116, 40, 98, 46, + 46,115,116,114, 98,121,116,101, 40, 34, 32, 34, 41, 41, 10, + 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 46, 46,112, + 114,101, 46, 46, 39, 32,125, 59, 92,110, 39, 41, 10, 32,105, + 102, 32,102,105,114,115,116, 95,108,105,110,101, 32, 97,110, + 100, 32,102,105,114,115,116, 95,108,105,110,101, 32,126, 61, + 32, 34, 34, 32,116,104,101,110, 10, 32, 9,111,117,116,112, + 117,116, 40,112,114,101, 46, 46, 39, 32,116,111,108,117, 97, + 95,100,111, 98,117,102,102,101,114, 40,116,111,108,117, 97, + 95, 83, 44, 40, 99,104, 97,114, 42, 41, 66, 44,115,105,122, + 101,111,102, 40, 66, 41, 44, 34,116,111,108,117, 97, 32,101, + 109, 98,101,100,100,101,100, 58, 32, 39, 46, 46,102,105,114, + 115,116, 95,108,105,110,101, 46, 46, 39, 34, 41, 59, 39, 41, + 10, 32,101,108,115,101, 10, 32, 9,111,117,116,112,117,116, + 40,112,114,101, 46, 46, 39, 32,116,111,108,117, 97, 95,100, + 111, 98,117,102,102,101,114, 40,116,111,108,117, 97, 95, 83, + 44, 40, 99,104, 97,114, 42, 41, 66, 44,115,105,122,101,111, + 102, 40, 66, 41, 44, 34,116,111,108,117, 97, 58, 32,101,109, + 98,101,100,100,101,100, 32, 76,117, 97, 32, 99,111,100,101, + 32, 39, 46, 46, 99,111,100,101, 95,110, 46, 46, 39, 34, 41, + 59, 39, 41, 10, 32,101,110,100, 10, 32,111,117,116,112,117, + 116, 40,112,114,101, 46, 46, 39, 32,108,117, 97, 95,115,101, + 116,116,111,112, 40,116,111,108,117, 97, 95, 83, 44, 32,116, + 111,112, 41, 59, 39, 41, 10, 32,111,117,116,112,117,116, 40, + 112,114,101, 46, 46, 39,125, 32, 47, 42, 32,101,110,100, 32, + 111,102, 32,101,109, 98,101,100,100,101,100, 32,108,117, 97, + 32, 99,111,100,101, 32, 42, 47, 92,110, 92,110, 39, 41, 10, + 32, 99,111,100,101, 95,110, 32, 61, 32, 99,111,100,101, 95, + 110, 32, 43, 49, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80, + 114,105,110,116, 32,109,101,116,104,111,100, 10,102,117,110, + 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,100,101, + 58,112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99, + 108,111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100, + 101,110,116, 46, 46, 34, 67,111,100,101,123, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 116,101,120,116, 32, 61, 32, 91, 91, 34, 46, 46,115,101,108, + 102, 46,116,101,120,116, 46, 46, 34, 93, 93, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10, + 10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99, + 111,110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99, + 116,105,111,110, 32, 95, 67,111,100,101, 32, 40,116, 41, 10, + 32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, + 44, 99,108, 97,115,115, 67,111,100,101, 41, 10, 32, 97,112, + 112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114,110, + 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115, + 116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, + 99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114,101, + 112,114,101,115,101,110,116,105,110,103, 32,116,104,101, 32, + 99,111,100,101, 32,116,101,120,116, 10,102,117,110, 99,116, + 105,111,110, 32, 67,111,100,101, 32, 40,108, 41, 10, 32,114, + 101,116,117,114,110, 32, 95, 67,111,100,101, 32,123, 10, 32, + 32,116,101,120,116, 32, 61, 32,108, 10, 32,125, 10,101,110, + 100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/code.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,116,121,112,101,100, + 101,102, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105, + 116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97, + 114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71, + 114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, + 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, + 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111, + 100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116, + 119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114, + 101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, + 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105, + 116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, + 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,101, + 114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97, + 110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, + 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117, + 116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108, + 105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118, + 105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, + 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97, + 116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101, + 109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102, + 105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45, + 32, 84,121,112,101,100,101,102, 32, 99,108, 97,115,115, 10, + 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 97, + 32,116,121,112,101, 32,115,121,110,111,110,121,109, 46, 10, + 45, 45, 32, 84,104,101, 32, 39,100,101, 32,102, 97, 99,116, + 111, 39, 32,116,121,112,101, 32,114,101,112,108, 97, 99,101, + 115, 32,116,104,101, 32,116,121,112,101,100,101,102, 32, 98, + 101,102,111,114,101, 32,116,104,101, 10, 45, 45, 32,114,101, + 109, 97,105,110,105,110,103, 32, 99,111,100,101, 32,105,115, + 32,112, 97,114,115,101,100, 46, 10, 45, 45, 32, 84,104,101, + 32,102,111,108,108,111,119,105,110,103, 32,102,105,101,108, + 100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10, + 45, 45, 32, 32, 32,117,116,121,112,101, 32, 61, 32,116,121, + 112,101,100,101,102, 32,110, 97,109,101, 10, 45, 45, 32, 32, + 32,116,121,112,101, 32, 61, 32, 39,116,104,101, 32,102, 97, + 99,116,111, 39, 32,116,121,112,101, 10, 45, 45, 32, 32, 32, + 109,111,100, 32, 61, 32,109,111,100,105,102,105,101,114,115, + 32,116,111, 32,116,104,101, 32, 39,100,101, 32,102, 97, 99, + 116,111, 39, 32,116,121,112,101, 10, 99,108, 97,115,115, 84, + 121,112,101,100,101,102, 32, 61, 32,123, 10, 32,117,116,121, + 112,101, 32, 61, 32, 39, 39, 44, 10, 32,109,111,100, 32, 61, + 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39, 39, + 10,125, 10, 99,108, 97,115,115, 84,121,112,101,100,101,102, + 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115, + 115, 84,121,112,101,100,101,102, 10, 10, 45, 45, 32, 80,114, + 105,110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99, + 116,105,111,110, 32, 99,108, 97,115,115, 84,121,112,101,100, + 101,102, 58,112,114,105,110,116, 32, 40,105,100,101,110,116, + 44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40, + 105,100,101,110,116, 46, 46, 34, 84,121,112,101,100,101,102, + 123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110, + 116, 46, 46, 34, 32,117,116,121,112,101, 32, 61, 32, 39, 34, + 46, 46,115,101,108,102, 46,117,116,121,112,101, 46, 46, 34, + 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 32,109,111,100, 32, 61, 32, 39, 34, 46, + 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115, + 101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, + 10, 10, 45, 45, 32, 82,101,116,117,114,110, 32,105,116, 39, + 115, 32,110,111,116, 32, 97, 32,118, 97,114,105, 97, 98,108, + 101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 84,121,112,101,100,101,102, 58,105,115,118, 97,114,105, + 97, 98,108,101, 32, 40, 41, 10, 32,114,101,116,117,114,110, + 32,102, 97,108,115,101, 10,101,110,100, 10, 10, 45, 45, 32, + 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114, + 117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32, + 95, 84,121,112,101,100,101,102, 32, 40,116, 41, 10, 32,115, + 101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99, + 108, 97,115,115, 84,121,112,101,100,101,102, 41, 10, 32,116, + 46,116,121,112,101, 32, 61, 32,114,101,115,111,108,118,101, + 95,116,101,109,112,108, 97,116,101, 95,116,121,112,101,115, + 40,116, 46,116,121,112,101, 41, 10, 32, 97,112,112,101,110, + 100,116,121,112,101,100,101,102, 40,116, 41, 10, 32,114,101, + 116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, + 67,111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, + 69,120,112,101, 99,116,115, 32,111,110,101, 32,115,116,114, + 105,110,103, 32,114,101,112,114,101,115,101,110,116,105,110, + 103, 32,116,104,101, 32,116,121,112,101, 32,100,101,102,105, + 110,105,116,105,111,110, 46, 10,102,117,110, 99,116,105,111, + 110, 32, 84,121,112,101,100,101,102, 32, 40,115, 41, 10, 32, + 105,102, 32,115,116,114,102,105,110,100, 40,115,116,114,105, + 110,103, 46,103,115,117, 98, 40,115, 44, 32, 39, 37, 98, 60, + 62, 39, 44, 32, 39, 39, 41, 44, 39, 91, 37, 42, 38, 93, 39, + 41, 32,116,104,101,110, 10, 32, 32,116,111,108,117, 97, 95, + 101,114,114,111,114, 40, 34, 35,105,110,118, 97,108,105,100, + 32,116,121,112,101,100,101,102, 58, 32,112,111,105,110,116, + 101,114,115, 32, 40, 97,110,100, 32,114,101,102,101,114,101, + 110, 99,101,115, 41, 32, 97,114,101, 32,110,111,116, 32,115, + 117,112,112,111,114,116,101,100, 34, 41, 10, 32,101,110,100, + 10, 32,108,111, 99, 97,108, 32,111, 32, 61, 32,123,109,111, + 100, 32, 61, 32, 39, 39,125, 10, 32,105,102, 32,115,116,114, + 105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 91, 60, + 62, 93, 34, 41, 32,116,104,101,110, 10, 32, 9, 95, 44, 95, + 44,111, 46,116,121,112,101, 44,111, 46,117,116,121,112,101, + 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, + 115, 44, 32, 34, 94, 37,115, 42, 40, 91, 94, 60, 62, 93, 43, + 37, 98, 60, 62, 91, 94, 37,115, 93, 42, 41, 37,115, 43, 40, + 46, 45, 41, 36, 34, 41, 10, 32,101,108,115,101, 10, 32, 9, + 108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,108,105,116, + 40,103,115,117, 98, 40,115, 44, 34, 37,115, 37,115, 42, 34, + 44, 34, 32, 34, 41, 44, 34, 32, 34, 41, 10, 32, 9,111, 32, + 61, 32,123, 10, 9, 32, 32,117,116,121,112,101, 32, 61, 32, + 116, 91,116, 46,110, 93, 44, 10, 9, 32, 32,116,121,112,101, + 32, 61, 32,116, 91,116, 46,110, 45, 49, 93, 44, 10, 9, 32, + 32,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,116, + 44, 49, 44,116, 46,110, 45, 50, 41, 44, 10, 9, 32,125, 10, + 32,101,110,100, 10, 32,114,101,116,117,114,110, 32, 95, 84, + 121,112,101,100,101,102, 40,111, 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/typedef.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32, 99,111,110,116, 97, + 105,110,101,114, 32, 97, 98,115,116,114, 97, 99,116, 32, 99, + 108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, + 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101, + 108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, + 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, + 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10, + 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,105, + 115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,101, + 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,115, + 116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100, 47, + 111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10, 45, + 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101, 32, + 112,114,111,118,105,100,101,100, 32,104,101,114,101,117,110, + 100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, 97, + 115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,110, + 100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,114, + 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,116, + 105,111,110, 32,116,111, 32,112,114,111,118,105,100,101, 32, + 109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,117, + 112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115, 44, + 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,116, + 115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,116, + 105,111,110,115, 46, 10, 10, 45, 45, 32,116, 97, 98,108,101, + 32,116,111, 32,115,116,111,114,101, 32,110, 97,109,101,115, + 112, 97, 99,101,100, 32,116,121,112,101,100,101,102,115, 47, + 101,110,117,109,115, 32,105,110, 32,103,108,111, 98, 97,108, + 32,115, 99,111,112,101, 10,103,108,111, 98, 97,108, 95,116, + 121,112,101,100,101,102,115, 32, 61, 32,123,125, 10,103,108, + 111, 98, 97,108, 95,101,110,117,109,115, 32, 61, 32,123,125, + 10, 10, 45, 45, 32, 67,111,110,116, 97,105,110,101,114, 32, + 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,115, + 101,110,116,115, 32, 97, 32, 99,111,110,116, 97,105,110,101, + 114, 32,111,102, 32,102,101, 97,116,117,114,101,115, 32,116, + 111, 32, 98,101, 32, 98,111,117,110,100, 10, 45, 45, 32,116, + 111, 32,108,117, 97, 46, 10, 99,108, 97,115,115, 67,111,110, + 116, 97,105,110,101,114, 32, 61, 10,123, 10, 32, 99,117,114, + 114, 32, 61, 32,110,105,108, 44, 10,125, 10, 99,108, 97,115, + 115, 67,111,110,116, 97,105,110,101,114, 46, 95, 95,105,110, + 100,101,120, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116, + 97,105,110,101,114, 10,115,101,116,109,101,116, 97,116, 97, + 98,108,101, 40, 99,108, 97,115,115, 67,111,110,116, 97,105, + 110,101,114, 44, 99,108, 97,115,115, 70,101, 97,116,117,114, + 101, 41, 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116, + 97,103,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108, + 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,100,101, + 99,108,116,121,112,101, 32, 40, 41, 10, 32,112,117,115,104, + 40,115,101,108,102, 41, 10, 32,108,111, 99, 97,108, 32,105, + 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91, + 105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,105, 93, + 58,100,101, 99,108,116,121,112,101, 40, 41, 10, 32, 32,105, + 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,111, + 112, 40, 41, 10,101,110,100, 10, 10, 10, 45, 45, 32,119,114, + 105,116,101, 32,115,117,112,112,111,114,116, 32, 99,111,100, + 101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 67,111,110,116, 97,105,110,101,114, 58,115,117,112, 99, + 111,100,101, 32, 40, 41, 10, 10, 9,105,102, 32,110,111,116, + 32,115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, 98, + 108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104, + 101,110, 10, 9, 9,114,101,116,117,114,110, 10, 9,101,110, + 100, 10, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10, + 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105, + 108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, + 32,105,102, 32,115,101,108,102, 91,105, 93, 58, 99,104,101, + 99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, 99,101,115, + 115, 40, 41, 32,116,104,101,110, 10, 32, 32, 9,115,101,108, + 102, 91,105, 93, 58,115,117,112, 99,111,100,101, 40, 41, 10, + 32, 32,101,110,100, 10, 32, 32,105, 32, 61, 32,105, 43, 49, + 10, 32,101,110,100, 10, 32,112,111,112, 40, 41, 10,101,110, + 100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 67,111,110,116, 97,105,110,101,114, 58,104, 97,115, + 118, 97,114, 32, 40, 41, 10, 32,108,111, 99, 97,108, 32,105, + 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91, + 105, 93, 32,100,111, 10, 32, 32,105,102, 32,115,101,108,102, + 91,105, 93, 58,105,115,118, 97,114,105, 97, 98,108,101, 40, + 41, 32,116,104,101,110, 10, 9, 9, 32,114,101,116,117,114, + 110, 32, 49, 10, 9, 9,101,110,100, 10, 32, 32,105, 32, 61, + 32,105, 43, 49, 10, 32,101,110,100, 10, 9,114,101,116,117, + 114,110, 32, 48, 10,101,110,100, 10, 10, 45, 45, 32, 73,110, + 116,101,114,110, 97,108, 32, 99,111,110,116, 97,105,110,101, + 114, 32, 99,111,110,115,116,114,117, 99,116,111,114, 10,102, + 117,110, 99,116,105,111,110, 32, 95, 67,111,110,116, 97,105, + 110,101,114, 32, 40,115,101,108,102, 41, 10, 32,115,101,116, + 109,101,116, 97,116, 97, 98,108,101, 40,115,101,108,102, 44, + 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 41, + 10, 32,115,101,108,102, 46,110, 32, 61, 32, 48, 10, 32,115, + 101,108,102, 46,116,121,112,101,100,101,102,115, 32, 61, 32, + 123,116,111,108,117, 97, 95,110, 61, 48,125, 10, 32,115,101, + 108,102, 46,117,115,101,114,116,121,112,101,115, 32, 61, 32, + 123,125, 10, 32,115,101,108,102, 46,101,110,117,109,115, 32, + 61, 32,123,116,111,108,117, 97, 95,110, 61, 48,125, 10, 32, + 115,101,108,102, 46,108,110, 97,109,101,115, 32, 61, 32,123, + 125, 10, 32,114,101,116,117,114,110, 32,115,101,108,102, 10, + 101,110,100, 10, 10, 45, 45, 32,112,117,115,104, 32, 99,111, + 110,116, 97,105,110,101,114, 10,102,117,110, 99,116,105,111, + 110, 32,112,117,115,104, 32, 40,116, 41, 10, 9,116, 46,112, + 114,111,120, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116, + 97,105,110,101,114, 46, 99,117,114,114, 10, 32, 99,108, 97, + 115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114, + 114, 32, 61, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,112, + 111,112, 32, 99,111,110,116, 97,105,110,101,114, 10,102,117, + 110, 99,116,105,111,110, 32,112,111,112, 32, 40, 41, 10, 45, + 45,112,114,105,110,116, 40, 34,110, 97,109,101, 34, 44, 99, + 108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99, + 117,114,114, 46,110, 97,109,101, 41, 10, 45, 45,102,111,114, + 101, 97, 99,104, 40, 99,108, 97,115,115, 67,111,110,116, 97, + 105,110,101,114, 46, 99,117,114,114, 46,117,115,101,114,116, + 121,112,101,115, 44,112,114,105,110,116, 41, 10, 45, 45,112, + 114,105,110,116, 40, 34, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 34, 41, 10, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 32, 61, + 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, + 46, 99,117,114,114, 46,112,114,111,120, 10,101,110,100, 10, + 10, 45, 45, 32,103,101,116, 32, 99,117,114,114,101,110,116, + 32,110, 97,109,101,115,112, 97, 99,101, 10,102,117,110, 99, + 116,105,111,110, 32,103,101,116, 99,117,114,114,110, 97,109, + 101,115,112, 97, 99,101, 32, 40, 41, 10, 9,114,101,116,117, + 114,110, 32,103,101,116,110, 97,109,101,115,112, 97, 99,101, + 40, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, + 46, 99,117,114,114, 41, 10,101,110,100, 10, 10, 45, 45, 32, + 97,112,112,101,110,100, 32,116,111, 32, 99,117,114,114,101, + 110,116, 32, 99,111,110,116, 97,105,110,101,114, 10,102,117, + 110, 99,116,105,111,110, 32, 97,112,112,101,110,100, 32, 40, + 116, 41, 10, 32,114,101,116,117,114,110, 32, 99,108, 97,115, + 115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, + 58, 97,112,112,101,110,100, 40,116, 41, 10,101,110,100, 10, + 10, 45, 45, 32, 97,112,112,101,110,100, 32,116,121,112,101, + 100,101,102, 32,116,111, 32, 99,117,114,114,101,110,116, 32, + 99,111,110,116, 97,105,110,101,114, 10,102,117,110, 99,116, + 105,111,110, 32, 97,112,112,101,110,100,116,121,112,101,100, + 101,102, 32, 40,116, 41, 10, 32,114,101,116,117,114,110, 32, + 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, + 99,117,114,114, 58, 97,112,112,101,110,100,116,121,112,101, + 100,101,102, 40,116, 41, 10,101,110,100, 10, 10, 45, 45, 32, + 97,112,112,101,110,100, 32,117,115,101,114,116,121,112,101, + 32,116,111, 32, 99,117,114,114,101,110,116, 32, 99,111,110, + 116, 97,105,110,101,114, 10,102,117,110, 99,116,105,111,110, + 32, 97,112,112,101,110,100,117,115,101,114,116,121,112,101, + 32, 40,116, 41, 10, 32,114,101,116,117,114,110, 32, 99,108, + 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117, + 114,114, 58, 97,112,112,101,110,100,117,115,101,114,116,121, + 112,101, 40,116, 41, 10,101,110,100, 10, 10, 45, 45, 32, 97, + 112,112,101,110,100, 32,101,110,117,109, 32,116,111, 32, 99, + 117,114,114,101,110,116, 32, 99,111,110,116, 97,105,110,101, + 114, 10,102,117,110, 99,116,105,111,110, 32, 97,112,112,101, + 110,100,101,110,117,109, 32, 40,116, 41, 10, 32,114,101,116, + 117,114,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105, + 110,101,114, 46, 99,117,114,114, 58, 97,112,112,101,110,100, + 101,110,117,109, 40,116, 41, 10,101,110,100, 10, 10, 45, 45, + 32,115,117, 98,115,116,105,116,117,116,101, 32,116,121,112, + 101,100,101,102, 10,102,117,110, 99,116,105,111,110, 32, 97, + 112,112,108,121,116,121,112,101,100,101,102, 32, 40,109,111, + 100, 44,116,121,112,101, 41, 10, 32,114,101,116,117,114,110, + 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, + 46, 99,117,114,114, 58, 97,112,112,108,121,116,121,112,101, + 100,101,102, 40,109,111,100, 44,116,121,112,101, 41, 10,101, + 110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, + 32,105,115, 32,116,121,112,101, 10,102,117,110, 99,116,105, + 111,110, 32,102,105,110,100,116,121,112,101, 32, 40,116,121, + 112,101, 41, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32, + 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, + 99,117,114,114, 58,102,105,110,100,116,121,112,101, 40,116, + 121,112,101, 41, 10, 9,114,101,116,117,114,110, 32,116, 10, + 101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105, + 102, 32,105,115, 32,116,121,112,101,100,101,102, 10,102,117, + 110, 99,116,105,111,110, 32,105,115,116,121,112,101,100,101, + 102, 32, 40,116,121,112,101, 41, 10, 32,114,101,116,117,114, + 110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101, + 114, 46, 99,117,114,114, 58,105,115,116,121,112,101,100,101, + 102, 40,116,121,112,101, 41, 10,101,110,100, 10, 10, 45, 45, + 32,103,101,116, 32,102,117,108,108,116,121,112,101, 32, 40, + 119,105,116,104, 32,110, 97,109,101,115,112, 97, 99,101, 41, + 10,102,117,110, 99,116,105,111,110, 32,102,117,108,108,116, + 121,112,101, 32, 40,116, 41, 10, 32,108,111, 99, 97,108, 32, + 99,117,114,114, 32, 61, 32, 32, 99,108, 97,115,115, 67,111, + 110,116, 97,105,110,101,114, 46, 99,117,114,114, 10, 9,119, + 104,105,108,101, 32, 99,117,114,114, 32,100,111, 10, 9, 32, + 105,102, 32, 99,117,114,114, 32,116,104,101,110, 10, 9, 9, + 32,105,102, 32, 99,117,114,114, 46,116,121,112,101,100,101, + 102,115, 32, 97,110,100, 32, 99,117,114,114, 46,116,121,112, + 101,100,101,102,115, 91,116, 93, 32,116,104,101,110, 10, 9, + 9, 32, 32,114,101,116,117,114,110, 32, 99,117,114,114, 46, + 116,121,112,101,100,101,102,115, 91,116, 93, 10, 9, 9, 32, + 101,108,115,101,105,102, 32, 99,117,114,114, 46,117,115,101, + 114,116,121,112,101,115, 32, 97,110,100, 32, 99,117,114,114, + 46,117,115,101,114,116,121,112,101,115, 91,116, 93, 32,116, + 104,101,110, 10, 9, 9, 32, 32,114,101,116,117,114,110, 32, + 99,117,114,114, 46,117,115,101,114,116,121,112,101,115, 91, + 116, 93, 10, 9, 9, 9,101,110,100, 10, 9, 9,101,110,100, + 10, 9, 32, 99,117,114,114, 32, 61, 32, 99,117,114,114, 46, + 112,114,111,120, 10, 9,101,110,100, 10, 9,114,101,116,117, + 114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 99,104, + 101, 99,107,115, 32,105,102, 32,105,116, 32,114,101,113,117, + 105,114,101,115, 32, 99,111,108,108,101, 99,116,105,111,110, + 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, + 67,111,110,116, 97,105,110,101,114, 58,114,101,113,117,105, + 114,101, 99,111,108,108,101, 99,116,105,111,110, 32, 40,116, + 41, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10, 32, + 108,111, 99, 97,108, 32,105, 61, 49, 10, 9,108,111, 99, 97, + 108, 32,114, 32, 61, 32,102, 97,108,115,101, 10, 32,119,104, + 105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, + 32, 32,114, 32, 61, 32,115,101,108,102, 91,105, 93, 58,114, + 101,113,117,105,114,101, 99,111,108,108,101, 99,116,105,111, + 110, 40,116, 41, 32,111,114, 32,114, 10, 32, 32,105, 32, 61, + 32,105, 43, 49, 10, 32,101,110,100, 10, 9,112,111,112, 40, + 41, 10, 9,114,101,116,117,114,110, 32,114, 10,101,110,100, + 10, 10, 10, 45, 45, 32,103,101,116, 32,110, 97,109,101,115, + 97,112, 99,101, 10,102,117,110, 99,116,105,111,110, 32,103, + 101,116,110, 97,109,101,115,112, 97, 99,101, 32, 40, 99,117, + 114,114, 41, 10, 9,108,111, 99, 97,108, 32,110, 97,109,101, + 115,112, 97, 99,101, 32, 61, 32, 39, 39, 10, 9,119,104,105, + 108,101, 32, 99,117,114,114, 32,100,111, 10, 9, 32,105,102, + 32, 99,117,114,114, 32, 97,110,100, 10, 9, 9, 32, 32, 32, + 40, 32, 99,117,114,114, 46, 99,108, 97,115,115,116,121,112, + 101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32,111,114, + 32, 99,117,114,114, 46, 99,108, 97,115,115,116,121,112,101, + 32, 61, 61, 32, 39,110, 97,109,101,115,112, 97, 99,101, 39, + 41, 10, 9, 9,116,104,101,110, 10, 9, 9, 32,110, 97,109, + 101,115,112, 97, 99,101, 32, 61, 32, 40, 99,117,114,114, 46, + 111,114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,111, + 114, 32, 99,117,114,114, 46,110, 97,109,101, 41, 32, 46, 46, + 32, 39, 58, 58, 39, 32, 46, 46, 32,110, 97,109,101,115,112, + 97, 99,101, 10, 9, 9, 32, 45, 45,110, 97,109,101,115,112, + 97, 99,101, 32, 61, 32, 99,117,114,114, 46,110, 97,109,101, + 32, 46, 46, 32, 39, 58, 58, 39, 32, 46, 46, 32,110, 97,109, + 101,115,112, 97, 99,101, 10, 9, 9,101,110,100, 10, 9, 32, + 99,117,114,114, 32, 61, 32, 99,117,114,114, 46,112,114,111, + 120, 10, 9,101,110,100, 10, 9,114,101,116,117,114,110, 32, + 110, 97,109,101,115,112, 97, 99,101, 10,101,110,100, 10, 10, + 45, 45, 32,103,101,116, 32,110, 97,109,101,115,112, 97, 99, + 101, 32, 40,111,110,108,121, 32,110, 97,109,101,115,112, 97, + 99,101, 41, 10,102,117,110, 99,116,105,111,110, 32,103,101, + 116,111,110,108,121,110, 97,109,101,115,112, 97, 99,101, 32, + 40, 41, 10, 32,108,111, 99, 97,108, 32, 99,117,114,114, 32, + 61, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101, + 114, 46, 99,117,114,114, 10, 9,108,111, 99, 97,108, 32,110, + 97,109,101,115,112, 97, 99,101, 32, 61, 32, 39, 39, 10, 9, + 119,104,105,108,101, 32, 99,117,114,114, 32,100,111, 10, 9, + 9,105,102, 32, 99,117,114,114, 46, 99,108, 97,115,115,116, + 121,112,101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32, + 116,104,101,110, 10, 9, 9, 32,114,101,116,117,114,110, 32, + 110, 97,109,101,115,112, 97, 99,101, 10, 9, 9,101,108,115, + 101,105,102, 32, 99,117,114,114, 46, 99,108, 97,115,115,116, + 121,112,101, 32, 61, 61, 32, 39,110, 97,109,101,115,112, 97, + 99,101, 39, 32,116,104,101,110, 10, 9, 9, 32,110, 97,109, + 101,115,112, 97, 99,101, 32, 61, 32, 99,117,114,114, 46,110, + 97,109,101, 32, 46, 46, 32, 39, 58, 58, 39, 32, 46, 46, 32, + 110, 97,109,101,115,112, 97, 99,101, 10, 9, 9,101,110,100, + 10, 9, 32, 99,117,114,114, 32, 61, 32, 99,117,114,114, 46, + 112,114,111,120, 10, 9,101,110,100, 10, 9,114,101,116,117, + 114,110, 32,110, 97,109,101,115,112, 97, 99,101, 10,101,110, + 100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32, + 105,115, 32,101,110,117,109, 10,102,117,110, 99,116,105,111, + 110, 32,105,115,101,110,117,109, 32, 40,116,121,112,101, 41, + 10, 32,114,101,116,117,114,110, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 58,105, + 115,101,110,117,109, 40,116,121,112,101, 41, 10,101,110,100, + 10, 10, 45, 45, 32, 97,112,112,101,110,100, 32,102,101, 97, + 116,117,114,101, 32,116,111, 32, 99,111,110,116, 97,105,110, + 101,114, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 67,111,110,116, 97,105,110,101,114, 58, 97,112,112, + 101,110,100, 32, 40,116, 41, 10, 32,115,101,108,102, 46,110, + 32, 61, 32,115,101,108,102, 46,110, 32, 43, 32, 49, 10, 32, + 115,101,108,102, 91,115,101,108,102, 46,110, 93, 32, 61, 32, + 116, 10, 32,116, 46,112, 97,114,101,110,116, 32, 61, 32,115, + 101,108,102, 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112, + 101,110,100, 32,116,121,112,101,100,101,102, 10,102,117,110, + 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,110,116, + 97,105,110,101,114, 58, 97,112,112,101,110,100,116,121,112, + 101,100,101,102, 32, 40,116, 41, 10, 32,108,111, 99, 97,108, + 32,110, 97,109,101,115,112, 97, 99,101, 32, 61, 32,103,101, + 116,110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97,115, + 115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, + 41, 10, 32,115,101,108,102, 46,116,121,112,101,100,101,102, + 115, 46,116,111,108,117, 97, 95,110, 32, 61, 32,115,101,108, + 102, 46,116,121,112,101,100,101,102,115, 46,116,111,108,117, + 97, 95,110, 32, 43, 32, 49, 10, 32,115,101,108,102, 46,116, + 121,112,101,100,101,102,115, 91,115,101,108,102, 46,116,121, + 112,101,100,101,102,115, 46,116,111,108,117, 97, 95,110, 93, + 32, 61, 32,116, 10, 9,115,101,108,102, 46,116,121,112,101, + 100,101,102,115, 91,116, 46,117,116,121,112,101, 93, 32, 61, + 32,110, 97,109,101,115,112, 97, 99,101, 32, 46, 46, 32,116, + 46,117,116,121,112,101, 10, 9,103,108,111, 98, 97,108, 95, + 116,121,112,101,100,101,102,115, 91,110, 97,109,101,115,112, + 97, 99,101, 46, 46,116, 46,117,116,121,112,101, 93, 32, 61, + 32,116, 10, 9,116, 46,102,116,121,112,101, 32, 61, 32,102, + 105,110,100,116,121,112,101, 40,116, 46,116,121,112,101, 41, + 32,111,114, 32,116, 46,116,121,112,101, 10, 9, 45, 45,112, + 114,105,110,116, 40, 34, 97,112,112,101,110,100,105,110,103, + 32,116,121,112,101,100,101,102, 32, 34, 46, 46,116, 46,117, + 116,121,112,101, 46, 46, 34, 32, 97,115, 32, 34, 46, 46,110, + 97,109,101,115,112, 97, 99,101, 46, 46,116, 46,117,116,121, + 112,101, 46, 46, 34, 32,119,105,116,104, 32,102,116,121,112, + 101, 32, 34, 46, 46,116, 46,102,116,121,112,101, 41, 10, 9, + 97,112,112,101,110,100, 95,103,108,111, 98, 97,108, 95,116, + 121,112,101, 40,110, 97,109,101,115,112, 97, 99,101, 46, 46, + 116, 46,117,116,121,112,101, 41, 10, 9,105,102, 32,116, 46, + 102,116,121,112,101, 32, 97,110,100, 32,105,115,101,110,117, + 109, 40,116, 46,102,116,121,112,101, 41, 32,116,104,101,110, + 10, 10, 9, 9,103,108,111, 98, 97,108, 95,101,110,117,109, + 115, 91,110, 97,109,101,115,112, 97, 99,101, 46, 46,116, 46, + 117,116,121,112,101, 93, 32, 61, 32,116,114,117,101, 10, 9, + 101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112, + 101,110,100, 32,117,115,101,114,116,121,112,101, 58, 32,114, + 101,116,117,114,110, 32,102,117,108,108, 32,116,121,112,101, + 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, + 67,111,110,116, 97,105,110,101,114, 58, 97,112,112,101,110, + 100,117,115,101,114,116,121,112,101, 32, 40,116, 41, 10, 9, + 108,111, 99, 97,108, 32, 99,111,110,116, 97,105,110,101,114, + 10, 9,105,102, 32,116, 32, 61, 61, 32, 40,115,101,108,102, + 46,111,114,105,103,105,110, 97,108, 95,110, 97,109,101, 32, + 111,114, 32,115,101,108,102, 46,110, 97,109,101, 41, 32,116, + 104,101,110, 10, 9, 9, 99,111,110,116, 97,105,110,101,114, + 32, 61, 32,115,101,108,102, 46,112,114,111,120, 10, 9,101, + 108,115,101, 10, 9, 9, 99,111,110,116, 97,105,110,101,114, + 32, 61, 32,115,101,108,102, 10, 9,101,110,100, 10, 9,108, + 111, 99, 97,108, 32,102,116, 32, 61, 32,103,101,116,110, 97, + 109,101,115,112, 97, 99,101, 40, 99,111,110,116, 97,105,110, + 101,114, 41, 32, 46, 46, 32,116, 10, 9, 99,111,110,116, 97, + 105,110,101,114, 46,117,115,101,114,116,121,112,101,115, 91, + 116, 93, 32, 61, 32,102,116, 10, 9, 95,117,115,101,114,116, + 121,112,101, 91,102,116, 93, 32, 61, 32,102,116, 10, 9,114, + 101,116,117,114,110, 32,102,116, 10,101,110,100, 10, 10, 45, + 45, 32, 97,112,112,101,110,100, 32,101,110,117,109, 10,102, + 117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111, + 110,116, 97,105,110,101,114, 58, 97,112,112,101,110,100,101, + 110,117,109, 32, 40,116, 41, 10, 32,108,111, 99, 97,108, 32, + 110, 97,109,101,115,112, 97, 99,101, 32, 61, 32,103,101,116, + 110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97,115,115, + 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 41, + 10, 32,115,101,108,102, 46,101,110,117,109,115, 46,116,111, + 108,117, 97, 95,110, 32, 61, 32,115,101,108,102, 46,101,110, + 117,109,115, 46,116,111,108,117, 97, 95,110, 32, 43, 32, 49, + 10, 32,115,101,108,102, 46,101,110,117,109,115, 91,115,101, + 108,102, 46,101,110,117,109,115, 46,116,111,108,117, 97, 95, + 110, 93, 32, 61, 32,116, 10, 9,103,108,111, 98, 97,108, 95, + 101,110,117,109,115, 91,110, 97,109,101,115,112, 97, 99,101, + 46, 46,116, 46,110, 97,109,101, 93, 32, 61, 32,116, 10,101, + 110,100, 10, 10, 45, 45, 32,100,101,116,101,114,109,105,110, + 101, 32,108,117, 97, 32,102,117,110, 99,116,105,111,110, 32, + 110, 97,109,101, 32,111,118,101,114,108,111, 97,100, 10,102, + 117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111, + 110,116, 97,105,110,101,114, 58,111,118,101,114,108,111, 97, + 100, 32, 40,108,110, 97,109,101, 41, 10, 32,105,102, 32,110, + 111,116, 32,115,101,108,102, 46,108,110, 97,109,101,115, 91, + 108,110, 97,109,101, 93, 32,116,104,101,110, 10, 32, 32,115, + 101,108,102, 46,108,110, 97,109,101,115, 91,108,110, 97,109, + 101, 93, 32, 61, 32, 48, 10, 32,101,108,115,101, 10, 32, 32, + 115,101,108,102, 46,108,110, 97,109,101,115, 91,108,110, 97, + 109,101, 93, 32, 61, 32,115,101,108,102, 46,108,110, 97,109, + 101,115, 91,108,110, 97,109,101, 93, 32, 43, 32, 49, 10, 32, + 101,110,100, 10, 32,114,101,116,117,114,110, 32,102,111,114, + 109, 97,116, 40, 34, 37, 48, 50,100, 34, 44,115,101,108,102, + 46,108,110, 97,109,101,115, 91,108,110, 97,109,101, 93, 41, + 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112,108,105,101, + 115, 32,116,121,112,101,100,101,102, 58, 32,114,101,116,117, + 114,110,115, 32,116,104,101, 32, 39,116,104,101, 32,102, 97, + 99,116,111, 39, 32,109,111,100,105,102,105,101,114, 32, 97, + 110,100, 32,116,121,112,101, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101, + 114, 58, 97,112,112,108,121,116,121,112,101,100,101,102, 32, + 40,109,111,100, 44,116,121,112,101, 41, 10, 9,105,102, 32, + 103,108,111, 98, 97,108, 95,116,121,112,101,100,101,102,115, + 91,116,121,112,101, 93, 32,116,104,101,110, 10, 9, 9, 45, + 45,112,114,105,110,116, 40, 34,102,111,117,110,100, 32,116, + 121,112,101,100,101,102, 32, 34, 46, 46,103,108,111, 98, 97, + 108, 95,116,121,112,101,100,101,102,115, 91,116,121,112,101, + 93, 46,116,121,112,101, 41, 10, 9, 9,108,111, 99, 97,108, + 32,109,111,100, 49, 44, 32,116,121,112,101, 49, 32, 61, 32, + 103,108,111, 98, 97,108, 95,116,121,112,101,100,101,102,115, + 91,116,121,112,101, 93, 46,109,111,100, 44, 32,103,108,111, + 98, 97,108, 95,116,121,112,101,100,101,102,115, 91,116,121, + 112,101, 93, 46,102,116,121,112,101, 10, 9, 9,108,111, 99, + 97,108, 32,109,111,100, 50, 44, 32,116,121,112,101, 50, 32, + 61, 32, 97,112,112,108,121,116,121,112,101,100,101,102, 40, + 109,111,100, 46, 46, 34, 32, 34, 46, 46,109,111,100, 49, 44, + 32,116,121,112,101, 49, 41, 10, 9, 9, 45, 45,114,101,116, + 117,114,110, 32,109,111,100, 50, 32, 46, 46, 32, 39, 32, 39, + 32, 46, 46, 32,109,111,100, 49, 44, 32,116,121,112,101, 50, + 10, 9, 9,114,101,116,117,114,110, 32,109,111,100, 50, 44, + 32,116,121,112,101, 50, 10, 9,101,110,100, 10, 9,100,111, + 32,114,101,116,117,114,110, 32,109,111,100, 44,116,121,112, + 101, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99, + 104,101, 99,107, 32,105,102, 32,105,116, 32,105,115, 32, 97, + 32,116,121,112,101,100,101,102, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110, + 101,114, 58,105,115,116,121,112,101,100,101,102, 32, 40,116, + 121,112,101, 41, 10, 32,108,111, 99, 97,108, 32,101,110,118, + 32, 61, 32,115,101,108,102, 10, 32,119,104,105,108,101, 32, + 101,110,118, 32,100,111, 10, 32, 32,105,102, 32,101,110,118, + 46,116,121,112,101,100,101,102,115, 32,116,104,101,110, 10, + 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32, + 32,119,104,105,108,101, 32,101,110,118, 46,116,121,112,101, + 100,101,102,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32, + 105,102, 32,101,110,118, 46,116,121,112,101,100,101,102,115, + 91,105, 93, 46,117,116,121,112,101, 32, 61, 61, 32,116,121, + 112,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, + 32, 32,114,101,116,117,114,110, 32,116,121,112,101, 10, 32, + 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, + 32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32, + 101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,101,110,118, + 32, 61, 32,101,110,118, 46,112, 97,114,101,110,116, 10, 32, + 101,110,100, 10, 32,114,101,116,117,114,110, 32,110,105,108, + 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, + 102,105,110,100, 95,101,110,117,109, 95,118, 97,114, 40,118, + 97,114, 41, 10, 10, 9,105,102, 32,116,111,110,117,109, 98, + 101,114, 40,118, 97,114, 41, 32,116,104,101,110, 32,114,101, + 116,117,114,110, 32,118, 97,114, 32,101,110,100, 10, 10, 9, + 108,111, 99, 97,108, 32, 99, 32, 61, 32, 99,108, 97,115,115, + 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 10, + 9,119,104,105,108,101, 32, 99, 32,100,111, 10, 9, 9,108, + 111, 99, 97,108, 32,110,115, 32, 61, 32,103,101,116,110, 97, + 109,101,115,112, 97, 99,101, 40, 99, 41, 10, 9, 9,102,111, + 114, 32,107, 44,118, 32,105,110, 32,112, 97,105,114,115, 40, + 95,103,108,111, 98, 97,108, 95,101,110,117,109,115, 41, 32, + 100,111, 10, 9, 9, 9,105,102, 32,109, 97,116, 99,104, 95, + 116,121,112,101, 40,118, 97,114, 44, 32,118, 44, 32,110,115, + 41, 32,116,104,101,110, 10, 9, 9, 9, 9,114,101,116,117, + 114,110, 32,118, 10, 9, 9, 9,101,110,100, 10, 9, 9,101, + 110,100, 10, 9, 9,105,102, 32, 99, 46, 98, 97,115,101, 32, + 97,110,100, 32, 99, 46, 98, 97,115,101, 32,126, 61, 32, 39, + 39, 32,116,104,101,110, 10, 9, 9, 9, 99, 32, 61, 32, 95, + 103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91, + 99, 58,102,105,110,100,116,121,112,101, 40, 99, 46, 98, 97, + 115,101, 41, 93, 10, 9, 9,101,108,115,101, 10, 9, 9, 9, + 99, 32, 61, 32,110,105,108, 10, 9, 9,101,110,100, 10, 9, + 101,110,100, 10, 10, 9,114,101,116,117,114,110, 32,118, 97, + 114, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, + 32,105,102, 32,105,115, 32, 97, 32,114,101,103,105,115,116, + 101,114,101,100, 32,116,121,112,101, 58, 32,114,101,116,117, + 114,110, 32,102,117,108,108, 32,116,121,112,101, 32,111,114, + 32,110,105,108, 10,102,117,110, 99,116,105,111,110, 32, 99, + 108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,102, + 105,110,100,116,121,112,101, 32, 40,116, 41, 10, 10, 9,116, + 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, + 116, 44, 32, 34, 61, 46, 42, 34, 44, 32, 34, 34, 41, 10, 9, + 105,102, 32, 95, 98, 97,115,105, 99, 91,116, 93, 32,116,104, + 101,110, 10, 9, 32,114,101,116,117,114,110, 32,116, 10, 9, + 101,110,100, 10, 10, 9,108,111, 99, 97,108, 32, 95, 44, 95, + 44,101,109, 32, 61, 32,115,116,114,105,110,103, 46,102,105, + 110,100, 40,116, 44, 32, 34, 40, 91, 38, 37, 42, 93, 41, 37, + 115, 42, 36, 34, 41, 10, 9,116, 32, 61, 32,115,116,114,105, + 110,103, 46,103,115,117, 98, 40,116, 44, 32, 34, 37,115, 42, + 40, 91, 38, 37, 42, 93, 41, 37,115, 42, 36, 34, 44, 32, 34, + 34, 41, 10, 9,112, 32, 61, 32,115,101,108,102, 10, 9,119, + 104,105,108,101, 32,112, 32, 97,110,100, 32,116,121,112,101, + 40,112, 41, 61, 61, 39,116, 97, 98,108,101, 39, 32,100,111, + 10, 9, 9,108,111, 99, 97,108, 32,115,116, 32, 61, 32,103, + 101,116,110, 97,109,101,115,112, 97, 99,101, 40,112, 41, 10, + 10, 9, 9,102,111,114, 32,105, 61, 95,103,108,111, 98, 97, + 108, 95,116,121,112,101,115, 46,110, 44, 49, 44, 45, 49, 32, + 100,111, 32, 45, 45, 32,105,110, 32,114,101,118,101,114,115, + 101, 32,111,114,100,101,114, 10, 10, 9, 9, 9,105,102, 32, + 109, 97,116, 99,104, 95,116,121,112,101, 40,116, 44, 32, 95, + 103,108,111, 98, 97,108, 95,116,121,112,101,115, 91,105, 93, + 44, 32,115,116, 41, 32,116,104,101,110, 10, 9, 9, 9, 9, + 114,101,116,117,114,110, 32, 95,103,108,111, 98, 97,108, 95, + 116,121,112,101,115, 91,105, 93, 46, 46, 40,101,109, 32,111, + 114, 32, 34, 34, 41, 10, 9, 9, 9,101,110,100, 10, 9, 9, + 101,110,100, 10, 9, 9,105,102, 32,112, 46, 98, 97,115,101, + 32, 97,110,100, 32,112, 46, 98, 97,115,101, 32,126, 61, 32, + 39, 39, 32, 97,110,100, 32,112, 46, 98, 97,115,101, 32,126, + 61, 32,116, 32,116,104,101,110, 10, 9, 9, 9, 45, 45,112, + 114,105,110,116, 40, 34,116,121,112,101, 32,105,115, 32, 34, + 46, 46,116, 46, 46, 34, 44, 32,112, 32,105,115, 32, 34, 46, + 46,112, 46, 98, 97,115,101, 46, 46, 34, 32,115,101,108,102, + 46,116,121,112,101, 32,105,115, 32, 34, 46, 46,115,101,108, + 102, 46,116,121,112,101, 46, 46, 34, 32,115,101,108,102, 46, + 110, 97,109,101, 32,105,115, 32, 34, 46, 46,115,101,108,102, + 46,110, 97,109,101, 41, 10, 9, 9, 9,112, 32, 61, 32, 95, + 103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91, + 112, 58,102,105,110,100,116,121,112,101, 40,112, 46, 98, 97, + 115,101, 41, 93, 10, 9, 9,101,108,115,101, 10, 9, 9, 9, + 112, 32, 61, 32,110,105,108, 10, 9, 9,101,110,100, 10, 9, + 101,110,100, 10, 10, 9,114,101,116,117,114,110, 32,110,105, + 108, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, + 32, 97,112,112,101,110,100, 95,103,108,111, 98, 97,108, 95, + 116,121,112,101, 40,116, 44, 32, 99,108, 97,115,115, 41, 10, + 9, 95,103,108,111, 98, 97,108, 95,116,121,112,101,115, 46, + 110, 32, 61, 32, 95,103,108,111, 98, 97,108, 95,116,121,112, + 101,115, 46,110, 32, 43, 49, 10, 9, 95,103,108,111, 98, 97, + 108, 95,116,121,112,101,115, 91, 95,103,108,111, 98, 97,108, + 95,116,121,112,101,115, 46,110, 93, 32, 61, 32,116, 10, 9, + 95,103,108,111, 98, 97,108, 95,116,121,112,101,115, 95,104, + 97,115,104, 91,116, 93, 32, 61, 32, 49, 10, 9,105,102, 32, + 99,108, 97,115,115, 32,116,104,101,110, 32, 97,112,112,101, + 110,100, 95, 99,108, 97,115,115, 95,116,121,112,101, 40,116, + 44, 32, 99,108, 97,115,115, 41, 32,101,110,100, 10,101,110, + 100, 10, 10,102,117,110, 99,116,105,111,110, 32, 97,112,112, + 101,110,100, 95, 99,108, 97,115,115, 95,116,121,112,101, 40, + 116, 44, 99,108, 97,115,115, 41, 10, 9,105,102, 32, 95,103, + 108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,116, + 93, 32,116,104,101,110, 10, 9, 9, 99,108, 97,115,115, 46, + 102,108, 97,103,115, 32, 61, 32, 95,103,108,111, 98, 97,108, + 95, 99,108, 97,115,115,101,115, 91,116, 93, 46,102,108, 97, + 103,115, 10, 9, 9, 99,108, 97,115,115, 46,108,110, 97,109, + 101,115, 32, 61, 32, 95,103,108,111, 98, 97,108, 95, 99,108, + 97,115,115,101,115, 91,116, 93, 46,108,110, 97,109,101,115, + 10, 9, 9,105,102, 32, 95,103,108,111, 98, 97,108, 95, 99, + 108, 97,115,115,101,115, 91,116, 93, 46, 98, 97,115,101, 32, + 97,110,100, 32, 40, 95,103,108,111, 98, 97,108, 95, 99,108, + 97,115,115,101,115, 91,116, 93, 46, 98, 97,115,101, 32,126, + 61, 32, 39, 39, 41, 32,116,104,101,110, 10, 9, 9, 9, 99, + 108, 97,115,115, 46, 98, 97,115,101, 32, 61, 32, 95,103,108, + 111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,116, 93, + 46, 98, 97,115,101, 32,111,114, 32, 99,108, 97,115,115, 46, + 98, 97,115,101, 10, 9, 9,101,110,100, 10, 9,101,110,100, + 10, 9, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,115, + 101,115, 91,116, 93, 32, 61, 32, 99,108, 97,115,115, 10, 9, + 99,108, 97,115,115, 46,102,108, 97,103,115, 32, 61, 32, 99, + 108, 97,115,115, 46,102,108, 97,103,115, 32,111,114, 32,123, + 125, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, + 32,109, 97,116, 99,104, 95,116,121,112,101, 40, 99,104,105, + 108,100,116,121,112,101, 44, 32,114,101,103,116,121,112,101, + 44, 32,115,116, 41, 10, 45, 45,112,114,105,110,116, 40, 34, + 102,105,110,100,116,121,112,101, 32, 34, 46, 46, 99,104,105, + 108,100,116,121,112,101, 46, 46, 34, 44, 32, 34, 46, 46,114, + 101,103,116,121,112,101, 46, 46, 34, 44, 32, 34, 46, 46,115, + 116, 41, 10, 9,108,111, 99, 97,108, 32, 98, 44,101, 32, 61, + 32,115,116,114,105,110,103, 46,102,105,110,100, 40,114,101, + 103,116,121,112,101, 44, 32, 99,104,105,108,100,116,121,112, + 101, 44, 32, 45,115,116,114,105,110,103, 46,108,101,110, 40, + 99,104,105,108,100,116,121,112,101, 41, 44, 32,116,114,117, + 101, 41, 10, 9,105,102, 32, 98, 32,116,104,101,110, 10, 10, + 9, 9,105,102, 32,101, 32, 61, 61, 32,115,116,114,105,110, + 103, 46,108,101,110, 40,114,101,103,116,121,112,101, 41, 32, + 97,110,100, 10, 9, 9, 9, 9, 40, 98, 32, 61, 61, 32, 49, + 32,111,114, 32, 40,115,116,114,105,110,103, 46,115,117, 98, + 40,114,101,103,116,121,112,101, 44, 32, 98, 45, 49, 44, 32, + 98, 45, 49, 41, 32, 61, 61, 32, 39, 58, 39, 32, 97,110,100, + 10, 9, 9, 9, 9,115,116,114,105,110,103, 46,115,117, 98, + 40,114,101,103,116,121,112,101, 44, 32, 49, 44, 32, 98, 45, + 49, 41, 32, 61, 61, 32,115,116,114,105,110,103, 46,115,117, + 98, 40,115,116, 44, 32, 49, 44, 32, 98, 45, 49, 41, 41, 41, + 32,116,104,101,110, 10, 9, 9, 9,114,101,116,117,114,110, + 32,116,114,117,101, 10, 9, 9,101,110,100, 10, 9,101,110, + 100, 10, 10, 9,114,101,116,117,114,110, 32,102, 97,108,115, + 101, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, + 32,102,105,110,100,116,121,112,101, 95,111,110, 95, 99,104, + 105,108,100,115, 40,115,101,108,102, 44, 32,116, 41, 10, 10, + 9,108,111, 99, 97,108, 32,116, 99,104,105,108,100, 10, 9, + 105,102, 32,115,101,108,102, 46, 99,108, 97,115,115,116,121, + 112,101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32,111, + 114, 32,115,101,108,102, 46, 99,108, 97,115,115,116,121,112, + 101, 32, 61, 61, 32, 39,110, 97,109,101,115,112, 97, 99,101, + 39, 32,116,104,101,110, 10, 9, 9,102,111,114, 32,107, 44, + 118, 32,105,110, 32,105,112, 97,105,114,115, 40,115,101,108, + 102, 41, 32,100,111, 10, 9, 9, 9,105,102, 32,118, 46, 99, + 108, 97,115,115,116,121,112,101, 32, 61, 61, 32, 39, 99,108, + 97,115,115, 39, 32,111,114, 32,118, 46, 99,108, 97,115,115, + 116,121,112,101, 32, 61, 61, 32, 39,110, 97,109,101,115,112, + 97, 99,101, 39, 32,116,104,101,110, 10, 9, 9, 9, 9,105, + 102, 32,118, 46,116,121,112,101,100,101,102,115, 32, 97,110, + 100, 32,118, 46,116,121,112,101,100,101,102,115, 91,116, 93, + 32,116,104,101,110, 10, 9, 9, 9, 9, 32,114,101,116,117, + 114,110, 32,118, 46,116,121,112,101,100,101,102,115, 91,116, + 93, 10, 9, 9, 9, 9,101,108,115,101,105,102, 32,118, 46, + 117,115,101,114,116,121,112,101,115, 32, 97,110,100, 32,118, + 46,117,115,101,114,116,121,112,101,115, 91,116, 93, 32,116, + 104,101,110, 10, 9, 9, 9, 9, 32,114,101,116,117,114,110, + 32,118, 46,117,115,101,114,116,121,112,101,115, 91,116, 93, + 10, 9, 9, 9, 9,101,110,100, 10, 9, 9, 9, 9,116, 99, + 104,105,108,100, 32, 61, 32,102,105,110,100,116,121,112,101, + 95,111,110, 95, 99,104,105,108,100,115, 40,118, 44, 32,116, + 41, 10, 9, 9, 9, 9,105,102, 32,116, 99,104,105,108,100, + 32,116,104,101,110, 32,114,101,116,117,114,110, 32,116, 99, + 104,105,108,100, 32,101,110,100, 10, 9, 9, 9,101,110,100, + 10, 9, 9,101,110,100, 10, 9,101,110,100, 10, 9,114,101, + 116,117,114,110, 32,110,105,108, 10, 10,101,110,100, 10, 10, + 102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 58,105,115,101,110,117,109, + 32, 40,116,121,112,101, 41, 10, 32,105,102, 32,103,108,111, + 98, 97,108, 95,101,110,117,109,115, 91,116,121,112,101, 93, + 32,116,104,101,110, 10, 9,114,101,116,117,114,110, 32,116, + 121,112,101, 10, 32,101,108,115,101, 10, 32, 9,114,101,116, + 117,114,110, 32,102, 97,108,115,101, 10, 32,101,110,100, 10, + 10, 32,108,111, 99, 97,108, 32, 98, 97,115,101,116,121,112, + 101, 32, 61, 32,103,115,117, 98, 40,116,121,112,101, 44, 34, + 94, 46, 42, 58, 58, 34, 44, 34, 34, 41, 10, 32,108,111, 99, + 97,108, 32,101,110,118, 32, 61, 32,115,101,108,102, 10, 32, + 119,104,105,108,101, 32,101,110,118, 32,100,111, 10, 32, 32, + 105,102, 32,101,110,118, 46,101,110,117,109,115, 32,116,104, + 101,110, 10, 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, + 10, 32, 32, 32,119,104,105,108,101, 32,101,110,118, 46,101, + 110,117,109,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32, + 105,102, 32,101,110,118, 46,101,110,117,109,115, 91,105, 93, + 46,110, 97,109,101, 32, 61, 61, 32, 98, 97,115,101,116,121, + 112,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, + 32, 32,114,101,116,117,114,110, 32,116,114,117,101, 10, 32, + 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, + 32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32, + 101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,101,110,118, + 32, 61, 32,101,110,118, 46,112, 97,114,101,110,116, 10, 32, + 101,110,100, 10, 32,114,101,116,117,114,110, 32,102, 97,108, + 115,101, 10,101,110,100, 10, 10,109,101,116,104,111,100,105, + 115,118,105,114,116,117, 97,108, 32, 61, 32,102, 97,108,115, + 101, 32, 45, 45, 32, 97, 32,103,108,111, 98, 97,108, 10, 10, + 45, 45, 32,112, 97,114,115,101, 32, 99,104,117,110,107, 10, + 102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 58,100,111,112, 97,114,115, + 101, 32, 40,115, 41, 10, 45, 45,112,114,105,110,116, 32, 40, + 34,112, 97,114,115,101, 32, 34, 46, 46,115, 41, 10, 10, 32, + 45, 45, 32,116,114,121, 32,116,104,101, 32,112, 97,114,115, + 101,114, 32,104,111,111,107, 10, 32,100,111, 10, 32, 9,108, + 111, 99, 97,108, 32,115,117, 98, 32, 61, 32,112, 97,114,115, + 101,114, 95,104,111,111,107, 40,115, 41, 10, 32, 9,105,102, + 32,115,117, 98, 32,116,104,101,110, 10, 32, 9, 9,114,101, + 116,117,114,110, 32,115,117, 98, 10, 32, 9,101,110,100, 10, + 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,116, + 104,101, 32,110,117,108,108, 32,115,116, 97,116,101,109,101, + 110,116, 10, 32,100,111, 10, 32, 9,108,111, 99, 97,108, 32, + 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114,105, + 110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115, + 42, 59, 34, 41, 10, 32, 9,105,102, 32, 98, 32,116,104,101, + 110, 10, 32, 9, 9,114,101,116,117,114,110, 32,115,116,114, + 115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 9,101,110, + 100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, + 32,101,109,112,116,121, 32,118,101,114, 98, 97,116,105,109, + 32,108,105,110,101, 10, 32,100,111, 10, 32, 9,108,111, 99, + 97,108, 32, 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115, + 116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, + 94, 37,115, 42, 36, 92,110, 34, 41, 10, 32, 9,105,102, 32, + 98, 32,116,104,101,110, 10, 32, 9, 9,114,101,116,117,114, + 110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, + 10, 32, 9,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, + 45, 32,116,114,121, 32, 76,117, 97, 32, 99,111,100,101, 10, + 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101, + 44, 99,111,100,101, 32, 61, 32,115,116,114,102,105,110,100, + 40,115, 44, 34, 94, 37,115, 42, 40, 37, 98, 92, 49, 92, 50, + 41, 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, + 10, 32, 32, 32, 67,111,100,101, 40,115,116,114,115,117, 98, + 40, 99,111,100,101, 44, 50, 44, 45, 50, 41, 41, 10, 32, 32, + 32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40, + 115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101, + 110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32, 67, 32, 99, + 111,100,101, 10, 32,100,111, 10, 32, 32,108,111, 99, 97,108, + 32, 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114, + 102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 37, 98, + 92, 51, 92, 52, 41, 34, 41, 10, 32, 32,105,102, 32, 98, 32, + 116,104,101,110, 10, 9, 99,111,100,101, 32, 61, 32, 39,123, + 39, 46, 46,115,116,114,115,117, 98, 40, 99,111,100,101, 44, + 50, 44, 45, 50, 41, 46, 46, 39, 92,110,125, 92,110, 39, 10, + 9, 86,101,114, 98, 97,116,105,109, 40, 99,111,100,101, 44, + 39,114, 39, 41, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32, + 118,101,114, 98, 97,116,105,109, 32, 99,111,100,101, 32,102, + 111,114, 32, 39,114, 39,101,103,105,115,116,101,114, 32,102, + 114, 97,103,109,101,110,116, 10, 9,114,101,116,117,114,110, + 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, + 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, + 32,116,114,121, 32, 67, 32, 99,111,100,101, 32,102,111,114, + 32,112,114,101, 97,109, 98,108,101, 32,115,101, 99,116,105, + 111,110, 10, 32,100,111, 10, 32, 9,108,111, 99, 97,108, 32, + 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114,105, + 110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115, + 42, 40, 37, 98, 92, 53, 92, 54, 41, 34, 41, 10, 32, 9,105, + 102, 32, 98, 32,116,104,101,110, 10, 32, 9, 9, 99,111,100, + 101, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40, + 99,111,100,101, 44, 32, 50, 44, 32, 45, 50, 41, 46, 46, 34, + 92,110, 34, 10, 9, 9, 86,101,114, 98, 97,116,105,109, 40, + 99,111,100,101, 44, 32, 39, 39, 41, 10, 9, 9,114,101,116, + 117,114,110, 32,115,116,114,105,110,103, 46,115,117, 98, 40, + 115, 44, 32,101, 43, 49, 41, 10, 32, 9,101,110,100, 10, 32, + 101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,100,101, + 102, 97,117,108,116, 95,112,114,111,112,101,114,116,121, 32, + 100,105,114,101, 99,116,105,118,101, 10, 32,100,111, 10, 32, + 9,108,111, 99, 97,108, 32, 98, 44,101, 44,112,116,121,112, + 101, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 32, + 34, 94, 37,115, 42, 84, 79, 76, 85, 65, 95, 80, 82, 79, 80, + 69, 82, 84, 89, 95, 84, 89, 80, 69, 37,115, 42, 37, 40, 43, + 37,115, 42, 40, 91, 94, 37, 41, 37,115, 93, 42, 41, 37,115, + 42, 37, 41, 43, 37,115, 42, 59, 63, 34, 41, 10, 32, 9,105, + 102, 32, 98, 32,116,104,101,110, 10, 32, 9, 9,105,102, 32, + 110,111,116, 32,112,116,121,112,101, 32,111,114, 32,112,116, + 121,112,101, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10, + 32, 9, 9, 9,112,116,121,112,101, 32, 61, 32, 34,100,101, + 102, 97,117,108,116, 34, 10, 32, 9, 9,101,110,100, 10, 32, + 9, 9,115,101,108,102, 58,115,101,116, 95,112,114,111,112, + 101,114,116,121, 95,116,121,112,101, 40,112,116,121,112,101, + 41, 10, 9, 32, 9,114,101,116,117,114,110, 32,115,116,114, + 115,117, 98, 40,115, 44, 32,101, 43, 49, 41, 10, 32, 9,101, + 110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114, + 121, 32,112,114,111,116,101, 99,116,101,100, 95,100,101,115, + 116,114,117, 99,116,111,114, 32,100,105,114,101, 99,116,105, + 118,101, 10, 32,100,111, 10, 32, 9,108,111, 99, 97,108, 32, + 98, 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,105, + 110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 84, 79, 76, 85, + 65, 95, 80, 82, 79, 84, 69, 67, 84, 69, 68, 95, 68, 69, 83, + 84, 82, 85, 67, 84, 79, 82, 37,115, 42, 59, 63, 34, 41, 10, + 9,105,102, 32, 98, 32,116,104,101,110, 10, 9, 9,105,102, + 32,115,101,108,102, 46,115,101,116, 95,112,114,111,116,101, + 99,116,101,100, 95,100,101,115,116,114,117, 99,116,111,114, + 32,116,104,101,110, 10, 9, 32, 9, 9,115,101,108,102, 58, + 115,101,116, 95,112,114,111,116,101, 99,116,101,100, 95,100, + 101,115,116,114,117, 99,116,111,114, 40,116,114,117,101, 41, + 10, 9, 32, 9,101,110,100, 10, 32, 9, 9,114,101,116,117, + 114,110, 32,115,116,114,115,117, 98, 40,115, 44, 32,101, 43, + 49, 41, 10, 32, 9,101,110,100, 10, 32,101,110,100, 10, 10, + 32, 45, 45, 32,116,114,121, 32, 39,101,120,116,101,114,110, + 39, 32,107,101,121,119,111,114,100, 10, 32,100,111, 10, 32, + 9,108,111, 99, 97,108, 32, 98, 44,101, 32, 61, 32,115,116, + 114,105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, + 37,115, 42,101,120,116,101,114,110, 37,115, 43, 34, 41, 10, + 32, 9,105,102, 32, 98, 32,116,104,101,110, 10, 9, 9, 45, + 45, 32,100,111, 32,110,111,116,104,105,110,103, 10, 32, 9, + 9,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40, + 115, 44, 32,101, 43, 49, 41, 10, 32, 9,101,110,100, 10, 32, + 101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32, 39,118, + 105,114,116,117, 97,108, 39, 32,107,101,121,119,111,114,107, + 100, 10, 32,100,111, 10, 32, 9,108,111, 99, 97,108, 32, 98, + 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110, + 100, 40,115, 44, 32, 34, 94, 37,115, 42,118,105,114,116,117, + 97,108, 37,115, 43, 34, 41, 10, 32, 9,105,102, 32, 98, 32, + 116,104,101,110, 10, 32, 9, 9,109,101,116,104,111,100,105, + 115,118,105,114,116,117, 97,108, 32, 61, 32,116,114,117,101, + 10, 32, 9, 9,114,101,116,117,114,110, 32,115,116,114,115, + 117, 98, 40,115, 44, 32,101, 43, 49, 41, 10, 32, 9,101,110, + 100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, + 32,108, 97, 98,101,108,115, 32, 40,112,117, 98,108,105, 99, + 44, 32,112,114,105,118, 97,116,101, 44, 32,101,116, 99, 41, + 10, 32,100,111, 10, 32, 9,108,111, 99, 97,108, 32, 98, 44, + 101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, + 40,115, 44, 32, 34, 94, 37,115, 42, 37,119, 42, 37,115, 42, + 58, 91, 94, 58, 93, 34, 41, 10, 32, 9,105,102, 32, 98, 32, + 116,104,101,110, 10, 32, 9, 9,114,101,116,117,114,110, 32, + 115,116,114,115,117, 98, 40,115, 44, 32,101, 41, 32, 45, 45, + 32,112,114,101,115,101,114,118,101, 32,116,104,101, 32, 91, + 94, 58, 93, 10, 32, 9,101,110,100, 10, 32,101,110,100, 10, + 10, 32, 45, 45, 32,116,114,121, 32,109,111,100,117,108,101, + 10, 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44, + 101, 44,110, 97,109,101, 44, 98,111,100,121, 32, 61, 32,115, + 116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42,109, + 111,100,117,108,101, 37,115, 37,115, 42, 40, 91, 95, 37,119, + 93, 91, 95, 37,119, 93, 42, 41, 37,115, 42, 40, 37, 98,123, + 125, 41, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32, 98, 32, + 116,104,101,110, 10, 32, 32, 32, 95, 99,117,114,114, 95, 99, + 111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44, + 98, 44,101, 41, 10, 32, 32, 32, 77,111,100,117,108,101, 40, + 110, 97,109,101, 44, 98,111,100,121, 41, 10, 32, 32, 32,114, + 101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44, + 101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, + 10, 10, 32, 45, 45, 32,116,114,121, 32,110, 97,109,101,115, + 97,112, 99,101, 10, 32,100,111, 10, 32, 32,108,111, 99, 97, + 108, 32, 98, 44,101, 44,110, 97,109,101, 44, 98,111,100,121, + 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, + 37,115, 42,110, 97,109,101,115,112, 97, 99,101, 37,115, 37, + 115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 93, 42, 41, + 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 59, 63, 34, + 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10, 32, + 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32, + 115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 32, + 32, 32, 78, 97,109,101,115,112, 97, 99,101, 40,110, 97,109, + 101, 44, 98,111,100,121, 41, 10, 32, 32, 32,114,101,116,117, + 114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, + 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, + 45, 45, 32,116,114,121, 32,100,101,102,105,110,101, 10, 32, + 100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44, + 110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,100, 40, + 115, 44, 34, 94, 37,115, 42, 35,100,101,102,105,110,101, 37, + 115, 37,115, 42, 40, 91, 94, 37,115, 93, 42, 41, 91, 94, 92, + 110, 93, 42, 92,110, 37,115, 42, 34, 41, 10, 32, 32,105,102, + 32, 98, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,114, + 114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, + 40,115, 44, 98, 44,101, 41, 10, 32, 32, 32, 68,101,102,105, + 110,101, 40,110, 97,109,101, 41, 10, 32, 32, 32,114,101,116, + 117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, + 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, + 32, 45, 45, 32,116,114,121, 32,101,110,117,109,101,114, 97, + 116,101,115, 10, 10, 32,100,111, 10, 32, 32,108,111, 99, 97, + 108, 32, 98, 44,101, 44,110, 97,109,101, 44, 98,111,100,121, + 44,118, 97,114,110, 97,109,101, 32, 61, 32,115,116,114,102, + 105,110,100, 40,115, 44, 34, 94, 37,115, 42,101,110,117,109, + 37,115, 43, 40, 37, 83, 42, 41, 37,115, 42, 40, 37, 98,123, + 125, 41, 37,115, 42, 40, 91, 94, 37,115, 59, 93, 42, 41, 37, + 115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32, + 98, 32,116,104,101,110, 10, 32, 32, 32, 45, 45,101,114,114, + 111,114, 40, 34, 35, 83,111,114,114,121, 44, 32,100,101, 99, + 108, 97,114, 97,116,105,111,110, 32,111,102, 32,101,110,117, + 109,115, 32, 97,110,100, 32,118, 97,114,105, 97, 98,108,101, + 115, 32,111,110, 32,116,104,101, 32,115, 97,109,101, 32,115, + 116, 97,116,101,109,101,110,116, 32,105,115, 32,110,111,116, + 32,115,117,112,112,111,114,116,101,100, 46, 92,110, 68,101, + 99,108, 97,114,101, 32,121,111,117,114, 32,118, 97,114,105, + 97, 98,108,101, 32,115,101,112, 97,114, 97,116,101,108,121, + 32, 40,101,120, 97,109,112,108,101, 58, 32, 39, 34, 46, 46, + 110, 97,109,101, 46, 46, 34, 32, 34, 46, 46,118, 97,114,110, + 97,109,101, 46, 46, 34, 59, 39, 41, 34, 41, 10, 32, 32, 32, + 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115,116, + 114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 32, 32, 32, + 69,110,117,109,101,114, 97,116,101, 40,110, 97,109,101, 44, + 98,111,100,121, 44,118, 97,114,110, 97,109,101, 41, 10, 32, + 32, 32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, + 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32, + 101,110,100, 10, 10, 45, 45, 32,100,111, 10, 45, 45, 32, 32, + 108,111, 99, 97,108, 32, 98, 44,101, 44,110, 97,109,101, 44, + 98,111,100,121, 32, 61, 32,115,116,114,102,105,110,100, 40, + 115, 44, 34, 94, 37,115, 42,101,110,117,109, 37,115, 43, 40, + 37, 83, 42, 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, + 42, 59, 63, 37,115, 42, 34, 41, 10, 45, 45, 32, 32,105,102, + 32, 98, 32,116,104,101,110, 10, 45, 45, 32, 32, 32, 95, 99, + 117,114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115, + 117, 98, 40,115, 44, 98, 44,101, 41, 10, 45, 45, 32, 32, 32, + 69,110,117,109,101,114, 97,116,101, 40,110, 97,109,101, 44, + 98,111,100,121, 41, 10, 45, 45, 32, 32,114,101,116,117,114, + 110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, + 10, 45, 45, 32, 32,101,110,100, 10, 45, 45, 32,101,110,100, + 10, 10, 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, + 44,101, 44, 98,111,100,121, 44,110, 97,109,101, 32, 61, 32, + 115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, + 116,121,112,101,100,101,102, 37,115, 43,101,110,117,109, 91, + 94,123, 93, 42, 40, 37, 98,123,125, 41, 37,115, 42, 40, 91, + 37,119, 95, 93, 91, 94, 37,115, 93, 42, 41, 37,115, 42, 59, + 37,115, 42, 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104, + 101,110, 10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100, + 101, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44, + 101, 41, 10, 32, 32, 32, 69,110,117,109,101,114, 97,116,101, + 40,110, 97,109,101, 44, 98,111,100,121, 41, 10, 32, 32, 32, + 114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115, + 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110, + 100, 10, 10, 32, 45, 45, 32,116,114,121, 32,111,112,101,114, + 97,116,111,114, 10, 32,100,111, 10, 32, 32,108,111, 99, 97, + 108, 32, 98, 44,101, 44,100,101, 99,108, 44,107,105,110,100, + 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116, + 114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, + 95, 37,119, 93, 91, 95, 37,119, 37,115, 37, 42, 38, 58, 60, + 62, 44, 93, 45, 37,115, 43,111,112,101,114, 97,116,111,114, + 41, 37,115, 42, 40, 91, 94, 37,115, 93, 91, 94, 37,115, 93, + 42, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, + 99, 63,111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 59, + 37,115, 42, 34, 41, 10, 32, 32,105,102, 32,110,111,116, 32, + 98, 32,116,104,101,110, 10, 9, 9, 32, 45, 45, 32,116,114, + 121, 32,105,110,108,105,110,101, 10, 32, 32, 32, 98, 44,101, + 44,100,101, 99,108, 44,107,105,110,100, 44, 97,114,103, 44, + 99,111,110,115,116, 32, 61, 32,115,116,114,102,105,110,100, + 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93, 91, + 95, 37,119, 37,115, 37, 42, 38, 58, 60, 62, 44, 93, 45, 37, + 115, 43,111,112,101,114, 97,116,111,114, 41, 37,115, 42, 40, + 91, 94, 37,115, 93, 91, 94, 37,115, 93, 42, 41, 37,115, 42, + 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,110, + 63,115, 63,116, 63, 41, 91, 37,115, 92,110, 93, 42, 37, 98, + 123,125, 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32, 32, + 101,110,100, 10, 32, 32,105,102, 32,110,111,116, 32, 98, 32, + 116,104,101,110, 10, 32, 32, 9, 45, 45, 32,116,114,121, 32, + 99, 97,115,116, 32,111,112,101,114, 97,116,111,114, 10, 32, + 32, 9, 98, 44,101, 44,100,101, 99,108, 44,107,105,110,100, + 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116, + 114,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 40, + 111,112,101,114, 97,116,111,114, 41, 37,115, 43, 40, 91, 37, + 119, 95, 58, 37,100, 60, 62, 37, 42, 37, 38, 37,115, 93, 43, + 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, + 63,111, 63,110, 63,115, 63,116, 63, 41, 34, 41, 59, 10, 32, + 32, 9,105,102, 32, 98, 32,116,104,101,110, 10, 32, 32, 9, + 9,108,111, 99, 97,108, 32, 95, 44,105,101, 32, 61, 32,115, + 116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, + 94, 37,115, 42, 37, 98,123,125, 34, 44, 32,101, 43, 49, 41, + 10, 32, 32, 9, 9,105,102, 32,105,101, 32,116,104,101,110, + 10, 32, 32, 9, 9, 9,101, 32, 61, 32,105,101, 10, 32, 32, + 9, 9,101,110,100, 10, 32, 32, 9,101,110,100, 10, 32, 32, + 101,110,100, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, + 10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, + 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, + 10, 32, 32, 32, 79,112,101,114, 97,116,111,114, 40,100,101, + 99,108, 44,107,105,110,100, 44, 97,114,103, 44, 99,111,110, + 115,116, 41, 10, 32, 32, 32,114,101,116,117,114,110, 32,115, + 116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32, + 101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116, + 114,121, 32,102,117,110, 99,116,105,111,110, 10, 32,100,111, + 10, 32, 32, 45, 45,108,111, 99, 97,108, 32, 98, 44,101, 44, + 100,101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116, 32, + 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37, + 115, 42, 40, 91,126, 95, 37,119, 93, 91, 95, 64, 37,119, 37, + 115, 37, 42, 38, 58, 60, 62, 93, 42, 91, 95, 37,119, 93, 41, + 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63, + 111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 61, 63, 37, + 115, 42, 48, 63, 37,115, 42, 59, 37,115, 42, 34, 41, 10, 32, + 32,108,111, 99, 97,108, 32, 98, 44,101, 44,100,101, 99,108, + 44, 97,114,103, 44, 99,111,110,115,116, 44,118,105,114,116, + 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, + 37,115, 42, 40, 91, 94, 37, 40, 92,110, 93, 43, 41, 37,115, + 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63, + 110, 63,115, 63,116, 63, 41, 37,115, 42, 40, 61, 63, 37,115, + 42, 48, 63, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10, 32, + 32,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10, + 32, 32, 9, 45, 45, 32,116,114,121, 32,102,117,110, 99,116, + 105,111,110, 32,119,105,116,104, 32,116,101,109,112,108, 97, + 116,101, 10, 32, 32, 9, 98, 44,101, 44,100,101, 99,108, 44, + 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116,114, + 102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91,126, + 95, 37,119, 93, 91, 95, 64, 37,119, 37,115, 37, 42, 38, 58, + 60, 62, 93, 42, 91, 95, 37,119, 93, 37, 98, 60, 62, 41, 37, + 115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, + 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 61, 63, 37,115, + 42, 48, 63, 37,115, 42, 59, 37,115, 42, 34, 41, 10, 32, 32, + 101,110,100, 10, 32, 32,105,102, 32,110,111,116, 32, 98, 32, + 116,104,101,110, 10, 32, 32, 32, 45, 45, 32,116,114,121, 32, + 97, 32,115,105,110,103,108,101, 32,108,101,116,116,101,114, + 32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101, 10, + 32, 32, 32, 98, 44,101, 44,100,101, 99,108, 44, 97,114,103, + 44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,105,110, + 100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93, + 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, + 63,111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 59, 37, + 115, 42, 34, 41, 10, 32, 32,101,110,100, 10, 32, 32,105,102, + 32,110,111,116, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, + 45, 45, 32,116,114,121, 32,102,117,110, 99,116,105,111,110, + 32,112,111,105,110,116,101,114, 10, 32, 32, 32, 98, 44,101, + 44,100,101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116, + 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, + 37,115, 42, 40, 91, 94, 37, 40, 59, 92,110, 93, 43, 37, 98, + 40, 41, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, + 59, 37,115, 42, 34, 41, 10, 32, 32, 32,105,102, 32, 98, 32, + 116,104,101,110, 10, 32, 32, 32, 32,100,101, 99,108, 32, 61, + 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,100,101, + 99,108, 44, 32, 34, 37, 40, 37,115, 42, 37, 42, 40, 91, 94, + 37, 41, 93, 42, 41, 37,115, 42, 37, 41, 34, 44, 32, 34, 32, + 37, 49, 32, 34, 41, 10, 32, 32, 32,101,110,100, 10, 32, 32, + 101,110,100, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, + 10, 32, 32, 9,105,102, 32,118,105,114,116, 32, 97,110,100, + 32,115,116,114,105,110,103, 46,102,105,110,100, 40,118,105, + 114,116, 44, 32, 34, 91, 61, 48, 93, 34, 41, 32,116,104,101, + 110, 10, 32, 32, 9, 9,105,102, 32,115,101,108,102, 46,102, + 108, 97,103,115, 32,116,104,101,110, 10, 32, 32, 9, 9, 9, + 115,101,108,102, 46,102,108, 97,103,115, 46,112,117,114,101, + 95,118,105,114,116,117, 97,108, 32, 61, 32,116,114,117,101, + 10, 32, 32, 9, 9,101,110,100, 10, 32, 32, 9,101,110,100, + 10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, + 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, + 10, 32, 32, 32, 70,117,110, 99,116,105,111,110, 40,100,101, + 99,108, 44, 97,114,103, 44, 99,111,110,115,116, 41, 10, 32, + 32, 32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, + 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32, + 101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,105,110, + 108,105,110,101, 32,102,117,110, 99,116,105,111,110, 10, 32, + 100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44, + 100,101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116, 32, + 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37, + 115, 42, 40, 91, 94, 37, 40, 92,110, 93, 43, 41, 37,115, 42, + 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,110, + 63,115, 63,116, 63, 41, 91, 94, 59,123, 93, 42, 37, 98,123, + 125, 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32, 32, 45, + 45,108,111, 99, 97,108, 32, 98, 44,101, 44,100,101, 99,108, + 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116, + 114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, + 126, 95, 37,119, 93, 91, 95, 64, 37,119, 37,115, 37, 42, 38, + 58, 60, 62, 93, 42, 91, 95, 37,119, 62, 93, 41, 37,115, 42, + 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,110, + 63,115, 63,116, 63, 41, 91, 94, 59, 93, 42, 37, 98,123,125, + 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32, 32,105,102, + 32,110,111,116, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, + 45, 45, 32,116,114,121, 32, 97, 32,115,105,110,103,108,101, + 32,108,101,116,116,101,114, 32,102,117,110, 99,116,105,111, + 110, 32,110, 97,109,101, 10, 32, 32, 32, 98, 44,101, 44,100, + 101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, + 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, + 42, 40, 91, 95, 37,119, 93, 41, 37,115, 42, 40, 37, 98, 40, + 41, 41, 37,115, 42, 40, 99, 63,111, 63,110, 63,115, 63,116, + 63, 41, 46, 45, 37, 98,123,125, 37,115, 42, 59, 63, 37,115, + 42, 34, 41, 10, 32, 32,101,110,100, 10, 32, 32,105,102, 32, + 98, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,114,114, + 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40, + 115, 44, 98, 44,101, 41, 10, 32, 32, 32, 70,117,110, 99,116, + 105,111,110, 40,100,101, 99,108, 44, 97,114,103, 44, 99,111, + 110,115,116, 41, 10, 32, 32, 32,114,101,116,117,114,110, 32, + 115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, + 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, + 116,114,121, 32, 99,108, 97,115,115, 10, 32,100,111, 10, 9, + 32,108,111, 99, 97,108, 32, 98, 44,101, 44,110, 97,109,101, + 44, 98, 97,115,101, 44, 98,111,100,121, 10, 9, 9, 98, 97, + 115,101, 32, 61, 32, 39, 39, 32, 98,111,100,121, 32, 61, 32, + 39, 39, 10, 9, 9, 98, 44,101, 44,110, 97,109,101, 32, 61, + 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, + 42, 99,108, 97,115,115, 37,115, 42, 40, 91, 95, 37,119, 93, + 91, 95, 37,119, 64, 93, 42, 41, 37,115, 42, 59, 34, 41, 32, + 32, 45, 45, 32,100,117,109,109,121, 32, 99,108, 97,115,115, + 10, 9, 9,108,111, 99, 97,108, 32,100,117,109,109,121, 32, + 61, 32,102, 97,108,115,101, 10, 9, 9,105,102, 32,110,111, + 116, 32, 98, 32,116,104,101,110, 10, 9, 9, 9, 98, 44,101, + 44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,100, + 40,115, 44, 34, 94, 37,115, 42,115,116,114,117, 99,116, 37, + 115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93, 42, + 41, 37,115, 42, 59, 34, 41, 32, 32, 32, 32, 45, 45, 32,100, + 117,109,109,121, 32,115,116,114,117, 99,116, 10, 9, 9, 9, + 105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10, 9, + 9, 9, 9, 98, 44,101, 44,110, 97,109,101, 44, 98, 97,115, + 101, 44, 98,111,100,121, 32, 61, 32,115,116,114,102,105,110, + 100, 40,115, 44, 34, 94, 37,115, 42, 99,108, 97,115,115, 37, + 115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93, 42, + 41, 37,115, 42, 40, 91, 94,123, 93, 45, 41, 37,115, 42, 40, + 37, 98,123,125, 41, 37,115, 42, 34, 41, 10, 9, 9, 9, 9, + 105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10, 9, + 9, 9, 9, 9, 98, 44,101, 44,110, 97,109,101, 44, 98, 97, + 115,101, 44, 98,111,100,121, 32, 61, 32,115,116,114,102,105, + 110,100, 40,115, 44, 34, 94, 37,115, 42,115,116,114,117, 99, + 116, 37,115, 43, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, + 93, 42, 41, 37,115, 42, 40, 91, 94,123, 93, 45, 41, 37,115, + 42, 40, 37, 98,123,125, 41, 37,115, 42, 34, 41, 10, 9, 9, + 9, 9, 9,105,102, 32,110,111,116, 32, 98, 32,116,104,101, + 110, 10, 9, 9, 9, 9, 9, 9, 98, 44,101, 44,110, 97,109, + 101, 44, 98, 97,115,101, 44, 98,111,100,121, 32, 61, 32,115, + 116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42,117, + 110,105,111,110, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, + 37,119, 64, 93, 42, 41, 37,115, 42, 40, 91, 94,123, 93, 45, + 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 34, 41, + 10, 9, 9, 9, 9, 9, 9,105,102, 32,110,111,116, 32, 98, + 32,116,104,101,110, 10, 9, 9, 9, 9, 9, 9, 9, 98, 97, + 115,101, 32, 61, 32, 39, 39, 10, 9, 9, 9, 9, 9, 9, 9, + 98, 44,101, 44, 98,111,100,121, 44,110, 97,109,101, 32, 61, + 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, + 42,116,121,112,101,100,101,102, 37,115, 37,115, 42,115,116, + 114,117, 99,116, 37,115, 37,115, 42, 91, 95, 37,119, 93, 42, + 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 40, 91, 95, + 37,119, 93, 91, 95, 37,119, 64, 93, 42, 41, 37,115, 42, 59, + 34, 41, 10, 9, 9, 9, 9, 9, 9,101,110,100, 10, 9, 9, + 9, 9, 9,101,110,100, 10, 9, 9, 9, 9,101,110,100, 10, + 9, 9, 9,101,108,115,101, 32,100,117,109,109,121, 32, 61, + 32, 49, 32,101,110,100, 10, 9, 9,101,108,115,101, 32,100, + 117,109,109,121, 32, 61, 32, 49, 32,101,110,100, 10, 9, 9, + 105,102, 32, 98, 32,116,104,101,110, 10, 9, 9, 9,105,102, + 32, 98, 97,115,101, 32,126, 61, 32, 39, 39, 32,116,104,101, + 110, 10, 9, 9, 9, 9, 98, 97,115,101, 32, 61, 32,115,116, + 114,105,110,103, 46,103,115,117, 98, 40, 98, 97,115,101, 44, + 32, 34, 94, 37,115, 42, 58, 37,115, 42, 34, 44, 32, 34, 34, + 41, 10, 9, 9, 9, 9, 98, 97,115,101, 32, 61, 32,115,116, + 114,105,110,103, 46,103,115,117, 98, 40, 98, 97,115,101, 44, + 32, 34, 37,115, 42,112,117, 98,108,105, 99, 37,115, 42, 34, + 44, 32, 34, 34, 41, 10, 9, 9, 9, 9, 98, 97,115,101, 32, + 61, 32,115,112,108,105,116, 40, 98, 97,115,101, 44, 32, 34, + 44, 34, 41, 10, 9, 9, 9, 9, 45, 45,108,111, 99, 97,108, + 32, 98, 44,101, 10, 9, 9, 9, 9, 45, 45, 98, 44,101, 44, + 98, 97,115,101, 32, 61, 32,115,116,114,102,105,110,100, 40, + 98, 97,115,101, 44, 34, 46, 45, 40, 91, 95, 37,119, 93, 91, + 95, 37,119, 60, 62, 44, 58, 93, 42, 41, 36, 34, 41, 10, 9, + 9, 9,101,108,115,101, 10, 9, 9, 9, 9, 98, 97,115,101, + 32, 61, 32,123,125, 10, 9, 9, 9,101,110,100, 10, 9, 9, + 9, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115, + 116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 9, 9, + 9, 67,108, 97,115,115, 40,110, 97,109,101, 44, 98, 97,115, + 101, 44, 98,111,100,121, 41, 10, 9, 9, 9,105,102, 32,110, + 111,116, 32,100,117,109,109,121, 32,116,104,101,110, 10, 9, + 9, 9, 9,118, 97,114, 98, 44,118, 97,114,101, 44,118, 97, + 114,110, 97,109,101, 32, 61, 32,115,116,114,105,110,103, 46, + 102,105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 40, 91, + 95, 37,119, 93, 43, 41, 37,115, 42, 59, 34, 44, 32,101, 43, + 49, 41, 10, 9, 9, 9, 9,105,102, 32,118, 97,114, 98, 32, + 116,104,101,110, 10, 9, 9, 9, 9, 9, 86, 97,114,105, 97, + 98,108,101, 40,110, 97,109,101, 46, 46, 34, 32, 34, 46, 46, + 118, 97,114,110, 97,109,101, 41, 10, 9, 9, 9, 9, 9,101, + 32, 61, 32,118, 97,114,101, 10, 9, 9, 9, 9,101,110,100, + 10, 9, 9, 9,101,110,100, 10, 9, 9, 9,114,101,116,117, + 114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, + 41, 10, 9, 9,101,110,100, 10, 9,101,110,100, 10, 10, 32, + 45, 45, 32,116,114,121, 32,116,121,112,101,100,101,102, 10, + 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101, + 44,116,121,112,101,115, 32, 61, 32,115,116,114,102,105,110, + 100, 40,115, 44, 34, 94, 37,115, 42,116,121,112,101,100,101, + 102, 37,115, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 59, 37, + 115, 42, 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101, + 110, 10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, + 32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, + 41, 10, 32, 32, 32, 84,121,112,101,100,101,102, 40,116,121, + 112,101,115, 41, 10, 32, 32, 32,114,101,116,117,114,110, 32, + 115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, + 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, + 116,114,121, 32,118, 97,114,105, 97, 98,108,101, 10, 32,100, + 111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44,100, + 101, 99,108, 32, 61, 32,115,116,114,102,105,110,100, 40,115, + 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 64, + 37,115, 37,119, 37,100, 37, 42, 38, 58, 60, 62, 44, 93, 42, + 91, 95, 37,119, 37,100, 93, 41, 37,115, 42, 59, 37,115, 42, + 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10, + 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, + 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, + 10, 9,108,111, 99, 97,108, 32,108,105,115,116, 32, 61, 32, + 115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40, + 100,101, 99,108, 44, 32, 34, 44, 34, 41, 10, 9, 86, 97,114, + 105, 97, 98,108,101, 40,108,105,115,116, 91, 49, 93, 41, 10, + 9,105,102, 32,108,105,115,116, 46,110, 32, 62, 32, 49, 32, + 116,104,101,110, 10, 9, 9,108,111, 99, 97,108, 32, 95, 44, + 95, 44,116,121,112,101, 32, 61, 32,115,116,114,102,105,110, + 100, 40,108,105,115,116, 91, 49, 93, 44, 32, 34, 40, 46, 45, + 41, 37,115, 43, 40, 91, 94, 37,115, 93, 42, 41, 36, 34, 41, + 59, 10, 10, 9, 9,108,111, 99, 97,108, 32,105, 32, 61, 50, + 59, 10, 9, 9,119,104,105,108,101, 32,108,105,115,116, 91, + 105, 93, 32,100,111, 10, 9, 9, 9, 86, 97,114,105, 97, 98, + 108,101, 40,116,121,112,101, 46, 46, 34, 32, 34, 46, 46,108, + 105,115,116, 91,105, 93, 41, 10, 9, 9, 9,105, 61,105, 43, + 49, 10, 9, 9,101,110,100, 10, 9,101,110,100, 10, 32, 32, + 32, 45, 45, 86, 97,114,105, 97, 98,108,101, 40,100,101, 99, + 108, 41, 10, 32, 32, 32,114,101,116,117,114,110, 32,115,116, + 114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32,101, + 110,100, 10, 32,101,110,100, 10, 10, 9, 45, 45, 32,116,114, + 121, 32,115,116,114,105,110,103, 10, 32,100,111, 10, 32, 32, + 108,111, 99, 97,108, 32, 98, 44,101, 44,100,101, 99,108, 32, + 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37, + 115, 42, 40, 91, 95, 37,119, 93, 63, 91, 95, 37,115, 37,119, + 37,100, 93, 45, 99,104, 97,114, 37,115, 43, 91, 95, 64, 37, + 119, 37,100, 93, 42, 37,115, 42, 37, 91, 37,115, 42, 37, 83, + 43, 37,115, 42, 37, 93, 41, 37,115, 42, 59, 37,115, 42, 34, + 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10, 32, + 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32, + 115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 32, + 32, 32, 86, 97,114,105, 97, 98,108,101, 40,100,101, 99,108, + 41, 10, 32, 32, 32,114,101,116,117,114,110, 32,115,116,114, + 115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110, + 100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, + 32, 97,114,114, 97,121, 10, 32,100,111, 10, 32, 32,108,111, + 99, 97,108, 32, 98, 44,101, 44,100,101, 99,108, 32, 61, 32, + 115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, + 40, 91, 95, 37,119, 93, 91, 93, 91, 95, 64, 37,115, 37,119, + 37,100, 37, 42, 38, 58, 93, 42, 91, 93, 95, 37,119, 37,100, + 93, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10, 32, 32,105, + 102, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,117, + 114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117, + 98, 40,115, 44, 98, 44,101, 41, 10, 32, 32, 32, 65,114,114, + 97,121, 40,100,101, 99,108, 41, 10, 32, 32, 32,114,101,116, + 117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, + 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, + 32, 45, 45, 32,110,111, 32,109, 97,116, 99,104,105,110,103, + 10, 32,105,102, 32,103,115,117, 98, 40,115, 44, 34, 37,115, + 37,115, 42, 34, 44, 34, 34, 41, 32,126, 61, 32, 34, 34, 32, + 116,104,101,110, 10, 32, 32, 95, 99,117,114,114, 95, 99,111, + 100,101, 32, 61, 32,115, 10, 32, 32,101,114,114,111,114, 40, + 34, 35,112, 97,114,115,101, 32,101,114,114,111,114, 34, 41, + 10, 32,101,108,115,101, 10, 32, 32,114,101,116,117,114,110, + 32, 34, 34, 10, 32,101,110,100, 10, 10,101,110,100, 10, 10, + 102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 58,112, 97,114,115,101, 32, + 40,115, 41, 10, 10, 9, 45, 45,115,101,108,102, 46, 99,117, + 114,114, 95,109,101,109, 98,101,114, 95, 97, 99, 99,101,115, + 115, 32, 61, 32,110,105,108, 10, 10, 32,119,104,105,108,101, + 32,115, 32,126, 61, 32, 39, 39, 32,100,111, 10, 32, 32,115, + 32, 61, 32,115,101,108,102, 58,100,111,112, 97,114,115,101, + 40,115, 41, 10, 32, 32,109,101,116,104,111,100,105,115,118, + 105,114,116,117, 97,108, 32, 61, 32,102, 97,108,115,101, 10, + 32,101,110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32,112, + 114,111,112,101,114,116,121, 32,116,121,112,101,115, 10, 10, + 102,117,110, 99,116,105,111,110, 32,103,101,116, 95,112,114, + 111,112,101,114,116,121, 95,116,121,112,101, 40, 41, 10, 10, + 9,114,101,116,117,114,110, 32, 99,108, 97,115,115, 67,111, + 110,116, 97,105,110,101,114, 46, 99,117,114,114, 58,103,101, + 116, 95,112,114,111,112,101,114,116,121, 95,116,121,112,101, + 40, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101, + 114, 58,115,101,116, 95,112,114,111,112,101,114,116,121, 95, + 116,121,112,101, 40,112,116,121,112,101, 41, 10, 9,112,116, + 121,112,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115, + 117, 98, 40,112,116,121,112,101, 44, 32, 34, 94, 37,115, 42, + 34, 44, 32, 34, 34, 41, 10, 9,112,116,121,112,101, 32, 61, + 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,112,116, + 121,112,101, 44, 32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, + 41, 10, 10, 9,115,101,108,102, 46,112,114,111,112,101,114, + 116,121, 95,116,121,112,101, 32, 61, 32,112,116,121,112,101, + 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, + 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58, + 103,101,116, 95,112,114,111,112,101,114,116,121, 95,116,121, + 112,101, 40, 41, 10, 9,114,101,116,117,114,110, 32,115,101, + 108,102, 46,112,114,111,112,101,114,116,121, 95,116,121,112, + 101, 32,111,114, 32, 40,115,101,108,102, 46,112, 97,114,101, + 110,116, 32, 97,110,100, 32,115,101,108,102, 46,112, 97,114, + 101,110,116, 58,103,101,116, 95,112,114,111,112,101,114,116, + 121, 95,116,121,112,101, 40, 41, 41, 32,111,114, 32, 34,100, + 101,102, 97,117,108,116, 34, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/container.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,112, 97, 99,107, 97, + 103,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105, + 116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97, + 114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71, + 114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, + 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, + 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111, + 100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116, + 119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114, + 101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, + 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105, + 116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, + 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,101, + 114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97, + 110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, + 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117, + 116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108, + 105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118, + 105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, + 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97, + 116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101, + 109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102, + 105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45, + 32, 80, 97, 99,107, 97,103,101, 32, 99,108, 97,115,115, 10, + 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,116, + 104,101, 32,119,104,111,108,101, 32,112, 97, 99,107, 97,103, + 101, 32, 98,101,105,110,103, 32, 98,111,117,110,100, 46, 10, + 45, 45, 32, 84,104,101, 32,102,111,108,108,111,119,105,110, + 103, 32,102,105,101,108,100,115, 32, 97,114,101, 32,115,116, + 111,114,101,100, 58, 10, 45, 45, 32, 32, 32, 32,123,105,125, + 32, 61, 32,108,105,115,116, 32,111,102, 32,111, 98,106,101, + 99,116,115, 32,105,110, 32,116,104,101, 32,112, 97, 99,107, + 97,103,101, 46, 10, 99,108, 97,115,115, 80, 97, 99,107, 97, + 103,101, 32, 61, 32,123, 10, 32, 99,108, 97,115,115,116,121, + 112,101, 32, 61, 32, 39,112, 97, 99,107, 97,103,101, 39, 10, + 125, 10, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 46, + 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, + 80, 97, 99,107, 97,103,101, 10,115,101,116,109,101,116, 97, + 116, 97, 98,108,101, 40, 99,108, 97,115,115, 80, 97, 99,107, + 97,103,101, 44, 99,108, 97,115,115, 67,111,110,116, 97,105, + 110,101,114, 41, 10, 10, 45, 45, 32, 80,114,105,110,116, 32, + 109,101,116,104,111,100, 10,102,117,110, 99,116,105,111,110, + 32, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112, + 114,105,110,116, 32, 40, 41, 10, 32,112,114,105,110,116, 40, + 34, 80, 97, 99,107, 97,103,101, 58, 32, 34, 46, 46,115,101, + 108,102, 46,110, 97,109,101, 41, 10, 32,108,111, 99, 97,108, + 32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108, + 102, 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91, + 105, 93, 58,112,114,105,110,116, 40, 34, 34, 44, 34, 34, 41, + 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, + 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, + 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112,114, + 101,112,114,111, 99,101,115,115, 32, 40, 41, 10, 10, 32, 45, + 45, 32, 97,118,111,105,100, 32,112,114,101,112,114,111, 99, + 101,115,115,105,110,103, 32,101,109, 98,101,100,100,101,100, + 32, 76,117, 97, 32, 99,111,100,101, 10, 32,108,111, 99, 97, + 108, 32, 76, 32, 61, 32,123,125, 10, 32,115,101,108,102, 46, + 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108, + 102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 37, 36, + 37, 91, 34, 44, 34, 92, 49, 34, 41, 32, 45, 45, 32,100,101, + 97,108, 32,119,105,116,104, 32,101,109, 98,101,100,100,101, + 100, 32,108,117, 97, 32, 99,111,100,101, 10, 32,115,101,108, + 102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115, + 101,108,102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, + 37, 36, 37, 93, 34, 44, 34, 92, 50, 34, 41, 10, 32,115,101, + 108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40, + 115,101,108,102, 46, 99,111,100,101, 44, 34, 40, 37, 98, 92, + 49, 92, 50, 41, 34, 44, 32, 32, 32, 32, 32, 32, 32,102,117, + 110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,105, + 110,115,101,114,116, 40, 76, 44, 99, 41, 10, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101, + 116,117,114,110, 32, 34, 92,110, 35, 91, 34, 46, 46,103,101, + 116,110, 40, 76, 41, 46, 46, 34, 93, 35, 34, 10, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110, + 100, 41, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,114, + 101,112,114,111, 99,101,115,115,105,110,103, 32,101,109, 98, + 101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,108, + 111, 99, 97,108, 32, 67, 32, 61, 32,123,125, 10, 32,115,101, + 108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40, + 115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, + 42, 37, 36, 37, 60, 34, 44, 34, 92, 51, 34, 41, 32, 45, 45, + 32,100,101, 97,108, 32,119,105,116,104, 32,101,109, 98,101, + 100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,115,101, + 108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40, + 115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, + 42, 37, 36, 37, 62, 34, 44, 34, 92, 52, 34, 41, 10, 32,115, + 101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, + 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40, 37, 98, + 92, 51, 92, 52, 41, 34, 44, 32, 32, 32, 32, 32, 32, 32,102, + 117,110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116, + 105,110,115,101,114,116, 40, 67, 44, 99, 41, 10, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114, + 101,116,117,114,110, 32, 34, 92,110, 35, 60, 34, 46, 46,103, + 101,116,110, 40, 67, 41, 46, 46, 34, 62, 35, 34, 10, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101, + 110,100, 41, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112, + 114,101,112,114,111, 99,101,115,115,105,110,103, 32,101,109, + 98,101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32, + 115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, + 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110, + 37,115, 42, 37, 36, 37,123, 34, 44, 34, 92, 53, 34, 41, 32, + 45, 45, 32,100,101, 97,108, 32,119,105,116,104, 32,101,109, + 98,101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32, + 115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, + 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110, + 37,115, 42, 37, 36, 37,125, 34, 44, 34, 92, 54, 34, 41, 10, + 32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115, + 117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40, + 37, 98, 92, 53, 92, 54, 41, 34, 44, 32, 32, 32, 32, 32, 32, + 32,102,117,110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,116,105,110,115,101,114,116, 40, 67, 44, 99, 41, 10, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,114,101,116,117,114,110, 32, 34, 92,110, 35, 60, 34, 46, + 46,103,101,116,110, 40, 67, 41, 46, 46, 34, 62, 35, 34, 10, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,101,110,100, 41, 10, 10, 32, 45, 45,115,101,108,102, 46, + 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108, + 102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 35, 91, + 94,100, 93, 91, 94, 92,110, 93, 42, 92,110, 34, 44, 32, 34, + 92,110, 92,110, 34, 41, 32, 45, 45, 32,101,108,105,109,105, + 110, 97,116,101, 32,112,114,101,112,114,111, 99,101,115,115, + 111,114, 32,100,105,114,101, 99,116,105,118,101,115, 32,116, + 104, 97,116, 32,100,111,110, 39,116, 32,115,116, 97,114,116, + 32,119,105,116,104, 32, 39,100, 39, 10, 32,115,101,108,102, + 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101, + 108,102, 46, 99,111,100,101, 44, 34, 92,110, 91, 32, 92,116, + 93, 42, 35, 91, 32, 92,116, 93, 42, 91, 94,100, 37, 60, 37, + 91, 93, 34, 44, 32, 34, 92,110, 47, 47, 34, 41, 32, 45, 45, + 32,101,108,105,109,105,110, 97,116,101, 32,112,114,101,112, + 114,111, 99,101,115,115,111,114, 32,100,105,114,101, 99,116, + 105,118,101,115, 32,116,104, 97,116, 32,100,111,110, 39,116, + 32,115,116, 97,114,116, 32,119,105,116,104, 32, 39,100, 39, + 10, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,114,101, + 112,114,111, 99,101,115,115,105,110,103, 32,118,101,114, 98, + 97,116,105,109, 32,108,105,110,101,115, 10, 32,108,111, 99, + 97,108, 32, 86, 32, 61, 32,123,125, 10, 32,115,101,108,102, + 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101, + 108,102, 46, 99,111,100,101, 44, 34, 92,110, 40, 37,115, 42, + 37, 36, 91, 94, 37, 91, 37, 93, 93, 91, 94, 92,110, 93, 42, + 41, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,118, 41, + 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32,116,105,110,115,101,114,116, 40, 86, 44,118, 41, + 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32,114,101,116,117,114,110, 32, 34, 92,110, 35, 34, + 46, 46,103,101,116,110, 40, 86, 41, 46, 46, 34, 35, 34, 10, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,101,110,100, 41, 10, 10, 32, 45, 45, 32,112,101,114,102, + 111,114,109, 32,103,108,111, 98, 97,108, 32,115,117, 98,115, + 116,105,116,117,116,105,111,110, 10, 10, 32,115,101,108,102, + 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101, + 108,102, 46, 99,111,100,101, 44, 34, 40, 47, 47, 91, 94, 92, + 110, 93, 42, 41, 34, 44, 34, 34, 41, 32, 32, 32, 32, 32, 45, + 45, 32,101,108,105,109,105,110, 97,116,101, 32, 67, 43, 43, + 32, 99,111,109,109,101,110,116,115, 10, 32,115,101,108,102, + 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101, + 108,102, 46, 99,111,100,101, 44, 34, 47, 37, 42, 34, 44, 34, + 92, 49, 34, 41, 10, 32,115,101,108,102, 46, 99,111,100,101, + 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111, + 100,101, 44, 34, 37, 42, 47, 34, 44, 34, 92, 50, 34, 41, 10, + 32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115, + 117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 37, + 98, 92, 49, 92, 50, 34, 44, 34, 34, 41, 10, 32,115,101,108, + 102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115, + 101,108,102, 46, 99,111,100,101, 44, 34, 92, 49, 34, 44, 34, + 47, 37, 42, 34, 41, 10, 32,115,101,108,102, 46, 99,111,100, + 101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99, + 111,100,101, 44, 34, 92, 50, 34, 44, 34, 37, 42, 47, 34, 41, + 10, 32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103, + 115,117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, + 37,115, 42, 64, 37,115, 42, 34, 44, 34, 64, 34, 41, 32, 45, + 45, 32,101,108,105,109,105,110, 97,116,101, 32,115,112, 97, + 99,101,115, 32, 98,101,115,105,100,101, 32, 64, 10, 32,115, + 101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, + 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 37,115, 63, + 105,110,108,105,110,101, 40, 37,115, 41, 34, 44, 34, 37, 49, + 34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101, + 32, 39,105,110,108,105,110,101, 39, 32,107,101,121,119,111, + 114,100, 10, 32, 45, 45,115,101,108,102, 46, 99,111,100,101, + 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111, + 100,101, 44, 34, 37,115, 63,101,120,116,101,114,110, 40, 37, + 115, 41, 34, 44, 34, 37, 49, 34, 41, 32, 45, 45, 32,101,108, + 105,109,105,110, 97,116,101, 32, 39,101,120,116,101,114,110, + 39, 32,107,101,121,119,111,114,100, 10, 32, 45, 45,115,101, + 108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40, + 115,101,108,102, 46, 99,111,100,101, 44, 34, 37,115, 63,118, + 105,114,116,117, 97,108, 40, 37,115, 41, 34, 44, 34, 37, 49, + 34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101, + 32, 39,118,105,114,116,117, 97,108, 39, 32,107,101,121,119, + 111,114,100, 10, 32, 45, 45,115,101,108,102, 46, 99,111,100, + 101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99, + 111,100,101, 44, 34,112,117, 98,108,105, 99, 58, 34, 44, 34, + 34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101, + 32, 39,112,117, 98,108,105, 99, 58, 39, 32,107,101,121,119, + 111,114,100, 10, 32,115,101,108,102, 46, 99,111,100,101, 32, + 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,100, + 101, 44, 34, 40, 91, 94, 37,119, 95, 93, 41,118,111,105,100, + 37,115, 42, 37, 42, 34, 44, 34, 37, 49, 95,117,115,101,114, + 100, 97,116, 97, 32, 34, 41, 32, 45, 45, 32,115,117, 98,115, + 116,105,116,117,116,101, 32, 39,118,111,105,100, 42, 39, 10, + 32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115, + 117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40, + 91, 94, 37,119, 95, 93, 41,118,111,105,100, 37,115, 42, 37, + 42, 34, 44, 34, 37, 49, 95,117,115,101,114,100, 97,116, 97, + 32, 34, 41, 32, 45, 45, 32,115,117, 98,115,116,105,116,117, + 116,101, 32, 39,118,111,105,100, 42, 39, 10, 32,115,101,108, + 102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115, + 101,108,102, 46, 99,111,100,101, 44, 34, 40, 91, 94, 37,119, + 95, 93, 41, 99,104, 97,114, 37,115, 42, 37, 42, 34, 44, 34, + 37, 49, 95, 99,115,116,114,105,110,103, 32, 34, 41, 32, 32, + 45, 45, 32,115,117, 98,115,116,105,116,117,116,101, 32, 39, + 99,104, 97,114, 42, 39, 10, 32,115,101,108,102, 46, 99,111, + 100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, + 99,111,100,101, 44, 34, 40, 91, 94, 37,119, 95, 93, 41,108, + 117, 97, 95, 83,116, 97,116,101, 37,115, 42, 37, 42, 34, 44, + 34, 37, 49, 95,108,115,116, 97,116,101, 32, 34, 41, 32, 32, + 45, 45, 32,115,117, 98,115,116,105,116,117,116,101, 32, 39, + 108,117, 97, 95, 83,116, 97,116,101, 42, 39, 10, 10, 32, 45, + 45, 32,114,101,115,116,111,114,101, 32,101,109, 98,101,100, + 100,101,100, 32, 76,117, 97, 32, 99,111,100,101, 10, 32,115, + 101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, + 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 37, 35, 37, + 91, 40, 37,100, 43, 41, 37, 93, 37, 35, 34, 44,102,117,110, + 99,116,105,111,110, 32, 40,110, 41, 10, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117, + 114,110, 32, 76, 91,116,111,110,117,109, 98,101,114, 40,110, + 41, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32,101,110,100, 41, 10, 32, 45, 45, 32,114,101,115,116, + 111,114,101, 32,101,109, 98,101,100,100,101,100, 32, 67, 32, + 99,111,100,101, 10, 32,115,101,108,102, 46, 99,111,100,101, + 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111, + 100,101, 44, 34, 37, 35, 37, 60, 40, 37,100, 43, 41, 37, 62, + 37, 35, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,110, + 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32,114,101,116,117,114,110, 32, 67, 91,116,111,110,117, + 109, 98,101,114, 40,110, 41, 93, 10, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 41, 10, 32, 45, + 45, 32,114,101,115,116,111,114,101, 32,118,101,114, 98, 97, + 116,105,109, 32,108,105,110,101,115, 10, 32,115,101,108,102, + 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101, + 108,102, 46, 99,111,100,101, 44, 34, 37, 35, 40, 37,100, 43, + 41, 37, 35, 34, 44,102,117,110, 99,116,105,111,110, 32, 40, + 110, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114, + 101,116,117,114,110, 32, 86, 91,116,111,110,117,109, 98,101, + 114, 40,110, 41, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,101,110,100, 41, 10, 10, 32,115,101,108,102, 46, 99,111, + 100,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, + 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 32, 34, 92, + 110, 37,115, 42, 37, 36, 40, 91, 94, 92,110, 93, 43, 41, 34, + 44, 32,102,117,110, 99,116,105,111,110, 32, 40,108, 41, 10, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 86,101,114, 98, + 97,116,105,109, 40,108, 46, 46, 34, 92,110, 34, 41, 10, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,114,101,116,117,114, + 110, 32, 34, 92,110, 34, 10, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 32, 32,101,110,100, 41, 10,101,110,100, 10, 10, 45, + 45, 32,116,114, 97,110,115,108, 97,116,101, 32,118,101,114, + 98, 97,116,105,109, 10,102,117,110, 99,116,105,111,110, 32, + 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112,114, + 101, 97,109, 98,108,101, 32, 40, 41, 10, 32,111,117,116,112, + 117,116, 40, 39, 47, 42, 92,110, 39, 41, 10, 32,111,117,116, + 112,117,116, 40, 39, 42, 42, 32, 76,117, 97, 32, 98,105,110, + 100,105,110,103, 58, 32, 39, 46, 46,115,101,108,102, 46,110, + 97,109,101, 46, 46, 39, 92,110, 39, 41, 10, 32,111,117,116, + 112,117,116, 40, 39, 42, 42, 32, 71,101,110,101,114, 97,116, + 101,100, 32, 97,117,116,111,109, 97,116,105, 99, 97,108,108, + 121, 32, 98,121, 32, 39, 46, 46, 84, 79, 76, 85, 65, 95, 86, + 69, 82, 83, 73, 79, 78, 46, 46, 39, 32,111,110, 32, 39, 46, + 46,100, 97,116,101, 40, 41, 46, 46, 39, 46, 92,110, 39, 41, + 10, 32,111,117,116,112,117,116, 40, 39, 42, 47, 92,110, 92, + 110, 39, 41, 10, 10, 9,111,117,116,112,117,116, 40, 39, 35, + 105,102,110,100,101,102, 32, 95, 95, 99,112,108,117,115,112, + 108,117,115, 92,110, 39, 41, 10, 9,111,117,116,112,117,116, + 40, 39, 35,105,110, 99,108,117,100,101, 32, 34,115,116,100, + 108,105, 98, 46,104, 34, 92,110, 39, 41, 10, 9,111,117,116, + 112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, + 10, 9,111,117,116,112,117,116, 40, 39, 35,105,110, 99,108, + 117,100,101, 32, 34,115,116,114,105,110,103, 46,104, 34, 92, + 110, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40, 39, + 35,105,110, 99,108,117,100,101, 32, 34,116,111,108,117, 97, + 43, 43, 46,104, 34, 92,110, 92,110, 39, 41, 10, 10, 32,105, + 102, 32,110,111,116, 32,102,108, 97,103,115, 46,104, 32,116, + 104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 47, + 42, 32, 69,120,112,111,114,116,101,100, 32,102,117,110, 99, + 116,105,111,110, 32, 42, 47, 39, 41, 10, 32, 32,111,117,116, + 112,117,116, 40, 39, 84, 79, 76, 85, 65, 95, 65, 80, 73, 32, + 105,110,116, 32, 32,116,111,108,117, 97, 95, 39, 46, 46,115, + 101,108,102, 46,110, 97,109,101, 46, 46, 39, 95,111,112,101, + 110, 32, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116, + 111,108,117, 97, 95, 83, 41, 59, 39, 41, 10, 32, 32,111,117, + 116,112,117,116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100, + 10, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119, + 104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, + 10, 32, 32,115,101,108,102, 91,105, 93, 58,112,114,101, 97, + 109, 98,108,101, 40, 41, 10, 32, 32,105, 32, 61, 32,105, 43, + 49, 10, 32,101,110,100, 10, 10, 9,105,102, 32,115,101,108, + 102, 58,114,101,113,117,105,114,101, 99,111,108,108,101, 99, + 116,105,111,110, 40, 95, 99,111,108,108,101, 99,116, 41, 32, + 116,104,101,110, 10, 9, 9,111,117,116,112,117,116, 40, 39, + 92,110, 39, 41, 10, 9, 9,111,117,116,112,117,116, 40, 39, + 47, 42, 32,102,117,110, 99,116,105,111,110, 32,116,111, 32, + 114,101,108,101, 97,115,101, 32, 99,111,108,108,101, 99,116, + 101,100, 32,111, 98,106,101, 99,116, 32,118,105, 97, 32,100, + 101,115,116,114,117, 99,116,111,114, 32, 42, 47, 39, 41, 10, + 9, 9,111,117,116,112,117,116, 40, 39, 35,105,102,100,101, + 102, 32, 95, 95, 99,112,108,117,115,112,108,117,115, 92,110, + 39, 41, 10, 9, 9,102,111,114, 32,105, 44,118, 32,105,110, + 32,112, 97,105,114,115, 40, 95, 99,111,108,108,101, 99,116, + 41, 32,100,111, 10, 9, 9, 32,111,117,116,112,117,116, 40, + 39, 92,110,115,116, 97,116,105, 99, 32,105,110,116, 32, 39, + 46, 46,118, 46, 46, 39, 32, 40,108,117, 97, 95, 83,116, 97, + 116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 39, 41, 10, + 9, 9, 9,111,117,116,112,117,116, 40, 39,123, 39, 41, 10, + 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, 39, 46, 46, + 105, 46, 46, 39, 42, 32,115,101,108,102, 32, 61, 32, 40, 39, + 46, 46,105, 46, 46, 39, 42, 41, 32,116,111,108,117, 97, 95, + 116,111,117,115,101,114,116,121,112,101, 40,116,111,108,117, + 97, 95, 83, 44, 49, 44, 48, 41, 59, 39, 41, 10, 9, 9, 9, + 111,117,116,112,117,116, 40, 39, 9, 77,116,111,108,117, 97, + 95,100,101,108,101,116,101, 40,115,101,108,102, 41, 59, 39, + 41, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, 9,114, + 101,116,117,114,110, 32, 48, 59, 39, 41, 10, 9, 9, 9,111, + 117,116,112,117,116, 40, 39,125, 39, 41, 10, 9, 9,101,110, + 100, 10, 9, 9,111,117,116,112,117,116, 40, 39, 35,101,110, + 100,105,102, 92,110, 92,110, 39, 41, 10, 9,101,110,100, 10, + 10, 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10, + 32,111,117,116,112,117,116, 40, 39, 47, 42, 32,102,117,110, + 99,116,105,111,110, 32,116,111, 32,114,101,103,105,115,116, + 101,114, 32,116,121,112,101, 32, 42, 47, 39, 41, 10, 32,111, + 117,116,112,117,116, 40, 39,115,116, 97,116,105, 99, 32,118, + 111,105,100, 32,116,111,108,117, 97, 95,114,101,103, 95,116, + 121,112,101,115, 32, 40,108,117, 97, 95, 83,116, 97,116,101, + 42, 32,116,111,108,117, 97, 95, 83, 41, 39, 41, 10, 32,111, + 117,116,112,117,116, 40, 39,123, 39, 41, 10, 10, 9,105,102, + 32,102,108, 97,103,115, 46,116, 32,116,104,101,110, 10, 9, + 9,111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101, + 102, 32, 77,116,111,108,117, 97, 95,116,121,112,101,105,100, + 92,110, 35,100,101,102,105,110,101, 32, 77,116,111,108,117, + 97, 95,116,121,112,101,105,100, 40, 76, 44, 84, 73, 44, 84, + 41, 92,110, 35,101,110,100,105,102, 92,110, 34, 41, 10, 9, + 101,110,100, 10, 9,102,111,114,101, 97, 99,104, 40, 95,117, + 115,101,114,116,121,112,101, 44,102,117,110, 99,116,105,111, + 110, 40,110, 44,118, 41, 10, 9, 9,105,102, 32, 40,110,111, + 116, 32, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,115, + 101,115, 91,118, 93, 41, 32,111,114, 32, 95,103,108,111, 98, + 97,108, 95, 99,108, 97,115,115,101,115, 91,118, 93, 58, 99, + 104,101, 99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, 99, + 101,115,115, 40, 41, 32,116,104,101,110, 10, 9, 9, 9,111, + 117,116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,117, + 115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, + 44, 34, 39, 44,118, 44, 39, 34, 41, 59, 39, 41, 10, 9, 9, + 9,105,102, 32,102,108, 97,103,115, 46,116, 32,116,104,101, + 110, 10, 9, 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, + 77,116,111,108,117, 97, 95,116,121,112,101,105,100, 40,116, + 111,108,117, 97, 95, 83, 44,116,121,112,101,105,100, 40, 39, + 44,118, 44, 39, 41, 44, 32, 34, 39, 44,118, 44, 39, 34, 41, + 59, 39, 41, 10, 9, 9, 9,101,110,100, 10, 9, 9,101,110, + 100, 10, 9, 32,101,110,100, 41, 10, 32,111,117,116,112,117, + 116, 40, 39,125, 39, 41, 10, 32,111,117,116,112,117,116, 40, + 39, 92,110, 39, 41, 10,101,110,100, 10, 10, 45, 45, 32,114, + 101,103,105,115,116,101,114, 32,112, 97, 99,107, 97,103,101, + 10, 45, 45, 32,119,114,105,116,101, 32,112, 97, 99,107, 97, + 103,101, 32,111,112,101,110, 32,102,117,110, 99,116,105,111, + 110, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 80, 97, 99,107, 97,103,101, 58,114,101,103,105,115,116, + 101,114, 32, 40,112,114,101, 41, 10, 32,112,114,101, 32, 61, + 32,112,114,101, 32,111,114, 32, 39, 39, 10, 32,112,117,115, + 104, 40,115,101,108,102, 41, 10, 32,111,117,116,112,117,116, + 40,112,114,101, 46, 46, 34, 47, 42, 32, 79,112,101,110, 32, + 102,117,110, 99,116,105,111,110, 32, 42, 47, 34, 41, 10, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 84, 79, + 76, 85, 65, 95, 65, 80, 73, 32,105,110,116, 32,116,111,108, + 117, 97, 95, 34, 46, 46,115,101,108,102, 46,110, 97,109,101, + 46, 46, 34, 95,111,112,101,110, 32, 40,108,117, 97, 95, 83, + 116, 97,116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34, + 41, 10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, + 34,123, 34, 41, 10, 32,111,117,116,112,117,116, 40,112,114, + 101, 46, 46, 34, 32,116,111,108,117, 97, 95,111,112,101,110, + 40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41, 10, 32,111, + 117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,116,111, + 108,117, 97, 95,114,101,103, 95,116,121,112,101,115, 40,116, + 111,108,117, 97, 95, 83, 41, 59, 34, 41, 10, 32,111,117,116, + 112,117,116, 40,112,114,101, 46, 46, 34, 32,116,111,108,117, + 97, 95,109,111,100,117,108,101, 40,116,111,108,117, 97, 95, + 83, 44, 78, 85, 76, 76, 44, 34, 44,115,101,108,102, 58,104, + 97,115,118, 97,114, 40, 41, 44, 34, 41, 59, 34, 41, 10, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,116, + 111,108,117, 97, 95, 98,101,103,105,110,109,111,100,117,108, + 101, 40,116,111,108,117, 97, 95, 83, 44, 78, 85, 76, 76, 41, + 59, 34, 41, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, + 32,119,104,105,108,101, 32,115,101,108,102, 91,105, 93, 32, + 100,111, 10, 32, 32,115,101,108,102, 91,105, 93, 58,114,101, + 103,105,115,116,101,114, 40,112,114,101, 46, 46, 34, 32, 32, + 34, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101, + 110,100, 10, 32,111,117,116,112,117,116, 40,112,114,101, 46, + 46, 34, 32,116,111,108,117, 97, 95,101,110,100,109,111,100, + 117,108,101, 40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41, + 10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, + 32,114,101,116,117,114,110, 32, 49, 59, 34, 41, 10, 32,111, + 117,116,112,117,116, 40,112,114,101, 46, 46, 34,125, 34, 41, + 10, 10, 32,111,117,116,112,117,116, 40, 34, 92,110, 92,110, + 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,105,102, + 32,100,101,102,105,110,101,100, 40, 76, 85, 65, 95, 86, 69, + 82, 83, 73, 79, 78, 95, 78, 85, 77, 41, 32, 38, 38, 32, 76, + 85, 65, 95, 86, 69, 82, 83, 73, 79, 78, 95, 78, 85, 77, 32, + 62, 61, 32, 53, 48, 49, 92,110, 34, 41, 59, 10, 32,111,117, + 116,112,117,116, 40,112,114,101, 46, 46, 34, 84, 79, 76, 85, + 65, 95, 65, 80, 73, 32,105,110,116, 32,108,117, 97,111,112, + 101,110, 95, 34, 46, 46,115,101,108,102, 46,110, 97,109,101, + 46, 46, 34, 32, 40,108,117, 97, 95, 83,116, 97,116,101, 42, + 32,116,111,108,117, 97, 95, 83, 41, 32,123, 34, 41, 10, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,114, + 101,116,117,114,110, 32,116,111,108,117, 97, 95, 34, 46, 46, + 115,101,108,102, 46,110, 97,109,101, 46, 46, 34, 95,111,112, + 101,110, 40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41, 10, + 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 34,125, + 59, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,101, + 110,100,105,102, 92,110, 92,110, 34, 41, 10, 10, 9,112,111, + 112, 40, 41, 10,101,110,100, 10, 10, 45, 45, 32,119,114,105, + 116,101, 32,104,101, 97,100,101,114, 32,102,105,108,101, 10, + 102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 80, + 97, 99,107, 97,103,101, 58,104,101, 97,100,101,114, 32, 40, + 41, 10, 32,111,117,116,112,117,116, 40, 39, 47, 42, 92,110, + 39, 41, 32,111,117,116,112,117,116, 40, 39, 42, 42, 32, 76, + 117, 97, 32, 98,105,110,100,105,110,103, 58, 32, 39, 46, 46, + 115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 92,110, 39, + 41, 10, 32,111,117,116,112,117,116, 40, 39, 42, 42, 32, 71, + 101,110,101,114, 97,116,101,100, 32, 97,117,116,111,109, 97, + 116,105, 99, 97,108,108,121, 32, 98,121, 32, 39, 46, 46, 84, + 79, 76, 85, 65, 95, 86, 69, 82, 83, 73, 79, 78, 46, 46, 39, + 32,111,110, 32, 39, 46, 46,100, 97,116,101, 40, 41, 46, 46, + 39, 46, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40, + 39, 42, 47, 92,110, 92,110, 39, 41, 10, 10, 32,105,102, 32, + 110,111,116, 32,102,108, 97,103,115, 46,104, 32,116,104,101, + 110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 47, 42, 32, + 69,120,112,111,114,116,101,100, 32,102,117,110, 99,116,105, + 111,110, 32, 42, 47, 39, 41, 10, 32, 32,111,117,116,112,117, + 116, 40, 39, 84, 79, 76, 85, 65, 95, 65, 80, 73, 32,105,110, + 116, 32, 32,116,111,108,117, 97, 95, 39, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 39, 95,111,112,101,110, 32, + 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108, + 117, 97, 95, 83, 41, 59, 39, 41, 10, 32, 32,111,117,116,112, + 117,116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100, 10,101, + 110,100, 10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, + 32, 99,111,110,115,116,114,117, 99,116,111,114, 10,102,117, + 110, 99,116,105,111,110, 32, 95, 80, 97, 99,107, 97,103,101, + 32, 40,115,101,108,102, 41, 10, 32,115,101,116,109,101,116, + 97,116, 97, 98,108,101, 40,115,101,108,102, 44, 99,108, 97, + 115,115, 80, 97, 99,107, 97,103,101, 41, 10, 32,114,101,116, + 117,114,110, 32,115,101,108,102, 10,101,110,100, 10, 10, 45, + 45, 32, 80, 97,114,115,101, 32, 67, 32,104,101, 97,100,101, + 114, 32,102,105,108,101, 32,119,105,116,104, 32,116,111,108, + 117, 97, 32,100,105,114,101, 99,116,105,118,101,115, 10, 45, + 45, 32, 42, 42, 42, 32, 84,104, 97,110,107,115, 32,116,111, + 32, 65,114,105,101,108, 32, 77, 97,110,122,117,114, 32,102, + 111,114, 32,102,105,120,105,110,103, 32, 98,117,103,115, 32, + 105,110, 32,110,101,115,116,101,100, 32,100,105,114,101, 99, + 116,105,118,101,115, 32, 42, 42, 42, 10,102,117,110, 99,116, + 105,111,110, 32,101,120,116,114, 97, 99,116, 95, 99,111,100, + 101, 40,102,110, 44,115, 41, 10, 9,108,111, 99, 97,108, 32, + 99,111,100,101, 32, 61, 32, 39, 92,110, 36, 35,105,110, 99, + 108,117,100,101, 32, 34, 39, 46, 46,102,110, 46, 46, 39, 34, + 92,110, 39, 10, 9,115, 61, 32, 34, 92,110, 34, 32, 46, 46, + 32,115, 32, 46, 46, 32, 34, 92,110, 34, 32, 45, 45, 32, 97, + 100,100, 32, 98,108, 97,110,107, 32,108,105,110,101,115, 32, + 97,115, 32,115,101,110,116,105,110,101,108,115, 10, 9,108, + 111, 99, 97,108, 32, 95, 44,101, 44, 99, 44,116, 32, 61, 32, + 115,116,114,102,105,110,100, 40,115, 44, 32, 34, 92,110, 40, + 91, 94, 92,110, 93, 45, 41, 91, 84,116, 93, 91, 79,111, 93, + 91, 76,108, 93, 91, 85,117, 93, 91, 65, 97, 93, 95, 40, 91, + 94, 37,115, 93, 42, 41, 91, 94, 92,110, 93, 42, 92,110, 34, + 41, 10, 9,119,104,105,108,101, 32,101, 32,100,111, 10, 9, + 9,116, 32, 61, 32,115,116,114,108,111,119,101,114, 40,116, + 41, 10, 9, 9,105,102, 32,116, 32, 61, 61, 32, 34, 98,101, + 103,105,110, 34, 32,116,104,101,110, 10, 9, 9, 9, 95, 44, + 101, 44, 99, 32, 61, 32,115,116,114,102,105,110,100, 40,115, + 44, 34, 40, 46, 45, 41, 92,110, 91, 94, 92,110, 93, 42, 91, + 84,116, 93, 91, 79,111, 93, 91, 76,108, 93, 91, 85,117, 93, + 91, 65, 97, 93, 95, 91, 69,101, 93, 91, 78,110, 93, 91, 68, + 100, 93, 91, 94, 92,110, 93, 42, 92,110, 34, 44,101, 41, 10, + 9, 9, 9,105,102, 32,110,111,116, 32,101, 32,116,104,101, + 110, 10, 9, 9, 9, 32,116,111,108,117, 97, 95,101,114,114, + 111,114, 40, 34, 85,110, 98, 97,108, 97,110, 99,101,100, 32, + 39,116,111,108,117, 97, 95, 98,101,103,105,110, 39, 32,100, + 105,114,101, 99,116,105,118,101, 32,105,110, 32,104,101, 97, + 100,101,114, 32,102,105,108,101, 34, 41, 10, 9, 9, 9,101, + 110,100, 10, 9, 9,101,110,100, 10, 9, 9, 99,111,100,101, + 32, 61, 32, 99,111,100,101, 32, 46, 46, 32, 99, 32, 46, 46, + 32, 34, 92,110, 34, 10, 9, 32, 95, 44,101, 44, 99, 44,116, + 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 32, 34, + 92,110, 40, 91, 94, 92,110, 93, 45, 41, 91, 84,116, 93, 91, + 79,111, 93, 91, 76,108, 93, 91, 85,117, 93, 91, 65, 97, 93, + 95, 40, 91, 94, 37,115, 93, 42, 41, 91, 94, 92,110, 93, 42, + 92,110, 34, 44,101, 41, 10, 9,101,110,100, 10, 9,114,101, + 116,117,114,110, 32, 99,111,100,101, 10,101,110,100, 10, 10, + 45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, 10, + 45, 45, 32, 69,120,112,101, 99,116,115, 32,116,104,101, 32, + 112, 97, 99,107, 97,103,101, 32,110, 97,109,101, 44, 32,116, + 104,101, 32,102,105,108,101, 32,101,120,116,101,110,115,105, + 111,110, 44, 32, 97,110,100, 32,116,104,101, 32,102,105,108, + 101, 32,116,101,120,116, 46, 10,102,117,110, 99,116,105,111, + 110, 32, 80, 97, 99,107, 97,103,101, 32, 40,110, 97,109,101, + 44,102,110, 41, 10, 32,108,111, 99, 97,108, 32,101,120,116, + 32, 61, 32, 34,112,107,103, 34, 10, 10, 32, 45, 45, 32,111, + 112,101,110, 32,105,110,112,117,116, 32,102,105,108,101, 44, + 32,105,102, 32, 97,110,121, 10, 32,108,111, 99, 97,108, 32, + 115,116, 44,109,115,103, 10, 32,105,102, 32,102,110, 32,116, + 104,101,110, 10, 32, 32,115,116, 44, 32,109,115,103, 32, 61, + 32,114,101, 97,100,102,114,111,109, 40,102,108, 97,103,115, + 46,102, 41, 10, 32, 32,105,102, 32,110,111,116, 32,115,116, + 32,116,104,101,110, 10, 32, 32, 32,101,114,114,111,114, 40, + 39, 35, 39, 46, 46,109,115,103, 41, 10, 32, 32,101,110,100, + 10, 32, 32,108,111, 99, 97,108, 32, 95, 59, 32, 95, 44, 32, + 95, 44, 32,101,120,116, 32, 61, 32,115,116,114,102,105,110, + 100, 40,102,110, 44, 34, 46, 42, 37, 46, 40, 46, 42, 41, 36, + 34, 41, 10, 32,101,110,100, 10, 32,108,111, 99, 97,108, 32, + 99,111,100,101, 10, 32,105,102, 32,101,120,116, 32, 61, 61, + 32, 39,112,107,103, 39, 32,116,104,101,110, 10, 32, 32, 99, + 111,100,101, 32, 61, 32,112,114,101,112, 40,115,116, 41, 10, + 32,101,108,115,101, 10, 32, 32, 99,111,100,101, 32, 61, 32, + 34, 92,110, 34, 32, 46, 46, 32,114,101, 97,100, 40, 39, 42, + 97, 39, 41, 10, 32, 32,105,102, 32,101,120,116, 32, 61, 61, + 32, 39,104, 39, 32,111,114, 32,101,120,116, 32, 61, 61, 32, + 39,104,112,112, 39, 32,116,104,101,110, 10, 32, 32, 32, 99, + 111,100,101, 32, 61, 32,101,120,116,114, 97, 99,116, 95, 99, + 111,100,101, 40,102,110, 44, 99,111,100,101, 41, 10, 32, 32, + 101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99, + 108,111,115,101, 32,102,105,108,101, 10, 32,105,102, 32,102, + 110, 32,116,104,101,110, 10, 32, 32,114,101, 97,100,102,114, + 111,109, 40, 41, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, + 100,101, 97,108, 32,119,105,116,104, 32,105,110, 99,108,117, + 100,101, 32,100,105,114,101, 99,116,105,118,101, 10, 32,108, + 111, 99, 97,108, 32,110,115,117, 98,115,116, 10, 32,114,101, + 112,101, 97,116, 10, 32, 32, 99,111,100,101, 44,110,115,117, + 98,115,116, 32, 61, 32,103,115,117, 98, 40, 99,111,100,101, + 44, 39, 92,110, 37,115, 42, 37, 36, 40, 46, 41,102,105,108, + 101, 37,115, 42, 34, 40, 46, 45, 41, 34, 40, 91, 94, 92,110, + 93, 42, 41, 92,110, 39, 44, 10, 9, 9,102,117,110, 99,116, + 105,111,110, 32, 40,107,105,110,100, 44,102,110, 44,101,120, + 116,114, 97, 41, 10, 9, 9, 9,108,111, 99, 97,108, 32, 95, + 44, 32, 95, 44, 32,101,120,116, 32, 61, 32,115,116,114,102, + 105,110,100, 40,102,110, 44, 34, 46, 42, 37, 46, 40, 46, 42, + 41, 36, 34, 41, 10, 9, 9, 9,108,111, 99, 97,108, 32,102, + 112, 44,109,115,103, 32, 61, 32,111,112,101,110,102,105,108, + 101, 40,102,110, 44, 39,114, 39, 41, 10, 9, 9, 9,105,102, + 32,110,111,116, 32,102,112, 32,116,104,101,110, 10, 9, 9, + 9, 9,101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,115, + 103, 46, 46, 39, 58, 32, 39, 46, 46,102,110, 41, 10, 9, 9, + 9,101,110,100, 10, 9, 9, 9,105,102, 32,107,105,110,100, + 32, 61, 61, 32, 39,112, 39, 32,116,104,101,110, 10, 9, 9, + 9, 9,108,111, 99, 97,108, 32,115, 32, 61, 32,112,114,101, + 112, 40,102,112, 41, 10, 9, 9, 9, 9, 99,108,111,115,101, + 102,105,108,101, 40,102,112, 41, 10, 9, 9, 9, 9,114,101, + 116,117,114,110, 32,115, 10, 9, 9, 9,101,110,100, 10, 9, + 9, 9,108,111, 99, 97,108, 32,115, 32, 61, 32,114,101, 97, + 100, 40,102,112, 44, 39, 42, 97, 39, 41, 10, 9, 9, 9, 99, + 108,111,115,101,102,105,108,101, 40,102,112, 41, 10, 9, 9, + 9,105,102, 32,107,105,110,100, 32, 61, 61, 32, 39, 99, 39, + 32,111,114, 32,107,105,110,100, 32, 61, 61, 32, 39,104, 39, + 32,116,104,101,110, 10, 9, 9, 9, 9,114,101,116,117,114, + 110, 32,101,120,116,114, 97, 99,116, 95, 99,111,100,101, 40, + 102,110, 44,115, 41, 10, 9, 9, 9,101,108,115,101,105,102, + 32,107,105,110,100, 32, 61, 61, 32, 39,108, 39, 32,116,104, + 101,110, 10, 9, 9, 9, 9,114,101,116,117,114,110, 32, 34, + 92,110, 36, 91, 45, 45, 35, 35, 34, 46, 46,102,110, 46, 46, + 34, 92,110, 34, 32, 46, 46, 32,115, 32, 46, 46, 32, 34, 92, + 110, 36, 93, 92,110, 34, 10, 9, 9, 9,101,108,115,101,105, + 102, 32,107,105,110,100, 32, 61, 61, 32, 39,105, 39, 32,116, + 104,101,110, 10, 9, 9, 9, 9,108,111, 99, 97,108, 32,116, + 32, 61, 32,123, 99,111,100,101, 61,115,125, 10, 9, 9, 9, + 9,101,120,116,114, 97, 32, 61, 32,115,116,114,105,110,103, + 46,103,115,117, 98, 40,101,120,116,114, 97, 44, 32, 34, 94, + 37,115, 42, 44, 37,115, 42, 34, 44, 32, 34, 34, 41, 10, 9, + 9, 9, 9,108,111, 99, 97,108, 32,112, 97,114,115, 32, 61, + 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115, + 40,101,120,116,114, 97, 44, 32, 34, 44, 34, 41, 10, 9, 9, + 9, 9,105,110, 99,108,117,100,101, 95,102,105,108,101, 95, + 104,111,111,107, 40,116, 44, 32,102,110, 44, 32,117,110,112, + 97, 99,107, 40,112, 97,114,115, 41, 41, 10, 9, 9, 9, 9, + 114,101,116,117,114,110, 32, 34, 92,110, 92,110, 34, 32, 46, + 46, 32,116, 46, 99,111,100,101, 10, 9, 9, 9,101,108,115, + 101, 10, 9, 9, 9, 9,101,114,114,111,114, 40, 39, 35, 73, + 110,118, 97,108,105,100, 32,105,110, 99,108,117,100,101, 32, + 100,105,114,101, 99,116,105,118,101, 32, 40,117,115,101, 32, + 36, 99,102,105,108,101, 44, 32, 36,112,102,105,108,101, 44, + 32, 36,108,102,105,108,101, 32,111,114, 32, 36,105,102,105, + 108,101, 41, 39, 41, 10, 9, 9, 9,101,110,100, 10, 9, 9, + 101,110,100, 41, 10, 32,117,110,116,105,108, 32,110,115,117, + 98,115,116, 61, 61, 48, 10, 10, 32, 45, 45, 32,100,101, 97, + 108, 32,119,105,116,104, 32,114,101,110, 97,109,105,110,103, + 32,100,105,114,101, 99,116,105,118,101, 10, 32,114,101,112, + 101, 97,116, 32, 45, 45, 32, 73, 32,100,111,110, 39,116, 32, + 107,110,111,119, 32,119,104,121, 32,116,104,105,115, 32,105, + 115, 32,110,101, 99,101,115, 97,114,121, 10, 9, 99,111,100, + 101, 44,110,115,117, 98,115,116, 32, 61, 32,103,115,117, 98, + 40, 99,111,100,101, 44, 39, 92,110, 37,115, 42, 37, 36,114, + 101,110, 97,109,105,110,103, 37,115, 42, 40, 46, 45, 41, 37, + 115, 42, 92,110, 39, 44, 32,102,117,110, 99,116,105,111,110, + 32, 40,114, 41, 32, 97,112,112,101,110,100,114,101,110, 97, + 109,105,110,103, 40,114, 41, 32,114,101,116,117,114,110, 32, + 34, 92,110, 34, 32,101,110,100, 41, 10, 32,117,110,116,105, + 108, 32,110,115,117, 98,115,116, 32, 61, 61, 32, 48, 10, 10, + 32,108,111, 99, 97,108, 32,116, 32, 61, 32, 95, 80, 97, 99, + 107, 97,103,101, 40, 95, 67,111,110,116, 97,105,110,101,114, + 123,110, 97,109,101, 61,110, 97,109,101, 44, 32, 99,111,100, + 101, 61, 99,111,100,101,125, 41, 10, 32,112,117,115,104, 40, + 116, 41, 10, 32,112,114,101,112,114,111, 99,101,115,115, 95, + 104,111,111,107, 40,116, 41, 10, 32,116, 58,112,114,101,112, + 114,111, 99,101,115,115, 40, 41, 10, 32,112,114,101,112, 97, + 114,115,101, 95,104,111,111,107, 40,116, 41, 10, 32,116, 58, + 112, 97,114,115,101, 40,116, 46, 99,111,100,101, 41, 10, 32, + 112,111,112, 40, 41, 10, 32,114,101,116,117,114,110, 32,116, + 10,101,110,100, 10, 10, 10,115,101,116,109,101,116, 97,116, + 97, 98,108,101, 40, 95,101,120,116,114, 97, 95,112, 97,114, + 97,109,101,116,101,114,115, 44, 32,123, 32, 95, 95,105,110, + 100,101,120, 32, 61, 32, 95, 71, 32,125, 41, 10, 10,102,117, + 110, 99,116,105,111,110, 32,112,114,101,112, 40,102,105,108, + 101, 41, 10, 10, 32, 32,108,111, 99, 97,108, 32, 99,104,117, + 110,107, 32, 61, 32,123, 39,108,111, 99, 97,108, 32, 95, 95, + 114,101,116, 32, 61, 32,123, 34, 92, 92,110, 34,125, 92,110, + 39,125, 10, 32, 32,102,111,114, 32,108,105,110,101, 32,105, + 110, 32,102,105,108,101, 58,108,105,110,101,115, 40, 41, 32, + 100,111, 10, 32, 32, 32, 32, 32,105,102, 32,115,116,114,105, + 110,103, 46,102,105,110,100, 40,108,105,110,101, 44, 32, 34, + 94, 35, 35, 34, 41, 32,116,104,101,110, 10, 32, 32, 32, 32, + 32, 32,116, 97, 98,108,101, 46,105,110,115,101,114,116, 40, + 99,104,117,110,107, 44, 32,115,116,114,105,110,103, 46,115, + 117, 98, 40,108,105,110,101, 44, 32, 51, 41, 32, 46, 46, 32, + 34, 92,110, 34, 41, 10, 32, 32, 32, 32, 32,101,108,115,101, + 10, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,108, 97, + 115,116, 32, 61, 32, 49, 10, 32, 32, 32, 32, 32, 32,102,111, + 114, 32,116,101,120,116, 44, 32,101,120,112,114, 44, 32,105, + 110,100,101,120, 32,105,110, 32,115,116,114,105,110,103, 46, + 103,102,105,110,100, 40,108,105,110,101, 44, 32, 34, 40, 46, + 45, 41, 36, 40, 37, 98, 40, 41, 41, 40, 41, 34, 41, 32,100, + 111, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32,108, 97,115,116, + 32, 61, 32,105,110,100,101,120, 10, 32, 32, 32, 32, 32, 32, + 32, 32,105,102, 32,116,101,120,116, 32,126, 61, 32, 34, 34, + 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,116, 97, 98,108,101, 46,105,110,115,101,114,116, 40, 99, + 104,117,110,107, 44, 32,115,116,114,105,110,103, 46,102,111, + 114,109, 97,116, 40, 39,116, 97, 98,108,101, 46,105,110,115, + 101,114,116, 40, 95, 95,114,101,116, 44, 32, 37,113, 32, 41, + 39, 44, 32,116,101,120,116, 41, 41, 10, 32, 32, 32, 32, 32, + 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, + 116, 97, 98,108,101, 46,105,110,115,101,114,116, 40, 99,104, + 117,110,107, 44, 32,115,116,114,105,110,103, 46,102,111,114, + 109, 97,116, 40, 39,116, 97, 98,108,101, 46,105,110,115,101, + 114,116, 40, 95, 95,114,101,116, 44, 32, 37,115, 32, 41, 39, + 44, 32,101,120,112,114, 41, 41, 10, 32, 32, 32, 32, 32, 32, + 101,110,100, 10, 32, 32, 32, 32, 32, 32,116, 97, 98,108,101, + 46,105,110,115,101,114,116, 40, 99,104,117,110,107, 44, 32, + 115,116,114,105,110,103, 46,102,111,114,109, 97,116, 40, 39, + 116, 97, 98,108,101, 46,105,110,115,101,114,116, 40, 95, 95, + 114,101,116, 44, 32, 37,113, 41, 92,110, 39, 44, 10, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32,115,116,114,105,110,103, + 46,115,117, 98, 40,108,105,110,101, 44, 32,108, 97,115,116, + 41, 46, 46, 34, 92,110, 34, 41, 41, 10, 32, 32, 32, 32,101, + 110,100, 10, 32, 32,101,110,100, 10, 32, 32,116, 97, 98,108, + 101, 46,105,110,115,101,114,116, 40, 99,104,117,110,107, 44, + 32, 39, 92,110,114,101,116,117,114,110, 32,116, 97, 98,108, + 101, 46, 99,111,110, 99, 97,116, 40, 95, 95,114,101,116, 41, + 92,110, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,102, 44, + 101, 32, 61, 32,108,111, 97,100,115,116,114,105,110,103, 40, + 116, 97, 98,108,101, 46, 99,111,110, 99, 97,116, 40, 99,104, + 117,110,107, 41, 41, 10, 32, 32,105,102, 32,101, 32,116,104, + 101,110, 10, 32, 32, 9,101,114,114,111,114, 40, 34, 35, 34, + 46, 46,101, 41, 10, 32, 32,101,110,100, 10, 32, 32,115,101, + 116,102,101,110,118, 40,102, 44, 32, 95,101,120,116,114, 97, + 95,112, 97,114, 97,109,101,116,101,114,115, 41, 10, 32, 32, + 114,101,116,117,114,110, 32,102, 40, 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/package.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,109,111,100,117,108, + 101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116, + 116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, + 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, + 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74, + 117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, + 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100, + 101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119, + 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101, + 100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97, + 110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116, + 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97, + 114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,114, + 101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, + 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, + 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116, + 104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105, + 103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105, + 100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, + 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116, + 101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109, + 101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105, + 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45, 32, + 77,111,100,117,108,101, 32, 99,108, 97,115,115, 10, 45, 45, + 32, 82,101,112,114,101,115,101,110,116,115, 32,109,111,100, + 117,108,101, 46, 10, 45, 45, 32, 84,104,101, 32,102,111,108, + 108,111,119,105,110,103, 32,102,105,101,108,100,115, 32, 97, + 114,101, 32,115,116,111,114,101,100, 58, 10, 45, 45, 32, 32, + 32, 32,123,105,125, 32, 61, 32,108,105,115,116, 32,111,102, + 32,111, 98,106,101, 99,116,115, 32,105,110, 32,116,104,101, + 32,109,111,100,117,108,101, 46, 10, 99,108, 97,115,115, 77, + 111,100,117,108,101, 32, 61, 32,123, 10, 32, 99,108, 97,115, + 115,116,121,112,101, 32, 61, 32, 39,109,111,100,117,108,101, + 39, 10,125, 10, 99,108, 97,115,115, 77,111,100,117,108,101, + 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115, + 115, 77,111,100,117,108,101, 10,115,101,116,109,101,116, 97, + 116, 97, 98,108,101, 40, 99,108, 97,115,115, 77,111,100,117, + 108,101, 44, 99,108, 97,115,115, 67,111,110,116, 97,105,110, + 101,114, 41, 10, 10, 45, 45, 32,114,101,103,105,115,116,101, + 114, 32,109,111,100,117,108,101, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 77,111,100,117,108,101, 58, + 114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41, 10, + 32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, + 39, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111, + 108,117, 97, 95,109,111,100,117,108,101, 40,116,111,108,117, + 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,110, 97, + 109,101, 46, 46, 39, 34, 44, 39, 44,115,101,108,102, 58,104, + 97,115,118, 97,114, 40, 41, 44, 39, 41, 59, 39, 41, 10, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111, + 108,117, 97, 95, 98,101,103,105,110,109,111,100,117,108,101, + 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101, + 108,102, 46,110, 97,109,101, 46, 46, 39, 34, 41, 59, 39, 41, + 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104, + 105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, + 32, 32,115,101,108,102, 91,105, 93, 58,114,101,103,105,115, + 116,101,114, 40,112,114,101, 46, 46, 39, 32, 39, 41, 10, 32, + 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111, + 108,117, 97, 95,101,110,100,109,111,100,117,108,101, 40,116, + 111,108,117, 97, 95, 83, 41, 59, 39, 41, 10, 9,112,111,112, + 40, 41, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110, + 116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 77,111,100,117,108,101, 58, + 112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108, + 111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 77,111,100,117,108,101,123, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 34, 39, 59, 34, 41, 10, 32, + 108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108, + 101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32, + 115,101,108,102, 91,105, 93, 58,112,114,105,110,116, 40,105, + 100,101,110,116, 46, 46, 34, 32, 34, 44, 34, 44, 34, 41, 10, + 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10, + 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111, + 110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116, + 105,111,110, 32, 95, 77,111,100,117,108,101, 32, 40,116, 41, + 10, 32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, + 116, 44, 99,108, 97,115,115, 77,111,100,117,108,101, 41, 10, + 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116, + 117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67, + 111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69, + 120,112,101, 99,116,115, 32,116,119,111, 32,115,116,114,105, + 110,103, 32,114,101,112,114,101,115,101,110,116,105,110,103, + 32,116,104,101, 32,109,111,100,117,108,101, 32,110, 97,109, + 101, 32, 97,110,100, 32, 98,111,100,121, 46, 10,102,117,110, + 99,116,105,111,110, 32, 77,111,100,117,108,101, 32, 40,110, + 44, 98, 41, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32, + 95, 77,111,100,117,108,101, 40, 95, 67,111,110,116, 97,105, + 110,101,114,123,110, 97,109,101, 61,110,125, 41, 10, 32,112, + 117,115,104, 40,116, 41, 10, 32,116, 58,112, 97,114,115,101, + 40,115,116,114,115,117, 98, 40, 98, 44, 50, 44,115,116,114, + 108,101,110, 40, 98, 41, 45, 49, 41, 41, 32, 45, 45, 32,101, + 108,105,109,105,110, 97,116,101, 32, 98,114, 97, 99,101,115, + 10, 32,112,111,112, 40, 41, 10, 32,114,101,116,117,114,110, + 32,116, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/module.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,110, 97,109,101,115, + 112, 97, 99,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87, + 114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101, + 109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, + 67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, + 45, 32, 74,117,108, 32, 50, 48, 48, 51, 10, 45, 45, 32, 36, + 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, + 99,111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111, + 102,116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, + 32,114,101,100,105,115,116,114,105, 98,117,116,101, 32,105, + 116, 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, + 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102, + 116,119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32, + 104,101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, + 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115, + 105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, + 97,117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, + 98,108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114, + 111,118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, + 99,101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112, + 100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, + 99,101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100, + 105,102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, + 45, 32, 78, 97,109,101,115,112, 97, 99,101, 32, 99,108, 97, + 115,115, 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116, + 115, 32, 97, 32,110, 97,109,101,115, 97,112, 99,101, 32,100, + 101,102,105,110,105,116,105,111,110, 46, 10, 45, 45, 32, 83, + 116,111,114,101,115, 32,116,104,101, 32,102,111,108,108,111, + 119,105,110,103, 32,102,105,101,108,100,115, 58, 10, 45, 45, + 32, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,108, 97,115, + 115, 32,110, 97,109,101, 10, 45, 45, 32, 32, 32, 32,123,105, + 125, 32, 32, 61, 32,108,105,115,116, 32,111,102, 32,109,101, + 109, 98,101,114,115, 10, 99,108, 97,115,115, 78, 97,109,101, + 115,112, 97, 99,101, 32, 61, 32,123, 10, 32, 99,108, 97,115, + 115,116,121,112,101, 32, 61, 32, 39,110, 97,109,101,115,112, + 97, 99,101, 39, 44, 10, 32,110, 97,109,101, 32, 61, 32, 39, + 39, 44, 10,125, 10, 99,108, 97,115,115, 78, 97,109,101,115, + 112, 97, 99,101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, + 99,108, 97,115,115, 78, 97,109,101,115,112, 97, 99,101, 10, + 115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108, + 97,115,115, 78, 97,109,101,115,112, 97, 99,101, 44, 99,108, + 97,115,115, 77,111,100,117,108,101, 41, 10, 10, 45, 45, 32, + 80,114,105,110,116, 32,109,101,116,104,111,100, 10,102,117, + 110, 99,116,105,111,110, 32, 99,108, 97,115,115, 78, 97,109, + 101,115,112, 97, 99,101, 58,112,114,105,110,116, 32, 40,105, + 100,101,110,116, 44, 99,108,111,115,101, 41, 10, 32,112,114, + 105,110,116, 40,105,100,101,110,116, 46, 46, 34, 78, 97,109, + 101,115,112, 97, 99,101,123, 34, 41, 10, 32,112,114,105,110, + 116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101, + 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109, + 101, 46, 46, 34, 39, 44, 34, 41, 10, 32,108,111, 99, 97,108, + 32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108, + 102, 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91, + 105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32, 61, + 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,110, + 116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99, + 108,111,115,101, 41, 10,101,110,100, 10, 10, 45, 45, 32, 73, + 110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,117, + 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32, 95, + 78, 97,109,101,115,112, 97, 99,101, 32, 40,116, 41, 10, 32, + 115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, + 99,108, 97,115,115, 78, 97,109,101,115,112, 97, 99,101, 41, + 10, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101, + 116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, + 67,111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, + 69,120,112,101, 99,116,115, 32,116,104,101, 32,110, 97,109, + 101, 32, 97,110,100, 32,116,104,101, 32, 98,111,100,121, 32, + 111,102, 32,116,104,101, 32,110, 97,109,101,115,112, 97, 99, + 101, 46, 10,102,117,110, 99,116,105,111,110, 32, 78, 97,109, + 101,115,112, 97, 99,101, 32, 40,110, 44, 98, 41, 10, 32,108, + 111, 99, 97,108, 32, 99, 32, 61, 32, 95, 78, 97,109,101,115, + 112, 97, 99,101, 40, 95, 67,111,110,116, 97,105,110,101,114, + 123,110, 97,109,101, 61,110,125, 41, 10, 32,112,117,115,104, + 40, 99, 41, 10, 32, 99, 58,112, 97,114,115,101, 40,115,116, + 114,115,117, 98, 40, 98, 44, 50, 44,115,116,114,108,101,110, + 40, 98, 41, 45, 49, 41, 41, 32, 45, 45, 32,101,108,105,109, + 105,110, 97,116,101, 32, 98,114, 97, 99,101,115, 10, 32,112, + 111,112, 40, 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/namespace.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,100,101,102,105,110, + 101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116, + 116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, + 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, + 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74, + 117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, + 32,100,101,102,105,110,101, 46,108,117, 97, 44,118, 32, 49, + 46, 50, 32, 49, 57, 57, 57, 47, 48, 55, 47, 50, 56, 32, 50, + 50, 58, 50, 49, 58, 48, 56, 32, 99,101,108,101,115, 32, 69, + 120,112, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99, + 111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102, + 116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32, + 114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, + 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32, + 105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116, + 119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104, + 101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, + 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105, + 115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97, + 117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98, + 108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111, + 118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99, + 101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, + 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99, + 101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105, + 102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, + 32, 68,101,102,105,110,101, 32, 99,108, 97,115,115, 10, 45, + 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 97, 32, + 110,117,109,101,114,105, 99, 32, 99,111,110,115,116, 32,100, + 101,102,105,110,105,116,105,111,110, 10, 45, 45, 32, 84,104, + 101, 32,102,111,108,108,111,119,105,110,103, 32,102,105,108, + 100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10, + 45, 45, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,111,110, + 115,116, 97,110,116, 32,110, 97,109,101, 10, 99,108, 97,115, + 115, 68,101,102,105,110,101, 32, 61, 32,123, 10, 32,110, 97, + 109,101, 32, 61, 32, 39, 39, 44, 10,125, 10, 99,108, 97,115, + 115, 68,101,102,105,110,101, 46, 95, 95,105,110,100,101,120, + 32, 61, 32, 99,108, 97,115,115, 68,101,102,105,110,101, 10, + 115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108, + 97,115,115, 68,101,102,105,110,101, 44, 99,108, 97,115,115, + 70,101, 97,116,117,114,101, 41, 10, 10, 45, 45, 32,114,101, + 103,105,115,116,101,114, 32,100,101,102,105,110,101, 10,102, + 117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, + 102,105,110,101, 58,114,101,103,105,115,116,101,114, 32, 40, + 112,114,101, 41, 10, 9,105,102, 32,110,111,116, 32,115,101, + 108,102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, + 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10, + 9, 9,114,101,116,117,114,110, 10, 9,101,110,100, 10, 10, + 32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, + 39, 10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, + 39,116,111,108,117, 97, 95, 99,111,110,115,116, 97,110,116, + 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101, + 108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 39, 46, + 46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 41, 59, + 39, 41, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110, + 116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 68,101,102,105,110,101, 58, + 112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108, + 111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 68,101,102,105,110,101,123, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10, + 10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99, + 111,110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99, + 116,105,111,110, 32, 95, 68,101,102,105,110,101, 32, 40,116, + 41, 10, 32,115,101,116,109,101,116, 97,116, 97, 98,108,101, + 40,116, 44, 99,108, 97,115,115, 68,101,102,105,110,101, 41, + 10, 32,116, 58, 98,117,105,108,100,110, 97,109,101,115, 40, + 41, 10, 10, 32,105,102, 32,116, 46,110, 97,109,101, 32, 61, + 61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,101,114,114, + 111,114, 40, 34, 35,105,110,118, 97,108,105,100, 32,100,101, + 102,105,110,101, 34, 41, 10, 32,101,110,100, 10, 10, 32, 97, + 112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114, + 110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110, + 115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112, + 101, 99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114, + 101,112,114,101,115,101,110,116,105,110,103, 32,116,104,101, + 32, 99,111,110,115,116, 97,110,116, 32,110, 97,109,101, 10, + 102,117,110, 99,116,105,111,110, 32, 68,101,102,105,110,101, + 32, 40,110, 41, 10, 32,114,101,116,117,114,110, 32, 95, 68, + 101,102,105,110,101,123, 10, 32, 32,110, 97,109,101, 32, 61, + 32,110, 10, 32,125, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/define.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,101,110,117,109,101, + 114, 97,116,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87, + 114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101, + 109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, + 67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, + 45, 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, + 73,100, 58, 32,101,110,117,109,101,114, 97,116,101, 46,108, + 117, 97, 44,118, 32, 49, 46, 51, 32, 50, 48, 48, 48, 47, 48, + 49, 47, 50, 52, 32, 50, 48, 58, 52, 49, 58, 49, 53, 32, 99, + 101,108,101,115, 32, 69,120,112, 32, 36, 10, 10, 45, 45, 32, + 84,104,105,115, 32, 99,111,100,101, 32,105,115, 32,102,114, + 101,101, 32,115,111,102,116,119, 97,114,101, 59, 32,121,111, + 117, 32, 99, 97,110, 32,114,101,100,105,115,116,114,105, 98, + 117,116,101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109, + 111,100,105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104, + 101, 32,115,111,102,116,119, 97,114,101, 32,112,114,111,118, + 105,100,101,100, 32,104,101,114,101,117,110,100,101,114, 32, + 105,115, 32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, + 34, 32, 98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, + 32,116,104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, + 32,110,111, 32,111, 98,108,105,103, 97,116,105,111,110, 32, + 116,111, 32,112,114,111,118,105,100,101, 32,109, 97,105,110, + 116,101,110, 97,110, 99,101, 44, 32,115,117,112,112,111,114, + 116, 44, 32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32, + 101,110,104, 97,110, 99,101,109,101,110,116,115, 44, 32,111, + 114, 32,109,111,100,105,102,105, 99, 97,116,105,111,110,115, + 46, 10, 10, 10, 45, 45, 32, 69,110,117,109,101,114, 97,116, + 101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114, + 101,115,101,110,116,115, 32,101,110,117,109,101,114, 97,116, + 105,111,110, 10, 45, 45, 32, 84,104,101, 32,102,111,108,108, + 111,119,105,110,103, 32,102,105,101,108,100,115, 32, 97,114, + 101, 32,115,116,111,114,101,100, 58, 10, 45, 45, 32, 32, 32, + 32,123,105,125, 32, 61, 32,108,105,115,116, 32,111,102, 32, + 99,111,110,115,116, 97,110,116, 32,110, 97,109,101,115, 10, + 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 32, + 61, 32,123, 10,125, 10, 99,108, 97,115,115, 69,110,117,109, + 101,114, 97,116,101, 46, 95, 95,105,110,100,101,120, 32, 61, + 32, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101, + 10,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99, + 108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 44, 99, + 108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10, 10, 45, + 45, 32,114,101,103,105,115,116,101,114, 32,101,110,117,109, + 101,114, 97,116,105,111,110, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116, + 101, 58,114,101,103,105,115,116,101,114, 32, 40,112,114,101, + 41, 10, 9,105,102, 32,110,111,116, 32,115,101,108,102, 58, + 99,104,101, 99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, + 99,101,115,115, 40, 41, 32,116,104,101,110, 10, 9, 9,114, + 101,116,117,114,110, 10, 9,101,110,100, 10, 32,112,114,101, + 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10, 32,108, + 111, 99, 97,108, 32,110,115,112, 97, 99,101, 32, 61, 32,103, + 101,116,110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97, + 115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114, + 114, 41, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, + 119,104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,100, + 111, 10, 32, 9,105,102, 32,115,101,108,102, 46,108,110, 97, + 109,101,115, 91,105, 93, 32, 97,110,100, 32,115,101,108,102, + 46,108,110, 97,109,101,115, 91,105, 93, 32,126, 61, 32, 34, + 34, 32,116,104,101,110, 10, 9, 10, 9, 9,111,117,116,112, + 117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, + 99,111,110,115,116, 97,110,116, 40,116,111,108,117, 97, 95, + 83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109, + 101,115, 91,105, 93, 46, 46, 39, 34, 44, 39, 46, 46,110,115, + 112, 97, 99,101, 46, 46,115,101,108,102, 91,105, 93, 46, 46, + 39, 41, 59, 39, 41, 10, 9,101,110,100, 10, 32, 32,105, 32, + 61, 32,105, 43, 49, 10, 32,101,110,100, 10,101,110,100, 10, + 10, 45, 45, 32, 80,114,105,110,116, 32,109,101,116,104,111, + 100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 69,110,117,109,101,114, 97,116,101, 58,112,114,105,110, + 116, 32, 40,105,100,101,110,116, 44, 99,108,111,115,101, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34, 69,110,117,109,101,114, 97,116,101,123, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 110, 97,109,101, 32, 61, 32, 34, 46, 46,115,101,108,102, 46, + 110, 97,109,101, 41, 10, 32,108,111, 99, 97,108, 32,105, 61, + 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91,105, + 93, 32,100,111, 10, 32, 32,112,114,105,110,116, 40,105,100, + 101,110,116, 46, 46, 34, 32, 39, 34, 46, 46,115,101,108,102, + 91,105, 93, 46, 46, 34, 39, 40, 34, 46, 46,115,101,108,102, + 46,108,110, 97,109,101,115, 91,105, 93, 46, 46, 34, 41, 44, + 34, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101, + 110,100, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, + 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101, + 110,100, 10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, + 32, 99,111,110,115,116,114,117, 99,116,111,114, 10,102,117, + 110, 99,116,105,111,110, 32, 95, 69,110,117,109,101,114, 97, + 116,101, 32, 40,116, 44,118, 97,114,110, 97,109,101, 41, 10, + 32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, + 44, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101, + 41, 10, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32, 97, + 112,112,101,110,100,101,110,117,109, 40,116, 41, 10, 9, 32, + 105,102, 32,118, 97,114,110, 97,109,101, 32, 97,110,100, 32, + 118, 97,114,110, 97,109,101, 32,126, 61, 32, 34, 34, 32,116, + 104,101,110, 10, 9, 9,105,102, 32,116, 46,110, 97,109,101, + 32,126, 61, 32, 34, 34, 32,116,104,101,110, 10, 9, 9, 9, + 86, 97,114,105, 97, 98,108,101, 40,116, 46,110, 97,109,101, + 46, 46, 34, 32, 34, 46, 46,118, 97,114,110, 97,109,101, 41, + 10, 9, 9,101,108,115,101, 10, 9, 9, 9,108,111, 99, 97, + 108, 32,110,115, 32, 61, 32,103,101,116, 99,117,114,114,110, + 97,109,101,115,112, 97, 99,101, 40, 41, 10, 9, 9, 9,119, + 97,114,110,105,110,103, 40, 34, 86, 97,114,105, 97, 98,108, + 101, 32, 34, 46, 46,110,115, 46, 46,118, 97,114,110, 97,109, + 101, 46, 46, 34, 32,111,102, 32,116,121,112,101, 32, 60, 97, + 110,111,110,121,109,111,117,115, 32,101,110,117,109, 62, 32, + 105,115, 32,100,101, 99,108, 97,114,101,100, 32, 97,115, 32, + 114,101, 97,100, 45,111,110,108,121, 34, 41, 10, 9, 9, 9, + 86, 97,114,105, 97, 98,108,101, 40, 34,116,111,108,117, 97, + 95,114,101, 97,100,111,110,108,121, 32,105,110,116, 32, 34, + 46, 46,118, 97,114,110, 97,109,101, 41, 10, 9, 9,101,110, + 100, 10, 9,101,110,100, 10, 9, 32,108,111, 99, 97,108, 32, + 112, 97,114,101,110,116, 32, 61, 32, 99,108, 97,115,115, 67, + 111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 10, 9, + 32,105,102, 32,112, 97,114,101,110,116, 32,116,104,101,110, + 10, 9, 9,116, 46, 97, 99, 99,101,115,115, 32, 61, 32,112, + 97,114,101,110,116, 46, 99,117,114,114, 95,109,101,109, 98, + 101,114, 95, 97, 99, 99,101,115,115, 10, 9, 9,116, 46,103, + 108,111, 98, 97,108, 95, 97, 99, 99,101,115,115, 32, 61, 32, + 116, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, 95, + 97, 99, 99,101,115,115, 40, 41, 10, 9, 32,101,110,100, 10, + 114,101,116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, + 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, 10, 45, + 45, 32, 69,120,112,101, 99,116,115, 32, 97, 32,115,116,114, + 105,110,103, 32,114,101,112,114,101,115,101,110,116,105,110, + 103, 32,116,104,101, 32,101,110,117,109,101,114, 97,116,101, + 32, 98,111,100,121, 10,102,117,110, 99,116,105,111,110, 32, + 69,110,117,109,101,114, 97,116,101, 32, 40,110, 44, 98, 44, + 118, 97,114,110, 97,109,101, 41, 10, 9, 98, 32, 61, 32,115, + 116,114,105,110,103, 46,103,115,117, 98, 40, 98, 44, 32, 34, + 44, 91, 37,115, 92,110, 93, 42,125, 34, 44, 32, 34, 92,110, + 125, 34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116, + 101, 32,108, 97,115,116, 32, 39, 44, 39, 10, 32,108,111, 99, + 97,108, 32,116, 32, 61, 32,115,112,108,105,116, 40,115,116, + 114,115,117, 98, 40, 98, 44, 50, 44, 45, 50, 41, 44, 39, 44, + 39, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101, + 32, 98,114, 97, 99,101,115, 10, 32,108,111, 99, 97,108, 32, + 105, 32, 61, 32, 49, 10, 32,108,111, 99, 97,108, 32,101, 32, + 61, 32,123,110, 61, 48,125, 10, 32,119,104,105,108,101, 32, + 116, 91,105, 93, 32,100,111, 10, 32, 32,108,111, 99, 97,108, + 32,116,116, 32, 61, 32,115,112,108,105,116, 40,116, 91,105, + 93, 44, 39, 61, 39, 41, 32, 32, 45, 45, 32,100,105,115, 99, + 97,114,100, 32,105,110,105,116,105, 97,108, 32,118, 97,108, + 117,101, 10, 32, 32,101, 46,110, 32, 61, 32,101, 46,110, 32, + 43, 32, 49, 10, 32, 32,101, 91,101, 46,110, 93, 32, 61, 32, + 116,116, 91, 49, 93, 10, 32, 32,105, 32, 61, 32,105, 43, 49, + 10, 32,101,110,100, 10, 32, 45, 45, 32,115,101,116, 32,108, + 117, 97, 32,110, 97,109,101,115, 10, 32,105, 32, 32, 61, 32, + 49, 10, 32,101, 46,108,110, 97,109,101,115, 32, 61, 32,123, + 125, 10, 32,108,111, 99, 97,108, 32,110,115, 32, 61, 32,103, + 101,116, 99,117,114,114,110, 97,109,101,115,112, 97, 99,101, + 40, 41, 10, 32,119,104,105,108,101, 32,101, 91,105, 93, 32, + 100,111, 10, 32, 32,108,111, 99, 97,108, 32,116, 32, 61, 32, + 115,112,108,105,116, 40,101, 91,105, 93, 44, 39, 64, 39, 41, + 10, 32, 32,101, 91,105, 93, 32, 61, 32,116, 91, 49, 93, 10, + 9, 9,105,102, 32,110,111,116, 32,116, 91, 50, 93, 32,116, + 104,101,110, 10, 9, 9, 32,116, 91, 50, 93, 32, 61, 32, 97, + 112,112,108,121,114,101,110, 97,109,105,110,103, 40,116, 91, + 49, 93, 41, 10, 9, 9,101,110,100, 10, 32, 32,101, 46,108, + 110, 97,109,101,115, 91,105, 93, 32, 61, 32,116, 91, 50, 93, + 32,111,114, 32,116, 91, 49, 93, 10, 32, 32, 95,103,108,111, + 98, 97,108, 95,101,110,117,109,115, 91, 32,110,115, 46, 46, + 101, 91,105, 93, 32, 93, 32, 61, 32, 40,110,115, 46, 46,101, + 91,105, 93, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, + 32,101,110,100, 10, 9,101, 46,110, 97,109,101, 32, 61, 32, + 110, 10, 9,105,102, 32,110, 32,126, 61, 32, 34, 34, 32,116, + 104,101,110, 10, 9, 9, 84,121,112,101,100,101,102, 40, 34, + 105,110,116, 32, 34, 46, 46,110, 41, 10, 9,101,110,100, 10, + 32,114,101,116,117,114,110, 32, 95, 69,110,117,109,101,114, + 97,116,101, 40,101, 44, 32,118, 97,114,110, 97,109,101, 41, + 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/enumerate.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,100,101, 99,108, 97, + 114, 97,116,105,111,110, 32, 99,108, 97,115,115, 10, 45, 45, + 32, 87,114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108, + 100,101,109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, + 84,101, 67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, + 10, 45, 45, 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, + 32, 36, 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105, + 115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101, 32, + 115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32, 99, + 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,101, + 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,105, + 102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115, + 111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,101, + 100, 32,104,101,114,101,117,110,100,101,114, 32,105,115, 32, + 111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, + 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104, + 101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,111, + 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111, 32, + 112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,110, + 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44, 32, + 117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, + 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,109, + 111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10, 10, + 10, 45, 45, 32, 68,101, 99,108, 97,114, 97,116,105,111,110, + 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101, + 115,101,110,116,115, 32,118, 97,114,105, 97, 98,108,101, 44, + 32,102,117,110, 99,116,105,111,110, 44, 32,111,114, 32, 97, + 114,103,117,109,101,110,116, 32,100,101, 99,108, 97,114, 97, + 116,105,111,110, 46, 10, 45, 45, 32, 83,116,111,114,101,115, + 32,116,104,101, 32,102,111,108,108,111,119,105,110,103, 32, + 102,105,101,108,100,115, 58, 10, 45, 45, 32, 32,109,111,100, + 32, 32, 61, 32,116,121,112,101, 32,109,111,100,105,102,105, + 101,114,115, 10, 45, 45, 32, 32,116,121,112,101, 32, 61, 32, + 116,121,112,101, 10, 45, 45, 32, 32,112,116,114, 32, 32, 61, + 32, 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, 32,105,102, + 32,114,101,112,114,101,115,101,110,116,105,110,103, 32, 97, + 32,112,111,105,110,116,101,114, 32,111,114, 32, 97, 32,114, + 101,102,101,114,101,110, 99,101, 10, 45, 45, 32, 32,110, 97, + 109,101, 32, 61, 32,110, 97,109,101, 10, 45, 45, 32, 32,100, + 105,109, 32, 32, 61, 32,100,105,109,101,110,115,105,111,110, + 44, 32,105,102, 32, 97, 32,118,101, 99,116,111,114, 10, 45, + 45, 32, 32,100,101,102, 32, 32, 61, 32,100,101,102, 97,117, + 108,116, 32,118, 97,108,117,101, 44, 32,105,102, 32, 97,110, + 121, 32, 40,111,110,108,121, 32,102,111,114, 32, 97,114,103, + 117,109,101,110,116,115, 41, 10, 45, 45, 32, 32,114,101,116, + 32, 32, 61, 32, 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, + 32,105,102, 32,118, 97,108,117,101, 32,105,115, 32,116,111, + 32, 98,101, 32,114,101,116,117,114,110,101,100, 32, 40,111, + 110,108,121, 32,102,111,114, 32, 97,114,103,117,109,101,110, + 116,115, 41, 10, 99,108, 97,115,115, 68,101, 99,108, 97,114, + 97,116,105,111,110, 32, 61, 32,123, 10, 32,109,111,100, 32, + 61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39, + 39, 44, 10, 32,112,116,114, 32, 61, 32, 39, 39, 44, 10, 32, + 110, 97,109,101, 32, 61, 32, 39, 39, 44, 10, 32,100,105,109, + 32, 61, 32, 39, 39, 44, 10, 32,114,101,116, 32, 61, 32, 39, + 39, 44, 10, 32,100,101,102, 32, 61, 32, 39, 39, 10,125, 10, + 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111, + 110, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97, + 115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 10,115, + 101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108, 97, + 115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 44, 99, + 108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10, 10, 45, + 45, 32, 67,114,101, 97,116,101, 32, 97,110, 32,117,110,105, + 113,117,101, 32,118, 97,114,105, 97, 98,108,101, 32,110, 97, + 109,101, 10,102,117,110, 99,116,105,111,110, 32, 99,114,101, + 97,116,101, 95,118, 97,114,110, 97,109,101, 32, 40, 41, 10, + 32,105,102, 32,110,111,116, 32, 95,118, 97,114,110,117,109, + 98,101,114, 32,116,104,101,110, 32, 95,118, 97,114,110,117, + 109, 98,101,114, 32, 61, 32, 48, 32,101,110,100, 10, 32, 95, + 118, 97,114,110,117,109, 98,101,114, 32, 61, 32, 95,118, 97, + 114,110,117,109, 98,101,114, 32, 43, 32, 49, 10, 32,114,101, + 116,117,114,110, 32, 34,116,111,108,117, 97, 95,118, 97,114, + 95, 34, 46, 46, 95,118, 97,114,110,117,109, 98,101,114, 10, + 101,110,100, 10, 10, 45, 45, 32, 67,104,101, 99,107, 32,100, + 101, 99,108, 97,114, 97,116,105,111,110, 32,110, 97,109,101, + 10, 45, 45, 32, 73,116, 32, 97,108,115,111, 32,105,100,101, + 110,116,105,102,105,101,115, 32,100,101,102, 97,117,108,116, + 32,118, 97,108,117,101,115, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116, + 105,111,110, 58, 99,104,101, 99,107,110, 97,109,101, 32, 40, + 41, 10, 10, 32,105,102, 32,115,116,114,115,117, 98, 40,115, + 101,108,102, 46,110, 97,109,101, 44, 49, 44, 49, 41, 32, 61, + 61, 32, 39, 91, 39, 32, 97,110,100, 32,110,111,116, 32,102, + 105,110,100,116,121,112,101, 40,115,101,108,102, 46,116,121, + 112,101, 41, 32,116,104,101,110, 10, 32, 32,115,101,108,102, + 46,110, 97,109,101, 32, 61, 32,115,101,108,102, 46,116,121, + 112,101, 46, 46,115,101,108,102, 46,110, 97,109,101, 10, 32, + 32,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112,108,105, + 116, 40,115,101,108,102, 46,109,111,100, 44, 39, 37,115, 37, + 115, 42, 39, 41, 10, 32, 32,115,101,108,102, 46,116,121,112, + 101, 32, 61, 32,109, 91,109, 46,110, 93, 10, 32, 32,115,101, + 108,102, 46,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, + 40,109, 44, 49, 44,109, 46,110, 45, 49, 41, 10, 32,101,110, + 100, 10, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,115, + 112,108,105,116, 40,115,101,108,102, 46,110, 97,109,101, 44, + 39, 61, 39, 41, 10, 32,105,102, 32,116, 46,110, 61, 61, 50, + 32,116,104,101,110, 10, 32, 32,115,101,108,102, 46,110, 97, + 109,101, 32, 61, 32,116, 91, 49, 93, 10, 32, 32,115,101,108, + 102, 46,100,101,102, 32, 61, 32,102,105,110,100, 95,101,110, + 117,109, 95,118, 97,114, 40,116, 91,116, 46,110, 93, 41, 10, + 32,101,110,100, 10, 10, 32,108,111, 99, 97,108, 32, 98, 44, + 101, 44,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115, + 101,108,102, 46,110, 97,109,101, 44, 34, 37, 91, 40, 46, 45, + 41, 37, 93, 34, 41, 10, 32,105,102, 32, 98, 32,116,104,101, + 110, 10, 32, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, + 32,115,116,114,115,117, 98, 40,115,101,108,102, 46,110, 97, + 109,101, 44, 49, 44, 98, 45, 49, 41, 10, 32, 32,115,101,108, + 102, 46,100,105,109, 32, 61, 32,102,105,110,100, 95,101,110, + 117,109, 95,118, 97,114, 40,100, 41, 10, 32,101,110,100, 10, + 10, 10, 32,105,102, 32,115,101,108,102, 46,116,121,112,101, + 32,126, 61, 32, 39, 39, 32, 97,110,100, 32,115,101,108,102, + 46,116,121,112,101, 32,126, 61, 32, 39,118,111,105,100, 39, + 32, 97,110,100, 32,115,101,108,102, 46,110, 97,109,101, 32, + 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,115,101, + 108,102, 46,110, 97,109,101, 32, 61, 32, 99,114,101, 97,116, + 101, 95,118, 97,114,110, 97,109,101, 40, 41, 10, 32,101,108, + 115,101,105,102, 32,115,101,108,102, 46,107,105,110,100, 61, + 61, 39,118, 97,114, 39, 32,116,104,101,110, 10, 32, 32,105, + 102, 32,115,101,108,102, 46,116,121,112,101, 61, 61, 39, 39, + 32, 97,110,100, 32,115,101,108,102, 46,110, 97,109,101,126, + 61, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,115,101,108, + 102, 46,116,121,112,101, 32, 61, 32,115,101,108,102, 46,116, + 121,112,101, 46, 46,115,101,108,102, 46,110, 97,109,101, 10, + 32, 32, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 32, + 99,114,101, 97,116,101, 95,118, 97,114,110, 97,109,101, 40, + 41, 10, 32, 32,101,108,115,101,105,102, 32,102,105,110,100, + 116,121,112,101, 40,115,101,108,102, 46,110, 97,109,101, 41, + 32,116,104,101,110, 10, 32, 32, 32,105,102, 32,115,101,108, + 102, 46,116,121,112,101, 61, 61, 39, 39, 32,116,104,101,110, + 32,115,101,108,102, 46,116,121,112,101, 32, 61, 32,115,101, + 108,102, 46,110, 97,109,101, 10, 32, 32, 32,101,108,115,101, + 32,115,101,108,102, 46,116,121,112,101, 32, 61, 32,115,101, + 108,102, 46,116,121,112,101, 46, 46, 39, 32, 39, 46, 46,115, + 101,108,102, 46,110, 97,109,101, 32,101,110,100, 10, 32, 32, + 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 32, 99,114, + 101, 97,116,101, 95,118, 97,114,110, 97,109,101, 40, 41, 10, + 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, + 32, 97,100,106,117,115,116, 32,116,121,112,101, 32,111,102, + 32,115,116,114,105,110,103, 10, 32,105,102, 32,115,101,108, + 102, 46,116,121,112,101, 32, 61, 61, 32, 39, 99,104, 97,114, + 39, 32, 97,110,100, 32,115,101,108,102, 46,100,105,109, 32, + 126, 61, 32, 39, 39, 32,116,104,101,110, 10, 9, 32,115,101, + 108,102, 46,116,121,112,101, 32, 61, 32, 39, 99,104, 97,114, + 42, 39, 10, 32,101,110,100, 10, 10, 9,105,102, 32,115,101, + 108,102, 46,107,105,110,100, 32, 97,110,100, 32,115,101,108, + 102, 46,107,105,110,100, 32, 61, 61, 32, 39,118, 97,114, 39, + 32,116,104,101,110, 10, 9, 9,115,101,108,102, 46,110, 97, + 109,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, + 98, 40,115,101,108,102, 46,110, 97,109,101, 44, 32, 34, 58, + 46, 42, 36, 34, 44, 32, 34, 34, 41, 32, 45, 45, 32, 63, 63, + 63, 10, 9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, + 67,104,101, 99,107, 32,100,101, 99,108, 97,114, 97,116,105, + 111,110, 32,116,121,112,101, 10, 45, 45, 32, 83,117, 98,115, + 116,105,116,117,116,101,115, 32,116,121,112,101,100,101,102, + 39,115, 46, 10,102,117,110, 99,116,105,111,110, 32, 99,108, + 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58, + 99,104,101, 99,107,116,121,112,101, 32, 40, 41, 10, 10, 32, + 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,116,104,101, + 114,101, 32,105,115, 32, 97, 32,112,111,105,110,116,101,114, + 32,116,111, 32, 98, 97,115,105, 99, 32,116,121,112,101, 10, + 32,108,111, 99, 97,108, 32, 98, 97,115,105, 99, 32, 61, 32, + 105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116,121, + 112,101, 41, 10, 32,105,102, 32,115,101,108,102, 46,107,105, + 110,100, 32, 61, 61, 32, 39,102,117,110, 99, 39, 32, 97,110, + 100, 32, 98, 97,115,105, 99, 61, 61, 39,110,117,109, 98,101, + 114, 39, 32, 97,110,100, 32,115,116,114,105,110,103, 46,102, + 105,110,100, 40,115,101,108,102, 46,112,116,114, 44, 32, 34, + 37, 42, 34, 41, 32,116,104,101,110, 10, 32, 9,115,101,108, + 102, 46,116,121,112,101, 32, 61, 32, 39, 95,117,115,101,114, + 100, 97,116, 97, 39, 10, 32, 9,115,101,108,102, 46,112,116, + 114, 32, 61, 32, 34, 34, 10, 32,101,110,100, 10, 32,105,102, + 32, 98, 97,115,105, 99, 32, 97,110,100, 32,115,101,108,102, + 46,112,116,114,126, 61, 39, 39, 32,116,104,101,110, 10, 32, + 32,115,101,108,102, 46,114,101,116, 32, 61, 32,115,101,108, + 102, 46,112,116,114, 10, 32, 32,115,101,108,102, 46,112,116, + 114, 32, 61, 32,110,105,108, 10, 32, 32,105,102, 32,105,115, + 98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,112,101, + 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116, + 104,101,110, 10, 32, 32, 9,115,101,108,102, 46,114,101,116, + 117,114,110, 95,117,115,101,114,100, 97,116, 97, 32, 61, 32, + 116,114,117,101, 10, 32, 32,101,110,100, 10, 32,101,110,100, + 10, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32, + 116,104,101,114,101, 32,105,115, 32, 97,114,114, 97,121, 32, + 116,111, 32, 98,101, 32,114,101,116,117,114,110,101,100, 10, + 32,105,102, 32,115,101,108,102, 46,100,105,109,126, 61, 39, + 39, 32, 97,110,100, 32,115,101,108,102, 46,114,101,116,126, + 61, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,101,114,114, + 111,114, 40, 39, 35,105,110,118, 97,108,105,100, 32,112, 97, + 114, 97,109,101,116,101,114, 58, 32, 99, 97,110,110,111,116, + 32,114,101,116,117,114,110, 32, 97,110, 32, 97,114,114, 97, + 121, 32,111,102, 32,118, 97,108,117,101,115, 39, 41, 10, 32, + 101,110,100, 10, 32, 45, 45, 32,114,101,115,116,111,114,101, + 32, 39,118,111,105,100, 42, 39, 32, 97,110,100, 32, 39,115, + 116,114,105,110,103, 42, 39, 10, 32,105,102, 32,115,101,108, + 102, 46,116,121,112,101, 32, 61, 61, 32, 39, 95,117,115,101, + 114,100, 97,116, 97, 39, 32,116,104,101,110, 32,115,101,108, + 102, 46,116,121,112,101, 32, 61, 32, 39,118,111,105,100, 42, + 39, 10, 32,101,108,115,101,105,102, 32,115,101,108,102, 46, + 116,121,112,101, 32, 61, 61, 32, 39, 95, 99,115,116,114,105, + 110,103, 39, 32,116,104,101,110, 32,115,101,108,102, 46,116, + 121,112,101, 32, 61, 32, 39, 99,104, 97,114, 42, 39, 10, 32, + 101,108,115,101,105,102, 32,115,101,108,102, 46,116,121,112, + 101, 32, 61, 61, 32, 39, 95,108,115,116, 97,116,101, 39, 32, + 116,104,101,110, 32,115,101,108,102, 46,116,121,112,101, 32, + 61, 32, 39,108,117, 97, 95, 83,116, 97,116,101, 42, 39, 10, + 32,101,110,100, 10, 10, 32, 45, 45, 32,114,101,115,111,108, + 118,101, 32,116,121,112,101,115, 32,105,110,115,105,100,101, + 32,116,104,101, 32,116,101,109,112,108, 97,116,101,115, 10, + 32,105,102, 32,115,101,108,102, 46,116,121,112,101, 32,116, + 104,101,110, 10, 9, 32,115,101,108,102, 46,116,121,112,101, + 32, 61, 32,114,101,115,111,108,118,101, 95,116,101,109,112, + 108, 97,116,101, 95,116,121,112,101,115, 40,115,101,108,102, + 46,116,121,112,101, 41, 10, 32,101,110,100, 10, 10, 45, 45, + 10, 45, 45, 32, 45, 45, 32,105,102, 32,114,101,116,117,114, + 110,105,110,103, 32,118, 97,108,117,101, 44, 32, 97,117,116, + 111,109, 97,116,105, 99, 97,108,108,121, 32,115,101,116, 32, + 100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 10, 45, + 45, 32,105,102, 32,115,101,108,102, 46,114,101,116, 32,126, + 61, 32, 39, 39, 32, 97,110,100, 32,115,101,108,102, 46,100, + 101,102, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 45, + 45, 32, 32,115,101,108,102, 46,100,101,102, 32, 61, 32, 39, + 48, 39, 10, 45, 45, 32,101,110,100, 10, 45, 45, 10, 10,101, + 110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,114,101, + 115,111,108,118,101, 95,116,101,109,112,108, 97,116,101, 95, + 116,121,112,101,115, 40,116,121,112,101, 41, 10, 10, 9,105, + 102, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41, + 32,116,104,101,110, 10, 9, 9,114,101,116,117,114,110, 32, + 116,121,112,101, 10, 9,101,110,100, 10, 9,108,111, 99, 97, + 108, 32, 98, 44, 95, 44,109, 32, 61, 32,115,116,114,105,110, + 103, 46,102,105,110,100, 40,116,121,112,101, 44, 32, 34, 40, + 37, 98, 60, 62, 41, 34, 41, 10, 9,105,102, 32, 98, 32,116, + 104,101,110, 10, 10, 9, 9,109, 32, 61, 32,115,112,108,105, + 116, 95, 99, 95,116,111,107,101,110,115, 40,115,116,114,105, + 110,103, 46,115,117, 98, 40,109, 44, 32, 50, 44, 32, 45, 50, + 41, 44, 32, 34, 44, 34, 41, 10, 9, 9,102,111,114, 32,105, + 61, 49, 44, 32,116, 97, 98,108,101, 46,103,101,116,110, 40, + 109, 41, 32,100,111, 10, 9, 9, 9,109, 91,105, 93, 32, 61, + 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109, 91, + 105, 93, 44, 34, 37,115, 42, 40, 91, 37, 42, 38, 93, 41, 34, + 44, 32, 34, 37, 49, 34, 41, 10, 9, 9, 9,105,102, 32,110, + 111,116, 32,105,115,101,110,117,109, 40,109, 91,105, 93, 41, + 32,116,104,101,110, 32, 95, 44, 32,109, 91,105, 93, 32, 61, + 32, 97,112,112,108,121,116,121,112,101,100,101,102, 40, 34, + 34, 44, 32,109, 91,105, 93, 41, 32,101,110,100, 10, 9, 9, + 9,109, 91,105, 93, 32, 61, 32,102,105,110,100,116,121,112, + 101, 40,109, 91,105, 93, 41, 32,111,114, 32,109, 91,105, 93, + 10, 9, 9, 9,109, 91,105, 93, 32, 61, 32,114,101,115,111, + 108,118,101, 95,116,101,109,112,108, 97,116,101, 95,116,121, + 112,101,115, 40,109, 91,105, 93, 41, 10, 9, 9,101,110,100, + 10, 10, 9, 9,108,111, 99, 97,108, 32, 98, 44,105, 10, 9, + 9,116,121,112,101, 44, 98, 44,105, 32, 61, 32, 98,114,101, + 97,107, 95,116,101,109,112,108, 97,116,101, 40,116,121,112, + 101, 41, 10, 45, 45,112,114,105,110,116, 40, 34, 99,111,110, + 99, 97,116, 32,105,115, 32, 34, 44, 99,111,110, 99, 97,116, + 40,109, 44, 32, 49, 44, 32,109, 46,110, 41, 41, 10, 9, 9, + 108,111, 99, 97,108, 32,116,101,109,112,108, 97,116,101, 95, + 112, 97,114,116, 32, 61, 32, 34, 60, 34, 46, 46, 99,111,110, + 99, 97,116, 40,109, 44, 32, 49, 44, 32,109, 46,110, 44, 32, + 34, 44, 34, 41, 46, 46, 34, 62, 34, 10, 9, 9,116,121,112, + 101, 32, 61, 32,114,101, 98,117,105,108,100, 95,116,101,109, + 112,108, 97,116,101, 40,116,121,112,101, 44, 32, 98, 44, 32, + 116,101,109,112,108, 97,116,101, 95,112, 97,114,116, 41, 10, + 9, 9,116,121,112,101, 32, 61, 32,115,116,114,105,110,103, + 46,103,115,117, 98, 40,116,121,112,101, 44, 32, 34, 62, 62, + 34, 44, 32, 34, 62, 32, 62, 34, 41, 10, 9,101,110,100, 10, + 9,114,101,116,117,114,110, 32,116,121,112,101, 10,101,110, + 100, 10, 10,102,117,110, 99,116,105,111,110, 32, 98,114,101, + 97,107, 95,116,101,109,112,108, 97,116,101, 40,115, 41, 10, + 9,108,111, 99, 97,108, 32, 98, 44,101, 44,116,105,109,112, + 108, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, + 40,115, 44, 32, 34, 40, 37, 98, 60, 62, 41, 34, 41, 10, 9, + 105,102, 32,116,105,109,112,108, 32,116,104,101,110, 10, 9, + 9,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, + 98, 40,115, 44, 32, 34, 37, 98, 60, 62, 34, 44, 32, 34, 34, + 41, 10, 9, 9,114,101,116,117,114,110, 32,115, 44, 32, 98, + 44, 32,116,105,109,112,108, 10, 9,101,108,115,101, 10, 9, + 9,114,101,116,117,114,110, 32,115, 44, 32, 48, 44, 32,110, + 105,108, 10, 9,101,110,100, 10,101,110,100, 10, 10,102,117, + 110, 99,116,105,111,110, 32,114,101, 98,117,105,108,100, 95, + 116,101,109,112,108, 97,116,101, 40,115, 44, 32, 98, 44, 32, + 116,105,109,112,108, 41, 10, 10, 9,105,102, 32, 98, 32, 61, + 61, 32, 48, 32,116,104,101,110, 10, 9, 9,114,101,116,117, + 114,110, 32,115, 10, 9,101,110,100, 10, 10, 9,114,101,116, + 117,114,110, 32,115,116,114,105,110,103, 46,115,117, 98, 40, + 115, 44, 32, 49, 44, 32, 98, 45, 49, 41, 46, 46,116,105,109, + 112,108, 46, 46,115,116,114,105,110,103, 46,115,117, 98, 40, + 115, 44, 32, 98, 44, 32, 45, 49, 41, 10,101,110,100, 10, 10, + 45, 45, 32, 80,114,105,110,116, 32,109,101,116,104,111,100, + 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, + 68,101, 99,108, 97,114, 97,116,105,111,110, 58,112,114,105, + 110,116, 32, 40,105,100,101,110,116, 44, 99,108,111,115,101, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 68,101, 99,108, 97,114, 97,116,105,111,110,123, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115, + 101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, + 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114, + 105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97, + 109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, + 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105, + 110,116, 40,105,100,101,110,116, 46, 46, 34, 32,100,105,109, + 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,100,105, + 109, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, + 40,105,100,101,110,116, 46, 46, 34, 32,100,101,102, 32, 32, + 61, 32, 39, 34, 46, 46,115,101,108,102, 46,100,101,102, 46, + 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105, + 100,101,110,116, 46, 46, 34, 32,114,101,116, 32, 32, 61, 32, + 39, 34, 46, 46,115,101,108,102, 46,114,101,116, 46, 46, 34, + 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, + 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32, + 105,102, 32, 97,114,114, 97,121, 32,111,102, 32,118, 97,108, + 117,101,115, 32, 97,114,101, 32,114,101,116,117,114,110,101, + 100, 32,116,111, 32, 76,117, 97, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97, + 116,105,111,110, 58,114,101,113,117,105,114,101, 99,111,108, + 108,101, 99,116,105,111,110, 32, 40,116, 41, 10, 32,105,102, + 32,115,101,108,102, 46,109,111,100, 32,126, 61, 32, 39, 99, + 111,110,115,116, 39, 32, 97,110,100, 10, 9, 32, 32, 32, 32, + 115,101,108,102, 46,100,105,109, 32, 97,110,100, 32,115,101, + 108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32, 97,110, + 100, 10, 9, 9, 9, 9, 32,110,111,116, 32,105,115, 98, 97, + 115,105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 32, + 97,110,100, 10, 9, 9, 9, 9, 32,115,101,108,102, 46,112, + 116,114, 32, 61, 61, 32, 39, 39, 32, 97,110,100, 32,115,101, + 108,102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, + 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10, + 9, 9,108,111, 99, 97,108, 32,116,121,112,101, 32, 61, 32, + 103,115,117, 98, 40,115,101,108,102, 46,116,121,112,101, 44, + 34, 37,115, 42, 99,111,110,115,116, 37,115, 43, 34, 44, 34, + 34, 41, 10, 9, 9,116, 91,116,121,112,101, 93, 32, 61, 32, + 34,116,111,108,117, 97, 95, 99,111,108,108,101, 99,116, 95, + 34, 32, 46, 46, 32, 99,108,101, 97,110, 95,116,101,109,112, + 108, 97,116,101, 40,116,121,112,101, 41, 10, 9, 9,114,101, + 116,117,114,110, 32,116,114,117,101, 10, 9,101,110,100, 10, + 9,114,101,116,117,114,110, 32,102, 97,108,115,101, 10,101, + 110,100, 10, 10, 45, 45, 32,100,101, 99,108, 97,114,101, 32, + 116, 97,103, 10,102,117,110, 99,116,105,111,110, 32, 99,108, + 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58, + 100,101, 99,108,116,121,112,101, 32, 40, 41, 10, 10, 9,115, + 101,108,102, 46,116,121,112,101, 32, 61, 32,116,121,112,101, + 118, 97,114, 40,115,101,108,102, 46,116,121,112,101, 41, 10, + 9,105,102, 32,115,116,114,102,105,110,100, 40,115,101,108, + 102, 46,109,111,100, 44, 39, 99,111,110,115,116, 39, 41, 32, + 116,104,101,110, 10, 9, 9,115,101,108,102, 46,116,121,112, + 101, 32, 61, 32, 39, 99,111,110,115,116, 32, 39, 46, 46,115, + 101,108,102, 46,116,121,112,101, 10, 9, 9,115,101,108,102, + 46,109,111,100, 32, 61, 32,103,115,117, 98, 40,115,101,108, + 102, 46,109,111,100, 44, 39, 99,111,110,115,116, 37,115, 42, + 39, 44, 39, 39, 41, 10, 9,101,110,100, 10,101,110,100, 10, + 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116,121,112, + 101, 32, 99,104,101, 99,107,105,110,103, 10,102,117,110, 99, + 116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108, 97, + 114, 97,116,105,111,110, 58,111,117,116, 99,104,101, 99,107, + 116,121,112,101, 32, 40,110, 97,114,103, 41, 10, 32,108,111, + 99, 97,108, 32,100,101,102, 10, 32,108,111, 99, 97,108, 32, + 116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108, + 102, 46,116,121,112,101, 41, 10, 32,105,102, 32,115,101,108, + 102, 46,100,101,102,126, 61, 39, 39, 32,116,104,101,110, 10, + 32, 32,100,101,102, 32, 61, 32, 49, 10, 32,101,108,115,101, + 10, 32, 32,100,101,102, 32, 61, 32, 48, 10, 32,101,110,100, + 10, 32,105,102, 32,115,101,108,102, 46,100,105,109, 32,126, + 61, 32, 39, 39, 32,116,104,101,110, 10, 9, 45, 45,105,102, + 32,116, 61, 61, 39,115,116,114,105,110,103, 39, 32,116,104, + 101,110, 10, 9, 45, 45, 9,114,101,116,117,114,110, 32, 39, + 116,111,108,117, 97, 95,105,115,115,116,114,105,110,103, 97, + 114,114, 97,121, 40,116,111,108,117, 97, 95, 83, 44, 39, 46, + 46,110, 97,114,103, 46, 46, 39, 44, 39, 46, 46,100,101,102, + 46, 46, 39, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, + 39, 10, 9, 45, 45,101,108,115,101, 10, 9,114,101,116,117, + 114,110, 32, 39, 33,116,111,108,117, 97, 95,105,115,116, 97, + 98,108,101, 40,116,111,108,117, 97, 95, 83, 44, 39, 46, 46, + 110, 97,114,103, 46, 46, 39, 44, 48, 44, 38,116,111,108,117, + 97, 95,101,114,114, 41, 39, 10, 32, 9, 45, 45,101,110,100, + 10, 32,101,108,115,101,105,102, 32,116, 32,116,104,101,110, + 10, 9,114,101,116,117,114,110, 32, 39, 33,116,111,108,117, + 97, 95,105,115, 39, 46, 46,116, 46, 46, 39, 40,116,111,108, + 117, 97, 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, 39, + 44, 39, 46, 46,100,101,102, 46, 46, 39, 44, 38,116,111,108, + 117, 97, 95,101,114,114, 41, 39, 10, 32,101,108,115,101, 10, + 32, 32,108,111, 99, 97,108, 32,105,115, 95,102,117,110, 99, + 32, 61, 32,103,101,116, 95,105,115, 95,102,117,110, 99,116, + 105,111,110, 40,115,101,108,102, 46,116,121,112,101, 41, 10, + 32, 32,105,102, 32,115,101,108,102, 46,112,116,114, 32, 61, + 61, 32, 39, 38, 39, 32,111,114, 32,115,101,108,102, 46,112, + 116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32, + 32, 9,114,101,116,117,114,110, 32, 39, 40,116,111,108,117, + 97, 95,105,115,118, 97,108,117,101,110,105,108, 40,116,111, + 108,117, 97, 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, + 39, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 32,124, + 124, 32, 33, 39, 46, 46,105,115, 95,102,117,110, 99, 46, 46, + 39, 40,116,111,108,117, 97, 95, 83, 44, 39, 46, 46,110, 97, + 114,103, 46, 46, 39, 44, 34, 39, 46, 46,115,101,108,102, 46, + 116,121,112,101, 46, 46, 39, 34, 44, 39, 46, 46,100,101,102, + 46, 46, 39, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, + 41, 39, 10, 32, 32,101,108,115,101, 10, 9,114,101,116,117, + 114,110, 32, 39, 33, 39, 46, 46,105,115, 95,102,117,110, 99, + 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 39, 46, 46, + 110, 97,114,103, 46, 46, 39, 44, 34, 39, 46, 46,115,101,108, + 102, 46,116,121,112,101, 46, 46, 39, 34, 44, 39, 46, 46,100, + 101,102, 46, 46, 39, 44, 38,116,111,108,117, 97, 95,101,114, + 114, 41, 39, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, + 101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99, + 108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, + 58, 98,117,105,108,100,100,101, 99,108, 97,114, 97,116,105, + 111,110, 32, 40,110, 97,114,103, 44, 32, 99,112,108,117,115, + 112,108,117,115, 41, 10, 32,108,111, 99, 97,108, 32, 97,114, + 114, 97,121, 32, 61, 32,115,101,108,102, 46,100,105,109, 32, + 126, 61, 32, 39, 39, 32, 97,110,100, 32,116,111,110,117,109, + 98,101,114, 40,115,101,108,102, 46,100,105,109, 41, 61, 61, + 110,105,108, 10, 9,108,111, 99, 97,108, 32,108,105,110,101, + 32, 61, 32, 34, 34, 10, 32,108,111, 99, 97,108, 32,112,116, + 114, 32, 61, 32, 39, 39, 10, 32,108,111, 99, 97,108, 32,109, + 111,100, 10, 32,108,111, 99, 97,108, 32,116,121,112,101, 32, + 61, 32,115,101,108,102, 46,116,121,112,101, 10, 32,108,111, + 99, 97,108, 32,110, 99,116,121,112,101, 32, 61, 32,103,115, + 117, 98, 40,115,101,108,102, 46,116,121,112,101, 44, 39, 99, + 111,110,115,116, 37,115, 43, 39, 44, 39, 39, 41, 10, 32,105, + 102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32, 39, + 39, 32,116,104,101,110, 10, 9, 32,116,121,112,101, 32, 61, + 32,103,115,117, 98, 40,115,101,108,102, 46,116,121,112,101, + 44, 39, 99,111,110,115,116, 37,115, 43, 39, 44, 39, 39, 41, + 32, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,115, + 32, 99,111,110,115,116, 32,109,111,100,105,102,105,101,114, + 32,102,111,114, 32, 97,114,114, 97,121,115, 10, 32,101,110, + 100, 10, 32,105,102, 32,115,101,108,102, 46,112,116,114,126, + 61, 39, 39, 32, 97,110,100, 32,110,111,116, 32,105,115, 98, + 97,115,105, 99, 40,116,121,112,101, 41, 32,116,104,101,110, + 32,112,116,114, 32, 61, 32, 39, 42, 39, 32,101,110,100, 10, + 32,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, + 97,114, 97,109, 40,108,105,110,101, 44, 34, 32, 34, 44,115, + 101,108,102, 46,109,111,100, 44,116,121,112,101, 44,112,116, + 114, 41, 10, 32,105,102, 32, 97,114,114, 97,121, 32,116,104, + 101,110, 10, 32, 32,108,105,110,101, 32, 61, 32, 99,111,110, + 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44, 39, + 42, 39, 41, 10, 32,101,110,100, 10, 32,108,105,110,101, 32, + 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108, + 105,110,101, 44,115,101,108,102, 46,110, 97,109,101, 41, 10, + 32,105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, + 32, 39, 39, 32,116,104,101,110, 10, 32, 32,105,102, 32,116, + 111,110,117,109, 98,101,114, 40,115,101,108,102, 46,100,105, + 109, 41,126, 61,110,105,108, 32,116,104,101,110, 10, 32, 32, + 32,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, + 97,114, 97,109, 40,108,105,110,101, 44, 39, 91, 39, 44,115, + 101,108,102, 46,100,105,109, 44, 39, 93, 59, 39, 41, 10, 32, + 32,101,108,115,101, 10, 9,105,102, 32, 99,112,108,117,115, + 112,108,117,115, 32,116,104,101,110, 10, 9, 9,108,105,110, + 101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, + 40,108,105,110,101, 44, 39, 32, 61, 32, 77,116,111,108,117, + 97, 95,110,101,119, 40, 40, 39, 44,116,121,112,101, 44,112, + 116,114, 44, 39, 41, 91, 39, 46, 46,115,101,108,102, 46,100, + 105,109, 46, 46, 39, 93, 41, 59, 39, 41, 10, 9,101,108,115, + 101, 10, 9, 9,108,105,110,101, 32, 61, 32, 99,111,110, 99, + 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 32, + 61, 32, 40, 39, 44,116,121,112,101, 44,112,116,114, 44, 39, + 42, 41, 39, 44, 10, 9, 9, 39,109, 97,108,108,111, 99, 40, + 40, 39, 44,115,101,108,102, 46,100,105,109, 44, 39, 41, 42, + 115,105,122,101,111,102, 40, 39, 44,116,121,112,101, 44,112, + 116,114, 44, 39, 41, 41, 59, 39, 41, 10, 9,101,110,100, 10, + 32, 32,101,110,100, 10, 32,101,108,115,101, 10, 32, 32,108, + 111, 99, 97,108, 32,116, 32, 61, 32,105,115, 98, 97,115,105, + 99, 40,116,121,112,101, 41, 10, 32, 32,108,105,110,101, 32, + 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108, + 105,110,101, 44, 39, 32, 61, 32, 39, 41, 10, 32, 32,105,102, + 32,116, 32, 61, 61, 32, 39,115,116, 97,116,101, 39, 32,116, + 104,101,110, 10, 32, 32, 9,108,105,110,101, 32, 61, 32, 99, + 111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, + 44, 32, 39,116,111,108,117, 97, 95, 83, 59, 39, 41, 10, 32, + 32,101,108,115,101, 10, 32, 32, 9, 45, 45,112,114,105,110, + 116, 40, 34,116, 32,105,115, 32, 34, 46, 46,116,111,115,116, + 114,105,110,103, 40,116, 41, 46, 46, 34, 44, 32,112,116,114, + 32,105,115, 32, 34, 46, 46,116,111,115,116,114,105,110,103, + 40,115,101,108,102, 46,112,116,114, 41, 41, 10, 32, 32, 9, + 105,102, 32,116, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32, 97,110,100, 32,115,116,114,105,110,103, 46,102,105, + 110,100, 40,115,101,108,102, 46,112,116,114, 44, 32, 34, 37, + 42, 34, 41, 32,116,104,101,110, 10, 32, 32, 9, 9,116, 32, + 61, 32, 39,117,115,101,114,100, 97,116, 97, 39, 10, 32, 32, + 9,101,110,100, 10, 9,105,102, 32,110,111,116, 32,116, 32, + 97,110,100, 32,112,116,114, 61, 61, 39, 39, 32,116,104,101, + 110, 32,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116, + 112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 42, 39, 41, + 32,101,110,100, 10, 9,108,105,110,101, 32, 61, 32, 99,111, + 110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44, + 39, 40, 40, 39, 44,115,101,108,102, 46,109,111,100, 44,116, + 121,112,101, 41, 10, 9,105,102, 32,110,111,116, 32,116, 32, + 116,104,101,110, 10, 9, 9,108,105,110,101, 32, 61, 32, 99, + 111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, + 44, 39, 42, 39, 41, 10, 9,101,110,100, 10, 9,108,105,110, + 101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, + 40,108,105,110,101, 44, 39, 41, 32, 39, 41, 10, 9,105,102, + 32,105,115,101,110,117,109, 40,110, 99,116,121,112,101, 41, + 32,116,104,101,110, 10, 9, 9,108,105,110,101, 32, 61, 32, + 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110, + 101, 44, 39, 40,105,110,116, 41, 32, 39, 41, 10, 9,101,110, + 100, 10, 9,108,111, 99, 97,108, 32,100,101,102, 32, 61, 32, + 48, 10, 9,105,102, 32,115,101,108,102, 46,100,101,102, 32, + 126, 61, 32, 39, 39, 32,116,104,101,110, 10, 9, 9,100,101, + 102, 32, 61, 32,115,101,108,102, 46,100,101,102, 10, 9, 9, + 105,102, 32, 40,112,116,114, 32, 61, 61, 32, 39, 39, 32,111, + 114, 32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, + 38, 39, 41, 32, 97,110,100, 32,110,111,116, 32,116, 32,116, + 104,101,110, 10, 9, 9, 9,100,101,102, 32, 61, 32, 34, 40, + 118,111,105,100, 42, 41, 38, 40, 99,111,110,115,116, 32, 34, + 46, 46,116,121,112,101, 46, 46, 34, 41, 34, 46, 46,100,101, + 102, 10, 9, 9,101,110,100, 10, 9,101,110,100, 10, 9,105, + 102, 32,116, 32,116,104,101,110, 10, 9, 9,108,105,110,101, + 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40, + 108,105,110,101, 44, 39,116,111,108,117, 97, 95,116,111, 39, + 46, 46,116, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 39, + 44,110, 97,114,103, 44, 39, 44, 39, 44,100,101,102, 44, 39, + 41, 41, 59, 39, 41, 10, 9,101,108,115,101, 10, 9, 9,108, + 111, 99, 97,108, 32,116,111, 95,102,117,110, 99, 32, 61, 32, + 103,101,116, 95,116,111, 95,102,117,110, 99,116,105,111,110, + 40,116,121,112,101, 41, 10, 9, 9,108,105,110,101, 32, 61, + 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105, + 110,101, 44,116,111, 95,102,117,110, 99, 46, 46, 39, 40,116, + 111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, + 44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10, 9, + 101,110,100, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, + 9,114,101,116,117,114,110, 32,108,105,110,101, 10,101,110, + 100, 10, 10, 45, 45, 32, 68,101, 99,108, 97,114,101, 32,118, + 97,114,105, 97, 98,108,101, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116, + 105,111,110, 58,100,101, 99,108, 97,114,101, 32, 40,110, 97, + 114,103, 41, 10, 32,105,102, 32,115,101,108,102, 46,100,105, + 109, 32,126, 61, 32, 39, 39, 32, 97,110,100, 32,116,111,110, + 117,109, 98,101,114, 40,115,101,108,102, 46,100,105,109, 41, + 61, 61,110,105,108, 32,116,104,101,110, 10, 9, 32,111,117, + 116,112,117,116, 40, 39, 35,105,102,100,101,102, 32, 95, 95, + 99,112,108,117,115,112,108,117,115, 92,110, 39, 41, 10, 9, + 9,111,117,116,112,117,116, 40,115,101,108,102, 58, 98,117, + 105,108,100,100,101, 99,108, 97,114, 97,116,105,111,110, 40, + 110, 97,114,103, 44,116,114,117,101, 41, 41, 10, 9, 9,111, + 117,116,112,117,116, 40, 39, 35,101,108,115,101, 92,110, 39, + 41, 10, 9, 9,111,117,116,112,117,116, 40,115,101,108,102, + 58, 98,117,105,108,100,100,101, 99,108, 97,114, 97,116,105, + 111,110, 40,110, 97,114,103, 44,102, 97,108,115,101, 41, 41, + 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,101,110,100, + 105,102, 92,110, 39, 41, 10, 9,101,108,115,101, 10, 9, 9, + 111,117,116,112,117,116, 40,115,101,108,102, 58, 98,117,105, + 108,100,100,101, 99,108, 97,114, 97,116,105,111,110, 40,110, + 97,114,103, 44,102, 97,108,115,101, 41, 41, 10, 9,101,110, + 100, 10,101,110,100, 10, 10, 45, 45, 32, 71,101,116, 32,112, + 97,114, 97,109,101,116,101,114, 32,118, 97,108,117,101, 10, + 102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68, + 101, 99,108, 97,114, 97,116,105,111,110, 58,103,101,116, 97, + 114,114, 97,121, 32, 40,110, 97,114,103, 41, 10, 32,105,102, + 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, + 32,116,104,101,110, 10, 9, 32,108,111, 99, 97,108, 32,116, + 121,112,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, + 46,116,121,112,101, 44, 39, 99,111,110,115,116, 32, 39, 44, + 39, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32,123, 39, 41, 10, 9, 32,111,117,116,112,117,116, 40, 39, + 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, + 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, 32, 32,108,111, + 99, 97,108, 32,100,101,102, 59, 32,105,102, 32,115,101,108, + 102, 46,100,101,102,126, 61, 39, 39, 32,116,104,101,110, 32, + 100,101,102, 61, 49, 32,101,108,115,101, 32,100,101,102, 61, + 48, 32,101,110,100, 10, 9, 9,108,111, 99, 97,108, 32,116, + 32, 61, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, + 41, 10, 9, 9,105,102, 32, 40,116, 41, 32,116,104,101,110, + 10, 9, 9, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32, 32,105,102, 32, 40, 33,116,111,108,117, 97, 95,105,115, + 39, 46, 46,116, 46, 46, 39, 97,114,114, 97,121, 40,116,111, + 108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44, + 39, 44,115,101,108,102, 46,100,105,109, 44, 39, 44, 39, 44, + 100,101,102, 44, 39, 44, 38,116,111,108,117, 97, 95,101,114, + 114, 41, 41, 39, 41, 10, 9, 9,101,108,115,101, 10, 9, 9, + 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,105, + 102, 32, 40, 33,116,111,108,117, 97, 95,105,115,117,115,101, + 114,116,121,112,101, 97,114,114, 97,121, 40,116,111,108,117, + 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44, 34, 39, + 44,116,121,112,101, 44, 39, 34, 44, 39, 44,115,101,108,102, + 46,100,105,109, 44, 39, 44, 39, 44,100,101,102, 44, 39, 44, + 38,116,111,108,117, 97, 95,101,114,114, 41, 41, 39, 41, 10, + 9, 9,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, + 39, 32, 32, 32, 32,103,111,116,111, 32,116,111,108,117, 97, + 95,108,101,114,114,111,114, 59, 39, 41, 10, 32, 32,111,117, + 116,112,117,116, 40, 39, 32, 32, 32,101,108,115,101, 92,110, + 39, 41, 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,101, + 110,100,105,102, 92,110, 39, 41, 10, 32, 32,111,117,116,112, + 117,116, 40, 39, 32, 32, 32,123, 39, 41, 10, 32, 32,111,117, + 116,112,117,116, 40, 39, 32, 32, 32, 32,105,110,116, 32,105, + 59, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32, 32, 32,102,111,114, 40,105, 61, 48, 59, 32,105, 60, 39, + 46, 46,115,101,108,102, 46,100,105,109, 46, 46, 39, 59,105, + 43, 43, 41, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,116, + 32, 61, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, + 41, 10, 32, 32,108,111, 99, 97,108, 32,112,116,114, 32, 61, + 32, 39, 39, 10, 32, 32,105,102, 32,115,101,108,102, 46,112, + 116,114,126, 61, 39, 39, 32,116,104,101,110, 32,112,116,114, + 32, 61, 32, 39, 42, 39, 32,101,110,100, 10, 32, 32,111,117, + 116,112,117,116, 40, 39, 32, 32, 32, 39, 44,115,101,108,102, + 46,110, 97,109,101, 46, 46, 39, 91,105, 93, 32, 61, 32, 39, + 41, 10, 32, 32,105,102, 32,110,111,116, 32,116, 32, 97,110, + 100, 32,112,116,114, 61, 61, 39, 39, 32,116,104,101,110, 32, + 111,117,116,112,117,116, 40, 39, 42, 39, 41, 32,101,110,100, + 10, 32, 32,111,117,116,112,117,116, 40, 39, 40, 40, 39, 44, + 116,121,112,101, 41, 10, 32, 32,105,102, 32,110,111,116, 32, + 116, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117, + 116, 40, 39, 42, 39, 41, 10, 32, 32,101,110,100, 10, 32, 32, + 111,117,116,112,117,116, 40, 39, 41, 32, 39, 41, 10, 32, 32, + 108,111, 99, 97,108, 32,100,101,102, 32, 61, 32, 48, 10, 32, + 32,105,102, 32,115,101,108,102, 46,100,101,102, 32,126, 61, + 32, 39, 39, 32,116,104,101,110, 32,100,101,102, 32, 61, 32, + 115,101,108,102, 46,100,101,102, 32,101,110,100, 10, 32, 32, + 105,102, 32,116, 32,116,104,101,110, 10, 32, 32, 32,111,117, + 116,112,117,116, 40, 39,116,111,108,117, 97, 95,116,111,102, + 105,101,108,100, 39, 46, 46,116, 46, 46, 39, 40,116,111,108, + 117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,105, + 43, 49, 44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, + 10, 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,112, + 117,116, 40, 39,116,111,108,117, 97, 95,116,111,102,105,101, + 108,100,117,115,101,114,116,121,112,101, 40,116,111,108,117, + 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,105, 43, + 49, 44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10, + 32, 32,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, + 39, 32, 32, 32,125, 39, 41, 10, 32, 32,111,117,116,112,117, + 116, 40, 39, 32, 32,125, 39, 41, 10, 32,101,110,100, 10,101, + 110,100, 10, 10, 45, 45, 32, 71,101,116, 32,112, 97,114, 97, + 109,101,116,101,114, 32,118, 97,108,117,101, 10,102,117,110, + 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108, + 97,114, 97,116,105,111,110, 58,115,101,116, 97,114,114, 97, + 121, 32, 40,110, 97,114,103, 41, 10, 32,105,102, 32,110,111, + 116, 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46, + 116,121,112,101, 44, 39, 99,111,110,115,116, 37,115, 43, 39, + 41, 32, 97,110,100, 32,115,101,108,102, 46,100,105,109, 32, + 126, 61, 32, 39, 39, 32,116,104,101,110, 10, 9, 32,108,111, + 99, 97,108, 32,116,121,112,101, 32, 61, 32,103,115,117, 98, + 40,115,101,108,102, 46,116,121,112,101, 44, 39, 99,111,110, + 115,116, 32, 39, 44, 39, 39, 41, 10, 32, 32,111,117,116,112, + 117,116, 40, 39, 32, 32,123, 39, 41, 10, 32, 32,111,117,116, + 112,117,116, 40, 39, 32, 32, 32,105,110,116, 32,105, 59, 39, + 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, + 102,111,114, 40,105, 61, 48, 59, 32,105, 60, 39, 46, 46,115, + 101,108,102, 46,100,105,109, 46, 46, 39, 59,105, 43, 43, 41, + 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,116, 44, 99,116, + 32, 61, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, + 41, 10, 32, 32,105,102, 32,116, 32,116,104,101,110, 10, 32, + 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,116, + 111,108,117, 97, 95,112,117,115,104,102,105,101,108,100, 39, + 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, + 39, 44,110, 97,114,103, 44, 39, 44,105, 43, 49, 44, 40, 39, + 44, 99,116, 44, 39, 41, 39, 44,115,101,108,102, 46,110, 97, + 109,101, 44, 39, 91,105, 93, 41, 59, 39, 41, 10, 32, 32,101, + 108,115,101, 10, 32, 32, 32,105,102, 32,115,101,108,102, 46, + 112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, + 32,123, 39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117, + 116, 40, 39, 35,105,102,100,101,102, 32, 95, 95, 99,112,108, + 117,115,112,108,117,115, 92,110, 39, 41, 10, 32, 32, 32, 32, + 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,118,111, + 105,100, 42, 32,116,111,108,117, 97, 95,111, 98,106, 32, 61, + 32, 77,116,111,108,117, 97, 95,110,101,119, 40, 40, 39, 44, + 116,121,112,101, 44, 39, 41, 40, 39, 44,115,101,108,102, 46, + 110, 97,109,101, 44, 39, 91,105, 93, 41, 41, 59, 39, 41, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, + 32, 32,116,111,108,117, 97, 95,112,117,115,104,102,105,101, + 108,100,117,115,101,114,116,121,112,101, 95, 97,110,100, 95, + 116, 97,107,101,111,119,110,101,114,115,104,105,112, 40,116, + 111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, + 44,105, 43, 49, 44,116,111,108,117, 97, 95,111, 98,106, 44, + 34, 39, 44,116,121,112,101, 44, 39, 34, 41, 59, 39, 41, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 35,101, + 108,115,101, 92,110, 39, 41, 10, 32, 32, 32, 32, 32,111,117, + 116,112,117,116, 40, 39, 32, 32, 32, 32,118,111,105,100, 42, + 32,116,111,108,117, 97, 95,111, 98,106, 32, 61, 32,116,111, + 108,117, 97, 95, 99,111,112,121, 40,116,111,108,117, 97, 95, + 83, 44, 40,118,111,105,100, 42, 41, 38, 39, 44,115,101,108, + 102, 46,110, 97,109,101, 44, 39, 91,105, 93, 44,115,105,122, + 101,111,102, 40, 39, 44,116,121,112,101, 44, 39, 41, 41, 59, + 39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, + 39, 32, 32, 32, 32,116,111,108,117, 97, 95,112,117,115,104, + 102,105,101,108,100,117,115,101,114,116,121,112,101, 40,116, + 111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, + 44,105, 43, 49, 44,116,111,108,117, 97, 95,111, 98,106, 44, + 34, 39, 44,116,121,112,101, 44, 39, 34, 41, 59, 39, 41, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 35,101, + 110,100,105,102, 92,110, 39, 41, 10, 32, 32, 32, 32, 32,111, + 117,116,112,117,116, 40, 39, 32, 32, 32,125, 39, 41, 10, 32, + 32, 32,101,108,115,101, 10, 32, 32, 32, 32,111,117,116,112, + 117,116, 40, 39, 32, 32, 32,116,111,108,117, 97, 95,112,117, + 115,104,102,105,101,108,100,117,115,101,114,116,121,112,101, + 40,116,111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, + 44, 39, 44,105, 43, 49, 44, 40,118,111,105,100, 42, 41, 39, + 44,115,101,108,102, 46,110, 97,109,101, 44, 39, 91,105, 93, + 44, 34, 39, 44,116,121,112,101, 44, 39, 34, 41, 59, 39, 41, + 10, 32, 32, 32,101,110,100, 10, 32, 32,101,110,100, 10, 32, + 32,111,117,116,112,117,116, 40, 39, 32, 32,125, 39, 41, 10, + 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 70,114, + 101,101, 32,100,121,110, 97,109,105, 99, 97,108,108,121, 32, + 97,108,108,111, 99, 97,116,101,100, 32, 97,114,114, 97,121, + 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, + 68,101, 99,108, 97,114, 97,116,105,111,110, 58,102,114,101, + 101, 97,114,114, 97,121, 32, 40, 41, 10, 32,105,102, 32,115, + 101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32, 97, + 110,100, 32,116,111,110,117,109, 98,101,114, 40,115,101,108, + 102, 46,100,105,109, 41, 61, 61,110,105,108, 32,116,104,101, + 110, 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,105,102, + 100,101,102, 32, 95, 95, 99,112,108,117,115,112,108,117,115, + 92,110, 39, 41, 10, 9, 9,111,117,116,112,117,116, 40, 39, + 32, 32, 77,116,111,108,117, 97, 95,100,101,108,101,116,101, + 95,100,105,109, 40, 39, 44,115,101,108,102, 46,110, 97,109, + 101, 44, 39, 41, 59, 39, 41, 10, 9, 32,111,117,116,112,117, + 116, 40, 39, 35,101,108,115,101, 92,110, 39, 41, 10, 32, 32, + 111,117,116,112,117,116, 40, 39, 32, 32,102,114,101,101, 40, + 39, 44,115,101,108,102, 46,110, 97,109,101, 44, 39, 41, 59, + 39, 41, 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,101, + 110,100,105,102, 92,110, 39, 41, 10, 32,101,110,100, 10,101, + 110,100, 10, 10, 45, 45, 32, 80, 97,115,115, 32,112, 97,114, + 97,109,101,116,101,114, 10,102,117,110, 99,116,105,111,110, + 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105, + 111,110, 58,112, 97,115,115,112, 97,114, 32, 40, 41, 10, 32, + 105,102, 32,115,101,108,102, 46,112,116,114, 61, 61, 39, 38, + 39, 32, 97,110,100, 32,110,111,116, 32,105,115, 98, 97,115, + 105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 32,116, + 104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 42, + 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10, 32, + 101,108,115,101,105,102, 32,115,101,108,102, 46,114,101,116, + 61, 61, 39, 42, 39, 32,116,104,101,110, 10, 32, 32,111,117, + 116,112,117,116, 40, 39, 38, 39, 46, 46,115,101,108,102, 46, + 110, 97,109,101, 41, 10, 32,101,108,115,101, 10, 32, 32,111, + 117,116,112,117,116, 40,115,101,108,102, 46,110, 97,109,101, + 41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, + 82,101,116,117,114,110, 32,112, 97,114, 97,109,101,116,101, + 114, 32,118, 97,108,117,101, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116, + 105,111,110, 58,114,101,116,118, 97,108,117,101, 32, 40, 41, + 10, 32,105,102, 32,115,101,108,102, 46,114,101,116, 32,126, + 61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,108,111, 99, + 97,108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115, + 105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 10, 32, + 32,105,102, 32,116, 32, 97,110,100, 32,116,126, 61, 39, 39, + 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, + 40, 39, 32, 32, 32,116,111,108,117, 97, 95,112,117,115,104, + 39, 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, + 44, 40, 39, 44, 99,116, 44, 39, 41, 39, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 39, 41, 59, 39, 41, 10, 32, + 32,101,108,115,101, 10, 32, 32, 32,108,111, 99, 97,108, 32, + 112,117,115,104, 95,102,117,110, 99, 32, 61, 32,103,101,116, + 95,112,117,115,104, 95,102,117,110, 99,116,105,111,110, 40, + 115,101,108,102, 46,116,121,112,101, 41, 10, 32, 32, 32,111, + 117,116,112,117,116, 40, 39, 32, 32, 32, 39, 44,112,117,115, + 104, 95,102,117,110, 99, 44, 39, 40,116,111,108,117, 97, 95, + 83, 44, 40,118,111,105,100, 42, 41, 39, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 39, 44, 34, 39, 44,115,101, + 108,102, 46,116,121,112,101, 44, 39, 34, 41, 59, 39, 41, 10, + 32, 32,101,110,100, 10, 32, 32,114,101,116,117,114,110, 32, + 49, 10, 32,101,110,100, 10, 32,114,101,116,117,114,110, 32, + 48, 10,101,110,100, 10, 10, 45, 45, 32, 73,110,116,101,114, + 110, 97,108, 32, 99,111,110,115,116,114,117, 99,116,111,114, + 10,102,117,110, 99,116,105,111,110, 32, 95, 68,101, 99,108, + 97,114, 97,116,105,111,110, 32, 40,116, 41, 10, 10, 32,115, + 101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99, + 108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, + 41, 10, 32,116, 58, 98,117,105,108,100,110, 97,109,101,115, + 40, 41, 10, 32,116, 58, 99,104,101, 99,107,110, 97,109,101, + 40, 41, 10, 32,116, 58, 99,104,101, 99,107,116,121,112,101, + 40, 41, 10, 32,108,111, 99, 97,108, 32,102,116, 32, 61, 32, + 102,105,110,100,116,121,112,101, 40,116, 46,116,121,112,101, + 41, 32,111,114, 32,116, 46,116,121,112,101, 10, 32,105,102, + 32,110,111,116, 32,105,115,101,110,117,109, 40,102,116, 41, + 32,116,104,101,110, 10, 9,116, 46,109,111,100, 44, 32,116, + 46,116,121,112,101, 32, 61, 32, 97,112,112,108,121,116,121, + 112,101,100,101,102, 40,116, 46,109,111,100, 44, 32,102,116, + 41, 10, 32,101,110,100, 10, 10, 32,105,102, 32,116, 46,107, + 105,110,100, 61, 61, 34,118, 97,114, 34, 32, 97,110,100, 32, + 40,115,116,114,105,110,103, 46,102,105,110,100, 40,116, 46, + 109,111,100, 44, 32, 34,116,111,108,117, 97, 95,112,114,111, + 112,101,114,116,121, 37,115, 34, 41, 32,111,114, 32,115,116, + 114,105,110,103, 46,102,105,110,100, 40,116, 46,109,111,100, + 44, 32, 34,116,111,108,117, 97, 95,112,114,111,112,101,114, + 116,121, 36, 34, 41, 41, 32,116,104,101,110, 10, 32, 9,116, + 46,109,111,100, 32, 61, 32,115,116,114,105,110,103, 46,103, + 115,117, 98, 40,116, 46,109,111,100, 44, 32, 34,116,111,108, + 117, 97, 95,112,114,111,112,101,114,116,121, 34, 44, 32, 34, + 116,111,108,117, 97, 95,112,114,111,112,101,114,116,121, 95, + 95, 34, 46, 46,103,101,116, 95,112,114,111,112,101,114,116, + 121, 95,116,121,112,101, 40, 41, 41, 10, 32,101,110,100, 10, + 10, 32,114,101,116,117,114,110, 32,116, 10,101,110,100, 10, + 10, 45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, + 10, 45, 45, 32, 69,120,112,101, 99,116,115, 32,116,104,101, + 32,115,116,114,105,110,103, 32,100,101, 99,108, 97,114, 97, + 116,105,111,110, 46, 10, 45, 45, 32, 84,104,101, 32,107,105, + 110,100, 32,111,102, 32,100,101, 99,108, 97,114, 97,116,105, + 111,110, 32, 99, 97,110, 32, 98,101, 32, 34,118, 97,114, 34, + 32,111,114, 32, 34,102,117,110, 99, 34, 46, 10,102,117,110, + 99,116,105,111,110, 32, 68,101, 99,108, 97,114, 97,116,105, + 111,110, 32, 40,115, 44,107,105,110,100, 44,105,115, 95,112, + 97,114, 97,109,101,116,101,114, 41, 10, 10, 32, 45, 45, 32, + 101,108,105,109,105,110, 97,116,101, 32,115,112, 97, 99,101, + 115, 32,105,102, 32,100,101,102, 97,117,108,116, 32,118, 97, + 108,117,101, 32,105,115, 32,112,114,111,118,105,100,101,100, + 10, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44, 34, 37, + 115, 42, 61, 37,115, 42, 34, 44, 34, 61, 34, 41, 10, 32,115, + 32, 61, 32,103,115,117, 98, 40,115, 44, 32, 34, 37,115, 42, + 60, 34, 44, 32, 34, 60, 34, 41, 10, 10, 32,108,111, 99, 97, + 108, 32,100,101,102, 98, 44,116,109,112,100,101,102, 10, 32, + 100,101,102, 98, 44, 95, 44,116,109,112,100,101,102, 32, 61, + 32,115,116,114,105,110,103, 46,102,105,110,100, 40,115, 44, + 32, 34, 40, 61, 46, 42, 41, 36, 34, 41, 10, 32,105,102, 32, + 100,101,102, 98, 32,116,104,101,110, 10, 32, 9,115, 32, 61, + 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44, + 32, 34, 61, 46, 42, 36, 34, 44, 32, 34, 34, 41, 10, 32,101, + 108,115,101, 10, 32, 9,116,109,112,100,101,102, 32, 61, 32, + 39, 39, 10, 32,101,110,100, 10, 32,105,102, 32,107,105,110, + 100, 32, 61, 61, 32, 34,118, 97,114, 34, 32,116,104,101,110, + 10, 32, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, + 32,102,111,114,109, 58, 32,118,111,105,100, 10, 32, 32,105, + 102, 32,115, 32, 61, 61, 32, 39, 39, 32,111,114, 32,115, 32, + 61, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10, + 32, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108, + 97,114, 97,116,105,111,110,123,116,121,112,101, 32, 61, 32, + 39,118,111,105,100, 39, 44, 32,107,105,110,100, 32, 61, 32, + 107,105,110,100, 44, 32,105,115, 95,112, 97,114, 97,109,101, + 116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101, + 116,101,114,125, 10, 32, 32,101,110,100, 10, 32,101,110,100, + 10, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, + 32,102,111,114,109, 58, 32,109,111,100, 32,116,121,112,101, + 42, 38, 32,110, 97,109,101, 10, 32,108,111, 99, 97,108, 32, + 116, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107, + 101,110,115, 40,115, 44, 39, 37, 42, 37,115, 42, 38, 39, 41, + 10, 32,105,102, 32,116, 46,110, 32, 61, 61, 32, 50, 32,116, + 104,101,110, 10, 32, 32,105,102, 32,107,105,110,100, 32, 61, + 61, 32, 39,102,117,110, 99, 39, 32,116,104,101,110, 10, 32, + 32, 32,101,114,114,111,114, 40, 34, 35,105,110,118, 97,108, + 105,100, 32,102,117,110, 99,116,105,111,110, 32,114,101,116, + 117,114,110, 32,116,121,112,101, 58, 32, 34, 46, 46,115, 41, + 10, 32, 32,101,110,100, 10, 32, 32, 45, 45,108,111, 99, 97, + 108, 32,109, 32, 61, 32,115,112,108,105,116, 40,116, 91, 49, + 93, 44, 39, 37,115, 37,115, 42, 39, 41, 10, 32, 32,108,111, + 99, 97,108, 32,109, 32, 61, 32,115,112,108,105,116, 95, 99, + 95,116,111,107,101,110,115, 40,116, 91, 49, 93, 44, 39, 37, + 115, 43, 39, 41, 10, 32, 32,114,101,116,117,114,110, 32, 95, + 68,101, 99,108, 97,114, 97,116,105,111,110,123, 10, 32, 32, + 32,110, 97,109,101, 32, 61, 32,116, 91, 50, 93, 46, 46,116, + 109,112,100,101,102, 44, 10, 32, 32, 32,112,116,114, 32, 61, + 32, 39, 42, 39, 44, 10, 32, 32, 32,114,101,116, 32, 61, 32, + 39, 38, 39, 44, 10, 32, 32, 32, 45, 45,116,121,112,101, 32, + 61, 32,114,101, 98,117,105,108,100, 95,116,101,109,112,108, + 97,116,101, 40,109, 91,109, 46,110, 93, 44, 32,116, 98, 44, + 32,116,105,109,112,108, 41, 44, 10, 32, 32, 32,116,121,112, + 101, 32, 61, 32,109, 91,109, 46,110, 93, 44, 10, 32, 32, 32, + 109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,109, 44, + 49, 44,109, 46,110, 45, 49, 41, 44, 10, 32, 32, 32,105,115, + 95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,115, + 95,112, 97,114, 97,109,101,116,101,114, 44, 10, 32, 32, 32, + 107,105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32,125, + 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99, + 107, 32,116,104,101, 32,102,111,114,109, 58, 32,109,111,100, + 32,116,121,112,101, 42, 42, 32,110, 97,109,101, 10, 32,116, + 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101, + 110,115, 40,115, 44, 39, 37, 42, 37,115, 42, 37, 42, 39, 41, + 10, 32,105,102, 32,116, 46,110, 32, 61, 61, 32, 50, 32,116, + 104,101,110, 10, 32, 32,105,102, 32,107,105,110,100, 32, 61, + 61, 32, 39,102,117,110, 99, 39, 32,116,104,101,110, 10, 32, + 32, 32,101,114,114,111,114, 40, 34, 35,105,110,118, 97,108, + 105,100, 32,102,117,110, 99,116,105,111,110, 32,114,101,116, + 117,114,110, 32,116,121,112,101, 58, 32, 34, 46, 46,115, 41, + 10, 32, 32,101,110,100, 10, 32, 32, 45, 45,108,111, 99, 97, + 108, 32,109, 32, 61, 32,115,112,108,105,116, 40,116, 91, 49, + 93, 44, 39, 37,115, 37,115, 42, 39, 41, 10, 32, 32,108,111, + 99, 97,108, 32,109, 32, 61, 32,115,112,108,105,116, 95, 99, + 95,116,111,107,101,110,115, 40,116, 91, 49, 93, 44, 39, 37, + 115, 43, 39, 41, 10, 32, 32,114,101,116,117,114,110, 32, 95, + 68,101, 99,108, 97,114, 97,116,105,111,110,123, 10, 32, 32, + 32,110, 97,109,101, 32, 61, 32,116, 91, 50, 93, 46, 46,116, + 109,112,100,101,102, 44, 10, 32, 32, 32,112,116,114, 32, 61, + 32, 39, 42, 39, 44, 10, 32, 32, 32,114,101,116, 32, 61, 32, + 39, 42, 39, 44, 10, 32, 32, 32, 45, 45,116,121,112,101, 32, + 61, 32,114,101, 98,117,105,108,100, 95,116,101,109,112,108, + 97,116,101, 40,109, 91,109, 46,110, 93, 44, 32,116, 98, 44, + 32,116,105,109,112,108, 41, 44, 10, 32, 32, 32,116,121,112, + 101, 32, 61, 32,109, 91,109, 46,110, 93, 44, 10, 32, 32, 32, + 109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,109, 44, + 49, 44,109, 46,110, 45, 49, 41, 44, 10, 32, 32, 32,105,115, + 95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,115, + 95,112, 97,114, 97,109,101,116,101,114, 44, 10, 32, 32, 32, + 107,105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32,125, + 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99, + 107, 32,116,104,101, 32,102,111,114,109, 58, 32,109,111,100, + 32,116,121,112,101, 38, 32,110, 97,109,101, 10, 32,116, 32, + 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110, + 115, 40,115, 44, 39, 38, 39, 41, 10, 32,105,102, 32,116, 46, + 110, 32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32, 45, + 45,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112,108,105, + 116, 40,116, 91, 49, 93, 44, 39, 37,115, 37,115, 42, 39, 41, + 10, 32, 32,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112, + 108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,116, 91, + 49, 93, 44, 39, 37,115, 43, 39, 41, 10, 32, 32,114,101,116, + 117,114,110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111, + 110,123, 10, 32, 32, 32,110, 97,109,101, 32, 61, 32,116, 91, + 50, 93, 46, 46,116,109,112,100,101,102, 44, 10, 32, 32, 32, + 112,116,114, 32, 61, 32, 39, 38, 39, 44, 10, 32, 32, 32, 45, + 45,116,121,112,101, 32, 61, 32,114,101, 98,117,105,108,100, + 95,116,101,109,112,108, 97,116,101, 40,109, 91,109, 46,110, + 93, 44, 32,116, 98, 44, 32,116,105,109,112,108, 41, 44, 10, + 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109, 46,110, + 93, 44, 10, 32, 32, 32,109,111,100, 32, 61, 32, 99,111,110, + 99, 97,116, 40,109, 44, 49, 44,109, 46,110, 45, 49, 41, 44, + 10, 32, 32, 32,105,115, 95,112, 97,114, 97,109,101,116,101, + 114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101,116,101, + 114, 44, 10, 32, 32, 32,107,105,110,100, 32, 61, 32,107,105, + 110,100, 10, 32, 32,125, 10, 32,101,110,100, 10, 10, 32, 45, + 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,102,111,114, + 109, 58, 32,109,111,100, 32,116,121,112,101, 42, 32,110, 97, + 109,101, 10, 32,108,111, 99, 97,108, 32,115, 49, 32, 61, 32, + 103,115,117, 98, 40,115, 44, 34, 40, 37, 98, 92, 91, 92, 93, + 41, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,110, 41, + 32,114,101,116,117,114,110, 32,103,115,117, 98, 40,110, 44, + 39, 37, 42, 39, 44, 39, 92, 49, 39, 41, 32,101,110,100, 41, + 10, 32,116, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116, + 111,107,101,110,115, 40,115, 49, 44, 39, 37, 42, 39, 41, 10, + 32,105,102, 32,116, 46,110, 32, 61, 61, 32, 50, 32,116,104, + 101,110, 10, 32, 32,116, 91, 50, 93, 32, 61, 32,103,115,117, + 98, 40,116, 91, 50, 93, 44, 39, 92, 49, 39, 44, 39, 37, 42, + 39, 41, 32, 45, 45, 32,114,101,115,116,111,114,101, 32, 42, + 32,105,110, 32,100,105,109,101,110,115,105,111,110, 32,101, + 120,112,114,101,115,115,105,111,110, 10, 32, 32, 45, 45,108, + 111, 99, 97,108, 32,109, 32, 61, 32,115,112,108,105,116, 40, + 116, 91, 49, 93, 44, 39, 37,115, 37,115, 42, 39, 41, 10, 32, + 32,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112,108,105, + 116, 95, 99, 95,116,111,107,101,110,115, 40,116, 91, 49, 93, + 44, 39, 37,115, 43, 39, 41, 10, 32, 32,114,101,116,117,114, + 110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,123, + 10, 32, 32, 32,110, 97,109,101, 32, 61, 32,116, 91, 50, 93, + 46, 46,116,109,112,100,101,102, 44, 10, 32, 32, 32,112,116, + 114, 32, 61, 32, 39, 42, 39, 44, 10, 32, 32, 32,116,121,112, + 101, 32, 61, 32,109, 91,109, 46,110, 93, 44, 10, 32, 32, 32, + 45, 45,116,121,112,101, 32, 61, 32,114,101, 98,117,105,108, + 100, 95,116,101,109,112,108, 97,116,101, 40,109, 91,109, 46, + 110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,108, 41, 44, + 10, 32, 32, 32,109,111,100, 32, 61, 32, 99,111,110, 99, 97, + 116, 40,109, 44, 49, 44,109, 46,110, 45, 49, 41, 32, 32, 32, + 44, 10, 32, 32, 32,105,115, 95,112, 97,114, 97,109,101,116, + 101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101,116, + 101,114, 44, 10, 32, 32, 32,107,105,110,100, 32, 61, 32,107, + 105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10, 10, 32, + 105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,118, 97,114, + 39, 32,116,104,101,110, 10, 32, 32, 45, 45, 32, 99,104,101, + 99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,109,111, + 100, 32,116,121,112,101, 32,110, 97,109,101, 10, 32, 32, 45, + 45,116, 32, 61, 32,115,112,108,105,116, 40,115, 44, 39, 37, + 115, 37,115, 42, 39, 41, 10, 32, 32,116, 32, 61, 32,115,112, + 108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44, + 39, 37,115, 43, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32, + 118, 10, 32, 32,105,102, 32,102,105,110,100,116,121,112,101, + 40,116, 91,116, 46,110, 93, 41, 32,116,104,101,110, 32,118, + 32, 61, 32, 99,114,101, 97,116,101, 95,118, 97,114,110, 97, + 109,101, 40, 41, 32,101,108,115,101, 32,118, 32, 61, 32,116, + 91,116, 46,110, 93, 59, 32,116, 46,110, 32, 61, 32,116, 46, + 110, 45, 49, 32,101,110,100, 10, 32, 32,114,101,116,117,114, + 110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,123, + 10, 32, 32, 32,110, 97,109,101, 32, 61, 32,118, 46, 46,116, + 109,112,100,101,102, 44, 10, 32, 32, 32, 45, 45,116,121,112, + 101, 32, 61, 32,114,101, 98,117,105,108,100, 95,116,101,109, + 112,108, 97,116,101, 40,116, 91,116, 46,110, 93, 44, 32,116, + 98, 44, 32,116,105,109,112,108, 41, 44, 10, 32, 32, 32,116, + 121,112,101, 32, 61, 32,116, 91,116, 46,110, 93, 44, 10, 32, + 32, 32,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40, + 116, 44, 49, 44,116, 46,110, 45, 49, 41, 44, 10, 32, 32, 32, + 105,115, 95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32, + 105,115, 95,112, 97,114, 97,109,101,116,101,114, 44, 10, 32, + 32, 32,107,105,110,100, 32, 61, 32,107,105,110,100, 10, 32, + 32,125, 10, 10, 32,101,108,115,101, 32, 45, 45, 32,107,105, + 110,100, 32, 61, 61, 32, 34,102,117,110, 99, 34, 10, 10, 32, + 32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,102, + 111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 32,110, + 97,109,101, 10, 32, 32, 45, 45,116, 32, 61, 32,115,112,108, + 105,116, 40,115, 44, 39, 37,115, 37,115, 42, 39, 41, 10, 32, + 32,116, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111, + 107,101,110,115, 40,115, 44, 39, 37,115, 43, 39, 41, 10, 32, + 32,108,111, 99, 97,108, 32,118, 32, 61, 32,116, 91,116, 46, + 110, 93, 32, 32, 45, 45, 32,108, 97,115,116, 32,119,111,114, + 100, 32,105,115, 32,116,104,101, 32,102,117,110, 99,116,105, + 111,110, 32,110, 97,109,101, 10, 32, 32,108,111, 99, 97,108, + 32,116,112, 44,109,100, 10, 32, 32,105,102, 32,116, 46,110, + 62, 49, 32,116,104,101,110, 10, 32, 32, 32,116,112, 32, 61, + 32,116, 91,116, 46,110, 45, 49, 93, 10, 32, 32, 32,109,100, + 32, 61, 32, 99,111,110, 99, 97,116, 40,116, 44, 49, 44,116, + 46,110, 45, 50, 41, 10, 32, 32,101,110,100, 10, 32, 32, 45, + 45,105,102, 32,116,112, 32,116,104,101,110, 32,116,112, 32, + 61, 32,114,101, 98,117,105,108,100, 95,116,101,109,112,108, + 97,116,101, 40,116,112, 44, 32,116, 98, 44, 32,116,105,109, + 112,108, 41, 32,101,110,100, 10, 32, 32,114,101,116,117,114, + 110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,123, + 10, 32, 32, 32,110, 97,109,101, 32, 61, 32,118, 44, 10, 32, + 32, 32,116,121,112,101, 32, 61, 32,116,112, 44, 10, 32, 32, + 32,109,111,100, 32, 61, 32,109,100, 44, 10, 32, 32, 32,105, + 115, 95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105, + 115, 95,112, 97,114, 97,109,101,116,101,114, 44, 10, 32, 32, + 32,107,105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32, + 125, 10, 32,101,110,100, 10, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/declaration.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,118, 97,114,105, 97, + 98,108,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114, + 105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, + 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, + 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, + 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73, + 100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99, + 111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102, + 116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32, + 114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, + 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32, + 105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116, + 119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104, + 101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, + 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105, + 115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97, + 117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98, + 108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111, + 118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99, + 101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, + 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99, + 101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105, + 102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, + 32, 86, 97,114,105, 97, 98,108,101, 32, 99,108, 97,115,115, + 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, + 97, 32,101,120,116,101,114,110, 32,118, 97,114,105, 97, 98, + 108,101, 32,111,114, 32, 97, 32,112,117, 98,108,105, 99, 32, + 109,101,109, 98,101,114, 32,111,102, 32, 97, 32, 99,108, 97, + 115,115, 46, 10, 45, 45, 32, 83,116,111,114,101,115, 32, 97, + 108,108, 32,102,105,101,108,100,115, 32,112,114,101,115,101, + 110,116, 32,105,110, 32, 97, 32,100,101, 99,108, 97,114, 97, + 116,105,111,110, 46, 10, 99,108, 97,115,115, 86, 97,114,105, + 97, 98,108,101, 32, 61, 32,123, 10, 32, 95,103,101,116, 32, + 61, 32,123,125, 44, 32, 32, 32, 45, 45, 32,109, 97,112,112, + 101,100, 32,103,101,116, 32,102,117,110, 99,116,105,111,110, + 115, 10, 32, 95,115,101,116, 32, 61, 32,123,125, 44, 32, 32, + 32, 45, 45, 32,109, 97,112,112,101,100, 32,115,101,116, 32, + 102,117,110, 99,116,105,111,110,115, 10,125, 10, 99,108, 97, + 115,115, 86, 97,114,105, 97, 98,108,101, 46, 95, 95,105,110, + 100,101,120, 32, 61, 32, 99,108, 97,115,115, 86, 97,114,105, + 97, 98,108,101, 10,115,101,116,109,101,116, 97,116, 97, 98, + 108,101, 40, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108, + 101, 44, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116, + 105,111,110, 41, 10, 10, 45, 45, 32, 80,114,105,110,116, 32, + 109,101,116,104,111,100, 10,102,117,110, 99,116,105,111,110, + 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 58, + 112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108, + 111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 86, 97,114,105, 97, 98,108,101,123, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115, + 101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, + 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114, + 105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97, + 109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, + 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,105,102, 32, + 115,101,108,102, 46,100,105,109, 32,116,104,101,110, 32,112, + 114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,100, + 105,109, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,100, + 105,109, 46, 46, 34, 39, 44, 34, 41, 32,101,110,100, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 100,101,102, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, + 46,100,101,102, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114, + 105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,114,101, + 116, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,114, + 101,116, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110, + 116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99, + 108,111,115,101, 41, 10,101,110,100, 10, 10, 45, 45, 32, 71, + 101,110,101,114, 97,116,101,115, 32, 67, 32,102,117,110, 99, + 116,105,111,110, 32,110, 97,109,101, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98, + 108,101, 58, 99,102,117,110, 99,110, 97,109,101, 32, 40,112, + 114,101,102,105,120, 41, 10, 32,108,111, 99, 97,108, 32,112, + 97,114,101,110,116, 32, 61, 32, 34, 34, 10, 32,108,111, 99, + 97,108, 32,117,110,115,105,103,110,101,100, 32, 61, 32, 34, + 34, 10, 32,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32, + 34, 34, 10, 10, 32,108,111, 99, 97,108, 32,112, 32, 61, 32, + 115,101,108,102, 58,105,110,109,111,100,117,108,101, 40, 41, + 32,111,114, 32,115,101,108,102, 58,105,110,110, 97,109,101, + 115,112, 97, 99,101, 40, 41, 32,111,114, 32,115,101,108,102, + 58,105,110, 99,108, 97,115,115, 40, 41, 10, 10, 32,105,102, + 32,112, 32,116,104,101,110, 10, 32, 9,105,102, 32,115,101, + 108,102, 46,112, 97,114,101,110,116, 46, 99,108, 97,115,115, + 116,121,112,101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, + 32,116,104,101,110, 10, 9, 9,112, 97,114,101,110,116, 32, + 61, 32, 34, 95, 34, 32, 46, 46, 32,115,101,108,102, 46,112, + 97,114,101,110,116, 46,116,121,112,101, 10, 9,101,108,115, + 101, 10, 9, 32, 32,112, 97,114,101,110,116, 32, 61, 32, 34, + 95, 34, 32, 46, 46, 32,112, 10, 9,101,110,100, 10, 32,101, + 110,100, 10, 10, 32,105,102, 32,115,116,114,102,105,110,100, + 40,115,101,108,102, 46,109,111,100, 44, 34, 40,117,110,115, + 105,103,110,101,100, 41, 34, 41, 32,116,104,101,110, 10, 32, + 32,117,110,115,105,103,110,101,100, 32, 61, 32, 34, 95,117, + 110,115,105,103,110,101,100, 34, 10, 32,101,110,100, 10, 10, + 32,105,102, 32,115,101,108,102, 46,112,116,114, 32, 61, 61, + 32, 34, 42, 34, 32,116,104,101,110, 32,112,116,114, 32, 61, + 32, 34, 95,112,116,114, 34, 10, 32,101,108,115,101,105,102, + 32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 34, 38, + 34, 32,116,104,101,110, 32,112,116,114, 32, 61, 32, 34, 95, + 114,101,102, 34, 10, 32,101,110,100, 10, 10, 32,108,111, 99, + 97,108, 32,110, 97,109,101, 32, 61, 32, 32,112,114,101,102, + 105,120, 32, 46, 46, 32,112, 97,114,101,110,116, 32, 46, 46, + 32,117,110,115,105,103,110,101,100, 32, 46, 46, 32, 34, 95, + 34, 32, 46, 46, 32,103,115,117, 98, 40,115,101,108,102, 46, + 108,110, 97,109,101, 32,111,114, 32,115,101,108,102, 46,110, + 97,109,101, 44, 34, 46, 42, 58, 58, 34, 44, 34, 34, 41, 32, + 46, 46, 32,112,116,114, 10, 10, 9,110, 97,109,101, 32, 61, + 32, 99,108,101, 97,110, 95,116,101,109,112,108, 97,116,101, + 40,110, 97,109,101, 41, 10, 32,114,101,116,117,114,110, 32, + 110, 97,109,101, 10, 10,101,110,100, 10, 10, 45, 45, 32, 99, + 104,101, 99,107, 32,105,102, 32,105,116, 32,105,115, 32, 97, + 32,118, 97,114,105, 97, 98,108,101, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98, + 108,101, 58,105,115,118, 97,114,105, 97, 98,108,101, 32, 40, + 41, 10, 32,114,101,116,117,114,110, 32,116,114,117,101, 10, + 101,110,100, 10, 10, 45, 45, 32,103,101,116, 32,118, 97,114, + 105, 97, 98,108,101, 32,118, 97,108,117,101, 10,102,117,110, + 99,116,105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, + 97, 98,108,101, 58,103,101,116,118, 97,108,117,101, 32, 40, + 99,108, 97,115,115, 44,115,116, 97,116,105, 99, 44, 32,112, + 114,111,112, 95,103,101,116, 41, 10, 10, 9,108,111, 99, 97, + 108, 32,110, 97,109,101, 10, 9,105,102, 32,112,114,111,112, + 95,103,101,116, 32,116,104,101,110, 10, 10, 9, 9,110, 97, + 109,101, 32, 61, 32,112,114,111,112, 95,103,101,116, 46, 46, + 34, 40, 41, 34, 10, 9,101,108,115,101, 10, 9, 9,110, 97, + 109,101, 32, 61, 32,115,101,108,102, 46,110, 97,109,101, 10, + 9,101,110,100, 10, 10, 9,105,102, 32, 99,108, 97,115,115, + 32, 97,110,100, 32,115,116, 97,116,105, 99, 32,116,104,101, + 110, 10, 9, 32,114,101,116,117,114,110, 32,115,101,108,102, + 46,112, 97,114,101,110,116, 46,116,121,112,101, 46, 46, 39, + 58, 58, 39, 46, 46,110, 97,109,101, 10, 9,101,108,115,101, + 105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10, 9, + 32,114,101,116,117,114,110, 32, 39,115,101,108,102, 45, 62, + 39, 46, 46,110, 97,109,101, 10, 9,101,108,115,101, 10, 9, + 32,114,101,116,117,114,110, 32,110, 97,109,101, 10, 9,101, + 110,100, 10,101,110,100, 10, 10, 45, 45, 32,103,101,116, 32, + 118, 97,114,105, 97, 98,108,101, 32,112,111,105,110,116,101, + 114, 32,118, 97,108,117,101, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, + 58,103,101,116,112,111,105,110,116,101,114,118, 97,108,117, + 101, 32, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, + 41, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, + 32,115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32, + 114,101,116,117,114,110, 32, 99,108, 97,115,115, 46, 46, 39, + 58, 58,112, 39, 10, 32,101,108,115,101,105,102, 32, 99,108, + 97,115,115, 32,116,104,101,110, 10, 32, 32,114,101,116,117, + 114,110, 32, 39,115,101,108,102, 45, 62,112, 39, 10, 32,101, + 108,115,101, 10, 32, 32,114,101,116,117,114,110, 32, 39,112, + 39, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, + 87,114,105,116,101, 32, 98,105,110,100,105,110,103, 32,102, + 117,110, 99,116,105,111,110,115, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108, + 101, 58,115,117,112, 99,111,100,101, 32, 40, 41, 10, 10, 32, + 108,111, 99, 97,108, 32, 99,108, 97,115,115, 32, 61, 32,115, + 101,108,102, 58,105,110, 99,108, 97,115,115, 40, 41, 10, 10, + 9,108,111, 99, 97,108, 32,112,114,111,112, 95,103,101,116, + 44,112,114,111,112, 95,115,101,116, 10, 9,105,102, 32,115, + 116,114,105,110,103, 46,102,105,110,100, 40,115,101,108,102, + 46,109,111,100, 44, 32, 39,116,111,108,117, 97, 95,112,114, + 111,112,101,114,116,121, 39, 41, 32,116,104,101,110, 10, 10, + 9, 9,108,111, 99, 97,108, 32, 95, 44, 95, 44,116,121,112, + 101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, + 40,115,101,108,102, 46,109,111,100, 44, 32, 34,116,111,108, + 117, 97, 95,112,114,111,112,101,114,116,121, 95, 95, 40, 91, + 94, 37,115, 93, 42, 41, 34, 41, 10, 9, 9,116,121,112,101, + 32, 61, 32,116,121,112,101, 32,111,114, 32, 34,100,101,102, + 97,117,108,116, 34, 10, 9, 9,112,114,111,112, 95,103,101, + 116, 44,112,114,111,112, 95,115,101,116, 32, 61, 32,103,101, + 116, 95,112,114,111,112,101,114,116,121, 95,109,101,116,104, + 111,100,115, 40,116,121,112,101, 44, 32,115,101,108,102, 46, + 110, 97,109,101, 41, 10, 9, 9,115,101,108,102, 46,109,111, + 100, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, + 40,115,101,108,102, 46,109,111,100, 44, 32, 34,116,111,108, + 117, 97, 95,112,114,111,112,101,114,116,121, 91, 94, 37,115, + 93, 42, 34, 44, 32, 34, 34, 41, 10, 9,101,110,100, 10, 10, + 32, 45, 45, 32,103,101,116, 32,102,117,110, 99,116,105,111, + 110, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 10, 32,105,102, 32, 99,108, 97,115,115, + 32,116,104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, + 34, 47, 42, 32,103,101,116, 32,102,117,110, 99,116,105,111, + 110, 58, 34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34, + 32,111,102, 32, 99,108, 97,115,115, 32, 34, 44, 99,108, 97, + 115,115, 44, 34, 32, 42, 47, 34, 41, 10, 32,101,108,115,101, + 10, 32, 32,111,117,116,112,117,116, 40, 34, 47, 42, 32,103, + 101,116, 32,102,117,110, 99,116,105,111,110, 58, 34, 44,115, + 101,108,102, 46,110, 97,109,101, 44, 34, 32, 42, 47, 34, 41, + 10, 32,101,110,100, 10, 32,115,101,108,102, 46, 99,103,101, + 116,110, 97,109,101, 32, 61, 32,115,101,108,102, 58, 99,102, + 117,110, 99,110, 97,109,101, 40, 34,116,111,108,117, 97, 95, + 103,101,116, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, + 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, + 73, 83, 65, 66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, + 99,103,101,116,110, 97,109,101, 41, 10, 32,111,117,116,112, + 117,116, 40, 34, 92,110,115,116, 97,116,105, 99, 32,105,110, + 116, 34, 44,115,101,108,102, 46, 99,103,101,116,110, 97,109, + 101, 44, 34, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32, + 116,111,108,117, 97, 95, 83, 41, 34, 41, 10, 32,111,117,116, + 112,117,116, 40, 34,123, 34, 41, 10, 10, 32, 45, 45, 32,100, + 101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32,105,102, + 32,116,104,101, 32, 99, 97,115,101, 10, 32,108,111, 99, 97, + 108, 32, 95, 44, 95, 44,115,116, 97,116,105, 99, 32, 61, 32, + 115,116,114,102,105,110,100, 40,115,101,108,102, 46,109,111, + 100, 44, 39, 94, 37,115, 42, 40,115,116, 97,116,105, 99, 41, + 39, 41, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110, + 100, 32,115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116, + 104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 39, 44,115,101,108,102, 46,112, 97,114,101,110,116, 46,116, + 121,112,101, 44, 39, 42, 39, 44, 39,115,101,108,102, 32, 61, + 32, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, 40, + 39, 44,115,101,108,102, 46,112, 97,114,101,110,116, 46,116, + 121,112,101, 44, 39, 42, 41, 32, 39, 41, 10, 32, 32,108,111, + 99, 97,108, 32,116,111, 95,102,117,110, 99, 32, 61, 32,103, + 101,116, 95,116,111, 95,102,117,110, 99,116,105,111,110, 40, + 115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112, + 101, 41, 10, 32, 32,111,117,116,112,117,116, 40,116,111, 95, + 102,117,110, 99, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, + 49, 44, 48, 41, 59, 39, 41, 10, 32,101,108,115,101,105,102, + 32,115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32, + 95, 44, 95, 44,115,101,108,102, 46,109,111,100, 32, 61, 32, + 115,116,114,102,105,110,100, 40,115,101,108,102, 46,109,111, + 100, 44, 39, 94, 37,115, 42,115,116, 97,116,105, 99, 37,115, + 37,115, 42, 40, 46, 42, 41, 39, 41, 10, 32,101,110,100, 10, + 10, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,115,101,108, + 102, 32,118, 97,108,117,101, 10, 32,105,102, 32, 99,108, 97, + 115,115, 32, 97,110,100, 32,115,116, 97,116,105, 99, 61, 61, + 110,105,108, 32,116,104,101,110, 10, 9, 32,111,117,116,112, + 117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, + 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, + 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,105,102, 32, + 40, 33,115,101,108,102, 41, 32,116,111,108,117, 97, 95,101, + 114,114,111,114, 40,116,111,108,117, 97, 95, 83, 44, 34,105, + 110,118, 97,108,105,100, 32, 92, 39,115,101,108,102, 92, 39, + 32,105,110, 32, 97, 99, 99,101,115,115,105,110,103, 32,118, + 97,114,105, 97, 98,108,101, 32, 92, 39, 39, 46, 46,115,101, + 108,102, 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44, 78, + 85, 76, 76, 41, 59, 39, 41, 59, 10, 9, 9,111,117,116,112, + 117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10, + 32,101,110,100, 10, 10, 32, 45, 45, 32,114,101,116,117,114, + 110, 32,118, 97,108,117,101, 10, 32,105,102, 32,115,116,114, + 105,110,103, 46,102,105,110,100, 40,115,101,108,102, 46,109, + 111,100, 44, 32, 39,116,111,108,117, 97, 95,105,110,104,101, + 114,105,116,115, 39, 41, 32,116,104,101,110, 10, 9,108,111, + 99, 97,108, 32,112,117,115,104, 95,102,117,110, 99, 32, 61, + 32,103,101,116, 95,112,117,115,104, 95,102,117,110, 99,116, + 105,111,110, 40,115,101,108,102, 46,116,121,112,101, 41, 10, + 32, 9,111,117,116,112,117,116, 40, 39, 35,105,102,100,101, + 102, 32, 95, 95, 99,112,108,117,115,112,108,117,115, 92,110, + 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, 32, 32, 39, + 44,112,117,115,104, 95,102,117,110, 99, 44, 39, 40,116,111, + 108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41,115,116, + 97,116,105, 99, 95, 99, 97,115,116, 60, 39, 46, 46,115,101, + 108,102, 46,116,121,112,101, 46, 46, 39, 42, 62, 40,115,101, + 108,102, 41, 44, 32, 34, 39, 44,115,101,108,102, 46,116,121, + 112,101, 44, 39, 34, 41, 59, 39, 41, 10, 9,111,117,116,112, + 117,116, 40, 39, 35,101,108,115,101, 92,110, 39, 41, 10, 9, + 111,117,116,112,117,116, 40, 39, 32, 32, 39, 44,112,117,115, + 104, 95,102,117,110, 99, 44, 39, 40,116,111,108,117, 97, 95, + 83, 44, 40,118,111,105,100, 42, 41, 40, 40, 39, 46, 46,115, + 101,108,102, 46,116,121,112,101, 46, 46, 39, 42, 41,115,101, + 108,102, 41, 44, 32, 34, 39, 44,115,101,108,102, 46,116,121, + 112,101, 44, 39, 34, 41, 59, 39, 41, 10, 9,111,117,116,112, + 117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10, + 32,101,108,115,101, 10, 9,108,111, 99, 97,108, 32,116, 44, + 99,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101, + 108,102, 46,116,121,112,101, 41, 10, 9,105,102, 32,116, 32, + 116,104,101,110, 10, 9, 9,111,117,116,112,117,116, 40, 39, + 32, 32,116,111,108,117, 97, 95,112,117,115,104, 39, 46, 46, + 116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39, + 44, 99,116, 44, 39, 41, 39, 46, 46,115,101,108,102, 58,103, + 101,116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115, + 116, 97,116,105, 99, 44,112,114,111,112, 95,103,101,116, 41, + 46, 46, 39, 41, 59, 39, 41, 10, 9,101,108,115,101, 10, 9, + 9,108,111, 99, 97,108, 32,112,117,115,104, 95,102,117,110, + 99, 32, 61, 32,103,101,116, 95,112,117,115,104, 95,102,117, + 110, 99,116,105,111,110, 40,115,101,108,102, 46,116,121,112, + 101, 41, 10, 9, 9,116, 32, 61, 32,115,101,108,102, 46,116, + 121,112,101, 10, 9, 9,105,102, 32,115,101,108,102, 46,112, + 116,114, 32, 61, 61, 32, 39, 38, 39, 32,111,114, 32,115,101, + 108,102, 46,112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104, + 101,110, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, + 32, 39, 44,112,117,115,104, 95,102,117,110, 99, 44, 39, 40, + 116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, + 38, 39, 46, 46,115,101,108,102, 58,103,101,116,118, 97,108, + 117,101, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, + 44,112,114,111,112, 95,103,101,116, 41, 46, 46, 39, 44, 34, + 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 9, 9,101,108, + 115,101, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, + 32, 39, 44,112,117,115,104, 95,102,117,110, 99, 44, 39, 40, + 116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, + 39, 46, 46,115,101,108,102, 58,103,101,116,118, 97,108,117, + 101, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, 44, + 112,114,111,112, 95,103,101,116, 41, 46, 46, 39, 44, 34, 39, + 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 9, 9,101,110,100, + 10, 9,101,110,100, 10, 32,101,110,100, 10, 32,111,117,116, + 112,117,116, 40, 39, 32,114,101,116,117,114,110, 32, 49, 59, + 39, 41, 10, 32,111,117,116,112,117,116, 40, 39,125, 39, 41, + 10, 32,111,117,116,112,117,116, 40, 39, 35,101,110,100,105, + 102, 32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79, 76, + 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10, + 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10, 10, + 32, 45, 45, 32,115,101,116, 32,102,117,110, 99,116,105,111, + 110, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 10, 32,105,102, 32,110,111,116, 32, 40, + 115,116,114,102,105,110,100, 40,115,101,108,102, 46,116,121, + 112,101, 44, 39, 99,111,110,115,116, 37,115, 43, 39, 41, 32, + 111,114, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, + 115,101,108,102, 46,109,111,100, 44, 32, 39,116,111,108,117, + 97, 95,114,101, 97,100,111,110,108,121, 39, 41, 32,111,114, + 32,115,116,114,105,110,103, 46,102,105,110,100, 40,115,101, + 108,102, 46,109,111,100, 44, 32, 39,116,111,108,117, 97, 95, + 105,110,104,101,114,105,116,115, 39, 41, 41, 32, 32,116,104, + 101,110, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32,116, + 104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, 40, 34, + 47, 42, 32,115,101,116, 32,102,117,110, 99,116,105,111,110, + 58, 34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34, 32, + 111,102, 32, 99,108, 97,115,115, 32, 34, 44, 99,108, 97,115, + 115, 44, 34, 32, 42, 47, 34, 41, 10, 32, 32,101,108,115,101, + 10, 32, 32, 32,111,117,116,112,117,116, 40, 34, 47, 42, 32, + 115,101,116, 32,102,117,110, 99,116,105,111,110, 58, 34, 44, + 115,101,108,102, 46,110, 97,109,101, 44, 34, 32, 42, 47, 34, + 41, 10, 32, 32,101,110,100, 10, 32, 32,115,101,108,102, 46, + 99,115,101,116,110, 97,109,101, 32, 61, 32,115,101,108,102, + 58, 99,102,117,110, 99,110, 97,109,101, 40, 34,116,111,108, + 117, 97, 95,115,101,116, 34, 41, 10, 32, 32,111,117,116,112, + 117,116, 40, 34, 35,105,102,110,100,101,102, 32, 84, 79, 76, + 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, 34, 46, 46,115, + 101,108,102, 46, 99,115,101,116,110, 97,109,101, 41, 10, 32, + 32,111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,116, + 105, 99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,115, + 101,116,110, 97,109,101, 44, 34, 40,108,117, 97, 95, 83,116, + 97,116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34, 41, + 10, 32, 32,111,117,116,112,117,116, 40, 34,123, 34, 41, 10, + 10, 32, 32, 45, 45, 32,100,101, 99,108, 97,114,101, 32,115, + 101,108,102, 44, 32,105,102, 32,116,104,101, 32, 99, 97,115, + 101, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110, + 100, 32,115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116, + 104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, 40, 39, + 32, 39, 44,115,101,108,102, 46,112, 97,114,101,110,116, 46, + 116,121,112,101, 44, 39, 42, 39, 44, 39,115,101,108,102, 32, + 61, 32, 39, 41, 10, 32, 32, 32,111,117,116,112,117,116, 40, + 39, 40, 39, 44,115,101,108,102, 46,112, 97,114,101,110,116, + 46,116,121,112,101, 44, 39, 42, 41, 32, 39, 41, 10, 32, 32, + 32,108,111, 99, 97,108, 32,116,111, 95,102,117,110, 99, 32, + 61, 32,103,101,116, 95,116,111, 95,102,117,110, 99,116,105, + 111,110, 40,115,101,108,102, 46,112, 97,114,101,110,116, 46, + 116,121,112,101, 41, 10, 32, 32, 32,111,117,116,112,117,116, + 40,116,111, 95,102,117,110, 99, 44, 39, 40,116,111,108,117, + 97, 95, 83, 44, 49, 44, 48, 41, 59, 39, 41, 10, 32, 32, 32, + 45, 45, 32, 99,104,101, 99,107, 32,115,101,108,102, 32,118, + 97,108,117,101, 10, 9, 9,101,110,100, 10, 32, 32, 45, 45, + 32, 99,104,101, 99,107, 32,116,121,112,101,115, 10, 9, 9, + 111,117,116,112,117,116, 40, 39, 35,105,102,110,100,101,102, + 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92, + 110, 39, 41, 10, 9, 9,111,117,116,112,117,116, 40, 39, 32, + 32,116,111,108,117, 97, 95, 69,114,114,111,114, 32,116,111, + 108,117, 97, 95,101,114,114, 59, 39, 41, 10, 32, 32,105,102, + 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,116, + 105, 99, 61, 61,110,105,108, 32,116,104,101,110, 10, 32, 32, + 32,111,117,116,112,117,116, 40, 39, 32, 32,105,102, 32, 40, + 33,115,101,108,102, 41, 32,116,111,108,117, 97, 95,101,114, + 114,111,114, 40,116,111,108,117, 97, 95, 83, 44, 34,105,110, + 118, 97,108,105,100, 32, 92, 39,115,101,108,102, 92, 39, 32, + 105,110, 32, 97, 99, 99,101,115,115,105,110,103, 32,118, 97, + 114,105, 97, 98,108,101, 32, 92, 39, 39, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44, 78, 85, + 76, 76, 41, 59, 39, 41, 59, 10, 32, 32,101,108,115,101,105, + 102, 32,115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, + 32, 32, 95, 44, 95, 44,115,101,108,102, 46,109,111,100, 32, + 61, 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46, + 109,111,100, 44, 39, 94, 37,115, 42,115,116, 97,116,105, 99, + 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10, 32, 32,101, + 110,100, 10, 10, 32, 32, 45, 45, 32, 99,104,101, 99,107, 32, + 118, 97,114,105, 97, 98,108,101, 32,116,121,112,101, 10, 32, + 32,111,117,116,112,117,116, 40, 39, 32, 32,105,102, 32, 40, + 39, 46, 46,115,101,108,102, 58,111,117,116, 99,104,101, 99, + 107,116,121,112,101, 40, 50, 41, 46, 46, 39, 41, 39, 41, 10, + 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111, + 108,117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, + 95, 83, 44, 34, 35,118,105,110,118, 97,108,105,100, 32,116, + 121,112,101, 32,105,110, 32,118, 97,114,105, 97, 98,108,101, + 32, 97,115,115,105,103,110,109,101,110,116, 46, 34, 44, 38, + 116,111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10, 9, + 9,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102, + 92,110, 39, 41, 10, 10, 32, 32, 45, 45, 32, 97,115,115,105, + 103,110, 32,118, 97,108,117,101, 10, 9, 9,108,111, 99, 97, + 108, 32,100,101,102, 32, 61, 32, 48, 10, 9, 9,105,102, 32, + 115,101,108,102, 46,100,101,102, 32,126, 61, 32, 39, 39, 32, + 116,104,101,110, 32,100,101,102, 32, 61, 32,115,101,108,102, + 46,100,101,102, 32,101,110,100, 10, 9, 9,105,102, 32,115, + 101,108,102, 46,116,121,112,101, 32, 61, 61, 32, 39, 99,104, + 97,114, 42, 39, 32, 97,110,100, 32,115,101,108,102, 46,100, + 105,109, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 32, 45, + 45, 32,105,115, 32,115,116,114,105,110,103, 10, 9, 9, 32, + 111,117,116,112,117,116, 40, 39, 32,115,116,114,110, 99,112, + 121, 40, 39, 41, 10, 9, 9, 9,105,102, 32, 99,108, 97,115, + 115, 32, 97,110,100, 32,115,116, 97,116,105, 99, 32,116,104, + 101,110, 10, 9, 9, 9, 9,111,117,116,112,117,116, 40,115, + 101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, + 46, 46, 39, 58, 58, 39, 46, 46,115,101,108,102, 46,110, 97, + 109,101, 41, 10, 9, 9, 9,101,108,115,101,105,102, 32, 99, + 108, 97,115,115, 32,116,104,101,110, 10, 9, 9, 9, 9,111, + 117,116,112,117,116, 40, 39,115,101,108,102, 45, 62, 39, 46, + 46,115,101,108,102, 46,110, 97,109,101, 41, 10, 9, 9, 9, + 101,108,115,101, 10, 9, 9, 9, 9,111,117,116,112,117,116, + 40,115,101,108,102, 46,110, 97,109,101, 41, 10, 9, 9, 9, + 101,110,100, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, + 44,116,111,108,117, 97, 95,116,111,115,116,114,105,110,103, + 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 39, 44,100,101, + 102, 44, 39, 41, 44, 39, 44,115,101,108,102, 46,100,105,109, + 44, 39, 45, 49, 41, 59, 39, 41, 10, 9, 9,101,108,115,101, + 10, 9, 9, 9,108,111, 99, 97,108, 32,112,116,114, 32, 61, + 32, 39, 39, 10, 9, 9, 9,105,102, 32,115,101,108,102, 46, + 112,116,114,126, 61, 39, 39, 32,116,104,101,110, 32,112,116, + 114, 32, 61, 32, 39, 42, 39, 32,101,110,100, 10, 9, 9, 9, + 111,117,116,112,117,116, 40, 39, 32, 39, 41, 10, 9, 9, 9, + 108,111, 99, 97,108, 32,110, 97,109,101, 32, 61, 32,112,114, + 111,112, 95,115,101,116, 32,111,114, 32,115,101,108,102, 46, + 110, 97,109,101, 10, 9, 9, 9,105,102, 32, 99,108, 97,115, + 115, 32, 97,110,100, 32,115,116, 97,116,105, 99, 32,116,104, + 101,110, 10, 9, 9, 9, 9,111,117,116,112,117,116, 40,115, + 101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, + 46, 46, 39, 58, 58, 39, 46, 46,110, 97,109,101, 41, 10, 9, + 9, 9,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32, + 116,104,101,110, 10, 9, 9, 9, 9,111,117,116,112,117,116, + 40, 39,115,101,108,102, 45, 62, 39, 46, 46,110, 97,109,101, + 41, 10, 9, 9, 9,101,108,115,101, 10, 9, 9, 9, 9,111, + 117,116,112,117,116, 40,110, 97,109,101, 41, 10, 9, 9, 9, + 101,110,100, 10, 9, 9, 9,108,111, 99, 97,108, 32,116, 32, + 61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46, + 116,121,112,101, 41, 10, 9, 9, 9,105,102, 32,112,114,111, + 112, 95,115,101,116, 32,116,104,101,110, 10, 9, 9, 9, 9, + 111,117,116,112,117,116, 40, 39, 40, 39, 41, 10, 9, 9, 9, + 101,108,115,101, 10, 9, 9, 9, 9,111,117,116,112,117,116, + 40, 39, 32, 61, 32, 39, 41, 10, 9, 9, 9,101,110,100, 10, + 9, 9, 9,105,102, 32,110,111,116, 32,116, 32, 97,110,100, + 32,112,116,114, 61, 61, 39, 39, 32,116,104,101,110, 32,111, + 117,116,112,117,116, 40, 39, 42, 39, 41, 32,101,110,100, 10, + 9, 9, 9,111,117,116,112,117,116, 40, 39, 40, 40, 39, 44, + 115,101,108,102, 46,109,111,100, 44,115,101,108,102, 46,116, + 121,112,101, 41, 10, 9, 9, 9,105,102, 32,110,111,116, 32, + 116, 32,116,104,101,110, 10, 9, 9, 9, 9,111,117,116,112, + 117,116, 40, 39, 42, 39, 41, 10, 9, 9, 9,101,110,100, 10, + 9, 9, 9,111,117,116,112,117,116, 40, 39, 41, 32, 39, 41, + 10, 9, 9, 9,105,102, 32,116, 32,116,104,101,110, 10, 9, + 9, 9, 9,105,102, 32,105,115,101,110,117,109, 40,115,101, + 108,102, 46,116,121,112,101, 41, 32,116,104,101,110, 10, 9, + 9, 9, 9, 9,111,117,116,112,117,116, 40, 39, 40,105,110, + 116, 41, 32, 39, 41, 10, 9, 9, 9, 9,101,110,100, 10, 9, + 9, 9, 9,111,117,116,112,117,116, 40, 39,116,111,108,117, + 97, 95,116,111, 39, 46, 46,116, 44, 39, 40,116,111,108,117, + 97, 95, 83, 44, 50, 44, 39, 44,100,101,102, 44, 39, 41, 41, + 39, 41, 10, 9, 9, 9,101,108,115,101, 10, 9, 9, 9, 9, + 108,111, 99, 97,108, 32,116,111, 95,102,117,110, 99, 32, 61, + 32,103,101,116, 95,116,111, 95,102,117,110, 99,116,105,111, + 110, 40,115,101,108,102, 46,116,121,112,101, 41, 10, 9, 9, + 9, 9,111,117,116,112,117,116, 40,116,111, 95,102,117,110, + 99, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 39, + 44,100,101,102, 44, 39, 41, 41, 39, 41, 10, 9, 9, 9,101, + 110,100, 10, 9, 9, 9,105,102, 32,112,114,111,112, 95,115, + 101,116, 32,116,104,101,110, 10, 9, 9, 9, 9,111,117,116, + 112,117,116, 40, 34, 41, 34, 41, 10, 9, 9, 9,101,110,100, + 10, 9, 9, 9,111,117,116,112,117,116, 40, 34, 59, 34, 41, + 10, 9, 9,101,110,100, 10, 32, 32,111,117,116,112,117,116, + 40, 39, 32,114,101,116,117,114,110, 32, 48, 59, 39, 41, 10, + 32, 32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10, 32, + 32,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102, + 32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, + 65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10, 32, + 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10, 32, + 101,110,100, 10, 10,101,110,100, 10, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98, + 108,101, 58,114,101,103,105,115,116,101,114, 32, 40,112,114, + 101, 41, 10, 10, 9,105,102, 32,110,111,116, 32,115,101,108, + 102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, 95, + 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10, 9, + 9,114,101,116,117,114,110, 10, 9,101,110,100, 10, 32,112, + 114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10, + 32,108,111, 99, 97,108, 32,112, 97,114,101,110,116, 32, 61, + 32,115,101,108,102, 58,105,110,109,111,100,117,108,101, 40, + 41, 32,111,114, 32,115,101,108,102, 58,105,110,110, 97,109, + 101,115,112, 97, 99,101, 40, 41, 32,111,114, 32,115,101,108, + 102, 58,105,110, 99,108, 97,115,115, 40, 41, 10, 32,105,102, + 32,110,111,116, 32,112, 97,114,101,110,116, 32,116,104,101, + 110, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 86, 97,114, + 105, 97, 98,108,101, 46, 95,119, 97,114,110,105,110,103, 61, + 61,110,105,108, 32,116,104,101,110, 10, 32, 32, 32,119, 97, + 114,110,105,110,103, 40, 34, 77, 97,112,112,105,110,103, 32, + 118, 97,114,105, 97, 98,108,101, 32,116,111, 32,103,108,111, + 98, 97,108, 32,109, 97,121, 32,100,101,103,114, 97,100,101, + 32,112,101,114,102,111,114,109, 97,110, 99,101, 34, 41, 10, + 32, 32, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108, + 101, 46, 95,119, 97,114,110,105,110,103, 32, 61, 32, 49, 10, + 32, 32,101,110,100, 10, 32,101,110,100, 10, 32,105,102, 32, + 115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 32,116, + 104,101,110, 10, 32, 32,111,117,116,112,117,116, 40,112,114, + 101, 46, 46, 39,116,111,108,117, 97, 95,118, 97,114,105, 97, + 98,108,101, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, + 46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, + 44, 39, 46, 46,115,101,108,102, 46, 99,103,101,116,110, 97, + 109,101, 46, 46, 39, 44, 39, 46, 46,115,101,108,102, 46, 99, + 115,101,116,110, 97,109,101, 46, 46, 39, 41, 59, 39, 41, 10, + 32,101,108,115,101, 10, 32, 32,111,117,116,112,117,116, 40, + 112,114,101, 46, 46, 39,116,111,108,117, 97, 95,118, 97,114, + 105, 97, 98,108,101, 40,116,111,108,117, 97, 95, 83, 44, 34, + 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, + 39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,103,101,116, + 110, 97,109,101, 46, 46, 39, 44, 78, 85, 76, 76, 41, 59, 39, + 41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, + 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114, + 117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32, + 95, 86, 97,114,105, 97, 98,108,101, 32, 40,116, 41, 10, 32, + 115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, + 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 41, 10, + 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116, + 117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67, + 111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69, + 120,112,101, 99,116,115, 32, 97, 32,115,116,114,105,110,103, + 32,114,101,112,114,101,115,101,110,116,105,110,103, 32,116, + 104,101, 32,118, 97,114,105, 97, 98,108,101, 32,100,101, 99, + 108, 97,114, 97,116,105,111,110, 46, 10,102,117,110, 99,116, + 105,111,110, 32, 86, 97,114,105, 97, 98,108,101, 32, 40,115, + 41, 10, 32,114,101,116,117,114,110, 32, 95, 86, 97,114,105, + 97, 98,108,101, 32, 40, 68,101, 99,108, 97,114, 97,116,105, + 111,110, 40,115, 44, 39,118, 97,114, 39, 41, 41, 10,101,110, + 100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/variable.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32, 97,114,114, 97,121, + 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116, + 101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, + 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97, + 102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117, + 108, 32, 49, 57, 57, 57, 10, 45, 45, 32, 36, 73,100, 58, 32, + 97,114,114, 97,121, 46,108,117, 97, 44,118, 32, 49, 46, 49, + 32, 50, 48, 48, 48, 47, 49, 49, 47, 48, 54, 32, 50, 50, 58, + 48, 51, 58, 53, 55, 32, 99,101,108,101,115, 32, 69,120,112, + 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100, + 101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119, + 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101, + 100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97, + 110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116, + 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97, + 114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,114, + 101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, + 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, + 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116, + 104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105, + 103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105, + 100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, + 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116, + 101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109, + 101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105, + 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, 32, 65, + 114,114, 97,121, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82, + 101,112,114,101,115,101,110,116,115, 32, 97, 32,101,120,116, + 101,114,110, 32, 97,114,114, 97,121, 32,118, 97,114,105, 97, + 98,108,101, 32,111,114, 32, 97, 32,112,117, 98,108,105, 99, + 32,109,101,109, 98,101,114, 32,111,102, 32, 97, 32, 99,108, + 97,115,115, 46, 10, 45, 45, 32, 83,116,111,114,101,115, 32, + 97,108,108, 32,102,105,101,108,100,115, 32,112,114,101,115, + 101,110,116, 32,105,110, 32, 97, 32,100,101, 99,108, 97,114, + 97,116,105,111,110, 46, 10, 99,108, 97,115,115, 65,114,114, + 97,121, 32, 61, 32,123, 10,125, 10, 99,108, 97,115,115, 65, + 114,114, 97,121, 46, 95, 95,105,110,100,101,120, 32, 61, 32, + 99,108, 97,115,115, 65,114,114, 97,121, 10,115,101,116,109, + 101,116, 97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 65, + 114,114, 97,121, 44, 99,108, 97,115,115, 68,101, 99,108, 97, + 114, 97,116,105,111,110, 41, 10, 10, 45, 45, 32, 80,114,105, + 110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121, 58, + 112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108, + 111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 65,114,114, 97,121,123, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, + 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114, + 105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,116,121, + 112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,116, + 121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105, + 110,116, 40,105,100,101,110,116, 46, 46, 34, 32,112,116,114, + 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,112,116, + 114, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, + 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101, 32, + 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109,101, + 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40, + 105,100,101,110,116, 46, 46, 34, 32,100,101,102, 32, 32, 61, + 32, 39, 34, 46, 46,115,101,108,102, 46,100,101,102, 46, 46, + 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100, + 101,110,116, 46, 46, 34, 32,100,105,109, 32, 32, 61, 32, 39, + 34, 46, 46,115,101,108,102, 46,100,105,109, 46, 46, 34, 39, + 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110, + 116, 46, 46, 34, 32,114,101,116, 32, 32, 61, 32, 39, 34, 46, + 46,115,101,108,102, 46,114,101,116, 46, 46, 34, 39, 44, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110, + 100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32, + 105,116, 32,105,115, 32, 97, 32,118, 97,114,105, 97, 98,108, + 101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 65,114,114, 97,121, 58,105,115,118, 97,114,105, 97, 98, + 108,101, 32, 40, 41, 10, 32,114,101,116,117,114,110, 32,116, + 114,117,101, 10,101,110,100, 10, 10, 10, 45, 45, 32,103,101, + 116, 32,118, 97,114,105, 97, 98,108,101, 32,118, 97,108,117, + 101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 65,114,114, 97,121, 58,103,101,116,118, 97,108,117,101, + 32, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, 41, + 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32, + 115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32,114, + 101,116,117,114,110, 32, 99,108, 97,115,115, 46, 46, 39, 58, + 58, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46, 46, + 39, 91,116,111,108,117, 97, 95,105,110,100,101,120, 93, 39, + 10, 32,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32, + 116,104,101,110, 10, 32, 32,114,101,116,117,114,110, 32, 39, + 115,101,108,102, 45, 62, 39, 46, 46,115,101,108,102, 46,110, + 97,109,101, 46, 46, 39, 91,116,111,108,117, 97, 95,105,110, + 100,101,120, 93, 39, 10, 32,101,108,115,101, 10, 32, 32,114, + 101,116,117,114,110, 32,115,101,108,102, 46,110, 97,109,101, + 46, 46, 39, 91,116,111,108,117, 97, 95,105,110,100,101,120, + 93, 39, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, + 32, 87,114,105,116,101, 32, 98,105,110,100,105,110,103, 32, + 102,117,110, 99,116,105,111,110,115, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121, 58, + 115,117,112, 99,111,100,101, 32, 40, 41, 10, 32,108,111, 99, + 97,108, 32, 99,108, 97,115,115, 32, 61, 32,115,101,108,102, + 58,105,110, 99,108, 97,115,115, 40, 41, 10, 10, 32, 45, 45, + 32,103,101,116, 32,102,117,110, 99,116,105,111,110, 32, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 10, 32,105,102, 32, 99,108, 97,115,115, 32,116,104, + 101,110, 10, 32, 32,111,117,116,112,117,116, 40, 34, 47, 42, + 32,103,101,116, 32,102,117,110, 99,116,105,111,110, 58, 34, + 44,115,101,108,102, 46,110, 97,109,101, 44, 34, 32,111,102, + 32, 99,108, 97,115,115, 32, 34, 44, 99,108, 97,115,115, 44, + 34, 32, 42, 47, 34, 41, 10, 32,101,108,115,101, 10, 32, 32, + 111,117,116,112,117,116, 40, 34, 47, 42, 32,103,101,116, 32, + 102,117,110, 99,116,105,111,110, 58, 34, 44,115,101,108,102, + 46,110, 97,109,101, 44, 34, 32, 42, 47, 34, 41, 10, 32,101, + 110,100, 10, 32,115,101,108,102, 46, 99,103,101,116,110, 97, + 109,101, 32, 61, 32,115,101,108,102, 58, 99,102,117,110, 99, + 110, 97,109,101, 40, 34,116,111,108,117, 97, 95,103,101,116, + 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,105,102, + 110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, + 66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, 99,103,101, + 116,110, 97,109,101, 41, 10, 32,111,117,116,112,117,116, 40, + 34, 92,110,115,116, 97,116,105, 99, 32,105,110,116, 34, 44, + 115,101,108,102, 46, 99,103,101,116,110, 97,109,101, 44, 34, + 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108, + 117, 97, 95, 83, 41, 34, 41, 10, 32,111,117,116,112,117,116, + 40, 34,123, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, + 32,105,110,116, 32,116,111,108,117, 97, 95,105,110,100,101, + 120, 59, 34, 41, 10, 10, 32, 45, 45, 32,100,101, 99,108, 97, + 114,101, 32,115,101,108,102, 44, 32,105,102, 32,116,104,101, + 32, 99, 97,115,101, 10, 32,108,111, 99, 97,108, 32, 95, 44, + 95, 44,115,116, 97,116,105, 99, 32, 61, 32,115,116,114,102, + 105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 39, 94, + 37,115, 42, 40,115,116, 97,116,105, 99, 41, 39, 41, 10, 32, + 105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, + 97,116,105, 99, 61, 61,110,105,108, 32,116,104,101,110, 10, + 32, 32,111,117,116,112,117,116, 40, 39, 32, 39, 44,115,101, + 108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, 44, + 39, 42, 39, 44, 39,115,101,108,102, 59, 39, 41, 10, 32, 32, + 111,117,116,112,117,116, 40, 39, 32,108,117, 97, 95,112,117, + 115,104,115,116,114,105,110,103, 40,116,111,108,117, 97, 95, + 83, 44, 34, 46,115,101,108,102, 34, 41, 59, 39, 41, 10, 32, + 32,111,117,116,112,117,116, 40, 39, 32,108,117, 97, 95,114, + 97,119,103,101,116, 40,116,111,108,117, 97, 95, 83, 44, 49, + 41, 59, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, + 32,115,101,108,102, 32, 61, 32, 39, 41, 10, 32, 32,111,117, + 116,112,117,116, 40, 39, 40, 39, 44,115,101,108,102, 46,112, + 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42, 41, 32, + 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39,108,117, + 97, 95,116,111,117,115,101,114,100, 97,116, 97, 40,116,111, + 108,117, 97, 95, 83, 44, 45, 49, 41, 59, 39, 41, 10, 32,101, + 108,115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104, + 101,110, 10, 32, 32, 95, 44, 95, 44,115,101,108,102, 46,109, + 111,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115,101, + 108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,115,116, 97, + 116,105, 99, 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10, + 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99,107, + 32,105,110,100,101,120, 10, 9,111,117,116,112,117,116, 40, + 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, + 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, 9,111,117, + 116,112,117,116, 40, 39, 32,123, 39, 41, 10, 9,111,117,116, + 112,117,116, 40, 39, 32, 32,116,111,108,117, 97, 95, 69,114, + 114,111,114, 32,116,111,108,117, 97, 95,101,114,114, 59, 39, + 41, 10, 32,111,117,116,112,117,116, 40, 39, 32, 32,105,102, + 32, 40, 33,116,111,108,117, 97, 95,105,115,110,117,109, 98, + 101,114, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 44, + 38,116,111,108,117, 97, 95,101,114,114, 41, 41, 39, 41, 10, + 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,108, + 117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95, + 83, 44, 34, 35,118,105,110,118, 97,108,105,100, 32,116,121, + 112,101, 32,105,110, 32, 97,114,114, 97,121, 32,105,110,100, + 101,120,105,110,103, 46, 34, 44, 38,116,111,108,117, 97, 95, + 101,114,114, 41, 59, 39, 41, 10, 9,111,117,116,112,117,116, + 40, 39, 32,125, 39, 41, 10, 9,111,117,116,112,117,116, 40, + 39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 9,105,102, + 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,104,101, + 110, 32, 45, 45, 32,102,111,114, 32, 99,111,109,112, 97,116, + 105, 98,105,108,105,116,121, 32,119,105,116,104, 32,116,111, + 108,117, 97, 53, 32, 63, 10, 9, 9,111,117,116,112,117,116, + 40, 39, 32,116,111,108,117, 97, 95,105,110,100,101,120, 32, + 61, 32, 40,105,110,116, 41,116,111,108,117, 97, 95,116,111, + 110,117,109, 98,101,114, 40,116,111,108,117, 97, 95, 83, 44, + 50, 44, 48, 41, 45, 49, 59, 39, 41, 10, 9,101,108,115,101, + 10, 9, 9,111,117,116,112,117,116, 40, 39, 32,116,111,108, + 117, 97, 95,105,110,100,101,120, 32, 61, 32, 40,105,110,116, + 41,116,111,108,117, 97, 95,116,111,110,117,109, 98,101,114, + 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 41, 59, 39, + 41, 10, 9,101,110,100, 10, 9,111,117,116,112,117,116, 40, + 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, + 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, 9,105,102, + 32,115,101,108,102, 46,100,105,109, 32, 97,110,100, 32,115, + 101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32,116, + 104,101,110, 10, 9, 32, 32,111,117,116,112,117,116, 40, 39, + 32,105,102, 32, 40,116,111,108,117, 97, 95,105,110,100,101, + 120, 60, 48, 32,124,124, 32,116,111,108,117, 97, 95,105,110, + 100,101,120, 62, 61, 39, 46, 46,115,101,108,102, 46,100,105, + 109, 46, 46, 39, 41, 39, 41, 10, 9,101,108,115,101, 10, 9, + 32, 32,111,117,116,112,117,116, 40, 39, 32,105,102, 32, 40, + 116,111,108,117, 97, 95,105,110,100,101,120, 60, 48, 41, 39, + 41, 10, 9,101,110,100, 10, 32,111,117,116,112,117,116, 40, + 39, 32, 32,116,111,108,117, 97, 95,101,114,114,111,114, 40, + 116,111,108,117, 97, 95, 83, 44, 34, 97,114,114, 97,121, 32, + 105,110,100,101,120,105,110,103, 32,111,117,116, 32,111,102, + 32,114, 97,110,103,101, 46, 34, 44, 78, 85, 76, 76, 41, 59, + 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, 35,101,110, + 100,105,102, 92,110, 39, 41, 10, 10, 32, 45, 45, 32,114,101, + 116,117,114,110, 32,118, 97,108,117,101, 10, 32,108,111, 99, + 97,108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115, + 105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 10, 32, + 108,111, 99, 97,108, 32,112,117,115,104, 95,102,117,110, 99, + 32, 61, 32,103,101,116, 95,112,117,115,104, 95,102,117,110, + 99,116,105,111,110, 40,116, 41, 10, 32,105,102, 32,116, 32, + 116,104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, 39, + 32,116,111,108,117, 97, 95,112,117,115,104, 39, 46, 46,116, + 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39, 44, + 99,116, 44, 39, 41, 39, 46, 46,115,101,108,102, 58,103,101, + 116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,116, + 97,116,105, 99, 41, 46, 46, 39, 41, 59, 39, 41, 10, 32,101, + 108,115,101, 10, 9, 9,116, 32, 61, 32,115,101,108,102, 46, + 116,121,112,101, 10, 32, 32,105,102, 32,115,101,108,102, 46, + 112,116,114, 32, 61, 61, 32, 39, 38, 39, 32,111,114, 32,115, + 101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 39, 32,116, + 104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, 40, 39, + 32, 39, 44,112,117,115,104, 95,102,117,110, 99, 44, 39, 40, + 116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, + 38, 39, 46, 46,115,101,108,102, 58,103,101,116,118, 97,108, + 117,101, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, + 41, 46, 46, 39, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, + 41, 10, 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116, + 112,117,116, 40, 39, 32, 39, 44,112,117,115,104, 95,102,117, + 110, 99, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 40,118, + 111,105,100, 42, 41, 39, 46, 46,115,101,108,102, 58,103,101, + 116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,116, + 97,116,105, 99, 41, 46, 46, 39, 44, 34, 39, 44,116, 44, 39, + 34, 41, 59, 39, 41, 10, 32, 32,101,110,100, 10, 32,101,110, + 100, 10, 32,111,117,116,112,117,116, 40, 39, 32,114,101,116, + 117,114,110, 32, 49, 59, 39, 41, 10, 32,111,117,116,112,117, + 116, 40, 39,125, 39, 41, 10, 32,111,117,116,112,117,116, 40, + 39, 35,101,110,100,105,102, 32, 47, 47, 35,105,102,110,100, + 101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, + 69, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40, 39, + 92,110, 39, 41, 10, 10, 32, 45, 45, 32,115,101,116, 32,102, + 117,110, 99,116,105,111,110, 32, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 32,105,102, + 32,110,111,116, 32,115,116,114,102,105,110,100, 40,115,101, + 108,102, 46,116,121,112,101, 44, 39, 99,111,110,115,116, 39, + 41, 32,116,104,101,110, 10, 32, 32,105,102, 32, 99,108, 97, + 115,115, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112, + 117,116, 40, 34, 47, 42, 32,115,101,116, 32,102,117,110, 99, + 116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, 97,109, + 101, 44, 34, 32,111,102, 32, 99,108, 97,115,115, 32, 34, 44, + 99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41, 10, 32, 32, + 101,108,115,101, 10, 32, 32, 32,111,117,116,112,117,116, 40, + 34, 47, 42, 32,115,101,116, 32,102,117,110, 99,116,105,111, + 110, 58, 34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34, + 32, 42, 47, 34, 41, 10, 32, 32,101,110,100, 10, 32, 32,115, + 101,108,102, 46, 99,115,101,116,110, 97,109,101, 32, 61, 32, + 115,101,108,102, 58, 99,102,117,110, 99,110, 97,109,101, 40, + 34,116,111,108,117, 97, 95,115,101,116, 34, 41, 10, 32, 32, + 111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101,102, + 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, + 34, 46, 46,115,101,108,102, 46, 99,115,101,116,110, 97,109, + 101, 41, 10, 32, 32,111,117,116,112,117,116, 40, 34, 92,110, + 115,116, 97,116,105, 99, 32,105,110,116, 34, 44,115,101,108, + 102, 46, 99,115,101,116,110, 97,109,101, 44, 34, 40,108,117, + 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95, + 83, 41, 34, 41, 10, 32, 32,111,117,116,112,117,116, 40, 34, + 123, 34, 41, 10, 10, 32, 32, 45, 45, 32,100,101, 99,108, 97, + 114,101, 32,105,110,100,101,120, 10, 32, 32,111,117,116,112, + 117,116, 40, 39, 32,105,110,116, 32,116,111,108,117, 97, 95, + 105,110,100,101,120, 59, 39, 41, 10, 10, 32, 32, 45, 45, 32, + 100,101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32,105, + 102, 32,116,104,101, 32, 99, 97,115,101, 10, 32, 32,108,111, + 99, 97,108, 32, 95, 44, 95, 44,115,116, 97,116,105, 99, 32, + 61, 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46, + 109,111,100, 44, 39, 94, 37,115, 42, 40,115,116, 97,116,105, + 99, 41, 39, 41, 10, 32, 32,105,102, 32, 99,108, 97,115,115, + 32, 97,110,100, 32,115,116, 97,116,105, 99, 61, 61,110,105, + 108, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117, + 116, 40, 39, 32, 39, 44,115,101,108,102, 46,112, 97,114,101, + 110,116, 46,116,121,112,101, 44, 39, 42, 39, 44, 39,115,101, + 108,102, 59, 39, 41, 10, 32, 32, 32,111,117,116,112,117,116, + 40, 39, 32,108,117, 97, 95,112,117,115,104,115,116,114,105, + 110,103, 40,116,111,108,117, 97, 95, 83, 44, 34, 46,115,101, + 108,102, 34, 41, 59, 39, 41, 10, 32, 32, 32,111,117,116,112, + 117,116, 40, 39, 32,108,117, 97, 95,114, 97,119,103,101,116, + 40,116,111,108,117, 97, 95, 83, 44, 49, 41, 59, 39, 41, 10, + 32, 32, 32,111,117,116,112,117,116, 40, 39, 32,115,101,108, + 102, 32, 61, 32, 39, 41, 10, 32, 32, 32,111,117,116,112,117, + 116, 40, 39, 40, 39, 44,115,101,108,102, 46,112, 97,114,101, + 110,116, 46,116,121,112,101, 44, 39, 42, 41, 32, 39, 41, 10, + 32, 32, 32,111,117,116,112,117,116, 40, 39,108,117, 97, 95, + 116,111,117,115,101,114,100, 97,116, 97, 40,116,111,108,117, + 97, 95, 83, 44, 45, 49, 41, 59, 39, 41, 10, 32, 32,101,108, + 115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,101, + 110, 10, 32, 32, 32, 95, 44, 95, 44,115,101,108,102, 46,109, + 111,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115,101, + 108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,115,116, 97, + 116,105, 99, 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10, + 32, 32,101,110,100, 10, 10, 32, 32, 45, 45, 32, 99,104,101, + 99,107, 32,105,110,100,101,120, 10, 9, 32,111,117,116,112, + 117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, + 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, + 9, 32,111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10, + 9, 32,111,117,116,112,117,116, 40, 39, 32, 32,116,111,108, + 117, 97, 95, 69,114,114,111,114, 32,116,111,108,117, 97, 95, + 101,114,114, 59, 39, 41, 10, 32, 32,111,117,116,112,117,116, + 40, 39, 32, 32,105,102, 32, 40, 33,116,111,108,117, 97, 95, + 105,115,110,117,109, 98,101,114, 40,116,111,108,117, 97, 95, + 83, 44, 50, 44, 48, 44, 38,116,111,108,117, 97, 95,101,114, + 114, 41, 41, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, + 39, 32, 32, 32,116,111,108,117, 97, 95,101,114,114,111,114, + 40,116,111,108,117, 97, 95, 83, 44, 34, 35,118,105,110,118, + 97,108,105,100, 32,116,121,112,101, 32,105,110, 32, 97,114, + 114, 97,121, 32,105,110,100,101,120,105,110,103, 46, 34, 44, + 38,116,111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10, + 9, 9,111,117,116,112,117,116, 40, 39, 32,125, 39, 41, 10, + 9, 9,111,117,116,112,117,116, 40, 39, 35,101,110,100,105, + 102, 92,110, 39, 41, 10, 10, 9,105,102, 32,102,108, 97,103, + 115, 91, 39, 49, 39, 93, 32,116,104,101,110, 32, 45, 45, 32, + 102,111,114, 32, 99,111,109,112, 97,116,105, 98,105,108,105, + 116,121, 32,119,105,116,104, 32,116,111,108,117, 97, 53, 32, + 63, 10, 9, 9,111,117,116,112,117,116, 40, 39, 32,116,111, + 108,117, 97, 95,105,110,100,101,120, 32, 61, 32, 40,105,110, + 116, 41,116,111,108,117, 97, 95,116,111,110,117,109, 98,101, + 114, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 41, 45, + 49, 59, 39, 41, 10, 9,101,108,115,101, 10, 9, 9,111,117, + 116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,105,110, + 100,101,120, 32, 61, 32, 40,105,110,116, 41,116,111,108,117, + 97, 95,116,111,110,117,109, 98,101,114, 40,116,111,108,117, + 97, 95, 83, 44, 50, 44, 48, 41, 59, 39, 41, 10, 9,101,110, + 100, 10, 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,105, + 102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, + 69, 65, 83, 69, 92,110, 39, 41, 10, 9,105,102, 32,115,101, + 108,102, 46,100,105,109, 32, 97,110,100, 32,115,101,108,102, + 46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,104,101,110, + 10, 9, 32, 32,111,117,116,112,117,116, 40, 39, 32,105,102, + 32, 40,116,111,108,117, 97, 95,105,110,100,101,120, 60, 48, + 32,124,124, 32,116,111,108,117, 97, 95,105,110,100,101,120, + 62, 61, 39, 46, 46,115,101,108,102, 46,100,105,109, 46, 46, + 39, 41, 39, 41, 10, 9,101,108,115,101, 10, 9, 32, 32,111, + 117,116,112,117,116, 40, 39, 32,105,102, 32, 40,116,111,108, + 117, 97, 95,105,110,100,101,120, 60, 48, 41, 39, 41, 10, 9, + 101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111, + 108,117, 97, 95, 83, 44, 34, 97,114,114, 97,121, 32,105,110, + 100,101,120,105,110,103, 32,111,117,116, 32,111,102, 32,114, + 97,110,103,101, 46, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, + 10, 9, 9,111,117,116,112,117,116, 40, 39, 35,101,110,100, + 105,102, 92,110, 39, 41, 10, 10, 32, 32, 45, 45, 32, 97,115, + 115,105,103,110, 32,118, 97,108,117,101, 10, 32, 32,108,111, + 99, 97,108, 32,112,116,114, 32, 61, 32, 39, 39, 10, 32, 32, + 105,102, 32,115,101,108,102, 46,112,116,114,126, 61, 39, 39, + 32,116,104,101,110, 32,112,116,114, 32, 61, 32, 39, 42, 39, + 32,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, + 32, 39, 41, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32, + 97,110,100, 32,115,116, 97,116,105, 99, 32,116,104,101,110, + 10, 32, 32, 32,111,117,116,112,117,116, 40, 99,108, 97,115, + 115, 46, 46, 39, 58, 58, 39, 46, 46,115,101,108,102, 46,110, + 97,109,101, 46, 46, 39, 91,116,111,108,117, 97, 95,105,110, + 100,101,120, 93, 39, 41, 10, 32, 32,101,108,115,101,105,102, + 32, 99,108, 97,115,115, 32,116,104,101,110, 10, 32, 32, 32, + 111,117,116,112,117,116, 40, 39,115,101,108,102, 45, 62, 39, + 46, 46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 91, + 116,111,108,117, 97, 95,105,110,100,101,120, 93, 39, 41, 10, + 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,112,117, + 116, 40,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 91, + 116,111,108,117, 97, 95,105,110,100,101,120, 93, 39, 41, 10, + 32, 32,101,110,100, 10, 32, 32,108,111, 99, 97,108, 32,116, + 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102, + 46,116,121,112,101, 41, 10, 32, 32,111,117,116,112,117,116, + 40, 39, 32, 61, 32, 39, 41, 10, 32, 32,105,102, 32,110,111, + 116, 32,116, 32, 97,110,100, 32,112,116,114, 61, 61, 39, 39, + 32,116,104,101,110, 32,111,117,116,112,117,116, 40, 39, 42, + 39, 41, 32,101,110,100, 10, 32, 32,111,117,116,112,117,116, + 40, 39, 40, 40, 39, 44,115,101,108,102, 46,109,111,100, 44, + 115,101,108,102, 46,116,121,112,101, 41, 10, 32, 32,105,102, + 32,110,111,116, 32,116, 32,116,104,101,110, 10, 32, 32, 32, + 111,117,116,112,117,116, 40, 39, 42, 39, 41, 10, 32, 32,101, + 110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 41, 32, + 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,100,101,102, 32, + 61, 32, 48, 10, 32, 32,105,102, 32,115,101,108,102, 46,100, + 101,102, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 32,100, + 101,102, 32, 61, 32,115,101,108,102, 46,100,101,102, 32,101, + 110,100, 10, 32, 32,105,102, 32,116, 32,116,104,101,110, 10, + 32, 32, 32,111,117,116,112,117,116, 40, 39,116,111,108,117, + 97, 95,116,111, 39, 46, 46,116, 44, 39, 40,116,111,108,117, + 97, 95, 83, 44, 51, 44, 39, 44,100,101,102, 44, 39, 41, 41, + 59, 39, 41, 10, 32, 32,101,108,115,101, 10, 32, 32, 32,108, + 111, 99, 97,108, 32,116,111, 95,102,117,110, 99, 32, 61, 32, + 103,101,116, 95,116,111, 95,102,117,110, 99,116,105,111,110, + 40,115,101,108,102, 46,116,121,112,101, 41, 10, 32, 32, 32, + 111,117,116,112,117,116, 40,116,111, 95,102,117,110, 99, 44, + 39, 40,116,111,108,117, 97, 95, 83, 44, 51, 44, 39, 44,100, + 101,102, 44, 39, 41, 41, 59, 39, 41, 10, 32, 32,101,110,100, + 10, 32, 32,111,117,116,112,117,116, 40, 39, 32,114,101,116, + 117,114,110, 32, 48, 59, 39, 41, 10, 32, 32,111,117,116,112, + 117,116, 40, 39,125, 39, 41, 10, 32, 32,111,117,116,112,117, + 116, 40, 39, 35,101,110,100,105,102, 32, 47, 47, 35,105,102, + 110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, + 66, 76, 69, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117, + 116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100, 10, 10,101, + 110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108, + 97,115,115, 65,114,114, 97,121, 58,114,101,103,105,115,116, + 101,114, 32, 40,112,114,101, 41, 10, 9,105,102, 32,110,111, + 116, 32,115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, + 98,108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116, + 104,101,110, 10, 9, 9,114,101,116,117,114,110, 10, 9,101, + 110,100, 10, 10, 32,112,114,101, 32, 61, 32,112,114,101, 32, + 111,114, 32, 39, 39, 10, 32,105,102, 32,115,101,108,102, 46, + 99,115,101,116,110, 97,109,101, 32,116,104,101,110, 10, 32, + 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116, + 111,108,117, 97, 95, 97,114,114, 97,121, 40,116,111,108,117, + 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,110, + 97,109,101, 46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, + 46, 99,103,101,116,110, 97,109,101, 46, 46, 39, 44, 39, 46, + 46,115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 46, + 46, 39, 41, 59, 39, 41, 10, 32,101,108,115,101, 10, 32, 32, + 111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111, + 108,117, 97, 95, 97,114,114, 97,121, 40,116,111,108,117, 97, + 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97, + 109,101, 46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46, + 99,103,101,116,110, 97,109,101, 46, 46, 39, 44, 78, 85, 76, + 76, 41, 59, 39, 41, 10, 32,101,110,100, 10,101,110,100, 10, + 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111, + 110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116, + 105,111,110, 32, 95, 65,114,114, 97,121, 32, 40,116, 41, 10, + 32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, + 44, 99,108, 97,115,115, 65,114,114, 97,121, 41, 10, 32, 97, + 112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114, + 110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110, + 115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112, + 101, 99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114, + 101,112,114,101,115,101,110,116,105,110,103, 32,116,104,101, + 32,118, 97,114,105, 97, 98,108,101, 32,100,101, 99,108, 97, + 114, 97,116,105,111,110, 46, 10,102,117,110, 99,116,105,111, + 110, 32, 65,114,114, 97,121, 32, 40,115, 41, 10, 32,114,101, + 116,117,114,110, 32, 95, 65,114,114, 97,121, 32, 40, 68,101, + 99,108, 97,114, 97,116,105,111,110, 40,115, 44, 39,118, 97, + 114, 39, 41, 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/array.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114, + 105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, + 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, + 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, + 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73, + 100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99, + 111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102, + 116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32, + 114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, + 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32, + 105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116, + 119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104, + 101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, + 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105, + 115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97, + 117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98, + 108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111, + 118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99, + 101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, + 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99, + 101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105, + 102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, + 45, 32, 70,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, + 32, 97, 32,102,117,110, 99,116,105,111,110, 32,111,114, 32, + 97, 32, 99,108, 97,115,115, 32,109,101,116,104,111,100, 46, + 10, 45, 45, 32, 84,104,101, 32,102,111,108,108,111,119,105, + 110,103, 32,102,105,101,108,100,115, 32, 97,114,101, 32,115, + 116,111,114,101,100, 58, 10, 45, 45, 32, 32,109,111,100, 32, + 32, 61, 32,116,121,112,101, 32,109,111,100,105,102,105,101, + 114,115, 10, 45, 45, 32, 32,116,121,112,101, 32, 61, 32,116, + 121,112,101, 10, 45, 45, 32, 32,112,116,114, 32, 32, 61, 32, + 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, 32,105,102, 32, + 114,101,112,114,101,115,101,110,116,105,110,103, 32, 97, 32, + 112,111,105,110,116,101,114, 32,111,114, 32, 97, 32,114,101, + 102,101,114,101,110, 99,101, 10, 45, 45, 32, 32,110, 97,109, + 101, 32, 61, 32,110, 97,109,101, 10, 45, 45, 32, 32,108,110, + 97,109,101, 32, 61, 32,108,117, 97, 32,110, 97,109,101, 10, + 45, 45, 32, 32, 97,114,103,115, 32, 32, 61, 32,108,105,115, + 116, 32,111,102, 32, 97,114,103,117,109,101,110,116, 32,100, + 101, 99,108, 97,114, 97,116,105,111,110,115, 10, 45, 45, 32, + 32, 99,111,110,115,116, 32, 61, 32,105,102, 32,105,116, 32, + 105,115, 32, 97, 32,109,101,116,104,111,100, 32,114,101, 99, + 101,105,118,105,110,103, 32, 97, 32, 99,111,110,115,116, 32, + 34,116,104,105,115, 34, 46, 10, 99,108, 97,115,115, 70,117, + 110, 99,116,105,111,110, 32, 61, 32,123, 10, 32,109,111,100, + 32, 61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, + 39, 39, 44, 10, 32,112,116,114, 32, 61, 32, 39, 39, 44, 10, + 32,110, 97,109,101, 32, 61, 32, 39, 39, 44, 10, 32, 97,114, + 103,115, 32, 61, 32,123,110, 61, 48,125, 44, 10, 32, 99,111, + 110,115,116, 32, 61, 32, 39, 39, 44, 10,125, 10, 99,108, 97, + 115,115, 70,117,110, 99,116,105,111,110, 46, 95, 95,105,110, + 100,101,120, 32, 61, 32, 99,108, 97,115,115, 70,117,110, 99, + 116,105,111,110, 10,115,101,116,109,101,116, 97,116, 97, 98, + 108,101, 40, 99,108, 97,115,115, 70,117,110, 99,116,105,111, + 110, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 41, + 10, 10, 45, 45, 32,100,101, 99,108, 97,114,101, 32,116, 97, + 103,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 70,117,110, 99,116,105,111,110, 58,100,101, 99,108, + 116,121,112,101, 32, 40, 41, 10, 32,115,101,108,102, 46,116, + 121,112,101, 32, 61, 32,116,121,112,101,118, 97,114, 40,115, + 101,108,102, 46,116,121,112,101, 41, 10, 32,105,102, 32,115, + 116,114,102,105,110,100, 40,115,101,108,102, 46,109,111,100, + 44, 39, 99,111,110,115,116, 39, 41, 32,116,104,101,110, 10, + 9, 32,115,101,108,102, 46,116,121,112,101, 32, 61, 32, 39, + 99,111,110,115,116, 32, 39, 46, 46,115,101,108,102, 46,116, + 121,112,101, 10, 9, 9,115,101,108,102, 46,109,111,100, 32, + 61, 32,103,115,117, 98, 40,115,101,108,102, 46,109,111,100, + 44, 39, 99,111,110,115,116, 39, 44, 39, 39, 41, 10, 9,101, + 110,100, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, + 119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115, + 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 46, 97, + 114,103,115, 91,105, 93, 58,100,101, 99,108,116,121,112,101, + 40, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101, + 110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32, 87,114,105, + 116,101, 32, 98,105,110,100,105,110,103, 32,102,117,110, 99, + 116,105,111,110, 10, 45, 45, 32, 79,117,116,112,117,116,115, + 32, 67, 47, 67, 43, 43, 32, 98,105,110,100,105,110,103, 32, + 102,117,110, 99,116,105,111,110, 46, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,116,105, + 111,110, 58,115,117,112, 99,111,100,101, 32, 40,108,111, 99, + 97,108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 41, + 10, 10, 32,108,111, 99, 97,108, 32,111,118,101,114,108,111, + 97,100, 32, 61, 32,115,116,114,115,117, 98, 40,115,101,108, + 102, 46, 99,110, 97,109,101, 44, 45, 50, 44, 45, 49, 41, 32, + 45, 32, 49, 32, 32, 45, 45, 32,105,110,100,105, 99, 97,116, + 101, 32,111,118,101,114,108,111, 97,100,101,100, 32,102,117, + 110, 99, 10, 32,108,111, 99, 97,108, 32,110,114,101,116, 32, + 61, 32, 48, 32, 32, 32, 32, 32, 32, 45, 45, 32,110,117,109, + 98,101,114, 32,111,102, 32,114,101,116,117,114,110,101,100, + 32,118, 97,108,117,101,115, 10, 32,108,111, 99, 97,108, 32, + 99,108, 97,115,115, 32, 61, 32,115,101,108,102, 58,105,110, + 99,108, 97,115,115, 40, 41, 10, 32,108,111, 99, 97,108, 32, + 95, 44, 95, 44,115,116, 97,116,105, 99, 32, 61, 32,115,116, + 114,102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44, + 39, 94, 37,115, 42, 40,115,116, 97,116,105, 99, 41, 39, 41, + 10, 32,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, + 10, 10, 32, 9,105,102, 32,115,101,108,102, 46,110, 97,109, + 101, 32, 61, 61, 32, 39,110,101,119, 39, 32, 97,110,100, 32, + 115,101,108,102, 46,112, 97,114,101,110,116, 46,102,108, 97, + 103,115, 46,112,117,114,101, 95,118,105,114,116,117, 97,108, + 32,116,104,101,110, 10, 32, 9, 9, 45, 45, 32,110,111, 32, + 99,111,110,115,116,114,117, 99,116,111,114, 32,102,111,114, + 32, 99,108, 97,115,115,101,115, 32,119,105,116,104, 32,112, + 117,114,101, 32,118,105,114,116,117, 97,108, 32,109,101,116, + 104,111,100,115, 10, 32, 9, 9,114,101,116,117,114,110, 10, + 32, 9,101,110,100, 10, 10, 32, 9,105,102, 32,108,111, 99, + 97,108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 32, + 116,104,101,110, 10, 9, 9,111,117,116,112,117,116, 40, 34, + 47, 42, 32,109,101,116,104,111,100, 58, 32,110,101,119, 95, + 108,111, 99, 97,108, 32,111,102, 32, 99,108, 97,115,115, 32, + 34, 44, 99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41, 10, + 9,101,108,115,101, 10, 9, 9,111,117,116,112,117,116, 40, + 34, 47, 42, 32,109,101,116,104,111,100, 58, 34, 44,115,101, + 108,102, 46,110, 97,109,101, 44, 34, 32,111,102, 32, 99,108, + 97,115,115, 32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42, + 47, 34, 41, 10, 9,101,110,100, 10, 32,101,108,115,101, 10, + 32, 32,111,117,116,112,117,116, 40, 34, 47, 42, 32,102,117, + 110, 99,116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, + 97,109,101, 44, 34, 32, 42, 47, 34, 41, 10, 32,101,110,100, + 10, 10, 32,105,102, 32,108,111, 99, 97,108, 95, 99,111,110, + 115,116,114,117, 99,116,111,114, 32,116,104,101,110, 10, 32, + 32,111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101, + 102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, + 95, 34, 46, 46,115,101,108,102, 46, 99,110, 97,109,101, 46, + 46, 34, 95,108,111, 99, 97,108, 34, 41, 10, 32, 32,111,117, + 116,112,117,116, 40, 34, 92,110,115,116, 97,116,105, 99, 32, + 105,110,116, 34, 44,115,101,108,102, 46, 99,110, 97,109,101, + 46, 46, 34, 95,108,111, 99, 97,108, 34, 44, 34, 40,108,117, + 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95, + 83, 41, 34, 41, 10, 32,101,108,115,101, 10, 32, 32,111,117, + 116,112,117,116, 40, 34, 35,105,102,110,100,101,102, 32, 84, + 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, 34, 46, + 46,115,101,108,102, 46, 99,110, 97,109,101, 41, 10, 32, 32, + 111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,116,105, + 99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,110, 97, + 109,101, 44, 34, 40,108,117, 97, 95, 83,116, 97,116,101, 42, + 32,116,111,108,117, 97, 95, 83, 41, 34, 41, 10, 32,101,110, + 100, 10, 32,111,117,116,112,117,116, 40, 34,123, 34, 41, 10, + 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,121,112,101, + 115, 10, 9,105,102, 32,111,118,101,114,108,111, 97,100, 32, + 60, 32, 48, 32,116,104,101,110, 10, 9, 32,111,117,116,112, + 117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, + 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, + 9,101,110,100, 10, 9,111,117,116,112,117,116, 40, 39, 32, + 116,111,108,117, 97, 95, 69,114,114,111,114, 32,116,111,108, + 117, 97, 95,101,114,114, 59, 39, 41, 10, 32,111,117,116,112, + 117,116, 40, 39, 32,105,102, 32, 40, 92,110, 39, 41, 10, 32, + 45, 45, 32, 99,104,101, 99,107, 32,115,101,108,102, 10, 32, + 108,111, 99, 97,108, 32,110, 97,114,103, 10, 32,105,102, 32, + 99,108, 97,115,115, 32,116,104,101,110, 32,110, 97,114,103, + 61, 50, 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32, + 101,110,100, 10, 32,105,102, 32, 99,108, 97,115,115, 32,116, + 104,101,110, 10, 9, 9,108,111, 99, 97,108, 32,102,117,110, + 99, 32, 61, 32,103,101,116, 95,105,115, 95,102,117,110, 99, + 116,105,111,110, 40,115,101,108,102, 46,112, 97,114,101,110, + 116, 46,116,121,112,101, 41, 10, 9, 9,108,111, 99, 97,108, + 32,116,121,112,101, 32, 61, 32,115,101,108,102, 46,112, 97, + 114,101,110,116, 46,116,121,112,101, 10, 9, 9,105,102, 32, + 115,101,108,102, 46,110, 97,109,101, 61, 61, 39,110,101,119, + 39, 32,111,114, 32,115,116, 97,116,105, 99,126, 61,110,105, + 108, 32,116,104,101,110, 10, 9, 9, 9,102,117,110, 99, 32, + 61, 32, 39,116,111,108,117, 97, 95,105,115,117,115,101,114, + 116, 97, 98,108,101, 39, 10, 9, 9, 9,116,121,112,101, 32, + 61, 32,115,101,108,102, 46,112, 97,114,101,110,116, 46,116, + 121,112,101, 10, 9, 9,101,110,100, 10, 9, 9,105,102, 32, + 115,101,108,102, 46, 99,111,110,115,116, 32,126, 61, 32, 39, + 39, 32,116,104,101,110, 10, 9, 9, 9,116,121,112,101, 32, + 61, 32, 34, 99,111,110,115,116, 32, 34, 46, 46,116,121,112, + 101, 10, 9, 9,101,110,100, 10, 9, 9,111,117,116,112,117, + 116, 40, 39, 32, 32, 32, 32, 32, 33, 39, 46, 46,102,117,110, + 99, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 49, 44, + 34, 39, 46, 46,116,121,112,101, 46, 46, 39, 34, 44, 48, 44, + 38,116,111,108,117, 97, 95,101,114,114, 41, 32,124,124, 92, + 110, 39, 41, 10, 32,101,110,100, 10, 32, 45, 45, 32, 99,104, + 101, 99,107, 32, 97,114,103,115, 10, 32,105,102, 32,115,101, + 108,102, 46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101, + 32,126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, + 10, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32, + 119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115, + 91,105, 93, 32,100,111, 10, 32, 32, 32,108,111, 99, 97,108, + 32, 98,116,121,112,101, 32, 61, 32,105,115, 98, 97,115,105, + 99, 40,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 46, + 116,121,112,101, 41, 10, 32, 32, 32,105,102, 32, 98,116,121, + 112,101, 32,126, 61, 32, 39,118, 97,108,117,101, 39, 32, 97, + 110,100, 32, 98,116,121,112,101, 32,126, 61, 32, 39,115,116, + 97,116,101, 39, 32,116,104,101,110, 10, 32, 32, 32, 32,111, + 117,116,112,117,116, 40, 39, 32, 32, 32, 32, 32, 39, 46, 46, + 115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58,111,117, + 116, 99,104,101, 99,107,116,121,112,101, 40,110, 97,114,103, + 41, 46, 46, 39, 32,124,124, 92,110, 39, 41, 10, 32, 32, 32, + 101,110,100, 10, 32, 32, 32,105,102, 32, 98,116,121,112,101, + 32,126, 61, 32, 39,115,116, 97,116,101, 39, 32,116,104,101, + 110, 10, 9, 32, 32, 32,110, 97,114,103, 32, 61, 32,110, 97, + 114,103, 43, 49, 10, 32, 32, 32,101,110,100, 10, 32, 32, 32, + 105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100, 10, 32, + 101,110,100, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,101, + 110,100, 32,111,102, 32,108,105,115,116, 10, 32,111,117,116, + 112,117,116, 40, 39, 32, 32, 32, 32, 32, 33,116,111,108,117, + 97, 95,105,115,110,111,111, 98,106, 40,116,111,108,117, 97, + 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, 39, 44, 38, + 116,111,108,117, 97, 95,101,114,114, 41, 92,110, 32, 41, 39, + 41, 10, 9,111,117,116,112,117,116, 40, 39, 32, 32,103,111, + 116,111, 32,116,111,108,117, 97, 95,108,101,114,114,111,114, + 59, 39, 41, 10, 10, 32,111,117,116,112,117,116, 40, 39, 32, + 101,108,115,101, 92,110, 39, 41, 10, 9,105,102, 32,111,118, + 101,114,108,111, 97,100, 32, 60, 32, 48, 32,116,104,101,110, + 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,101,110,100, + 105,102, 92,110, 39, 41, 10, 9,101,110,100, 10, 9,111,117, + 116,112,117,116, 40, 39, 32,123, 39, 41, 10, 10, 32, 45, 45, + 32,100,101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32, + 105,102, 32,116,104,101, 32, 99, 97,115,101, 10, 32,108,111, + 99, 97,108, 32,110, 97,114,103, 10, 32,105,102, 32, 99,108, + 97,115,115, 32,116,104,101,110, 32,110, 97,114,103, 61, 50, + 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,101,110, + 100, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, + 32,115,101,108,102, 46,110, 97,109,101,126, 61, 39,110,101, + 119, 39, 32, 97,110,100, 32,115,116, 97,116,105, 99, 61, 61, + 110,105,108, 32,116,104,101,110, 10, 32, 32,111,117,116,112, + 117,116, 40, 39, 32, 39, 44,115,101,108,102, 46, 99,111,110, + 115,116, 44,115,101,108,102, 46,112, 97,114,101,110,116, 46, + 116,121,112,101, 44, 39, 42, 39, 44, 39,115,101,108,102, 32, + 61, 32, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, + 40, 39, 44,115,101,108,102, 46, 99,111,110,115,116, 44,115, + 101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, + 44, 39, 42, 41, 32, 39, 41, 10, 32, 32,108,111, 99, 97,108, + 32,116,111, 95,102,117,110, 99, 32, 61, 32,103,101,116, 95, + 116,111, 95,102,117,110, 99,116,105,111,110, 40,115,101,108, + 102, 46,112, 97,114,101,110,116, 46,116,121,112,101, 41, 10, + 32, 32,111,117,116,112,117,116, 40,116,111, 95,102,117,110, + 99, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 49, 44, 48, + 41, 59, 39, 41, 10, 32,101,108,115,101,105,102, 32,115,116, + 97,116,105, 99, 32,116,104,101,110, 10, 32, 32, 95, 44, 95, + 44,115,101,108,102, 46,109,111,100, 32, 61, 32,115,116,114, + 102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 39, + 94, 37,115, 42,115,116, 97,116,105, 99, 37,115, 37,115, 42, + 40, 46, 42, 41, 39, 41, 10, 32,101,110,100, 10, 32, 45, 45, + 32,100,101, 99,108, 97,114,101, 32,112, 97,114, 97,109,101, + 116,101,114,115, 10, 32,105,102, 32,115,101,108,102, 46, 97, + 114,103,115, 91, 49, 93, 46,116,121,112,101, 32,126, 61, 32, + 39,118,111,105,100, 39, 32,116,104,101,110, 10, 32, 32,108, + 111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,119,104,105,108, + 101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32, + 100,111, 10, 32, 32, 32,115,101,108,102, 46, 97,114,103,115, + 91,105, 93, 58,100,101, 99,108, 97,114,101, 40,110, 97,114, + 103, 41, 10, 32, 32, 32,105,102, 32,105,115, 98, 97,115,105, + 99, 40,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 46, + 116,121,112,101, 41, 32,126, 61, 32, 34,115,116, 97,116,101, + 34, 32,116,104,101,110, 10, 9, 32, 32, 32,110, 97,114,103, + 32, 61, 32,110, 97,114,103, 43, 49, 10, 32, 32, 32,101,110, + 100, 10, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, + 101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99, + 104,101, 99,107, 32,115,101,108,102, 10, 32,105,102, 32, 99, + 108, 97,115,115, 32, 97,110,100, 32,115,101,108,102, 46,110, + 97,109,101,126, 61, 39,110,101,119, 39, 32, 97,110,100, 32, + 115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116,104,101, + 110, 10, 9, 32,111,117,116,112,117,116, 40, 39, 35,105,102, + 110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, + 65, 83, 69, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117, + 116, 40, 39, 32, 32,105,102, 32, 40, 33,115,101,108,102, 41, + 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111, + 108,117, 97, 95, 83, 44, 34,105,110,118, 97,108,105,100, 32, + 92, 39,115,101,108,102, 92, 39, 32,105,110, 32,102,117,110, + 99,116,105,111,110, 32, 92, 39, 39, 46, 46,115,101,108,102, + 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44, 78, 85, 76, + 76, 41, 59, 39, 41, 59, 10, 9, 32,111,117,116,112,117,116, + 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 32,101, + 110,100, 10, 10, 32, 45, 45, 32,103,101,116, 32, 97,114,114, + 97,121, 32,101,108,101,109,101,110,116, 32,118, 97,108,117, + 101,115, 10, 32,105,102, 32, 99,108, 97,115,115, 32,116,104, + 101,110, 32,110, 97,114,103, 61, 50, 32,101,108,115,101, 32, + 110, 97,114,103, 61, 49, 32,101,110,100, 10, 32,105,102, 32, + 115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 46,116,121, + 112,101, 32,126, 61, 32, 39,118,111,105,100, 39, 32,116,104, + 101,110, 10, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, + 32, 32,119,104,105,108,101, 32,115,101,108,102, 46, 97,114, + 103,115, 91,105, 93, 32,100,111, 10, 32, 32, 32,115,101,108, + 102, 46, 97,114,103,115, 91,105, 93, 58,103,101,116, 97,114, + 114, 97,121, 40,110, 97,114,103, 41, 10, 32, 32, 32,110, 97, + 114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32, 32, 32, + 105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100, 10, 32, + 101,110,100, 10, 10, 32,108,111, 99, 97,108, 32,111,117,116, + 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, + 115,101,108,102, 46,109,111,100, 44, 32, 34,116,111,108,117, + 97, 95,111,117,116,115,105,100,101, 34, 41, 10, 32, 45, 45, + 32, 99, 97,108,108, 32,102,117,110, 99,116,105,111,110, 10, + 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115, + 101,108,102, 46,110, 97,109,101, 61, 61, 39,100,101,108,101, + 116,101, 39, 32,116,104,101,110, 10, 32, 32,111,117,116,112, + 117,116, 40, 39, 32, 32, 77,116,111,108,117, 97, 95,100,101, + 108,101,116,101, 40,115,101,108,102, 41, 59, 39, 41, 10, 32, + 101,108,115,101,105,102, 32, 99,108, 97,115,115, 32, 97,110, + 100, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 61, 32, + 39,111,112,101,114, 97,116,111,114, 38, 91, 93, 39, 32,116, + 104,101,110, 10, 32, 32,105,102, 32,102,108, 97,103,115, 91, + 39, 49, 39, 93, 32,116,104,101,110, 32, 45, 45, 32,102,111, + 114, 32, 99,111,109,112, 97,116,105, 98,105,108,105,116,121, + 32,119,105,116,104, 32,116,111,108,117, 97, 53, 32, 63, 10, + 9,111,117,116,112,117,116, 40, 39, 32, 32,115,101,108,102, + 45, 62,111,112,101,114, 97,116,111,114, 91, 93, 40, 39, 44, + 115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 46,110, 97, + 109,101, 44, 39, 45, 49, 41, 32, 61, 32, 39, 44,115,101,108, + 102, 46, 97,114,103,115, 91, 50, 93, 46,110, 97,109,101, 44, + 39, 59, 39, 41, 10, 32, 32,101,108,115,101, 10, 32, 32, 32, + 32,111,117,116,112,117,116, 40, 39, 32, 32,115,101,108,102, + 45, 62,111,112,101,114, 97,116,111,114, 91, 93, 40, 39, 44, + 115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 46,110, 97, + 109,101, 44, 39, 41, 32, 61, 32, 39, 44,115,101,108,102, 46, + 97,114,103,115, 91, 50, 93, 46,110, 97,109,101, 44, 39, 59, + 39, 41, 10, 32, 32,101,110,100, 10, 32,101,108,115,101, 10, + 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,123, 39, 41, + 10, 32, 32,105,102, 32,115,101,108,102, 46,116,121,112,101, + 32,126, 61, 32, 39, 39, 32, 97,110,100, 32,115,101,108,102, + 46,116,121,112,101, 32,126, 61, 32, 39,118,111,105,100, 39, + 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, + 40, 39, 32, 32, 39, 44,115,101,108,102, 46,109,111,100, 44, + 115,101,108,102, 46,116,121,112,101, 44,115,101,108,102, 46, + 112,116,114, 44, 39,116,111,108,117, 97, 95,114,101,116, 32, + 61, 32, 39, 41, 10, 32, 32, 32,111,117,116,112,117,116, 40, + 39, 40, 39, 44,115,101,108,102, 46,109,111,100, 44,115,101, + 108,102, 46,116,121,112,101, 44,115,101,108,102, 46,112,116, + 114, 44, 39, 41, 32, 39, 41, 10, 32, 32,101,108,115,101, 10, + 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 39, 41, + 10, 32, 32,101,110,100, 10, 32, 32,105,102, 32, 99,108, 97, + 115,115, 32, 97,110,100, 32,115,101,108,102, 46,110, 97,109, + 101, 61, 61, 39,110,101,119, 39, 32,116,104,101,110, 10, 32, + 32, 32,111,117,116,112,117,116, 40, 39, 77,116,111,108,117, + 97, 95,110,101,119, 40, 40, 39, 44,115,101,108,102, 46,116, + 121,112,101, 44, 39, 41, 40, 39, 41, 10, 32, 32,101,108,115, + 101,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115, + 116, 97,116,105, 99, 32,116,104,101,110, 10, 9,105,102, 32, + 111,117,116, 32,116,104,101,110, 10, 9, 9,111,117,116,112, + 117,116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, + 39, 41, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,112, + 117,116, 40, 99,108, 97,115,115, 46, 46, 39, 58, 58, 39, 46, + 46,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, 39, 41, + 10, 9,101,110,100, 10, 32, 32,101,108,115,101,105,102, 32, + 99,108, 97,115,115, 32,116,104,101,110, 10, 9,105,102, 32, + 111,117,116, 32,116,104,101,110, 10, 9, 9,111,117,116,112, + 117,116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, + 39, 41, 10, 9,101,108,115,101, 10, 9, 32, 32,105,102, 32, + 115,101,108,102, 46, 99, 97,115,116, 95,111,112,101,114, 97, + 116,111,114, 32,116,104,101,110, 10, 9, 32, 32, 9, 45, 45, + 111,117,116,112,117,116, 40, 39,115,116, 97,116,105, 99, 95, + 99, 97,115,116, 60, 39, 44,115,101,108,102, 46,109,111,100, + 44,115,101,108,102, 46,116,121,112,101, 44,115,101,108,102, + 46,112,116,114, 44, 39, 62, 40, 42,115,101,108,102, 39, 41, + 10, 9, 9,111,117,116,112,117,116, 40, 39,115,101,108,102, + 45, 62,111,112,101,114, 97,116,111,114, 32, 39, 44,115,101, + 108,102, 46,109,111,100, 44,115,101,108,102, 46,116,121,112, + 101, 44, 39, 40, 39, 41, 10, 9, 32, 32,101,108,115,101, 10, + 9, 9,111,117,116,112,117,116, 40, 39,115,101,108,102, 45, + 62, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 44, 39, + 40, 39, 41, 10, 9, 32, 32,101,110,100, 10, 9,101,110,100, + 10, 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,112, + 117,116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, + 39, 41, 10, 32, 32,101,110,100, 10, 10, 32, 32,105,102, 32, + 111,117,116, 32, 97,110,100, 32,110,111,116, 32,115,116, 97, + 116,105, 99, 32,116,104,101,110, 10, 32, 32, 9,111,117,116, + 112,117,116, 40, 39,115,101,108,102, 39, 41, 10, 9,105,102, + 32,115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 32, 97, + 110,100, 32,115,101,108,102, 46, 97,114,103,115, 91, 49, 93, + 46,110, 97,109,101, 32,126, 61, 32, 39, 39, 32,116,104,101, + 110, 10, 9, 9,111,117,116,112,117,116, 40, 39, 44, 39, 41, + 10, 9,101,110,100, 10, 32, 32,101,110,100, 10, 32, 32, 45, + 45, 32,119,114,105,116,101, 32,112, 97,114, 97,109,101,116, + 101,114,115, 10, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, + 10, 32, 32,119,104,105,108,101, 32,115,101,108,102, 46, 97, + 114,103,115, 91,105, 93, 32,100,111, 10, 32, 32, 32,115,101, + 108,102, 46, 97,114,103,115, 91,105, 93, 58,112, 97,115,115, + 112, 97,114, 40, 41, 10, 32, 32, 32,105, 32, 61, 32,105, 43, + 49, 10, 32, 32, 32,105,102, 32,115,101,108,102, 46, 97,114, + 103,115, 91,105, 93, 32,116,104,101,110, 10, 32, 32, 32, 32, + 111,117,116,112,117,116, 40, 39, 44, 39, 41, 10, 32, 32, 32, + 101,110,100, 10, 32, 32,101,110,100, 10, 10, 32, 32,105,102, + 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,101,108,102, + 46,110, 97,109,101, 32, 61, 61, 32, 39,111,112,101,114, 97, + 116,111,114, 91, 93, 39, 32, 97,110,100, 32,102,108, 97,103, + 115, 91, 39, 49, 39, 93, 32,116,104,101,110, 10, 9,111,117, + 116,112,117,116, 40, 39, 45, 49, 41, 59, 39, 41, 10, 32, 32, + 101,108,115,101, 10, 9,105,102, 32, 99,108, 97,115,115, 32, + 97,110,100, 32,115,101,108,102, 46,110, 97,109,101, 61, 61, + 39,110,101,119, 39, 32,116,104,101,110, 10, 9, 9,111,117, + 116,112,117,116, 40, 39, 41, 41, 59, 39, 41, 32, 45, 45, 32, + 99,108,111,115,101, 32, 77,116,111,108,117, 97, 95,110,101, + 119, 40, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,112, + 117,116, 40, 39, 41, 59, 39, 41, 10, 9,101,110,100, 10, 32, + 32,101,110,100, 10, 10, 32, 32, 45, 45, 32,114,101,116,117, + 114,110, 32,118, 97,108,117,101,115, 10, 32, 32,105,102, 32, + 115,101,108,102, 46,116,121,112,101, 32,126, 61, 32, 39, 39, + 32, 97,110,100, 32,115,101,108,102, 46,116,121,112,101, 32, + 126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10, + 32, 32, 32,110,114,101,116, 32, 61, 32,110,114,101,116, 32, + 43, 32, 49, 10, 32, 32, 32,108,111, 99, 97,108, 32,116, 44, + 99,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101, + 108,102, 46,116,121,112,101, 41, 10, 32, 32, 32,105,102, 32, + 116, 32,116,104,101,110, 10, 32, 32, 32, 9,105,102, 32,115, + 101,108,102, 46, 99, 97,115,116, 95,111,112,101,114, 97,116, + 111,114, 32, 97,110,100, 32, 95, 98, 97,115,105, 99, 95,114, + 97,119, 95,112,117,115,104, 91,116, 93, 32,116,104,101,110, + 10, 9, 9,111,117,116,112,117,116, 40, 39, 32, 32, 32, 39, + 44, 95, 98, 97,115,105, 99, 95,114, 97,119, 95,112,117,115, + 104, 91,116, 93, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, + 40, 39, 44, 99,116, 44, 39, 41,116,111,108,117, 97, 95,114, + 101,116, 41, 59, 39, 41, 10, 32, 32, 32, 9,101,108,115,101, + 10, 9, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32, 32,116,111,108,117, 97, 95,112,117,115,104, 39, 46, 46, + 116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39, + 44, 99,116, 44, 39, 41,116,111,108,117, 97, 95,114,101,116, + 41, 59, 39, 41, 10, 9,101,110,100, 10, 32, 32, 32,101,108, + 115,101, 10, 9,116, 32, 61, 32,115,101,108,102, 46,116,121, + 112,101, 10, 9,110,101,119, 95,116, 32, 61, 32,115,116,114, + 105,110,103, 46,103,115,117, 98, 40,116, 44, 32, 34, 99,111, + 110,115,116, 37,115, 43, 34, 44, 32, 34, 34, 41, 10, 9,108, + 111, 99, 97,108, 32,111,119,110,101,100, 32, 61, 32,102, 97, + 108,115,101, 10, 9,105,102, 32,115,116,114,105,110,103, 46, + 102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 32, + 34,116,111,108,117, 97, 95,111,119,110,101,100, 34, 41, 32, + 116,104,101,110, 10, 9, 9,111,119,110,101,100, 32, 61, 32, + 116,114,117,101, 10, 9,101,110,100, 10, 32, 32, 32, 32,108, + 111, 99, 97,108, 32,112,117,115,104, 95,102,117,110, 99, 32, + 61, 32,103,101,116, 95,112,117,115,104, 95,102,117,110, 99, + 116,105,111,110, 40,116, 41, 10, 32, 32, 32, 32,105,102, 32, + 115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 39, 32, + 116,104,101,110, 10, 32, 32, 32, 32, 32,111,117,116,112,117, + 116, 40, 39, 32, 32, 32,123, 39, 41, 10, 32, 32, 32, 32, 32, + 111,117,116,112,117,116, 40, 39, 35,105,102,100,101,102, 32, + 95, 95, 99,112,108,117,115,112,108,117,115, 92,110, 39, 41, + 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32, 32, 32,118,111,105,100, 42, 32,116,111,108,117, 97, 95, + 111, 98,106, 32, 61, 32, 77,116,111,108,117, 97, 95,110,101, + 119, 40, 40, 39, 44,110,101,119, 95,116, 44, 39, 41, 40,116, + 111,108,117, 97, 95,114,101,116, 41, 41, 59, 39, 41, 10, 32, + 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, + 32, 39, 44,112,117,115,104, 95,102,117,110, 99, 44, 39, 40, + 116,111,108,117, 97, 95, 83, 44,116,111,108,117, 97, 95,111, + 98,106, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, + 32, 32,116,111,108,117, 97, 95,114,101,103,105,115,116,101, + 114, 95,103, 99, 40,116,111,108,117, 97, 95, 83, 44,108,117, + 97, 95,103,101,116,116,111,112, 40,116,111,108,117, 97, 95, + 83, 41, 41, 59, 39, 41, 10, 32, 32, 32, 32, 32,111,117,116, + 112,117,116, 40, 39, 35,101,108,115,101, 92,110, 39, 41, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, + 32, 32,118,111,105,100, 42, 32,116,111,108,117, 97, 95,111, + 98,106, 32, 61, 32,116,111,108,117, 97, 95, 99,111,112,121, + 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, + 41, 38,116,111,108,117, 97, 95,114,101,116, 44,115,105,122, + 101,111,102, 40, 39, 44,116, 44, 39, 41, 41, 59, 39, 41, 10, + 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, + 32, 32, 39, 44,112,117,115,104, 95,102,117,110, 99, 44, 39, + 40,116,111,108,117, 97, 95, 83, 44,116,111,108,117, 97, 95, + 111, 98,106, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, + 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, + 32, 32, 32,116,111,108,117, 97, 95,114,101,103,105,115,116, + 101,114, 95,103, 99, 40,116,111,108,117, 97, 95, 83, 44,108, + 117, 97, 95,103,101,116,116,111,112, 40,116,111,108,117, 97, + 95, 83, 41, 41, 59, 39, 41, 10, 32, 32, 32, 32, 32,111,117, + 116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, + 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, + 32, 32, 32,125, 39, 41, 10, 32, 32, 32, 32,101,108,115,101, + 105,102, 32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, + 39, 38, 39, 32,116,104,101,110, 10, 32, 32, 32, 32, 32,111, + 117,116,112,117,116, 40, 39, 32, 32, 32, 39, 44,112,117,115, + 104, 95,102,117,110, 99, 44, 39, 40,116,111,108,117, 97, 95, + 83, 44, 40,118,111,105,100, 42, 41, 38,116,111,108,117, 97, + 95,114,101,116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, + 41, 10, 32, 32, 32, 32,101,108,115,101, 10, 9, 32,111,117, + 116,112,117,116, 40, 39, 32, 32, 32, 39, 44,112,117,115,104, + 95,102,117,110, 99, 44, 39, 40,116,111,108,117, 97, 95, 83, + 44, 40,118,111,105,100, 42, 41,116,111,108,117, 97, 95,114, + 101,116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, + 9, 32,105,102, 32,111,119,110,101,100, 32,111,114, 32,108, + 111, 99, 97,108, 95, 99,111,110,115,116,114,117, 99,116,111, + 114, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,111,117, + 116,112,117,116, 40, 39, 32, 32, 32, 32,116,111,108,117, 97, + 95,114,101,103,105,115,116,101,114, 95,103, 99, 40,116,111, + 108,117, 97, 95, 83, 44,108,117, 97, 95,103,101,116,116,111, + 112, 40,116,111,108,117, 97, 95, 83, 41, 41, 59, 39, 41, 10, + 9, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10, 32, + 32, 32,101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,108, + 111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,119,104,105,108, + 101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32, + 100,111, 10, 32, 32, 32,110,114,101,116, 32, 61, 32,110,114, + 101,116, 32, 43, 32,115,101,108,102, 46, 97,114,103,115, 91, + 105, 93, 58,114,101,116,118, 97,108,117,101, 40, 41, 10, 32, + 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100, + 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,125, 39, + 41, 10, 10, 32, 32, 45, 45, 32,115,101,116, 32, 97,114,114, + 97,121, 32,101,108,101,109,101,110,116, 32,118, 97,108,117, + 101,115, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32,116, + 104,101,110, 32,110, 97,114,103, 61, 50, 32,101,108,115,101, + 32,110, 97,114,103, 61, 49, 32,101,110,100, 10, 32, 32,105, + 102, 32,115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 46, + 116,121,112,101, 32,126, 61, 32, 39,118,111,105,100, 39, 32, + 116,104,101,110, 10, 32, 32, 32,108,111, 99, 97,108, 32,105, + 61, 49, 10, 32, 32, 32,119,104,105,108,101, 32,115,101,108, + 102, 46, 97,114,103,115, 91,105, 93, 32,100,111, 10, 32, 32, + 32, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58, + 115,101,116, 97,114,114, 97,121, 40,110, 97,114,103, 41, 10, + 32, 32, 32, 32,110, 97,114,103, 32, 61, 32,110, 97,114,103, + 43, 49, 10, 32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, + 32, 32, 32,101,110,100, 10, 32, 32,101,110,100, 10, 10, 32, + 32, 45, 45, 32,102,114,101,101, 32,100,121,110, 97,109,105, + 99, 97,108,108,121, 32, 97,108,108,111, 99, 97,116,101,100, + 32, 97,114,114, 97,121, 10, 32, 32,105,102, 32,115,101,108, + 102, 46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101, 32, + 126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10, + 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32, + 32,119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103, + 115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32,115,101,108, + 102, 46, 97,114,103,115, 91,105, 93, 58,102,114,101,101, 97, + 114,114, 97,121, 40, 41, 10, 32, 32, 32, 32,105, 32, 61, 32, + 105, 43, 49, 10, 32, 32, 32,101,110,100, 10, 32, 32,101,110, + 100, 10, 32,101,110,100, 10, 10, 32,111,117,116,112,117,116, + 40, 39, 32,125, 39, 41, 10, 32,111,117,116,112,117,116, 40, + 39, 32,114,101,116,117,114,110, 32, 39, 46, 46,110,114,101, + 116, 46, 46, 39, 59, 39, 41, 10, 10, 32, 45, 45, 32, 99, 97, + 108,108, 32,111,118,101,114,108,111, 97,100,101,100, 32,102, + 117,110, 99,116,105,111,110, 32,111,114, 32,103,101,110,101, + 114, 97,116,101, 32,101,114,114,111,114, 10, 9,105,102, 32, + 111,118,101,114,108,111, 97,100, 32, 60, 32, 48, 32,116,104, + 101,110, 10, 10, 9, 9,111,117,116,112,117,116, 40, 39, 35, + 105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, + 76, 69, 65, 83, 69, 92,110, 39, 41, 10, 9, 9,111,117,116, + 112,117,116, 40, 39,116,111,108,117, 97, 95,108,101,114,114, + 111,114, 58, 92,110, 39, 41, 10, 9, 9,111,117,116,112,117, + 116, 40, 39, 32,116,111,108,117, 97, 95,101,114,114,111,114, + 40,116,111,108,117, 97, 95, 83, 44, 34, 35,102,101,114,114, + 111,114, 32,105,110, 32,102,117,110, 99,116,105,111,110, 32, + 92, 39, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101, + 46, 46, 39, 92, 39, 46, 34, 44, 38,116,111,108,117, 97, 95, + 101,114,114, 41, 59, 39, 41, 10, 9, 9,111,117,116,112,117, + 116, 40, 39, 32,114,101,116,117,114,110, 32, 48, 59, 39, 41, + 10, 9, 9,111,117,116,112,117,116, 40, 39, 35,101,110,100, + 105,102, 92,110, 39, 41, 10, 9,101,108,115,101, 10, 9, 9, + 108,111, 99, 97,108, 32, 95,108,111, 99, 97,108, 32, 61, 32, + 34, 34, 10, 9, 9,105,102, 32,108,111, 99, 97,108, 95, 99, + 111,110,115,116,114,117, 99,116,111,114, 32,116,104,101,110, + 10, 9, 9, 9, 95,108,111, 99, 97,108, 32, 61, 32, 34, 95, + 108,111, 99, 97,108, 34, 10, 9, 9,101,110,100, 10, 9, 9, + 111,117,116,112,117,116, 40, 39,116,111,108,117, 97, 95,108, + 101,114,114,111,114, 58, 92,110, 39, 41, 10, 9, 9,111,117, + 116,112,117,116, 40, 39, 32,114,101,116,117,114,110, 32, 39, + 46, 46,115,116,114,115,117, 98, 40,115,101,108,102, 46, 99, + 110, 97,109,101, 44, 49, 44, 45, 51, 41, 46, 46,102,111,114, + 109, 97,116, 40, 34, 37, 48, 50,100, 34, 44,111,118,101,114, + 108,111, 97,100, 41, 46, 46, 95,108,111, 99, 97,108, 46, 46, + 39, 40,116,111,108,117, 97, 95, 83, 41, 59, 39, 41, 10, 9, + 101,110,100, 10, 32,111,117,116,112,117,116, 40, 39,125, 39, + 41, 10, 32,111,117,116,112,117,116, 40, 39, 35,101,110,100, + 105,102, 32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79, + 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, + 10, 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10, + 10, 9, 45, 45, 32,114,101, 99,117,114,115,105,118,101, 32, + 99, 97,108,108, 32,116,111, 32,119,114,105,116,101, 32,108, + 111, 99, 97,108, 32, 99,111,110,115,116,114,117, 99,116,111, + 114, 10, 9,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, + 32,115,101,108,102, 46,110, 97,109,101, 61, 61, 39,110,101, + 119, 39, 32, 97,110,100, 32,110,111,116, 32,108,111, 99, 97, + 108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 32,116, + 104,101,110, 10, 10, 9, 9,115,101,108,102, 58,115,117,112, + 99,111,100,101, 40, 49, 41, 10, 9,101,110,100, 10, 10,101, + 110,100, 10, 10, 10, 45, 45, 32,114,101,103,105,115,116,101, + 114, 32,102,117,110, 99,116,105,111,110, 10,102,117,110, 99, + 116,105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,116, + 105,111,110, 58,114,101,103,105,115,116,101,114, 32, 40,112, + 114,101, 41, 10, 10, 9,105,102, 32,110,111,116, 32,115,101, + 108,102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, + 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10, + 9, 9,114,101,116,117,114,110, 10, 9,101,110,100, 10, 10, + 32, 9,105,102, 32,115,101,108,102, 46,110, 97,109,101, 32, + 61, 61, 32, 39,110,101,119, 39, 32, 97,110,100, 32,115,101, + 108,102, 46,112, 97,114,101,110,116, 46,102,108, 97,103,115, + 46,112,117,114,101, 95,118,105,114,116,117, 97,108, 32,116, + 104,101,110, 10, 32, 9, 9, 45, 45, 32,110,111, 32, 99,111, + 110,115,116,114,117, 99,116,111,114, 32,102,111,114, 32, 99, + 108, 97,115,115,101,115, 32,119,105,116,104, 32,112,117,114, + 101, 32,118,105,114,116,117, 97,108, 32,109,101,116,104,111, + 100,115, 10, 32, 9, 9,114,101,116,117,114,110, 10, 32, 9, + 101,110,100, 10, 10, 32,111,117,116,112,117,116, 40,112,114, + 101, 46, 46, 39,116,111,108,117, 97, 95,102,117,110, 99,116, + 105,111,110, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, + 46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, + 44, 39, 46, 46,115,101,108,102, 46, 99,110, 97,109,101, 46, + 46, 39, 41, 59, 39, 41, 10, 32, 32,105,102, 32,115,101,108, + 102, 46,110, 97,109,101, 32, 61, 61, 32, 39,110,101,119, 39, + 32,116,104,101,110, 10, 9, 32, 32,111,117,116,112,117,116, + 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95,102,117, + 110, 99,116,105,111,110, 40,116,111,108,117, 97, 95, 83, 44, + 34,110,101,119, 95,108,111, 99, 97,108, 34, 44, 39, 46, 46, + 115,101,108,102, 46, 99,110, 97,109,101, 46, 46, 39, 95,108, + 111, 99, 97,108, 41, 59, 39, 41, 10, 9, 32, 32,111,117,116, + 112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, + 95,102,117,110, 99,116,105,111,110, 40,116,111,108,117, 97, + 95, 83, 44, 34, 46, 99, 97,108,108, 34, 44, 39, 46, 46,115, + 101,108,102, 46, 99,110, 97,109,101, 46, 46, 39, 95,108,111, + 99, 97,108, 41, 59, 39, 41, 10, 9, 32, 32, 45, 45,111,117, + 116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,115,101, + 116, 95, 99, 97,108,108, 95,101,118,101,110,116, 40,116,111, + 108,117, 97, 95, 83, 44, 39, 46, 46,115,101,108,102, 46, 99, + 110, 97,109,101, 46, 46, 39, 95,108,111, 99, 97,108, 44, 32, + 34, 39, 46, 46,115,101,108,102, 46,112, 97,114,101,110,116, + 46,116,121,112,101, 46, 46, 39, 34, 41, 59, 39, 41, 10, 32, + 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 80,114, + 105,110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99, + 116,105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,116, + 105,111,110, 58,112,114,105,110,116, 32, 40,105,100,101,110, + 116, 44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, + 40,105,100,101,110,116, 46, 46, 34, 70,117,110, 99,116,105, + 111,110,123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100, + 101,110,116, 46, 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, + 34, 46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, + 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110, + 116, 46, 46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, + 46,115,101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, + 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, + 46, 46, 34, 32,112,116,114, 32, 32, 61, 32, 39, 34, 46, 46, + 115,101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34, 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101, + 108,102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101, + 108,102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34, 32, 99,111,110,115,116, 32, 61, 32, 39, 34, 46, 46,115, + 101,108,102, 46, 99,111,110,115,116, 46, 46, 34, 39, 44, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32, 99,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46, + 115,101,108,102, 46, 99,110, 97,109,101, 46, 46, 34, 39, 44, + 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, + 46, 46, 34, 32,108,110, 97,109,101, 32, 61, 32, 39, 34, 46, + 46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, 34, 39, + 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110, + 116, 46, 46, 34, 32, 97,114,103,115, 32, 61, 32,123, 34, 41, + 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104, + 105,108,101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, + 93, 32,100,111, 10, 32, 32,115,101,108,102, 46, 97,114,103, + 115, 91,105, 93, 58,112,114,105,110,116, 40,105,100,101,110, + 116, 46, 46, 34, 32, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32, + 105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112, + 114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,125, + 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, + 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101, + 110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, + 32,105,116, 32,114,101,116,117,114,110,115, 32, 97,110, 32, + 111, 98,106,101, 99,116, 32, 98,121, 32,118, 97,108,117,101, + 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, + 70,117,110, 99,116,105,111,110, 58,114,101,113,117,105,114, + 101, 99,111,108,108,101, 99,116,105,111,110, 32, 40,116, 41, + 10, 9,108,111, 99, 97,108, 32,114, 32, 61, 32,102, 97,108, + 115,101, 10, 9,105,102, 32,115,101,108,102, 46,116,121,112, + 101, 32,126, 61, 32, 39, 39, 32, 97,110,100, 32,110,111,116, + 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116, + 121,112,101, 41, 32, 97,110,100, 32,115,101,108,102, 46,112, + 116,114, 61, 61, 39, 39, 32,116,104,101,110, 10, 9, 9,108, + 111, 99, 97,108, 32,116,121,112,101, 32, 61, 32,103,115,117, + 98, 40,115,101,108,102, 46,116,121,112,101, 44, 34, 37,115, + 42, 99,111,110,115,116, 37,115, 43, 34, 44, 34, 34, 41, 10, + 9, 32,116, 91,116,121,112,101, 93, 32, 61, 32, 34,116,111, + 108,117, 97, 95, 99,111,108,108,101, 99,116, 95, 34, 32, 46, + 46, 32, 99,108,101, 97,110, 95,116,101,109,112,108, 97,116, + 101, 40,116,121,112,101, 41, 10, 9, 32,114, 32, 61, 32,116, + 114,117,101, 10, 9,101,110,100, 10, 9,108,111, 99, 97,108, + 32,105, 61, 49, 10, 9,119,104,105,108,101, 32,115,101,108, + 102, 46, 97,114,103,115, 91,105, 93, 32,100,111, 10, 9, 9, + 114, 32, 61, 32,115,101,108,102, 46, 97,114,103,115, 91,105, + 93, 58,114,101,113,117,105,114,101, 99,111,108,108,101, 99, + 116,105,111,110, 40,116, 41, 32,111,114, 32,114, 10, 9, 9, + 105, 32, 61, 32,105, 43, 49, 10, 9,101,110,100, 10, 9,114, + 101,116,117,114,110, 32,114, 10,101,110,100, 10, 10, 45, 45, + 32,100,101,116,101,114,109,105,110,101, 32,108,117, 97, 32, + 102,117,110, 99,116,105,111,110, 32,110, 97,109,101, 32,111, + 118,101,114,108,111, 97,100, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108, 97,115,115, 70,117,110, 99,116,105,111,110, + 58,111,118,101,114,108,111, 97,100, 32, 40, 41, 10, 32,114, + 101,116,117,114,110, 32,115,101,108,102, 46,112, 97,114,101, + 110,116, 58,111,118,101,114,108,111, 97,100, 40,115,101,108, + 102, 46,108,110, 97,109,101, 41, 10,101,110,100, 10, 10, 10, + 102,117,110, 99,116,105,111,110, 32,112, 97,114, 97,109, 95, + 111, 98,106,101, 99,116, 40,112, 97,114, 41, 32, 45, 45, 32, + 114,101,116,117,114,110,115, 32,116,114,117,101, 32,105,102, + 32,116,104,101, 32,112, 97,114, 97,109,101,116,101,114, 32, + 104, 97,115, 32, 97,110, 32,111, 98,106,101, 99,116, 32, 97, + 115, 32,105,116,115, 32,100,101,102, 97,117,108,116, 32,118, + 97,108,117,101, 10, 10, 9,105,102, 32,110,111,116, 32,115, + 116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114, 44, + 32, 39, 61, 39, 41, 32,116,104,101,110, 32,114,101,116,117, + 114,110, 32,102, 97,108,115,101, 32,101,110,100, 32, 45, 45, + 32,105,116, 32,104, 97,115, 32,110,111, 32,100,101,102, 97, + 117,108,116, 32,118, 97,108,117,101, 10, 10, 9,108,111, 99, + 97,108, 32, 95, 44, 95, 44,100,101,102, 32, 61, 32,115,116, + 114,105,110,103, 46,102,105,110,100, 40,112, 97,114, 44, 32, + 34, 61, 40, 46, 42, 41, 36, 34, 41, 10, 10, 9,105,102, 32, + 115,116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114, + 44, 32, 34,124, 34, 41, 32,116,104,101,110, 32, 45, 45, 32, + 97, 32,108,105,115,116, 32,111,102, 32,102,108, 97,103,115, + 10, 10, 9, 9,114,101,116,117,114,110, 32,116,114,117,101, + 10, 9,101,110,100, 10, 10, 9,105,102, 32,115,116,114,105, + 110,103, 46,102,105,110,100, 40,112, 97,114, 44, 32, 34, 37, + 42, 34, 41, 32,116,104,101,110, 32, 45, 45, 32,105,116, 39, + 115, 32, 97, 32,112,111,105,110,116,101,114, 32,119,105,116, + 104, 32, 97, 32,100,101,102, 97,117,108,116, 32,118, 97,108, + 117,101, 10, 10, 9, 9,105,102, 32,115,116,114,105,110,103, + 46,102,105,110,100, 40,112, 97,114, 44, 32, 39, 61, 37,115, + 42,110,101,119, 39, 41, 32,111,114, 32,115,116,114,105,110, + 103, 46,102,105,110,100, 40,112, 97,114, 44, 32, 34, 37, 40, + 34, 41, 32,116,104,101,110, 32, 45, 45, 32,105,116, 39,115, + 32, 97, 32,112,111,105,110,116,101,114, 32,119,105,116,104, + 32, 97,110, 32,105,110,115,116, 97,110, 99,101, 32, 97,115, + 32,100,101,102, 97,117,108,116, 32,112, 97,114, 97,109,101, + 116,101,114, 46, 46, 32,105,115, 32,116,104, 97,116, 32,118, + 97,108,105,100, 63, 10, 9, 9, 9,114,101,116,117,114,110, + 32,116,114,117,101, 10, 9, 9,101,110,100, 10, 9, 9,114, + 101,116,117,114,110, 32,102, 97,108,115,101, 32, 45, 45, 32, + 100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 32,105, + 115, 32, 39, 78, 85, 76, 76, 39, 32,111,114, 32,115,111,109, + 101,116,104,105,110,103, 10, 9,101,110,100, 10, 10, 10, 9, + 105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, + 112, 97,114, 44, 32, 34, 91, 37, 40, 38, 93, 34, 41, 32,116, + 104,101,110, 10, 9, 9,114,101,116,117,114,110, 32,116,114, + 117,101, 10, 9,101,110,100, 32, 45, 45, 32,100,101,102, 97, + 117,108,116, 32,118, 97,108,117,101, 32,105,115, 32, 97, 32, + 99,111,110,115,116,114,117, 99,116,111,114, 32, 99, 97,108, + 108, 32, 40,109,111,115,116, 32,108,105,107,101,108,121, 32, + 102,111,114, 32, 97, 32, 99,111,110,115,116, 32,114,101,102, + 101,114,101,110, 99,101, 41, 10, 10, 9, 45, 45,105,102, 32, + 115,116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114, + 44, 32, 34, 38, 34, 41, 32,116,104,101,110, 10, 10, 9, 45, + 45, 9,105,102, 32,115,116,114,105,110,103, 46,102,105,110, + 100, 40,100,101,102, 44, 32, 34, 58, 34, 41, 32,111,114, 32, + 115,116,114,105,110,103, 46,102,105,110,100, 40,100,101,102, + 44, 32, 34, 94, 37,115, 42,110,101,119, 37,115, 43, 34, 41, + 32,116,104,101,110, 10, 10, 9, 45, 45, 9, 9, 45, 45, 32, + 105,116, 39,115, 32, 97, 32,114,101,102,101,114,101,110, 99, + 101, 32,119,105,116,104, 32,100,101,102, 97,117,108,116, 32, + 116,111, 32,115,111,109,101,116,104,105,110,103, 32,108,105, + 107,101, 32, 67,108, 97,115,115, 58, 58,109,101,109, 98,101, + 114, 44, 32,111,114, 32, 39,110,101,119, 32, 67,108, 97,115, + 115, 39, 10, 9, 45, 45, 9, 9,114,101,116,117,114,110, 32, + 116,114,117,101, 10, 9, 45, 45, 9,101,110,100, 10, 9, 45, + 45,101,110,100, 10, 10, 9,114,101,116,117,114,110, 32,102, + 97,108,115,101, 32, 45, 45, 32, 63, 10,101,110,100, 10, 10, + 102,117,110, 99,116,105,111,110, 32,115,116,114,105,112, 95, + 108, 97,115,116, 95, 97,114,103, 40, 97,108,108, 95, 97,114, + 103,115, 44, 32,108, 97,115,116, 95, 97,114,103, 41, 32, 45, + 45, 32,115,116,114,105,112,115, 32,116,104,101, 32,100,101, + 102, 97,117,108,116, 32,118, 97,108,117,101, 32,102,114,111, + 109, 32,116,104,101, 32,108, 97,115,116, 32, 97,114,103,117, + 109,101,110,116, 10, 10, 9,108,111, 99, 97,108, 32, 95, 44, + 95, 44,115, 95, 97,114,103, 32, 61, 32,115,116,114,105,110, + 103, 46,102,105,110,100, 40,108, 97,115,116, 95, 97,114,103, + 44, 32, 34, 94, 40, 91, 94, 61, 93, 43, 41, 34, 41, 10, 9, + 108, 97,115,116, 95, 97,114,103, 32, 61, 32,115,116,114,105, + 110,103, 46,103,115,117, 98, 40,108, 97,115,116, 95, 97,114, + 103, 44, 32, 34, 40, 91, 37, 37, 37, 40, 37, 41, 93, 41, 34, + 44, 32, 34, 37, 37, 37, 49, 34, 41, 59, 10, 9, 97,108,108, + 95, 97,114,103,115, 32, 61, 32,115,116,114,105,110,103, 46, + 103,115,117, 98, 40, 97,108,108, 95, 97,114,103,115, 44, 32, + 34, 37,115, 42, 44, 37,115, 42, 34, 46, 46,108, 97,115,116, + 95, 97,114,103, 46, 46, 34, 37,115, 42, 37, 41, 37,115, 42, + 36, 34, 44, 32, 34, 41, 34, 41, 10, 9,114,101,116,117,114, + 110, 32, 97,108,108, 95, 97,114,103,115, 44, 32,115, 95, 97, + 114,103, 10,101,110,100, 10, 10, 10, 10, 45, 45, 32, 73,110, + 116,101,114,110, 97,108, 32, 99,111,110,115,116,114,117, 99, + 116,111,114, 10,102,117,110, 99,116,105,111,110, 32, 95, 70, + 117,110, 99,116,105,111,110, 32, 40,116, 41, 10, 32,115,101, + 116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,108, + 97,115,115, 70,117,110, 99,116,105,111,110, 41, 10, 10, 32, + 105,102, 32,116, 46, 99,111,110,115,116, 32,126, 61, 32, 39, + 99,111,110,115,116, 39, 32, 97,110,100, 32,116, 46, 99,111, + 110,115,116, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 10, + 32, 32,101,114,114,111,114, 40, 34, 35,105,110,118, 97,108, + 105,100, 32, 39, 99,111,110,115,116, 39, 32,115,112,101, 99, + 105,102,105, 99, 97,116,105,111,110, 34, 41, 10, 32,101,110, + 100, 10, 10, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32, + 105,102, 32,116, 58,105,110, 99,108, 97,115,115, 40, 41, 32, + 116,104,101,110, 10, 32, 45, 45,112,114,105,110,116, 32, 40, + 39,116, 46,110, 97,109,101, 32,105,115, 32, 39, 46, 46,116, + 46,110, 97,109,101, 46, 46, 39, 44, 32,112, 97,114,101,110, + 116, 46,110, 97,109,101, 32,105,115, 32, 39, 46, 46,116, 46, + 112, 97,114,101,110,116, 46,110, 97,109,101, 41, 10, 32, 32, + 105,102, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, + 116, 46,110, 97,109,101, 44, 32, 34, 37, 98, 60, 62, 34, 44, + 32, 34, 34, 41, 32, 61, 61, 32,115,116,114,105,110,103, 46, + 103,115,117, 98, 40,116, 46,112, 97,114,101,110,116, 46,111, + 114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,111,114, + 32,116, 46,112, 97,114,101,110,116, 46,110, 97,109,101, 44, + 32, 34, 37, 98, 60, 62, 34, 44, 32, 34, 34, 41, 32,116,104, + 101,110, 10, 32, 32, 32,116, 46,110, 97,109,101, 32, 61, 32, + 39,110,101,119, 39, 10, 32, 32, 32,116, 46,108,110, 97,109, + 101, 32, 61, 32, 39,110,101,119, 39, 10, 32, 32, 32,116, 46, + 112, 97,114,101,110,116, 46, 95,110,101,119, 32, 61, 32,116, + 114,117,101, 10, 32, 32, 32,116, 46,116,121,112,101, 32, 61, + 32,116, 46,112, 97,114,101,110,116, 46,110, 97,109,101, 10, + 32, 32, 32,116, 46,112,116,114, 32, 61, 32, 39, 42, 39, 10, + 32, 32,101,108,115,101,105,102, 32,115,116,114,105,110,103, + 46,103,115,117, 98, 40,116, 46,110, 97,109,101, 44, 32, 34, + 37, 98, 60, 62, 34, 44, 32, 34, 34, 41, 32, 61, 61, 32, 39, + 126, 39, 46, 46,115,116,114,105,110,103, 46,103,115,117, 98, + 40,116, 46,112, 97,114,101,110,116, 46,111,114,105,103,105, + 110, 97,108, 95,110, 97,109,101, 32,111,114, 32,116, 46,112, + 97,114,101,110,116, 46,110, 97,109,101, 44, 32, 34, 37, 98, + 60, 62, 34, 44, 32, 34, 34, 41, 32,116,104,101,110, 10, 32, + 32, 32,116, 46,110, 97,109,101, 32, 61, 32, 39,100,101,108, + 101,116,101, 39, 10, 32, 32, 32,116, 46,108,110, 97,109,101, + 32, 61, 32, 39,100,101,108,101,116,101, 39, 10, 32, 32, 32, + 116, 46,112, 97,114,101,110,116, 46, 95,100,101,108,101,116, + 101, 32, 61, 32,116,114,117,101, 10, 32, 32,101,110,100, 10, + 32,101,110,100, 10, 32,116, 46, 99,110, 97,109,101, 32, 61, + 32,116, 58, 99,102,117,110, 99,110, 97,109,101, 40, 34,116, + 111,108,117, 97, 34, 41, 46, 46,116, 58,111,118,101,114,108, + 111, 97,100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32, + 116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116, + 114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99, + 116,115, 32,116,104,114,101,101, 32,115,116,114,105,110,103, + 115, 58, 32,111,110,101, 32,114,101,112,114,101,115,101,110, + 116,105,110,103, 32,116,104,101, 32,102,117,110, 99,116,105, + 111,110, 32,100,101, 99,108, 97,114, 97,116,105,111,110, 44, + 10, 45, 45, 32, 97,110,111,116,104,101,114, 32,114,101,112, + 114,101,115,101,110,116,105,110,103, 32,116,104,101, 32, 97, + 114,103,117,109,101,110,116, 32,108,105,115,116, 44, 32, 97, + 110,100, 32,116,104,101, 32,116,104,105,114,100, 32,114,101, + 112,114,101,115,101,110,116,105,110,103, 10, 45, 45, 32,116, + 104,101, 32, 34, 99,111,110,115,116, 34, 32,111,114, 32,101, + 109,112,116,121, 32,115,116,114,105,110,103, 46, 10,102,117, + 110, 99,116,105,111,110, 32, 70,117,110, 99,116,105,111,110, + 32, 40,100, 44, 97, 44, 99, 41, 10, 32, 45, 45,108,111, 99, + 97,108, 32,116, 32, 61, 32,115,112,108,105,116, 40,115,116, + 114,115,117, 98, 40, 97, 44, 50, 44, 45, 50, 41, 44, 39, 44, + 39, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101, + 32, 98,114, 97, 99,101,115, 10, 32, 45, 45,108,111, 99, 97, + 108, 32,116, 32, 61, 32,115,112,108,105,116, 95,112, 97,114, + 97,109,115, 40,115,116,114,115,117, 98, 40, 97, 44, 50, 44, + 45, 50, 41, 41, 10, 10, 9,105,102, 32,110,111,116, 32,102, + 108, 97,103,115, 91, 39, 87, 39, 93, 32, 97,110,100, 32,115, + 116,114,105,110,103, 46,102,105,110,100, 40, 97, 44, 32, 34, + 37, 46, 37, 46, 37, 46, 37,115, 42, 37, 41, 34, 41, 32,116, + 104,101,110, 10, 10, 9, 9,119, 97,114,110,105,110,103, 40, + 34, 70,117,110, 99,116,105,111,110,115, 32,119,105,116,104, + 32,118, 97,114,105, 97, 98,108,101, 32, 97,114,103,117,109, + 101,110,116,115, 32, 40, 96, 46, 46, 46, 39, 41, 32, 97,114, + 101, 32,110,111,116, 32,115,117,112,112,111,114,116,101,100, + 46, 32, 73,103,110,111,114,105,110,103, 32, 34, 46, 46,100, + 46, 46, 97, 46, 46, 99, 41, 10, 9, 9,114,101,116,117,114, + 110, 32,110,105,108, 10, 9,101,110,100, 10, 10, 10, 32,108, + 111, 99, 97,108, 32,105, 61, 49, 10, 32,108,111, 99, 97,108, + 32,108, 32, 61, 32,123,110, 61, 48,125, 10, 10, 32, 9, 97, + 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, + 97, 44, 32, 34, 37,115, 42, 40, 91, 37, 40, 37, 41, 93, 41, + 37,115, 42, 34, 44, 32, 34, 37, 49, 34, 41, 10, 9,108,111, + 99, 97,108, 32,116, 44,115,116,114,105,112, 44,108, 97,115, + 116, 32, 61, 32,115,116,114,105,112, 95,112, 97,114,115, 40, + 115,116,114,115,117, 98, 40, 97, 44, 50, 44, 45, 50, 41, 41, + 59, 10, 9,105,102, 32,115,116,114,105,112, 32,116,104,101, + 110, 10, 9, 9, 45, 45,108,111, 99, 97,108, 32,110,115, 32, + 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,115,116, + 114,115,117, 98, 40, 97, 44, 49, 44, 45, 50, 41, 44, 32, 49, + 44, 32, 45, 40,115,116,114,105,110,103, 46,108,101,110, 40, + 108, 97,115,116, 41, 43, 49, 41, 41, 10, 9, 9,108,111, 99, + 97,108, 32,110,115, 32, 61, 32,106,111,105,110, 40,116, 44, + 32, 34, 44, 34, 44, 32, 49, 44, 32,108, 97,115,116, 45, 49, + 41, 10, 10, 9, 9,110,115, 32, 61, 32, 34, 40, 34, 46, 46, + 115,116,114,105,110,103, 46,103,115,117, 98, 40,110,115, 44, + 32, 34, 37,115, 42, 44, 37,115, 42, 36, 34, 44, 32, 34, 34, + 41, 46, 46, 39, 41, 39, 10, 9, 9, 45, 45,110,115, 32, 61, + 32,115,116,114,105,112, 95,100,101,102, 97,117,108,116,115, + 40,110,115, 41, 10, 10, 9, 9, 70,117,110, 99,116,105,111, + 110, 40,100, 44, 32,110,115, 44, 32, 99, 41, 10, 9, 9,102, + 111,114, 32,105, 61, 49, 44,108, 97,115,116, 32,100,111, 10, + 9, 9, 9,116, 91,105, 93, 32, 61, 32,115,116,114,105,110, + 103, 46,103,115,117, 98, 40,116, 91,105, 93, 44, 32, 34, 61, + 46, 42, 36, 34, 44, 32, 34, 34, 41, 10, 9, 9,101,110,100, + 10, 9,101,110,100, 10, 10, 32,119,104,105,108,101, 32,116, + 91,105, 93, 32,100,111, 10, 32, 32,108, 46,110, 32, 61, 32, + 108, 46,110, 43, 49, 10, 32, 32,108, 91,108, 46,110, 93, 32, + 61, 32, 68,101, 99,108, 97,114, 97,116,105,111,110, 40,116, + 91,105, 93, 44, 39,118, 97,114, 39, 44,116,114,117,101, 41, + 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, + 10, 32,108,111, 99, 97,108, 32,102, 32, 61, 32, 68,101, 99, + 108, 97,114, 97,116,105,111,110, 40,100, 44, 39,102,117,110, + 99, 39, 41, 10, 32,102, 46, 97,114,103,115, 32, 61, 32,108, + 10, 32,102, 46, 99,111,110,115,116, 32, 61, 32, 99, 10, 32, + 114,101,116,117,114,110, 32, 95, 70,117,110, 99,116,105,111, + 110, 40,102, 41, 10,101,110,100, 10, 10,102,117,110, 99,116, + 105,111,110, 32,106,111,105,110, 40,116, 44, 32,115,101,112, + 44, 32,102,105,114,115,116, 44, 32,108, 97,115,116, 41, 10, + 10, 9,102,105,114,115,116, 32, 61, 32,102,105,114,115,116, + 32,111,114, 32, 49, 10, 9,108, 97,115,116, 32, 61, 32,108, + 97,115,116, 32,111,114, 32,116, 97, 98,108,101, 46,103,101, + 116,110, 40,116, 41, 10, 9,108,111, 99, 97,108, 32,108,115, + 101,112, 32, 61, 32, 34, 34, 10, 9,108,111, 99, 97,108, 32, + 114,101,116, 32, 61, 32, 34, 34, 10, 9,108,111, 99, 97,108, + 32,108,111,111,112, 32, 61, 32,102, 97,108,115,101, 10, 9, + 102,111,114, 32,105, 32, 61, 32,102,105,114,115,116, 44,108, + 97,115,116, 32,100,111, 10, 10, 9, 9,114,101,116, 32, 61, + 32,114,101,116, 46, 46,108,115,101,112, 46, 46,116, 91,105, + 93, 10, 9, 9,108,115,101,112, 32, 61, 32,115,101,112, 10, + 9, 9,108,111,111,112, 32, 61, 32,116,114,117,101, 10, 9, + 101,110,100, 10, 9,105,102, 32,110,111,116, 32,108,111,111, + 112, 32,116,104,101,110, 10, 9, 9,114,101,116,117,114,110, + 32, 34, 34, 10, 9,101,110,100, 10, 10, 9,114,101,116,117, + 114,110, 32,114,101,116, 10,101,110,100, 10, 10,102,117,110, + 99,116,105,111,110, 32,115,116,114,105,112, 95,112, 97,114, + 115, 40,115, 41, 10, 10, 9,108,111, 99, 97,108, 32,116, 32, + 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110, + 115, 40,115, 44, 32, 39, 44, 39, 41, 10, 9,108,111, 99, 97, + 108, 32,115,116,114,105,112, 32, 61, 32,102, 97,108,115,101, + 10, 9,108,111, 99, 97,108, 32,108, 97,115,116, 10, 10, 9, + 102,111,114, 32,105, 61,116, 46,110, 44, 49, 44, 45, 49, 32, + 100,111, 10, 10, 9, 9,105,102, 32,110,111,116, 32,115,116, + 114,105,112, 32, 97,110,100, 32,112, 97,114, 97,109, 95,111, + 98,106,101, 99,116, 40,116, 91,105, 93, 41, 32,116,104,101, + 110, 10, 9, 9, 9,108, 97,115,116, 32, 61, 32,105, 10, 9, + 9, 9,115,116,114,105,112, 32, 61, 32,116,114,117,101, 10, + 9, 9,101,110,100, 10, 9, 9, 45, 45,105,102, 32,115,116, + 114,105,112, 32,116,104,101,110, 10, 9, 9, 45, 45, 9,116, + 91,105, 93, 32, 61, 32,115,116,114,105,110,103, 46,103,115, + 117, 98, 40,116, 91,105, 93, 44, 32, 34, 61, 46, 42, 36, 34, + 44, 32, 34, 34, 41, 10, 9, 9, 45, 45,101,110,100, 10, 9, + 101,110,100, 10, 10, 9,114,101,116,117,114,110, 32,116, 44, + 115,116,114,105,112, 44,108, 97,115,116, 10, 10,101,110,100, + 10, 10,102,117,110, 99,116,105,111,110, 32,115,116,114,105, + 112, 95,100,101,102, 97,117,108,116,115, 40,115, 41, 10, 10, + 9,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, + 98, 40,115, 44, 32, 34, 94, 37, 40, 34, 44, 32, 34, 34, 41, + 10, 9,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115, + 117, 98, 40,115, 44, 32, 34, 37, 41, 36, 34, 44, 32, 34, 34, + 41, 10, 10, 9,108,111, 99, 97,108, 32,116, 32, 61, 32,115, + 112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, + 44, 32, 34, 44, 34, 41, 10, 9,108,111, 99, 97,108, 32,115, + 101,112, 44, 32,114,101,116, 32, 61, 32, 34, 34, 44, 34, 34, + 10, 9,102,111,114, 32,105, 61, 49, 44,116, 46,110, 32,100, + 111, 10, 9, 9,116, 91,105, 93, 32, 61, 32,115,116,114,105, + 110,103, 46,103,115,117, 98, 40,116, 91,105, 93, 44, 32, 34, + 61, 46, 42, 36, 34, 44, 32, 34, 34, 41, 10, 9, 9,114,101, + 116, 32, 61, 32,114,101,116, 46, 46,115,101,112, 46, 46,116, + 91,105, 93, 10, 9, 9,115,101,112, 32, 61, 32, 34, 44, 34, + 10, 9,101,110,100, 10, 10, 9,114,101,116,117,114,110, 32, + 34, 40, 34, 46, 46,114,101,116, 46, 46, 34, 41, 34, 10,101, + 110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/function.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32,111,112,101,114, 97, + 116,111,114, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114, + 105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, + 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, + 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, + 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73, + 100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99, + 111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102, + 116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32, + 114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, + 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32, + 105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116, + 119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104, + 101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, + 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105, + 115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97, + 117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98, + 108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111, + 118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99, + 101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, + 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99, + 101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105, + 102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, + 32, 79,112,101,114, 97,116,111,114, 32, 99,108, 97,115,115, + 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, + 97,110, 32,111,112,101,114, 97,116,111,114, 32,102,117,110, + 99,116,105,111,110, 32,111,114, 32, 97, 32, 99,108, 97,115, + 115, 32,111,112,101,114, 97,116,111,114, 32,109,101,116,104, + 111,100, 46, 10, 45, 45, 32, 73,116, 32,115,116,111,114,101, + 115, 32,116,104,101, 32,115, 97,109,101, 32,102,105,101,108, + 100,115, 32, 97,115, 32,102,117,110, 99,116,105,111,110,115, + 32,100,111, 32,112,108,117,115, 58, 10, 45, 45, 32, 32,107, + 105,110,100, 32, 61, 32,115,101,116, 32,111,102, 32, 99,104, + 97,114, 97, 99,116,101,114, 32,114,101,112,114,101,115,101, + 110,116,105,110,103, 32,116,104,101, 32,111,112,101,114, 97, + 116,111,114, 32, 40, 97,115, 32,105,116, 32, 97,112,112,101, + 114,115, 32,105,110, 32, 67, 43, 43, 32, 99,111,100,101, 41, + 10, 99,108, 97,115,115, 79,112,101,114, 97,116,111,114, 32, + 61, 32,123, 10, 32,107,105,110,100, 32, 61, 32, 39, 39, 44, + 10,125, 10, 99,108, 97,115,115, 79,112,101,114, 97,116,111, + 114, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97, + 115,115, 79,112,101,114, 97,116,111,114, 10,115,101,116,109, + 101,116, 97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 79, + 112,101,114, 97,116,111,114, 44, 99,108, 97,115,115, 70,117, + 110, 99,116,105,111,110, 41, 10, 10, 45, 45, 32,116, 97, 98, + 108,101, 32,116,111, 32,116,114, 97,110,115,102,111,114,109, + 32,111,112,101,114, 97,116,111,114, 32,107,105,110,100, 32, + 105,110,116,111, 32,116,104,101, 32, 97,112,112,114,111,112, + 114,105, 97,116,101, 32,116, 97,103, 32,109,101,116,104,111, + 100, 32,110, 97,109,101, 10, 95, 84, 77, 32, 61, 32,123, 91, + 39, 43, 39, 93, 32, 61, 32, 39, 97,100,100, 39, 44, 10, 32, + 32, 32, 32, 32, 32, 32, 91, 39, 45, 39, 93, 32, 61, 32, 39, + 115,117, 98, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, + 42, 39, 93, 32, 61, 32, 39,109,117,108, 39, 44, 10, 32, 32, + 32, 32, 32, 32, 32, 91, 39, 47, 39, 93, 32, 61, 32, 39,100, + 105,118, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 60, + 39, 93, 32, 61, 32, 39,108,116, 39, 44, 10, 32, 32, 32, 32, + 32, 32, 32, 91, 39, 60, 61, 39, 93, 32, 61, 32, 39,108,101, + 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 61, 61, 39, + 93, 32, 61, 32, 39,101,113, 39, 44, 10, 32, 32, 32, 32, 32, + 32, 32, 91, 39, 91, 93, 39, 93, 32, 61, 32, 39,103,101,116, + 105, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 38, 91, + 93, 39, 93, 32, 61, 32, 39,115,101,116,105, 39, 44, 10, 32, + 32, 32, 32, 32, 32, 32, 45, 45, 91, 39, 45, 62, 39, 93, 32, + 61, 32, 39,102,108,101, 99,104,105,116, 97, 39, 44, 10, 32, + 32, 32, 32, 32, 32,125, 10, 10, 10, 45, 45, 32, 80,114,105, + 110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 79,112,101,114, 97,116, + 111,114, 58,112,114,105,110,116, 32, 40,105,100,101,110,116, + 44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40, + 105,100,101,110,116, 46, 46, 34, 79,112,101,114, 97,116,111, + 114,123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 32,107,105,110,100, 32, 32, 61, 32, 39, + 34, 46, 46,115,101,108,102, 46,107,105,110,100, 46, 46, 34, + 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101, + 110,116, 46, 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, + 46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, + 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, + 46, 46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46, + 115,101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32,112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115, + 101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 99,111,110,115,116, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46, 99,111,110,115,116, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32, 99,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101, + 108,102, 46, 99,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34, 32,108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115, + 101,108,102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, + 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32, 97,114,103,115, 32, 61, 32,123, 34, 41, 10, 32, + 108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108, + 101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32, + 100,111, 10, 32, 32,115,101,108,102, 46, 97,114,103,115, 91, + 105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34, 32, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32, + 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105, + 110,116, 40,105,100,101,110,116, 46, 46, 34, 32,125, 34, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, + 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115, + 115, 79,112,101,114, 97,116,111,114, 58,115,117,112, 99,111, + 100,101, 95,116,109,112, 40, 41, 10, 10, 9,105,102, 32,110, + 111,116, 32, 95, 84, 77, 91,115,101,108,102, 46,107,105,110, + 100, 93, 32,116,104,101,110, 10, 9, 9,114,101,116,117,114, + 110, 32, 99,108, 97,115,115, 70,117,110, 99,116,105,111,110, + 46,115,117,112, 99,111,100,101, 40,115,101,108,102, 41, 10, + 9,101,110,100, 10, 10, 9, 45, 45, 32,110,111, 32,111,118, + 101,114,108,111, 97,100, 44, 32,110,111, 32,112, 97,114, 97, + 109,101,116,101,114,115, 44, 32, 97,108,119, 97,121,115, 32, + 105,110, 99,108, 97,115,115, 10, 9,111,117,116,112,117,116, + 40, 34, 47, 42, 32,109,101,116,104,111,100, 58, 34, 44,115, + 101,108,102, 46,110, 97,109,101, 44, 34, 32,111,102, 32, 99, + 108, 97,115,115, 32, 34, 44,115,101,108,102, 58,105,110, 99, + 108, 97,115,115, 40, 41, 44, 34, 32, 42, 47, 34, 41, 10, 10, + 9,111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101, + 102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, + 95, 34, 46, 46,115,101,108,102, 46, 99,110, 97,109,101, 41, + 10, 9,111,117,116,112,117,116, 40, 34, 92,110,115,116, 97, + 116,105, 99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99, + 110, 97,109,101, 44, 34, 40,108,117, 97, 95, 83,116, 97,116, + 101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34, 41, 10, 10, + 9,105,102, 32,111,118,101,114,108,111, 97,100, 32, 60, 32, + 48, 32,116,104,101,110, 10, 9, 32,111,117,116,112,117,116, + 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, + 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, 9,101, + 110,100, 10, 9,111,117,116,112,117,116, 40, 39, 32,116,111, + 108,117, 97, 95, 69,114,114,111,114, 32,116,111,108,117, 97, + 95,101,114,114, 59, 39, 41, 10, 9,111,117,116,112,117,116, + 40, 39, 32,105,102, 32, 40, 92,110, 39, 41, 10, 9, 45, 45, + 32, 99,104,101, 99,107, 32,115,101,108,102, 10, 9,108,111, + 99, 97,108, 32,105,115, 95,102,117,110, 99, 32, 61, 32,103, + 101,116, 95,105,115, 95,102,117,110, 99,116,105,111,110, 40, + 115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112, + 101, 41, 10, 9,111,117,116,112,117,116, 40, 39, 32, 32, 32, + 32, 32, 33, 39, 46, 46,105,115, 95,102,117,110, 99, 46, 46, + 39, 40,116,111,108,117, 97, 95, 83, 44, 49, 44, 34, 39, 46, + 46,115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121, + 112,101, 46, 46, 39, 34, 44, 48, 44, 38,116,111,108,117, 97, + 95,101,114,114, 41, 32,124,124, 92,110, 39, 41, 10, 9,111, + 117,116,112,117,116, 40, 39, 32, 32, 32, 32, 32, 33,116,111, + 108,117, 97, 95,105,115,110,111,111, 98,106, 40,116,111,108, + 117, 97, 95, 83, 44, 50, 44, 38,116,111,108,117, 97, 95,101, + 114,114, 41, 92,110, 32, 41, 39, 41, 10, 9,111,117,116,112, + 117,116, 40, 39, 32, 32,103,111,116,111, 32,116,111,108,117, + 97, 95,108,101,114,114,111,114, 59, 39, 41, 10, 10, 9,111, + 117,116,112,117,116, 40, 39, 32,101,108,115,101, 92,110, 39, + 41, 10, 9,111,117,116,112,117,116, 40, 39, 35,101,110,100, + 105,102, 92,110, 39, 41, 32, 45, 45, 32,116,111,108,117, 97, + 95,114,101,108,101, 97,115,101, 10, 9,111,117,116,112,117, + 116, 40, 39, 32,123, 39, 41, 10, 10, 9, 45, 45, 32,100,101, + 99,108, 97,114,101, 32,115,101,108,102, 10, 9,111,117,116, + 112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46, 99,111, + 110,115,116, 44,115,101,108,102, 46,112, 97,114,101,110,116, + 46,116,121,112,101, 44, 39, 42, 39, 44, 39,115,101,108,102, + 32, 61, 32, 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, + 40, 39, 44,115,101,108,102, 46, 99,111,110,115,116, 44,115, + 101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, + 44, 39, 42, 41, 32, 39, 41, 10, 9,108,111, 99, 97,108, 32, + 116,111, 95,102,117,110, 99, 32, 61, 32,103,101,116, 95,116, + 111, 95,102,117,110, 99, 40,115,101,108,102, 46,112, 97,114, + 101,110,116, 46,116,121,112,101, 41, 10, 9,111,117,116,112, + 117,116, 40,116,111, 95,102,117,110, 99, 44, 39, 40,116,111, + 108,117, 97, 95, 83, 44, 49, 44, 48, 41, 59, 39, 41, 10, 10, + 9, 45, 45, 32, 99,104,101, 99,107, 32,115,101,108,102, 10, + 9,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,101, + 102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, + 92,110, 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, 32, + 32,105,102, 32, 40, 33,115,101,108,102, 41, 32,116,111,108, + 117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95, + 83, 44, 34,105,110,118, 97,108,105,100, 32, 92, 39,115,101, + 108,102, 92, 39, 32,105,110, 32,102,117,110, 99,116,105,111, + 110, 32, 92, 39, 39, 46, 46,115,101,108,102, 46,110, 97,109, + 101, 46, 46, 39, 92, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, + 41, 59, 10, 9,111,117,116,112,117,116, 40, 39, 35,101,110, + 100,105,102, 92,110, 39, 41, 10, 10, 9, 45, 45, 32, 99, 97, + 115,116, 32,115,101,108,102, 10, 9,111,117,116,112,117,116, + 40, 39, 32, 32, 39, 44,115,101,108,102, 46,109,111,100, 44, + 115,101,108,102, 46,116,121,112,101, 44,115,101,108,102, 46, + 112,116,114, 44, 39,116,111,108,117, 97, 95,114,101,116, 32, + 61, 32, 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, 40, + 39, 44,115,101,108,102, 46,109,111,100, 44,115,101,108,102, + 46,116,121,112,101, 44,115,101,108,102, 46,112,116,114, 44, + 39, 41, 40, 42,115,101,108,102, 41, 59, 39, 41, 10, 10, 9, + 45, 45, 32,114,101,116,117,114,110, 32,118, 97,108,117,101, + 10, 9,108,111, 99, 97,108, 32,116, 44, 99,116, 32, 61, 32, + 105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116,121, + 112,101, 41, 10, 9,105,102, 32,116, 32,116,104,101,110, 10, + 9, 9,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111, + 108,117, 97, 95,112,117,115,104, 39, 46, 46,116, 46, 46, 39, + 40,116,111,108,117, 97, 95, 83, 44, 40, 39, 44, 99,116, 44, + 39, 41,116,111,108,117, 97, 95,114,101,116, 41, 59, 39, 41, + 10, 9,101,108,115,101, 10, 9, 9,116, 32, 61, 32,115,101, + 108,102, 46,116,121,112,101, 10, 9, 9,108,111, 99, 97,108, + 32,112,117,115,104, 95,102,117,110, 99, 32, 61, 32,103,101, + 116, 95,112,117,115,104, 95,102,117,110, 99,116,105,111,110, + 40,116, 41, 10, 9, 9,110,101,119, 95,116, 32, 61, 32,115, + 116,114,105,110,103, 46,103,115,117, 98, 40,116, 44, 32, 34, + 99,111,110,115,116, 37,115, 43, 34, 44, 32, 34, 34, 41, 10, + 9, 9,105,102, 32,115,101,108,102, 46,112,116,114, 32, 61, + 61, 32, 39, 39, 32,116,104,101,110, 10, 9, 9, 9,111,117, + 116,112,117,116, 40, 39, 32, 32, 32,123, 39, 41, 10, 9, 9, + 9,111,117,116,112,117,116, 40, 39, 35,105,102,100,101,102, + 32, 95, 95, 99,112,108,117,115,112,108,117,115, 92,110, 39, + 41, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, 32, + 32, 32,118,111,105,100, 42, 32,116,111,108,117, 97, 95,111, + 98,106, 32, 61, 32, 77,116,111,108,117, 97, 95,110,101,119, + 40, 40, 39, 44,110,101,119, 95,116, 44, 39, 41, 40,116,111, + 108,117, 97, 95,114,101,116, 41, 41, 59, 39, 41, 10, 9, 9, + 9,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32, 39, 44, + 112,117,115,104, 95,102,117,110, 99, 44, 39, 40,116,111,108, + 117, 97, 95, 83, 44,116,111,108,117, 97, 95,111, 98,106, 44, + 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 9, 9, 9, + 111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,116,111,108, + 117, 97, 95,114,101,103,105,115,116,101,114, 95,103, 99, 40, + 116,111,108,117, 97, 95, 83, 44,108,117, 97, 95,103,101,116, + 116,111,112, 40,116,111,108,117, 97, 95, 83, 41, 41, 59, 39, + 41, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, 35,101, + 108,115,101, 92,110, 39, 41, 10, 9, 9, 9,111,117,116,112, + 117,116, 40, 39, 32, 32, 32, 32,118,111,105,100, 42, 32,116, + 111,108,117, 97, 95,111, 98,106, 32, 61, 32,116,111,108,117, + 97, 95, 99,111,112,121, 40,116,111,108,117, 97, 95, 83, 44, + 40,118,111,105,100, 42, 41, 38,116,111,108,117, 97, 95,114, + 101,116, 44,115,105,122,101,111,102, 40, 39, 44,116, 44, 39, + 41, 41, 59, 39, 41, 10, 9, 9, 9,111,117,116,112,117,116, + 40, 39, 32, 32, 32, 32, 39, 44,112,117,115,104, 95,102,117, + 110, 99, 44, 39, 40,116,111,108,117, 97, 95, 83, 44,116,111, + 108,117, 97, 95,111, 98,106, 44, 34, 39, 44,116, 44, 39, 34, + 41, 59, 39, 41, 10, 9, 9, 9,111,117,116,112,117,116, 40, + 39, 32, 32, 32, 32,116,111,108,117, 97, 95,114,101,103,105, + 115,116,101,114, 95,103, 99, 40,116,111,108,117, 97, 95, 83, + 44,108,117, 97, 95,103,101,116,116,111,112, 40,116,111,108, + 117, 97, 95, 83, 41, 41, 59, 39, 41, 10, 9, 9, 9,111,117, + 116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, + 41, 10, 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, 32, + 32,125, 39, 41, 10, 9, 9,101,108,115,101,105,102, 32,115, + 101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 38, 39, 32, + 116,104,101,110, 10, 9, 9, 9,111,117,116,112,117,116, 40, + 39, 32, 32, 32, 39, 44,112,117,115,104, 95,102,117,110, 99, + 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105, + 100, 42, 41, 38,116,111,108,117, 97, 95,114,101,116, 44, 34, + 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 9, 9,101,108, + 115,101, 10, 9, 9, 9,105,102, 32,108,111, 99, 97,108, 95, + 99,111,110,115,116,114,117, 99,116,111,114, 32,116,104,101, + 110, 10, 9, 9, 9, 9,111,117,116,112,117,116, 40, 39, 32, + 32, 32, 39, 44,112,117,115,104, 95,102,117,110, 99, 44, 39, + 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 32, + 42, 41,116,111,108,117, 97, 95,114,101,116, 44, 34, 39, 44, + 116, 44, 39, 34, 41, 59, 39, 41, 10, 9, 9, 9, 9,111,117, + 116,112,117,116, 40, 39, 32, 32, 32, 32,116,111,108,117, 97, + 95,114,101,103,105,115,116,101,114, 95,103, 99, 40,116,111, + 108,117, 97, 95, 83, 44,108,117, 97, 95,103,101,116,116,111, + 112, 40,116,111,108,117, 97, 95, 83, 41, 41, 59, 39, 41, 10, + 9, 9, 9,101,108,115,101, 10, 9, 9, 9, 9,111,117,116, + 112,117,116, 40, 39, 32, 32, 32, 39, 44,112,117,115,104, 95, + 102,117,110, 99, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, + 40,118,111,105,100, 42, 41,116,111,108,117, 97, 95,114,101, + 116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 9, + 9, 9,101,110,100, 10, 9, 9,101,110,100, 10, 9,101,110, + 100, 10, 10, 9,111,117,116,112,117,116, 40, 39, 32, 32,125, + 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, 32,114,101, + 116,117,114,110, 32, 49, 59, 39, 41, 10, 10, 9,111,117,116, + 112,117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, + 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, + 10, 9,111,117,116,112,117,116, 40, 39,116,111,108,117, 97, + 95,108,101,114,114,111,114, 58, 92,110, 39, 41, 10, 9,111, + 117,116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,101, + 114,114,111,114, 40,116,111,108,117, 97, 95, 83, 44, 34, 35, + 102,101,114,114,111,114, 32,105,110, 32,102,117,110, 99,116, + 105,111,110, 32, 92, 39, 39, 46, 46,115,101,108,102, 46,108, + 110, 97,109,101, 46, 46, 39, 92, 39, 46, 34, 44, 38,116,111, + 108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10, 9,111,117, + 116,112,117,116, 40, 39, 32,114,101,116,117,114,110, 32, 48, + 59, 39, 41, 10, 9,111,117,116,112,117,116, 40, 39, 35,101, + 110,100,105,102, 92,110, 39, 41, 10, 10, 10, 9,111,117,116, + 112,117,116, 40, 39,125, 39, 41, 10, 9,111,117,116,112,117, + 116, 40, 39, 35,101,110,100,105,102, 32, 47, 47, 35,105,102, + 110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, + 66, 76, 69, 92,110, 39, 41, 10, 9,111,117,116,112,117,116, + 40, 39, 92,110, 39, 41, 10,101,110,100, 10, 10, 45, 45, 32, + 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114, + 117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32, + 95, 79,112,101,114, 97,116,111,114, 32, 40,116, 41, 10, 32, + 115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, + 99,108, 97,115,115, 79,112,101,114, 97,116,111,114, 41, 10, + 10, 32,105,102, 32,116, 46, 99,111,110,115,116, 32,126, 61, + 32, 39, 99,111,110,115,116, 39, 32, 97,110,100, 32,116, 46, + 99,111,110,115,116, 32,126, 61, 32, 39, 39, 32,116,104,101, + 110, 10, 32, 32,101,114,114,111,114, 40, 34, 35,105,110,118, + 97,108,105,100, 32, 39, 99,111,110,115,116, 39, 32,115,112, + 101, 99,105,102,105, 99, 97,116,105,111,110, 34, 41, 10, 32, + 101,110,100, 10, 10, 32, 97,112,112,101,110,100, 40,116, 41, + 10, 32,105,102, 32,110,111,116, 32,116, 58,105,110, 99,108, + 97,115,115, 40, 41, 32,116,104,101,110, 10, 32, 32,101,114, + 114,111,114, 40, 34, 35,111,112,101,114, 97,116,111,114, 32, + 99, 97,110, 32,111,110,108,121, 32, 98,101, 32,100,101,102, + 105,110,101,100, 32, 97,115, 32, 99,108, 97,115,115, 32,109, + 101,109, 98,101,114, 34, 41, 10, 32,101,110,100, 10, 10, 32, + 45, 45,116, 46,110, 97,109,101, 32, 61, 32,116, 46,110, 97, + 109,101, 32, 46, 46, 32, 34, 95, 34, 32, 46, 46, 32, 40, 95, + 84, 77, 91,116, 46,107,105,110,100, 93, 32,111,114, 32,116, + 46,107,105,110,100, 41, 10, 32,116, 46, 99,110, 97,109,101, + 32, 61, 32,116, 58, 99,102,117,110, 99,110, 97,109,101, 40, + 34,116,111,108,117, 97, 34, 41, 46, 46,116, 58,111,118,101, + 114,108,111, 97,100, 40,116, 41, 10, 32,116, 46,110, 97,109, + 101, 32, 61, 32, 34,111,112,101,114, 97,116,111,114, 34, 32, + 46, 46, 32,116, 46,107,105,110,100, 32, 32, 45, 45, 32,115, + 101,116, 32, 97,112,112,114,111,112,114,105, 97,116,101, 32, + 99, 97,108,108,105,110,103, 32,110, 97,109,101, 10, 32,114, + 101,116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, + 32, 67,111,110,115,116,114,117, 99,116,111,114, 10,102,117, + 110, 99,116,105,111,110, 32, 79,112,101,114, 97,116,111,114, + 32, 40,100, 44,107, 44, 97, 44, 99, 41, 10, 10, 9,108,111, + 99, 97,108, 32,111,112, 95,107, 32, 61, 32,115,116,114,105, + 110,103, 46,103,115,117, 98, 40,107, 44, 32, 34, 94, 37,115, + 42, 34, 44, 32, 34, 34, 41, 10, 9,111,112, 95,107, 32, 61, + 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,107, 44, + 32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 10, 9, 45, + 45,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, + 40,107, 44, 32, 34, 94, 91, 37,119, 95, 58, 37,100, 60, 62, + 37, 42, 37, 38, 93, 43, 36, 34, 41, 32,116,104,101,110, 10, + 9,105,102, 32,100, 32, 61, 61, 32, 34,111,112,101,114, 97, + 116,111,114, 34, 32, 97,110,100, 32,107, 32,126, 61, 32, 39, + 39, 32,116,104,101,110, 10, 10, 9, 9,100, 32, 61, 32,107, + 46, 46, 34, 32,111,112,101,114, 97,116,111,114, 34, 10, 9, + 101,108,115,101,105,102, 32,110,111,116, 32, 95, 84, 77, 91, + 111,112, 95,107, 93, 32,116,104,101,110, 10, 10, 9, 9,105, + 102, 32,102,108, 97,103,115, 91, 39, 87, 39, 93, 32,116,104, + 101,110, 10, 9, 9, 9,101,114,114,111,114, 40, 34,116,111, + 108,117, 97, 58, 32,110,111, 32,115,117,112,112,111,114,116, + 32,102,111,114, 32,111,112,101,114, 97,116,111,114, 34, 32, + 46, 46, 32,102, 46,107,105,110,100, 41, 10, 9, 9,101,108, + 115,101, 10, 9, 9, 9,119, 97,114,110,105,110,103, 40, 34, + 78,111, 32,115,117,112,112,111,114,116, 32,102,111,114, 32, + 111,112,101,114, 97,116,111,114, 32, 34, 46, 46,111,112, 95, + 107, 46, 46, 34, 44, 32,105,103,110,111,114,105,110,103, 34, + 41, 10, 9, 9, 9,114,101,116,117,114,110, 32,110,105,108, + 10, 9, 9,101,110,100, 10, 9,101,110,100, 10, 10, 9,108, + 111, 99, 97,108, 32,114,101,102, 32, 61, 32, 39, 39, 10, 32, + 108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,108,105,116, + 95, 99, 95,116,111,107,101,110,115, 40,115,116,114,115,117, + 98, 40, 97, 44, 50, 44,115,116,114,108,101,110, 40, 97, 41, + 45, 49, 41, 44, 39, 44, 39, 41, 32, 45, 45, 32,101,108,105, + 109,105,110, 97,116,101, 32, 98,114, 97, 99,101,115, 10, 32, + 108,111, 99, 97,108, 32,105, 61, 49, 10, 32,108,111, 99, 97, + 108, 32,108, 32, 61, 32,123,110, 61, 48,125, 10, 32,119,104, + 105,108,101, 32,116, 91,105, 93, 32,100,111, 10, 32, 32,108, + 46,110, 32, 61, 32,108, 46,110, 43, 49, 10, 32, 32,108, 91, + 108, 46,110, 93, 32, 61, 32, 68,101, 99,108, 97,114, 97,116, + 105,111,110, 40,116, 91,105, 93, 44, 39,118, 97,114, 39, 41, + 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, + 10, 32,105,102, 32,107, 32, 61, 61, 32, 39, 91, 93, 39, 32, + 116,104,101,110, 10, 9, 32,108,111, 99, 97,108, 32, 95, 10, + 9, 32, 95, 44, 32, 95, 44, 32,114,101,102, 32, 61, 32,115, + 116,114,102,105,110,100, 40,100, 44, 39, 40, 38, 41, 39, 41, + 10, 32, 32,100, 32, 61, 32,103,115,117, 98, 40,100, 44, 39, + 38, 39, 44, 39, 39, 41, 10, 32,101,108,115,101,105,102, 32, + 107, 61, 61, 39, 38, 91, 93, 39, 32,116,104,101,110, 10, 32, + 32,108, 46,110, 32, 61, 32,108, 46,110, 43, 49, 10, 32, 32, + 108, 91,108, 46,110, 93, 32, 61, 32, 68,101, 99,108, 97,114, + 97,116,105,111,110, 40,100, 44, 39,118, 97,114, 39, 41, 10, + 32, 32,108, 91,108, 46,110, 93, 46,110, 97,109,101, 32, 61, + 32, 39,116,111,108,117, 97, 95,118, 97,108,117,101, 39, 10, + 32,101,110,100, 10, 32,108,111, 99, 97,108, 32,102, 32, 61, + 32, 68,101, 99,108, 97,114, 97,116,105,111,110, 40,100, 44, + 39,102,117,110, 99, 39, 41, 10, 32,105,102, 32,107, 32, 61, + 61, 32, 39, 91, 93, 39, 32, 97,110,100, 32, 40,108, 91, 49, + 93, 61, 61,110,105,108, 32,111,114, 32,105,115, 98, 97,115, + 105, 99, 40,108, 91, 49, 93, 46,116,121,112,101, 41,126, 61, + 39,110,117,109, 98,101,114, 39, 41, 32,116,104,101,110, 10, + 32, 32,101,114,114,111,114, 40, 39,111,112,101,114, 97,116, + 111,114, 91, 93, 32, 99, 97,110, 32,111,110,108,121, 32, 98, + 101, 32,100,101,102,105,110,101,100, 32,102,111,114, 32,110, + 117,109,101,114,105, 99, 32,105,110,100,101,120, 46, 39, 41, + 10, 32,101,110,100, 10, 32,102, 46, 97,114,103,115, 32, 61, + 32,108, 10, 32,102, 46, 99,111,110,115,116, 32, 61, 32, 99, + 10, 32,102, 46,107,105,110,100, 32, 61, 32,111,112, 95,107, + 10, 32,102, 46,108,110, 97,109,101, 32, 61, 32, 34, 46, 34, + 46, 46, 40, 95, 84, 77, 91,102, 46,107,105,110,100, 93, 32, + 111,114, 32,102, 46,107,105,110,100, 41, 10, 32,105,102, 32, + 110,111,116, 32, 95, 84, 77, 91,102, 46,107,105,110,100, 93, + 32,116,104,101,110, 10, 32, 9,102, 46, 99, 97,115,116, 95, + 111,112,101,114, 97,116,111,114, 32, 61, 32,116,114,117,101, + 10, 32,101,110,100, 10, 32,105,102, 32,102, 46,107,105,110, + 100, 32, 61, 61, 32, 39, 91, 93, 39, 32, 97,110,100, 32,114, + 101,102, 61, 61, 39, 38, 39, 32, 97,110,100, 32,102, 46, 99, + 111,110,115,116,126, 61, 39, 99,111,110,115,116, 39, 32,116, + 104,101,110, 10, 32, 32, 79,112,101,114, 97,116,111,114, 40, + 100, 44, 39, 38, 39, 46, 46,107, 44, 97, 44, 99, 41, 32, 9, + 45, 45, 32, 99,114,101, 97,116,101, 32, 99,111,114,114,101, + 115,112,111,100,105,110,103, 32,115,101,116, 32,111,112,101, + 114, 97,116,111,114, 10, 32,101,110,100, 10, 32,114,101,116, + 117,114,110, 32, 95, 79,112,101,114, 97,116,111,114, 40,102, + 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/operator.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 10, 95,103,108,111, 98, 97,108, 95,116,101,109,112,108, 97, + 116,101,115, 32, 61, 32,123,125, 10, 10, 99,108, 97,115,115, + 84,101,109,112,108, 97,116,101, 67,108, 97,115,115, 32, 61, + 32,123, 10, 10, 9,110, 97,109,101, 32, 61, 32, 39, 39, 44, + 10, 9, 98,111,100,121, 32, 61, 32, 39, 39, 44, 10, 9,112, + 97,114,101,110,116,115, 32, 61, 32,123,125, 44, 10, 9, 97, + 114,103,115, 32, 61, 32,123,125, 44, 32, 45, 45, 32,116,104, + 101, 32,116,101,109,112,108, 97,116,101, 32, 97,114,103,117, + 109,101,110,116,115, 10,125, 10, 10, 99,108, 97,115,115, 84, + 101,109,112,108, 97,116,101, 67,108, 97,115,115, 46, 95, 95, + 105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 84,101, + 109,112,108, 97,116,101, 67,108, 97,115,115, 10, 10, 10,102, + 117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 84,101, + 109,112,108, 97,116,101, 67,108, 97,115,115, 58,116,104,114, + 111,119, 40,116,121,112,101,115, 44, 32,108,111, 99, 97,108, + 95,115, 99,111,112,101, 41, 10, 10, 9, 45, 45,105,102, 32, + 116, 97, 98,108,101, 46,103,101,116,110, 40,116,121,112,101, + 115, 41, 32,126, 61, 32,116, 97, 98,108,101, 46,103,101,116, + 110, 40,115,101,108,102, 46, 97,114,103,115, 41, 32,116,104, + 101,110, 10, 9, 45, 45, 9,101,114,114,111,114, 40, 34, 35, + 105,110,118, 97,108,105,100, 32,112, 97,114, 97,109,101,116, + 101,114, 32, 99,111,117,110,116, 34, 41, 10, 9, 45, 45,101, + 110,100, 10, 10, 9, 45, 45, 32,114,101,112,108, 97, 99,101, + 10, 9,102,111,114, 32,105, 32, 61, 49, 32, 44, 32,116,121, + 112,101,115, 46,110, 32,100,111, 10, 10, 9, 9,108,111, 99, + 97,108, 32, 73,108, 32, 61, 32,115,112,108,105,116, 95, 99, + 95,116,111,107,101,110,115, 40,116,121,112,101,115, 91,105, + 93, 44, 32, 34, 32, 34, 41, 10, 9, 9,105,102, 32,116, 97, + 98,108,101, 46,103,101,116,110, 40, 73,108, 41, 32,126, 61, + 32,116, 97, 98,108,101, 46,103,101,116,110, 40,115,101,108, + 102, 46, 97,114,103,115, 41, 32,116,104,101,110, 10, 9, 9, + 9,101,114,114,111,114, 40, 34, 35,105,110,118, 97,108,105, + 100, 32,112, 97,114, 97,109,101,116,101,114, 32, 99,111,117, + 110,116, 32,102,111,114, 32, 34, 46, 46,116,121,112,101,115, + 91,105, 93, 41, 10, 9, 9,101,110,100, 10, 9, 9,108,111, + 99, 97,108, 32, 98, 73, 32, 61, 32,115,101,108,102, 46, 98, + 111,100,121, 10, 9, 9,108,111, 99, 97,108, 32,112, 73, 32, + 61, 32,123,125, 10, 9, 9,102,111,114, 32,106, 32, 61, 32, + 49, 44,115,101,108,102, 46, 97,114,103,115, 46,110, 32,100, + 111, 10, 9, 9, 9, 45, 45, 84,108, 91,106, 93, 32, 61, 32, + 102,105,110,100,116,121,112,101, 40, 84,108, 91,106, 93, 41, + 32,111,114, 32, 84,108, 91,106, 93, 10, 9, 9, 9, 98, 73, + 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, + 98, 73, 44, 32, 34, 40, 91, 94, 95, 37,119, 93, 41, 34, 46, + 46,115,101,108,102, 46, 97,114,103,115, 91,106, 93, 46, 46, + 34, 40, 91, 94, 95, 37,119, 93, 41, 34, 44, 32, 34, 37, 49, + 34, 46, 46, 73,108, 91,106, 93, 46, 46, 34, 37, 50, 34, 41, + 10, 9, 9, 9,105,102, 32,115,101,108,102, 46,112, 97,114, + 101,110,116,115, 32,116,104,101,110, 10, 9, 9, 9, 9,102, + 111,114, 32,105, 61, 49, 44,116, 97, 98,108,101, 46,103,101, + 116,110, 40,115,101,108,102, 46,112, 97,114,101,110,116,115, + 41, 32,100,111, 10, 9, 9, 9, 9, 9,112, 73, 91,105, 93, + 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, + 115,101,108,102, 46,112, 97,114,101,110,116,115, 91,105, 93, + 44, 32, 34, 40, 91, 94, 95, 37,119, 93, 63, 41, 34, 46, 46, + 115,101,108,102, 46, 97,114,103,115, 91,106, 93, 46, 46, 34, + 40, 91, 94, 95, 37,119, 93, 63, 41, 34, 44, 32, 34, 37, 49, + 34, 46, 46, 73,108, 91,106, 93, 46, 46, 34, 37, 50, 34, 41, + 10, 9, 9, 9, 9,101,110,100, 10, 9, 9, 9,101,110,100, + 10, 9, 9,101,110,100, 10, 9, 9, 45, 45,108,111, 99, 97, + 108, 32, 97,112,112,101,110,100, 32, 61, 32, 34, 60, 34, 46, + 46,115,116,114,105,110,103, 46,103,115,117, 98, 40,116,121, + 112,101,115, 91,105, 93, 44, 32, 34, 37,115, 43, 34, 44, 32, + 34, 44, 34, 41, 46, 46, 34, 62, 34, 10, 9, 9,108,111, 99, + 97,108, 32, 97,112,112,101,110,100, 32, 61, 32, 34, 60, 34, + 46, 46, 99,111,110, 99, 97,116, 40, 73,108, 44, 32, 49, 44, + 32,116, 97, 98,108,101, 46,103,101,116,110, 40, 73,108, 41, + 44, 32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10, 9, 9, 97, + 112,112,101,110,100, 32, 61, 32,115,116,114,105,110,103, 46, + 103,115,117, 98, 40, 97,112,112,101,110,100, 44, 32, 34, 37, + 115, 42, 44, 37,115, 42, 34, 44, 32, 34, 44, 34, 41, 10, 9, + 9, 97,112,112,101,110,100, 32, 61, 32,115,116,114,105,110, + 103, 46,103,115,117, 98, 40, 97,112,112,101,110,100, 44, 32, + 34, 62, 62, 34, 44, 32, 34, 62, 32, 62, 34, 41, 10, 9, 9, + 102,111,114, 32,105, 61, 49, 44,116, 97, 98,108,101, 46,103, + 101,116,110, 40,112, 73, 41, 32,100,111, 10, 9, 9, 9, 45, + 45,112, 73, 91,105, 93, 32, 61, 32,115,116,114,105,110,103, + 46,103,115,117, 98, 40,112, 73, 91,105, 93, 44, 32, 34, 62, + 62, 34, 44, 32, 34, 62, 32, 62, 34, 41, 10, 9, 9, 9,112, + 73, 91,105, 93, 32, 61, 32,114,101,115,111,108,118,101, 95, + 116,101,109,112,108, 97,116,101, 95,116,121,112,101,115, 40, + 112, 73, 91,105, 93, 41, 10, 9, 9,101,110,100, 10, 9, 9, + 98, 73, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, + 98, 40, 98, 73, 44, 32, 34, 62, 62, 34, 44, 32, 34, 62, 32, + 62, 34, 41, 10, 9, 9,108,111, 99, 97,108, 32,110, 32, 61, + 32,115,101,108,102, 46,110, 97,109,101, 10, 9, 9,105,102, + 32,108,111, 99, 97,108, 95,115, 99,111,112,101, 32,116,104, + 101,110, 10, 9, 9, 9,110, 32, 61, 32,115,101,108,102, 46, + 108,111, 99, 97,108, 95,110, 97,109,101, 10, 9, 9,101,110, + 100, 10, 10, 9, 9, 67,108, 97,115,115, 40,110, 46, 46, 97, + 112,112,101,110,100, 44, 32,112, 73, 44, 32, 98, 73, 41, 10, + 9,101,110,100, 10,101,110,100, 10, 10, 10,102,117,110, 99, + 116,105,111,110, 32, 84,101,109,112,108, 97,116,101, 67,108, + 97,115,115, 40,110, 97,109,101, 44, 32,112, 97,114,101,110, + 116,115, 44, 32, 98,111,100,121, 44, 32,112, 97,114, 97,109, + 101,116,101,114,115, 41, 10, 10, 9,108,111, 99, 97,108, 32, + 111, 32, 61, 32,123, 10, 9, 10, 9, 9,112, 97,114,101,110, + 116,115, 32, 61, 32,112, 97,114,101,110,116,115, 44, 10, 9, + 9, 98,111,100,121, 32, 61, 32, 98,111,100,121, 44, 10, 9, + 9, 97,114,103,115, 32, 61, 32,112, 97,114, 97,109,101,116, + 101,114,115, 44, 10, 9,125, 10, 9, 10, 9,108,111, 99, 97, + 108, 32,111,110, 97,109,101, 32, 61, 32,115,116,114,105,110, + 103, 46,103,115,117, 98, 40,110, 97,109,101, 44, 32, 34, 64, + 46, 42, 36, 34, 44, 32, 34, 34, 41, 10, 9,111,110, 97,109, + 101, 32, 61, 32,103,101,116,110, 97,109,101,115,112, 97, 99, + 101, 40, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101, + 114, 46, 99,117,114,114, 41, 46, 46,111,110, 97,109,101, 10, + 9,111, 46,110, 97,109,101, 32, 61, 32,111,110, 97,109,101, + 10, 10, 9,111, 46,108,111, 99, 97,108, 95,110, 97,109,101, + 32, 61, 32,110, 97,109,101, 10, 9, 10, 9,115,101,116,109, + 101,116, 97,116, 97, 98,108,101, 40,111, 44, 32, 99,108, 97, + 115,115, 84,101,109,112,108, 97,116,101, 67,108, 97,115,115, + 41, 10, 10, 9,105,102, 32, 95,103,108,111, 98, 97,108, 95, + 116,101,109,112,108, 97,116,101,115, 91,111,110, 97,109,101, + 93, 32,116,104,101,110, 10, 9, 9,119, 97,114,110,105,110, + 103, 40, 34, 68,117,112,108,105, 99, 97,116,101, 32,100,101, + 99,108, 97,114, 97,116,105,111,110, 32,111,102, 32,116,101, + 109,112,108, 97,116,101, 32, 34, 46, 46,111,110, 97,109,101, + 41, 10, 9,101,108,115,101, 10, 9, 9, 95,103,108,111, 98, + 97,108, 95,116,101,109,112,108, 97,116,101,115, 91,111,110, + 97,109,101, 93, 32, 61, 32,111, 10, 9,101,110,100, 10, 10, + 9,114,101,116,117,114,110, 32,111, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/template_class.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,116,111,108,117, 97, 58, 32, 99,108, 97,115,115, + 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116, + 101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, + 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97, + 102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117, + 108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, + 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, + 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97, + 114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100, + 105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110, + 100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, + 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114, + 101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,101, + 117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, + 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, + 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104, + 111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, + 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,100, + 101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32, + 115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101, + 115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101, + 110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, + 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, 32, 67,108, + 97,115,115, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101, + 112,114,101,115,101,110,116,115, 32, 97, 32, 99,108, 97,115, + 115, 32,100,101,102,105,110,105,116,105,111,110, 46, 10, 45, + 45, 32, 83,116,111,114,101,115, 32,116,104,101, 32,102,111, + 108,108,111,119,105,110,103, 32,102,105,101,108,100,115, 58, + 10, 45, 45, 32, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99, + 108, 97,115,115, 32,110, 97,109,101, 10, 45, 45, 32, 32, 32, + 32, 98, 97,115,101, 32, 61, 32, 99,108, 97,115,115, 32, 98, + 97,115,101, 44, 32,105,102, 32, 97,110,121, 32, 40,111,110, + 108,121, 32,115,105,110,103,108,101, 32,105,110,104,101,114, + 105,116, 97,110, 99,101, 32,105,115, 32,115,117,112,112,111, + 114,116,101,100, 41, 10, 45, 45, 32, 32, 32, 32,123,105,125, + 32, 32, 61, 32,108,105,115,116, 32,111,102, 32,109,101,109, + 98,101,114,115, 10, 99,108, 97,115,115, 67,108, 97,115,115, + 32, 61, 32,123, 10, 32, 99,108, 97,115,115,116,121,112,101, + 32, 61, 32, 39, 99,108, 97,115,115, 39, 44, 10, 32,110, 97, + 109,101, 32, 61, 32, 39, 39, 44, 10, 32, 98, 97,115,101, 32, + 61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39, + 39, 44, 10, 32, 98,116,121,112,101, 32, 61, 32, 39, 39, 44, + 10, 32, 99,116,121,112,101, 32, 61, 32, 39, 39, 44, 10,125, + 10, 99,108, 97,115,115, 67,108, 97,115,115, 46, 95, 95,105, + 110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 67,108, 97, + 115,115, 10,115,101,116,109,101,116, 97,116, 97, 98,108,101, + 40, 99,108, 97,115,115, 67,108, 97,115,115, 44, 99,108, 97, + 115,115, 67,111,110,116, 97,105,110,101,114, 41, 10, 10, 10, + 45, 45, 32,114,101,103,105,115,116,101,114, 32, 99,108, 97, + 115,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 67,108, 97,115,115, 58,114,101,103,105,115,116,101, + 114, 32, 40,112,114,101, 41, 10, 10, 9,105,102, 32,110,111, + 116, 32,115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, + 98,108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116, + 104,101,110, 10, 9, 9,114,101,116,117,114,110, 10, 9,101, + 110,100, 10, 10, 32,112,114,101, 32, 61, 32,112,114,101, 32, + 111,114, 32, 39, 39, 10, 32,112,117,115,104, 40,115,101,108, + 102, 41, 10, 9,105,102, 32, 95, 99,111,108,108,101, 99,116, + 91,115,101,108,102, 46,116,121,112,101, 93, 32,116,104,101, + 110, 10, 9, 9,111,117,116,112,117,116, 40,112,114,101, 44, + 39, 35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,115, + 112,108,117,115, 92,110, 39, 41, 10, 32, 32,111,117,116,112, + 117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, + 99, 99,108, 97,115,115, 40,116,111,108,117, 97, 95, 83, 44, + 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101, 46, + 46, 39, 34, 44, 34, 39, 46, 46,115,101,108,102, 46,116,121, + 112,101, 46, 46, 39, 34, 44, 34, 39, 46, 46,115,101,108,102, + 46, 98,116,121,112,101, 46, 46, 39, 34, 44, 39, 46, 46, 95, + 99,111,108,108,101, 99,116, 91,115,101,108,102, 46,116,121, + 112,101, 93, 46, 46, 39, 41, 59, 39, 41, 10, 9, 9,111,117, + 116,112,117,116, 40,112,114,101, 44, 39, 35,101,108,115,101, + 92,110, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40,112, + 114,101, 46, 46, 39,116,111,108,117, 97, 95, 99, 99,108, 97, + 115,115, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46, + 115,101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, + 34, 39, 46, 46,115,101,108,102, 46,116,121,112,101, 46, 46, + 39, 34, 44, 34, 39, 46, 46,115,101,108,102, 46, 98,116,121, + 112,101, 46, 46, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, + 10, 9, 9,111,117,116,112,117,116, 40,112,114,101, 44, 39, + 35,101,110,100,105,102, 92,110, 39, 41, 10, 9,101,108,115, + 101, 10, 32, 32,111,117,116,112,117,116, 40,112,114,101, 46, + 46, 39,116,111,108,117, 97, 95, 99, 99,108, 97,115,115, 40, + 116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108, + 102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 34, 39, 46, + 46,115,101,108,102, 46,116,121,112,101, 46, 46, 39, 34, 44, + 34, 39, 46, 46,115,101,108,102, 46, 98,116,121,112,101, 46, + 46, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 10, 9,101, + 110,100, 10, 9,105,102, 32,115,101,108,102, 46,101,120,116, + 114, 97, 95, 98, 97,115,101,115, 32,116,104,101,110, 10, 9, + 9,102,111,114, 32,107, 44, 98, 97,115,101, 32,105,110, 32, + 105,112, 97,105,114,115, 40,115,101,108,102, 46,101,120,116, + 114, 97, 95, 98, 97,115,101,115, 41, 32,100,111, 10, 9, 9, + 9, 45, 45, 32,110,111,116, 32,110,111,119, 10, 32, 32, 32, + 45, 45,111,117,116,112,117,116, 40,112,114,101, 46, 46, 39, + 32,116,111,108,117, 97, 95, 97,100,100, 98, 97,115,101, 40, + 116,111,108,117, 97, 95, 83, 44, 32, 34, 39, 46, 46,115,101, + 108,102, 46,116,121,112,101, 46, 46, 39, 34, 44, 32, 34, 39, + 46, 46, 98, 97,115,101, 46, 46, 39, 34, 41, 59, 39, 41, 10, + 9, 9,101,110,100, 10, 9,101,110,100, 10, 32,111,117,116, + 112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, + 95, 98,101,103,105,110,109,111,100,117,108,101, 40,116,111, + 108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46, + 108,110, 97,109,101, 46, 46, 39, 34, 41, 59, 39, 41, 10, 32, + 108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108, + 101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32, + 115,101,108,102, 91,105, 93, 58,114,101,103,105,115,116,101, + 114, 40,112,114,101, 46, 46, 39, 32, 39, 41, 10, 32, 32,105, + 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,111,117, + 116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, + 97, 95,101,110,100,109,111,100,117,108,101, 40,116,111,108, + 117, 97, 95, 83, 41, 59, 39, 41, 10, 9,112,111,112, 40, 41, + 10,101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,110, + 32, 99,111,108,108,101, 99,116,105,111,110, 32,114,101,113, + 117,105,114,101,109,101,110,116, 10,102,117,110, 99,116,105, + 111,110, 32, 99,108, 97,115,115, 67,108, 97,115,115, 58,114, + 101,113,117,105,114,101, 99,111,108,108,101, 99,116,105,111, + 110, 32, 40,116, 41, 10, 9,105,102, 32,115,101,108,102, 46, + 102,108, 97,103,115, 46,112,114,111,116,101, 99,116,101,100, + 95,100,101,115,116,114,117, 99,116,111,114, 32,111,114, 32, + 40,110,111,116, 32,115,101,108,102, 58, 99,104,101, 99,107, + 95,112,117, 98,108,105, 99, 95, 97, 99, 99,101,115,115, 40, + 41, 41, 32,116,104,101,110, 10, 9, 9,114,101,116,117,114, + 110, 32,102, 97,108,115,101, 10, 9,101,110,100, 10, 32,112, + 117,115,104, 40,115,101,108,102, 41, 10, 9,108,111, 99, 97, + 108, 32,114, 32, 61, 32,102, 97,108,115,101, 10, 32,108,111, + 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,101, 32, + 115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32,114, 32, + 61, 32,115,101,108,102, 91,105, 93, 58,114,101,113,117,105, + 114,101, 99,111,108,108,101, 99,116,105,111,110, 40,116, 41, + 32,111,114, 32,114, 10, 32, 32,105, 32, 61, 32,105, 43, 49, + 10, 32,101,110,100, 10, 9,112,111,112, 40, 41, 10, 9, 45, + 45, 32,111,110,108,121, 32, 99,108, 97,115,115, 32,116,104, + 97,116, 32,101,120,112,111,114,116,115, 32,100,101,115,116, + 114,117, 99,116,111,114, 32, 99, 97,110, 32, 98,101, 32, 97, + 112,112,114,111,112,114,105, 97,116,101,108,121, 32, 99,111, + 108,108,101, 99,116,101,100, 10, 9, 45, 45, 32, 99,108, 97, + 115,115,101,115, 32,116,104, 97,116, 32,101,120,112,111,114, + 116, 32, 99,111,110,115,116,114,117, 99,116,111,114,115, 32, + 110,101,101,100, 32,116,111, 32,104, 97,118,101, 32, 97, 32, + 99,111,108,108,101, 99,116,111,114, 32, 40,111,118,101,114, + 114,105,100,101,100, 32, 98,121, 32, 45, 68, 32,102,108, 97, + 103, 32,111,110, 32, 99,111,109,109, 97,110,100, 32,108,105, + 110,101, 41, 10, 9,105,102, 32,115,101,108,102, 46, 95,100, + 101,108,101,116,101, 32,111,114, 32, 40, 40,110,111,116, 32, + 102,108, 97,103,115, 91, 39, 68, 39, 93, 41, 32, 97,110,100, + 32,115,101,108,102, 46, 95,110,101,119, 41, 32,116,104,101, + 110, 10, 9, 9, 45, 45,116, 91,115,101,108,102, 46,116,121, + 112,101, 93, 32, 61, 32, 34,116,111,108,117, 97, 95, 99,111, + 108,108,101, 99,116, 95, 34, 32, 46, 46, 32,103,115,117, 98, + 40,115,101,108,102, 46,116,121,112,101, 44, 34, 58, 58, 34, + 44, 34, 95, 34, 41, 10, 9, 9,116, 91,115,101,108,102, 46, + 116,121,112,101, 93, 32, 61, 32, 34,116,111,108,117, 97, 95, + 99,111,108,108,101, 99,116, 95, 34, 32, 46, 46, 32, 99,108, + 101, 97,110, 95,116,101,109,112,108, 97,116,101, 40,115,101, + 108,102, 46,116,121,112,101, 41, 10, 9, 9,114, 32, 61, 32, + 116,114,117,101, 10, 9,101,110,100, 10, 32,114,101,116,117, + 114,110, 32,114, 10,101,110,100, 10, 10, 45, 45, 32,111,117, + 116,112,117,116, 32,116, 97,103,115, 10,102,117,110, 99,116, + 105,111,110, 32, 99,108, 97,115,115, 67,108, 97,115,115, 58, + 100,101, 99,108,116,121,112,101, 32, 40, 41, 10, 32,112,117, + 115,104, 40,115,101,108,102, 41, 10, 9,115,101,108,102, 46, + 116,121,112,101, 32, 61, 32,114,101,103,116,121,112,101, 40, + 115,101,108,102, 46,111,114,105,103,105,110, 97,108, 95,110, + 97,109,101, 32,111,114, 32,115,101,108,102, 46,110, 97,109, + 101, 41, 10, 9,115,101,108,102, 46, 98,116,121,112,101, 32, + 61, 32,116,121,112,101,118, 97,114, 40,115,101,108,102, 46, + 98, 97,115,101, 41, 10, 9,115,101,108,102, 46, 99,116,121, + 112,101, 32, 61, 32, 39, 99,111,110,115,116, 32, 39, 46, 46, + 115,101,108,102, 46,116,121,112,101, 10, 9,105,102, 32,115, + 101,108,102, 46,101,120,116,114, 97, 95, 98, 97,115,101,115, + 32,116,104,101,110, 10, 9, 9,102,111,114, 32,105, 61, 49, + 44,116, 97, 98,108,101, 46,103,101,116,110, 40,115,101,108, + 102, 46,101,120,116,114, 97, 95, 98, 97,115,101,115, 41, 32, + 100,111, 10, 9, 9, 9,115,101,108,102, 46,101,120,116,114, + 97, 95, 98, 97,115,101,115, 91,105, 93, 32, 61, 32,116,121, + 112,101,118, 97,114, 40,115,101,108,102, 46,101,120,116,114, + 97, 95, 98, 97,115,101,115, 91,105, 93, 41, 10, 9, 9,101, + 110,100, 10, 9,101,110,100, 10, 32,108,111, 99, 97,108, 32, + 105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, + 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,105, + 93, 58,100,101, 99,108,116,121,112,101, 40, 41, 10, 32, 32, + 105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 9,112, + 111,112, 40, 41, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80, + 114,105,110,116, 32,109,101,116,104,111,100, 10,102,117,110, + 99,116,105,111,110, 32, 99,108, 97,115,115, 67,108, 97,115, + 115, 58,112,114,105,110,116, 32, 40,105,100,101,110,116, 44, + 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40,105, + 100,101,110,116, 46, 46, 34, 67,108, 97,115,115,123, 34, 41, + 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, + 34, 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101, + 108,102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32, 98, 97,115,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46, 98, 97,115,101, 46, 46, 34, 39, 59, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32, + 112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, + 98,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108, + 102, 46, 98,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, + 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, + 32, 99,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101, + 108,102, 46, 99,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, + 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104, + 105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, + 32, 32,115,101,108,102, 91,105, 93, 58,112,114,105,110,116, + 40,105,100,101,110,116, 46, 46, 34, 32, 34, 44, 34, 44, 34, + 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110, + 100, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, + 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110, + 100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97, + 115,115, 67,108, 97,115,115, 58,115,101,116, 95,112,114,111, + 116,101, 99,116,101,100, 95,100,101,115,116,114,117, 99,116, + 111,114, 40,112, 41, 10, 9,115,101,108,102, 46,102,108, 97, + 103,115, 46,112,114,111,116,101, 99,116,101,100, 95,100,101, + 115,116,114,117, 99,116,111,114, 32, 61, 32,115,101,108,102, + 46,102,108, 97,103,115, 46,112,114,111,116,101, 99,116,101, + 100, 95,100,101,115,116,114,117, 99,116,111,114, 32,111,114, + 32,112, 10,101,110,100, 10, 10, 45, 45, 32, 73,110,116,101, + 114,110, 97,108, 32, 99,111,110,115,116,114,117, 99,116,111, + 114, 10,102,117,110, 99,116,105,111,110, 32, 95, 67,108, 97, + 115,115, 32, 40,116, 41, 10, 32,115,101,116,109,101,116, 97, + 116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 67,108, + 97,115,115, 41, 10, 32,116, 58, 98,117,105,108,100,110, 97, + 109,101,115, 40, 41, 10, 32, 97,112,112,101,110,100, 40,116, + 41, 10, 32,114,101,116,117,114,110, 32,116, 10,101,110,100, + 10, 10, 45, 45, 32, 67,111,110,115,116,114,117, 99,116,111, + 114, 10, 45, 45, 32, 69,120,112,101, 99,116,115, 32,116,104, + 101, 32,110, 97,109,101, 44, 32,116,104,101, 32, 98, 97,115, + 101, 32, 40, 97,114,114, 97,121, 41, 32, 97,110,100, 32,116, + 104,101, 32, 98,111,100,121, 32,111,102, 32,116,104,101, 32, + 99,108, 97,115,115, 46, 10,102,117,110, 99,116,105,111,110, + 32, 67,108, 97,115,115, 32, 40,110, 44,112, 44, 98, 41, 10, + 10, 9,105,102, 32,116, 97, 98,108,101, 46,103,101,116,110, + 40,112, 41, 32, 62, 32, 49, 32,116,104,101,110, 10, 9, 9, + 98, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40, + 98, 44, 32, 49, 44, 32, 45, 50, 41, 10, 9, 9,102,111,114, + 32,105, 61, 50, 44,116, 97, 98,108,101, 46,103,101,116,110, + 40,112, 41, 44, 49, 32,100,111, 10, 9, 9, 9, 98, 32, 61, + 32, 98, 46, 46, 34, 92,110, 32,116,111,108,117, 97, 95,105, + 110,104,101,114,105,116,115, 32, 34, 46, 46,112, 91,105, 93, + 46, 46, 34, 32, 95, 95, 34, 46, 46,112, 91,105, 93, 46, 46, + 34, 95, 95, 59, 92,110, 34, 10, 9, 9,101,110,100, 10, 9, + 9, 98, 32, 61, 32, 98, 46, 46, 34, 92,110,125, 34, 10, 9, + 101,110,100, 10, 10, 9, 45, 45, 32, 99,104,101, 99,107, 32, + 102,111,114, 32,116,101,109,112,108, 97,116,101, 10, 9, 98, + 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, + 98, 44, 32, 34, 94,123, 37,115, 42, 84, 69, 77, 80, 76, 65, + 84, 69, 95, 66, 73, 78, 68, 34, 44, 32, 34,123, 92,110, 84, + 79, 76, 85, 65, 95, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, + 73, 78, 68, 34, 41, 10, 9,108,111, 99, 97,108, 32,116, 44, + 95, 44, 84, 44, 73, 32, 61, 32,115,116,114,105,110,103, 46, + 102,105,110,100, 40, 98, 44, 32, 39, 94,123, 37,115, 42, 84, + 79, 76, 85, 65, 95, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, + 73, 78, 68, 37,115, 42, 37, 40, 43, 37,115, 42, 92, 34, 63, + 40, 91, 94, 92, 34, 44, 93, 42, 41, 92, 34, 63, 37,115, 42, + 44, 37,115, 42, 40, 91, 94, 37, 41, 93, 42, 41, 37,115, 42, + 37, 41, 43, 39, 41, 10, 9,105,102, 32,116, 32,116,104,101, + 110, 10, 10, 9, 9, 45, 45, 32,114,101,109,111,118,101, 32, + 113,117,111,116,101,115, 10, 9, 9, 73, 32, 61, 32,115,116, + 114,105,110,103, 46,103,115,117, 98, 40, 73, 44, 32, 34, 92, + 34, 34, 44, 32, 34, 34, 41, 10, 9, 9, 84, 32, 61, 32,115, + 116,114,105,110,103, 46,103,115,117, 98, 40, 84, 44, 32, 34, + 92, 34, 34, 44, 32, 34, 34, 41, 10, 9, 9, 45, 45, 32,103, + 101,116, 32,116,121,112,101, 32,108,105,115,116, 10, 9, 9, + 108,111, 99, 97,108, 32,116,121,112,101,115, 32, 61, 32,115, + 112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40, 73, + 44, 32, 34, 44, 34, 41, 10, 9, 9, 45, 45, 32,114,101,109, + 111,118,101, 32, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, 73, + 78, 68, 32,108,105,110,101, 10, 9, 9,108,111, 99, 97,108, + 32, 98,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115, + 117, 98, 40, 98, 44, 32, 34, 94,123, 37,115, 42, 84, 79, 76, + 85, 65, 95, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, 73, 78, + 68, 91, 94, 92,110, 93, 42, 92,110, 34, 44, 32, 34,123, 92, + 110, 34, 41, 10, 9, 9, 9, 10, 9, 9,108,111, 99, 97,108, + 32, 84,108, 32, 61, 32,115,112,108,105,116, 40, 84, 44, 32, + 34, 32, 34, 41, 10, 9, 9,108,111, 99, 97,108, 32,116, 99, + 32, 61, 32, 84,101,109,112,108, 97,116,101, 67,108, 97,115, + 115, 40,110, 44, 32,112, 44, 32, 98,115, 44, 32, 84,108, 41, + 10, 10, 9, 9, 10, 9, 9,116, 99, 58,116,104,114,111,119, + 40,116,121,112,101,115, 44, 32,116,114,117,101, 41, 10, 9, + 9, 45, 45,102,111,114, 32,105, 61, 49, 44,116,121,112,101, + 115, 46,110, 32,100,111, 10, 9, 9, 45, 45, 9,116, 99, 58, + 116,104,114,111,119, 40,115,112,108,105,116, 95, 99, 95,116, + 111,107,101,110,115, 40,116,121,112,101,115, 91,105, 93, 44, + 32, 34, 32, 34, 41, 44, 32,116,114,117,101, 41, 10, 9, 9, + 45, 45,101,110,100, 10, 9, 9,114,101,116,117,114,110, 10, + 9,101,110,100, 10, 9, 10, 9,108,111, 99, 97,108, 32,109, + 98, 97,115,101, 10, 10, 9,105,102, 32,112, 32,116,104,101, + 110, 10, 9, 9,109, 98, 97,115,101, 32, 61, 32,116, 97, 98, + 108,101, 46,114,101,109,111,118,101, 40,112, 44, 32, 49, 41, + 10, 9, 9,105,102, 32,110,111,116, 32,112, 91, 49, 93, 32, + 116,104,101,110, 32,112, 32, 61, 32,110,105,108, 32,101,110, + 100, 10, 9,101,110,100, 10, 10, 9,109, 98, 97,115,101, 32, + 61, 32,109, 98, 97,115,101, 32, 97,110,100, 32,114,101,115, + 111,108,118,101, 95,116,101,109,112,108, 97,116,101, 95,116, + 121,112,101,115, 40,109, 98, 97,115,101, 41, 10, 10, 9,108, + 111, 99, 97,108, 32, 99, 10, 9,108,111, 99, 97,108, 32,111, + 110, 97,109,101, 32, 61, 32,115,116,114,105,110,103, 46,103, + 115,117, 98, 40,110, 44, 32, 34, 64, 46, 42, 36, 34, 44, 32, + 34, 34, 41, 10, 9,111,110, 97,109,101, 32, 61, 32,103,101, + 116,110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97,115, + 115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, + 41, 46, 46,111,110, 97,109,101, 10, 10, 9,105,102, 32, 95, + 103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91, + 111,110, 97,109,101, 93, 32,116,104,101,110, 10, 9, 9, 99, + 32, 61, 32, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115, + 115,101,115, 91,111,110, 97,109,101, 93, 10, 9, 9,105,102, + 32,109, 98, 97,115,101, 32, 97,110,100, 32, 40, 40,110,111, + 116, 32, 99, 46, 98, 97,115,101, 41, 32,111,114, 32, 99, 46, + 98, 97,115,101, 32, 61, 61, 32, 34, 34, 41, 32,116,104,101, + 110, 10, 9, 9, 9, 99, 46, 98, 97,115,101, 32, 61, 32,109, + 98, 97,115,101, 10, 9, 9,101,110,100, 10, 9,101,108,115, + 101, 10, 9, 9, 99, 32, 61, 32, 95, 67,108, 97,115,115, 40, + 95, 67,111,110,116, 97,105,110,101,114,123,110, 97,109,101, + 61,110, 44, 32, 98, 97,115,101, 61,109, 98, 97,115,101, 44, + 32,101,120,116,114, 97, 95, 98, 97,115,101,115, 61,112,125, + 41, 10, 10, 9, 9,108,111, 99, 97,108, 32,102,116, 32, 61, + 32,103,101,116,110, 97,109,101,115,112, 97, 99,101, 40, 99, + 46,112, 97,114,101,110,116, 41, 46, 46, 99, 46,111,114,105, + 103,105,110, 97,108, 95,110, 97,109,101, 10, 9, 9, 97,112, + 112,101,110,100, 95,103,108,111, 98, 97,108, 95,116,121,112, + 101, 40,102,116, 44, 32, 99, 41, 10, 9,101,110,100, 10, 10, + 9,112,117,115,104, 40, 99, 41, 10, 9, 99, 58,112, 97,114, + 115,101, 40,115,116,114,115,117, 98, 40, 98, 44, 50, 44,115, + 116,114,108,101,110, 40, 98, 41, 45, 49, 41, 41, 32, 45, 45, + 32,101,108,105,109,105,110, 97,116,101, 32, 98,114, 97, 99, + 101,115, 10, 9,112,111,112, 40, 41, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/class.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32,109, 97,114,107, 32,117,112, 32, 99,111,109,109, + 101,110,116,115, 32, 97,110,100, 32,115,116,114,105,110,103, + 115, 10, 83, 84, 82, 49, 32, 61, 32, 34, 92, 48, 48, 49, 34, + 10, 83, 84, 82, 50, 32, 61, 32, 34, 92, 48, 48, 50, 34, 10, + 83, 84, 82, 51, 32, 61, 32, 34, 92, 48, 48, 51, 34, 10, 83, + 84, 82, 52, 32, 61, 32, 34, 92, 48, 48, 52, 34, 10, 82, 69, + 77, 32, 32, 61, 32, 34, 92, 48, 48, 53, 34, 10, 65, 78, 89, + 32, 32, 61, 32, 34, 40, 91, 92, 48, 48, 49, 45, 92, 48, 48, + 53, 93, 41, 34, 10, 69, 83, 67, 49, 32, 61, 32, 34, 92, 48, + 48, 54, 34, 10, 69, 83, 67, 50, 32, 61, 32, 34, 92, 48, 48, + 55, 34, 10, 10, 77, 65, 83, 75, 32, 61, 32,123, 32, 45, 45, + 32,116,104,101, 32,115,117, 98,115,116,105,116,117,116,105, + 111,110, 32,111,114,100,101,114, 32,105,115, 32,105,109,112, + 111,114,116, 97,110,116, 10, 32,123, 69, 83, 67, 49, 44, 32, + 34, 92, 92, 39, 34,125, 44, 10, 32,123, 69, 83, 67, 50, 44, + 32, 39, 92, 92, 34, 39,125, 44, 10, 32,123, 83, 84, 82, 49, + 44, 32, 34, 39, 34,125, 44, 10, 32,123, 83, 84, 82, 50, 44, + 32, 39, 34, 39,125, 44, 10, 32,123, 83, 84, 82, 51, 44, 32, + 34, 37, 91, 37, 91, 34,125, 44, 10, 32,123, 83, 84, 82, 52, + 44, 32, 34, 37, 93, 37, 93, 34,125, 44, 10, 32,123, 82, 69, + 77, 32, 44, 32, 34, 37, 45, 37, 45, 34,125, 44, 10,125, 10, + 10,102,117,110, 99,116,105,111,110, 32,109, 97,115,107, 32, + 40,115, 41, 10, 32,102,111,114, 32,105, 32, 61, 32, 49, 44, + 103,101,116,110, 40, 77, 65, 83, 75, 41, 32, 32,100,111, 10, + 32, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44, 77, 65, + 83, 75, 91,105, 93, 91, 50, 93, 44, 77, 65, 83, 75, 91,105, + 93, 91, 49, 93, 41, 10, 32,101,110,100, 10, 32,114,101,116, + 117,114,110, 32,115, 10,101,110,100, 10, 10,102,117,110, 99, + 116,105,111,110, 32,117,110,109, 97,115,107, 32, 40,115, 41, + 10, 32,102,111,114, 32,105, 32, 61, 32, 49, 44,103,101,116, + 110, 40, 77, 65, 83, 75, 41, 32, 32,100,111, 10, 32, 32,115, + 32, 61, 32,103,115,117, 98, 40,115, 44, 77, 65, 83, 75, 91, + 105, 93, 91, 49, 93, 44, 77, 65, 83, 75, 91,105, 93, 91, 50, + 93, 41, 10, 32,101,110,100, 10, 32,114,101,116,117,114,110, + 32,115, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111, + 110, 32, 99,108,101, 97,110, 32, 40,115, 41, 10, 32, 45, 45, + 32, 99,104,101, 99,107, 32,102,111,114, 32, 99,111,109,112, + 105,108, 97,116,105,111,110, 32,101,114,114,111,114, 10, 32, + 108,111, 99, 97,108, 32, 99,111,100,101, 32, 61, 32, 34,114, + 101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 32, + 40, 41, 92,110, 34, 32, 46, 46, 32,115, 32, 46, 46, 32, 34, + 92,110, 32,101,110,100, 34, 10, 32,105,102, 32,110,111,116, + 32,100,111,115,116,114,105,110,103, 40, 99,111,100,101, 41, + 32,116,104,101,110, 10, 32, 32,114,101,116,117,114,110, 32, + 110,105,108, 10, 32,101,110,100, 10, 10, 32,105,102, 32,102, + 108, 97,103,115, 91, 39, 67, 39, 93, 32,116,104,101,110, 10, + 32, 9,114,101,116,117,114,110, 32,115, 10, 32,101,110,100, + 10, 10, 32,108,111, 99, 97,108, 32, 83, 32, 61, 32, 34, 34, + 32, 45, 45, 32,115, 97,118,101,100, 32,115,116,114,105,110, + 103, 10, 10, 32,115, 32, 61, 32,109, 97,115,107, 40,115, 41, + 10, 10, 32, 45, 45, 32,114,101,109,111,118,101, 32, 98,108, + 97,110,107,115, 32, 97,110,100, 32, 99,111,109,109,101,110, + 116,115, 10, 32,119,104,105,108,101, 32, 49, 32,100,111, 10, + 32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44,100, 32, 61, + 32,115,116,114,102,105,110,100, 40,115, 44, 65, 78, 89, 41, + 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10, 32, 32, + 32, 83, 32, 61, 32, 83, 46, 46,115,116,114,115,117, 98, 40, + 115, 44, 49, 44, 98, 45, 49, 41, 10, 32, 32, 32,115, 32, 61, + 32,115,116,114,115,117, 98, 40,115, 44, 98, 43, 49, 41, 10, + 32, 32, 32,105,102, 32,100, 61, 61, 83, 84, 82, 49, 32,111, + 114, 32,100, 61, 61, 83, 84, 82, 50, 32,116,104,101,110, 10, + 32, 32, 32, 32,101, 32, 61, 32,115,116,114,102,105,110,100, + 40,115, 44,100, 41, 10, 32, 32, 32, 32, 83, 32, 61, 32, 83, + 32, 46, 46,100, 46, 46,115,116,114,115,117, 98, 40,115, 44, + 49, 44,101, 41, 10, 32, 32, 32, 32,115, 32, 61, 32,115,116, + 114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32, 32, + 101,108,115,101,105,102, 32,100, 61, 61, 83, 84, 82, 51, 32, + 116,104,101,110, 10, 32, 32, 32, 32,101, 32, 61, 32,115,116, + 114,102,105,110,100, 40,115, 44, 83, 84, 82, 52, 41, 10, 32, + 32, 32, 32, 83, 32, 61, 32, 83, 46, 46,100, 46, 46,115,116, + 114,115,117, 98, 40,115, 44, 49, 44,101, 41, 10, 32, 32, 32, + 32,115, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44,101, + 43, 49, 41, 10, 32, 32, 32,101,108,115,101,105,102, 32,100, + 61, 61, 82, 69, 77, 32,116,104,101,110, 10, 32, 32, 32, 32, + 115, 32, 61, 32,103,115,117, 98, 40,115, 44, 34, 91, 94, 92, + 110, 93, 42, 40, 92,110, 63, 41, 34, 44, 34, 37, 49, 34, 44, + 49, 41, 10, 32, 32, 32,101,110,100, 10, 32, 32,101,108,115, + 101, 10, 32, 32, 32, 83, 32, 61, 32, 83, 46, 46,115, 10, 32, + 32, 32, 98,114,101, 97,107, 10, 32, 32,101,110,100, 10, 32, + 101,110,100, 10, 32, 45, 45, 32,101,108,105,109,105,110, 97, + 116,101, 32,117,110,101, 99,101,115,115, 97,114,121, 32,115, + 112, 97, 99,101,115, 10, 32, 83, 32, 61, 32,103,115,117, 98, + 40, 83, 44, 34, 91, 32, 92,116, 93, 43, 34, 44, 34, 32, 34, + 41, 10, 32, 83, 32, 61, 32,103,115,117, 98, 40, 83, 44, 34, + 91, 32, 92,116, 93, 42, 92,110, 91, 32, 92,116, 93, 42, 34, + 44, 34, 92,110, 34, 41, 10, 9, 83, 32, 61, 32,103,115,117, + 98, 40, 83, 44, 34, 92,110, 43, 34, 44, 34, 92,110, 34, 41, + 10, 32, 83, 32, 61, 32,117,110,109, 97,115,107, 40, 83, 41, + 10, 32,114,101,116,117,114,110, 32, 83, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/clean.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 45, 45, 32, 71,101,110,101,114, 97,116,101, 32, 98,105,110, + 100,105,110,103, 32, 99,111,100,101, 10, 45, 45, 32, 87,114, + 105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, + 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, + 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, + 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 76, 97, + 115,116, 32,117,112,100, 97,116,101, 58, 32, 65,112,114, 32, + 50, 48, 48, 51, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10, + 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32, + 105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114, + 101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105, + 115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100, + 47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10, + 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101, + 32,112,114,111,118,105,100,101,100, 32,104,101,114,101,117, + 110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, + 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97, + 110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111, + 114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97, + 116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,101, + 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115, + 117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115, + 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110, + 116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97, + 116,105,111,110,115, 46, 10, 10,102,117,110, 99,116,105,111, + 110, 32,112, 97,114,115,101, 95,101,120,116,114, 97, 40, 41, + 10, 10, 9,102,111,114, 32,107, 44,118, 32,105,110, 32,105, + 112, 97,105,114,115, 40, 95,101,120,116,114, 97, 95,112, 97, + 114, 97,109,101,116,101,114,115, 32,111,114, 32,123,125, 41, + 32,100,111, 10, 9, 9, 10, 9, 9,108,111, 99, 97,108, 32, + 98, 44,101, 44,110, 97,109,101, 44,118, 97,108,117,101, 32, + 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,118, + 44, 32, 34, 94, 40, 91, 94, 61, 93, 42, 41, 61, 40, 46, 42, + 41, 36, 34, 41, 10, 9, 9,105,102, 32, 98, 32,116,104,101, + 110, 10, 9, 9, 9, 95,101,120,116,114, 97, 95,112, 97,114, + 97,109,101,116,101,114,115, 91,110, 97,109,101, 93, 32, 61, + 32,118, 97,108,117,101, 10, 9, 9,101,108,115,101, 10, 9, + 9, 9, 95,101,120,116,114, 97, 95,112, 97,114, 97,109,101, + 116,101,114,115, 91,118, 93, 32, 61, 32,116,114,117,101, 10, + 9, 9,101,110,100, 10, 9,101,110,100, 10,101,110,100, 10, + 10,102,117,110, 99,116,105,111,110, 32,100,111,105,116, 32, + 40, 41, 10, 9, 45, 45, 32,100,101,102,105,110,101, 32,112, + 97, 99,107, 97,103,101, 32,110, 97,109,101, 44, 32,105,102, + 32,110,111,116, 32,112,114,111,118,105,100,101,100, 10, 9, + 105,102, 32,110,111,116, 32,102,108, 97,103,115, 46,110, 32, + 116,104,101,110, 10, 9, 9,105,102, 32,102,108, 97,103,115, + 46,102, 32,116,104,101,110, 10, 9, 9, 9,102,108, 97,103, + 115, 46,110, 32, 61, 32,103,115,117, 98, 40,102,108, 97,103, + 115, 46,102, 44, 34, 37, 46, 46, 42, 36, 34, 44, 34, 34, 41, + 10, 9, 9, 9, 95, 44, 95, 44,102,108, 97,103,115, 46,110, + 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, + 102,108, 97,103,115, 46,110, 44, 32, 34, 40, 91, 94, 47, 92, + 92, 93, 42, 41, 36, 34, 41, 10, 9, 9,101,108,115,101, 10, + 9, 9, 9,101,114,114,111,114, 40, 34, 35,110,111, 32,112, + 97, 99,107, 97,103,101, 32,110, 97,109,101, 32,110,111,114, + 32,105,110,112,117,116, 32,102,105,108,101, 32,112,114,111, + 118,105,100,101,100, 34, 41, 10, 9, 9,101,110,100, 10, 9, + 101,110,100, 10, 10, 9, 45, 45, 32,112, 97,114,115,101, 32, + 116, 97, 98,108,101, 32,119,105,116,104, 32,101,120,116,114, + 97, 32,112, 97,114, 97,109,116,101,114,115, 10, 9,112, 97, + 114,115,101, 95,101,120,116,114, 97, 40, 41, 10, 10, 9, 45, + 45, 32,100,111, 32,116,104,105,115, 32, 97,102,116,101,114, + 32,115,101,116,116,105,110,103, 32,116,104,101, 32,112, 97, + 99,107, 97,103,101, 32,110, 97,109,101, 10, 9,105,102, 32, + 102,108, 97,103,115, 91, 39, 76, 39, 93, 32,116,104,101,110, + 10, 9, 9,100,111,102,105,108,101, 40,102,108, 97,103,115, + 91, 39, 76, 39, 93, 41, 10, 9,101,110,100, 10, 10, 9, 45, + 45, 32, 97,100,100, 32, 99,112,112,115,116,114,105,110,103, + 10, 9,105,102, 32,110,111,116, 32,102,108, 97,103,115, 91, + 39, 83, 39, 93, 32,116,104,101,110, 10, 9, 9, 95, 98, 97, + 115,105, 99, 91, 39,115,116,114,105,110,103, 39, 93, 32, 61, + 32, 39, 99,112,112,115,116,114,105,110,103, 39, 10, 9, 9, + 95, 98, 97,115,105, 99, 91, 39,115,116,100, 58, 58,115,116, + 114,105,110,103, 39, 93, 32, 61, 32, 39, 99,112,112,115,116, + 114,105,110,103, 39, 10, 9, 9, 95, 98, 97,115,105, 99, 95, + 99,116,121,112,101, 46, 99,112,112,115,116,114,105,110,103, + 32, 61, 32, 39, 99,111,110,115,116, 32, 99,104, 97,114, 42, + 39, 10, 9,101,110,100, 10, 10, 9, 45, 45, 32,112,114,111, + 99, 99,101,115,115, 32,112, 97, 99,107, 97,103,101, 10, 9, + 108,111, 99, 97,108, 32,112, 32, 32, 61, 32, 80, 97, 99,107, + 97,103,101, 40,102,108, 97,103,115, 46,110, 44,102,108, 97, + 103,115, 46,102, 41, 10, 10, 9,105,102, 32,102,108, 97,103, + 115, 46,112, 32,116,104,101,110, 10, 9, 9,114,101,116,117, + 114,110, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32,111,110, + 108,121, 32,112, 97,114,115,101, 10, 9,101,110,100, 10, 10, + 9,105,102, 32,102,108, 97,103,115, 46,111, 32,116,104,101, + 110, 10, 9, 9,108,111, 99, 97,108, 32,115,116, 44,109,115, + 103, 32, 61, 32,119,114,105,116,101,116,111, 40,102,108, 97, + 103,115, 46,111, 41, 10, 9, 9,105,102, 32,110,111,116, 32, + 115,116, 32,116,104,101,110, 10, 9, 9, 9,101,114,114,111, + 114, 40, 39, 35, 39, 46, 46,109,115,103, 41, 10, 9, 9,101, + 110,100, 10, 9,101,110,100, 10, 10, 9,112, 58,100,101, 99, + 108,116,121,112,101, 40, 41, 10, 9,105,102, 32,102,108, 97, + 103,115, 46, 80, 32,116,104,101,110, 10, 9, 9,112, 58,112, + 114,105,110,116, 40, 41, 10, 9,101,108,115,101, 10, 9, 9, + 112, 58,112,114,101, 97,109, 98,108,101, 40, 41, 10, 9, 9, + 112, 58,115,117,112, 99,111,100,101, 40, 41, 10, 9, 9,112, + 58,114,101,103,105,115,116,101,114, 40, 41, 10, 9, 9,112, + 117,115,104, 40,112, 41, 10, 9, 9,112,111,115,116, 95,111, + 117,116,112,117,116, 95,104,111,111,107, 40,112, 41, 10, 9, + 9,112,111,112, 40, 41, 10, 9,101,110,100, 10, 10, 9,105, + 102, 32,102,108, 97,103,115, 46,111, 32,116,104,101,110, 10, + 9, 9,119,114,105,116,101,116,111, 40, 41, 10, 9,101,110, + 100, 10, 10, 9, 45, 45, 32,119,114,105,116,101, 32,104,101, + 97,100,101,114, 32,102,105,108,101, 10, 9,105,102, 32,110, + 111,116, 32,102,108, 97,103,115, 46, 80, 32,116,104,101,110, + 10, 9, 9,105,102, 32,102,108, 97,103,115, 46, 72, 32,116, + 104,101,110, 10, 9, 9, 9,108,111, 99, 97,108, 32,115,116, + 44,109,115,103, 32, 61, 32,119,114,105,116,101,116,111, 40, + 102,108, 97,103,115, 46, 72, 41, 10, 9, 9, 9,105,102, 32, + 110,111,116, 32,115,116, 32,116,104,101,110, 10, 9, 9, 9, + 9,101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,115,103, + 41, 10, 9, 9, 9,101,110,100, 10, 9, 9, 9,112, 58,104, + 101, 97,100,101,114, 40, 41, 10, 9, 9, 9,119,114,105,116, + 101,116,111, 40, 41, 10, 9, 9,101,110,100, 10, 9,101,110, + 100, 10,101,110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: lua/tolua++/src/bin/lua/doit.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static unsigned char B[] = { + 10,108,111, 99, 97,108, 32,101,114,114, 44,109,115,103, 32, + 61, 32,112, 99, 97,108,108, 40,100,111,105,116, 41, 10,105, + 102, 32,110,111,116, 32,101,114,114, 32,116,104,101,110, 10, + 32,108,111, 99, 97,108, 32, 95, 44, 95, 44,108, 97, 98,101, + 108, 44,109,115,103, 32, 61, 32,115,116,114,102,105,110,100, + 40,109,115,103, 44, 34, 40, 46, 45, 58, 46, 45, 58, 37,115, + 42, 41, 40, 46, 42, 41, 34, 41, 10, 32,116,111,108,117, 97, + 95,101,114,114,111,114, 40,109,115,103, 44,108, 97, 98,101, + 108, 41, 10, 32,112,114,105,110,116, 40,100,101, 98,117,103, + 46,116,114, 97, 99,101, 98, 97, 99,107, 40, 41, 41, 10,101, + 110,100,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 23"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + tolua_endmodule(tolua_S); + return 1; +} + + +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + TOLUA_API int luaopen_tolua (lua_State* tolua_S) { + return tolua_tolua_open(tolua_S); +}; +#endif + diff --git a/third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.h b/third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.h new file mode 100644 index 000000000..c31a14875 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/bin/toluabind_default.h @@ -0,0 +1,8 @@ +/* +** Lua binding: tolua +** Generated automatically by tolua++-1.0.8pre2 on Tue Dec 13 01:43:55 2005. +*/ + +/* Exported function */ +TOLUA_API int tolua_tolua_open (lua_State* tolua_S); + diff --git a/third-party/lua-5.1.5/toluapp/src/lib/SCsub b/third-party/lua-5.1.5/toluapp/src/lib/SCsub new file mode 100644 index 000000000..2f9a24691 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/SCsub @@ -0,0 +1,18 @@ +Import('env') + + +sources = [ + 'tolua_event.c', + 'tolua_is.c', + 'tolua_map.c', + 'tolua_push.c', + 'tolua_to.c', + ] + +env.lib_target_static = env.Library('#/lib/'+env['tolua_lib']+'_static', sources) + +if env['shared']: + env.lib_target = env.SharedLibrary('#lib/'+env['tolua_lib'], sources) +else: + env.lib_target = env.Library('#/lib/'+env['tolua_lib'], sources) + diff --git a/third-party/lua-5.1.5/toluapp/src/lib/tolua_event.c b/third-party/lua-5.1.5/toluapp/src/lib/tolua_event.c new file mode 100644 index 000000000..8258867b4 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/tolua_event.c @@ -0,0 +1,536 @@ +/* tolua: event functions +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include + +#include "tolua++.h" + +/* Store at ubox + * It stores, creating the corresponding table if needed, + * the pair key/value in the corresponding ubox table +*/ +static void storeatubox (lua_State* L, int lo) +{ + #ifdef LUA_VERSION_NUM + lua_getfenv(L, lo); + if (lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pop(L, 1); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setfenv(L, lo); /* stack: k,v,table */ + }; + lua_insert(L, -3); + lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */ + lua_pop(L, 1); + #else + /* stack: key value (to be stored) */ + lua_pushstring(L,"tolua_peers"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: k v ubox */ + lua_pushvalue(L,lo); + lua_rawget(L,-2); /* stack: k v ubox ubox[u] */ + if (!lua_istable(L,-1)) + { + lua_pop(L,1); /* stack: k v ubox */ + lua_newtable(L); /* stack: k v ubox table */ + lua_pushvalue(L,1); + lua_pushvalue(L,-2); /* stack: k v ubox table u table */ + lua_rawset(L,-4); /* stack: k v ubox ubox[u]=table */ + } + lua_insert(L,-4); /* put table before k */ + lua_pop(L,1); /* pop ubox */ + lua_rawset(L,-3); /* store at table */ + lua_pop(L,1); /* pop ubox[u] */ + #endif +} + +/* Module index function +*/ +static int module_index_event (lua_State* L) +{ + lua_pushstring(L,".get"); + lua_rawget(L,-3); + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { + lua_call(L,0,1); + return 1; + } + else if (lua_istable(L,-1)) + return 1; + } + /* call old index meta event */ + if (lua_getmetatable(L,1)) + { + lua_pushstring(L,"__index"); + lua_rawget(L,-2); + lua_pushvalue(L,1); + lua_pushvalue(L,2); + if (lua_isfunction(L,-1)) + { + lua_call(L,2,1); + return 1; + } + else if (lua_istable(L,-1)) + { + lua_gettable(L,-3); + return 1; + } + } + lua_pushnil(L); + return 1; +} + +/* Module newindex function +*/ +static int module_newindex_event (lua_State* L) +{ + lua_pushstring(L,".set"); + lua_rawget(L,-4); + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); /* only to be compatible with non-static vars */ + lua_pushvalue(L,3); /* value */ + lua_call(L,2,0); + return 0; + } + } + /* call old newindex meta event */ + if (lua_getmetatable(L,1) && lua_getmetatable(L,-1)) + { + lua_pushstring(L,"__newindex"); + lua_rawget(L,-2); + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_pushvalue(L,3); + lua_call(L,3,0); + } + } + lua_settop(L,3); + lua_rawset(L,-3); + return 0; +} + +/* Class index function + * If the object is a userdata (ie, an object), it searches the field in + * the alternative table stored in the corresponding "ubox" table. +*/ +static int class_index_event (lua_State* L) +{ + int t = lua_type(L,1); + if (t == LUA_TUSERDATA) + { + /* Access alternative table */ + #ifdef LUA_VERSION_NUM /* new macro on version 5.1 */ + lua_getfenv(L,1); + if (!lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pushvalue(L, 2); /* key */ + lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */ + if (!lua_isnil(L, -1)) + return 1; + }; + #else + lua_pushstring(L,"tolua_peers"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: obj key ubox */ + lua_pushvalue(L,1); + lua_rawget(L,-2); /* stack: obj key ubox ubox[u] */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* stack: obj key ubox ubox[u] value */ + if (!lua_isnil(L,-1)) + return 1; + } + #endif + lua_settop(L,2); /* stack: obj key */ + /* Try metatables */ + lua_pushvalue(L,1); /* stack: obj key obj */ + while (lua_getmetatable(L,-1)) + { /* stack: obj key obj mt */ + lua_remove(L,-2); /* stack: obj key mt */ + if (lua_isnumber(L,2)) /* check if key is a numeric value */ + { + /* try operator[] */ + lua_pushstring(L,".geti"); + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + } + else + { + lua_pushvalue(L,2); /* stack: obj key mt key */ + lua_rawget(L,-2); /* stack: obj key mt value */ + if (!lua_isnil(L,-1)) + return 1; + else + lua_pop(L,1); + /* try C/C++ variable */ + lua_pushstring(L,".get"); + lua_rawget(L,-2); /* stack: obj key mt tget */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); + lua_rawget(L,-2); /* stack: obj key mt value */ + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + else if (lua_istable(L,-1)) + { + /* deal with array: create table to be returned and cache it in ubox */ + void* u = *((void**)lua_touserdata(L,1)); + lua_newtable(L); /* stack: obj key mt value table */ + lua_pushstring(L,".self"); + lua_pushlightuserdata(L,u); + lua_rawset(L,-3); /* store usertype in ".self" */ + lua_insert(L,-2); /* stack: obj key mt table value */ + lua_setmetatable(L,-2); /* set stored value as metatable */ + lua_pushvalue(L,-1); /* stack: obj key met table table */ + lua_pushvalue(L,2); /* stack: obj key mt table table key */ + lua_insert(L,-2); /* stack: obj key mt table key table */ + storeatubox(L,1); /* stack: obj key mt table */ + return 1; + } + } + } + lua_settop(L,3); + } + lua_pushnil(L); + return 1; + } + else if (t== LUA_TTABLE) + { + module_index_event(L); + return 1; + } + lua_pushnil(L); + return 1; +} + +/* Newindex function + * It first searches for a C/C++ varaible to be set. + * Then, it either stores it in the alternative ubox table (in the case it is + * an object) or in the own table (that represents the class or module). +*/ +static int class_newindex_event (lua_State* L) +{ + int t = lua_type(L,1); + if (t == LUA_TUSERDATA) + { + /* Try accessing a C/C++ variable to be set */ + lua_getmetatable(L,1); + while (lua_istable(L,-1)) /* stack: t k v mt */ + { + if (lua_isnumber(L,2)) /* check if key is a numeric value */ + { + /* try operator[] */ + lua_pushstring(L,".seti"); + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_pushvalue(L,3); + lua_call(L,3,0); + return 0; + } + } + else + { + lua_pushstring(L,".set"); + lua_rawget(L,-2); /* stack: t k v mt tset */ + if (lua_istable(L,-1)) + { + lua_pushvalue(L,2); + lua_rawget(L,-2); /* stack: t k v mt tset func */ + if (lua_iscfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,3); + lua_call(L,2,0); + return 0; + } + lua_pop(L,1); /* stack: t k v mt tset */ + } + lua_pop(L,1); /* stack: t k v mt */ + if (!lua_getmetatable(L,-1)) /* stack: t k v mt mt */ + lua_pushnil(L); + lua_remove(L,-2); /* stack: t k v mt */ + } + } + lua_settop(L,3); /* stack: t k v */ + + /* then, store as a new field */ + storeatubox(L,1); + } + else if (t== LUA_TTABLE) + { + module_newindex_event(L); + } + return 0; +} + +static int class_call_event(lua_State* L) { + + if (lua_istable(L, 1)) { + lua_pushstring(L, ".call"); + lua_rawget(L, 1); + if (lua_isfunction(L, -1)) { + + lua_insert(L, 1); + lua_call(L, lua_gettop(L)-1, 1); + + return 1; + }; + }; + tolua_error(L,"Attempt to call a non-callable object.",NULL); + return 0; +}; + +static int do_operator (lua_State* L, const char* op) +{ + if (lua_isuserdata(L,1)) + { + /* Try metatables */ + lua_pushvalue(L,1); /* stack: op1 op2 */ + while (lua_getmetatable(L,-1)) + { /* stack: op1 op2 op1 mt */ + lua_remove(L,-2); /* stack: op1 op2 mt */ + lua_pushstring(L,op); /* stack: op1 op2 mt key */ + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + lua_settop(L,3); + } + } + tolua_error(L,"Attempt to perform operation on an invalid operand",NULL); + return 0; +} + +static int class_add_event (lua_State* L) +{ + return do_operator(L,".add"); +} + +static int class_sub_event (lua_State* L) +{ + return do_operator(L,".sub"); +} + +static int class_mul_event (lua_State* L) +{ + return do_operator(L,".mul"); +} + +static int class_div_event (lua_State* L) +{ + return do_operator(L,".div"); +} + +static int class_lt_event (lua_State* L) +{ + return do_operator(L,".lt"); +} + +static int class_le_event (lua_State* L) +{ + return do_operator(L,".le"); +} + +static int class_eq_event (lua_State* L) +{ + /* copying code from do_operator here to return false when no operator is found */ + if (lua_isuserdata(L,1)) + { + /* Try metatables */ + lua_pushvalue(L,1); /* stack: op1 op2 */ + while (lua_getmetatable(L,-1)) + { /* stack: op1 op2 op1 mt */ + lua_remove(L,-2); /* stack: op1 op2 mt */ + lua_pushstring(L,".eq"); /* stack: op1 op2 mt key */ + lua_rawget(L,-2); /* stack: obj key mt func */ + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_pushvalue(L,2); + lua_call(L,2,1); + return 1; + } + lua_settop(L,3); + } + } + + lua_settop(L, 3); + lua_pushboolean(L, 0); + return 1; +} + +/* +static int class_gc_event (lua_State* L) +{ + void* u = *((void**)lua_touserdata(L,1)); + fprintf(stderr, "collecting: looking at %p\n", u); + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); + if (lua_isfunction(L,-1)) + { + lua_pushvalue(L,1); + lua_call(L,1,0); + lua_pushlightuserdata(L,u); + lua_pushnil(L); + lua_rawset(L,-3); + } + lua_pop(L,2); + return 0; +} +*/ +TOLUA_API int class_gc_event (lua_State* L) +{ + void* u = *((void**)lua_touserdata(L,1)); + int top; + /*fprintf(stderr, "collecting: looking at %p\n", u);*/ + /* + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + */ + lua_pushvalue(L, lua_upvalueindex(1)); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); /* stack: gc umt */ + lua_getmetatable(L,1); /* stack: gc umt mt */ + /*fprintf(stderr, "checking type\n");*/ + top = lua_gettop(L); + if (tolua_fast_isa(L,top,top-1, lua_upvalueindex(2))) /* make sure we collect correct type */ + { + /*fprintf(stderr, "Found type!\n");*/ + /* get gc function */ + lua_pushliteral(L,".collector"); + lua_rawget(L,-2); /* stack: gc umt mt collector */ + if (lua_isfunction(L,-1)) { + /*fprintf(stderr, "Found .collector!\n");*/ + } + else { + lua_pop(L,1); + /*fprintf(stderr, "Using default cleanup\n");*/ + lua_pushcfunction(L,tolua_default_collect); + } + + lua_pushvalue(L,1); /* stack: gc umt mt collector u */ + lua_call(L,1,0); + + lua_pushlightuserdata(L,u); /* stack: gc umt mt u */ + lua_pushnil(L); /* stack: gc umt mt u nil */ + lua_rawset(L,-5); /* stack: gc umt mt */ + } + lua_pop(L,3); + return 0; +} + + +/* Register module events + * It expects the metatable on the top of the stack +*/ +TOLUA_API void tolua_moduleevents (lua_State* L) +{ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,module_index_event); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,module_newindex_event); + lua_rawset(L,-3); +} + +/* Check if the object on the top has a module metatable +*/ +TOLUA_API int tolua_ismodulemetatable (lua_State* L) +{ + int r = 0; + if (lua_getmetatable(L,-1)) + { + lua_pushstring(L,"__index"); + lua_rawget(L,-2); + r = (lua_tocfunction(L,-1) == module_index_event); + lua_pop(L,2); + } + return r; +} + +/* Register class events + * It expects the metatable on the top of the stack +*/ +TOLUA_API void tolua_classevents (lua_State* L) +{ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,class_index_event); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,class_newindex_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__add"); + lua_pushcfunction(L,class_add_event); + lua_rawset(L,-3); + lua_pushstring(L,"__sub"); + lua_pushcfunction(L,class_sub_event); + lua_rawset(L,-3); + lua_pushstring(L,"__mul"); + lua_pushcfunction(L,class_mul_event); + lua_rawset(L,-3); + lua_pushstring(L,"__div"); + lua_pushcfunction(L,class_div_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__lt"); + lua_pushcfunction(L,class_lt_event); + lua_rawset(L,-3); + lua_pushstring(L,"__le"); + lua_pushcfunction(L,class_le_event); + lua_rawset(L,-3); + lua_pushstring(L,"__eq"); + lua_pushcfunction(L,class_eq_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__call"); + lua_pushcfunction(L,class_call_event); + lua_rawset(L,-3); + + lua_pushstring(L,"__gc"); + lua_pushstring(L, "tolua_gc_event"); + lua_rawget(L, LUA_REGISTRYINDEX); + /*lua_pushcfunction(L,class_gc_event);*/ + lua_rawset(L,-3); +} + diff --git a/third-party/lua-5.1.5/toluapp/src/lib/tolua_event.h b/third-party/lua-5.1.5/toluapp/src/lib/tolua_event.h new file mode 100644 index 000000000..898f33dfc --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/tolua_event.h @@ -0,0 +1,24 @@ +/* tolua: event functions +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#ifndef TOLUA_EVENT_H +#define TOLUA_EVENT_H + +#include "tolua++.h" + +TOLUA_API void tolua_moduleevents (lua_State* L); +TOLUA_API int tolua_ismodulemetatable (lua_State* L); +TOLUA_API void tolua_classevents (lua_State* L); + +#endif diff --git a/third-party/lua-5.1.5/toluapp/src/lib/tolua_is.c b/third-party/lua-5.1.5/toluapp/src/lib/tolua_is.c new file mode 100644 index 000000000..add337d19 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/tolua_is.c @@ -0,0 +1,621 @@ +/* tolua: functions to check types. +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "lauxlib.h" + +#include +#include + +/* a fast check if a is b, without parameter validation + i.e. if b is equal to a or a superclass of a. */ +TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index) +{ + int result; + if (lua_rawequal(L,mt_indexa,mt_indexb)) + result = 1; + else + { + if (super_index) { + lua_pushvalue(L, super_index); + } else { + lua_pushliteral(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ + }; + lua_pushvalue(L,mt_indexa); /* stack: super mta */ + lua_rawget(L,-2); /* stack: super super[mta] */ + lua_pushvalue(L,mt_indexb); /* stack: super super[mta] mtb */ + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super super[mta] typenameB */ + lua_rawget(L,-2); /* stack: super super[mta] bool */ + result = lua_toboolean(L,-1); + lua_pop(L,3); + } + return result; +} + +/* Push and returns the corresponding object typename */ +TOLUA_API const char* tolua_typename (lua_State* L, int lo) +{ + int tag = lua_type(L,lo); + if (tag == LUA_TNONE) + lua_pushstring(L,"[no object]"); + else if (tag != LUA_TUSERDATA && tag != LUA_TTABLE) + lua_pushstring(L,lua_typename(L,tag)); + else if (tag == LUA_TUSERDATA) + { + if (!lua_getmetatable(L,lo)) + lua_pushstring(L,lua_typename(L,tag)); + else + { + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isstring(L,-1)) + { + lua_pop(L,1); + lua_pushstring(L,"[undefined]"); + } + } + } + else /* is table */ + { + lua_pushvalue(L,lo); + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isstring(L,-1)) + { + lua_pop(L,1); + lua_pushstring(L,"table"); + } + else + { + lua_pushstring(L,"class "); + lua_insert(L,-2); + lua_concat(L,2); + } + } + return lua_tostring(L,-1); +} + +TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err) +{ + if (msg[0] == '#') + { + const char* expected = err->type; + const char* provided = tolua_typename(L,err->index); + if (msg[1]=='f') + { + int narg = err->index; + if (err->array) + luaL_error(L,"%s\n argument #%d is array of '%s'; array of '%s' expected.\n", + msg+2,narg,provided,expected); + else + luaL_error(L,"%s\n argument #%d is '%s'; '%s' expected.\n", + msg+2,narg,provided,expected); + } + else if (msg[1]=='v') + { + if (err->array) + luaL_error(L,"%s\n value is array of '%s'; array of '%s' expected.\n", + msg+2,provided,expected); + else + luaL_error(L,"%s\n value is '%s'; '%s' expected.\n", + msg+2,provided,expected); + } + } + else + luaL_error(L,msg); +} + +/* the equivalent of lua_is* for usertable */ +static int lua_isusertable (lua_State* L, int lo, const const char* type) +{ + int r = 0; + if (lo < 0) lo = lua_gettop(L)+lo+1; + lua_pushvalue(L,lo); + lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[t] */ + if (lua_isstring(L,-1)) + { + r = strcmp(lua_tostring(L,-1),type)==0; + if (!r) + { + /* try const */ + lua_pushstring(L,"const "); + lua_insert(L,-2); + lua_concat(L,2); + r = lua_isstring(L,-1) && strcmp(lua_tostring(L,-1),type)==0; + } + } + lua_pop(L, 1); + return r; +} + +int push_table_instance(lua_State* L, int lo) { + + if (lua_istable(L, lo)) { + + lua_pushstring(L, ".c_instance"); + lua_gettable(L, lo); + if (lua_isuserdata(L, -1)) { + + lua_replace(L, lo); + return 1; + } else { + + lua_pop(L, 1); + return 0; + }; + } else { + return 0; + }; + + return 0; +}; + +/* the equivalent of lua_is* for usertype */ +static int lua_isusertype (lua_State* L, int lo, const char* type) +{ + if (!lua_isuserdata(L,lo)) { + if (!push_table_instance(L, lo)) { + return 0; + }; + }; + { + /* check if it is of the same type */ + int r; + const char *tn; + if (lua_getmetatable(L,lo)) /* if metatable? */ + { + lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[mt] */ + tn = lua_tostring(L,-1); + r = tn && (strcmp(tn,type) == 0); + lua_pop(L, 1); + if (r) + return 1; + else + { + /* check if it is a specialized class */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* get super */ + lua_getmetatable(L,lo); + lua_rawget(L,-2); /* get super[mt] */ + if (lua_istable(L,-1)) + { + int b; + lua_pushstring(L,type); + lua_rawget(L,-2); /* get super[mt][type] */ + b = lua_toboolean(L,-1); + lua_pop(L,3); + if (b) + return 1; + } + } + } + } + return 0; +} + +TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err) +{ + if (lua_gettop(L)index = lo; + err->array = 0; + err->type = "[no object]"; + return 0; +} + +TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "boolean"; + return 0; +} + +TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "number"; + return 0; +} + +TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "string"; + return 0; +} + +TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "table"; + return 0; +} + +TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = type; + return 0; +} + + +TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = "userdata"; + return 0; +} + +TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) { + + if (lua_gettop(L)index = lo; + err->array = 0; + err->type = "value"; + return 1; +}; + +TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err) +{ + if (def || abs(lo)<=lua_gettop(L)) /* any valid index */ + return 1; + err->index = lo; + err->array = 0; + err->type = "value"; + return 0; +} + +TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err) +{ + if (def && lua_gettop(L)index = lo; + err->array = 0; + err->type = type; + return 0; +} + +TOLUA_API int tolua_isvaluearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + return 1; +} + +TOLUA_API int tolua_isbooleanarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "boolean"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isnumberarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!lua_isnumber(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "number"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isstringarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "string"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_istablearray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (! lua_istable(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "table"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isuserdataarray + (lua_State* L, int lo, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "userdata"; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +TOLUA_API int tolua_isusertypearray + (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err) +{ + if (!tolua_istable(L,lo,def,err)) + return 0; + else + { + int i; + for (i=1; i<=dim; ++i) + { + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->type = type; + err->array = 1; + return 0; + } + lua_pop(L,1); + } + } + return 1; +} + +#if 0 +int tolua_isbooleanfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "boolean"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isnumberfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!lua_isnumber(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "number"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isstringfield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "string"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_istablefield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i+1); + lua_gettable(L,lo); + if (! lua_istable(L,-1) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "table"; + return 0; + } + lua_pop(L,1); +} + +int tolua_isusertablefield + (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (! lua_isusertable(L,-1,type) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = type; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isuserdatafield + (lua_State* L, int lo, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->array = 1; + err->type = "userdata"; + return 0; + } + lua_pop(L,1); + return 1; +} + +int tolua_isusertypefield + (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) +{ + lua_pushnumber(L,i); + lua_gettable(L,lo); + if (!(lua_isnil(L,-1) || lua_isusertype(L,-1,type)) && + !(def && lua_isnil(L,-1)) + ) + { + err->index = lo; + err->type = type; + err->array = 1; + return 0; + } + lua_pop(L,1); + return 1; +} + +#endif diff --git a/third-party/lua-5.1.5/toluapp/src/lib/tolua_map.c b/third-party/lua-5.1.5/toluapp/src/lib/tolua_map.c new file mode 100644 index 000000000..d00e7069b --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/tolua_map.c @@ -0,0 +1,704 @@ +/* tolua: functions to map features +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "tolua_event.h" +#include "lauxlib.h" + +#include +#include +#include +#include + + +/* Create metatable + * Create and register new metatable +*/ +static int tolua_newmetatable (lua_State* L, char* name) +{ + int r = luaL_newmetatable(L,name); + + #ifdef LUA_VERSION_NUM /* only lua 5.1 */ + if (r) { + lua_pushvalue(L, -1); + lua_pushstring(L, name); + lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */ + }; + #endif + + if (r) + tolua_classevents(L); /* set meta events */ + lua_pop(L,1); + return r; +} + +/* Map super classes + * It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name' +*/ +static void mapsuper (lua_State* L, const char* name, const char* base) +{ + /* push registry.super */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ + luaL_getmetatable(L,name); /* stack: super mt */ + lua_rawget(L,-2); /* stack: super table */ + if (lua_isnil(L,-1)) + { + /* create table */ + lua_pop(L,1); + lua_newtable(L); /* stack: super table */ + luaL_getmetatable(L,name); /* stack: super table mt */ + lua_pushvalue(L,-2); /* stack: super table mt table */ + lua_rawset(L,-4); /* stack: super table */ + } + + /* set base as super class */ + lua_pushstring(L,base); + lua_pushboolean(L,1); + lua_rawset(L,-3); /* stack: super table */ + + /* set all super class of base as super class of name */ + luaL_getmetatable(L,base); /* stack: super table base_mt */ + lua_rawget(L,-3); /* stack: super table base_table */ + if (lua_istable(L,-1)) + { + /* traverse base table */ + lua_pushnil(L); /* first key */ + while (lua_next(L,-2) != 0) + { + /* stack: ... base_table key value */ + lua_pushvalue(L,-2); /* stack: ... base_table key value key */ + lua_insert(L,-2); /* stack: ... base_table key key value */ + lua_rawset(L,-5); /* stack: ... base_table key */ + } + } + lua_pop(L,3); /* stack: */ +} + +/* creates a 'tolua_ubox' table for base clases, and +// expects the metatable and base metatable on the stack */ +static void set_ubox(lua_State* L) { + + /* mt basemt */ + if (!lua_isnil(L, -1)) { + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L,-2); + } else { + lua_pushnil(L); + }; + /* mt basemt base_ubox */ + if (!lua_isnil(L,-1)) { + lua_pushstring(L, "tolua_ubox"); + lua_insert(L, -2); + /* mt basemt key ubox */ + lua_rawset(L,-4); + /* (mt with ubox) basemt */ + } else { + /* mt basemt nil */ + lua_pop(L, 1); + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be + garbage-collected */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ + lua_setmetatable(L, -2); /* stack:mt basemt string ubox */ + lua_rawset(L,-4); + }; + +}; + +/* Map inheritance + * It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name' +*/ +static void mapinheritance (lua_State* L, const char* name, const char* base) +{ + /* set metatable inheritance */ + luaL_getmetatable(L,name); + + if (base && *base) + luaL_getmetatable(L,base); + else { + + if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */ + lua_pop(L, 2); + return; + }; + luaL_getmetatable(L,"tolua_commonclass"); + }; + + set_ubox(L); + + lua_setmetatable(L,-2); + lua_pop(L,1); +} + +/* Object type +*/ +static int tolua_bnd_type (lua_State* L) +{ + tolua_typename(L,lua_gettop(L)); + return 1; +} + +/* Take ownership +*/ +static int tolua_bnd_takeownership (lua_State* L) +{ + int success = 0; + if (lua_isuserdata(L,1)) + { + if (lua_getmetatable(L,1)) /* if metatable? */ + { + lua_pop(L,1); /* clear metatable off stack */ + /* force garbage collection to avoid C to reuse a to-be-collected address */ + #ifdef LUA_VERSION_NUM + lua_gc(L, LUA_GCCOLLECT, 0); + #else + lua_setgcthreshold(L,0); + #endif + + success = tolua_register_gc(L,1); + } + } + lua_pushboolean(L,success!=0); + return 1; +} + +/* Release ownership +*/ +static int tolua_bnd_releaseownership (lua_State* L) +{ + int done = 0; + if (lua_isuserdata(L,1)) + { + void* u = *((void**)lua_touserdata(L,1)); + /* force garbage collection to avoid releasing a to-be-collected address */ + #ifdef LUA_VERSION_NUM + lua_gc(L, LUA_GCCOLLECT, 0); + #else + lua_setgcthreshold(L,0); + #endif + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,u); + lua_rawget(L,-2); + lua_getmetatable(L,1); + if (lua_rawequal(L,-1,-2)) /* check that we are releasing the correct type */ + { + lua_pushlightuserdata(L,u); + lua_pushnil(L); + lua_rawset(L,-5); + done = 1; + } + } + lua_pushboolean(L,done!=0); + return 1; +} + +/* Type casting +*/ +static int tolua_bnd_cast (lua_State* L) +{ + +/* // old code + void* v = tolua_tousertype(L,1,NULL); + const char* s = tolua_tostring(L,2,NULL); + if (v && s) + tolua_pushusertype(L,v,s); + else + lua_pushnil(L); + return 1; +*/ + + void* v; + const char* s; + if (lua_islightuserdata(L, 1)) { + v = tolua_touserdata(L, 1, NULL); + } else { + v = tolua_tousertype(L, 1, 0); + }; + + s = tolua_tostring(L,2,NULL); + if (v && s) + tolua_pushusertype(L,v,s); + else + lua_pushnil(L); + return 1; +} + +/* Inheritance +*/ +static int tolua_bnd_inherit (lua_State* L) { + + /* stack: lua object, c object */ + lua_pushstring(L, ".c_instance"); + lua_pushvalue(L, -2); + lua_rawset(L, -4); + /* l_obj[".c_instance"] = c_obj */ + + return 0; +}; + +#ifdef LUA_VERSION_NUM /* lua 5.1 */ +static int tolua_bnd_setpeer(lua_State* L) { + + /* stack: userdata, table */ + if (!lua_isuserdata(L, -2)) { + lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected."); + lua_error(L); + }; + + if (lua_isnil(L, -1)) { + + lua_pop(L, 1); + lua_pushvalue(L, TOLUA_NOPEER); + }; + lua_setfenv(L, -2); + + return 0; +}; + +static int tolua_bnd_getpeer(lua_State* L) { + + /* stack: userdata */ + lua_getfenv(L, -1); + if (lua_rawequal(L, -1, TOLUA_NOPEER)) { + lua_pop(L, 1); + lua_pushnil(L); + }; + return 1; +}; +#endif + +/* static int class_gc_event (lua_State* L); */ + +TOLUA_API void tolua_open (lua_State* L) +{ + int top = lua_gettop(L); + lua_pushstring(L,"tolua_opened"); + lua_rawget(L,LUA_REGISTRYINDEX); + if (!lua_isboolean(L,-1)) + { + lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX); + + #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */ + /* create peer object table */ + lua_pushstring(L, "tolua_peers"); lua_newtable(L); + /* make weak key metatable for peers indexed by userdata object */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3); /* stack: string peers mt */ + lua_setmetatable(L, -2); /* stack: string peers */ + lua_rawset(L,LUA_REGISTRYINDEX); + #endif + + /* create object ptr -> udata mapping table */ + lua_pushstring(L,"tolua_ubox"); lua_newtable(L); + /* make weak value metatable for ubox table to allow userdata to be + garbage-collected */ + lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ + lua_setmetatable(L, -2); /* stack: string ubox */ + lua_rawset(L,LUA_REGISTRYINDEX); + + lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX); + lua_pushstring(L,"tolua_gc"); lua_newtable(L);lua_rawset(L,LUA_REGISTRYINDEX); + + /* create gc_event closure */ + lua_pushstring(L, "tolua_gc_event"); + lua_pushstring(L, "tolua_gc"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushstring(L, "tolua_super"); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushcclosure(L, class_gc_event, 2); + lua_rawset(L, LUA_REGISTRYINDEX); + + tolua_newmetatable(L,"tolua_commonclass"); + + tolua_module(L,NULL,0); + tolua_beginmodule(L,NULL); + tolua_module(L,"tolua",0); + tolua_beginmodule(L,"tolua"); + tolua_function(L,"type",tolua_bnd_type); + tolua_function(L,"takeownership",tolua_bnd_takeownership); + tolua_function(L,"releaseownership",tolua_bnd_releaseownership); + tolua_function(L,"cast",tolua_bnd_cast); + tolua_function(L,"inherit", tolua_bnd_inherit); + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + tolua_function(L, "setpeer", tolua_bnd_setpeer); + tolua_function(L, "getpeer", tolua_bnd_getpeer); + #endif + + tolua_endmodule(L); + tolua_endmodule(L); + } + lua_settop(L,top); +} + +/* Copy a C object +*/ +TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size) +{ + void* clone = (void*)malloc(size); + if (clone) + memcpy(clone,value,size); + else + tolua_error(L,"insuficient memory",NULL); + return clone; +} + +/* Default collect function +*/ +TOLUA_API int tolua_default_collect (lua_State* tolua_S) +{ + void* self = tolua_tousertype(tolua_S,1,0); + free(self); + return 0; +} + +/* Do clone +*/ +TOLUA_API int tolua_register_gc (lua_State* L, int lo) +{ + int success = 1; + void *value = *(void **)lua_touserdata(L,lo); + lua_pushstring(L,"tolua_gc"); + lua_rawget(L,LUA_REGISTRYINDEX); + lua_pushlightuserdata(L,value); + lua_rawget(L,-2); + if (!lua_isnil(L,-1)) /* make sure that object is not already owned */ + success = 0; + else + { + lua_pushlightuserdata(L,value); + lua_getmetatable(L,lo); + lua_rawset(L,-4); + } + lua_pop(L,2); + return success; +} + +/* Register a usertype + * It creates the correspoding metatable in the registry, for both 'type' and 'const type'. + * It maps 'const type' as being also a 'type' +*/ +TOLUA_API void tolua_usertype (lua_State* L, const char* type) +{ + char ctype[128] = "const "; + strncat(ctype,type,120); + + /* create both metatables */ + if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type)) + mapsuper(L,type,ctype); /* 'type' is also a 'const type' */ +} + + +/* Begin module + * It pushes the module (or class) table on the stack +*/ +TOLUA_API void tolua_beginmodule (lua_State* L, const char* name) +{ + if (name) + { + lua_pushstring(L,name); + lua_rawget(L,-2); + } + else + lua_pushvalue(L,LUA_GLOBALSINDEX); +} + +/* End module + * It pops the module (or class) from the stack +*/ +TOLUA_API void tolua_endmodule (lua_State* L) +{ + lua_pop(L,1); +} + +/* Map module + * It creates a new module +*/ +#if 1 +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) +{ + if (name) + { + /* tolua module */ + lua_pushstring(L,name); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) /* check if module already exists */ + { + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,name); + lua_pushvalue(L,-2); + lua_rawset(L,-4); /* assing module into module */ + } + } + else + { + /* global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + } + if (hasvar) + { + if (!tolua_ismodulemetatable(L)) /* check if it already has a module metatable */ + { + /* create metatable to get/set C/C++ variable */ + lua_newtable(L); + tolua_moduleevents(L); + if (lua_getmetatable(L,-2)) + lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ + lua_setmetatable(L,-2); + } + } + lua_pop(L,1); /* pop module */ +} +#else +TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) +{ + if (name) + { + /* tolua module */ + lua_pushstring(L,name); + lua_newtable(L); + } + else + { + /* global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + } + if (hasvar) + { + /* create metatable to get/set C/C++ variable */ + lua_newtable(L); + tolua_moduleevents(L); + if (lua_getmetatable(L,-2)) + lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ + lua_setmetatable(L,-2); + } + if (name) + lua_rawset(L,-3); /* assing module into module */ + else + lua_pop(L,1); /* pop global table */ +} +#endif + +static void push_collector(lua_State* L, const char* type, lua_CFunction col) { + + /* push collector function, but only if it's not NULL, or if there's no + collector already */ + if (!col) return; + luaL_getmetatable(L,type); + lua_pushstring(L,".collector"); + /* + if (!col) { + lua_pushvalue(L, -1); + lua_rawget(L, -3); + if (!lua_isnil(L, -1)) { + lua_pop(L, 3); + return; + }; + lua_pop(L, 1); + }; + // */ + lua_pushcfunction(L,col); + + lua_rawset(L,-3); + lua_pop(L, 1); +}; + +/* Map C class + * It maps a C class, setting the appropriate inheritance and super classes. +*/ +TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col) +{ + char cname[128] = "const "; + char cbase[128] = "const "; + strncat(cname,name,120); + strncat(cbase,base,120); + + mapinheritance(L,name,base); + mapinheritance(L,cname,name); + + mapsuper(L,cname,cbase); + mapsuper(L,name,base); + + lua_pushstring(L,lname); + + push_collector(L, name, col); + /* + luaL_getmetatable(L,name); + lua_pushstring(L,".collector"); + lua_pushcfunction(L,col); + + lua_rawset(L,-3); + */ + + luaL_getmetatable(L,name); + lua_rawset(L,-3); /* assign class metatable to module */ + + /* now we also need to store the collector table for the const + instances of the class */ + push_collector(L, cname, col); + /* + luaL_getmetatable(L,cname); + lua_pushstring(L,".collector"); + lua_pushcfunction(L,col); + lua_rawset(L,-3); + lua_pop(L,1); + */ + + +} + +/* Add base + * It adds additional base classes to a class (for multiple inheritance) + * (not for now) +TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) { + + char cname[128] = "const "; + char cbase[128] = "const "; + strncat(cname,name,120); + strncat(cbase,base,120); + + mapsuper(L,cname,cbase); + mapsuper(L,name,base); +}; +*/ + +/* Map function + * It assigns a function into the current module (or class) +*/ +TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func) +{ + lua_pushstring(L,name); + lua_pushcfunction(L,func); + lua_rawset(L,-3); +} + +/* sets the __call event for the class (expects the class' main table on top) */ +/* never really worked :( +TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) { + + lua_getmetatable(L, -1); + //luaL_getmetatable(L, type); + lua_pushstring(L,"__call"); + lua_pushcfunction(L,func); + lua_rawset(L,-3); + lua_pop(L, 1); +}; +*/ + +/* Map constant number + * It assigns a constant number into the current module (or class) +*/ +TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value) +{ + lua_pushstring(L,name); + tolua_pushnumber(L,value); + lua_rawset(L,-3); +} + + +/* Map variable + * It assigns a variable into the current module (or class) +*/ +TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) +{ + /* get func */ + lua_pushstring(L,".get"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .get table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".get"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + lua_pushcfunction(L,get); + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .get table */ + + /* set func */ + if (set) + { + lua_pushstring(L,".set"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .set table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".set"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + lua_pushcfunction(L,set); + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .set table */ + } +} + +/* Access const array + * It reports an error when trying to write into a const array +*/ +static int const_array (lua_State* L) +{ + luaL_error(L,"value of const array cannot be changed"); + return 0; +} + +/* Map an array + * It assigns an array into the current module (or class) +*/ +TOLUA_API void tolua_array (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) +{ + lua_pushstring(L,".get"); + lua_rawget(L,-2); + if (!lua_istable(L,-1)) + { + /* create .get table, leaving it at the top */ + lua_pop(L,1); + lua_newtable(L); + lua_pushstring(L,".get"); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } + lua_pushstring(L,name); + + lua_newtable(L); /* create array metatable */ + lua_pushvalue(L,-1); + lua_setmetatable(L,-2); /* set the own table as metatable (for modules) */ + lua_pushstring(L,"__index"); + lua_pushcfunction(L,get); + lua_rawset(L,-3); + lua_pushstring(L,"__newindex"); + lua_pushcfunction(L,set?set:const_array); + lua_rawset(L,-3); + + lua_rawset(L,-3); /* store variable */ + lua_pop(L,1); /* pop .get table */ +} + + +TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) { + + #ifdef LUA_VERSION_NUM /* lua 5.1 */ + luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0); + #else + lua_dobuffer(L, B, size, name); + #endif +}; + diff --git a/third-party/lua-5.1.5/toluapp/src/lib/tolua_push.c b/third-party/lua-5.1.5/toluapp/src/lib/tolua_push.c new file mode 100644 index 000000000..639414755 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/tolua_push.c @@ -0,0 +1,171 @@ +/* tolua: functions to push C values. +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" +#include "lauxlib.h" + +#include + +TOLUA_API void tolua_pushvalue (lua_State* L, int lo) +{ + lua_pushvalue(L,lo); +} + +TOLUA_API void tolua_pushboolean (lua_State* L, int value) +{ + lua_pushboolean(L,value); +} + +TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value) +{ + lua_pushnumber(L,value); +} + +TOLUA_API void tolua_pushstring (lua_State* L, const char* value) +{ + if (value == NULL) + lua_pushnil(L); + else + lua_pushstring(L,value); +} + +TOLUA_API void tolua_pushuserdata (lua_State* L, void* value) +{ + if (value == NULL) + lua_pushnil(L); + else + lua_pushlightuserdata(L,value); +} + +TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type) +{ + if (value == NULL) + lua_pushnil(L); + else + { + luaL_getmetatable(L, type); + lua_pushstring(L,"tolua_ubox"); + lua_rawget(L,-2); /* stack: mt ubox */ + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L, LUA_REGISTRYINDEX); + }; + lua_pushlightuserdata(L,value); + lua_rawget(L,-2); /* stack: mt ubox ubox[u] */ + if (lua_isnil(L,-1)) + { + lua_pop(L,1); /* stack: mt ubox */ + lua_pushlightuserdata(L,value); + *(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox u newud */ + lua_pushvalue(L,-1); /* stack: mt ubox u newud newud */ + lua_insert(L,-4); /* stack: mt newud ubox u newud */ + lua_rawset(L,-3); /* stack: mt newud ubox */ + lua_pop(L,1); /* stack: mt newud */ + /*luaL_getmetatable(L,type);*/ + lua_pushvalue(L, -2); /* stack: mt newud mt */ + lua_setmetatable(L,-2); /* stack: mt newud */ + + #ifdef LUA_VERSION_NUM + lua_pushvalue(L, TOLUA_NOPEER); + lua_setfenv(L, -2); + #endif + } + else + { + /* check the need of updating the metatable to a more specialized class */ + lua_insert(L,-2); /* stack: mt ubox[u] ubox */ + lua_pop(L,1); /* stack: mt ubox[u] */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */ + lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */ + if (lua_istable(L,-1)) + { + lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */ + if (lua_toboolean(L,-1) == 1) /* if true */ + { + lua_pop(L,3); /* mt ubox[u]*/ + lua_remove(L, -2); + return; + } + } + /* type represents a more specilized type */ + /*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */ + lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */ + lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */ + lua_pop(L,3); /* stack: mt ubox[u] */ + } + lua_remove(L, -2); /* stack: ubox[u]*/ + } +} + +TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type) +{ + tolua_pushusertype(L,value,type); + tolua_register_gc(L,lua_gettop(L)); +} + +TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v) +{ + lua_pushnumber(L,index); + lua_pushvalue(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v) +{ + lua_pushnumber(L,index); + lua_pushboolean(L,v); + lua_settable(L,lo); +} + + +TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v) +{ + lua_pushnumber(L,index); + tolua_pushnumber(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v) +{ + lua_pushnumber(L,index); + tolua_pushstring(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v) +{ + lua_pushnumber(L,index); + tolua_pushuserdata(L,v); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type) +{ + lua_pushnumber(L,index); + tolua_pushusertype(L,v,type); + lua_settable(L,lo); +} + +TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type) +{ + lua_pushnumber(L,index); + tolua_pushusertype(L,v,type); + tolua_register_gc(L,lua_gettop(L)); + lua_settable(L,lo); +} + diff --git a/third-party/lua-5.1.5/toluapp/src/lib/tolua_to.c b/third-party/lua-5.1.5/toluapp/src/lib/tolua_to.c new file mode 100644 index 000000000..542ca67d1 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/lib/tolua_to.c @@ -0,0 +1,133 @@ +/* tolua: funcitons to convert to C types +** Support code for Lua bindings. +** Written by Waldemar Celes +** TeCGraf/PUC-Rio +** Apr 2003 +** $Id: $ +*/ + +/* This code is free software; you can redistribute it and/or modify it. +** The software provided hereunder is on an "as is" basis, and +** the author has no obligation to provide maintenance, support, updates, +** enhancements, or modifications. +*/ + +#include "tolua++.h" + +#include +#include + +TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def) +{ + return lua_gettop(L)x); + return 1; +} + +/* set function: x of class Point */ +static int tolua_set_Point_x(lua_State* tolua_S) +{ + Point* self = (Point*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->x = ((float) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: y of class Point */ +static int tolua_get_Point_y(lua_State* tolua_S) +{ + Point* self = (Point*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->y); + return 1; +} + +/* set function: y of class Point */ +static int tolua_set_Point_y(lua_State* tolua_S) +{ + Point* self = (Point*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->y = ((float) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: a */ +static int tolua_get_tarray_a(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushnumber(tolua_S,(double)a[tolua_index]); + return 1; +} + +/* set function: a */ +static int tolua_set_tarray_a(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + a[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0)); + return 0; +} + +/* get function: p */ +static int tolua_get_tarray_p(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&p[tolua_index],"const Point"); + return 1; +} + +/* get function: pp */ +static int tolua_get_tarray_pp(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)pp[tolua_index],"Point"); + return 1; +} + +/* set function: pp */ +static int tolua_set_tarray_pp(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + pp[tolua_index] = ((Point*) tolua_tousertype(tolua_S,3,0)); + return 0; +} + +/* get function: ma */ +static int tolua_get_tarray_M_ma(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushnumber(tolua_S,(double)ma[tolua_index]); + return 1; +} + +/* set function: ma */ +static int tolua_set_tarray_M_ma(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + ma[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0)); + return 0; +} + +/* get function: mp */ +static int tolua_get_tarray_M_mp(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&mp[tolua_index],"const Point"); + return 1; +} + +/* get function: mpp */ +static int tolua_get_tarray_M_mpp(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)mpp[tolua_index],"Point"); + return 1; +} + +/* set function: mpp */ +static int tolua_set_tarray_M_mpp(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + mpp[tolua_index] = ((Point*) tolua_tousertype(tolua_S,3,0)); + return 0; +} + +/* get function: a of class Array */ +static int tolua_get_tarray_Array_a(lua_State* tolua_S) +{ + int tolua_index; + Array* self; + lua_pushstring(tolua_S,".self"); + lua_rawget(tolua_S,1); + self = (Array*) lua_touserdata(tolua_S,-1); +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->a[tolua_index]); + return 1; +} + +/* set function: a of class Array */ +static int tolua_set_tarray_Array_a(lua_State* tolua_S) +{ + int tolua_index; + Array* self; + lua_pushstring(tolua_S,".self"); + lua_rawget(tolua_S,1); + self = (Array*) lua_touserdata(tolua_S,-1); +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + self->a[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0)); + return 0; +} + +/* get function: p of class Array */ +static int tolua_get_tarray_Array_p(lua_State* tolua_S) +{ + int tolua_index; + Array* self; + lua_pushstring(tolua_S,".self"); + lua_rawget(tolua_S,1); + self = (Array*) lua_touserdata(tolua_S,-1); +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&self->p[tolua_index],"Point"); + return 1; +} + +/* set function: p of class Array */ +static int tolua_set_tarray_Array_p(lua_State* tolua_S) +{ + int tolua_index; + Array* self; + lua_pushstring(tolua_S,".self"); + lua_rawget(tolua_S,1); + self = (Array*) lua_touserdata(tolua_S,-1); +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + self->p[tolua_index] = *((Point*) tolua_tousertype(tolua_S,3,0)); + return 0; +} + +/* get function: pp of class Array */ +static int tolua_get_tarray_Array_pp(lua_State* tolua_S) +{ + int tolua_index; + Array* self; + lua_pushstring(tolua_S,".self"); + lua_rawget(tolua_S,1); + self = (Array*) lua_touserdata(tolua_S,-1); +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->pp[tolua_index],"Point"); + return 1; +} + +/* set function: pp of class Array */ +static int tolua_set_tarray_Array_pp(lua_State* tolua_S) +{ + int tolua_index; + Array* self; + lua_pushstring(tolua_S,".self"); + lua_rawget(tolua_S,1); + self = (Array*) lua_touserdata(tolua_S,-1); +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1; +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=10) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + self->pp[tolua_index] = ((Point*) tolua_tousertype(tolua_S,3,0)); + return 0; +} + +/* get function: array */ +static int tolua_get_array(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)&array,"Array"); + return 1; +} + +/* set function: array */ +static int tolua_set_array(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"Array",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + array = *((Array*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: parray */ +static int tolua_get_parray_ptr(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)parray,"Array"); + return 1; +} + +/* set function: parray */ +static int tolua_set_parray_ptr(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"Array",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + parray = ((Array*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* Open function */ +TOLUA_API int tolua_tarray_open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,1); + tolua_beginmodule(tolua_S,NULL); +#ifdef __cplusplus + tolua_cclass(tolua_S,"Point","Point","",tolua_collect_Point); +#else + tolua_cclass(tolua_S,"Point","Point","",NULL); +#endif + tolua_beginmodule(tolua_S,"Point"); + tolua_variable(tolua_S,"x",tolua_get_Point_x,tolua_set_Point_x); + tolua_variable(tolua_S,"y",tolua_get_Point_y,tolua_set_Point_y); + tolua_endmodule(tolua_S); + tolua_array(tolua_S,"a",tolua_get_tarray_a,tolua_set_tarray_a); + tolua_array(tolua_S,"p",tolua_get_tarray_p,NULL); + tolua_array(tolua_S,"pp",tolua_get_tarray_pp,tolua_set_tarray_pp); + tolua_module(tolua_S,"M",1); + tolua_beginmodule(tolua_S,"M"); + tolua_array(tolua_S,"a",tolua_get_tarray_M_ma,tolua_set_tarray_M_ma); + tolua_array(tolua_S,"p",tolua_get_tarray_M_mp,NULL); + tolua_array(tolua_S,"pp",tolua_get_tarray_M_mpp,tolua_set_tarray_M_mpp); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"Array","Array","",NULL); + tolua_beginmodule(tolua_S,"Array"); + tolua_array(tolua_S,"a",tolua_get_tarray_Array_a,tolua_set_tarray_Array_a); + tolua_array(tolua_S,"p",tolua_get_tarray_Array_p,tolua_set_tarray_Array_p); + tolua_array(tolua_S,"pp",tolua_get_tarray_Array_pp,tolua_set_tarray_Array_pp); + tolua_endmodule(tolua_S); + tolua_variable(tolua_S,"array",tolua_get_array,tolua_set_array); + tolua_variable(tolua_S,"parray",tolua_get_parray_ptr,tolua_set_parray_ptr); + tolua_endmodule(tolua_S); + return 1; +} diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tclass.cpp b/third-party/lua-5.1.5/toluapp/src/tests/tclass.cpp new file mode 100644 index 000000000..02ca7709d --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tclass.cpp @@ -0,0 +1,32 @@ +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +#include "tclass.h" + +//Test::Tst_A* Test::Tst_A::last; +//Test::Tst_B* Test::Tst_B::last; +//Test::Tst_C* Test::Tst_C::last; + +extern "C" { + int tolua_tclass_open (lua_State*); +} + +int main () +{ + Test::Tst_B* b = new Test::Tst_B; // instance used in Lua code + + lua_State* L = lua_open(); + luaL_openlibs(L); + tolua_tclass_open(L); + + luaL_dofile(L,"tclass.lua"); + + lua_close(L); + + delete b; + return 0; +} + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tclass.h b/third-party/lua-5.1.5/toluapp/src/tests/tclass.h new file mode 100644 index 000000000..de64ae6b4 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tclass.h @@ -0,0 +1,121 @@ +#ifndef TCLASS_H +#define TCLASS_H + +#include + +namespace Test { + +class Tst_Dummy +{ +}; + +class Tst_A +{ + + int number; +public: + static Tst_A* last; + Tst_A () {last = this;} + virtual char* a () { return "A"; } + class Tst_AA + { + public: + Tst_AA () {} + ~Tst_AA () { } + char* aa () { return "AA"; } + }; + class Tst_BB : public Tst_AA + { + public: + Tst_BB () {} + ~Tst_BB () {} + Tst_AA* Base () { return this; } + }; + + void set_number(int p_number) { number = p_number;}; + int get_number() {return number*2;}; + + virtual ~Tst_A() {}; +}; + +class Tst_B : public Tst_A +{ +public: + static Tst_B* last; + Tst_B () {last = this;} + virtual char* b () { return "B"; } + + static Tst_A* create() {return new Tst_B;}; + static void* create_void() {return new Tst_B;}; + + virtual ~Tst_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 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 Tst_E { + void* ptr; + +public: + enum Pete { + ONE, + TWO, + } pete; + + void get_pete(Pete p) {}; + + template + T get_t() {T a=0; return a;}; + + Tst_E& operator+(const Tst_E& rvalue) {return *this;}; + + void pars(int a=0, int b=0) {}; + void get_pointer(void* a) {}; + + Tst_A a; + + void set_ptr(void* p_ptr) { + printf("this is %p, ptr is %p\n", this, p_ptr); + ptr = p_ptr; + }; + void* get_ptr() {return ptr;}; + + Tst_E(int) {}; +}; + +class Tst_Outside { + +public: + + Tst_Outside() {}; +}; + +}; // end of namespace + + +static void outside_func(Test::Tst_Outside* p_out, lua_State* ls) { + + if (p_out) printf("method!\n"); + else printf("static!\n"); + //printf("luastate: %i\n", ls); +}; + +#endif diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tclass.lua b/third-party/lua-5.1.5/toluapp/src/tests/tclass.lua new file mode 100644 index 000000000..6dea5e98a --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tclass.lua @@ -0,0 +1,131 @@ +if not Test then + local loadlib + if not package then + loadlib = _G['loadlib'] + else + loadlib = package.loadlib + end + f, e, eo = loadlib("./libtclass.so", "luaopen_tclass") + if f then + f() + else + print(eo, e) + os.exit() + end +end + +a = {} +rawset(a, ".c_instance", "something") + +function hello() + + print("hello world") +end + +rawset(Test.B, "hello", hello) + +-- type convertion tests +--print(Test.A) +--print(tolua.type(Test.A.last)) +--assert(tolua.type(Test.A.last) == 'Test::Tst_A') -- first time the object is mapped +--assert(tolua.type(Test.B.last) == 'Test::Tst_B') -- type convertion to specialized type +--assert(tolua.type(Test.A.last) == 'Test::Tst_B') -- no convertion: obj already mapped as B + + +local a = Test.A:new() +assert(tolua.type(Test.A.last) == 'Test::Tst_A') -- no type convertion: same type +local b = Test.B:new() +assert(tolua.type(Test.A.last) == 'Test::Tst_B') -- no convertion: obj already mapped as B +local c = Test.luaC:new(0) +assert(tolua.type(Test.A.last) == 'Test::Tst_C') -- no convertion: obj already mapped as C +assert(tolua.type(Test.luaC.last) == 'Test::Tst_C') + +local aa = Test.A.AA:new() +local bb = Test.A.BB:new() +local xx = Test.create_aa() + +-- 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(Test.is_aa(bb) == true) + +-- test ownershipping handling +-- should delete objects: 6 7 8 9 10 (it may vary!) +local set = {} +for i=1,10 do + local c = Test.luaC:new(i) + if i>5 then + tolua.takeownership(c) + end + --set[i] = c +end + + + +e = Test.B:new_local() + +print("e is type "..tolua.type(e)) +print("ae is type "..tolua.type(ae)) + +--e:delete() + +b:hello() + +---------- +local out = Test.Outside:new_local() +out:outside() +Test.Outside:outside_static(nil) + + +print "***** cast" +local acast = Test.B:create_void() +print("type is "..tolua.type(acast)) +local bcast = tolua.cast(acast, "Test::Tst_B") +print("bcast is "..tostring(bcast)) +print("type is "..tolua.type(bcast)) +print(bcast:b()) + +-- test properies +local n = 7 +a.number = n +assert(a.number == n*2) + +-- constructors +print(getmetatable(Test.A)) +print(getmetatable(Test.B)) +print(getmetatable(Test.E)) + +local a = Test.A() +local b = Test.B() +local e = Test.E(5) +--print(e+5) +print(tostring(getmetatable(Test.B).__call)) +print(tostring(Test.B.__call)) +print(tostring(Test.B.__call(Test.B))) +print(tolua.type(b)) + +e:set_ptr(e) +local ve = tolua.cast(e:get_ptr(), "Test::Tst_E") +ve:set_ptr(ve) + +print"1" +Test.A.pete = {} +print"2" +table.insert(Test.A.pete, a) +print"3" + + +for i=1,100000 do + la = {} + tolua.inherit(la, a) +end + +print("Class test OK") + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tclass.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tclass.pkg new file mode 100644 index 000000000..614245c55 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tclass.pkg @@ -0,0 +1,97 @@ +$#include "tclass.h" + +$Test::Tst_A* Test::Tst_A::last; +$Test::Tst_B* Test::Tst_B::last; +$Test::Tst_C* Test::Tst_C::last; + + +$renaming ^Tst_ @ + +namespace Test { + +class Tst_Dummy; + +class Tst_A +{ + static Tst_A* last; + Tst_A (); + virtual char* a (); + class Tst_AA + { + Tst_AA () {} + ~Tst_AA () {} + char* aa () { return "AA"; } + }; + class Tst_BB : public Tst_AA + { + Tst_BB () {} + ~Tst_BB () {} + Tst_AA* Base () { return this; } + }; + + tolua_property int number; +}; + +class Tst_E { +public: + typedef enum{ + ONE, + TWO, + } Pete; + Pete pete; + + float get_t(); + + void get_pete(Pete p); + + Tst_E& operator+(const Tst_E& rvalue); + + void pars(int a=0xa, int b=GetNumber(GetNumber(1,2))); + void get_pointer(void* a=NULL); + + void set_ptr(void* p_ptr) { + printf("this is %p, ptr is %p\n", this, p_ptr); + ptr = p_ptr; + }; + void* get_ptr() {return ptr;}; + + Tst_A a; + Tst_E(int); + //~Tst_E(); +}; + + +class Tst_B : public Tst_A +{ + static Tst_B* last; + Tst_B (); + virtual char* b (); + static Tst_A* create(); + static void* create_void() {return new Tst_B;}; +}; + +class Tst_C@luaC : public Tst_B +{ + static Tst_C* last; + Tst_C (int n); + ~Tst_C (); + virtual char* c (); +}; + +Tst_A::Tst_AA* Tst_create_aa (); +bool Tst_is_aa (Tst_A::Tst_AA* obj); + +class Tst_Outside { + + + tolua_outside void outside_func@outside(lua_State* ls); + + static tolua_outside void outside_func@outside_static(Tst_Outside* instance, lua_State* ls); + + Tst_Outside() {}; +}; + + +}; // end of namespace + + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tconstant.h b/third-party/lua-5.1.5/toluapp/src/tests/tconstant.h new file mode 100644 index 000000000..917ad0a68 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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/third-party/lua-5.1.5/toluapp/src/tests/tconstant.lua b/third-party/lua-5.1.5/toluapp/src/tests/tconstant.lua new file mode 100644 index 000000000..f7753fecb --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tconstant.lua @@ -0,0 +1,11 @@ +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/third-party/lua-5.1.5/toluapp/src/tests/tconstant.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tconstant.pkg new file mode 100644 index 000000000..ada33909b --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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/third-party/lua-5.1.5/toluapp/src/tests/tdirective.lua b/third-party/lua-5.1.5/toluapp/src/tests/tdirective.lua new file mode 100644 index 000000000..547b1507c --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tdirective.lua @@ -0,0 +1,6 @@ +assert(a==3) +assert(A==4) +assert(func()==5) + +print("Directive test OK") + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tdirective.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tdirective.pkg new file mode 100644 index 000000000..cc1f84e9c --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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 = lua_open(); +$ luaopen_base(L); +$ tolua_tdirective_open(L); +$ lua_dofile(L,"tdirective.lua"); +$ lua_close(L); +$ return 0; +$} + +$pfile "tdirectivepkg.pkg" + +$< + a = 3; +$> + +$[ +A = 4 +$] + +$lfile "tdirectivelua.lua" + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tdirectivebind.c b/third-party/lua-5.1.5/toluapp/src/tests/tdirectivebind.c new file mode 100644 index 000000000..8e5af465f --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tdirectivebind.c @@ -0,0 +1,85 @@ +/* +** Lua binding: tdirective +** Generated automatically by tolua 5.0a-CDLVS2 on 08/08/03 17:06:24. +*/ + +#ifndef __cplusplus +#include "stdlib.h" +#endif +#include "string.h" + +#include "tolua.h" + +/* Exported function */ +TOLUA_API int tolua_tdirective_open (lua_State* tolua_S); + +#include "lualib.h" +#include "lauxlib.h" +int a; +extern int a; +int main (void) +{ + lua_State* L = lua_open(); + luaopen_base(L); + tolua_tdirective_open(L); + lua_dofile(L,"tdirective.lua"); + lua_close(L); + return 0; +} + +/* function to register type */ +static void tolua_reg_types (lua_State* tolua_S) +{ +} + +/* get function: a */ +static int tolua_get_a(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)a); + return 1; +} + +/* set function: a */ +static int tolua_set_a(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + a = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* Open function */ +TOLUA_API int tolua_tdirective_open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,1); + tolua_beginmodule(tolua_S,NULL); + tolua_variable(tolua_S,"a",tolua_get_a,tolua_set_a); +{ + a = 3; +} + + { /* begin embedded lua code */ + static unsigned char B[] = { + 10, 65, 32, 61, 32, 52,32 + }; + lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code"); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + static unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32,102,117,110, 99, 32, + 40, 41, 10,114,101,116,117,114,110, 32, 53, 10,101,110,100, + 32 + }; + lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code"); + } /* end of embedded lua code */ + + tolua_endmodule(tolua_S); + return 1; +} diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tdirectivelua.lua b/third-party/lua-5.1.5/toluapp/src/tests/tdirectivelua.lua new file mode 100644 index 000000000..f7c7c15f2 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tdirectivelua.lua @@ -0,0 +1,3 @@ +function func () + return 5 +end diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tdirectivepkg.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tdirectivepkg.pkg new file mode 100644 index 000000000..b15a66e7f --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tdirectivepkg.pkg @@ -0,0 +1,2 @@ +extern int a; + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tfunction.h b/third-party/lua-5.1.5/toluapp/src/tests/tfunction.h new file mode 100644 index 000000000..9c69f0696 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tfunction.h @@ -0,0 +1,220 @@ +#ifndef tfunction_h +#define tfunction_h + +#include +#include + +typedef enum { + FIRST = 1, + SECOND = 2 +} Order; + +class Point +{ + char m_s[64]; + 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 setname (const char* s) + { + strncpy(m_s,s,63); + } + + 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; + } + const char* getname () const + { + return m_s; + } + + 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; + } + + 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; iq) +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) + + +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/third-party/lua-5.1.5/toluapp/src/tests/tfunction.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tfunction.pkg new file mode 100644 index 000000000..bae3f432a --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tfunction.pkg @@ -0,0 +1,74 @@ +$#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 setname (const char* s); + + 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; + const char* getname () 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; + + 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/third-party/lua-5.1.5/toluapp/src/tests/tmodule.c b/third-party/lua-5.1.5/toluapp/src/tests/tmodule.c new file mode 100644 index 000000000..1cbfa2964 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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 = lua_open(); + luaopen_base(L); + tolua_tmodule_open(L); + + lua_dofile(L,"tmodule.lua"); + + lua_close(L); + return 0; +} + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tmodule.h b/third-party/lua-5.1.5/toluapp/src/tests/tmodule.h new file mode 100644 index 000000000..3766bc4e9 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tmodule.h @@ -0,0 +1,7 @@ +#include + +extern int a; +extern int b; +extern int c; +extern int d; + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tmodule.lua b/third-party/lua-5.1.5/toluapp/src/tests/tmodule.lua new file mode 100644 index 000000000..96ddf4399 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tmodule.lua @@ -0,0 +1,17 @@ +-- 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/third-party/lua-5.1.5/toluapp/src/tests/tmodule.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tmodule.pkg new file mode 100644 index 000000000..43d430639 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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/third-party/lua-5.1.5/toluapp/src/tests/tmodulebind.c b/third-party/lua-5.1.5/toluapp/src/tests/tmodulebind.c new file mode 100644 index 000000000..4ddeba5ef --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tmodulebind.c @@ -0,0 +1,124 @@ +/* +** Lua binding: tmodule +** Generated automatically by tolua 5.0a-CDLVS2 on 08/08/03 17:06:13. +*/ + +#ifndef __cplusplus +#include "stdlib.h" +#endif +#include "string.h" + +#include "tolua.h" + +/* Exported function */ +TOLUA_API int tolua_tmodule_open (lua_State* tolua_S); + +#include "tmodule.h" + +/* function to register type */ +static void tolua_reg_types (lua_State* tolua_S) +{ +} + +/* get function: a */ +static int tolua_get_A_a(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)a); + return 1; +} + +/* set function: a */ +static int tolua_set_A_a(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + a = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: b */ +static int tolua_get_B_b(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)b); + return 1; +} + +/* set function: b */ +static int tolua_set_B_b(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + b = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: c */ +static int tolua_get_C_c(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)c); + return 1; +} + +/* set function: c */ +static int tolua_set_C_c(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + c = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: d */ +static int tolua_get_A_d(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)d); + return 1; +} + +/* set function: d */ +static int tolua_set_A_d(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + d = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* Open function */ +TOLUA_API int tolua_tmodule_open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,0); + tolua_beginmodule(tolua_S,NULL); + tolua_module(tolua_S,"A",1); + tolua_beginmodule(tolua_S,"A"); + tolua_variable(tolua_S,"a",tolua_get_A_a,tolua_set_A_a); + tolua_module(tolua_S,"B",1); + tolua_beginmodule(tolua_S,"B"); + tolua_variable(tolua_S,"b",tolua_get_B_b,tolua_set_B_b); + tolua_module(tolua_S,"C",1); + tolua_beginmodule(tolua_S,"C"); + tolua_variable(tolua_S,"c",tolua_get_C_c,tolua_set_C_c); + tolua_endmodule(tolua_S); + tolua_endmodule(tolua_S); + tolua_endmodule(tolua_S); + tolua_module(tolua_S,"A",1); + tolua_beginmodule(tolua_S,"A"); + tolua_variable(tolua_S,"d",tolua_get_A_d,tolua_set_A_d); + tolua_endmodule(tolua_S); + tolua_endmodule(tolua_S); + return 1; +} diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.h b/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.h new file mode 100644 index 000000000..8c15e414f --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.lua b/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.lua new file mode 100644 index 000000000..3a51dfb6d --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.lua @@ -0,0 +1,14 @@ +-- 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/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tnamespace.pkg new file mode 100644 index 000000000..0b583663a --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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/third-party/lua-5.1.5/toluapp/src/tests/tvariable.c b/third-party/lua-5.1.5/toluapp/src/tests/tvariable.c new file mode 100644 index 000000000..25e788eeb --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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 = lua_open(); + + B bb = {a,NULL}; + B bbb = {ma,&bb}; + b = &bb; + mb = &bbb; + + + luaopen_base(L); + tolua_tvariable_open(L); + + lua_dofile(L,"tvariable.lua"); + + lua_close(L); + return 0; +} + diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tvariable.h b/third-party/lua-5.1.5/toluapp/src/tests/tvariable.h new file mode 100644 index 000000000..6363c484b --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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/third-party/lua-5.1.5/toluapp/src/tests/tvariable.lua b/third-party/lua-5.1.5/toluapp/src/tests/tvariable.lua new file mode 100644 index 000000000..3db902901 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tvariable.lua @@ -0,0 +1,73 @@ +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/third-party/lua-5.1.5/toluapp/src/tests/tvariable.pkg b/third-party/lua-5.1.5/toluapp/src/tests/tvariable.pkg new file mode 100644 index 000000000..a8a1539a0 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/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; +} diff --git a/third-party/lua-5.1.5/toluapp/src/tests/tvariablebind.c b/third-party/lua-5.1.5/toluapp/src/tests/tvariablebind.c new file mode 100644 index 000000000..8088db0a4 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/src/tests/tvariablebind.c @@ -0,0 +1,631 @@ +/* +** Lua binding: tvariable +** Generated automatically by tolua 5.0a-CDLVS2 on 08/08/03 17:06:18. +*/ + +#ifndef __cplusplus +#include "stdlib.h" +#endif +#include "string.h" + +#include "tolua.h" + +/* Exported function */ +TOLUA_API int tolua_tvariable_open (lua_State* tolua_S); + +#include "tvariable.h" + +/* function to register type */ +static void tolua_reg_types (lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"A"); + tolua_usertype(tolua_S,"U"); + tolua_usertype(tolua_S,"B"); +} + +/* get function: i of class A */ +static int tolua_get_A_i(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'i'",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->i); + return 1; +} + +/* set function: i of class A */ +static int tolua_set_A_i(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'i'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->i = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: f of class A */ +static int tolua_get_A_f(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'f'",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->f); + return 1; +} + +/* set function: f of class A */ +static int tolua_set_A_f(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'f'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->f = ((float) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: d of class A */ +static int tolua_get_A_d(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd'",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->d); + return 1; +} + +/* set function: d of class A */ +static int tolua_set_A_d(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->d = ((double) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: s of class A */ +static int tolua_get_A_s(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 's'",NULL); +#endif + tolua_pushstring(tolua_S,(const char*)self->s); + return 1; +} + +/* set function: s of class A */ +static int tolua_set_A_s(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 's'",NULL); + if (!tolua_isstring(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->s = ((char*) tolua_tostring(tolua_S,2,0)); + return 0; +} + +/* get function: v of class A */ +static int tolua_get_A_v(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'v'",NULL); +#endif + tolua_pushuserdata(tolua_S,(void*)self->v); + return 1; +} + +/* set function: v of class A */ +static int tolua_set_A_v(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'v'",NULL); + if (!tolua_isuserdata(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->v = ((void*) tolua_touserdata(tolua_S,2,0)); + return 0; +} + +/* get function: n of class A */ +static int tolua_get_A_n(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'n'",NULL); +#endif + tolua_pushstring(tolua_S,(const char*)self->n); + return 1; +} + +/* set function: n of class A */ +static int tolua_set_A_n(lua_State* tolua_S) +{ + A* self = (A*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'n'",NULL); + if (!tolua_isstring(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + strncpy(self->n,tolua_tostring(tolua_S,2,0),64-1); + return 0; +} + +/* get function: a of class B */ +static int tolua_get_B_a(lua_State* tolua_S) +{ + B* self = (B*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'a'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&self->a,"A"); + return 1; +} + +/* set function: a of class B */ +static int tolua_set_B_a(lua_State* tolua_S) +{ + B* self = (B*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'a'",NULL); + if (!tolua_isusertype(tolua_S,2,"A",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->a = *((A*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: b of class B */ +static int tolua_get_B_b_ptr(lua_State* tolua_S) +{ + B* self = (B*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'b'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->b,"B"); + return 1; +} + +/* set function: b of class B */ +static int tolua_set_B_b_ptr(lua_State* tolua_S) +{ + B* self = (B*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'b'",NULL); + if (!tolua_isusertype(tolua_S,2,"B",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->b = ((B*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: i of class U */ +static int tolua_get_U_i(lua_State* tolua_S) +{ + U* self = (U*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'i'",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->i); + return 1; +} + +/* set function: i of class U */ +static int tolua_set_U_i(lua_State* tolua_S) +{ + U* self = (U*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'i'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->i = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: f of class U */ +static int tolua_get_U_f(lua_State* tolua_S) +{ + U* self = (U*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'f'",NULL); +#endif + tolua_pushnumber(tolua_S,(double)self->f); + return 1; +} + +/* set function: f of class U */ +static int tolua_set_U_f(lua_State* tolua_S) +{ + U* self = (U*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'f'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->f = ((float) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: i */ +static int tolua_get_i(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)i); + return 1; +} + +/* set function: i */ +static int tolua_set_i(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + i = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: f */ +static int tolua_get_f(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)f); + return 1; +} + +/* set function: f */ +static int tolua_set_f(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + f = ((float) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: d */ +static int tolua_get_d(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)d); + return 1; +} + +/* set function: d */ +static int tolua_set_d(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + d = ((double) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: s */ +static int tolua_get_s(lua_State* tolua_S) +{ + tolua_pushstring(tolua_S,(const char*)s); + return 1; +} + +/* get function: v */ +static int tolua_get_v(lua_State* tolua_S) +{ + tolua_pushuserdata(tolua_S,(void*)v); + return 1; +} + +/* set function: v */ +static int tolua_set_v(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isuserdata(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + v = ((void*) tolua_touserdata(tolua_S,2,0)); + return 0; +} + +/* get function: n */ +static int tolua_get_n(lua_State* tolua_S) +{ + tolua_pushstring(tolua_S,(const char*)n); + return 1; +} + +/* set function: n */ +static int tolua_set_n(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isstring(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + strncpy(n,tolua_tostring(tolua_S,2,0),64-1); + return 0; +} + +/* get function: a */ +static int tolua_get_a(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)&a,"A"); + return 1; +} + +/* set function: a */ +static int tolua_set_a(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"A",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + a = *((A*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: b */ +static int tolua_get_b_ptr(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)b,"B"); + return 1; +} + +/* set function: b */ +static int tolua_set_b_ptr(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"B",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + b = ((B*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: u */ +static int tolua_get_u(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)&u,"U"); + return 1; +} + +/* set function: u */ +static int tolua_set_u(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"U",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + u = *((U*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: mi */ +static int tolua_get_M_mi(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)mi); + return 1; +} + +/* set function: mi */ +static int tolua_set_M_mi(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + mi = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: mf */ +static int tolua_get_M_mf(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)mf); + return 1; +} + +/* set function: mf */ +static int tolua_set_M_mf(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + mf = ((float) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: md */ +static int tolua_get_M_md(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)md); + return 1; +} + +/* set function: md */ +static int tolua_set_M_md(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + md = ((double) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* get function: ms */ +static int tolua_get_M_ms(lua_State* tolua_S) +{ + tolua_pushstring(tolua_S,(const char*)ms); + return 1; +} + +/* get function: mv */ +static int tolua_get_M_mv(lua_State* tolua_S) +{ + tolua_pushuserdata(tolua_S,(void*)mv); + return 1; +} + +/* set function: mv */ +static int tolua_set_M_mv(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isuserdata(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + mv = ((void*) tolua_touserdata(tolua_S,2,0)); + return 0; +} + +/* get function: mn */ +static int tolua_get_M_mn(lua_State* tolua_S) +{ + tolua_pushstring(tolua_S,(const char*)mn); + return 1; +} + +/* get function: a */ +static int tolua_get_M_a(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)&a,"A"); + return 1; +} + +/* set function: a */ +static int tolua_set_M_a(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"A",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + a = *((A*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: ma */ +static int tolua_get_M_ma(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)&ma,"A"); + return 1; +} + +/* set function: ma */ +static int tolua_set_M_ma(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"A",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + ma = *((A*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* get function: mb */ +static int tolua_get_M_mb_ptr(lua_State* tolua_S) +{ + tolua_pushusertype(tolua_S,(void*)mb,"B"); + return 1; +} + +/* set function: mb */ +static int tolua_set_M_mb_ptr(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,2,"B",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + mb = ((B*) tolua_tousertype(tolua_S,2,0)); + return 0; +} + +/* Open function */ +TOLUA_API int tolua_tvariable_open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,1); + tolua_beginmodule(tolua_S,NULL); + tolua_cclass(tolua_S,"A","A","",NULL); + tolua_beginmodule(tolua_S,"A"); + tolua_variable(tolua_S,"i",tolua_get_A_i,tolua_set_A_i); + tolua_variable(tolua_S,"f",tolua_get_A_f,tolua_set_A_f); + tolua_variable(tolua_S,"d",tolua_get_A_d,tolua_set_A_d); + tolua_variable(tolua_S,"s",tolua_get_A_s,tolua_set_A_s); + tolua_variable(tolua_S,"v",tolua_get_A_v,tolua_set_A_v); + tolua_variable(tolua_S,"n",tolua_get_A_n,tolua_set_A_n); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"B","B","",NULL); + tolua_beginmodule(tolua_S,"B"); + tolua_variable(tolua_S,"a",tolua_get_B_a,tolua_set_B_a); + tolua_variable(tolua_S,"b",tolua_get_B_b_ptr,tolua_set_B_b_ptr); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"U","U","",NULL); + tolua_beginmodule(tolua_S,"U"); + tolua_variable(tolua_S,"i",tolua_get_U_i,tolua_set_U_i); + tolua_variable(tolua_S,"f",tolua_get_U_f,tolua_set_U_f); + tolua_endmodule(tolua_S); + tolua_variable(tolua_S,"i",tolua_get_i,tolua_set_i); + tolua_variable(tolua_S,"f",tolua_get_f,tolua_set_f); + tolua_variable(tolua_S,"d",tolua_get_d,tolua_set_d); + tolua_variable(tolua_S,"s",tolua_get_s,NULL); + tolua_variable(tolua_S,"v",tolua_get_v,tolua_set_v); + tolua_variable(tolua_S,"n",tolua_get_n,tolua_set_n); + tolua_variable(tolua_S,"a",tolua_get_a,tolua_set_a); + tolua_variable(tolua_S,"b",tolua_get_b_ptr,tolua_set_b_ptr); + tolua_variable(tolua_S,"u",tolua_get_u,tolua_set_u); + tolua_module(tolua_S,"M",1); + tolua_beginmodule(tolua_S,"M"); + tolua_variable(tolua_S,"mi",tolua_get_M_mi,tolua_set_M_mi); + tolua_variable(tolua_S,"mf",tolua_get_M_mf,tolua_set_M_mf); + tolua_variable(tolua_S,"md",tolua_get_M_md,tolua_set_M_md); + tolua_variable(tolua_S,"ms",tolua_get_M_ms,NULL); + tolua_variable(tolua_S,"mv",tolua_get_M_mv,tolua_set_M_mv); + tolua_variable(tolua_S,"mn",tolua_get_M_mn,NULL); + tolua_variable(tolua_S,"a",tolua_get_M_a,tolua_set_M_a); + tolua_variable(tolua_S,"ma",tolua_get_M_ma,tolua_set_M_ma); + tolua_variable(tolua_S,"mb",tolua_get_M_mb_ptr,tolua_set_M_mb_ptr); + tolua_endmodule(tolua_S); + tolua_endmodule(tolua_S); + return 1; +} diff --git a/third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.sln b/third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.sln new file mode 100755 index 000000000..c974421f6 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluapp", "toluapp.vcproj", "{71891C1A-E328-4258-AC3F-6F9698C6D8B4}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + withLua50_Debug = withLua50_Debug + withLua50_Release = withLua50_Release + withLua51_Debug = withLua51_Debug + withLua51_Release = withLua51_Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug.ActiveCfg = withLua51_Release|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Debug.Build.0 = withLua51_Release|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release.ActiveCfg = withLua50_Release|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua50_Release.Build.0 = withLua50_Release|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug.ActiveCfg = withLua51_Debug|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Debug.Build.0 = withLua51_Debug|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release.ActiveCfg = withLua51_Release|Win32 + {71891C1A-E328-4258-AC3F-6F9698C6D8B4}.withLua51_Release.Build.0 = withLua51_Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.vcproj b/third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.vcproj new file mode 100755 index 000000000..f27c63b85 --- /dev/null +++ b/third-party/lua-5.1.5/toluapp/win32/vc7/toluapp.vcproj @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +