dub 0.2.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dub might be problematic. Click here for more details.
- data/History.txt +92 -0
- data/LICENSE +20 -0
- data/README.rdoc +115 -0
- data/Rakefile +59 -0
- data/dub.gemspec +197 -0
- data/lib/dub/argument.rb +286 -0
- data/lib/dub/entities_unescape.rb +9 -0
- data/lib/dub/function.rb +177 -0
- data/lib/dub/function_group.rb +72 -0
- data/lib/dub/generator.rb +15 -0
- data/lib/dub/group.rb +20 -0
- data/lib/dub/klass.rb +338 -0
- data/lib/dub/lua/class.cpp.erb +114 -0
- data/lib/dub/lua/class_gen.rb +96 -0
- data/lib/dub/lua/function.cpp.erb +15 -0
- data/lib/dub/lua/function_gen.rb +329 -0
- data/lib/dub/lua/group.cpp.erb +9 -0
- data/lib/dub/lua/lua_cpp_helper.cpp +259 -0
- data/lib/dub/lua/lua_cpp_helper.h +219 -0
- data/lib/dub/lua/lua_object.cpp +158 -0
- data/lib/dub/lua/lua_object.h +69 -0
- data/lib/dub/lua/namespace.cpp.erb +42 -0
- data/lib/dub/lua/namespace_gen.rb +69 -0
- data/lib/dub/lua.rb +24 -0
- data/lib/dub/member_extraction.rb +128 -0
- data/lib/dub/namespace.rb +295 -0
- data/lib/dub/opts_parser.rb +30 -0
- data/lib/dub/parser.rb +46 -0
- data/lib/dub/templates/lua_template.erb +21 -0
- data/lib/dub/version.rb +3 -0
- data/lib/dub.rb +24 -20
- data/test/argument_test.rb +581 -0
- data/test/fixtures/app/CMakeLists.txt +54 -0
- data/test/fixtures/app/Doxyfile +1600 -0
- data/test/fixtures/app/bindings/all_lua.cpp +299 -0
- data/test/fixtures/app/include/matrix.h +283 -0
- data/test/fixtures/app/make_lua_bindings.rb +13 -0
- data/test/fixtures/app/vendor/lua/CMakeLists.txt +25 -0
- data/test/fixtures/app/vendor/lua/COPYRIGHT +34 -0
- data/test/fixtures/app/vendor/lua/HISTORY +183 -0
- data/test/fixtures/app/vendor/lua/INSTALL +99 -0
- data/test/fixtures/app/vendor/lua/Makefile +183 -0
- data/test/fixtures/app/vendor/lua/README +37 -0
- data/test/fixtures/app/vendor/lua/lapi.c +1080 -0
- data/test/fixtures/app/vendor/lua/lapi.h +16 -0
- data/test/fixtures/app/vendor/lua/lauxlib.c +653 -0
- data/test/fixtures/app/vendor/lua/lauxlib.h +174 -0
- data/test/fixtures/app/vendor/lua/lbaselib.c +643 -0
- data/test/fixtures/app/vendor/lua/lcode.c +839 -0
- data/test/fixtures/app/vendor/lua/lcode.h +76 -0
- data/test/fixtures/app/vendor/lua/ldblib.c +397 -0
- data/test/fixtures/app/vendor/lua/ldebug.c +622 -0
- data/test/fixtures/app/vendor/lua/ldebug.h +33 -0
- data/test/fixtures/app/vendor/lua/ldo.c +516 -0
- data/test/fixtures/app/vendor/lua/ldo.h +57 -0
- data/test/fixtures/app/vendor/lua/ldump.c +164 -0
- data/test/fixtures/app/vendor/lua/lfunc.c +174 -0
- data/test/fixtures/app/vendor/lua/lfunc.h +34 -0
- data/test/fixtures/app/vendor/lua/lgc.c +711 -0
- data/test/fixtures/app/vendor/lua/lgc.h +110 -0
- data/test/fixtures/app/vendor/lua/liblua.a +0 -0
- data/test/fixtures/app/vendor/lua/linit.c +38 -0
- data/test/fixtures/app/vendor/lua/liolib.c +532 -0
- data/test/fixtures/app/vendor/lua/llex.c +461 -0
- data/test/fixtures/app/vendor/lua/llex.h +81 -0
- data/test/fixtures/app/vendor/lua/llimits.h +128 -0
- data/test/fixtures/app/vendor/lua/lmathlib.c +263 -0
- data/test/fixtures/app/vendor/lua/lmem.c +86 -0
- data/test/fixtures/app/vendor/lua/lmem.h +49 -0
- data/test/fixtures/app/vendor/lua/loadlib.c +664 -0
- data/test/fixtures/app/vendor/lua/lobject.c +214 -0
- data/test/fixtures/app/vendor/lua/lobject.h +381 -0
- data/test/fixtures/app/vendor/lua/lopcodes.c +102 -0
- data/test/fixtures/app/vendor/lua/lopcodes.h +268 -0
- data/test/fixtures/app/vendor/lua/loslib.c +244 -0
- data/test/fixtures/app/vendor/lua/lparser.c +1337 -0
- data/test/fixtures/app/vendor/lua/lparser.h +82 -0
- data/test/fixtures/app/vendor/lua/lstate.c +214 -0
- data/test/fixtures/app/vendor/lua/lstate.h +168 -0
- data/test/fixtures/app/vendor/lua/lstring.c +111 -0
- data/test/fixtures/app/vendor/lua/lstring.h +31 -0
- data/test/fixtures/app/vendor/lua/lstrlib.c +868 -0
- data/test/fixtures/app/vendor/lua/ltable.c +588 -0
- data/test/fixtures/app/vendor/lua/ltable.h +40 -0
- data/test/fixtures/app/vendor/lua/ltablib.c +278 -0
- data/test/fixtures/app/vendor/lua/ltm.c +75 -0
- data/test/fixtures/app/vendor/lua/ltm.h +54 -0
- data/test/fixtures/app/vendor/lua/lua.c +695 -0
- data/test/fixtures/app/vendor/lua/lua.h +385 -0
- data/test/fixtures/app/vendor/lua/lua_dub_helper.h +77 -0
- data/test/fixtures/app/vendor/lua/luac +0 -0
- data/test/fixtures/app/vendor/lua/luac.c +200 -0
- data/test/fixtures/app/vendor/lua/luaconf.h +762 -0
- data/test/fixtures/app/vendor/lua/lualib.h +53 -0
- data/test/fixtures/app/vendor/lua/lundump.c +223 -0
- data/test/fixtures/app/vendor/lua/lundump.h +36 -0
- data/test/fixtures/app/vendor/lua/lvm.c +765 -0
- data/test/fixtures/app/vendor/lua/lvm.h +36 -0
- data/test/fixtures/app/vendor/lua/lzio.c +82 -0
- data/test/fixtures/app/vendor/lua/lzio.h +67 -0
- data/test/fixtures/app/vendor/lua/matrix.h +102 -0
- data/test/fixtures/app/vendor/lua/print.c +227 -0
- data/test/fixtures/app/vendor/lua/test/README +26 -0
- data/test/fixtures/app/vendor/lua/test/bisect.lua +27 -0
- data/test/fixtures/app/vendor/lua/test/cf.lua +16 -0
- data/test/fixtures/app/vendor/lua/test/echo.lua +5 -0
- data/test/fixtures/app/vendor/lua/test/env.lua +7 -0
- data/test/fixtures/app/vendor/lua/test/factorial.lua +32 -0
- data/test/fixtures/app/vendor/lua/test/fib.lua +40 -0
- data/test/fixtures/app/vendor/lua/test/fibfor.lua +13 -0
- data/test/fixtures/app/vendor/lua/test/globals.lua +13 -0
- data/test/fixtures/app/vendor/lua/test/hello.lua +3 -0
- data/test/fixtures/app/vendor/lua/test/life.lua +111 -0
- data/test/fixtures/app/vendor/lua/test/luac.lua +7 -0
- data/test/fixtures/app/vendor/lua/test/printf.lua +7 -0
- data/test/fixtures/app/vendor/lua/test/readonly.lua +12 -0
- data/test/fixtures/app/vendor/lua/test/sieve.lua +29 -0
- data/test/fixtures/app/vendor/lua/test/sort.lua +66 -0
- data/test/fixtures/app/vendor/lua/test/table.lua +12 -0
- data/test/fixtures/app/vendor/lua/test/trace-calls.lua +32 -0
- data/test/fixtures/app/vendor/lua/test/trace-globals.lua +38 -0
- data/test/fixtures/app/vendor/lua/test/xd.lua +14 -0
- data/test/fixtures/app/xml/classdub_1_1_base.xml +85 -0
- data/test/fixtures/app/xml/classdub_1_1_custom_destructor.xml +67 -0
- data/test/fixtures/app/xml/classdub_1_1_deletable_out_of_lua.xml +43 -0
- data/test/fixtures/app/xml/classdub_1_1_matrix.xml +482 -0
- data/test/fixtures/app/xml/classdub_1_1_no_destructor.xml +49 -0
- data/test/fixtures/app/xml/classdub_1_1_priv_sub_base.xml +89 -0
- data/test/fixtures/app/xml/classdub_1_1_private_constr.xml +68 -0
- data/test/fixtures/app/xml/classdub_1_1_static_constr.xml +69 -0
- data/test/fixtures/app/xml/classdub_1_1_sub_base.xml +89 -0
- data/test/fixtures/app/xml/classdub_1_1_t_mat.xml +252 -0
- data/test/fixtures/app/xml/combine.xslt +15 -0
- data/test/fixtures/app/xml/compound.xsd +814 -0
- data/test/fixtures/app/xml/dir_53661a2bdeb1d55e60581a7e15deb763.xml +12 -0
- data/test/fixtures/app/xml/index.xml +91 -0
- data/test/fixtures/app/xml/index.xsd +66 -0
- data/test/fixtures/app/xml/matrix_8h.xml +310 -0
- data/test/fixtures/app/xml/namespacedub.xml +48 -0
- data/test/fixtures/classcv_1_1_mat.xml +1996 -0
- data/test/fixtures/classcv_1_1_point__.xml +341 -0
- data/test/fixtures/classcv_1_1_scalar__.xml +269 -0
- data/test/fixtures/classcv_1_1_size__.xml +270 -0
- data/test/fixtures/dummy_class.cpp.erb +1 -0
- data/test/fixtures/dummy_function.cpp.erb +1 -0
- data/test/fixtures/group___magic_type.xml +406 -0
- data/test/fixtures/namespacecv.xml +12659 -0
- data/test/function_group_test.rb +43 -0
- data/test/function_test.rb +405 -0
- data/test/group_test.rb +241 -0
- data/test/helper.rb +34 -0
- data/test/klass_test.rb +551 -0
- data/test/lua_function_gen_test.rb +242 -0
- data/test/namespace_test.rb +220 -0
- data/test/parser_test.rb +36 -0
- metadata +229 -272
- checksums.yaml +0 -7
- data/lib/open_api_sdk/analytics.rb +0 -99
- data/lib/open_api_sdk/domains.rb +0 -353
- data/lib/open_api_sdk/dub.rb +0 -88
- data/lib/open_api_sdk/links.rb +0 -766
- data/lib/open_api_sdk/metatags.rb +0 -54
- data/lib/open_api_sdk/models/operations/bulkcreatelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_requestbody.rb +0 -27
- data/lib/open_api_sdk/models/operations/bulkupdatelinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/color.rb +0 -24
- data/lib/open_api_sdk/models/operations/createdomain_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/createdomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createlink_requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/createlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/createtag_requestbody.rb +0 -32
- data/lib/open_api_sdk/models/operations/createtag_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/data.rb +0 -83
- data/lib/open_api_sdk/models/operations/deletedomain_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletedomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletedomain_responsebody.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletelink_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/deletelink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/deletelink_responsebody.rb +0 -24
- data/lib/open_api_sdk/models/operations/event.rb +0 -21
- data/lib/open_api_sdk/models/operations/getlinkinfo_request.rb +0 -33
- data/lib/open_api_sdk/models/operations/getlinkinfo_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getlinks_request.rb +0 -51
- data/lib/open_api_sdk/models/operations/getlinks_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getlinkscount_request.rb +0 -48
- data/lib/open_api_sdk/models/operations/getlinkscount_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getmetatags_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/getmetatags_response.rb +0 -33
- data/lib/open_api_sdk/models/operations/getmetatags_responsebody.rb +0 -30
- data/lib/open_api_sdk/models/operations/getqrcode_request.rb +0 -39
- data/lib/open_api_sdk/models/operations/getqrcode_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/gettags_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/getworkspace_request.rb +0 -24
- data/lib/open_api_sdk/models/operations/getworkspace_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/groupby.rb +0 -28
- data/lib/open_api_sdk/models/operations/interval.rb +0 -25
- data/lib/open_api_sdk/models/operations/level.rb +0 -21
- data/lib/open_api_sdk/models/operations/listdomains_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/paymentprocessor.rb +0 -20
- data/lib/open_api_sdk/models/operations/requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/retrieveanalytics_request.rb +0 -81
- data/lib/open_api_sdk/models/operations/retrieveanalytics_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/sort.rb +0 -20
- data/lib/open_api_sdk/models/operations/trackcustomer_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/trackcustomer_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/trackcustomer_responsebody.rb +0 -33
- data/lib/open_api_sdk/models/operations/tracklead_requestbody.rb +0 -42
- data/lib/open_api_sdk/models/operations/tracklead_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/tracklead_responsebody.rb +0 -42
- data/lib/open_api_sdk/models/operations/tracksale_requestbody.rb +0 -42
- data/lib/open_api_sdk/models/operations/tracksale_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/tracksale_responsebody.rb +0 -42
- data/lib/open_api_sdk/models/operations/updatedomain_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatedomain_requestbody.rb +0 -33
- data/lib/open_api_sdk/models/operations/updatedomain_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatelink_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatelink_requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/updatelink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updatetag_color.rb +0 -24
- data/lib/open_api_sdk/models/operations/updatetag_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updatetag_requestbody.rb +0 -32
- data/lib/open_api_sdk/models/operations/updatetag_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/updateworkspace_request.rb +0 -27
- data/lib/open_api_sdk/models/operations/updateworkspace_requestbody.rb +0 -27
- data/lib/open_api_sdk/models/operations/updateworkspace_response.rb +0 -60
- data/lib/open_api_sdk/models/operations/upsertlink_requestbody.rb +0 -95
- data/lib/open_api_sdk/models/operations/upsertlink_response.rb +0 -60
- data/lib/open_api_sdk/models/operations.rb +0 -74
- data/lib/open_api_sdk/models/shared/badrequest.rb +0 -24
- data/lib/open_api_sdk/models/shared/code.rb +0 -18
- data/lib/open_api_sdk/models/shared/color.rb +0 -24
- data/lib/open_api_sdk/models/shared/conflict.rb +0 -24
- data/lib/open_api_sdk/models/shared/conflict_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/conflict_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/countrycode.rb +0 -267
- data/lib/open_api_sdk/models/shared/domains.rb +0 -27
- data/lib/open_api_sdk/models/shared/domainschema.rb +0 -48
- data/lib/open_api_sdk/models/shared/error.rb +0 -30
- data/lib/open_api_sdk/models/shared/forbidden.rb +0 -24
- data/lib/open_api_sdk/models/shared/forbidden_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/forbidden_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/geo.rb +0 -771
- data/lib/open_api_sdk/models/shared/internalservererror.rb +0 -24
- data/lib/open_api_sdk/models/shared/internalservererror_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/internalservererror_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/inviteexpired.rb +0 -24
- data/lib/open_api_sdk/models/shared/inviteexpired_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/inviteexpired_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/linkgeotargeting.rb +0 -771
- data/lib/open_api_sdk/models/shared/linkschema.rb +0 -142
- data/lib/open_api_sdk/models/shared/notfound.rb +0 -24
- data/lib/open_api_sdk/models/shared/notfound_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/notfound_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/plan.rb +0 -24
- data/lib/open_api_sdk/models/shared/ratelimitexceeded.rb +0 -24
- data/lib/open_api_sdk/models/shared/ratelimitexceeded_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/ratelimitexceeded_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/role.rb +0 -19
- data/lib/open_api_sdk/models/shared/security.rb +0 -24
- data/lib/open_api_sdk/models/shared/tagschema.rb +0 -30
- data/lib/open_api_sdk/models/shared/unauthorized.rb +0 -24
- data/lib/open_api_sdk/models/shared/unauthorized_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/unauthorized_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/unprocessableentity.rb +0 -24
- data/lib/open_api_sdk/models/shared/unprocessableentity_code.rb +0 -18
- data/lib/open_api_sdk/models/shared/unprocessableentity_error.rb +0 -30
- data/lib/open_api_sdk/models/shared/users.rb +0 -24
- data/lib/open_api_sdk/models/shared/workspaceschema.rb +0 -81
- data/lib/open_api_sdk/models/shared.rb +0 -49
- data/lib/open_api_sdk/qr_codes.rb +0 -97
- data/lib/open_api_sdk/sdkconfiguration.rb +0 -52
- data/lib/open_api_sdk/tags.rb +0 -272
- data/lib/open_api_sdk/track.rb +0 -276
- data/lib/open_api_sdk/utils/metadata_fields.rb +0 -150
- data/lib/open_api_sdk/utils/t.rb +0 -59
- data/lib/open_api_sdk/utils/utils.rb +0 -772
- data/lib/open_api_sdk/workspaces.rb +0 -192
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
|
3
|
+
** Lua standard libraries
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef lualib_h
|
9
|
+
#define lualib_h
|
10
|
+
|
11
|
+
#include "lua.h"
|
12
|
+
|
13
|
+
|
14
|
+
/* Key to file-handle type */
|
15
|
+
#define LUA_FILEHANDLE "FILE*"
|
16
|
+
|
17
|
+
|
18
|
+
#define LUA_COLIBNAME "coroutine"
|
19
|
+
LUALIB_API int (luaopen_base) (lua_State *L);
|
20
|
+
|
21
|
+
#define LUA_TABLIBNAME "table"
|
22
|
+
LUALIB_API int (luaopen_table) (lua_State *L);
|
23
|
+
|
24
|
+
#define LUA_IOLIBNAME "io"
|
25
|
+
LUALIB_API int (luaopen_io) (lua_State *L);
|
26
|
+
|
27
|
+
#define LUA_OSLIBNAME "os"
|
28
|
+
LUALIB_API int (luaopen_os) (lua_State *L);
|
29
|
+
|
30
|
+
#define LUA_STRLIBNAME "string"
|
31
|
+
LUALIB_API int (luaopen_string) (lua_State *L);
|
32
|
+
|
33
|
+
#define LUA_MATHLIBNAME "math"
|
34
|
+
LUALIB_API int (luaopen_math) (lua_State *L);
|
35
|
+
|
36
|
+
#define LUA_DBLIBNAME "debug"
|
37
|
+
LUALIB_API int (luaopen_debug) (lua_State *L);
|
38
|
+
|
39
|
+
#define LUA_LOADLIBNAME "package"
|
40
|
+
LUALIB_API int (luaopen_package) (lua_State *L);
|
41
|
+
|
42
|
+
|
43
|
+
/* open all previous libraries */
|
44
|
+
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#ifndef lua_assert
|
49
|
+
#define lua_assert(x) ((void)0)
|
50
|
+
#endif
|
51
|
+
|
52
|
+
|
53
|
+
#endif
|
@@ -0,0 +1,223 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $
|
3
|
+
** load precompiled Lua chunks
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <string.h>
|
8
|
+
|
9
|
+
#define lundump_c
|
10
|
+
#define LUA_CORE
|
11
|
+
|
12
|
+
#include "lua.h"
|
13
|
+
|
14
|
+
#include "ldebug.h"
|
15
|
+
#include "ldo.h"
|
16
|
+
#include "lfunc.h"
|
17
|
+
#include "lmem.h"
|
18
|
+
#include "lobject.h"
|
19
|
+
#include "lstring.h"
|
20
|
+
#include "lundump.h"
|
21
|
+
#include "lzio.h"
|
22
|
+
|
23
|
+
typedef struct {
|
24
|
+
lua_State* L;
|
25
|
+
ZIO* Z;
|
26
|
+
Mbuffer* b;
|
27
|
+
const char* name;
|
28
|
+
} LoadState;
|
29
|
+
|
30
|
+
#ifdef LUAC_TRUST_BINARIES
|
31
|
+
#define IF(c,s)
|
32
|
+
#else
|
33
|
+
#define IF(c,s) if (c) error(S,s)
|
34
|
+
|
35
|
+
static void error(LoadState* S, const char* why)
|
36
|
+
{
|
37
|
+
luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
|
38
|
+
luaD_throw(S->L,LUA_ERRSYNTAX);
|
39
|
+
}
|
40
|
+
#endif
|
41
|
+
|
42
|
+
#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
|
43
|
+
#define LoadByte(S) (lu_byte)LoadChar(S)
|
44
|
+
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
|
45
|
+
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
|
46
|
+
|
47
|
+
static void LoadBlock(LoadState* S, void* b, size_t size)
|
48
|
+
{
|
49
|
+
size_t r=luaZ_read(S->Z,b,size);
|
50
|
+
IF (r!=0, "unexpected end");
|
51
|
+
}
|
52
|
+
|
53
|
+
static int LoadChar(LoadState* S)
|
54
|
+
{
|
55
|
+
char x;
|
56
|
+
LoadVar(S,x);
|
57
|
+
return x;
|
58
|
+
}
|
59
|
+
|
60
|
+
static int LoadInt(LoadState* S)
|
61
|
+
{
|
62
|
+
int x;
|
63
|
+
LoadVar(S,x);
|
64
|
+
IF (x<0, "bad integer");
|
65
|
+
return x;
|
66
|
+
}
|
67
|
+
|
68
|
+
static lua_Number LoadNumber(LoadState* S)
|
69
|
+
{
|
70
|
+
lua_Number x;
|
71
|
+
LoadVar(S,x);
|
72
|
+
return x;
|
73
|
+
}
|
74
|
+
|
75
|
+
static TString* LoadString(LoadState* S)
|
76
|
+
{
|
77
|
+
size_t size;
|
78
|
+
LoadVar(S,size);
|
79
|
+
if (size==0)
|
80
|
+
return NULL;
|
81
|
+
else
|
82
|
+
{
|
83
|
+
char* s=luaZ_openspace(S->L,S->b,size);
|
84
|
+
LoadBlock(S,s,size);
|
85
|
+
return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
static void LoadCode(LoadState* S, Proto* f)
|
90
|
+
{
|
91
|
+
int n=LoadInt(S);
|
92
|
+
f->code=luaM_newvector(S->L,n,Instruction);
|
93
|
+
f->sizecode=n;
|
94
|
+
LoadVector(S,f->code,n,sizeof(Instruction));
|
95
|
+
}
|
96
|
+
|
97
|
+
static Proto* LoadFunction(LoadState* S, TString* p);
|
98
|
+
|
99
|
+
static void LoadConstants(LoadState* S, Proto* f)
|
100
|
+
{
|
101
|
+
int i,n;
|
102
|
+
n=LoadInt(S);
|
103
|
+
f->k=luaM_newvector(S->L,n,TValue);
|
104
|
+
f->sizek=n;
|
105
|
+
for (i=0; i<n; i++) setnilvalue(&f->k[i]);
|
106
|
+
for (i=0; i<n; i++)
|
107
|
+
{
|
108
|
+
TValue* o=&f->k[i];
|
109
|
+
int t=LoadChar(S);
|
110
|
+
switch (t)
|
111
|
+
{
|
112
|
+
case LUA_TNIL:
|
113
|
+
setnilvalue(o);
|
114
|
+
break;
|
115
|
+
case LUA_TBOOLEAN:
|
116
|
+
setbvalue(o,LoadChar(S));
|
117
|
+
break;
|
118
|
+
case LUA_TNUMBER:
|
119
|
+
setnvalue(o,LoadNumber(S));
|
120
|
+
break;
|
121
|
+
case LUA_TSTRING:
|
122
|
+
setsvalue2n(S->L,o,LoadString(S));
|
123
|
+
break;
|
124
|
+
default:
|
125
|
+
IF (1, "bad constant");
|
126
|
+
break;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
n=LoadInt(S);
|
130
|
+
f->p=luaM_newvector(S->L,n,Proto*);
|
131
|
+
f->sizep=n;
|
132
|
+
for (i=0; i<n; i++) f->p[i]=NULL;
|
133
|
+
for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
|
134
|
+
}
|
135
|
+
|
136
|
+
static void LoadDebug(LoadState* S, Proto* f)
|
137
|
+
{
|
138
|
+
int i,n;
|
139
|
+
n=LoadInt(S);
|
140
|
+
f->lineinfo=luaM_newvector(S->L,n,int);
|
141
|
+
f->sizelineinfo=n;
|
142
|
+
LoadVector(S,f->lineinfo,n,sizeof(int));
|
143
|
+
n=LoadInt(S);
|
144
|
+
f->locvars=luaM_newvector(S->L,n,LocVar);
|
145
|
+
f->sizelocvars=n;
|
146
|
+
for (i=0; i<n; i++) f->locvars[i].varname=NULL;
|
147
|
+
for (i=0; i<n; i++)
|
148
|
+
{
|
149
|
+
f->locvars[i].varname=LoadString(S);
|
150
|
+
f->locvars[i].startpc=LoadInt(S);
|
151
|
+
f->locvars[i].endpc=LoadInt(S);
|
152
|
+
}
|
153
|
+
n=LoadInt(S);
|
154
|
+
f->upvalues=luaM_newvector(S->L,n,TString*);
|
155
|
+
f->sizeupvalues=n;
|
156
|
+
for (i=0; i<n; i++) f->upvalues[i]=NULL;
|
157
|
+
for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
|
158
|
+
}
|
159
|
+
|
160
|
+
static Proto* LoadFunction(LoadState* S, TString* p)
|
161
|
+
{
|
162
|
+
Proto* f=luaF_newproto(S->L);
|
163
|
+
setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
|
164
|
+
f->source=LoadString(S); if (f->source==NULL) f->source=p;
|
165
|
+
f->linedefined=LoadInt(S);
|
166
|
+
f->lastlinedefined=LoadInt(S);
|
167
|
+
f->nups=LoadByte(S);
|
168
|
+
f->numparams=LoadByte(S);
|
169
|
+
f->is_vararg=LoadByte(S);
|
170
|
+
f->maxstacksize=LoadByte(S);
|
171
|
+
LoadCode(S,f);
|
172
|
+
LoadConstants(S,f);
|
173
|
+
LoadDebug(S,f);
|
174
|
+
IF (!luaG_checkcode(f), "bad code");
|
175
|
+
S->L->top--;
|
176
|
+
return f;
|
177
|
+
}
|
178
|
+
|
179
|
+
static void LoadHeader(LoadState* S)
|
180
|
+
{
|
181
|
+
char h[LUAC_HEADERSIZE];
|
182
|
+
char s[LUAC_HEADERSIZE];
|
183
|
+
luaU_header(h);
|
184
|
+
LoadBlock(S,s,LUAC_HEADERSIZE);
|
185
|
+
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
|
186
|
+
}
|
187
|
+
|
188
|
+
/*
|
189
|
+
** load precompiled chunk
|
190
|
+
*/
|
191
|
+
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
|
192
|
+
{
|
193
|
+
LoadState S;
|
194
|
+
if (*name=='@' || *name=='=')
|
195
|
+
S.name=name+1;
|
196
|
+
else if (*name==LUA_SIGNATURE[0])
|
197
|
+
S.name="binary string";
|
198
|
+
else
|
199
|
+
S.name=name;
|
200
|
+
S.L=L;
|
201
|
+
S.Z=Z;
|
202
|
+
S.b=buff;
|
203
|
+
LoadHeader(&S);
|
204
|
+
return LoadFunction(&S,luaS_newliteral(L,"=?"));
|
205
|
+
}
|
206
|
+
|
207
|
+
/*
|
208
|
+
* make header
|
209
|
+
*/
|
210
|
+
void luaU_header (char* h)
|
211
|
+
{
|
212
|
+
int x=1;
|
213
|
+
memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
|
214
|
+
h+=sizeof(LUA_SIGNATURE)-1;
|
215
|
+
*h++=(char)LUAC_VERSION;
|
216
|
+
*h++=(char)LUAC_FORMAT;
|
217
|
+
*h++=(char)*(char*)&x; /* endianness */
|
218
|
+
*h++=(char)sizeof(int);
|
219
|
+
*h++=(char)sizeof(size_t);
|
220
|
+
*h++=(char)sizeof(Instruction);
|
221
|
+
*h++=(char)sizeof(lua_Number);
|
222
|
+
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
|
223
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $
|
3
|
+
** load precompiled Lua chunks
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef lundump_h
|
8
|
+
#define lundump_h
|
9
|
+
|
10
|
+
#include "lobject.h"
|
11
|
+
#include "lzio.h"
|
12
|
+
|
13
|
+
/* load one chunk; from lundump.c */
|
14
|
+
LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
|
15
|
+
|
16
|
+
/* make header; from lundump.c */
|
17
|
+
LUAI_FUNC void luaU_header (char* h);
|
18
|
+
|
19
|
+
/* dump one chunk; from ldump.c */
|
20
|
+
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
21
|
+
|
22
|
+
#ifdef luac_c
|
23
|
+
/* print one chunk; from print.c */
|
24
|
+
LUAI_FUNC void luaU_print (const Proto* f, int full);
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/* for header of binary files -- this is Lua 5.1 */
|
28
|
+
#define LUAC_VERSION 0x51
|
29
|
+
|
30
|
+
/* for header of binary files -- this is the official format */
|
31
|
+
#define LUAC_FORMAT 0
|
32
|
+
|
33
|
+
/* size of header of binary files */
|
34
|
+
#define LUAC_HEADERSIZE 12
|
35
|
+
|
36
|
+
#endif
|