From 9815ea28bb7d90f46bf235a4c2379aea021fd39f Mon Sep 17 00:00:00 2001 From: ouczbs Date: Mon, 29 Apr 2024 01:07:26 +0800 Subject: [PATCH] rebuild code gen --- src/refl/BuildOption.cs | 5 +- src/refl/ClassMetaGen.cs | 160 ------------------ src/refl/Gen.cs | 119 +++++++++++++ src/refl/GenMeta.cs | 86 ++++++++++ src/refl/GenMultyMeta.cs | 30 ++++ src/refl/MetaToken.cs | 2 +- src/refl/Properties/launchSettings.json | 2 +- src/refl/cpp/gen/meta_vertex_gen.inl | 23 ++- src/refl/cpp/gen/vertex_gen.inl | 10 +- src/refl/cpp/gen/vkmeta_vertex_gen.inl | 9 +- src/refl/cpp/macro.h | 6 +- src/refl/cpp/vertex.h | 14 +- .../template/{refl.liquid => meta.liquid} | 9 +- src/refl/template/multy_meta.liquid | 41 +++++ 14 files changed, 320 insertions(+), 196 deletions(-) delete mode 100644 src/refl/ClassMetaGen.cs create mode 100644 src/refl/Gen.cs create mode 100644 src/refl/GenMeta.cs create mode 100644 src/refl/GenMultyMeta.cs rename src/refl/template/{refl.liquid => meta.liquid} (85%) create mode 100644 src/refl/template/multy_meta.liquid diff --git a/src/refl/BuildOption.cs b/src/refl/BuildOption.cs index 2fba9a0..1c3f578 100644 --- a/src/refl/BuildOption.cs +++ b/src/refl/BuildOption.cs @@ -58,7 +58,7 @@ namespace refl } public static int CMD_CheckBuildOption(CmdBuildOption opt) { - if(opt.InputFiles == null || !ClassMetaGen.InitTemplate(opt.Template)) + if(opt.InputFiles == null || !Gen.InitTemplate(opt.Template)) { return -1; } @@ -82,7 +82,8 @@ namespace refl Console.WriteLine(message); } var module = ModuleMeta.ParseCompileInfo(compilation); - ClassMetaGen.GenCppMeta(module, opt.Output.ToLower()); + Gen gen = new Gen(); + gen.GenCppMeta(module, opt.Output.ToLower()); if (opt.Verbose) { Console.WriteLine("gen success!"); diff --git a/src/refl/ClassMetaGen.cs b/src/refl/ClassMetaGen.cs deleted file mode 100644 index cd793e6..0000000 --- a/src/refl/ClassMetaGen.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System.IO; -using System.Text; -using Fluid; - -namespace refl -{ - internal class FieldMetaGenData - { - public string Name { get; set; } - public string Meta { get; set; } - public bool IsMethod { get; set; } - - public FieldMetaGenData(string name, string meta, bool isMethod) - { - Name = name; - Meta = meta; - IsMethod = isMethod; - } - } - internal class ClassMetaGenData - { - public string Name { get; set; } = ""; - public string NameSpace { get; set; } = ""; - public string ParentName { get; set; } = ""; - public string Indent { get; set; } = ""; - public string Indent2 { get; set; } = ""; - public string MetaName { get; set; } = ""; - public List FieldList = new List(); - - public ClassMetaGenData(string indent, string nameSpace) - { - Indent = indent; - NameSpace = nameSpace; - if (string.IsNullOrEmpty(nameSpace)) - { - Indent2 = indent; - } - else - { - Indent2 = indent + "\t"; - } - } - } - - internal class ClassMetaGen - { - public static Dictionary FileList = new Dictionary(); - public static Fluid.IFluidTemplate? GenTemplate; - public static TemplateOptions GenOptions = new TemplateOptions(); - public static bool InitTemplate(string path) - { - var template_string = File.ReadAllText(path); - var parser = new FluidParser(); - parser.TryParse(template_string, out GenTemplate, out var error); - GenOptions.MemberAccessStrategy.Register(); - if (!string.IsNullOrEmpty(error)) - { - Console.WriteLine(error); - return false; - } - return true; - } - public static void GenCppMeta(ModuleMeta module, string target) - { - foreach (var name in ModuleMeta.NameSet) - { - var build = new StringBuilder(); - build.AppendLine("#pragma once"); - FileList.Add(name, build); - } - GenModuleMeta(module, null); - string file_name = Path.GetFileName(target); - string? dir = Path.GetDirectoryName(target); - if(dir != null && !Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - var output = new StringBuilder(); - output.AppendLine("#pragma once"); - foreach (var pair in FileList) - { - string path = $"{pair.Key}_{file_name}".ToLower(); - output.AppendLine($"#include \"{path}\""); - if (dir != null) - { - path = Path.Combine(dir, path); - } - File.WriteAllText(path, pair.Value.ToString()); - } - File.WriteAllText(target, output.ToString()); - } - public static void GenModuleMeta(ModuleMeta module, string? prefix) - { - if (!module.HasMeta()) - { - return; - } - var gen = new ClassMetaGenData(prefix+"", module.NameSpace); - if (prefix != null) - { - GenNamespaceBegin(gen); - } - foreach (var cls in module.ClassList) - { - GenClassMeta(cls, gen); - } - foreach (var child in module.ChildList) - { - if(prefix == null) - { - GenModuleMeta(child, ""); - } - else - { - GenModuleMeta(child, prefix + "\t"); - } - } - if (prefix != null) - { - GenNamespaceEnd(gen); - } - } - public static void GenNamespaceBegin(ClassMetaGenData gen) - { - foreach (var name in ModuleMeta.NameSet) - { - string line = $"{gen.Indent}namespace {gen.NameSpace} {{"; - FileList[name].AppendLine(line); - } - } - public static void GenNamespaceEnd(ClassMetaGenData gen) - { - foreach (var name in ModuleMeta.NameSet) - { - FileList[name].AppendLine($"{gen.Indent}}}"); - } - } - public static void GenClassMeta(ClassMeta cls, ClassMetaGenData gen) - { - gen.Name = cls.Name; - gen.ParentName = cls.ParentName; - foreach (var pair in cls.Fields) - { - gen.FieldList.Clear(); - foreach (var field in pair.Value.MemberList) - { - gen.FieldList.Add(new FieldMetaGenData(field.Name, field.Meta, false)); - } - foreach (var field in pair.Value.MethodList) - { - gen.FieldList.Add(new FieldMetaGenData(field.Name, field.Meta, true)); - } - gen.MetaName = pair.Key; - var context = new TemplateContext(gen, GenOptions); - var res = GenTemplate.Render(context); - FileList[pair.Key].Append(res); - } - } - } -} diff --git a/src/refl/Gen.cs b/src/refl/Gen.cs new file mode 100644 index 0000000..78808a6 --- /dev/null +++ b/src/refl/Gen.cs @@ -0,0 +1,119 @@ +using Fluid; +using System.Text; + +namespace refl +{ + internal class Gen + { + public static Dictionary FileList = new Dictionary(); + public static StringBuilder Output = new StringBuilder(); + + private GenMeta meta = new GenMeta(); + private GenMultyMeta multyMeta = new GenMultyMeta(); + public Gen() { } + + public static bool InitTemplate(string dir) + { + string meta_file = Path.Combine(dir, "meta.liquid"); + string multy_meta_file = Path.Combine(dir, "meta.liquid"); + var parser = new FluidParser(); + return GenMeta.InitTemplate(meta_file, parser) && GenMultyMeta.InitTemplate(multy_meta_file, parser); + } + public void CheckDir(string? dir) + { + if (dir != null && !Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } + } + public void InitFile(string file_name) + { + Output.AppendLine("#pragma once"); + foreach (var name in ModuleMeta.NameSet) + { + var build = new StringBuilder(); + build.AppendLine("#pragma once"); + FileList.Add(name, build); + if (name == "Meta") + { + string path = $"Meta_{file_name}".ToLower(); + Output.AppendLine($"#include \"{path}\""); + } + } + } + public void GenCppMeta(ModuleMeta module, string target) + { + string file_name = Path.GetFileName(target); + string? dir = Path.GetDirectoryName(target); + CheckDir(dir); + InitFile(file_name); + GenModuleMeta(module, null); + OutFile(file_name, dir, target); + } + public void OutFile(string file_name, string? dir,string target) + { + foreach (var pair in FileList) + { + string path = $"{pair.Key}_{file_name}".ToLower(); + if (dir != null) + { + path = Path.Combine(dir, path); + } + File.WriteAllText(path, pair.Value.ToString()); + } + File.WriteAllText(target, Output.ToString()); + } + public void GenModuleMeta(ModuleMeta module, string? prefix) + { + if (!module.HasMeta()) + { + return; + } + var data = new ClassMetaData(prefix + "", module.NameSpace); + if (prefix != null) + { + GenNamespaceBegin(data.Indent, data.NameSpace); + } + foreach (var cls in module.ClassList) + { + GenClassMeta(cls, data); + } + string new_prefix = prefix == null ? "" : "\t"; + foreach (var child in module.ChildList) + { + GenModuleMeta(child, new_prefix); + } + if (prefix != null) + { + GenNamespaceEnd(data.Indent); + } + } + public void GenClassMeta(ClassMeta cls, ClassMetaData data) + { + meta.GenClassMeta(cls, data); + if (cls.Fields.Count > 0) + { + multyMeta.GenClassMeta(cls, data); + } + } + public static void GenNamespaceBegin(string indent, string name_space) + { + foreach (var name in ModuleMeta.NameSet) + { + string line = $"{indent}namespace {name_space} {{"; + FileList[name].AppendLine(line); + } + } + public static void GenNamespaceEnd(string indent) + { + foreach (var name in ModuleMeta.NameSet) + { + FileList[name].AppendLine($"{indent}}}"); + } + } + public static void Append(string name, string res) + { + FileList[name].Append(res); + } + } +} diff --git a/src/refl/GenMeta.cs b/src/refl/GenMeta.cs new file mode 100644 index 0000000..98541f2 --- /dev/null +++ b/src/refl/GenMeta.cs @@ -0,0 +1,86 @@ +using System.IO; +using System.Text; +using Fluid; + +namespace refl +{ + internal class FieldMetaData + { + public string Name { get; set; } + public string Meta { get; set; } + public bool IsMethod { get; set; } + + public FieldMetaData(string name, string meta, bool isMethod) + { + Name = name; + Meta = meta; + IsMethod = isMethod; + } + } + internal class ClassMetaData + { + public string Name { get; set; } = ""; + public string NameSpace { get; set; } = ""; + public string ParentName { get; set; } = ""; + public string Indent { get; set; } = ""; + public string Indent2 { get; set; } = ""; + public string MetaName { get; set; } = ""; + public bool IsMultyMeta { get; set; } = false; + + public List FieldList = new List(); + + public ClassMetaData(string indent, string nameSpace) + { + Indent = indent; + NameSpace = nameSpace; + if (string.IsNullOrEmpty(nameSpace)) + { + Indent2 = indent; + } + else + { + Indent2 = indent + "\t"; + } + } + } + + internal class GenMeta + { + private static IFluidTemplate? template; + private static TemplateOptions options = new TemplateOptions(); + public static bool InitTemplate(string path, FluidParser parser) + { + var meta_string = File.ReadAllText(path); + parser.TryParse(meta_string, out template, out var error); + options.MemberAccessStrategy.Register(); + if (!string.IsNullOrEmpty(error)) + { + Console.WriteLine(error); + return false; + } + return true; + } + public void GenClassMeta(ClassMeta cls, ClassMetaData data) + { + data.Name = cls.Name; + data.ParentName = cls.ParentName; + foreach (var pair in cls.Fields) + { + data.FieldList.Clear(); + foreach (var field in pair.Value.MemberList) + { + data.FieldList.Add(new FieldMetaData(field.Name, field.Meta, false)); + } + foreach (var field in pair.Value.MethodList) + { + data.FieldList.Add(new FieldMetaData(field.Name, field.Meta, true)); + } + data.IsMultyMeta = !pair.Key.Equals("Meta"); + data.MetaName = pair.Key; + var context = new TemplateContext(data, options); + var res = template.Render(context); + Gen.Append(pair.Key, res); + } + } + } +} diff --git a/src/refl/GenMultyMeta.cs b/src/refl/GenMultyMeta.cs new file mode 100644 index 0000000..05b1026 --- /dev/null +++ b/src/refl/GenMultyMeta.cs @@ -0,0 +1,30 @@ +using Fluid; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace refl +{ + internal class GenMultyMeta + { + private static IFluidTemplate? template; + private static TemplateOptions options = new TemplateOptions(); + public static bool InitTemplate(string path, FluidParser parser) + { + var meta_string = File.ReadAllText(path); + parser.TryParse(meta_string, out template, out var error); + if (!string.IsNullOrEmpty(error)) + { + Console.WriteLine(error); + return false; + } + return true; + } + public void GenClassMeta(ClassMeta cls, ClassMetaData data) + { + + } + } +} diff --git a/src/refl/MetaToken.cs b/src/refl/MetaToken.cs index 715ecf0..4db5d77 100644 --- a/src/refl/MetaToken.cs +++ b/src/refl/MetaToken.cs @@ -77,7 +77,7 @@ namespace refl } if(key.Length > 0 && value.Length > 0) { - metas.Add(key.ToString().Trim(), value.ToString().Trim()); + metas.Add(key.ToString().Trim(), "{" + value.ToString().Trim()+"}"); } return metas; } diff --git a/src/refl/Properties/launchSettings.json b/src/refl/Properties/launchSettings.json index a9de0ce..aed724c 100644 --- a/src/refl/Properties/launchSettings.json +++ b/src/refl/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "refl": { "commandName": "Project", - "commandLineArgs": "build F:\\csharp\\cppast\\src\\refl\\cpp\\vertex.h -o F:\\csharp\\cppast\\src\\refl\\cpp\\gen\\vertex_gen.inl -t F:\\csharp\\cppast\\src\\refl\\template\\refl.liquid -m F:\\csharp\\cppast\\src\\refl\\cpp\\macro.h -v" + "commandLineArgs": "build F:\\csharp\\cppast\\src\\refl\\cpp\\vertex.h -o F:\\csharp\\cppast\\src\\refl\\cpp\\gen\\vertex_gen.inl -t F:\\csharp\\cppast\\src\\refl\\template -m F:\\csharp\\cppast\\src\\refl\\cpp\\macro.h -v" } } } \ No newline at end of file diff --git a/src/refl/cpp/gen/meta_vertex_gen.inl b/src/refl/cpp/gen/meta_vertex_gen.inl index 7f8a551..83761f6 100644 --- a/src/refl/cpp/gen/meta_vertex_gen.inl +++ b/src/refl/cpp/gen/meta_vertex_gen.inl @@ -1,17 +1,15 @@ #pragma once struct vec3_Static_Meta { consteval static auto __StaticFields() { - return std::make_tuple(&vec3::z, &vec3::name, &vec3::norm, &vec3::norm1, &vec3::norm2, &vec3::norm3); + return std::make_tuple(&vec3::z, &vec3::name, &vec3::norm, &vec3::norm1); }; consteval static auto __MakeStaticFields() { return std::array{ - refl::StaticMemberField(&vec3::z, FName("z"), { 5.f }), - refl::StaticMemberField(&vec3::name, FName("name"), { "hello meta" }), - refl::StaticMethodField(&vec3::norm, FName("norm"), { {3,4} }), - refl::StaticMethodField(&vec3::norm1, FName("norm1"), {1}), - refl::StaticMethodField(&vec3::norm2, FName("norm2"), {}), - refl::StaticMethodField(&vec3::norm3, FName("norm3"), {}), + refl::StaticMemberField(&vec3::z, FName("z"), {5.f}), + refl::StaticMemberField(&vec3::name, FName("name"), {"hello meta"}), + refl::StaticMethodField(&vec3::norm, FName("norm"), {{3,4}}), + refl::StaticMethodField(&vec3::norm1, FName("norm1"), {{1}}), }; }; @@ -24,15 +22,14 @@ struct vec3_Meta : public refl::Meta { using MyStatic = vec3_Static_Meta; using MyUClass = refl::UClass_Meta;; inline static char s_data[MyStatic::Size()]{}; + static auto __MakeFields() { char* memory = &s_data[0]; return std::array{ - MemberField(&vec3::z, FName("z"), memory, { 5.f }), - MemberField(&vec3::name, FName("name"), memory, { "hello meta" }), - MethodField(&vec3::norm, FName("norm"), memory, { {3,4} }), - MethodField(&vec3::norm1, FName("norm1"), memory, {1}), - MethodField(&vec3::norm2, FName("norm2"), memory, {}), - MethodField(&vec3::norm3, FName("norm3"), memory, {}), + MemberField(&vec3::z, FName("z"), memory, {5.f}), + MemberField(&vec3::name, FName("name"), memory, {"hello meta"}), + MethodField(&vec3::norm, FName("norm"), memory, {{3,4}}), + MethodField(&vec3::norm1, FName("norm1"), memory, {{1}}), }; }; }; diff --git a/src/refl/cpp/gen/vertex_gen.inl b/src/refl/cpp/gen/vertex_gen.inl index 2516e8e..c9ad232 100644 --- a/src/refl/cpp/gen/vertex_gen.inl +++ b/src/refl/cpp/gen/vertex_gen.inl @@ -1,3 +1,11 @@ #pragma once -#include "vkmeta_vertex_gen.inl" #include "meta_vertex_gen.inl" + +template<> +struct MultyMeta { + const refl::UClass* Meta() { + return &TypeInfo::StaticClass; + } + const refl::UClass* vkMeta(); + const refl::UClass* GetMeta(const Name& name); +}; \ No newline at end of file diff --git a/src/refl/cpp/gen/vkmeta_vertex_gen.inl b/src/refl/cpp/gen/vkmeta_vertex_gen.inl index 17d64cb..56cb9f5 100644 --- a/src/refl/cpp/gen/vkmeta_vertex_gen.inl +++ b/src/refl/cpp/gen/vkmeta_vertex_gen.inl @@ -6,8 +6,8 @@ struct vec3_Static_vkMeta { consteval static auto __MakeStaticFields() { return std::array{ - refl::StaticMemberField(&vec3::x, FName("x"), ...), - refl::StaticMemberField(&vec3::y, FName("y"), ...), + refl::StaticMemberField(&vec3::x, FName("x"), {1.f}), + refl::StaticMemberField(&vec3::y, FName("y"), {2.f}), }; }; @@ -20,11 +20,12 @@ struct vec3_vkMeta : public refl::Meta { using MyStatic = vec3_Static_vkMeta; using MyUClass = refl::UClass_Meta;; inline static char s_data[MyStatic::Size()]{}; + inline static MyUClass s_cls = MyUClass(); static auto __MakeFields() { char* memory = &s_data[0]; return std::array{ - MemberField(&vec3::x, FName("x"), memory, ...), - MemberField(&vec3::y, FName("y"), memory, ...), + MemberField(&vec3::x, FName("x"), memory, {1.f}), + MemberField(&vec3::y, FName("y"), memory, {2.f}), }; }; }; diff --git a/src/refl/cpp/macro.h b/src/refl/cpp/macro.h index b2e4798..3540166 100644 --- a/src/refl/cpp/macro.h +++ b/src/refl/cpp/macro.h @@ -5,6 +5,6 @@ #define UFUNCTION(...) __Meta(__VA_ARGS__) -#define __vkMeta(...) __cppast(vkMeta,...) -#define UPROPERTY_vk(...) __vkMeta(...) -#define UFUNCTION_vk(...) __vkMeta(...) \ No newline at end of file +#define __vkMeta(...) __cppast(vkMeta,__VA_ARGS__) +#define UPROPERTY_vk(...) __vkMeta(__VA_ARGS__) +#define UFUNCTION_vk(...) __vkMeta(__VA_ARGS__) \ No newline at end of file diff --git a/src/refl/cpp/vertex.h b/src/refl/cpp/vertex.h index 1fca573..c5f5792 100644 --- a/src/refl/cpp/vertex.h +++ b/src/refl/cpp/vertex.h @@ -12,15 +12,15 @@ struct vec3_parent { struct vec3 : public vec3_parent { using MyMeta = class vec3_Meta; using MyMetas = MulytMeta; - UPROPERTY_vk({ 1.f }) + UPROPERTY_vk(1.f) float x = 1; - UPROPERTY_vk({ 2.f }) + UPROPERTY_vk(2.f ) float y = 2; - UPROPERTY({ 5.f }) + UPROPERTY(5.f) float z = 3; - UPROPERTY({ "hello meta" }) + UPROPERTY("hello meta") string name = "???"; - UFUNCTION({ {3,4} }) + UFUNCTION({3,4}) int norm(int x1, int& x2)override { int tmp = x1 * 2 + 1; x1 = x2; @@ -37,11 +37,11 @@ struct vec3 : public vec3_parent { //cout << x1 << "::norm1" << endl; return x1; } - UFUNCTION({}) + UFUNCTION() static void norm2(int x1 = 10) { cout << x1 << "::norm2" << endl; } - UFUNCTION({}) + UFUNCTION() static void norm3(int x1 = 10) { x1 = x1 * 10; cout << x1 << "::norm3" << endl; diff --git a/src/refl/template/refl.liquid b/src/refl/template/meta.liquid similarity index 85% rename from src/refl/template/refl.liquid rename to src/refl/template/meta.liquid index 13be47c..e54747f 100644 --- a/src/refl/template/refl.liquid +++ b/src/refl/template/meta.liquid @@ -8,9 +8,9 @@ {{ Indent2 }} return std::array{ {{ NewLine }} {%- for field in FieldList -%} {{ NewLine }} {%- if field.IsMethod -%} -{{ Indent2 }} refl::StaticMethodField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"){% if field.Meta %}, {{field.Meta}}{% endif %}), +{{ Indent2 }} refl::StaticMethodField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}), {{ NewLine }} {%- else -%} -{{ Indent2 }} refl::StaticMemberField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"){% if field.Meta %}, {{field.Meta}}{% endif %}), +{{ Indent2 }} refl::StaticMemberField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}), {{ NewLine }} {%- endif -%} {{ NewLine }} {%- endfor -%} {{ Indent2 }} }; @@ -25,14 +25,15 @@ {{ Indent2 }} using MyStatic = {{ Name }}_Static_{{MetaName}}; {{ Indent2 }} using MyUClass = refl::UClass_Meta<{{ Name }}, {{ ParentName }}>;; {{ Indent2 }} inline static char s_data[MyStatic::Size()]{}; +{{ NewLine }} {%if IsMultyMeta %}inline static MyUClass s_cls = MyUClass();{% endif %} {{ Indent2 }} static auto __MakeFields() { {{ Indent2 }} char* memory = &s_data[0]; {{ Indent2 }} return std::array{ {{ NewLine }} {%- for field in FieldList -%} {{ NewLine }} {%- if field.IsMethod -%} -{{ Indent2 }} MethodField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), memory{% if field.Meta %}, {{field.Meta}}{% endif %}), +{{ Indent2 }} MethodField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), memory, {{field.Meta}}), {{ NewLine }} {%- else -%} -{{ Indent2 }} MemberField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), memory{% if field.Meta %}, {{field.Meta}}{% endif %}), +{{ Indent2 }} MemberField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), memory, {{field.Meta}}), {{ NewLine }} {%- endif -%} {{ NewLine }} {%- endfor -%} {{ Indent2 }} }; diff --git a/src/refl/template/multy_meta.liquid b/src/refl/template/multy_meta.liquid new file mode 100644 index 0000000..f4e80a1 --- /dev/null +++ b/src/refl/template/multy_meta.liquid @@ -0,0 +1,41 @@ +{%- assign NewLine = newline_to_br -%} +{{ Indent2 }}struct {{ Name }}_Static_{{MetaName}} { +{{ Indent2 }} consteval static auto __StaticFields() { +{{ Indent2 }} return std::make_tuple({% for field in FieldList %}&{{Name}}::{{field.Name}}{% unless forloop.last %}, {% endunless %}{% endfor %}); +{{ Indent2 }} }; +{{ NewLine }} +{{ Indent2 }} consteval static auto __MakeStaticFields() { +{{ Indent2 }} return std::array{ +{{ NewLine }} {%- for field in FieldList -%} +{{ NewLine }} {%- if field.IsMethod -%} +{{ Indent2 }} refl::StaticMethodField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}), +{{ NewLine }} {%- else -%} +{{ Indent2 }} refl::StaticMemberField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}), +{{ NewLine }} {%- endif -%} +{{ NewLine }} {%- endfor -%} +{{ Indent2 }} }; +{{ Indent2 }} }; +{{ NewLine }} +{{ Indent2 }} consteval static int Size() { +{{ Indent2 }} return refl::fetch_meta_size<{{ Name }}_Static_{{MetaName}}>(); +{{ Indent2 }} }; +{{ Indent2 }}}; +{{ NewLine }} +{{ Indent2 }}struct {{ Name }}_{{MetaName}} : public refl::Meta { +{{ Indent2 }} using MyStatic = {{ Name }}_Static_{{MetaName}}; +{{ Indent2 }} using MyUClass = refl::UClass_Meta<{{ Name }}, {{ ParentName }}>;; +{{ Indent2 }} inline static char s_data[MyStatic::Size()]{}; +{{ Indent2 }} static auto __MakeFields() { +{{ Indent2 }} char* memory = &s_data[0]; +{{ Indent2 }} return std::array{ +{{ NewLine }} {%- for field in FieldList -%} +{{ NewLine }} {%- if field.IsMethod -%} +{{ Indent2 }} MethodField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), memory, {{field.Meta}}), +{{ NewLine }} {%- else -%} +{{ Indent2 }} MemberField(&{{Name}}::{{field.Name}}, FName("{{field.Name}}"), memory, {{field.Meta}}), +{{ NewLine }} {%- endif -%} +{{ NewLine }} {%- endfor -%} +{{ Indent2 }} }; +{{ Indent2 }} }; +{{ Indent2 }}}; +{{ NewLine }} \ No newline at end of file