From 35fb9574c5efc426491f7ce55689e0f911890e98 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 16 Mar 2026 05:07:39 +0100 Subject: [CHORE] Improve and fix libDDK and implement libMsg. Signed-off-by: Amlal El Mahrouss --- src/libMsg/MsgKit/Server.h | 8 ++++++-- src/libMsg/libMsg.json | 2 +- src/libMsg/scripts/hello-world.json | 7 +++++++ src/libMsg/scripts/window_client.json | 7 ------- src/libMsg/src/Server.cpp | 37 ++++++++++++++++++++++++++++++++--- 5 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 src/libMsg/scripts/hello-world.json delete mode 100644 src/libMsg/scripts/window_client.json (limited to 'src/libMsg') 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 #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/hello-world.json b/src/libMsg/scripts/hello-world.json new file mode 100644 index 00000000..f23a3714 --- /dev/null +++ b/src/libMsg/scripts/hello-world.json @@ -0,0 +1,7 @@ +{ + "id": 1, + "pos": { "x": 100, "y": 100 }, + "size": { "w": 300, "h": 200 }, + "title": "Message", + "on-init": "_PrintHelloWorld" +} \ No newline at end of file diff --git a/src/libMsg/scripts/window_client.json b/src/libMsg/scripts/window_client.json deleted file mode 100644 index 4c8a21ba..00000000 --- a/src/libMsg/scripts/window_client.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": 1, - "pos": { "x": 100, "y": 100 }, - "size": { "w": 300, "h": 200 }, - "title": "Window Client", - "on-click": "_OnClickCSymbol" -} \ 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 -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); +} -- cgit v1.2.3