diff options
Diffstat (limited to 'apps/plugins/lua')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 4 | ||||
-rwxr-xr-x | apps/plugins/lua/rocklib_aux.pl | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 73c3851bc1..46572014f0 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -38,6 +38,10 @@ | |||
38 | * a C function just pushes them onto the stack, in direct order (the first result is pushed first), | 38 | * a C function just pushes them onto the stack, in direct order (the first result is pushed first), |
39 | * and returns the number of results. Any other value in the stack below the results will be properly | 39 | * and returns the number of results. Any other value in the stack below the results will be properly |
40 | * discarded by Lua. Like a Lua function, a C function called by Lua can also return many results. | 40 | * discarded by Lua. Like a Lua function, a C function called by Lua can also return many results. |
41 | * | ||
42 | * When porting new functions, don't forget to check rocklib_aux.pl whether it automatically creates | ||
43 | * wrappers for the function and if so, add the function names to @forbidden_functions. This is to | ||
44 | * prevent namespace collisions and adding duplicate wrappers. | ||
41 | */ | 45 | */ |
42 | 46 | ||
43 | 47 | ||
diff --git a/apps/plugins/lua/rocklib_aux.pl b/apps/plugins/lua/rocklib_aux.pl index b63aaee18a..77fd08b119 100755 --- a/apps/plugins/lua/rocklib_aux.pl +++ b/apps/plugins/lua/rocklib_aux.pl | |||
@@ -18,6 +18,13 @@ | |||
18 | # | 18 | # |
19 | ############################################################################ | 19 | ############################################################################ |
20 | 20 | ||
21 | |||
22 | # The purpose of this script is to automatically generate Lua wrappers for | ||
23 | # (easily) portable C functions used in the Rockbox plugin API. | ||
24 | # It doesn't contain support for enums, structs or pointers (apart from char*). | ||
25 | # | ||
26 | # The output will be written to <build_dir>/apps/plugins/lua/rocklib_aux.c | ||
27 | |||
21 | sub trim | 28 | sub trim |
22 | { | 29 | { |
23 | my $text = $_[0]; | 30 | my $text = $_[0]; |
@@ -40,6 +47,9 @@ sub rand_string | |||
40 | 47 | ||
41 | my @functions; | 48 | my @functions; |
42 | my @ported_functions; | 49 | my @ported_functions; |
50 | # These functions are excluded from automatically wrapping. This is useful if | ||
51 | # you want to manually port them to Lua. The format is a standard Perl regular | ||
52 | # expression. | ||
43 | my @forbidden_functions = ('^open$', | 53 | my @forbidden_functions = ('^open$', |
44 | '^close$', | 54 | '^close$', |
45 | '^read$', | 55 | '^read$', |
@@ -111,7 +121,10 @@ my $svnrev = '$Revision$'; | |||
111 | 121 | ||
112 | # Print the header | 122 | # Print the header |
113 | print <<EOF | 123 | print <<EOF |
114 | /* Automatically generated of $svnrev from rocklib.c & plugin.h */ | 124 | /* Automatically generated from rocklib.c & plugin.h ($svnrev) |
125 | * | ||
126 | * See apps/plugins/lua/rocklib_aux.pl for the generator. | ||
127 | */ | ||
115 | 128 | ||
116 | #define lrocklib_c | 129 | #define lrocklib_c |
117 | #define LUA_LIB | 130 | #define LUA_LIB |