From 4fb783582fa6d961160fea940ad417d099ec0732 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 27 Sep 2019 03:15:57 -0500 Subject: lua rocklib_aux.pl support for enums everything that would have been added has already been added or needs more supporting functions so they've been excluded for the time being Change-Id: I4ae4753c543287934702a3bd2eeccce5b032235d --- apps/plugins/lua/rocklib_aux.pl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 @@ # The purpose of this script is to automatically generate Lua wrappers for # (easily) portable C functions used in the Rockbox plugin API. -# It doesn't contain support for enums, structs or pointers (apart from char*). +# It doesn't contain support for structs or pointers (apart from char*). # # The output will be written to /apps/plugins/lua/rocklib_aux.c @@ -104,6 +104,7 @@ my @forbidden_functions = ('^atoi$', '^pcm_(apply_settings|get_bytes_waiting)$', '^pcm_(set_frequency|calculate_peaks)$', '^sound_(set|current|default|min|max|unit|pitch|val2phys)$', + '^mixer_channel.*$', '^mixer_(set|get)_frequency$', '^plugin_get_current_filename$', '^plugin_release_audio_buffer$', @@ -112,12 +113,15 @@ my @forbidden_functions = ('^atoi$', '^set_dirfilter$', '^sleep$', '^system_memory_guard$', + '^system_sound_play$', '^talk_number$', '^talk_force_shutup$', '^talk_spell$', '^talk_shutup$', '^(trigger|cancel)_cpu_boost$', '^thread_', + '^touchscreen_(get|set)_mode$', + '^viewportmanager_theme_undo$', '^round_value_to_list32$'); my $rocklib = sprintf("%s/rocklib.c", $ARGV[0]); @@ -193,6 +197,7 @@ EOF ; my %in_types = ('void' => \&in_void, + 'enum' => \&in_enum, 'int' => \&in_int, 'unsigned' => \&in_int, 'unsignedint' => \&in_int, @@ -216,6 +221,7 @@ my %in_types = ('void' => \&in_void, 'bool' => \&in_bool, '_Bool' => \&in_bool ), %out_types = ('void' => \&out_void, + 'enum' => \&out_enum, 'int' => \&out_int, 'unsigned' => \&out_int, 'unsignedint' => \&out_int, @@ -245,6 +251,12 @@ sub in_void return "\t(void)L;\n"; } +sub in_enum +{ + my ($name, $type, $pos) = @_; + return sprintf("\t%s %s = luaL_checkint(L, %d); /*(enum)*/\n", "int", $name, $pos); +} + sub in_int { my ($name, $type, $pos) = @_; @@ -269,6 +281,12 @@ sub out_void return sprintf("\t%s;\n\treturn 0;\n", $name); } +sub out_enum +{ + my ($name, $type) = @_; + return sprintf("\t%s result = %s;\n\tlua_pushinteger(L, result);\n\treturn 1; /*(enum)*/\n", "int", $name); +} + sub out_int { my ($name, $type) = @_; @@ -310,6 +328,7 @@ foreach my $function (@sorted_functions) else { $literal_type = trim($1), $name = trim($2), $type = trim($1); + $type =~ s/^enum\s+.*/enum/g; $type =~ s/(\s|const)//g; if($name eq "") @@ -339,6 +358,7 @@ foreach my $function (@sorted_functions) # Check for supported return value my $return = @$function{'return'}; + $return =~ s/^enum\s+.*/enum/g; $return =~ s/(\s|const)//g; #printf "/* %s: %s [%d] */\n", @$function{'name'}, $return, $valid; if(!defined $out_types{$return}) -- cgit v1.2.3