summaryrefslogtreecommitdiffhomepage
path: root/src/libMsg
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-16 05:07:39 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-16 05:14:22 +0100
commit35fb9574c5efc426491f7ce55689e0f911890e98 (patch)
tree6761ca8cbdf4a7f92db0c8098b08fc6b5f629374 /src/libMsg
parent9213bc66f2a3b05314e1a7386794bb39a02ac81b (diff)
[CHORE] Improve and fix libDDK and implement libMsg.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/libMsg')
-rw-r--r--src/libMsg/MsgKit/Server.h8
-rw-r--r--src/libMsg/libMsg.json2
-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.cpp37
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);
+}