2014-03-27 03:24:37 +01:00
|
|
|
// Copyright (c) 2014, Thomas Goyne <plorkyeran@aegisub.org>
|
2007-05-01 23:51:49 +02:00
|
|
|
//
|
2011-09-28 21:45:16 +02:00
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
2007-05-01 23:51:49 +02:00
|
|
|
//
|
2011-09-28 21:45:16 +02:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2014-03-27 03:24:37 +01:00
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
#include "libaegisub/lua/modules.h"
|
|
|
|
|
2014-12-28 21:45:55 +01:00
|
|
|
#include "libaegisub/lua/ffi.h"
|
2014-03-27 03:24:37 +01:00
|
|
|
#include "libaegisub/lua/utils.h"
|
|
|
|
|
|
|
|
extern "C" int luaopen_luabins(lua_State *L);
|
|
|
|
extern "C" int luaopen_re_impl(lua_State *L);
|
2014-05-09 15:41:47 +02:00
|
|
|
extern "C" int luaopen_unicode_impl(lua_State *L);
|
2014-07-18 19:33:57 +02:00
|
|
|
extern "C" int luaopen_lfs_impl(lua_State *L);
|
2014-04-27 16:20:11 +02:00
|
|
|
extern "C" int luaopen_lpeg(lua_State *L);
|
2009-07-29 07:43:02 +02:00
|
|
|
|
2014-03-27 03:24:37 +01:00
|
|
|
namespace agi { namespace lua {
|
|
|
|
int regex_init(lua_State *L);
|
2007-05-01 23:51:49 +02:00
|
|
|
|
2014-03-27 03:24:37 +01:00
|
|
|
void preload_modules(lua_State *L) {
|
2014-04-28 04:45:14 +02:00
|
|
|
luaL_openlibs(L);
|
2014-04-26 00:40:43 +02:00
|
|
|
|
2014-03-27 03:24:37 +01:00
|
|
|
lua_getglobal(L, "package");
|
|
|
|
lua_getfield(L, -1, "preload");
|
2007-05-01 23:51:49 +02:00
|
|
|
|
2014-04-26 00:40:43 +02:00
|
|
|
set_field(L, "aegisub.__re_impl", luaopen_re_impl);
|
2014-05-09 15:41:47 +02:00
|
|
|
set_field(L, "aegisub.__unicode_impl", luaopen_unicode_impl);
|
2014-07-18 19:33:57 +02:00
|
|
|
set_field(L, "aegisub.__lfs_impl", luaopen_lfs_impl);
|
2014-03-27 03:24:37 +01:00
|
|
|
set_field(L, "lpeg", luaopen_lpeg);
|
|
|
|
set_field(L, "luabins", luaopen_luabins);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2014-03-27 03:24:37 +01:00
|
|
|
lua_pop(L, 2);
|
2014-12-28 21:45:55 +01:00
|
|
|
|
|
|
|
register_lib_functions(L); // silence an unused static function warning
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_register_lib_function(lua_State *L, const char *name, const char *type_name, void *func) {
|
|
|
|
lua_pushvalue(L, -2); // push cast function
|
|
|
|
lua_pushstring(L, type_name);
|
|
|
|
lua_pushlightuserdata(L, func);
|
|
|
|
lua_call(L, 2, 1);
|
|
|
|
lua_setfield(L, -2, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_register_lib_table(lua_State *L, std::initializer_list<const char *> types) {
|
|
|
|
lua_getglobal(L, "require");
|
|
|
|
lua_pushstring(L, "ffi");
|
|
|
|
lua_call(L, 1, 1);
|
|
|
|
|
|
|
|
// Register all passed type with the ffi
|
|
|
|
for (auto type : types) {
|
|
|
|
lua_getfield(L, -1, "cdef");
|
|
|
|
lua_pushfstring(L, "typedef struct %s %s;", type, type);
|
|
|
|
lua_call(L, 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_getfield(L, -1, "cast");
|
|
|
|
lua_remove(L, -2); // ffi table
|
|
|
|
|
|
|
|
// leaves ffi.cast on the stack
|
2011-12-28 22:27:06 +01:00
|
|
|
}
|
2014-03-27 03:24:37 +01:00
|
|
|
} }
|