From 009af747b2e0bf25233da1b1d698f2be3f82150c Mon Sep 17 00:00:00 2001 From: Hugo Amiard Date: Sat, 18 Nov 2023 16:47:01 +0100 Subject: [PATCH] C++20 Modules Cleanup --- example/00_tutorial/Forward.h | 107 +--------------------------------- example/15_script/Forward.h | 16 ----- src/amalg/Forward.h | 6 -- src/clrefl/Forward.h | 10 ---- src/ctx-glfw/Forward.h | 3 - src/fract/Forward.h | 19 +++--- src/fract/Fract.cpp | 3 +- src/fract/Fract.h | 4 +- src/frame/Shell.cpp | 1 + src/gfx-edit/Forward.h | 13 ----- src/gfx-ui/Forward.h | 3 +- src/gfx/Animation.h | 2 - src/gltf/Forward.h | 76 +++++++++++------------- src/infra/Forward.h | 3 +- src/lang/lang.ixx | 2 + src/meta/ctx.meta.cpp | 2 + src/meta/fract.meta.cpp | 2 + src/meta/geom.meta.cpp | 4 ++ src/meta/gfx.meta.cpp | 2 + src/meta/gfx.obj.meta.cpp | 2 +- src/meta/gfx.obj.meta.ixx | 2 +- src/meta/gfx.ui.meta.cpp | 2 + src/meta/gltf.meta.cpp | 2 + src/meta/lang.meta.cpp | 2 + src/meta/math.meta.cpp | 4 ++ src/meta/noise.meta.cpp | 2 + src/meta/refl.meta.cpp | 4 ++ src/meta/ui.meta.cpp | 15 +++-- src/meta/wfc.meta.cpp | 2 + src/noise/Forward.h | 7 +-- src/noise/Noise.cpp | 2 +- src/noise/Noise.h | 12 ++-- src/refl/Convert.h | 6 +- src/refl/Meta.h | 4 ++ src/srlz/Forward.h | 26 ++------- src/srlz/Serial.h | 2 + src/stl/algorithm.h | 4 +- src/stl/decls.h | 3 +- src/tool/Forward.h | 90 ++++++++++++---------------- src/tree/Forward.h | 16 +---- src/ui-nvg-bgfx/Forward.h | 77 +----------------------- src/ui-vg/VgVg.cpp | 1 + src/ui-vg/ui.vg.ixx | 1 + src/ui/Edit/Lang.cpp | 4 ++ src/ui/Edit/Lang.h | 2 + src/ui/Edit/TypeIn.cpp | 2 + src/ui/Frame/Caption.h | 4 +- src/ui/ui.ixx | 2 + src/uio/Object.h | 2 + src/webcl/Forward.h | 11 ---- src/wfc-gfx/Forward.h | 19 +----- src/wfc/Forward.h | 32 +++++----- src/wfc/Overlapping.cpp | 4 +- src/wfc/Wfc.h | 14 ++--- 54 files changed, 202 insertions(+), 460 deletions(-) diff --git a/example/00_tutorial/Forward.h b/example/00_tutorial/Forward.h index 5d4e85116..7467db5b3 100644 --- a/example/00_tutorial/Forward.h +++ b/example/00_tutorial/Forward.h @@ -4,113 +4,10 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifndef _00_TUTORIAL_EXPORT #define _00_TUTORIAL_EXPORT MUD_IMPORT #endif +enum class ShapeType : unsigned int; - enum class ShapeType : unsigned int; - - - class MyObject; - -namespace std { - - - -} - -namespace mud { -namespace ui { - - - -} -} - -namespace glm { - - - -} - -namespace mud { -namespace gfx { - - - -} -} - -namespace json11 { - - - -} - -namespace mud { - - - -} - -namespace mud { -namespace detail { - - - -} -} - -namespace bgfx { - - - -} - -namespace bimg { - - - -} - -namespace toy { - - - -} - -namespace bx { - - - -} - +class MyObject; diff --git a/example/15_script/Forward.h b/example/15_script/Forward.h index cc6d24544..977472fe9 100644 --- a/example/15_script/Forward.h +++ b/example/15_script/Forward.h @@ -4,22 +4,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifndef _15_SCRIPT_EXPORT #define _15_SCRIPT_EXPORT MUD_IMPORT #endif diff --git a/src/amalg/Forward.h b/src/amalg/Forward.h index d6d8b1964..d8a8facba 100644 --- a/src/amalg/Forward.h +++ b/src/amalg/Forward.h @@ -1,13 +1,7 @@ - - #pragma once #include -#include -#include -#include - #ifndef TWO_AMALG_EXPORT #define TWO_AMALG_EXPORT TWO_IMPORT #endif diff --git a/src/clrefl/Forward.h b/src/clrefl/Forward.h index 73d55e6cb..02bc5b5cb 100644 --- a/src/clrefl/Forward.h +++ b/src/clrefl/Forward.h @@ -1,21 +1,11 @@ - - #pragma once #include -#include -#include -#include - #ifndef TWO_CLREFL_EXPORT #define TWO_CLREFL_EXPORT TWO_IMPORT #endif - - - - namespace two { } diff --git a/src/ctx-glfw/Forward.h b/src/ctx-glfw/Forward.h index 362329d08..d86765f8e 100644 --- a/src/ctx-glfw/Forward.h +++ b/src/ctx-glfw/Forward.h @@ -2,9 +2,6 @@ #include -#include -#include - #ifndef TWO_CTX_GLFW_EXPORT #define TWO_CTX_GLFW_EXPORT TWO_IMPORT #endif diff --git a/src/fract/Forward.h b/src/fract/Forward.h index 6c196d166..f5a369ae5 100644 --- a/src/fract/Forward.h +++ b/src/fract/Forward.h @@ -2,25 +2,20 @@ #include -#include -#include -#include -#include - #ifndef TWO_FRACT_EXPORT #define TWO_FRACT_EXPORT TWO_IMPORT #endif namespace two { - enum class PatternSampling : unsigned int; + export_ enum class PatternSampling : unsigned int; - class Pixircle; - class Circlifier; - struct Pattern; - struct FractTab; - class Fract; - class FractSample; + export_ class Pixircle; + export_ class Circlifier; + export_ struct Pattern; + export_ struct FractTab; + export_ class Fract; + export_ class FractSample; } #ifdef TWO_META_GENERATOR diff --git a/src/fract/Fract.cpp b/src/fract/Fract.cpp index e21945b38..f72e20cc7 100644 --- a/src/fract/Fract.cpp +++ b/src/fract/Fract.cpp @@ -4,12 +4,11 @@ module; #include -module two.fract; - #define PI 3.14159f #define COEFF_TRANS 1.5f #define COEFF_ROTATION 15 #define COEFF_V 0.004 +module two.fract; float rnd_float() { diff --git a/src/fract/Fract.h b/src/fract/Fract.h index a0c880d46..0316bc170 100644 --- a/src/fract/Fract.h +++ b/src/fract/Fract.h @@ -4,9 +4,9 @@ namespace two { - TWO_FRACT_EXPORT func_ void generate_fract(uvec2 resolution, const Pattern& pattern, Image256& output_image); + export_ TWO_FRACT_EXPORT func_ void generate_fract(uvec2 resolution, const Pattern& pattern, Image256& output_image); - typedef uint32_t(*PatternSampler)(const Pattern&, float, float, float); + export_ using PatternSampler = uint32_t(*)(const Pattern&, float, float, float); export_ enum class refl_ PatternSampling : unsigned int { diff --git a/src/frame/Shell.cpp b/src/frame/Shell.cpp index a333ad011..c2db9245b 100644 --- a/src/frame/Shell.cpp +++ b/src/frame/Shell.cpp @@ -1,5 +1,6 @@ module; +#define BX_COMPILER_MSVC_CONFORMANCE #include #include #include diff --git a/src/gfx-edit/Forward.h b/src/gfx-edit/Forward.h index d41c7fc0a..8acf031d1 100644 --- a/src/gfx-edit/Forward.h +++ b/src/gfx-edit/Forward.h @@ -2,19 +2,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifndef TWO_GFX_EDIT_EXPORT #define TWO_GFX_EDIT_EXPORT TWO_IMPORT #endif diff --git a/src/gfx-ui/Forward.h b/src/gfx-ui/Forward.h index e3b7156d7..19bb3ee23 100644 --- a/src/gfx-ui/Forward.h +++ b/src/gfx-ui/Forward.h @@ -10,8 +10,7 @@ namespace two { namespace ui { - enum class OrbitMode : int; - + export_ enum class OrbitMode : int; } } diff --git a/src/gfx/Animation.h b/src/gfx/Animation.h index b5458e10a..ad0b4c86d 100644 --- a/src/gfx/Animation.h +++ b/src/gfx/Animation.h @@ -8,9 +8,7 @@ namespace two { -#ifdef TWO_MODULES using stl::string; -#endif export_ enum class refl_ AnimTarget : unsigned int { diff --git a/src/gltf/Forward.h b/src/gltf/Forward.h index 4cad25c09..2af60cc67 100644 --- a/src/gltf/Forward.h +++ b/src/gltf/Forward.h @@ -2,48 +2,42 @@ #include -#include -#include -#include -#include -#include - #ifndef TWO_GLTF_EXPORT #define TWO_GLTF_EXPORT TWO_IMPORT #endif -enum class glTFComponentType : unsigned int; -enum class glTFType : unsigned int; -enum class glTFPrimitiveType : unsigned int; -enum class glTFInterpolation : unsigned int; -enum class glTFAlphaMode : unsigned int; - - -struct glTFBuffer; -struct glTFImage; -struct glTFBufferView; -struct glTFSparseIndices; -struct glTFSparseValues; -struct glTFSparse; -struct glTFAccessor; -struct glTFSampler; -struct glTFTexture; -struct glTFSkin; -struct glTFAttributes; -struct glTFMorphTarget; -struct glTFPrimitive; -struct glTFMesh; -struct glTFPerspective; -struct glTFOrthographic; -struct glTFCamera; -struct glTFAnimationTarget; -struct glTFAnimationChannel; -struct glTFAnimationSampler; -struct glTFAnimation; -struct glTFTextureInfo; -struct glTFMaterialPBR; -struct glTFMaterial; -struct glTFNode; -struct glTFNodeExtras; -struct glTFScene; -struct glTF; +export_ enum class glTFComponentType : unsigned int; +export_ enum class glTFType : unsigned int; +export_ enum class glTFPrimitiveType : unsigned int; +export_ enum class glTFInterpolation : unsigned int; +export_ enum class glTFAlphaMode : unsigned int; + + +export_ struct glTFBuffer; +export_ struct glTFImage; +export_ struct glTFBufferView; +export_ struct glTFSparseIndices; +export_ struct glTFSparseValues; +export_ struct glTFSparse; +export_ struct glTFAccessor; +export_ struct glTFSampler; +export_ struct glTFTexture; +export_ struct glTFSkin; +export_ struct glTFAttributes; +export_ struct glTFMorphTarget; +export_ struct glTFPrimitive; +export_ struct glTFMesh; +export_ struct glTFPerspective; +export_ struct glTFOrthographic; +export_ struct glTFCamera; +export_ struct glTFAnimationTarget; +export_ struct glTFAnimationChannel; +export_ struct glTFAnimationSampler; +export_ struct glTFAnimation; +export_ struct glTFTextureInfo; +export_ struct glTFMaterialPBR; +export_ struct glTFMaterial; +export_ struct glTFNode; +export_ struct glTFNodeExtras; +export_ struct glTFScene; +export_ struct glTF; diff --git a/src/infra/Forward.h b/src/infra/Forward.h index 3eb5cab6a..ffaddafd3 100644 --- a/src/infra/Forward.h +++ b/src/infra/Forward.h @@ -5,7 +5,8 @@ #define TWO_INFRA_EXPORT TWO_IMPORT #endif -#ifdef USE_STLnamespace stl +#ifdef USE_STL +namespace stl { template struct span; template struct array; diff --git a/src/lang/lang.ixx b/src/lang/lang.ixx index c8e9dbf2f..f935f1b86 100644 --- a/src/lang/lang.ixx +++ b/src/lang/lang.ixx @@ -4,6 +4,8 @@ module; export module two.lang; +import ; + export import two.infra; export import two.type; export import two.pool; diff --git a/src/meta/ctx.meta.cpp b/src/meta/ctx.meta.cpp index b641b7e1e..08f51e097 100644 --- a/src/meta/ctx.meta.cpp +++ b/src/meta/ctx.meta.cpp @@ -4,6 +4,8 @@ module two.ctx.meta; using namespace two; +namespace two { using stl::string; } + void two_Key__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_Key__to_value(const string& str, void* val) { (*static_cast(val)) = two::Key(g_enu[type().m_id]->value(str.c_str())); } void two_MouseButtonCode__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } diff --git a/src/meta/fract.meta.cpp b/src/meta/fract.meta.cpp index 5b0c7c0d9..5baccbfa0 100644 --- a/src/meta/fract.meta.cpp +++ b/src/meta/fract.meta.cpp @@ -4,6 +4,8 @@ module two.fract.meta; using namespace two; +namespace two { using stl::string; } + void two_PatternSampling__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_PatternSampling__to_value(const string& str, void* val) { (*static_cast(val)) = two::PatternSampling(g_enu[type().m_id]->value(str.c_str())); } size_t stl_vector_two_Image256__size(void* vec) { return (*static_cast*>(vec)).size(); } diff --git a/src/meta/geom.meta.cpp b/src/meta/geom.meta.cpp index 9f6ad8039..f57d62206 100644 --- a/src/meta/geom.meta.cpp +++ b/src/meta/geom.meta.cpp @@ -4,6 +4,10 @@ module two.geom.meta; using namespace two; +#ifdef TWO_MODULES +namespace two { using stl::string; } +#endif + void two_CatmullType__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_CatmullType__to_value(const string& str, void* val) { (*static_cast(val)) = two::CatmullType(g_enu[type().m_id]->value(str.c_str())); } void two_DrawMode__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } diff --git a/src/meta/gfx.meta.cpp b/src/meta/gfx.meta.cpp index cea4c9ae1..65b5e7483 100644 --- a/src/meta/gfx.meta.cpp +++ b/src/meta/gfx.meta.cpp @@ -4,6 +4,8 @@ module two.gfx.meta; using namespace two; +namespace two { using stl::string; } + void two_AnimTarget__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_AnimTarget__to_value(const string& str, void* val) { (*static_cast(val)) = two::AnimTarget(g_enu[type().m_id]->value(str.c_str())); } void two_Interpolation__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } diff --git a/src/meta/gfx.obj.meta.cpp b/src/meta/gfx.obj.meta.cpp index 807c0f20b..2922d3d53 100644 --- a/src/meta/gfx.obj.meta.cpp +++ b/src/meta/gfx.obj.meta.cpp @@ -1,6 +1,6 @@ module; #include -module TWO2(gfx.obj, meta); +module two.gfx.obj.meta; using namespace two; diff --git a/src/meta/gfx.obj.meta.ixx b/src/meta/gfx.obj.meta.ixx index e83839ff4..f5dfaee8a 100644 --- a/src/meta/gfx.obj.meta.ixx +++ b/src/meta/gfx.obj.meta.ixx @@ -2,7 +2,7 @@ module; #include #include -export module two.gfx.obj, meta); +export module two.gfx.obj.meta; import std.core; import std.threading; import std.regex; diff --git a/src/meta/gfx.ui.meta.cpp b/src/meta/gfx.ui.meta.cpp index e8359c045..05727505a 100644 --- a/src/meta/gfx.ui.meta.cpp +++ b/src/meta/gfx.ui.meta.cpp @@ -4,6 +4,8 @@ module two.gfx.ui.meta; using namespace two; +namespace two { using stl::string; } + void two_ui_OrbitMode__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_ui_OrbitMode__to_value(const string& str, void* val) { (*static_cast(val)) = two::ui::OrbitMode(g_enu[type().m_id]->value(str.c_str())); } void two_OrbitController_set_eye(void* object, span args, void*& result) { UNUSED(result); (*static_cast(object)).set_eye(*static_cast(args[0])); } diff --git a/src/meta/gltf.meta.cpp b/src/meta/gltf.meta.cpp index a8a1a0b79..874198e20 100644 --- a/src/meta/gltf.meta.cpp +++ b/src/meta/gltf.meta.cpp @@ -4,6 +4,8 @@ module two.gltf.meta; using namespace two; +namespace two { using stl::string; } + void glTFComponentType__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void glTFComponentType__to_value(const string& str, void* val) { (*static_cast(val)) = glTFComponentType(g_enu[type().m_id]->value(str.c_str())); } void glTFType__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } diff --git a/src/meta/lang.meta.cpp b/src/meta/lang.meta.cpp index 1734bc80f..d1b5df137 100644 --- a/src/meta/lang.meta.cpp +++ b/src/meta/lang.meta.cpp @@ -4,6 +4,8 @@ module two.lang.meta; using namespace two; +namespace two { using stl::string; } + void two_Language__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_Language__to_value(const string& str, void* val) { (*static_cast(val)) = two::Language(g_enu[type().m_id]->value(str.c_str())); } void* two_Script__get_type(void* object) { return &(*static_cast(object)).m_type; } diff --git a/src/meta/math.meta.cpp b/src/meta/math.meta.cpp index 399163246..58e1d7f73 100644 --- a/src/meta/math.meta.cpp +++ b/src/meta/math.meta.cpp @@ -4,6 +4,10 @@ module two.math.meta; using namespace two; +#ifdef TWO_MODULES +namespace two { using stl::string; } +#endif + void two_Axis__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_Axis__to_value(const string& str, void* val) { (*static_cast(val)) = two::Axis(g_enu[type().m_id]->value(str.c_str())); } void two_Axes__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } diff --git a/src/meta/noise.meta.cpp b/src/meta/noise.meta.cpp index d15c9ff8a..8fc67790f 100644 --- a/src/meta/noise.meta.cpp +++ b/src/meta/noise.meta.cpp @@ -4,6 +4,8 @@ module two.noise.meta; using namespace two; +namespace two { using stl::string; } + void two_Noise_NoiseType__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_Noise_NoiseType__to_value(const string& str, void* val) { (*static_cast(val)) = two::Noise::NoiseType(g_enu[type().m_id]->value(str.c_str())); } void two_Noise_Interp__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } diff --git a/src/meta/refl.meta.cpp b/src/meta/refl.meta.cpp index 706a81d5e..9024db252 100644 --- a/src/meta/refl.meta.cpp +++ b/src/meta/refl.meta.cpp @@ -4,6 +4,10 @@ module two.refl.meta; using namespace two; +#ifdef TWO_MODULES +namespace two { using stl::string; } +#endif + void two_TypeClass__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_TypeClass__to_value(const string& str, void* val) { (*static_cast(val)) = two::TypeClass(g_enu[type().m_id]->value(str.c_str())); } size_t stl_span_two_Type___size(void* vec) { return (*static_cast*>(vec)).size(); } diff --git a/src/meta/ui.meta.cpp b/src/meta/ui.meta.cpp index c218b9b38..8c1f25115 100644 --- a/src/meta/ui.meta.cpp +++ b/src/meta/ui.meta.cpp @@ -1,9 +1,12 @@ module; #include module two.ui.meta; +import two.infra; using namespace two; +namespace two { using stl::string; } + void two_FlowAxis__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_FlowAxis__to_value(const string& str, void* val) { (*static_cast(val)) = two::FlowAxis(g_enu[type().m_id]->value(str.c_str())); } void two_Pivot__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } @@ -232,11 +235,11 @@ void two_ui_typedown_field_107(span args, void*& result) { (*static_cast< void two_ui_color_field_108(span args, void*& result) { (*static_cast(result)) = two::ui::color_field(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3])); } void two_ui_color_display_field_109(span args, void*& result) { UNUSED(result); two::ui::color_display_field(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3])); } void two_ui_input_bool_110(span args, void*& result) { (*static_cast(result)) = two::ui::input(*static_cast(args[0]), *static_cast(args[1])); } -void two_ui_input_stl_basic_string___stl_allocator_111(span args, void*& result) { (*static_cast(result)) = two::ui::input>(*static_cast(args[0]), *static_cast(args[1])); } +void two_ui_input_stl_string_111(span args, void*& result) { (*static_cast(result)) = two::ui::input(*static_cast(args[0]), *static_cast(args[1])); } void two_ui_input_int_112(span args, void*& result) { (*static_cast(result)) = two::ui::input(*static_cast(args[0]), *static_cast(args[1]), *static_cast*>(args[2])); } void two_ui_input_float_113(span args, void*& result) { (*static_cast(result)) = two::ui::input(*static_cast(args[0]), *static_cast(args[1]), *static_cast*>(args[2])); } void two_ui_field_bool_114(span args, void*& result) { (*static_cast(result)) = two::ui::field(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3])); } -void two_ui_field_stl_basic_string___stl_allocator_115(span args, void*& result) { (*static_cast(result)) = two::ui::field>(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3])); } +void two_ui_field_stl_basic_string___stl_allocator_115(span args, void*& result) { (*static_cast(result)) = two::ui::field(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3])); } void two_ui_field_int_116(span args, void*& result) { (*static_cast(result)) = two::ui::field(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast*>(args[3]), *static_cast(args[4])); } void two_ui_field_float_117(span args, void*& result) { (*static_cast(result)) = two::ui::field(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast*>(args[3]), *static_cast(args[4])); } void two_ui_text_box_118(span args, void*& result) { result = &two::ui::text_box(*static_cast(args[0]), *static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3]), *static_cast(args[4]), *static_cast(args[5])); } @@ -244,7 +247,7 @@ void two_ui_type_in_119(span args, void*& result) { result = &two::ui::ty void two_ui_text_edit_120(span args, void*& result) { result = &two::ui::text_edit(*static_cast(args[0]), *static_cast(args[1]), *static_cast(args[2]), static_cast*>(args[3])); } void two_ui_code_edit_121(span args, void*& result) { result = &two::ui::code_edit(*static_cast(args[0]), *static_cast(args[1]), *static_cast(args[2]), static_cast*>(args[3])); } void two_ui_input_bool_122(span args, void*& result) { (*static_cast(result)) = two::ui::input(*static_cast(args[0]), *static_cast(args[1])); } -void two_ui_input_stl_basic_string___stl_allocator_123(span args, void*& result) { (*static_cast(result)) = two::ui::input>(*static_cast(args[0]), *static_cast(args[1])); } +void two_ui_input_stl_basic_string___stl_allocator_123(span args, void*& result) { (*static_cast(result)) = two::ui::input(*static_cast(args[0]), *static_cast(args[1])); } void two_ui_node_input_124(span args, void*& result) { result = &two::ui::node_input(*static_cast(args[0]), static_cast(args[1]), static_cast(args[2]), *static_cast(args[3]), *static_cast(args[4]), *static_cast(args[5])); } void two_ui_node_output_125(span args, void*& result) { result = &two::ui::node_output(*static_cast(args[0]), static_cast(args[1]), static_cast(args[2]), *static_cast(args[3]), *static_cast(args[4]), *static_cast(args[5])); } void two_ui_node_126(span args, void*& result) { result = &two::ui::node(*static_cast(args[0]), static_cast(args[1]), *static_cast(args[2]), *static_cast(args[3]), *static_cast(args[4])); } @@ -2103,7 +2106,7 @@ namespace two m.m_functions.push_back(&f); } { - static Function f = { &namspc({ "two", "ui" }), "input>", funcptr(two::ui::input>), two_ui_input_stl_basic_string___stl_allocator_111, { { "parent", type(), }, { "value", type(), } }, { &type(), QualType::None } }; + static Function f = { &namspc({ "two", "ui" }), "input", funcptr(two::ui::input), two_ui_input_stl_string_111, { { "parent", type(), }, { "value", type(), } }, { &type(), QualType::None } }; m.m_functions.push_back(&f); } { @@ -2121,7 +2124,7 @@ namespace two } { static bool reverse_default = false; - static Function f = { &namspc({ "two", "ui" }), "field>", funcptr(two::ui::field>), two_ui_field_stl_basic_string___stl_allocator_115, { { "parent", type(), }, { "name", type(), Param::Nullable }, { "value", type(), }, { "reverse", type(), Param::Default, &reverse_default } }, { &type(), QualType::None } }; + static Function f = { &namspc({ "two", "ui" }), "field", funcptr(two::ui::field), two_ui_field_stl_basic_string___stl_allocator_115, { { "parent", type(), }, { "name", type(), Param::Nullable }, { "value", type(), }, { "reverse", type(), Param::Default, &reverse_default } }, { &type(), QualType::None } }; m.m_functions.push_back(&f); } { @@ -2164,7 +2167,7 @@ namespace two m.m_functions.push_back(&f); } { - static Function f = { &namspc({ "two", "ui" }), "input>", funcptr(two::ui::input>), two_ui_input_stl_basic_string___stl_allocator_123, { { "parent", type(), }, { "value", type(), } }, { &type(), QualType::None } }; + static Function f = { &namspc({ "two", "ui" }), "input", funcptr(two::ui::input), two_ui_input_stl_basic_string___stl_allocator_123, { { "parent", type(), }, { "value", type(), } }, { &type(), QualType::None } }; m.m_functions.push_back(&f); } { diff --git a/src/meta/wfc.meta.cpp b/src/meta/wfc.meta.cpp index a88419b9b..dca11b3e1 100644 --- a/src/meta/wfc.meta.cpp +++ b/src/meta/wfc.meta.cpp @@ -4,6 +4,8 @@ module two.wfc.meta; using namespace two; +namespace two { using stl::string; } + void two_Result__to_string(void* val, string& str) { str = g_enu[type().m_id]->name(uint32_t((*static_cast(val)))); } void two_Result__to_value(const string& str, void* val) { (*static_cast(val)) = two::Result(g_enu[type().m_id]->value(str.c_str())); } void two_Tile__construct_0(void* ref, span args) { UNUSED(args); new(stl::placeholder(), ref) two::Tile( ); } diff --git a/src/noise/Forward.h b/src/noise/Forward.h index 09fb8cf26..2178167e1 100644 --- a/src/noise/Forward.h +++ b/src/noise/Forward.h @@ -2,16 +2,11 @@ #include -#include -#include -#include -#include - #ifndef TWO_NOISE_EXPORT #define TWO_NOISE_EXPORT TWO_IMPORT #endif namespace two { - class Noise; + export_ class Noise; } diff --git a/src/noise/Noise.cpp b/src/noise/Noise.cpp index 40ea3abdc..753cd017a 100644 --- a/src/noise/Noise.cpp +++ b/src/noise/Noise.cpp @@ -2,9 +2,9 @@ // This software is provided 'as-is' under the zlib License, see the LICENSE.txt file. // This notice and the license may not be removed or altered from any source distribution. +module; #include #include - module two.noise; namespace two diff --git a/src/noise/Noise.h b/src/noise/Noise.h index f16ca13e2..cccb7c490 100644 --- a/src/noise/Noise.h +++ b/src/noise/Noise.h @@ -57,18 +57,18 @@ namespace two #endif }; - TWO_NOISE_EXPORT func_ float noise_2d(float x, float y, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); - TWO_NOISE_EXPORT func_ float noise_3d(float x, float y, float z, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); + export_ TWO_NOISE_EXPORT func_ float noise_2d(float x, float y, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); + export_ TWO_NOISE_EXPORT func_ float noise_3d(float x, float y, float z, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); - TWO_NOISE_EXPORT func_ float noise_fract_2d(float x, float y, Noise::NoiseType noise_type, float frequency, Noise::Interp interp = Noise::Quintic, + export_ TWO_NOISE_EXPORT func_ float noise_fract_2d(float x, float y, Noise::NoiseType noise_type, float frequency, Noise::Interp interp = Noise::Quintic, Noise::FractalType fractal_type = Noise::FBM, int octaves = 3, float lacunarity = 2.f, float gain = 0.5f); - TWO_NOISE_EXPORT func_ float noise_fract_3d(float x, float y, float z, Noise::NoiseType noise_type, float frequency, Noise::Interp interp = Noise::Quintic, + export_ TWO_NOISE_EXPORT func_ float noise_fract_3d(float x, float y, float z, Noise::NoiseType noise_type, float frequency, Noise::Interp interp = Noise::Quintic, Noise::FractalType fractal_type = Noise::FBM, int octaves = 3, float lacunarity = 2.f, float gain = 0.5f); extern template struct refl_ struct_ seque_ vector3d; - TWO_NOISE_EXPORT func_ void noise_field_2d(vector3d& output_values, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); - TWO_NOISE_EXPORT func_ void noise_field_3d(vector3d& output_values, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); + export_ TWO_NOISE_EXPORT func_ void noise_field_2d(vector3d& output_values, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); + export_ TWO_NOISE_EXPORT func_ void noise_field_3d(vector3d& output_values, Noise::NoiseType noise_type, float frequency = 0.01f, Noise::Interp interp = Noise::Quintic); } diff --git a/src/refl/Convert.h b/src/refl/Convert.h index a1c674f27..4d517ba00 100644 --- a/src/refl/Convert.h +++ b/src/refl/Convert.h @@ -15,17 +15,19 @@ namespace two export_ template <> inline void to_string(const Ref& object, string& str) { convert(*object.m_type).m_to_string(object.m_value, str); } +#ifndef TWO_MODULES export_ template - void convert(T_Source& from, T_Dest& to) + inline void convert(T_Source& from, T_Dest& to) { to = static_cast(from); } export_ template - void copy_convert(T_Source& from, T_Dest& to) + inline void copy_convert(T_Source& from, T_Dest& to) { to = T_Dest(from); } +#endif export_ class TWO_REFL_EXPORT TypeConverter : public DoubleDispatch, public LazyGlobal { diff --git a/src/refl/Meta.h b/src/refl/Meta.h index d91e7f703..20b5a57a9 100644 --- a/src/refl/Meta.h +++ b/src/refl/Meta.h @@ -8,6 +8,10 @@ namespace two { +#ifdef TWO_MODULES + export_ using stl::string; +#endif + using cstring = const char*; export_ enum class refl_ TypeClass : unsigned int diff --git a/src/srlz/Forward.h b/src/srlz/Forward.h index 341f70abd..065d3df01 100644 --- a/src/srlz/Forward.h +++ b/src/srlz/Forward.h @@ -1,32 +1,14 @@ - - #pragma once #include -#include -#include -#include - #ifndef TWO_SRLZ_EXPORT #define TWO_SRLZ_EXPORT TWO_IMPORT #endif - - - - -namespace two { - - - - class FromJson; - class ToJson; -} - -namespace json11 { - - - +namespace two +{ + export_ class FromJson; + export_ class ToJson; } diff --git a/src/srlz/Serial.h b/src/srlz/Serial.h index 97aca586a..f38d5744e 100644 --- a/src/srlz/Serial.h +++ b/src/srlz/Serial.h @@ -8,6 +8,8 @@ namespace two { + using stl::string; + export_ using Json = json11::Json; export_ class TWO_SRLZ_EXPORT FromJson : public Dispatch diff --git a/src/stl/algorithm.h b/src/stl/algorithm.h index 1a37d4d65..f5c7aa99c 100644 --- a/src/stl/algorithm.h +++ b/src/stl/algorithm.h @@ -415,13 +415,13 @@ namespace two #ifdef TWO_MODULES export_ template - void convert(T_Source& from, T_Dest& to) + inline void convert(T_Source& from, T_Dest& to) { to = static_cast(from); } export_ template - void copy_convert(T_Source& from, T_Dest& to) + inline void copy_convert(T_Source& from, T_Dest& to) { to = T_Dest(from); } diff --git a/src/stl/decls.h b/src/stl/decls.h index 76124df4a..df4b81799 100644 --- a/src/stl/decls.h +++ b/src/stl/decls.h @@ -10,7 +10,8 @@ namespace stl { export_ template struct span; export_ template struct array; -}namespace stl +} +namespace stl { export_ using std::string; export_ using std::function; diff --git a/src/tool/Forward.h b/src/tool/Forward.h index d21a48d09..a93004eb4 100644 --- a/src/tool/Forward.h +++ b/src/tool/Forward.h @@ -2,62 +2,48 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifndef TWO_TOOL_EXPORT #define TWO_TOOL_EXPORT TWO_IMPORT #endif namespace two { - enum class ToolState : unsigned int; - - - class EditorAction; - struct ToolContext; - class ToolOption; - class Tool; - class ViewportTool; - class SpatialTool; - class Gizmo; - class TransformAction; - class TransformTool; - class TransformGizmo; - class ActionStack; - class UndoTool; - class RedoTool; - class Brush; - class PlaneSnapOption; - class WorldSnapOption; - class PlaceBrush; - class CircleBrush; - class ScriptedBrush; - class TranslateAction; - class TranslateTool; - class RotateAction; - class RotateTool; - class ScaleAction; - class ScaleTool; - struct Selection; - class CopyAction; - class CopyTool; - class ViewAction; - class FrameViewTool; - class ViewTool; - struct ViewTools; - class EditContext; - class WorkPlaneAction; - class WorkPlaneTool; + export_ enum class ToolState : unsigned int; + + + export_ class EditorAction; + export_ struct ToolContext; + export_ class ToolOption; + export_ class Tool; + export_ class ViewportTool; + export_ class SpatialTool; + export_ class Gizmo; + export_ class TransformAction; + export_ class TransformTool; + export_ class TransformGizmo; + export_ class ActionStack; + export_ class UndoTool; + export_ class RedoTool; + export_ class Brush; + export_ class PlaneSnapOption; + export_ class WorldSnapOption; + export_ class PlaceBrush; + export_ class CircleBrush; + export_ class ScriptedBrush; + export_ class TranslateAction; + export_ class TranslateTool; + export_ class RotateAction; + export_ class RotateTool; + export_ class ScaleAction; + export_ class ScaleTool; + export_ struct Selection; + export_ class CopyAction; + export_ class CopyTool; + export_ class ViewAction; + export_ class FrameViewTool; + export_ class ViewTool; + export_ struct ViewTools; + export_ class EditContext; + export_ class WorkPlaneAction; + export_ class WorkPlaneTool; } diff --git a/src/tree/Forward.h b/src/tree/Forward.h index 4129aea98..b5731463d 100644 --- a/src/tree/Forward.h +++ b/src/tree/Forward.h @@ -1,23 +1,13 @@ - - #pragma once #include -#include - #ifndef TWO_TREE_EXPORT #define TWO_TREE_EXPORT TWO_IMPORT #endif - - - - -namespace two { - - - - class NodeState; +namespace two +{ + export_ class NodeState; } diff --git a/src/ui-nvg-bgfx/Forward.h b/src/ui-nvg-bgfx/Forward.h index 47ea9cdad..7c4ea93d0 100644 --- a/src/ui-nvg-bgfx/Forward.h +++ b/src/ui-nvg-bgfx/Forward.h @@ -4,83 +4,12 @@ #include -#include -#include -#include -#include - #ifndef TWO_UI_NANOVG_BGFX_EXPORT #define TWO_UI_NANOVG_BGFX_EXPORT TWO_IMPORT #endif - - - - -namespace std { - - - -} - -namespace two { -namespace ui { - - - -} -} - -namespace glm { - - - -} - -namespace two { -namespace gfx { - - - -} -} - -namespace json11 { - - - -} - -namespace two { - - - - class VgNanoBgfx; -} - -namespace two { -namespace detail { - - - -} -} - -namespace bgfx { - - - -} - -namespace bimg { - - - -} - -namespace bx { - - - +namespace two +{ + export_ class VgNanoBgfx; } diff --git a/src/ui-vg/VgVg.cpp b/src/ui-vg/VgVg.cpp index 8d747adc6..b4f0b3a0b 100644 --- a/src/ui-vg/VgVg.cpp +++ b/src/ui-vg/VgVg.cpp @@ -3,6 +3,7 @@ // This notice and the license may not be removed or altered from any source distribution. module; +#define BX_COMPILER_MSVC_CONFORMANCE #include #include #include diff --git a/src/ui-vg/ui.vg.ixx b/src/ui-vg/ui.vg.ixx index aba44ed13..14a788878 100644 --- a/src/ui-vg/ui.vg.ixx +++ b/src/ui-vg/ui.vg.ixx @@ -1,4 +1,5 @@ module; +#define BX_COMPILER_MSVC_CONFORMANCE #include #include #include diff --git a/src/ui/Edit/Lang.cpp b/src/ui/Edit/Lang.cpp index 760714b87..cce789754 100644 --- a/src/ui/Edit/Lang.cpp +++ b/src/ui/Edit/Lang.cpp @@ -8,6 +8,8 @@ module two.ui; #include +#ifndef TWO_MODULES + namespace two { template @@ -447,3 +449,5 @@ namespace two return lang; } } + +#endif diff --git a/src/ui/Edit/Lang.h b/src/ui/Edit/Lang.h index b20a886db..18ea5830d 100644 --- a/src/ui/Edit/Lang.h +++ b/src/ui/Edit/Lang.h @@ -9,6 +9,7 @@ namespace two { +#ifndef TWO_MODULES struct Identifier { uvec2 m_location; @@ -41,4 +42,5 @@ namespace two export_ LanguageDefinition& LanguageC(); export_ LanguageDefinition& LanguageLua(); export_ LanguageDefinition& LanguageWren(); +#endif } diff --git a/src/ui/Edit/TypeIn.cpp b/src/ui/Edit/TypeIn.cpp index f64366e60..539418f47 100644 --- a/src/ui/Edit/TypeIn.cpp +++ b/src/ui/Edit/TypeIn.cpp @@ -572,6 +572,7 @@ namespace two if(m_string.empty()) return; +#ifndef TWO_MODULES if(m_language == nullptr) { m_text.m_sections.clear(); @@ -644,6 +645,7 @@ namespace two if(*current == '\n') preproc = false; } +#endif } void TextEdit::scroll_to_cursor(Frame& frame, Frame& content) diff --git a/src/ui/Frame/Caption.h b/src/ui/Frame/Caption.h index 94ad1786b..5aa6cd390 100644 --- a/src/ui/Frame/Caption.h +++ b/src/ui/Frame/Caption.h @@ -69,8 +69,8 @@ namespace two bool m_insert_mode = false; }; - using PaletteIndex = uint16_t; - using ColourPalette = span; + export_ using PaletteIndex = uint16_t; + export_ using ColourPalette = span; export_ enum class TextMarkerKind { diff --git a/src/ui/ui.ixx b/src/ui/ui.ixx index e605710f5..00e87cdce 100644 --- a/src/ui/ui.ixx +++ b/src/ui/ui.ixx @@ -4,6 +4,8 @@ module; export module two.ui; +import ; + export import two.infra; export import two.type; export import two.tree; diff --git a/src/uio/Object.h b/src/uio/Object.h index b2e3ebf36..d1e77c3d6 100644 --- a/src/uio/Object.h +++ b/src/uio/Object.h @@ -8,6 +8,8 @@ namespace two { + using stl::string; + export_ TWO_UIO_EXPORT string object_name(Ref object); export_ TWO_UIO_EXPORT string object_icon(Ref object); diff --git a/src/webcl/Forward.h b/src/webcl/Forward.h index ad0d24e97..d7fbbaa73 100644 --- a/src/webcl/Forward.h +++ b/src/webcl/Forward.h @@ -1,22 +1,11 @@ - - #pragma once #include -#include -#include -#include - #ifndef TWO_WEBCL_EXPORT #define TWO_WEBCL_EXPORT TWO_IMPORT #endif - - - - namespace two { } - diff --git a/src/wfc-gfx/Forward.h b/src/wfc-gfx/Forward.h index fd8e91262..76fe2bf1e 100644 --- a/src/wfc-gfx/Forward.h +++ b/src/wfc-gfx/Forward.h @@ -2,25 +2,12 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifndef TWO_WFC_GFX_EXPORT #define TWO_WFC_GFX_EXPORT TWO_IMPORT #endif namespace two -{ - struct TileModel; - class WfcBlock; +{ + export_ struct TileModel; + export_ class WfcBlock; } diff --git a/src/wfc/Forward.h b/src/wfc/Forward.h index 4e2a25da2..756f3f401 100644 --- a/src/wfc/Forward.h +++ b/src/wfc/Forward.h @@ -2,29 +2,23 @@ #include -#include -#include -#include -#include -#include - #ifndef TWO_WFC_EXPORT #define TWO_WFC_EXPORT TWO_IMPORT #endif namespace two { - enum Result : unsigned int; - - - struct Tile; - struct Tileset; - struct DoubleGenerator; - struct Wave; - struct WaveTileset; - struct TileWave; - struct VoxelTile; - struct RGBA; - struct PalettedImage; - class Patternset; + export_ enum Result : unsigned int; + + + export_ struct Tile; + export_ struct Tileset; + export_ struct DoubleGenerator; + export_ struct Wave; + export_ struct WaveTileset; + export_ struct TileWave; + export_ struct VoxelTile; + export_ struct RGBA; + export_ struct PalettedImage; + export_ class Patternset; } diff --git a/src/wfc/Overlapping.cpp b/src/wfc/Overlapping.cpp index d8a86ac33..13615c6bf 100644 --- a/src/wfc/Overlapping.cpp +++ b/src/wfc/Overlapping.cpp @@ -4,11 +4,9 @@ module; #include -module two.wfc; - #include using Json = json11::Json; - +module two.wfc; namespace two { diff --git a/src/wfc/Wfc.h b/src/wfc/Wfc.h index feef8b53b..50ef1fb7d 100644 --- a/src/wfc/Wfc.h +++ b/src/wfc/Wfc.h @@ -4,7 +4,7 @@ namespace two { - using ubool = uint8_t; + export_ using ubool = uint8_t; #define TWO_WFC_PROPAGATION_VEC @@ -132,12 +132,12 @@ namespace two static_assert(sizeof(RGBA) == 4, ""); inline bool operator==(RGBA x, RGBA y) { return x.r == y.r && x.g == y.g && x.b == y.b && x.a == y.a; } - using ColorIndex = uint8_t; // tile index or color index. If you have more than 255, don't. - using ColorPalette = vector; - using ColorPattern = vector; - using PatternHash = uint64_t; // Another representation of a Pattern. - using PatternPrevalence = map; - using PatternIndex = uint16_t; + export_ using ColorIndex = uint8_t; // tile index or color index. If you have more than 255, don't. + export_ using ColorPalette = vector; + export_ using ColorPattern = vector; + export_ using PatternHash = uint64_t; // Another representation of a Pattern. + export_ using PatternPrevalence = map; + export_ using PatternIndex = uint16_t; const auto kInvalidIndex = static_cast(-1); const auto kInvalidHash = static_cast(-1);