summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rwxr-xr-xapps/plugins/lua/rocklib_aux.pl22
1 files changed, 21 insertions, 1 deletions
diff --git a/apps/plugins/lua/rocklib_aux.pl b/apps/plugins/lua/rocklib_aux.pl
index 547a628f52..8454da2369 100755
--- a/apps/plugins/lua/rocklib_aux.pl
+++ b/apps/plugins/lua/rocklib_aux.pl
@@ -21,7 +21,7 @@
21 21
22# The purpose of this script is to automatically generate Lua wrappers for 22# The purpose of this script is to automatically generate Lua wrappers for
23# (easily) portable C functions used in the Rockbox plugin API. 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*). 24# It doesn't contain support for structs or pointers (apart from char*).
25# 25#
26# The output will be written to <build_dir>/apps/plugins/lua/rocklib_aux.c 26# The output will be written to <build_dir>/apps/plugins/lua/rocklib_aux.c
27 27
@@ -104,6 +104,7 @@ my @forbidden_functions = ('^atoi$',
104 '^pcm_(apply_settings|get_bytes_waiting)$', 104 '^pcm_(apply_settings|get_bytes_waiting)$',
105 '^pcm_(set_frequency|calculate_peaks)$', 105 '^pcm_(set_frequency|calculate_peaks)$',
106 '^sound_(set|current|default|min|max|unit|pitch|val2phys)$', 106 '^sound_(set|current|default|min|max|unit|pitch|val2phys)$',
107 '^mixer_channel.*$',
107 '^mixer_(set|get)_frequency$', 108 '^mixer_(set|get)_frequency$',
108 '^plugin_get_current_filename$', 109 '^plugin_get_current_filename$',
109 '^plugin_release_audio_buffer$', 110 '^plugin_release_audio_buffer$',
@@ -112,12 +113,15 @@ my @forbidden_functions = ('^atoi$',
112 '^set_dirfilter$', 113 '^set_dirfilter$',
113 '^sleep$', 114 '^sleep$',
114 '^system_memory_guard$', 115 '^system_memory_guard$',
116 '^system_sound_play$',
115 '^talk_number$', 117 '^talk_number$',
116 '^talk_force_shutup$', 118 '^talk_force_shutup$',
117 '^talk_spell$', 119 '^talk_spell$',
118 '^talk_shutup$', 120 '^talk_shutup$',
119 '^(trigger|cancel)_cpu_boost$', 121 '^(trigger|cancel)_cpu_boost$',
120 '^thread_', 122 '^thread_',
123 '^touchscreen_(get|set)_mode$',
124 '^viewportmanager_theme_undo$',
121 '^round_value_to_list32$'); 125 '^round_value_to_list32$');
122 126
123my $rocklib = sprintf("%s/rocklib.c", $ARGV[0]); 127my $rocklib = sprintf("%s/rocklib.c", $ARGV[0]);
@@ -193,6 +197,7 @@ EOF
193; 197;
194 198
195my %in_types = ('void' => \&in_void, 199my %in_types = ('void' => \&in_void,
200 'enum' => \&in_enum,
196 'int' => \&in_int, 201 'int' => \&in_int,
197 'unsigned' => \&in_int, 202 'unsigned' => \&in_int,
198 'unsignedint' => \&in_int, 203 'unsignedint' => \&in_int,
@@ -216,6 +221,7 @@ my %in_types = ('void' => \&in_void,
216 'bool' => \&in_bool, 221 'bool' => \&in_bool,
217 '_Bool' => \&in_bool 222 '_Bool' => \&in_bool
218), %out_types = ('void' => \&out_void, 223), %out_types = ('void' => \&out_void,
224 'enum' => \&out_enum,
219 'int' => \&out_int, 225 'int' => \&out_int,
220 'unsigned' => \&out_int, 226 'unsigned' => \&out_int,
221 'unsignedint' => \&out_int, 227 'unsignedint' => \&out_int,
@@ -245,6 +251,12 @@ sub in_void
245 return "\t(void)L;\n"; 251 return "\t(void)L;\n";
246} 252}
247 253
254sub in_enum
255{
256 my ($name, $type, $pos) = @_;
257 return sprintf("\t%s %s = luaL_checkint(L, %d); /*(enum)*/\n", "int", $name, $pos);
258}
259
248sub in_int 260sub in_int
249{ 261{
250 my ($name, $type, $pos) = @_; 262 my ($name, $type, $pos) = @_;
@@ -269,6 +281,12 @@ sub out_void
269 return sprintf("\t%s;\n\treturn 0;\n", $name); 281 return sprintf("\t%s;\n\treturn 0;\n", $name);
270} 282}
271 283
284sub out_enum
285{
286 my ($name, $type) = @_;
287 return sprintf("\t%s result = %s;\n\tlua_pushinteger(L, result);\n\treturn 1; /*(enum)*/\n", "int", $name);
288}
289
272sub out_int 290sub out_int
273{ 291{
274 my ($name, $type) = @_; 292 my ($name, $type) = @_;
@@ -310,6 +328,7 @@ foreach my $function (@sorted_functions)
310 else 328 else
311 { 329 {
312 $literal_type = trim($1), $name = trim($2), $type = trim($1); 330 $literal_type = trim($1), $name = trim($2), $type = trim($1);
331 $type =~ s/^enum\s+.*/enum/g;
313 $type =~ s/(\s|const)//g; 332 $type =~ s/(\s|const)//g;
314 333
315 if($name eq "") 334 if($name eq "")
@@ -339,6 +358,7 @@ foreach my $function (@sorted_functions)
339 358
340 # Check for supported return value 359 # Check for supported return value
341 my $return = @$function{'return'}; 360 my $return = @$function{'return'};
361 $return =~ s/^enum\s+.*/enum/g;
342 $return =~ s/(\s|const)//g; 362 $return =~ s/(\s|const)//g;
343 #printf "/* %s: %s [%d] */\n", @$function{'name'}, $return, $valid; 363 #printf "/* %s: %s [%d] */\n", @$function{'name'}, $return, $valid;
344 if(!defined $out_types{$return}) 364 if(!defined $out_types{$return})