diff options
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 77b49dc8ec..e617f3e4bf 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) | 57 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) |
58 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } | 58 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } |
59 | 59 | ||
60 | /* KERNEL */ | ||
60 | RB_WRAP(current_tick) | 61 | RB_WRAP(current_tick) |
61 | { | 62 | { |
62 | lua_pushinteger(L, *rb->current_tick); | 63 | lua_pushinteger(L, *rb->current_tick); |
@@ -77,6 +78,13 @@ RB_WRAP(schedule_cpu_boost) | |||
77 | } | 78 | } |
78 | #endif | 79 | #endif |
79 | 80 | ||
81 | RB_WRAP(sleep) | ||
82 | { | ||
83 | unsigned ticks = (unsigned) lua_tonumber(L, 1); | ||
84 | rb->sleep(ticks); | ||
85 | return 0; | ||
86 | } | ||
87 | |||
80 | #ifdef HAVE_PRIORITY_SCHEDULING | 88 | #ifdef HAVE_PRIORITY_SCHEDULING |
81 | RB_WRAP(thread_set_priority) | 89 | RB_WRAP(thread_set_priority) |
82 | { | 90 | { |
@@ -847,8 +855,47 @@ RB_WRAP(read_mem) | |||
847 | lua_replace(L, -3);/* stk pos 1 is no longer offset it is starting address */ | 855 | lua_replace(L, -3);/* stk pos 1 is no longer offset it is starting address */ |
848 | return mem_read_write(L, address, maxsize, false); | 856 | return mem_read_write(L, address, maxsize, false); |
849 | } | 857 | } |
858 | |||
859 | /* will add this back if anyone finds a target that needs it */ | ||
860 | RB_WRAP(system_memory_guard) | ||
861 | { | ||
862 | int newmode = (int) luaL_checkint(L, 1); | ||
863 | int result = rb->system_memory_guard(newmode); | ||
864 | lua_pushinteger(L, result); | ||
865 | return 1; | ||
866 | } | ||
850 | #endif | 867 | #endif |
851 | 868 | ||
869 | /* SPEAKING */ | ||
870 | static int rock_talk(lua_State *L) | ||
871 | { | ||
872 | int result; | ||
873 | bool enqueue = lua_toboolean(L, 2); | ||
874 | if (lua_isnumber(L, 1)) | ||
875 | { | ||
876 | long n = (long) lua_tonumber(L, 1); | ||
877 | result = rb->talk_number(n, enqueue); | ||
878 | } | ||
879 | else | ||
880 | { | ||
881 | const char* spell = luaL_checkstring(L, 1); | ||
882 | result = rb->talk_spell(spell, enqueue); | ||
883 | } | ||
884 | |||
885 | lua_pushinteger(L, result); | ||
886 | return 1; | ||
887 | } | ||
888 | |||
889 | RB_WRAP(talk_shutup) | ||
890 | { | ||
891 | if (lua_toboolean(L, 1)) | ||
892 | rb->talk_force_shutup(); | ||
893 | else | ||
894 | rb->talk_shutup(); | ||
895 | return 0; | ||
896 | } | ||
897 | |||
898 | /* MISC */ | ||
852 | RB_WRAP(restart_lua) | 899 | RB_WRAP(restart_lua) |
853 | { | 900 | { |
854 | /*close lua state, open a new lua state, load script @ filename */ | 901 | /*close lua state, open a new lua state, load script @ filename */ |
@@ -859,17 +906,16 @@ RB_WRAP(restart_lua) | |||
859 | return -1; | 906 | return -1; |
860 | } | 907 | } |
861 | 908 | ||
862 | |||
863 | #define RB_FUNC(func) {#func, rock_##func} | 909 | #define RB_FUNC(func) {#func, rock_##func} |
864 | #define RB_ALIAS(name, func) {name, rock_##func} | 910 | #define RB_ALIAS(name, func) {name, rock_##func} |
865 | static const luaL_Reg rocklib[] = | 911 | static const luaL_Reg rocklib[] = |
866 | { | 912 | { |
867 | /* Kernel */ | 913 | /* KERNEL */ |
868 | RB_FUNC(current_tick), | 914 | RB_FUNC(current_tick), |
869 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | 915 | #ifdef HAVE_SCHEDULER_BOOSTCTRL |
870 | RB_FUNC(schedule_cpu_boost), | 916 | RB_FUNC(schedule_cpu_boost), |
871 | #endif | 917 | #endif |
872 | 918 | RB_FUNC(sleep), | |
873 | #ifdef HAVE_PRIORITY_SCHEDULING | 919 | #ifdef HAVE_PRIORITY_SCHEDULING |
874 | RB_FUNC(thread_set_priority), | 920 | RB_FUNC(thread_set_priority), |
875 | #endif | 921 | #endif |
@@ -932,6 +978,12 @@ static const luaL_Reg rocklib[] = | |||
932 | RB_FUNC(audio_next_track), | 978 | RB_FUNC(audio_next_track), |
933 | RB_FUNC(audio_current_track), | 979 | RB_FUNC(audio_current_track), |
934 | 980 | ||
981 | /* SPEAKING */ | ||
982 | {"talk_number", rock_talk}, | ||
983 | {"talk_spell", rock_talk}, | ||
984 | RB_FUNC(talk_shutup), | ||
985 | |||
986 | /* MISC */ | ||
935 | RB_FUNC(restart_lua), | 987 | RB_FUNC(restart_lua), |
936 | 988 | ||
937 | {NULL, NULL} | 989 | {NULL, NULL} |