From e30f65a86ba4b05860732d8e9382b1144c141095 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 1 Feb 2025 16:05:53 -0500 Subject: [PATCH] progress on resolving deps --- .vscode/c_cpp_properties.json | 2 +- code/{dependencies => base}/arch.h | 0 code/{dependencies => base}/base_types.h | 0 code/{dependencies => base}/compiler.h | 0 code/{dependencies => base}/cstd.h | 0 code/base/macros.h | 125 ++++++++++++++++++ code/{dependencies => base}/math.h | 2 +- code/base/memory.h | 38 ++++++ code/{dependencies => base}/os.h | 0 .../metagen_base_arena.c => base/rarena.c} | 0 .../metagen_base_arena.h => base/rarena.h} | 0 code/{dependencies => base}/string.h | 0 code/dependencies/macros.h | 49 ------- code/mdesk/context.h | 10 ++ code/mdesk/mdesk.h | 3 +- docs/mdesk.pur | Bin 1381968 -> 1381968 bytes thirdparty/gencpp_c11/gen.h | 2 +- 17 files changed, 178 insertions(+), 53 deletions(-) rename code/{dependencies => base}/arch.h (100%) rename code/{dependencies => base}/base_types.h (100%) rename code/{dependencies => base}/compiler.h (100%) rename code/{dependencies => base}/cstd.h (100%) create mode 100644 code/base/macros.h rename code/{dependencies => base}/math.h (81%) create mode 100644 code/base/memory.h rename code/{dependencies => base}/os.h (100%) rename code/{metagen/metagen_base/metagen_base_arena.c => base/rarena.c} (100%) rename code/{metagen/metagen_base/metagen_base_arena.h => base/rarena.h} (100%) rename code/{dependencies => base}/string.h (100%) delete mode 100644 code/dependencies/macros.h create mode 100644 code/mdesk/context.h diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 0375c3a..b9f72e7 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -3,7 +3,7 @@ { "name": "Win32", "includePath": [ - "${workspaceFolder}/**" + "${workspaceFolder}/code" ], "defines": [ "_DEBUG", diff --git a/code/dependencies/arch.h b/code/base/arch.h similarity index 100% rename from code/dependencies/arch.h rename to code/base/arch.h diff --git a/code/dependencies/base_types.h b/code/base/base_types.h similarity index 100% rename from code/dependencies/base_types.h rename to code/base/base_types.h diff --git a/code/dependencies/compiler.h b/code/base/compiler.h similarity index 100% rename from code/dependencies/compiler.h rename to code/base/compiler.h diff --git a/code/dependencies/cstd.h b/code/base/cstd.h similarity index 100% rename from code/dependencies/cstd.h rename to code/base/cstd.h diff --git a/code/base/macros.h b/code/base/macros.h new file mode 100644 index 0000000..835b1dd --- /dev/null +++ b/code/base/macros.h @@ -0,0 +1,125 @@ +#if MD_INTELLISENSE_DIRECTIVES +#include "cstd.h" +#endif + +#ifndef MD_API +#if MD_COMPILER_MSVC +# ifdef MD_DYN_LINK +# ifdef MD_DYN_EXPORT +# define MD_API __declspec(dllexport) +# else +# define MD_API __declspec(dllimport) +# endif +# else +# define MD_API // Empty for static builds +# endif +#else +# ifdef MD_DYN_LINK +# define MD_API __attribute__((visibility("default"))) +# else +# define MD_API // Empty for static builds +# endif +#endif +#endif // GEN_API + +#ifndef internal +#define internal static +#endif + +#ifndef local_persist +#define local_persist static +#endif + +#if MD_COMPILER_CPP +# ifndef ccast +# define ccast( type, value ) ( const_cast< type >( (value) ) ) +# endif +# ifndef pcast +# define pcast( type, value ) ( * reinterpret_cast< type* >( & ( value ) ) ) +# endif +# ifndef rcast +# define rcast( type, value ) reinterpret_cast< type >( value ) +# endif +# ifndef scast +# define scast( type, value ) static_cast< type >( value ) +# endif +#else +# ifndef ccast +# define ccast( type, value ) ( (type)(value) ) +# endif +# ifndef pcast +# define pcast( type, value ) ( * (type*)(& value) ) +# endif +# ifndef rcast +# define rcast( type, value ) ( (type)(value) ) +# endif +# ifndef scast +# define scast( type, value ) ( (type)(value) ) +# endif +#endif + +#if ! defined(typeof) && (!MD_COMPILER_C || __STDC_VERSION__ < 202311L) +# if ! MD_COMPILER_C +# define typeof decltype +# elif defined(_MSC_VER) +# define typeof __typeof__ +# elif defined(__GNUC__) || defined(__clang__) +# define typeof __typeof__ +# else +# error "Compiler not supported" +# endif +#endif + +#ifndef MD_API_C_BEGIN +# if MD_COMPILER_C +# define MD_API_C_BEGIN +# define MD_API_C_END +# else +# define MD_API_C_BEGIN extern "C" { +# define MD_API_C_END } +# endif +#endif + +#if MD_COMPILER_C +# if __STDC_VERSION__ >= 202311L +# define enum_underlying(type) : type +# else +# define enum_underlying(type) +# endif +#else +# define enum_underlying(type) : type +#endif + +#if MD_COMPILER_C +# ifndef nullptr +# define nullptr NULL +# endif + +# ifndef MD_REMOVE_PTR +# define MD_REMOVE_PTR(type) typeof(* ( (type) NULL) ) +# endif +#endif + +#if ! defined(MD_PARAM_DEFAULT) && MD_COMPILER_CPP +# define MD_PARAM_DEFAULT = {} +#else +# define MD_PARAM_DEFAULT +#endif + +#if MD_DONT_USE_NAMESPACE || MD_COMPILER_C +# if MD_COMPILER_C +# define MD_NS +# define MD_NS_BEGIN +# define MD_NS_END +# else +# define MD_NS :: +# define MD_NS_BEGIN +# define MD_NS_END +# endif +#else + namespace MD {} + namespace md = MD; +# define MD_NS MD:: +# define MD_NS_BEGIN namespace MD { +# define MD_NS_END } +#endif diff --git a/code/dependencies/math.h b/code/base/math.h similarity index 81% rename from code/dependencies/math.h rename to code/base/math.h index ccb3938..656d454 100644 --- a/code/dependencies/math.h +++ b/code/base/math.h @@ -1,6 +1,6 @@ #if MD_INTELLISENSE_DIRECTIVES #pragma once -#include "dependencies/base_types.h" +#include "base/base_types.h" #endif typedef union Rng1U64 Rng1U64; diff --git a/code/base/memory.h b/code/base/memory.h new file mode 100644 index 0000000..55b5709 --- /dev/null +++ b/code/base/memory.h @@ -0,0 +1,38 @@ +#if MD_INTELLISENE_DIRECTIVES +#pragma once +#include "base_types.h" +#endif + +#define MD_KILOBYTES( x ) ( ( x ) * ( S64 )( 1024 ) ) +#define MD_MEGABYTES( x ) ( MD_KILOBYTES( x ) * ( S64 )( 1024 ) ) +#define MD_GIGABYTES( x ) ( MD_MEGABYTES( x ) * ( S64 )( 1024 ) ) +#define MD_TERABYTES( x ) ( MD_GIGABYTES( x ) * ( S64 )( 1024 ) ) + +#define MD__ONES ( scast( GEN_NS usize, - 1) / MD_U8_MAX ) +#define MD__HIGHS ( MD__ONES * ( MD_U8_MAX / 2 + 1 ) ) +#define MD__HAS_ZERO( x ) ( ( ( x ) - MD__ONES ) & ~( x ) & MD__HIGHS ) + +#define swap(a, b) \ +do \ +{ \ + typeof(a) tmp = a; \ + a = b; \ + b = tmp; \ +} \ +while (0) + +#if MD_COMPILER_MSVC || (MD_COMPILER_CLANG && MD_OS_WINDOWS) +# pragma section(".rdata$", read) +# define read_only __declspec(allocate(".rdata$")) +#elif (MD_COMPILER_CLANG && MD_OS_LINUX) +# define read_only __attribute__((section(".rodata"))) +#else +// NOTE(rjf): I don't know of a useful way to do this in GCC land. +// __attribute__((section(".rodata"))) looked promising, but it introduces a +// strange warning about malformed section attributes, and it doesn't look +// like writing to that section reliably produces access violations, strangely +// enough. (It does on Clang) +# define read_only +#endif + + diff --git a/code/dependencies/os.h b/code/base/os.h similarity index 100% rename from code/dependencies/os.h rename to code/base/os.h diff --git a/code/metagen/metagen_base/metagen_base_arena.c b/code/base/rarena.c similarity index 100% rename from code/metagen/metagen_base/metagen_base_arena.c rename to code/base/rarena.c diff --git a/code/metagen/metagen_base/metagen_base_arena.h b/code/base/rarena.h similarity index 100% rename from code/metagen/metagen_base/metagen_base_arena.h rename to code/base/rarena.h diff --git a/code/dependencies/string.h b/code/base/string.h similarity index 100% rename from code/dependencies/string.h rename to code/base/string.h diff --git a/code/dependencies/macros.h b/code/dependencies/macros.h deleted file mode 100644 index b2d80a1..0000000 --- a/code/dependencies/macros.h +++ /dev/null @@ -1,49 +0,0 @@ -#if MD_INTELLISENSE_DIRECTIVES -#include "cstd.h" -#endif - -#ifndef MD_API -#if MD_COMPILER_MSVC -# ifdef MD_DYN_LINK -# ifdef MD_DYN_EXPORT -# define MD_API __declspec(dllexport) -# else -# define MD_API __declspec(dllimport) -# endif -# else -# define MD_API // Empty for static builds -# endif -#else -# ifdef MD_DYN_LINK -# define MD_API __attribute__((visibility("default"))) -# else -# define MD_API // Empty for static builds -# endif -#endif -#endif // GEN_API - -#ifndef internal -#define internal static -#endif - -#ifndef local_persist -#define local_persist static -#endif - -#if MD_DONT_USE_NAMESPACE || MD_COMPILER_C -# if MD_COMPILER_C -# define MD_NS -# define MD_NS_BEGIN -# define MD_NS_END -# else -# define MD_NS :: -# define MD_NS_BEGIN -# define MD_NS_END -# endif -#else - namespace MD {} - namespace md = MD; -# define MD_NS MD:: -# define MD_NS_BEGIN namespace MD { -# define MD_NS_END } -#endif diff --git a/code/mdesk/context.h b/code/mdesk/context.h new file mode 100644 index 0000000..cb7dbec --- /dev/null +++ b/code/mdesk/context.h @@ -0,0 +1,10 @@ +#ifdef MD_INTELLISENSE_DIRECTIVES +#pragma once +#include "base/memory.h" +#endif + +typedef struct Context Context; +struct Context +{ + Allocator allocator; +}; diff --git a/code/mdesk/mdesk.h b/code/mdesk/mdesk.h index 7ed9a99..b37958d 100644 --- a/code/mdesk/mdesk.h +++ b/code/mdesk/mdesk.h @@ -1,6 +1,7 @@ #if MD_INTELLISENSE_DIRECTIVES #pragma once -#include "dependencies/string.h" +#include "base/string.h" +#include "base/math.h" #endif // Copyright (c) 2024 Epic Games Tools diff --git a/docs/mdesk.pur b/docs/mdesk.pur index 136b239566146b54963a940df2d3fa9ecb71a79b..ece16b103316cbc012b247bcaaa66c5148ec9a97 100644 GIT binary patch delta 188 zcmWNHI}(CG5JU(6AN-SPU~0y?uwZ0hc>@k0i%@d}i_Bm)HquLwS{}nWibrsgSKY6h zn~a<6u{&NNg&Yd7!U{^^0rrw2F%~o!=_MrcFyd0l8WhArEqi=NLXWUT*e2`{b_sig zeZm3ZkZ?peexrZ;ZYvY3*qA&owT%j6k|

EmUPo9fry{_8m_gPaV%3&mAuuFCDL* S9IU7*<1ze?;t`C@&d%<9 zyHw{?=l9*AWRk@!a+XeolVO}GCYWwW;#%l-;h1(=y8J)FhRPctcnB?oHbMuXi_k;p zBMcCR2qT2?3;gS6TX0<%tyEG7X@t6D8IPk>>~$m~o~Fiuyo_;|0HnIQ! diff --git a/thirdparty/gencpp_c11/gen.h b/thirdparty/gencpp_c11/gen.h index e4fd47f..755045f 100644 --- a/thirdparty/gencpp_c11/gen.h +++ b/thirdparty/gencpp_c11/gen.h @@ -38,7 +38,7 @@ | \_____|\___}_l |_|\___} .__/| .__/ {_____/ \__\__/_l\__. |\___/\__,_l \____}{_____}{_____} | | | | | | __} | | | l_l l_l {___/ | - ! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | + ! ----------------------------------------------------------------------- VERSION: v0.24-Alpha | ! ============================================================================================= | ! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION | ! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |