summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Private/CRT/__cxxkit_defines.hxx6
-rw-r--r--Private/CRT/__som.hxx32
-rw-r--r--Private/CRT/makefile3
-rw-r--r--Private/CRT/som_example.cxx18
-rw-r--r--Private/CRT/som_internal.cxx68
-rw-r--r--Private/NewKit/Defines.hpp18
6 files changed, 128 insertions, 17 deletions
diff --git a/Private/CRT/__cxxkit_defines.hxx b/Private/CRT/__cxxkit_defines.hxx
index 83d8d979..e1c70aac 100644
--- a/Private/CRT/__cxxkit_defines.hxx
+++ b/Private/CRT/__cxxkit_defines.hxx
@@ -7,8 +7,8 @@
* ========================================================
*/
-#ifndef __CXKIT_DEF__
-#define __CXKIT_DEF__
+#ifndef __CXXKIT_DEF__
+#define __CXXKIT_DEF__
typedef __SIZE_TYPE__ size_t;
@@ -88,4 +88,4 @@ typedef union double_cast {
double f;
} __attribute__((packed)) double_cast_t;
-#endif /* __CXKIT_DEF__ */
+#endif /* __CXXKIT_DEF__ */
diff --git a/Private/CRT/__som.hxx b/Private/CRT/__som.hxx
new file mode 100644
index 00000000..ef9354f7
--- /dev/null
+++ b/Private/CRT/__som.hxx
@@ -0,0 +1,32 @@
+/*
+ * ========================================================
+ *
+ * HCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#ifndef __SOM__
+#define __SOM__
+
+typedef unsigned long long int _HandleCls;
+
+/// @brief Looks like an objc class, because it takes inspiration from it.
+typedef struct _Handle {
+ _HandleCls _Cls;
+ int (*Release)(_Handle *);
+ _Handle* (*Sel)(_Handle*, ...);
+} *Handle;
+
+extern "C" Handle __som_send(int sel, int len, ...);
+
+enum {
+ kSomCreate,
+ kSomQuery,
+ kSomCount,
+};
+
+#define kHUnknown 11
+
+#endif /* ifndef __SOM__ */ \ No newline at end of file
diff --git a/Private/CRT/makefile b/Private/CRT/makefile
new file mode 100644
index 00000000..707650c0
--- /dev/null
+++ b/Private/CRT/makefile
@@ -0,0 +1,3 @@
+.PHONY: all
+all:
+ g++ som_example.cxx som_internal.cxx -o som_example.exe \ No newline at end of file
diff --git a/Private/CRT/som_example.cxx b/Private/CRT/som_example.cxx
new file mode 100644
index 00000000..409c6c2c
--- /dev/null
+++ b/Private/CRT/som_example.cxx
@@ -0,0 +1,18 @@
+/*
+ * ========================================================
+ *
+ * HCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include "__som.hxx"
+
+int main(int argc, char const *argv[])
+{
+ Handle handle_type = (Handle)__som_send(kSomCreate, 1, kHUnknown);
+ handle_type->Release(handle_type);
+
+ return 0;
+}
diff --git a/Private/CRT/som_internal.cxx b/Private/CRT/som_internal.cxx
new file mode 100644
index 00000000..4877c318
--- /dev/null
+++ b/Private/CRT/som_internal.cxx
@@ -0,0 +1,68 @@
+/*
+ * ========================================================
+ *
+ * HCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include "__som.hxx"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+static void __som_error(const char* msg)
+{
+ printf("%s\n", "*****************************************");
+ printf("%s\n", msg);
+ printf("%s\n", "*****************************************");
+
+ exit(-33);
+}
+
+static int __som_release(Handle handle)
+{
+ printf("%s\n", "*****************************************");
+ printf("%s\n", "HUnknown, default behavior.");
+ printf("%s\n", "*****************************************");
+
+ free(handle);
+ return 0;
+}
+
+extern "C" Handle __som_send(int sel, int len, ...)
+{
+ switch (sel)
+ {
+ case kSomCreate:
+ {
+ va_list list;
+ va_start(list, len);
+
+ int id = va_arg(list, int);
+
+ Handle handle = nullptr;
+
+ switch (id)
+ {
+ case kHUnknown:
+ handle = (Handle)malloc(sizeof(struct _Handle));
+ handle->Release = __som_release;
+ handle->_Cls = (_HandleCls)handle;
+ break;
+
+ default:
+ __som_error("SOM: Invalid Selector!");
+ break;
+ }
+
+ va_end(list);
+
+ return handle;
+ }
+ default:
+ __som_error("SOM: Invalid Selector!");
+ return nullptr;
+ }
+} \ No newline at end of file
diff --git a/Private/NewKit/Defines.hpp b/Private/NewKit/Defines.hpp
index a64b816d..6d27e4c5 100644
--- a/Private/NewKit/Defines.hpp
+++ b/Private/NewKit/Defines.hpp
@@ -69,7 +69,7 @@ using Void = void;
using Lba = SSizeT;
-enum class Endian : UChar { kLittle, kBig };
+enum class Endian : UChar { kEndianLittle, kEndianBig, kEndianMixed, kCount };
template <typename Args>
Args &&forward(Args &arg) {
@@ -80,22 +80,12 @@ template <typename Args>
Args &&move(Args &&arg) {
return static_cast<Args &&>(arg);
}
-
-typedef UIntPtr _HandleCls;
-
-/// @brief Looks like an objc class, because it takes inspiration from it.
-typedef struct _Handle {
- _HandleCls _Cls;
- void Release(_Handle *);
- _Handle* Init();
- _Handle* Sel(_Handle*, ...);
-} *Handle;
} // namespace HCore
#define DEDUCE_ENDIAN(address, value) \
(((reinterpret_cast<HCore::Char *>(address)[0]) == (value)) \
- ? (HCore::Endian::kBig) \
- : (HCore::Endian::kLittle))
+ ? (HCore::Endian::kEndianBig) \
+ : (HCore::Endian::kEndianLittle))
#define Yes (true)
#define No (false)
@@ -106,4 +96,4 @@ typedef struct _Handle {
#undef INIT
#endif // ifdef INIT
-#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)
+#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__) \ No newline at end of file