Compare commits
1 Commits
main
...
add-excamp
Author | SHA1 | Date | |
---|---|---|---|
7fd94fc4c6 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "lua"]
|
||||||
|
path = lua
|
||||||
|
url = https://git.kolibrios.org/lua/lua.git
|
||||||
|
30
.vscode/c_cpp_properties.json
vendored
30
.vscode/c_cpp_properties.json
vendored
@@ -1,42 +1,20 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Windows Lua5.4",
|
"name": "Release",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"C:/MinGW/msys/1.0/home/autobuild/tools/win32/include",
|
"${workspaceFolder}/lua/src",
|
||||||
"C:/MinGW/msys/1.0/home/autobuild/tools/win32/include/lua5.4",
|
|
||||||
"${workspaceFolder}/../kolibrios/contrib/sdk/sources/newlib/libc/include"
|
"${workspaceFolder}/../kolibrios/contrib/sdk/sources/newlib/libc/include"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": []
|
||||||
"SYSCALLS_VERSION_A",
|
|
||||||
"SYSCALLS_VERSION_B",
|
|
||||||
"SYSCALLS_VERSION_C"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Windows Lua5.3",
|
|
||||||
"includePath": [
|
|
||||||
"C:/MinGW/msys/1.0/home/autobuild/tools/win32/include",
|
|
||||||
"C:/MinGW/msys/1.0/home/autobuild/tools/win32/include/lua5.3",
|
|
||||||
"${workspaceFolder}/../kolibrios/contrib/sdk/sources/newlib/libc/include"
|
|
||||||
],
|
|
||||||
"defines": [
|
|
||||||
"SYSCALLS_VERSION_A",
|
|
||||||
"SYSCALLS_VERSION_B",
|
|
||||||
"SYSCALLS_VERSION_C"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Debug",
|
"name": "Debug",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"/home/autobuild/tools/win32/include",
|
"${workspaceFolder}/lua/src",
|
||||||
"/home/autobuild/tools/win32/include/lua5.4",
|
|
||||||
"${workspaceFolder}/../kolibrios/contrib/sdk/sources/newlib/libc/include"
|
"${workspaceFolder}/../kolibrios/contrib/sdk/sources/newlib/libc/include"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"SYSCALLS_VERSION_A",
|
|
||||||
"SYSCALLS_VERSION_B",
|
|
||||||
"SYSCALLS_VERSION_C",
|
|
||||||
"NDEBUG"
|
"NDEBUG"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@@ -7,11 +7,7 @@
|
|||||||
"socket.h": "c",
|
"socket.h": "c",
|
||||||
"graphic.h": "c",
|
"graphic.h": "c",
|
||||||
"syscalls.h": "c",
|
"syscalls.h": "c",
|
||||||
"registers.h": "c",
|
"registers.h": "c"
|
||||||
"version_type.h": "c",
|
|
||||||
"library_version.h": "c",
|
|
||||||
"scancodes.h": "c",
|
|
||||||
"ipc.h": "c"
|
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"syscalls",
|
"syscalls",
|
||||||
@@ -32,7 +28,6 @@
|
|||||||
"luaL_checkudata",
|
"luaL_checkudata",
|
||||||
"luaL_optinteger",
|
"luaL_optinteger",
|
||||||
"luaL_pushfail",
|
"luaL_pushfail",
|
||||||
"lua_pushlightuserdata",
|
|
||||||
"lua_pushboolean",
|
"lua_pushboolean",
|
||||||
"lua_pushinteger",
|
"lua_pushinteger",
|
||||||
"lua_pushnumber",
|
"lua_pushnumber",
|
||||||
|
30
.vscode/tasks.json
vendored
30
.vscode/tasks.json
vendored
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "Build",
|
|
||||||
"type": "process",
|
|
||||||
"command": "make",
|
|
||||||
"args": [
|
|
||||||
"syscalls.dll"
|
|
||||||
],
|
|
||||||
"group": {
|
|
||||||
"isDefault": true,
|
|
||||||
"kind": "build"
|
|
||||||
},
|
|
||||||
"problemMatcher": "$gcc"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Clean",
|
|
||||||
"type": "process",
|
|
||||||
"command": "make",
|
|
||||||
"args": [
|
|
||||||
"clean"
|
|
||||||
],
|
|
||||||
"group": {
|
|
||||||
"isDefault": false,
|
|
||||||
"kind": "build"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
40
Makefile
40
Makefile
@@ -1,18 +1,13 @@
|
|||||||
|
LUA_V = 54
|
||||||
LUA_V = 5.4
|
|
||||||
SYSCALLS_VER_A = 2
|
|
||||||
SYSCALLS_VER_B = 0
|
|
||||||
SYSCALLS_VER_C = 0
|
|
||||||
SYSCALLS_VER = $(SYSCALLS_VER_C).$(SYSCALLS_VER_B).$(SYSCALLS_VER_A)
|
|
||||||
|
|
||||||
CC = kos32-gcc
|
CC = kos32-gcc
|
||||||
LD = kos32-ld
|
LD = kos32-ld
|
||||||
STRIP = kos32-strip
|
STRIP = kos32-strip
|
||||||
OBJCOPY = kos32-objcopy
|
OBJCOPY = kos32-objcopy
|
||||||
STD = -std=gnu11
|
STD = -std=gnu11
|
||||||
CFLAGS = $(SYSCFLAGS) -O2 -Wall -Wextra $(STD) $(MYCFLAGS) -DSYSCALLS_VERSION_A=$(SYSCALLS_VER_A) -DSYSCALLS_VERSION_B=$(SYSCALLS_VER_B) -DSYSCALLS_VERSION_C=$(SYSCALLS_VER_C)
|
CFLAGS = $(SYSCFLAGS) -O2 -Wall -Wextra $(STD) $(MYCFLAGS)
|
||||||
LDFLAGS = $(SYSLDFLAGS) $(MYLDFLAGS)
|
LDFLAGS = $(SYSLDFLAGS) $(MYLDFLAGS)
|
||||||
LIBS = $(SYSLIBS) $(MYLIBS) -llua$(LUA_V).dll
|
LIBS = $(SYSLIBS) $(MYLIBS) $(TOOLCHAIN_PATH)/mingw32/lib/lua$(LUA_V).dll.a
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
TOOLCHAIN_PATH = C:/MinGW/msys/1.0/home/autobuild/tools/win32
|
TOOLCHAIN_PATH = C:/MinGW/msys/1.0/home/autobuild/tools/win32
|
||||||
@@ -26,8 +21,9 @@ KOLIBRIOS_REPO = $(abspath ../kolibrios)
|
|||||||
|
|
||||||
SDK_DIR = $(KOLIBRIOS_REPO)/contrib/sdk
|
SDK_DIR = $(KOLIBRIOS_REPO)/contrib/sdk
|
||||||
NewLib_DIR = $(SDK_DIR)/sources/newlib
|
NewLib_DIR = $(SDK_DIR)/sources/newlib
|
||||||
SYSCFLAGS = -fno-ident -fomit-frame-pointer -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -I$(NewLib_DIR)/libc/include -I$(TOOLCHAIN_PATH)/include -I$(TOOLCHAIN_PATH)/include/lua$(LUA_V)
|
SYSCFLAGS = -fno-ident -fomit-frame-pointer -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -I$(NewLib_DIR)/libc/include -I$(abspath .)/lua/src
|
||||||
SYSLIBS = -L $(SDK_DIR)/lib -lgcc -lc.dll -ldll
|
SYSLDFLAGS = --image-base 0 -Tapp-dynamic.lds
|
||||||
|
SYSLIBS = -nostdlib -L $(SDK_DIR)/lib -L$(TOOLCHAIN_PATH)/lib -L$(TOOLCHAIN_PATH)/mingw32/lib -lgcc -lc.dll -ldll
|
||||||
MYCFLAGS =
|
MYCFLAGS =
|
||||||
MYLDFLAGS =
|
MYLDFLAGS =
|
||||||
MYLIBS =
|
MYLIBS =
|
||||||
@@ -35,14 +31,12 @@ MYOBJS =
|
|||||||
|
|
||||||
|
|
||||||
Socket_O = src/sockets/socket.o src/sockets/socket_lua.o src/sockets/sockaddr.o
|
Socket_O = src/sockets/socket.o src/sockets/socket_lua.o src/sockets/sockaddr.o
|
||||||
IPC_O = src/IPC/ipc.o src/IPC/IPC_msg.o src/IPC/IPC_buffer.o
|
|
||||||
Debug_O = src/debug/debug.o src/debug/registers.o
|
Debug_O = src/debug/debug.o src/debug/registers.o
|
||||||
Version_O = src/version/coreversion.o src/version/version_type.o
|
|
||||||
|
|
||||||
ALL_O = src/syscalls.o src/ARP_entry.o src/systemColors.o src/graphic.o $(Socket_O) $(Debug_O) $(Version_O) $(IPC_O) src/background/background.o
|
ALL_O = src/syscalls.o src/ARP_entry.o src/systemColors.o src/graphic.o $(Socket_O) $(Debug_O)
|
||||||
|
|
||||||
syscalls.dll: $(ALL_O)
|
syscalls.dll: $(ALL_O)
|
||||||
$(LD) -shared -T dll.lds --entry _DllStartup $(LDFLAGS) -o $@ $(ALL_O) $(LIBS)
|
$(CC) -shared -T dll.lds --entry _DllStartup -o $@ $(ALL_O) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ALL_O) syscalls.dll
|
rm -f $(ALL_O) syscalls.dll
|
||||||
@@ -51,9 +45,7 @@ clean:
|
|||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
|
|
||||||
IPC_H = src/IPC/IPC_msg.h src/IPC/IPC_buffer.h src/IPC/ipc.h
|
src/syscalls.o: src/syscalls.c src/syscalls.h src/systemColors.h src/ARP_entry.h src/scancodes.h src/sockets/socket_lua.h src/graphic.h
|
||||||
|
|
||||||
src/syscalls.o: src/syscalls.c src/syscalls.h src/systemColors.h src/ARP_entry.h src/scancodes.h src/sockets/socket_lua.h src/graphic.h src/version/library_version.h $(IPC_H)
|
|
||||||
src/ARP_entry.o: src/ARP_entry.c src/ARP_entry.h src/debug.h
|
src/ARP_entry.o: src/ARP_entry.c src/ARP_entry.h src/debug.h
|
||||||
src/systemColors.o: src/systemColors.c src/systemColors.h src/debug.h
|
src/systemColors.o: src/systemColors.c src/systemColors.h src/debug.h
|
||||||
src/sockets/socket.o: src/sockets/socket.c src/sockets/socket.h
|
src/sockets/socket.o: src/sockets/socket.c src/sockets/socket.h
|
||||||
@@ -61,13 +53,7 @@ src/sockets/socket_lua.o: src/sockets/socket_lua.c src/sockets/socket_lua.h
|
|||||||
src/sockets/sockaddr.o: src/sockets/sockaddr.c src/sockets/sockaddr.h
|
src/sockets/sockaddr.o: src/sockets/sockaddr.c src/sockets/sockaddr.h
|
||||||
src/graphic.o: src/graphic.c src/graphic.h
|
src/graphic.o: src/graphic.c src/graphic.h
|
||||||
src/debug/debug.o: src/debug/debug.c src/debug/debug.h src/debug/registers.h
|
src/debug/debug.o: src/debug/debug.c src/debug/debug.h src/debug/registers.h
|
||||||
src/IPC/ipc.o: src/IPC/ipc.c src/IPC/ipc.h src/IPC/IPC_msg.h
|
src/debug/registers.o: src/debug/registers.c src/debug/registers.h src/syscalls.h
|
||||||
src/IPC/IPC_msg.o: src/IPC/IPC_msg.c src/IPC/IPC_msg.h
|
|
||||||
src/IPC/IPC_buffer.o: src/IPC/IPC_buffer.c src/IPC/IPC_buffer.h src/IPC/IPC_msg.h
|
|
||||||
src/debug/registers.o: src/debug/registers.c src/debug/registers.h src/syscalls.h src/debug.h
|
|
||||||
src/version/coreversion.o: src/version/coreversion.c src/version/coreversion.h
|
|
||||||
src/version/version_type.o: src/version/version_type.c src/version/version_type.h src/debug.h
|
|
||||||
src/background/background.o: src/background/background.c src/background/background.h
|
|
||||||
|
|
||||||
## headers
|
## headers
|
||||||
|
|
||||||
@@ -76,9 +62,3 @@ src/sockets/socket_lua.h: src/syscalls.h src/sockets/socket.h
|
|||||||
src/sockets/sockaddr.h: src/sockets/socket.h src/syscalls.h
|
src/sockets/sockaddr.h: src/sockets/socket.h src/syscalls.h
|
||||||
src/debug/debug.h: src/syscalls.h
|
src/debug/debug.h: src/syscalls.h
|
||||||
src/debug/registers.h: src/syscalls.h
|
src/debug/registers.h: src/syscalls.h
|
||||||
src/IPC/IPC_msg.h: src/syscalls.h
|
|
||||||
src/IPC/IPC_buffer.h: src/syscalls.h
|
|
||||||
src/IPC/ipc.h: src/syscalls.h
|
|
||||||
src/version/coreversion.h: src/version/version_type.h
|
|
||||||
src/version/version_type.h: src/syscalls.h
|
|
||||||
src/background/background.h: src/syscalls.h
|
|
||||||
|
@@ -1,3 +1,7 @@
|
|||||||
# Syscalls
|
# Syscalls
|
||||||
|
|
||||||
Syscalls library for Lua
|
Syscalls library for Lua
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
you can find it in tests folder
|
||||||
|
196
doc/manual.md
196
doc/manual.md
@@ -4,24 +4,24 @@ This is KolibriOS lua syscalls library. Usually you shouldn't use this library
|
|||||||
|
|
||||||
Better if you read before [KolibriOS syscalls wiki](http://wiki.kolibrios.org/wiki/)
|
Better if you read before [KolibriOS syscalls wiki](http://wiki.kolibrios.org/wiki/)
|
||||||
|
|
||||||
include this library:
|
include:
|
||||||
```lua
|
```lua
|
||||||
local syscalls = require("syscalls")
|
local syscalls = require("syscalls")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
### SetEventMask(newMask)
|
### `SetEventMask(newMask)`
|
||||||
|
|
||||||
### CheckEvent()
|
### `CheckEvent()`
|
||||||
|
|
||||||
check [event](#events-list)
|
check event
|
||||||
|
|
||||||
### WaitEvent()
|
### `WaitEvent()`
|
||||||
|
|
||||||
Endless wait [event](#events-list)
|
Endless wait event
|
||||||
|
|
||||||
### WaitEventTimeout(timeout)
|
### `WaitEventTimeout(timeout)`
|
||||||
|
|
||||||
Wait timeout 1/100 sec
|
Wait timeout 1/100 sec
|
||||||
|
|
||||||
@@ -44,37 +44,37 @@ syscalls.Event.<EventName>
|
|||||||
|
|
||||||
## Window
|
## Window
|
||||||
|
|
||||||
### CreateWindow(x, y, width, height, workColor, [style](#window-style), borderColor, titleColor)
|
### `CreateWindow(x, y, width, height, workColor, style, borderColor, titleColor)`
|
||||||
|
|
||||||
Define window
|
Define window
|
||||||
|
|
||||||
`borderColor` and borderColor` only for FixSizes` and CanChangeSizes` (without skin styles) style.
|
`borderColor` and `borderColor` only for `FixSizes` and `CanChangeSizes` (without skin styles) style.
|
||||||
|
|
||||||
### StartRedraw()
|
### `StartRedraw()`
|
||||||
|
|
||||||
Start window redraw. Just call it before CreateWindow`
|
Start window redraw. Just call it before `CreateWindow`
|
||||||
|
|
||||||
### EndRedraw()
|
### `EndRedraw()`
|
||||||
|
|
||||||
End window redraw. Just call it after you done redraw window.
|
End window redraw. Just call it after you done redraw window.
|
||||||
|
|
||||||
### ChangeWindow(newX, newY, newWidth, newHeight)
|
### `ChangeWindow(newX, newY, newWidth, newHeight)`
|
||||||
|
|
||||||
### FocusWindow(slot)
|
### `FocusWindow(slot)`
|
||||||
|
|
||||||
### UnfocusWindow(slot)
|
### `UnfocusWindow(slot)`
|
||||||
|
|
||||||
### SetWindowTitle(newTitle)
|
### `SetWindowTitle(newTitle)`
|
||||||
|
|
||||||
### GetSkinHeight()
|
### `GetSkinHeight()`
|
||||||
|
|
||||||
return skin height.
|
return skin height.
|
||||||
|
|
||||||
### SetSkin(path)
|
### `SetSkin(path)`
|
||||||
|
|
||||||
return error code
|
return error code
|
||||||
|
|
||||||
### GetSkinTitleArea()
|
### `GetSkinTitleArea()`
|
||||||
|
|
||||||
return table:
|
return table:
|
||||||
```lua
|
```lua
|
||||||
@@ -86,7 +86,7 @@ return table:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Window Style
|
### Style
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
syscalls.windowStyle.<Value>
|
syscalls.windowStyle.<Value>
|
||||||
@@ -134,35 +134,34 @@ syscalls.textSize.<value>
|
|||||||
+ `56x112`
|
+ `56x112`
|
||||||
+ `64x128`
|
+ `64x128`
|
||||||
|
|
||||||
### DrawText(text, xPos, yPos, textColor, [textScale](#text-sizes), textLen, backgroundColor, [encoding](#text-encoding))
|
### `DrawText(text, xPos, yPos, textColor, textScale, textLen, backgroundColor, encoding)`
|
||||||
|
|
||||||
### DrawTextFixSize(text, xPos, yPos, textColor, [textScale](#text-sizes), textLen, backgroundColor, [encoding](#text-encoding))
|
### `DrawTextFixSize(text, xPos, yPos, textColor, textSize, textLen, backgroundColor, encoding)`
|
||||||
|
|
||||||
Draw text.
|
Draw text.
|
||||||
|
|
||||||
textSize, textLen, backgroundColor, encoding are optional.
|
textSize, textLen, backgroundColor, encoding are optional.
|
||||||
|
|
||||||
### DrawLine(x1, y1, x2, y2)
|
### `DrawLine(x1, y1, x2, y2)`
|
||||||
|
|
||||||
### DrawRectangle(x, y, width, height, color)
|
### `DrawRectangle(x, y, widht, height, color)`
|
||||||
|
|
||||||
### ReadPoint(x, y)
|
### `ReadPoint(x, y)`
|
||||||
|
|
||||||
return color
|
return color
|
||||||
|
|
||||||
## Buttons
|
## Buttons
|
||||||
|
|
||||||
### DefineButton(x, y, width, height, id, color)
|
### `DefineButton(x, y, widht, height, id, color)`
|
||||||
|
|
||||||
### DeleteButton(id)
|
### `DeleteButton(id)`
|
||||||
|
|
||||||
### GetButton()
|
### `GetButton()`
|
||||||
|
|
||||||
return pressed button or `nil`
|
return pressed button or `nil`
|
||||||
|
|
||||||
### SetButtonStyle([style](#button-styles))
|
### `SetButtonStyle(style)`
|
||||||
|
|
||||||
Set buttons style
|
|
||||||
|
|
||||||
### buttons
|
### buttons
|
||||||
|
|
||||||
@@ -175,23 +174,20 @@ syscalls.buttons.<Value>
|
|||||||
+ `close`
|
+ `close`
|
||||||
+ `minimization`
|
+ `minimization`
|
||||||
|
|
||||||
### Button styles
|
### ButtonStyles
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
syscalls.buttonStyle.<Value>
|
syscalls.buttonStyle.<Value>
|
||||||
```
|
```
|
||||||
|
|
||||||
+ `Flat`
|
|
||||||
+ `Volume`
|
|
||||||
|
|
||||||
## Keyboard
|
## Keyboard
|
||||||
|
|
||||||
### GetKey()
|
### `GetKey()`
|
||||||
|
|
||||||
return:
|
return:
|
||||||
+ `nil` if buffer empty
|
+ nil if buffer empty
|
||||||
+ if hotkey return second number
|
+ if hotkey return second number
|
||||||
+ if key pressed and key input mode is ascii return string(1 char), else return [scancode](#scancodes)
|
+ if key pressed and key input mode is ascii return string(1 char), else return scancode
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
@@ -203,15 +199,15 @@ if key then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if hotkey then
|
if hotkey then
|
||||||
print("hotkey pressed")
|
print(hotkey pressed)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### SetKeyInputMode(mode)
|
### `SetKeyInputMode(mode)`
|
||||||
|
|
||||||
by default is `ASCII`
|
by default is `ASCII`
|
||||||
|
|
||||||
### GetKeyInputMode()
|
### `GetKeyInputMode()`
|
||||||
|
|
||||||
return key input mode.
|
return key input mode.
|
||||||
|
|
||||||
@@ -314,18 +310,17 @@ syscalls.SystemColors.new(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### GetSystemColors()
|
### `GetSystemColors()`
|
||||||
|
|
||||||
return [SystemColors](#systemcolors-type)
|
return SystemColors
|
||||||
|
|
||||||
### SetSystemColors([SystemColors](#systemcolors-type))
|
### `SetSystemColors(SystemColors)`
|
||||||
|
|
||||||
## Threads
|
## Threads
|
||||||
|
|
||||||
### ThreadInfo(pid)
|
### `ThreadInfo(pid)`
|
||||||
|
|
||||||
return table:
|
return table:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
name: string,
|
name: string,
|
||||||
@@ -344,7 +339,7 @@ return table:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### KillBySlot(slot)
|
### `KillBySlot(slot)`
|
||||||
|
|
||||||
### Slot states
|
### Slot states
|
||||||
|
|
||||||
@@ -362,9 +357,7 @@ syscalls.slotState.<Value>
|
|||||||
|
|
||||||
## Sockets
|
## Sockets
|
||||||
|
|
||||||
### OpenSocket([domain](#socket-types), [type](#address-families), [protocol](#ip-protocols))
|
### `OpenSocket(domain, type, protocol)`
|
||||||
|
|
||||||
return socket
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local socket, err = syscalls.OpenSocket(
|
local socket, err = syscalls.OpenSocket(
|
||||||
@@ -380,9 +373,9 @@ else
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### CloseSocket(socket)
|
### `CloseSocket(socket)`
|
||||||
|
|
||||||
### PairSocket()
|
### `PairSocket()`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local first, second = PairSocket()
|
local first, second = PairSocket()
|
||||||
@@ -394,19 +387,19 @@ else
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### Bind(socket, address)
|
### `Bind(socket, address)`
|
||||||
|
|
||||||
### Listen(socket, backlog)
|
### `Listen(socket, backlog)`
|
||||||
|
|
||||||
### Connect(socket, address)
|
### `Connect(socket, address)`
|
||||||
|
|
||||||
### Accept(socket, , flags)
|
### `Accept(socket, , flags)`
|
||||||
|
|
||||||
### Receive(socket, , flags)
|
### `Receive(socket, , flags)`
|
||||||
|
|
||||||
### SetSocketOption(socket, [opt](#socket-options))
|
### `SetSocketOption(socket, opt)`
|
||||||
|
|
||||||
### GetSocketOption(socket, [opt](#socket-options))
|
### `GetSocketOption(socket, opt)`
|
||||||
|
|
||||||
### Socket types
|
### Socket types
|
||||||
|
|
||||||
@@ -475,116 +468,53 @@ syscalls.SO.<Value>
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### DebugPutc(char)
|
### `DebugPutc(char)`
|
||||||
|
|
||||||
Put char to debug board
|
Put char to debug board
|
||||||
|
|
||||||
### DebugPuts(text)
|
### `DebugPuts(text)`
|
||||||
|
|
||||||
Put string to debug board
|
Put string to debug board
|
||||||
|
|
||||||
### GetRegisters(pid)
|
### `GetRegisters(pid)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
return registers table
|
return registers table
|
||||||
|
|
||||||
### SetRegisters(pid, [registers](#registers-type))
|
### `SetRegisters(pid, registers)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
### Disconnect(pid)
|
### `Disconnect(pid)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
If the process was suspended, it resumes execution.
|
If the process was suspended, it resumes execution.
|
||||||
|
|
||||||
### Stop(pid)
|
### `Stop(pid)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
### Continue(pid)
|
### `Continue(pid)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
### ReadFromMem(pid, bytes, pointer, buffer)
|
### `ReadFromMem(pid, bytes, pointer, buffer)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
return or `nil`
|
return or `nil`
|
||||||
|
|
||||||
### WriteToMem(pid, bytes, pointer, buffer)
|
### `WriteToMem(pid, bytes, pointer, buffer)`
|
||||||
|
|
||||||
The process must be loaded for debugging (as stated in the general description).
|
The process must be loaded for debugging (as stated in the general description).
|
||||||
|
|
||||||
return or `nil`
|
return or `nil`
|
||||||
|
|
||||||
### Done(pid)
|
### `Done(pid)`
|
||||||
|
|
||||||
### DefineBreakpoint(pid, index, condition, len)
|
### `DefineBreakpoint(pid, index, condition, len)`
|
||||||
|
|
||||||
### UndefBreakpoint(pid, index, condition, len)
|
### `UndefBreakpoint(pid, index, condition, len)`
|
||||||
|
|
||||||
## IPC
|
|
||||||
|
|
||||||
### DefineIPCBuffer(size)
|
|
||||||
|
|
||||||
Define buffer for IPC receive
|
|
||||||
|
|
||||||
Return [buffer](#ipc_buffer) type
|
|
||||||
|
|
||||||
### SendIPCMessage(pid, [message](#ipc_msg))
|
|
||||||
|
|
||||||
Send message to process by pid
|
|
||||||
|
|
||||||
return [Error code](#ipc-error-codes)
|
|
||||||
|
|
||||||
### IPC Error codes
|
|
||||||
|
|
||||||
```lua
|
|
||||||
syscalls.IPCError.<Value>
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `Ok`
|
|
||||||
+ `BufferLocked`
|
|
||||||
+ `BufferNotDefined`
|
|
||||||
+ `BufferOverflow`
|
|
||||||
+ `PIDNotExist`
|
|
||||||
|
|
||||||
### IPC_buffer
|
|
||||||
|
|
||||||
```lua
|
|
||||||
{
|
|
||||||
used: number,
|
|
||||||
lock: boolean,
|
|
||||||
Lock: (self: IPC_buffer) -> nil
|
|
||||||
Unlock: (self: IPC_buffer) -> nil
|
|
||||||
GetMessage: (self: IPC_buffer, i: number) -> IPC_msg
|
|
||||||
GetLastMessage: (self: IPC_buffer) -> IPC_msg
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Lock(self)
|
|
||||||
|
|
||||||
Lock buffer
|
|
||||||
|
|
||||||
#### Unlock(self)
|
|
||||||
|
|
||||||
Unlock buffer
|
|
||||||
|
|
||||||
#### GetMessage(self, i)
|
|
||||||
|
|
||||||
return [message](#ipc_msg) that were send by number i
|
|
||||||
|
|
||||||
#### GetLastMessage(self)
|
|
||||||
|
|
||||||
return last sended [message](#ipc_msg)
|
|
||||||
|
|
||||||
### IPC_msg
|
|
||||||
|
|
||||||
```lua
|
|
||||||
{
|
|
||||||
pid: number,
|
|
||||||
size: number
|
|
||||||
}
|
|
||||||
```
|
|
@@ -33,7 +33,7 @@ int syscalls_indexARPEntry(lua_State* L)
|
|||||||
else if (strcmp(index, "MAC") == 0)
|
else if (strcmp(index, "MAC") == 0)
|
||||||
{
|
{
|
||||||
char str[7];
|
char str[7];
|
||||||
memcpy(str, &entry->MAC, 6);
|
memset(str, entry->MAC, 6);
|
||||||
str[6] = '\n';
|
str[6] = '\n';
|
||||||
lua_pushstring(L, str);
|
lua_pushstring(L, str);
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ int syscalls_newindexARPEntry(lua_State* L)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
luaL_error(L, "wrong index: %s", index);
|
_ksys_debug_puts("err\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
struct ARP_entry
|
struct ARP_entry
|
||||||
{
|
{
|
||||||
uint32_t IP;
|
uint32_t IP;
|
||||||
uint8_t MAC[6];
|
char MAC[6];
|
||||||
uint16_t Status;
|
uint16_t Status;
|
||||||
uint16_t TTL;
|
uint16_t TTL;
|
||||||
};
|
};
|
||||||
|
@@ -1,244 +0,0 @@
|
|||||||
#include "IPC_buffer.h"
|
|
||||||
#include "IPC_msg.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "../debug.h"
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int syscalls_indexIPC_buffer(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* r = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
const char* index = luaL_checkstring(L, 2);
|
|
||||||
|
|
||||||
if (strcmp(index, "used") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->used);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "lock") == 0)
|
|
||||||
{
|
|
||||||
lua_pushboolean(L, r->lock);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "size") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->size);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_newindexIPC_buffer(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* r = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
const char* index = luaL_checkstring(L, 2);
|
|
||||||
int val = luaL_checkinteger(L, 3);
|
|
||||||
|
|
||||||
if (strcmp(index, "used") == 0)
|
|
||||||
{
|
|
||||||
r->used = val;
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "lock") == 0)
|
|
||||||
{
|
|
||||||
r->lock = val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
luaL_error(L, "wrong index: %s", index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool compare_ipc_buffer(ksys_ipc_buffer* a, ksys_ipc_buffer* b)
|
|
||||||
{ // блять че за высер...
|
|
||||||
if (a == b)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (a->used == b->used)
|
|
||||||
{
|
|
||||||
return memcmp(
|
|
||||||
a + (2 * sizeof(unsigned)),
|
|
||||||
b + (2 * sizeof(unsigned)),
|
|
||||||
a->used
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else // длина сообщений не совпадает, занчитт они зразу не могут быть равны
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_eqIPC_buffer(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushboolean(
|
|
||||||
L,
|
|
||||||
compare_ipc_buffer(
|
|
||||||
luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name),
|
|
||||||
luaL_checkudata(L, 2, syscalls_IPC_buffer_metatable_name)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_buffer_lock(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* buffer = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
|
|
||||||
buffer->lock = 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_buffer_unlock(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* buffer = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
|
|
||||||
buffer->lock = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Получить сообщение под номером
|
|
||||||
* @param buffer
|
|
||||||
* @param i
|
|
||||||
* @return указатель на сообщение, если такого сообщения ещё нет, то возвращает 0
|
|
||||||
*/
|
|
||||||
static ksys_ipc_msg* IPC_buffer_get_message(ksys_ipc_buffer* buffer, int i)
|
|
||||||
{
|
|
||||||
ksys_ipc_msg* j = (ksys_ipc_msg*)(buffer + 8);
|
|
||||||
unsigned diff = 0;
|
|
||||||
|
|
||||||
for (int k = 0; k < i; k++)
|
|
||||||
{
|
|
||||||
diff += j->datalen + 8; // прибавление длинны сообщения и заголовка
|
|
||||||
j += diff;
|
|
||||||
|
|
||||||
if (diff >= buffer->used)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ksys_ipc_msg* IPC_buffer_get_last_message(ksys_ipc_buffer* buffer)
|
|
||||||
{
|
|
||||||
ksys_ipc_msg* j = (ksys_ipc_msg*)(buffer + 8);
|
|
||||||
unsigned diff = 0;
|
|
||||||
|
|
||||||
while (diff < buffer->used)
|
|
||||||
{
|
|
||||||
j += diff;
|
|
||||||
diff += j->datalen + 8; // прибавление длинны сообщения и заголовка
|
|
||||||
}
|
|
||||||
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_buffer_get_message(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* buffer = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
unsigned i = luaL_checkinteger(L, 2);
|
|
||||||
|
|
||||||
ksys_ipc_msg* msg = IPC_buffer_get_message(IPC_buffer_to_ksys_ipc_buffer(buffer), i);
|
|
||||||
|
|
||||||
if (msg != 0)
|
|
||||||
{
|
|
||||||
lua_pushlightuserdata(L, msg);
|
|
||||||
luaL_setmetatable(L, syscalls_IPC_msg_metatable_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_buffer_get_last_message(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* buffer = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
|
|
||||||
ksys_ipc_msg* msg = IPC_buffer_get_last_message(IPC_buffer_to_ksys_ipc_buffer(buffer));
|
|
||||||
|
|
||||||
if ((unsigned)msg != (unsigned)buffer)
|
|
||||||
{
|
|
||||||
lua_pushlightuserdata(L, msg);
|
|
||||||
luaL_setmetatable(L, syscalls_IPC_msg_metatable_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_buffer_reset(lua_State* L)
|
|
||||||
{
|
|
||||||
struct IPC_buffer* buffer = luaL_checkudata(L, 1, syscalls_IPC_buffer_metatable_name);
|
|
||||||
|
|
||||||
buffer->used = 0;
|
|
||||||
memset(&buffer->data, 0, buffer->size);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg syscalls_IPC_buffer_m[] = {
|
|
||||||
{"__newindex", syscalls_newindexIPC_buffer},
|
|
||||||
{"__eq", syscalls_eqIPC_buffer},
|
|
||||||
{"__index", syscalls_indexIPC_buffer},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPC_buffer* syscalls_pushIPC_buffer(lua_State* L, size_t size)
|
|
||||||
{
|
|
||||||
DEBUG_LINE("push " syscalls_IPC_buffer_name " entry");
|
|
||||||
|
|
||||||
struct IPC_buffer* buffer = lua_newuserdata(L, sizeof(struct IPC_buffer) + size);
|
|
||||||
|
|
||||||
luaL_setmetatable(L, syscalls_IPC_buffer_metatable_name);
|
|
||||||
|
|
||||||
buffer->used = 0;
|
|
||||||
buffer->size = size;
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_newIPC_buffer(lua_State* L)
|
|
||||||
{
|
|
||||||
size_t size = luaL_checkinteger(L, 1);
|
|
||||||
struct IPC_buffer* buffer = syscalls_pushIPC_buffer(L, size);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg syscalls_IPC_buffer_lib[] = {
|
|
||||||
{"new", syscalls_newIPC_buffer},
|
|
||||||
{"Lock", syscalls_IPC_buffer_lock},
|
|
||||||
{"Unlock", syscalls_IPC_buffer_unlock},
|
|
||||||
{"GetMessage", syscalls_IPC_buffer_get_message},
|
|
||||||
{"GetLastMessage", syscalls_IPC_buffer_get_last_message},
|
|
||||||
{"Reset", syscalls_IPC_buffer_reset},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
void syscalls_register_IPC_buffer(lua_State* L)
|
|
||||||
{
|
|
||||||
DEBUG_LINE("register " syscalls_IPC_buffer_name " entry");
|
|
||||||
|
|
||||||
luaL_newlib(L, syscalls_IPC_buffer_lib);
|
|
||||||
|
|
||||||
lua_setfield(L, -2, syscalls_IPC_buffer_name);
|
|
||||||
|
|
||||||
|
|
||||||
luaL_newmetatable(L, syscalls_IPC_buffer_metatable_name);
|
|
||||||
luaL_setfuncs(L, syscalls_IPC_buffer_m, 0);
|
|
||||||
|
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
@@ -1,27 +0,0 @@
|
|||||||
#ifndef __IPC_BUFFER_H__
|
|
||||||
#define __IPC_BUFFER_H__
|
|
||||||
|
|
||||||
#include "../syscalls.h"
|
|
||||||
|
|
||||||
struct IPC_buffer
|
|
||||||
{
|
|
||||||
size_t size;
|
|
||||||
ksys_ipc_buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline ksys_ipc_buffer* IPC_buffer_to_ksys_ipc_buffer(struct IPC_buffer* buffer)
|
|
||||||
{
|
|
||||||
return (ksys_ipc_buffer*)(buffer + (sizeof(struct IPC_buffer) - sizeof(ksys_ipc_buffer)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define syscalls_IPC_buffer_metatable_name "syscalls IPC_buffer metatable"
|
|
||||||
#define syscalls_IPC_buffer_name "IPC_buffer"
|
|
||||||
|
|
||||||
struct IPC_buffer* syscalls_pushIPC_buffer(lua_State* L, size_t dataLen);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register SystemColors lib
|
|
||||||
*/
|
|
||||||
void syscalls_register_IPC_buffer(lua_State* L);
|
|
||||||
|
|
||||||
#endif // __IPC_BUFFER_H__
|
|
@@ -1,225 +0,0 @@
|
|||||||
#include "IPC_msg.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "../debug.h"
|
|
||||||
#include <sys/ksys.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
static int syscalls_indexIPC_msg(lua_State* L)
|
|
||||||
{
|
|
||||||
ksys_ipc_msg* r = luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name);
|
|
||||||
const char* index = luaL_checkstring(L, 2);
|
|
||||||
|
|
||||||
if (strcmp(index, "size") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->datalen);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "pid") == 0)
|
|
||||||
{
|
|
||||||
lua_pushboolean(L, r->pid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_newindexIPC_msg(lua_State* L)
|
|
||||||
{
|
|
||||||
ksys_ipc_msg* r = luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name);
|
|
||||||
lua_Integer index_i = lua_isnumber(L, 2);
|
|
||||||
uint32_t val = luaL_checkinteger(L, 3);
|
|
||||||
|
|
||||||
if (!index_i)
|
|
||||||
{
|
|
||||||
const char* index = luaL_checkstring(L, 2);
|
|
||||||
|
|
||||||
if (strcmp(index, "size") == 0)
|
|
||||||
{
|
|
||||||
r->datalen = val;
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "pid") == 0)
|
|
||||||
{
|
|
||||||
r->pid = val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
luaL_error(L, "wrong index: %s", index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (index_i < (unsigned)r->data)
|
|
||||||
{
|
|
||||||
((lua_Integer*)r + (2 * sizeof(unsigned)))[index_i] = val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
luaL_error(L, "out of range. size: %d index: %d", r->datalen, index_i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool compare_ipc_msg(ksys_ipc_msg* a, ksys_ipc_msg* b)
|
|
||||||
{
|
|
||||||
if (a->datalen == b->datalen)
|
|
||||||
{
|
|
||||||
return memcmp(
|
|
||||||
a + (2 * sizeof(unsigned)),
|
|
||||||
b + (2 * sizeof(unsigned)),
|
|
||||||
a->datalen
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else // длина сообщений не совпадает, занчитт они зразу не могут быть равны
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_eqIPC_msg(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushboolean(
|
|
||||||
L,
|
|
||||||
compare_ipc_msg(
|
|
||||||
luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name),
|
|
||||||
luaL_checkudata(L, 2, syscalls_IPC_msg_metatable_name)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_msg_ReadByte(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
((uint8_t*)luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name) + (2 * sizeof(unsigned)))[luaL_checkinteger(L, 2)]
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_msg_ReadWord(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
((uint16_t*)luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name) + (2 * sizeof(unsigned)))[luaL_checkinteger(L, 2)]
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_msg_ReadDword(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
((uint32_t*)luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name) + (2 * sizeof(unsigned)))[luaL_checkinteger(L, 2)]
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_msg_ReadInteger(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
((lua_Integer*)luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name) + (2 * sizeof(unsigned)))[luaL_checkinteger(L, 2)]
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_IPC_msg_tostring(lua_State* L)
|
|
||||||
{
|
|
||||||
ksys_ipc_msg* msg = luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name);
|
|
||||||
|
|
||||||
char* buff = malloc(msg->datalen + 24 + 1);
|
|
||||||
|
|
||||||
sprintf(buff, "pid: %d, len: %d, text: ", msg->pid, msg->datalen);
|
|
||||||
|
|
||||||
memcpy(buff + 24, &msg->data, msg->datalen);
|
|
||||||
|
|
||||||
buff[msg->datalen + 24] = '\0';
|
|
||||||
|
|
||||||
lua_pushstring(L, buff);
|
|
||||||
|
|
||||||
free(buff);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg syscalls_IPC_msg_m[] = {
|
|
||||||
{"__newindex", syscalls_newindexIPC_msg},
|
|
||||||
{"__eq", syscalls_eqIPC_msg},
|
|
||||||
{"__tostring", syscalls_IPC_msg_tostring},
|
|
||||||
{"__index", syscalls_indexIPC_msg},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
ksys_ipc_msg* syscalls_pushIPC_msg(lua_State* L, size_t dataLen)
|
|
||||||
{
|
|
||||||
DEBUG_LINE("push IPC_msg entry");
|
|
||||||
|
|
||||||
ksys_ipc_msg* msg = lua_newuserdata(L, sizeof(ksys_ipc_msg) + dataLen);
|
|
||||||
|
|
||||||
luaL_setmetatable(L, syscalls_IPC_msg_metatable_name);
|
|
||||||
|
|
||||||
msg->datalen = dataLen;
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_newIPC_msg(lua_State* L)
|
|
||||||
{
|
|
||||||
size_t dataLen = luaL_checkinteger(L, 1);
|
|
||||||
unsigned pid = luaL_checkinteger(L, 2);
|
|
||||||
ksys_ipc_msg* msg = syscalls_pushIPC_msg(L, dataLen);
|
|
||||||
|
|
||||||
msg->pid = pid;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_fromStringIPC_msg(lua_State* L)
|
|
||||||
{
|
|
||||||
const char* text = luaL_checkstring(L, 1);
|
|
||||||
unsigned pid = luaL_checkinteger(L, 2);
|
|
||||||
size_t len = strlen(text);
|
|
||||||
|
|
||||||
ksys_ipc_msg* r = syscalls_pushIPC_msg(L, len);
|
|
||||||
r->pid = pid;
|
|
||||||
|
|
||||||
memcpy(&r->data, text, len);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const luaL_Reg syscalls_IPC_msg_lib[] = {
|
|
||||||
{"new", syscalls_newIPC_msg},
|
|
||||||
{"fromString", syscalls_fromStringIPC_msg},
|
|
||||||
{"ReadByte", syscalls_IPC_msg_ReadByte},
|
|
||||||
{"ReadWord", syscalls_IPC_msg_ReadWord},
|
|
||||||
{"ReadDword", syscalls_IPC_msg_ReadDword},
|
|
||||||
{"ReadInteger", syscalls_IPC_msg_ReadInteger},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
void syscalls_register_IPC_msg(lua_State* L)
|
|
||||||
{
|
|
||||||
DEBUG_LINE("register IPC_msg entry");
|
|
||||||
|
|
||||||
luaL_newlib(L, syscalls_IPC_msg_lib);
|
|
||||||
|
|
||||||
lua_setfield(L, -2, syscalls_IPC_msg_name);
|
|
||||||
|
|
||||||
|
|
||||||
luaL_newmetatable(L, syscalls_IPC_msg_metatable_name);
|
|
||||||
luaL_setfuncs(L, syscalls_IPC_msg_m, 0);
|
|
||||||
|
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
#ifndef _SYSCALLS_IPC_MSG_H_
|
|
||||||
#define _SYSCALLS_IPC_MSG_H_
|
|
||||||
|
|
||||||
#include "../syscalls.h"
|
|
||||||
#include <sys/ksys.h>
|
|
||||||
|
|
||||||
#define syscalls_IPC_msg_metatable_name "syscalls IPC_msg metatable"
|
|
||||||
#define syscalls_IPC_msg_name "IPC_msg"
|
|
||||||
|
|
||||||
ksys_ipc_msg* syscalls_pushIPC_msg(lua_State* L, size_t dataLen);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register SystemColors lib
|
|
||||||
*/
|
|
||||||
void syscalls_register_IPC_msg(lua_State* L);
|
|
||||||
|
|
||||||
#endif // _SYSCALLS_IPC_MSG_H_
|
|
@@ -1,51 +0,0 @@
|
|||||||
#include "ipc.h"
|
|
||||||
#include "IPC_msg.h"
|
|
||||||
#include "IPC_buffer.h"
|
|
||||||
#include <sys/ksys.h>
|
|
||||||
|
|
||||||
inline static void define_ipc(ksys_ipc_buffer* buffer, size_t bufLen)
|
|
||||||
{
|
|
||||||
asm_inline(
|
|
||||||
"int $0x40"
|
|
||||||
::"a"(60), "b"(1), "c"(buffer), "d"(bufLen)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static enum SendIPCErrors send_ipc(int pid, void* msg, size_t len)
|
|
||||||
{
|
|
||||||
enum SendIPCErrors ret;
|
|
||||||
|
|
||||||
asm_inline(
|
|
||||||
"int $0x40"
|
|
||||||
: "=a"(ret)
|
|
||||||
: "a"(60), "b"(2), "c"(pid), "d"(msg), "S"(len)
|
|
||||||
);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_DefineIPCBuffer(lua_State* L)
|
|
||||||
{
|
|
||||||
uint32_t len = luaL_checkinteger(L, 1);
|
|
||||||
struct IPC_buffer* buffer = syscalls_pushIPC_buffer(L, len);
|
|
||||||
|
|
||||||
define_ipc(IPC_buffer_to_ksys_ipc_buffer(buffer), len);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_SendIPCMessage(lua_State* L)
|
|
||||||
{
|
|
||||||
ksys_ipc_msg* msg = luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name);
|
|
||||||
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
send_ipc(
|
|
||||||
msg->pid,
|
|
||||||
msg + 8,
|
|
||||||
msg->datalen
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
#ifndef __IPC_H__
|
|
||||||
#define __IPC_H__
|
|
||||||
|
|
||||||
#include "../syscalls.h"
|
|
||||||
|
|
||||||
enum SendIPCErrors
|
|
||||||
{
|
|
||||||
Ok = 0,
|
|
||||||
BufferNotDefined = 1,
|
|
||||||
BufferLocked = 2,
|
|
||||||
BufferOverflow = 3,
|
|
||||||
PIDNotExist = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
int syscalls_DefineIPCBuffer(lua_State* L);
|
|
||||||
int syscalls_SendIPCMessage(lua_State* L);
|
|
||||||
|
|
||||||
|
|
||||||
inline void syscalls_push_IPC_errors(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_createtable(L, 0, 5);
|
|
||||||
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, Ok, "Ok");
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, BufferLocked, "BufferLocked");
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, BufferNotDefined, "BufferNotDefined");
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, BufferOverflow, "BufferOverflow");
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, PIDNotExist, "PIDNotExist");
|
|
||||||
|
|
||||||
lua_setfield(L, -2, "IPCError");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __IPC_H__
|
|
@@ -1,129 +0,0 @@
|
|||||||
#include "background.h"
|
|
||||||
|
|
||||||
static ksys_pos_t sizes;
|
|
||||||
|
|
||||||
int syscalls_backgroundGetSize(lua_State* L)
|
|
||||||
{
|
|
||||||
asm_inline(
|
|
||||||
"int $0x40"
|
|
||||||
:"=a"(sizes)
|
|
||||||
: "a"(39), "b"(1)
|
|
||||||
);
|
|
||||||
|
|
||||||
syscalls_push_pos_t(L, sizes);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundSetSize(lua_State* L)
|
|
||||||
{
|
|
||||||
sizes = syscalls_check_pos_t(L, 1);
|
|
||||||
|
|
||||||
_ksys_bg_set_size(
|
|
||||||
sizes.x,
|
|
||||||
sizes.y
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundPutPixel(lua_State* L)
|
|
||||||
{
|
|
||||||
uint32_t x = luaL_checkinteger(L, 1);
|
|
||||||
uint32_t y = luaL_checkinteger(L, 2);
|
|
||||||
|
|
||||||
_ksys_bg_put_pixel(
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
sizes.x,
|
|
||||||
luaL_checkinteger(L, 3)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ksys_color_t background_read_point(ksys_pos_t pos, uint16_t w)
|
|
||||||
{
|
|
||||||
ksys_color_t color;
|
|
||||||
|
|
||||||
asm_inline(
|
|
||||||
"int $0x40"
|
|
||||||
:"=a"(color)
|
|
||||||
: "a"(39), "b"(2), "c"((pos.x + pos.y * w) * 3)
|
|
||||||
);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundReadPoint(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
background_read_point(syscalls_check_pos_t(L, 1), sizes.x)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundRedraw(lua_State* L)
|
|
||||||
{
|
|
||||||
_ksys_bg_redraw();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundSetDrawMode(lua_State* L)
|
|
||||||
{
|
|
||||||
_ksys_bg_set_mode(luaL_checkinteger(L, 1));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundGetDrawMode(lua_State* L)
|
|
||||||
{
|
|
||||||
enum KSYS_BG_MODES mode;
|
|
||||||
|
|
||||||
asm_inline(
|
|
||||||
"int $0x40"
|
|
||||||
:"=a"(mode)
|
|
||||||
: "a"(39), "b"(4)
|
|
||||||
);
|
|
||||||
|
|
||||||
lua_pushinteger(L, mode);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundOpenMap(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushinteger(
|
|
||||||
L,
|
|
||||||
_ksys_bg_get_map()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundCloseMap(lua_State* L)
|
|
||||||
{
|
|
||||||
if (_ksys_bg_close_map(luaL_checkinteger(L, 1)) == 0)
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lua_pushboolean(L, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int syscalls_backgroundRedrawArea(lua_State* L)
|
|
||||||
{
|
|
||||||
_ksys_bg_redraw_bar(
|
|
||||||
syscalls_check_pos_t(L, 1),
|
|
||||||
syscalls_check_pos_t(L, 3)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -1,33 +0,0 @@
|
|||||||
#ifndef __BACKGROUND_H__
|
|
||||||
#define __BACKGROUND_H__
|
|
||||||
|
|
||||||
#include "../syscalls.h"
|
|
||||||
|
|
||||||
int syscalls_backgroundSetSize(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundPutPixel(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundRedraw(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundSetDrawMode(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundGetDrawMode(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundOpenMap(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundCloseMap(lua_State* L);
|
|
||||||
|
|
||||||
int syscalls_backgroundRedrawArea(lua_State* L);
|
|
||||||
|
|
||||||
inline syscalls_push_BackgroundDrawMode(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_createtable(L, 0, 2);
|
|
||||||
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, KSYS_BG_MODE_PAVE, "Pave");
|
|
||||||
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, KSYS_BG_MODE_STRETCH, "Stretch");
|
|
||||||
|
|
||||||
lua_setfield(L, -2, "DrawMode");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __BACKGROUND_H__
|
|
@@ -20,6 +20,6 @@ struct registers
|
|||||||
|
|
||||||
struct registers* syscalls_pushRegisters(lua_State* L);
|
struct registers* syscalls_pushRegisters(lua_State* L);
|
||||||
|
|
||||||
void syscalls_register_registers(lua_State* L);
|
inline void syscalls_register_registers(lua_State* L);
|
||||||
|
|
||||||
#endif // __REGISTERS_H__
|
#endif // __REGISTERS_H__
|
||||||
|
@@ -9,18 +9,13 @@
|
|||||||
|
|
||||||
#include "syscalls.h"
|
#include "syscalls.h"
|
||||||
#include "scancodes.h"
|
#include "scancodes.h"
|
||||||
|
|
||||||
#include "ARP_entry.h"
|
#include "ARP_entry.h"
|
||||||
|
|
||||||
#include "systemColors.h"
|
#include "systemColors.h"
|
||||||
#include "sockets/socket_lua.h"
|
#include "sockets/socket_lua.h"
|
||||||
#include "debug/debug.h"
|
#include "debug/debug.h"
|
||||||
#include "graphic.h"
|
#include "graphic.h"
|
||||||
#include "IPC/ipc.h"
|
|
||||||
#include "IPC/IPC_msg.h"
|
|
||||||
#include "IPC/IPC_buffer.h"
|
|
||||||
#include "version/coreversion.h"
|
|
||||||
#include "version/library_version.h"
|
|
||||||
#include "background/background.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Режим ввода с клавиатуры
|
Режим ввода с клавиатуры
|
||||||
@@ -111,7 +106,7 @@ static int syscalls_SetSkin(lua_State* L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int syscalls_GetSkinTitleArea(lua_State* L)
|
static int syscalls_GetSkinTilteArea(lua_State* L)
|
||||||
{
|
{
|
||||||
ksys_pos_t leftRight, topBottom;
|
ksys_pos_t leftRight, topBottom;
|
||||||
|
|
||||||
@@ -253,7 +248,7 @@ static int syscalls_threadInfo(lua_State* L)
|
|||||||
{
|
{
|
||||||
ksys_thread_t t;
|
ksys_thread_t t;
|
||||||
|
|
||||||
_ksys_thread_info(&t, luaL_optinteger(L, 1, -1));
|
_ksys_thread_info(&t, luaL_checkinteger(L, 1));
|
||||||
|
|
||||||
lua_createtable(L, 0, 13);
|
lua_createtable(L, 0, 13);
|
||||||
|
|
||||||
@@ -412,6 +407,37 @@ static int syscalls_getButton(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Backgound
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int syscalls_backgroundSetSize(lua_State* L)
|
||||||
|
{
|
||||||
|
_ksys_bg_set_size(
|
||||||
|
luaL_checkinteger(L, 1),
|
||||||
|
luaL_checkinteger(L, 2));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int syscalls_backgroundPutPixel(lua_State* L)
|
||||||
|
{
|
||||||
|
_ksys_bg_put_pixel(
|
||||||
|
luaL_checkinteger(L, 1),
|
||||||
|
luaL_checkinteger(L, 2),
|
||||||
|
luaL_checkinteger(L, 3),
|
||||||
|
luaL_checkinteger(L, 4));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int syscalls_backgroundRedraw(lua_State* L)
|
||||||
|
{
|
||||||
|
_ksys_bg_redraw();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int syscalls_getCPUClock(lua_State* L)
|
static int syscalls_getCPUClock(lua_State* L)
|
||||||
{
|
{
|
||||||
lua_pushinteger(L, _ksys_get_cpu_clock());
|
lua_pushinteger(L, _ksys_get_cpu_clock());
|
||||||
@@ -479,7 +505,7 @@ static int syscalls_getKey(lua_State* L)
|
|||||||
{
|
{
|
||||||
char s[2];
|
char s[2];
|
||||||
s[0] = a.code;
|
s[0] = a.code;
|
||||||
s[1] = '\0';
|
s[1] = '\n';
|
||||||
lua_pushstring(L, s);
|
lua_pushstring(L, s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1139,7 +1165,7 @@ typedef enum SYSCALLS_PROTOCOLS
|
|||||||
ARP = 5
|
ARP = 5
|
||||||
} SYSCALLS_PROTOCOLS;
|
} SYSCALLS_PROTOCOLS;
|
||||||
|
|
||||||
static inline int syscalls_ReadPacketSend(lua_State* L, SYSCALLS_PROTOCOLS protocol)
|
inline int syscalls_ReadPacketSend(lua_State* L, SYSCALLS_PROTOCOLS protocol)
|
||||||
{
|
{
|
||||||
uint32_t eax;
|
uint32_t eax;
|
||||||
uint8_t device = luaL_checkinteger(L, 1);
|
uint8_t device = luaL_checkinteger(L, 1);
|
||||||
@@ -1154,7 +1180,7 @@ static inline int syscalls_ReadPacketSend(lua_State* L, SYSCALLS_PROTOCOLS proto
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int syscalls_ReadPacketReceive(lua_State* L, SYSCALLS_PROTOCOLS protocol)
|
inline int syscalls_ReadPacketReceive(lua_State* L, SYSCALLS_PROTOCOLS protocol)
|
||||||
{
|
{
|
||||||
uint32_t eax;
|
uint32_t eax;
|
||||||
uint8_t device = luaL_checkinteger(L, 1);
|
uint8_t device = luaL_checkinteger(L, 1);
|
||||||
@@ -1468,7 +1494,7 @@ static const luaL_Reg syscallsLib[] = {
|
|||||||
{"SetWindowTitle", syscalls_setWindowTitle},
|
{"SetWindowTitle", syscalls_setWindowTitle},
|
||||||
{"GetSkinHeight", syscalls_getSkinHeight},
|
{"GetSkinHeight", syscalls_getSkinHeight},
|
||||||
{"SetSkin", syscalls_SetSkin},
|
{"SetSkin", syscalls_SetSkin},
|
||||||
{"GetSkinTitleArea", syscalls_GetSkinTitleArea},
|
{"GetSkinTitleArea", syscalls_GetSkinTilteArea},
|
||||||
/* Buttons funcs*/
|
/* Buttons funcs*/
|
||||||
{"DefineButton", syscalls_defineButton},
|
{"DefineButton", syscalls_defineButton},
|
||||||
{"DeleteButton", syscalls_deleteButton},
|
{"DeleteButton", syscalls_deleteButton},
|
||||||
@@ -1480,16 +1506,11 @@ static const luaL_Reg syscallsLib[] = {
|
|||||||
{"CheckEvent", syscalls_checkEvent},
|
{"CheckEvent", syscalls_checkEvent},
|
||||||
{"WaitEventTimeout", syscalls_waitEventTimeout},
|
{"WaitEventTimeout", syscalls_waitEventTimeout},
|
||||||
/* Background funcs */
|
/* Background funcs */
|
||||||
{ "BackgroundSetSize", syscalls_backgroundSetSize },
|
{"BackgroundSetSize", syscalls_backgroundSetSize},
|
||||||
{ "BackgroundPutPixel", syscalls_backgroundPutPixel },
|
{"BackgroundPutPixel", syscalls_backgroundPutPixel},
|
||||||
{ "BackgroundRedraw", syscalls_backgroundRedraw },
|
{"BackgroundRedraw", syscalls_backgroundRedraw},
|
||||||
{ "BackgroundSetDrawMode", syscalls_backgroundSetDrawMode },
|
|
||||||
{ "BackgroundGetDrawMode", syscalls_backgroundGetDrawMode },
|
|
||||||
{ "BackgroundOpenMap", syscalls_backgroundOpenMap },
|
|
||||||
{ "BackgroundCloseMap", syscalls_backgroundCloseMap },
|
|
||||||
{ "BackgroundRedrawArea", syscalls_backgroundRedrawArea },
|
|
||||||
/* system funcs */
|
/* system funcs */
|
||||||
{ "GetRamSize", syscalls_getRamSize },
|
{"GetRamSize", syscalls_getRamSize},
|
||||||
{"GetFreeRam", syscalls_getFreeRam},
|
{"GetFreeRam", syscalls_getFreeRam},
|
||||||
{"GetCPUClock", syscalls_getCPUClock},
|
{"GetCPUClock", syscalls_getCPUClock},
|
||||||
{"ShutdownPowerOff", syscalls_shutdownPowerOff},
|
{"ShutdownPowerOff", syscalls_shutdownPowerOff},
|
||||||
@@ -1607,9 +1628,6 @@ static const luaL_Reg syscallsLib[] = {
|
|||||||
{ "Done", syscalls_Done },
|
{ "Done", syscalls_Done },
|
||||||
{ "DefineBreakpoint", syscalls_DefineBreakpoint },
|
{ "DefineBreakpoint", syscalls_DefineBreakpoint },
|
||||||
{ "UndefBreakpoint", syscalls_UndefBreakpoint },
|
{ "UndefBreakpoint", syscalls_UndefBreakpoint },
|
||||||
/* IPC */
|
|
||||||
{ "DefineIPCBuffer", syscalls_DefineIPCBuffer },
|
|
||||||
{ "SendIPCMessage", syscalls_SendIPCMessage },
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1757,34 +1775,19 @@ LUALIB_API int luaopen_syscalls(lua_State* L)
|
|||||||
{
|
{
|
||||||
luaL_newlib(L, syscallsLib);
|
luaL_newlib(L, syscallsLib);
|
||||||
|
|
||||||
syscalls_push_library_version(L);
|
|
||||||
|
|
||||||
syscalls_push_events(L);
|
syscalls_push_events(L);
|
||||||
syscalls_push_slotStates(L);
|
syscalls_push_slotStates(L);
|
||||||
|
|
||||||
syscalls_register_scancodes(L);
|
syscalls_register_scancodes(L);
|
||||||
syscalls_push_hotkey_states(L);
|
syscalls_push_hotkey_states(L);
|
||||||
|
|
||||||
syscalls_push_buttonsStyle(L);
|
syscalls_push_buttonsStyle(L);
|
||||||
syscalls_push_windowStyles(L);
|
syscalls_push_windowStyles(L);
|
||||||
|
|
||||||
syscalls_push_buttons(L);
|
syscalls_push_buttons(L);
|
||||||
|
|
||||||
// net
|
|
||||||
syscalls_push_connectionStatus(L);
|
syscalls_push_connectionStatus(L);
|
||||||
syscalls_register_ARPEntry(L);
|
|
||||||
|
|
||||||
syscalls_push_graphic(L);
|
syscalls_push_graphic(L);
|
||||||
|
|
||||||
// Register IPC
|
syscalls_register_ARPEntry(L);
|
||||||
syscalls_register_IPC_msg(L);
|
|
||||||
syscalls_register_IPC_buffer(L);
|
|
||||||
syscalls_push_IPC_errors(L);
|
|
||||||
|
|
||||||
syscalls_register_SystemColors(L);
|
syscalls_register_SystemColors(L);
|
||||||
|
|
||||||
syscalls_register_Version(L);
|
|
||||||
|
|
||||||
_ksys_set_event_mask(7); // set default event mask
|
_ksys_set_event_mask(7); // set default event mask
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -4,9 +4,8 @@
|
|||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <sys/ksys.h>
|
|
||||||
|
|
||||||
static inline void syscalls_ReturnIntegerOrNil(LUA_INTEGER value, lua_State* L)
|
inline void syscalls_ReturnIntegerOrNil(LUA_INTEGER value, lua_State* L)
|
||||||
{
|
{
|
||||||
if (value == -1)
|
if (value == -1)
|
||||||
{
|
{
|
||||||
@@ -18,7 +17,7 @@ static inline void syscalls_ReturnIntegerOrNil(LUA_INTEGER value, lua_State* L)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void syscalls_ReturnIntegerValueOrNil(LUA_INTEGER cond, LUA_INTEGER value, lua_State* L)
|
inline void syscalls_ReturnIntegerValueOrNil(LUA_INTEGER cond, LUA_INTEGER value, lua_State* L)
|
||||||
{
|
{
|
||||||
if (cond == -1)
|
if (cond == -1)
|
||||||
{
|
{
|
||||||
@@ -30,7 +29,7 @@ static inline void syscalls_ReturnIntegerValueOrNil(LUA_INTEGER cond, LUA_INTEGE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void syscalls_ReturnTrueOrNil(LUA_INTEGER value, lua_State* L)
|
inline void syscalls_ReturnTrueOrNil(LUA_INTEGER value, lua_State* L)
|
||||||
{
|
{
|
||||||
if (value == -1)
|
if (value == -1)
|
||||||
{
|
{
|
||||||
@@ -42,7 +41,7 @@ static inline void syscalls_ReturnTrueOrNil(LUA_INTEGER value, lua_State* L)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void syscalls_ReturnStringOrNil(LUA_INTEGER cond, const char* value, lua_State* L)
|
inline void syscalls_ReturnStringOrNil(LUA_INTEGER cond, const char* value, lua_State* L)
|
||||||
{
|
{
|
||||||
if (cond == -1)
|
if (cond == -1)
|
||||||
{
|
{
|
||||||
@@ -58,23 +57,4 @@ static inline void syscalls_ReturnStringOrNil(LUA_INTEGER cond, const char* valu
|
|||||||
#define LUA_PUSH_STRING_FIELD(L, val, name) lua_pushstring(L, val); lua_setfield(L, -2, name);
|
#define LUA_PUSH_STRING_FIELD(L, val, name) lua_pushstring(L, val); lua_setfield(L, -2, name);
|
||||||
#define LUA_PUSH_NUMBER_FIELD(L, val, name) lua_pushnumber(L, val); lua_setfield(L, -2, name);
|
#define LUA_PUSH_NUMBER_FIELD(L, val, name) lua_pushnumber(L, val); lua_setfield(L, -2, name);
|
||||||
|
|
||||||
static inline ksys_pos_t syscalls_check_pos_t(lua_State* L, int index)
|
|
||||||
{
|
|
||||||
ksys_pos_t pos;
|
|
||||||
|
|
||||||
pos.x = luaL_checkinteger(L, index);
|
|
||||||
pos.y = luaL_checkinteger(L, index + 1);
|
|
||||||
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void syscalls_push_pos_t(lua_State* L, ksys_pos_t pos)
|
|
||||||
{
|
|
||||||
lua_createtable(L, 0, 2);
|
|
||||||
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, pos.x, "x");
|
|
||||||
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, pos.y, "y");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __SYSCALLS_H__
|
#endif // __SYSCALLS_H__
|
||||||
|
@@ -1,13 +0,0 @@
|
|||||||
#include "coreversion.h"
|
|
||||||
|
|
||||||
int syscalls_GetCoreVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
struct core_version* ver = syscalls_pushVersion(L);
|
|
||||||
|
|
||||||
asm_inline(
|
|
||||||
"int $0x40"
|
|
||||||
::"a"(18), "b"(13), "c"(ver)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
@@ -1,8 +0,0 @@
|
|||||||
#ifndef __CORE_VERSION_H__
|
|
||||||
#define __CORE_VERSION_H__
|
|
||||||
|
|
||||||
#include "version_type.h"
|
|
||||||
|
|
||||||
int syscalls_GetCoreVersion(lua_State *L);
|
|
||||||
|
|
||||||
#endif // __CORE_VERSION_H__
|
|
@@ -1,17 +0,0 @@
|
|||||||
#ifndef __LIBRARY_VERSION_H__
|
|
||||||
#define __LIBRARY_VERSION_H__
|
|
||||||
|
|
||||||
#include "../syscalls.h"
|
|
||||||
|
|
||||||
inline void syscalls_push_library_version(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_createtable(L, 0, 3);
|
|
||||||
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, SYSCALLS_VERSION_A, "a");
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, SYSCALLS_VERSION_B, "b");
|
|
||||||
LUA_PUSH_INTEGER_FIELD(L, SYSCALLS_VERSION_C, "c");
|
|
||||||
|
|
||||||
lua_setfield(L, -2, "version");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __LIBRARY_VERSION_H__
|
|
@@ -1,202 +0,0 @@
|
|||||||
#include "version_type.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "../debug.h"
|
|
||||||
|
|
||||||
static int syscalls_indexVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
struct core_version* r = luaL_checkudata(L, 1, syscalls_Version_metatable_name);
|
|
||||||
const char* index = luaL_checkstring(L, 2);
|
|
||||||
|
|
||||||
if (strcmp(index, "a") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->a);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "b") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->b);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "c") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->c);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "d") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->d);
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "rev") == 0)
|
|
||||||
{
|
|
||||||
lua_pushinteger(L, r->revision);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_newindexVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
struct core_version* r = luaL_checkudata(L, 1, syscalls_Version_metatable_name);
|
|
||||||
const char* index = luaL_checkstring(L, 2);
|
|
||||||
uint32_t val = luaL_checkinteger(L, 3);
|
|
||||||
|
|
||||||
if (strcmp(index, "a") == 0)
|
|
||||||
{
|
|
||||||
r->a = val;
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "b") == 0)
|
|
||||||
{
|
|
||||||
r->b = val;
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "c") == 0)
|
|
||||||
{
|
|
||||||
r->c = val;
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "d") == 0)
|
|
||||||
{
|
|
||||||
r->d = val;
|
|
||||||
}
|
|
||||||
else if (strcmp(index, "rev") == 0)
|
|
||||||
{
|
|
||||||
r->revision = val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
luaL_error(L, "wrong index: %s", index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_eqVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
lua_pushboolean(
|
|
||||||
L,
|
|
||||||
memcmp(
|
|
||||||
luaL_checkudata(L, 1, syscalls_Version_metatable_name),
|
|
||||||
luaL_checkudata(L, 2, syscalls_Version_metatable_name),
|
|
||||||
sizeof(struct core_version)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_ltVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
struct core_version* a = luaL_checkudata(L, 1, syscalls_Version_metatable_name);
|
|
||||||
struct core_version* b = luaL_checkudata(L, 2, syscalls_Version_metatable_name);
|
|
||||||
|
|
||||||
bool r;
|
|
||||||
|
|
||||||
if (a->a < b->a)
|
|
||||||
r = true;
|
|
||||||
else if (a->b < b->b)
|
|
||||||
r = true;
|
|
||||||
else if (a->c < b->c)
|
|
||||||
r = true;
|
|
||||||
else if (a->d < b->d)
|
|
||||||
r = true;
|
|
||||||
else if (a->revision < b->revision)
|
|
||||||
r = true;
|
|
||||||
else
|
|
||||||
r = false;
|
|
||||||
|
|
||||||
lua_pushboolean(L, r);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_leVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
struct core_version* a = luaL_checkudata(L, 1, syscalls_Version_metatable_name);
|
|
||||||
struct core_version* b = luaL_checkudata(L, 2, syscalls_Version_metatable_name);
|
|
||||||
|
|
||||||
bool r;
|
|
||||||
|
|
||||||
if (a->a <= b->a)
|
|
||||||
r = true;
|
|
||||||
else if (a->b <= b->b)
|
|
||||||
r = true;
|
|
||||||
else if (a->c <= b->c)
|
|
||||||
r = true;
|
|
||||||
else if (a->d <= b->d)
|
|
||||||
r = true;
|
|
||||||
else if (a->revision <= b->revision)
|
|
||||||
r = true;
|
|
||||||
else
|
|
||||||
r = false;
|
|
||||||
|
|
||||||
lua_pushboolean(L, r);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_tostringVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
// AAA.BBB.CCC.DDD.RRRRRRRRRRRRR
|
|
||||||
// +1 на конце на всякий случай
|
|
||||||
char buff[4 + 4 + 4 + 4 + 13 + 1];
|
|
||||||
struct core_version* a = luaL_checkudata(L, 1, syscalls_Version_metatable_name);
|
|
||||||
|
|
||||||
sprintf(buff, "%d.%d.%d.%d.%d", a->a, a->b, a->c, a->d, a->revision);
|
|
||||||
|
|
||||||
lua_pushstring(L, buff);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg syscalls_Version_m[] = {
|
|
||||||
{"__index", syscalls_indexVersion},
|
|
||||||
{"__newindex", syscalls_newindexVersion},
|
|
||||||
{"__eq", syscalls_eqVersion},
|
|
||||||
{"__lt", syscalls_ltVersion},
|
|
||||||
{"__le", syscalls_ltVersion},
|
|
||||||
{"__tostring", syscalls_tostringVersion},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct core_version* syscalls_pushVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
DEBUG_LINE("push Version entry");
|
|
||||||
|
|
||||||
struct core_version* entry = lua_newuserdata(L, sizeof(struct core_version));
|
|
||||||
|
|
||||||
luaL_setmetatable(L, syscalls_Version_metatable_name);
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int syscalls_newVersion(lua_State* L)
|
|
||||||
{
|
|
||||||
struct core_version* r = syscalls_pushVersion(L);
|
|
||||||
memset(r, 0, sizeof(struct core_version));
|
|
||||||
|
|
||||||
r->a = luaL_checkinteger(L, 1);
|
|
||||||
r->b = luaL_checkinteger(L, 2);
|
|
||||||
r->c = luaL_checkinteger(L, 3);
|
|
||||||
r->d = luaL_checkinteger(L, 4);
|
|
||||||
r->revision = luaL_checkinteger(L, 5);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg syscalls_Version_lib[] = {
|
|
||||||
{"new", syscalls_newVersion},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
void syscalls_register_Version(lua_State* L)
|
|
||||||
{
|
|
||||||
DEBUG_LINE("register Version entry");
|
|
||||||
|
|
||||||
luaL_newlib(L, syscalls_Version_lib);
|
|
||||||
|
|
||||||
lua_setfield(L, -2, syscalls_Version_name);
|
|
||||||
|
|
||||||
|
|
||||||
luaL_newmetatable(L, syscalls_Version_metatable_name);
|
|
||||||
luaL_setfuncs(L, syscalls_Version_m, 0);
|
|
||||||
|
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
#ifndef __VERSION_TYPE_H__
|
|
||||||
#define __VERSION_TYPE_H__
|
|
||||||
|
|
||||||
#include <sys/ksys.h>
|
|
||||||
#include "../syscalls.h"
|
|
||||||
|
|
||||||
// sub library name
|
|
||||||
#define syscalls_Version_name "CoreVersion"
|
|
||||||
#define syscalls_Version_metatable_name "Version table"
|
|
||||||
#define syscalls_Version_metatable_name "Version metatable"
|
|
||||||
|
|
||||||
struct core_version
|
|
||||||
{
|
|
||||||
uint8_t a;
|
|
||||||
uint8_t b;
|
|
||||||
uint8_t c;
|
|
||||||
uint8_t d;
|
|
||||||
uint8_t zero;
|
|
||||||
uint32_t revision;
|
|
||||||
|
|
||||||
uint32_t unused;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct core_version* syscalls_pushVersion(lua_State* L);
|
|
||||||
|
|
||||||
void syscalls_register_Version(lua_State* L);
|
|
||||||
|
|
||||||
#endif // __VERSION_TYPE_H__
|
|
145
tests/calc.lua
Normal file
145
tests/calc.lua
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
local syscalls = require("syscalls")
|
||||||
|
|
||||||
|
local systemColors = syscalls.GetSystemColors()
|
||||||
|
local skinHeight = syscalls.GetSkinHeight()
|
||||||
|
|
||||||
|
local display = "0"
|
||||||
|
local ans = "0"
|
||||||
|
|
||||||
|
local buttons = {
|
||||||
|
{"1", "2", "3", "+", "-"},
|
||||||
|
{"4", "5", "6", "*", "/"},
|
||||||
|
{"7", "8", "9", "%", ""},
|
||||||
|
{"0", ".", "Ans", "="}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function DrawDisplay()
|
||||||
|
syscalls.DrawText(
|
||||||
|
display,
|
||||||
|
20,
|
||||||
|
20 + skinHeight,
|
||||||
|
systemColors.workText
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function redraw()
|
||||||
|
syscalls.StartRedraw()
|
||||||
|
|
||||||
|
syscalls.CreateWindow(
|
||||||
|
100,
|
||||||
|
100,
|
||||||
|
200,
|
||||||
|
256,
|
||||||
|
"lua example Calc",
|
||||||
|
systemColors.workArea,
|
||||||
|
syscalls.windowStyle.WithSkinFixSizes
|
||||||
|
)
|
||||||
|
|
||||||
|
DrawDisplay()
|
||||||
|
|
||||||
|
--local t = syscalls.ThreadInfo()
|
||||||
|
|
||||||
|
local i = 2
|
||||||
|
local h = math.floor(150 / #buttons)
|
||||||
|
|
||||||
|
for rowN, row in pairs(buttons) do
|
||||||
|
|
||||||
|
local w = math.floor(200 / #row)
|
||||||
|
|
||||||
|
for col, v in pairs(row) do
|
||||||
|
|
||||||
|
local x = math.floor((col-1) * w)
|
||||||
|
local y = math.floor((rowN-1) * h + 50 + skinHeight)
|
||||||
|
|
||||||
|
syscalls.DefineButton(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
w,
|
||||||
|
h,
|
||||||
|
i,
|
||||||
|
systemColors.workButton
|
||||||
|
)
|
||||||
|
|
||||||
|
syscalls.DrawText(
|
||||||
|
v,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
systemColors.workButtonText
|
||||||
|
)
|
||||||
|
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
syscalls.EndRedraw()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function CheckButton(ButtonID)
|
||||||
|
local i = 2
|
||||||
|
for k, v in pairs(buttons) do
|
||||||
|
for j, s in pairs(v) do
|
||||||
|
if ButtonID ~= i then
|
||||||
|
i = i + 1
|
||||||
|
else
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function checkInput(s)
|
||||||
|
if s == "=" then
|
||||||
|
display = assert(load( "return " .. display))()
|
||||||
|
ans = display
|
||||||
|
elseif s == "Ans" then
|
||||||
|
display = display .. ans
|
||||||
|
elseif s then
|
||||||
|
if display == "0" then
|
||||||
|
display = s
|
||||||
|
else
|
||||||
|
display = display .. s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
syscalls.DrawRectangle(20, 20 + skinHeight, 200, 30, systemColors.workArea)
|
||||||
|
DrawDisplay()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- main
|
||||||
|
|
||||||
|
redraw()
|
||||||
|
|
||||||
|
local exit = false
|
||||||
|
while not exit do
|
||||||
|
local event = syscalls.WaitEvent()
|
||||||
|
|
||||||
|
if event == syscalls.Event.Redraw then
|
||||||
|
redraw()
|
||||||
|
elseif event == syscalls.Event.Button then
|
||||||
|
local ButtonID = syscalls.GetButton()
|
||||||
|
|
||||||
|
if ButtonID == syscalls.buttons.close then
|
||||||
|
exit = true
|
||||||
|
else
|
||||||
|
local s = CheckButton(ButtonID)
|
||||||
|
|
||||||
|
checkInput(s)
|
||||||
|
end
|
||||||
|
elseif event == syscalls.Event.Key then
|
||||||
|
local key, a = syscalls.GetKey()
|
||||||
|
|
||||||
|
key = key:sub(1, 1)
|
||||||
|
|
||||||
|
for _, row in pairs(buttons) do
|
||||||
|
for _, v in pairs(row) do
|
||||||
|
if v == key then
|
||||||
|
checkInput(key)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -1,35 +0,0 @@
|
|||||||
--[[
|
|
||||||
Этот скрипт принимает данные от ipc_send и выводит в консоль
|
|
||||||
]]
|
|
||||||
|
|
||||||
local syscalls = require("syscalls")
|
|
||||||
|
|
||||||
-- Enable IPC event only
|
|
||||||
syscalls.SetEventMask(1 << (syscalls.Event.IPC - 1))
|
|
||||||
|
|
||||||
-- write pid to /tmp0/1/lua_test_ipc_pid
|
|
||||||
|
|
||||||
local pid = syscalls.ThreadInfo().PID
|
|
||||||
|
|
||||||
local f = io.open("/tmp0/1/lua_test_ipc_pid", "w")
|
|
||||||
|
|
||||||
if f then
|
|
||||||
f:write(pid);
|
|
||||||
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
------------
|
|
||||||
|
|
||||||
local buffer = syscalls.DefineIPCBuffer(4096)
|
|
||||||
syscalls.IPC_buffer.Unlock(buffer)
|
|
||||||
|
|
||||||
|
|
||||||
while true do
|
|
||||||
print("buffer:", buffer.used .. '/' .. buffer.size, "Locked:" .. tostring(buffer.lock))
|
|
||||||
if syscalls.WaitEvent() == syscalls.Event.IPC then
|
|
||||||
syscalls.IPC_buffer.Lock(buffer)
|
|
||||||
print("message:", syscalls.IPC_buffer.GetLastMessage(buffer))
|
|
||||||
syscalls.IPC_buffer.Unlock(buffer)
|
|
||||||
end
|
|
||||||
end
|
|
@@ -1,21 +0,0 @@
|
|||||||
--[[
|
|
||||||
скрипт который отправляет данные по IPC
|
|
||||||
]]
|
|
||||||
|
|
||||||
local syscalls = require("syscalls")
|
|
||||||
|
|
||||||
local f = io.open("/tmp0/1/lua_test_ipc_pid", "r")
|
|
||||||
|
|
||||||
local pid
|
|
||||||
|
|
||||||
if f then
|
|
||||||
pid = tonumber(f:read("l"))
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
if pid then
|
|
||||||
while true do
|
|
||||||
local msg = syscalls.IPC_msg.fromString("Test aboba", pid)
|
|
||||||
print("Send:", msg, "State:", syscalls.SendIPCMessage(msg))
|
|
||||||
end
|
|
||||||
end
|
|
@@ -1,11 +0,0 @@
|
|||||||
#SHS
|
|
||||||
|
|
||||||
# Graphic
|
|
||||||
../lua helloWorld.lua
|
|
||||||
|
|
||||||
../lua SystemColors.lua
|
|
||||||
|
|
||||||
# IPC tests
|
|
||||||
../lua ipc_get.lua
|
|
||||||
../lua ipc_send.lua
|
|
||||||
|
|
Reference in New Issue
Block a user