summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/Defines.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-27 07:39:05 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-27 07:39:05 +0100
commitf61c814a0a95e98529c96361c992f1a8ea24688a (patch)
tree0c5fcb7976f5753149e0b8cc3b974a318e013f61 /dev/LibCompiler/Defines.h
parentc2046f25120d8c39b36cb81459f3370c8a5f1fa3 (diff)
META: Refactor source code.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/LibCompiler/Defines.h')
-rw-r--r--dev/LibCompiler/Defines.h172
1 files changed, 172 insertions, 0 deletions
diff --git a/dev/LibCompiler/Defines.h b/dev/LibCompiler/Defines.h
new file mode 100644
index 0000000..ceb6c45
--- /dev/null
+++ b/dev/LibCompiler/Defines.h
@@ -0,0 +1,172 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024 Theater Quality Inc, all rights reserved
+
+------------------------------------------- */
+
+#ifndef __TOOLCHAINKIT_DEFINES_H__
+#define __TOOLCHAINKIT_DEFINES_H__
+
+#ifndef Yes
+#define Yes true
+#endif // ifndef Yes
+
+#ifndef No
+#define No false
+#endif // ifndef No
+
+#ifndef YES
+#define YES true
+#endif // ifndef YES
+
+#ifndef NO
+#define NO false
+#endif // ifndef NO
+
+#define SizeType size_t
+
+#define VoidPtr void*
+#define voidPtr VoidPtr
+
+#define UIntPtr uintptr_t
+
+#define Int64 int64_t
+#define UInt64 uint64_t
+
+#define Int32 int
+#define UInt32 unsigned
+
+#define Bool bool
+
+#define Int16 int16_t
+#define UInt16 uint16_t
+
+#define Int8 int8_t
+#define UInt8 uint8_t
+
+#define CharType char
+#define Boolean bool
+
+#include <filesystem>
+#include <cstdint>
+#include <cassert>
+#include <cstring>
+#include <iostream>
+#include <utility>
+#include <cctype>
+#include <cstdio>
+#include <fstream>
+#include <memory>
+#include <string>
+#include <vector>
+#include <vector>
+#include <new>
+
+#define nullPtr std::nullptr_t
+
+#define MUST_PASS(E) assert(E)
+
+#ifndef __FORCE_STRLEN
+#define __FORCE_STRLEN 1
+
+#define string_length(len) strlen(len)
+#endif
+
+#ifndef __FORCE_MEMCPY
+#define __FORCE_MEMCPY 1
+
+#define rt_copy_memory(dst, src, len) memcpy(dst, src, len)
+#endif
+
+#define TOOLCHAINKIT_COPY_DELETE(KLASS) \
+ KLASS& operator=(const KLASS&) = delete; \
+ KLASS(const KLASS&) = delete;
+
+#define TOOLCHAINKIT_COPY_DEFAULT(KLASS) \
+ KLASS& operator=(const KLASS&) = default; \
+ KLASS(const KLASS&) = default;
+
+#define TOOLCHAINKIT_MOVE_DELETE(KLASS) \
+ KLASS& operator=(KLASS&&) = delete; \
+ KLASS(KLASS&&) = delete;
+
+#define TOOLCHAINKIT_MOVE_DEFAULT(KLASS) \
+ KLASS& operator=(KLASS&&) = default; \
+ KLASS(KLASS&&) = default;
+
+#define TK_IMPORT_C extern "C"
+#define TK_IMPORT extern
+
+#include <ctime>
+#include <fstream>
+#include <string>
+#include <vector>
+
+namespace LibCompiler
+{
+ inline constexpr int kBaseYear = 1900;
+
+ typedef std::string String;
+
+ inline String current_date() noexcept
+ {
+ auto time_data = time(nullptr);
+ auto time_struct = gmtime(&time_data);
+
+ String fmt = std::to_string(kBaseYear + time_struct->tm_year);
+
+ fmt += "-";
+ fmt += std::to_string(time_struct->tm_mon + 1);
+ fmt += "-";
+ fmt += std::to_string(time_struct->tm_mday);
+
+ return fmt;
+ }
+
+ inline bool to_str(CharType* str, Int32 limit, Int32 base) noexcept
+ {
+ if (limit == 0)
+ return false;
+
+ Int32 copy_limit = limit;
+ Int32 cnt = 0;
+ Int32 ret = base;
+
+ while (limit != 1)
+ {
+ ret = ret % 10;
+ str[cnt] = ret;
+
+ ++cnt;
+ --limit;
+ --ret;
+ }
+
+ str[copy_limit] = '\0';
+ return true;
+ }
+
+ using String = std::basic_string<CharType>;
+} // namespace LibCompiler
+
+#define PACKED __attribute__((packed))
+
+typedef char char_type;
+
+#define kObjectFileExt ".obj"
+#define kBinaryFileExt ".bin"
+
+#define kAsmFileExts \
+ { \
+ ".64x", ".32x", ".masm", ".s", ".S", ".asm", ".x64" \
+ }
+
+#define kAsmFileExtsMax 7
+
+#define TOOLCHAINKIT_MODULE(name) extern "C" int name(int argc, char** argv)
+
+#ifdef MSVC
+#pragma scalar_storage_order big - endian
+#endif // ifdef MSVC
+
+#endif /* ifndef __TOOLCHAINKIT_DEFINES_H__ */