diff options
Diffstat (limited to 'src/libMsg')
| -rw-r--r-- | src/libMsg/MsgKit/Server.h | 8 | ||||
| -rw-r--r-- | src/libMsg/libMsg.json | 2 | ||||
| -rw-r--r-- | src/libMsg/scripts/hello-world.json (renamed from src/libMsg/scripts/window_client.json) | 4 | ||||
| -rw-r--r-- | src/libMsg/src/Server.cpp | 37 |
4 files changed, 43 insertions, 8 deletions
diff --git a/src/libMsg/MsgKit/Server.h b/src/libMsg/MsgKit/Server.h index 3ab8eb73..faac0b0b 100644 --- a/src/libMsg/MsgKit/Server.h +++ b/src/libMsg/MsgKit/Server.h @@ -6,6 +6,7 @@ #ifndef MSGKIT_SERVER_H #define MSGKIT_SERVER_H +#include "libSystem/SystemKit/Macros.h" #ifdef __cplusplus #include <CoreFoundation.fwrk/headers/String.h> #else @@ -25,9 +26,12 @@ struct LIBMSG_EXPR final { CF::CFString* l_value{nullptr}; #else // if we use C, we won't know about CF, so let's make those private. - VoidPtr l_private_data[2]{nullptr}; + VoidPtr l_key{nullptr}; + VoidPtr l_value{nullptr}; #endif + SizeT l_index{}; + LIBMSG_EXPR* l_head{nullptr}; LIBMSG_EXPR* l_tail{nullptr}; LIBMSG_EXPR* l_child{nullptr}; @@ -38,6 +42,6 @@ typedef Void (*libmsg_func_type)(struct LIBMSG_EXPR* self, VoidPtr arg, SizeT ar IMPORT_C Void libmsg_init_library(libmsg_func_type* funcs, SizeT cnt); IMPORT_C UInt32 libmsg_close_library(Void); -IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head); +IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head, VoidPtr arg, SizeT arg_size); #endif diff --git a/src/libMsg/libMsg.json b/src/libMsg/libMsg.json index 4b22534f..54f284b8 100644 --- a/src/libMsg/libMsg.json +++ b/src/libMsg/libMsg.json @@ -17,5 +17,5 @@ "kLibSystemVersionHighest=0x0100", "kLibSystemVersionLowest=0x0100" ], - "description": "OpenMessage Kit for NeKernel." + "description": "OpenMessage Kit for the NeSystem." } diff --git a/src/libMsg/scripts/window_client.json b/src/libMsg/scripts/hello-world.json index 4c8a21ba..f23a3714 100644 --- a/src/libMsg/scripts/window_client.json +++ b/src/libMsg/scripts/hello-world.json @@ -2,6 +2,6 @@ "id": 1, "pos": { "x": 100, "y": 100 }, "size": { "w": 300, "h": 200 }, - "title": "Window Client", - "on-click": "_OnClickCSymbol" + "title": "Message", + "on-init": "_PrintHelloWorld" }
\ No newline at end of file diff --git a/src/libMsg/src/Server.cpp b/src/libMsg/src/Server.cpp index 3f2e8f5a..e4602047 100644 --- a/src/libMsg/src/Server.cpp +++ b/src/libMsg/src/Server.cpp @@ -5,9 +5,40 @@ #include <libMsg/MsgKit/Server.h> -IMPORT_C UInt32 libmsg_close_library(Void) { return 0; } +static libmsg_func_type* kFuncs{nullptr}; +static SizeT kFuncCnt{0}; +static SemaphoreRef kSemaphore{nullptr}; -IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head) { return 0; } +IMPORT_C UInt32 libmsg_close_library(Void) { + if (kSemaphore) return 0; -IMPORT_C Void libmsg_init_library(libmsg_func_type* funcs, SizeT cnt) {} + kFuncs = nullptr; + kFuncCnt = 0; + return 0; +} + +IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head, VoidPtr arg, SizeT arg_size) { + if (kSemaphore) return 0; + + if (!head) return 0; + + kSemaphore = SemCreate(1000, 1000, "libmsg_semaphore"); + + if (!kSemaphore) return 0; + + kFuncs[head->l_index](head, arg, arg_size); + + SemClose(kSemaphore); + kSemaphore = nullptr; + + return 0; +} + +IMPORT_C Void libmsg_init_library(libmsg_func_type* funcs, SizeT cnt) { + kFuncs = funcs; + kFuncCnt = cnt; + + MUST_PASS(kFuncs != nullptr); + MUST_PASS(kFuncCnt > 0); +} |
