Module wrapper
Generator of a C "wrapper" for standalone Lua programs.
Functions
generate (lua_chunk, clib_names, opts, write) | Generates source code of the C "wrapper" with the given Lua chunk and preloaded native modules. |
Local Functions
luaopen_name (name) | Converts the module name in dot-notation into name of the corresponding C luaopen function. |
encode_c_hex (write, data) | Encodes the given data into hexadecimal representation formatted as a C array. |
define_macro_const (write, name, value) | Formats C #define directive with the specified constant. |
define_preloaded_libs (write, names) | Writes code for preloading of the specified Lua/C modules. |
define_script (write, data, unpacked_size) | Writes the Lua script encoded as a C array of bytes in hexa. |
Functions
- generate (lua_chunk, clib_names, opts, write)
-
Generates source code of the C "wrapper" with the given Lua chunk and preloaded
native modules.
Parameters:
- lua_chunk string The Lua chunk (source code or byte code) to embed.
- clib_names optional {string,...} List of names of native modules to be preload.
- opts
optional {[string]=bool,...}
Options:
compress
- enable compression. - write optional function The writer function. If not give, an intermediate table will be created and generated code returned as string.
Returns:
-
optional string
A generated source code, or nil if the
write
function given.
Local Functions
- luaopen_name (name)
-
Converts the module name in dot-notation into name of the corresponding
C luaopen function.
Parameters:
- name string
Returns:
- encode_c_hex (write, data)
-
Encodes the given data into hexadecimal representation formatted as a C array.
Parameters:
- write func The writer function.
- data string
- define_macro_const (write, name, value)
-
Formats C
#define
directive with the specified constant.Parameters:
- write function
- name string The constant name.
- value The constant value.
- define_preloaded_libs (write, names)
-
Writes code for preloading of the specified Lua/C modules.
Parameters:
- write func The writer function.
- names {string,...} A list of full names in dot-notation.
- define_script (write, data, unpacked_size)
-
Writes the Lua script encoded as a C array of bytes in hexa.
Parameters:
- write function
- data string Lua chunk or compressed Lua chunk.
- unpacked_size optional int Size of uncompressed Lua chunk.