Tasklist
FS#9174 - Lua Scripting Language for Rockbox
| Task Type |
Patches |
| Category |
Plugins |
| Status |
Closed |
| Assigned To |
No-one |
| Player Type |
All players |
| Severity |
Low |
| Priority |
Normal |
| Reported Version |
Daily build (which?) |
| Due in Version |
Undecided |
| Due Date |
Undecided |
| Percent Complete |
|
| Private |
No
|
|
Details
Here is an (very, very) early proof of concept Lua viewer plugin (v.5.1.3).
Currently only a few functions are exported from the plugin API and it also lacks a setjmp/longjmp implementation for actual targets so error handling will go wrong very quickly.
However it does work so far for simple scripts like the following:
function sayhello(seconds)
message = string.format("Hello from LUA for %d seconds", 5)
rb.splash(seconds, message)
end
-- Drawn an X on the screen
rb.clear()
rb.drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT)
rb.drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT)
rb.update()
seconds = 5
rb.sleep(5 * rb.HZ)
sayhello(seconds)
lua-viewer-v0.patch
(593 KiB)
apps/plugins/CATEGORIES | 1
apps/plugins/viewers.config | 1
apps/plugins/lua/ldebug.c | 622 +++++
apps/plugins/lua/ldebug.h | 33
apps/plugins/lua/ltablib.c | 279 ++
apps/plugins/lua/lstrlib.c | 868 +++++++
apps/plugins/lua/lualib.h | 53
apps/plugins/lua/lundump.c | 225 +
apps/plugins/lua/lundump.h | 36
apps/plugins/lua/lmem.c | 86
apps/plugins/lua/Makefile | 84
apps/plugins/lua/lvm.c | 763 ++++++
apps/plugins/lua/lmem.h | 49
apps/plugins/lua/rocklua.c | 93
apps/plugins/lua/ltable.c | 588 ++++
apps/plugins/lua/lvm.h | 36
apps/plugins/lua/lfunc.c | 174 +
apps/plugins/lua/ltable.h | 40
apps/plugins/lua/lparser.c | 1339 +++++++++++
apps/plugins/lua/lfunc.h | 34
apps/plugins/lua/lparser.h | 82
apps/plugins/lua/lzio.c | 82
apps/plugins/lua/lbaselib.c | 654 +++++
apps/plugins/lua/lzio.h | 67
apps/plugins/lua/lstring.c | 111
apps/plugins/lua/lobject.c | 214 +
apps/plugins/lua/lapi.c | 1085 +++++++++
apps/plugins/lua/lua.h | 388 +++
apps/plugins/lua/lstring.h | 31
apps/plugins/lua/lobject.h | 381 +++
apps/plugins/lua/lapi.h | 16
apps/plugins/lua/strcspn.c | 16
apps/plugins/lua/rocklibc.h | 47
apps/plugins/lua/lauxlib.c | 654 +++++
apps/plugins/lua/lauxlib.h | 174 +
apps/plugins/lua/malloc.c | 5061 ++++++++++++++++++++++++++++++++++++++++++
apps/plugins/lua/strtoul.c | 53
apps/plugins/lua/ldo.c | 518 ++++
apps/plugins/lua/ldump.c | 164 +
apps/plugins/lua/ldo.h | 57
apps/plugins/lua/rocklib.c | 108
apps/plugins/lua/rockmalloc.c | 80
apps/plugins/lua/strpbrk.c | 10
apps/plugins/lua/rocklib.h | 29
apps/plugins/lua/ltm.c | 75
apps/plugins/lua/lstate.c | 214 +
apps/plugins/lua/ltm.h | 54
apps/plugins/lua/strstr.c | 16
apps/plugins/lua/lstate.h | 169 +
apps/plugins/lua/SOURCES | 33
apps/plugins/lua/llex.c | 461 +++
apps/plugins/lua/lgc.c | 711 +++++
apps/plugins/lua/lopcodes.c | 102
apps/plugins/lua/rockconf.h | 68
apps/plugins/lua/llex.h | 81
apps/plugins/lua/lgc.h | 110
apps/plugins/lua/rockaux.c | 84
apps/plugins/lua/README | 19
apps/plugins/lua/lopcodes.h | 268 ++
apps/plugins/lua/strncat.c | 21
apps/plugins/lua/strtod.c | 64
apps/plugins/lua/llimits.h | 128 +
apps/plugins/lua/lcode.c | 839 ++++++
apps/plugins/lua/lcode.h | 76
apps/plugins/lua/luaconf.h | 763 ++++++
apps/plugins/SUBDIRS | 5
apps/plugin.h | 2
firmware/include/ctype.h | 2
68 files changed, 19849 insertions(+), 2 deletions(-)
|
Loading...
I've added some extra functions to the rb lib (see attached diff)
I will test it later on a device but it looked good in sim.
* added more functions to rocklib
* added ability to use audiobuffer when out of pluginbuffer RAM
AFAIK, this is pretty stable; but I would like to get another dev to confirm that..
* Adds UNLIKELY & LIKELY
I tried v6 on the gigabeat and it looks as if numbers are not parsed correctly. I.e. the 5 seconds become 1075052544 - maybe to do with the fact that the only numerical datatype in LUA is float. Also the rectangle doesn't get drawn - I suspect for the same reason.
In the simulator (cygwin) it is worse. To get it to compile I had to make the "int error_no = 0;" unconditional. I didn't get it to draw anything, but the splash was displayed (with a rather big number).
But i got problems running the test script in the simulator.
The screen gets cleaned and nothing else happends.
* removes strtod
* adds strtol
* should completely remove floating-point support
If this version doesn't break somewhere/something I'll probably commit it soon.
* adds some more wrappers
* adds the current path & /.rockbox/rocks/viewers/ to the search path when including files