summaryrefslogtreecommitdiffhomepage
path: root/dev/crt
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-09-28 19:13:46 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-09-28 19:13:46 +0200
commit421db65331663304466577b7187780d9eba18077 (patch)
tree3c7c4dc68537935b8cf98313e6a5bfe51786b7d2 /dev/crt
parentb6e416c9986bb545956a642d626e6aafd54f3b76 (diff)
feat: Add common XPCOM controls directory, restructure project, and introduce API breaking changes
- Added a new directory for common XPCOM controls to organize reusable components. - Restructured project layout for better modularity and maintainability. - Introduced API breaking changes in the process, requiring adjustments for backward compatibility. Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/crt')
-rw-r--r--dev/crt/ReadMe.md2
-rw-r--r--dev/crt/__ndk_new_delete.hxx28
-rw-r--r--dev/crt/alloca.hxx (renamed from dev/crt/__ndk_alloca.hxx)2
-rw-r--r--dev/crt/base_alloc.hxx49
-rw-r--r--dev/crt/base_exception.hxx (renamed from dev/crt/__ndk_exception.hxx)2
-rw-r--r--dev/crt/crt.json4
-rw-r--r--dev/crt/defines.hxx (renamed from dev/crt/__ndk_defines.hxx)3
-rw-r--r--dev/crt/math.hxx34
-rw-r--r--dev/crt/src/__ndk_runtime.cxx12
-rw-r--r--dev/crt/src/crt_lib.cxx13
10 files changed, 86 insertions, 63 deletions
diff --git a/dev/crt/ReadMe.md b/dev/crt/ReadMe.md
index c90f5b5f..4f8ad4f5 100644
--- a/dev/crt/ReadMe.md
+++ b/dev/crt/ReadMe.md
@@ -1,4 +1,4 @@
-# ZKA C++ RunTime.
+# ZKA C++ RunTime Kit.
This is the public interface of ZKA' C++ RunTime.
diff --git a/dev/crt/__ndk_new_delete.hxx b/dev/crt/__ndk_new_delete.hxx
deleted file mode 100644
index fad61aa9..00000000
--- a/dev/crt/__ndk_new_delete.hxx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <crt/__ndk_defines.hxx>
-
-namespace stdx
-{
- /// @brief allocate a new class.
- /// @tparam KindClass the class type to allocate.
- template <typename KindClass, typename... Args>
- inline void* allocate(Args&&... args)
- {
- return new KindClass(forward(args)...);
- }
-
- /// @brief free a class.
- /// @tparam KindClass the class type to allocate.
- template <typename KindClass>
- inline void release(KindClass ptr)
- {
- delete ptr;
- }
-} // namespace stdx
diff --git a/dev/crt/__ndk_alloca.hxx b/dev/crt/alloca.hxx
index 3c796bf2..fedcb25d 100644
--- a/dev/crt/__ndk_alloca.hxx
+++ b/dev/crt/alloca.hxx
@@ -2,7 +2,7 @@
Copyright ZKA Technologies.
- File: __ndk_alloca.hxx
+ File: alloca.hxx
Purpose: Stack allocation functions.
------------------------------------------- */
diff --git a/dev/crt/base_alloc.hxx b/dev/crt/base_alloc.hxx
new file mode 100644
index 00000000..de157866
--- /dev/null
+++ b/dev/crt/base_alloc.hxx
@@ -0,0 +1,49 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <crt/defines.hxx>
+
+namespace std::base_alloc
+{
+ /// @brief allocate a new class.
+ /// @tparam KindClass the class type to allocate.
+ template <typename KindClass, typename... Args>
+ inline KindClass* allocate(Args&&... args)
+ {
+ return new KindClass(forward(args)...);
+ }
+
+ /// @brief allocate a new class.
+ /// @note aborts on error.
+ /// @tparam KindClass the class type to allocate.
+ template <typename KindClass, typename... Args>
+ inline KindClass* allocate_nothrow(Args&&... args) noexcept
+ {
+ return allocate(forward(args)...);
+ }
+
+ /// @brief free a class.
+ /// @tparam KindClass the class type to allocate.
+ template <typename KindClass>
+ inline void release(KindClass ptr)
+ {
+ if (!ptr)
+ return;
+
+ delete ptr;
+ }
+
+ /// @brief destroy and free a class.
+ /// @note aborts on error.
+ /// @tparam KindClass the class type to allocate.
+ template <typename KindClass>
+ inline void release_nothrow(KindClass ptr) noexcept
+ {
+ release(ptr);
+ }
+} // namespace std::base_alloc
diff --git a/dev/crt/__ndk_exception.hxx b/dev/crt/base_exception.hxx
index 67735a9d..9d3fd208 100644
--- a/dev/crt/__ndk_exception.hxx
+++ b/dev/crt/base_exception.hxx
@@ -6,7 +6,7 @@
#pragma once
-#include <crt/__ndk_defines.hxx>
+#include <crt/defines.hxx>
/// @brief CRT exit, with exit code (!!! exits all threads. !!!)
/// @param code
diff --git a/dev/crt/crt.json b/dev/crt/crt.json
index dbca05fa..07368550 100644
--- a/dev/crt/crt.json
+++ b/dev/crt/crt.json
@@ -3,13 +3,13 @@
"compiler_std": "c++20",
"headers_path": ["../", "./"],
"sources_path": ["src/*.cxx"],
- "output_name": "ndkcrt.dll",
+ "output_name": "zka-crt-cxx.dll",
"compiler_flags": [
"-ffreestanding",
"-shared",
"-fno-rtti",
"-fno-exceptions",
- " -Wl,--subsystem=17"
+ "-Wl,--subsystem=17"
],
"cpp_macros": [
"__CRT_AMD64__",
diff --git a/dev/crt/__ndk_defines.hxx b/dev/crt/defines.hxx
index bea3f67c..11a76ded 100644
--- a/dev/crt/__ndk_defines.hxx
+++ b/dev/crt/defines.hxx
@@ -7,6 +7,9 @@
#ifndef __NDK_DEFINES_HXX__
#define __NDK_DEFINES_HXX__
+#include <stdint.h>
+#include <stddef.h>
+
#ifndef __GNUC__
typedef __SIZE_TYPE__ size_t;
diff --git a/dev/crt/math.hxx b/dev/crt/math.hxx
index 5f55b430..56bb1236 100644
--- a/dev/crt/math.hxx
+++ b/dev/crt/math.hxx
@@ -6,24 +6,22 @@
#pragma once
-#include <NewKit/Defines.hxx>
+#include <crt/defines.hxx>
/// @file Math.hxx
/// @brief Math functions.
-namespace CRT
-{
- using namespace Kernel;
-
#ifdef __ZKA_USE_DOUBLE__
- typedef double Real;
+typedef double real_type;
#else
- typedef float Real;
+typedef float real_type;
#endif
+namespace std::math
+{
/// @brief Power function, with Repeat argument.
- template <SizeT Exponent>
- inline Real Pow(Real in)
+ template <size_t Exponent>
+ inline real_type pow(real_type in)
{
if (Exponent == 0)
return 1; // Any number to the power of 0 is 1.
@@ -31,11 +29,11 @@ namespace CRT
if (Exponent == 1)
return in; // Any number to the power of 1 is itself.
- UInt64 cnt = Exponent;
+ size_t cnt = Exponent;
- Real result = 1;
+ real_type result = 1;
- for (auto i = 0; i < (cnt); ++i)
+ for (auto i = 0; i < cnt; ++i)
result *= in;
return result;
@@ -43,22 +41,22 @@ namespace CRT
/// @brief Square of function, with Base template argument.
/// @param of Base argument to find sqquare of
- template <SizeT Base>
- inline Real SqrOf(Real in)
+ template <size_t Base>
+ inline real_type sqr(real_type in)
{
if (in == 0)
return 0;
- return Pow<1 / Base>(in);
+ return pow<1 / Base>(in);
}
/// @brief Linear interpolation equation solver.
/// @param from where?
/// @param to to?
/// @param Updated diff value according to difference.
- inline Real CGLerp(Real to, Real from, Real stat)
+ inline real_type lerp(real_type to, real_type from, real_type stat)
{
- Real diff = (to - from);
+ real_type diff = (to - from);
return from + (diff * stat);
}
-} // namespace CRT
+} // namespace std::math
diff --git a/dev/crt/src/__ndk_runtime.cxx b/dev/crt/src/__ndk_runtime.cxx
deleted file mode 100644
index b81963a8..00000000
--- a/dev/crt/src/__ndk_runtime.cxx
+++ /dev/null
@@ -1,12 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <crt/__ndk_alloca.hxx>
-#include <crt/__ndk_defines.hxx>
-#include <crt/__ndk_exception.hxx>
-#include <crt/__ndk_new_delete.hxx>
-
-/// @note No sources needed for now.
diff --git a/dev/crt/src/crt_lib.cxx b/dev/crt/src/crt_lib.cxx
new file mode 100644
index 00000000..530e40db
--- /dev/null
+++ b/dev/crt/src/crt_lib.cxx
@@ -0,0 +1,13 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#include <crt/alloca.hxx>
+#include <crt/defines.hxx>
+#include <crt/base_exception.hxx>
+#include <crt/math.hxx>
+#include <crt/base_alloc.hxx>
+
+/// @note Just here for building.