bugfix
This commit is contained in:
parent
6d4d39ee4e
commit
19ca675bf1
@ -26,7 +26,7 @@ namespace refl
|
||||
public string ParentName { get; set; } = "";
|
||||
public string FullName { get; set; } = "";
|
||||
public string MetaName { get; set; } = "";
|
||||
public bool IsMultyMeta { get; set; } = false;
|
||||
public int MetaType { get; set; } = 0;
|
||||
public int MemberCount { get; set; } = 0;
|
||||
public int CtorCount { get; set; } = 0;
|
||||
|
||||
@ -54,7 +54,7 @@ namespace refl
|
||||
{
|
||||
data.Name = cls.Name;
|
||||
data.ParentName = cls.ParentName;
|
||||
bool isMulty = false;
|
||||
bool isMulty = cls.Fields.Count > 0;
|
||||
foreach (var pair in cls.Fields)
|
||||
{
|
||||
data.FieldList.Clear();
|
||||
@ -73,9 +73,12 @@ namespace refl
|
||||
}
|
||||
data.MemberCount = pair.Value.MemberList.Count;
|
||||
data.CtorCount = pair.Value.CtorList.Count;
|
||||
data.IsMultyMeta = !pair.Key.Equals("Meta");
|
||||
data.MetaType = isMulty ? 1 : 0;
|
||||
if (pair.Key.Equals("Meta"))
|
||||
{
|
||||
data.MetaType = 2;
|
||||
}
|
||||
data.MetaName = pair.Key;
|
||||
isMulty = isMulty || data.IsMultyMeta;
|
||||
var context = new TemplateContext(data, options);
|
||||
var res = template.Render(context);
|
||||
Gen.FileList[pair.Key].Append(res);
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace refl
|
||||
{
|
||||
@ -12,8 +13,8 @@ namespace refl
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public string FullName { get; set; } = "";
|
||||
|
||||
public bool IsMultyMeta { get; set; } = false;
|
||||
public bool HasMeta { get; set; } = false;
|
||||
}
|
||||
internal class GenMetaImpl
|
||||
{
|
||||
@ -37,6 +38,14 @@ namespace refl
|
||||
impl.Name = cls.Name;
|
||||
impl.FullName = fullName;
|
||||
impl.IsMultyMeta = isMulty;
|
||||
impl.HasMeta = false;
|
||||
foreach (var pair in cls.Fields)
|
||||
{
|
||||
if (pair.Key.Equals("Meta"))
|
||||
{
|
||||
impl.HasMeta = true;
|
||||
}
|
||||
}
|
||||
var context = new TemplateContext(impl, options);
|
||||
return template.Render(context);
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ namespace refl
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
public string FullName { get; set; } = "";
|
||||
public bool HasMeta { get; set; } = false;
|
||||
|
||||
public List<string> MetaList = new List<string>();
|
||||
}
|
||||
@ -38,14 +37,7 @@ namespace refl
|
||||
data.FullName = fullName;
|
||||
foreach (var pair in cls.Fields)
|
||||
{
|
||||
if (pair.Key.Equals("Meta"))
|
||||
{
|
||||
data.HasMeta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.MetaList.Add(pair.Key);
|
||||
}
|
||||
data.MetaList.Add(pair.Key);
|
||||
}
|
||||
var context = new TemplateContext(data, options);
|
||||
return template.Render(context);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
{{ Indent }}template<> struct _Static<{{FullName}},{{MetaName}}> {
|
||||
{{ Indent }} using T = class {{FullName}};
|
||||
{{ Indent }} using T = {{FullName}};
|
||||
{{ Indent }} consteval static auto __MakeStaticFields() {
|
||||
{{ Indent }} return std::array{
|
||||
{{ Indent }} {%- for field in FieldList %}
|
||||
{{ Indent }} {%- if field.Type == 1 %}
|
||||
{{ Indent }} refl::StaticMemberField(&T::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}),
|
||||
{{ Indent }} {%- elsif field.Type == 2 %}
|
||||
{{ Indent }} refl::StaticCtorField<T::{{field.Ref}}>({{field.Meta}}),
|
||||
{{ Indent }} refl::StaticCtorField((T::{{field.Ref}})nullptr,{{field.Meta}}),
|
||||
{{ Indent }} {%- elsif field.Type == 3 %}
|
||||
{{ Indent }} refl::StaticMethodField(&T::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}),
|
||||
{{ Indent }} {%- else %}
|
||||
@ -28,12 +28,12 @@
|
||||
{{ Indent }}};
|
||||
{{ Indent }}
|
||||
{{ Indent }}template<> struct _Meta<{{FullName}},{{MetaName}}> : public refl::MetaHelp {
|
||||
{{ Indent }} using T = class {{FullName}};
|
||||
{{ Indent }} using T = {{FullName}};
|
||||
{{ Indent }} using MyParent = {{ ParentName }};
|
||||
{{ Indent }} using MyStatic = _Static<T,{{MetaName}}>;
|
||||
{{ Indent }} {%-if IsMultyMeta %}
|
||||
{{ Indent }}{%-if IsMultyMeta %}
|
||||
{{ Indent }} using MyMetas = class _Multy<T>;
|
||||
{{ Indent }} {%- endif %}
|
||||
{{ Indent }}{%- endif %}
|
||||
{{ Indent }} inline static char s_data[MyStatic::Size()]{};
|
||||
{{ Indent }} static auto __MakeFields() {
|
||||
{{ Indent }} char* memory = &s_data[0];
|
||||
@ -42,7 +42,7 @@
|
||||
{{ Indent }} {%- if field.Type == 1 %}
|
||||
{{ Indent }} MemberField(&T::{{field.Name}}, FName("{{field.Name}}"), memory, {{field.Meta}}),
|
||||
{{ Indent }} {%- elsif field.Type == 2 %}
|
||||
{{ Indent }} CtorField<T::{{field.Ref}}>(memory, {{field.Meta}}),
|
||||
{{ Indent }} CtorField((T::{{field.Ref}})nullptr, memory, {{field.Meta}}),
|
||||
{{ Indent }} {%- elsif field.Type == 3 %}
|
||||
{{ Indent }} MethodField(&T::{{field.Name}}, FName("{{field.Name}}"), memory, {{field.Meta}}),
|
||||
{{ Indent }} {%- else %}
|
||||
@ -52,10 +52,15 @@
|
||||
{{ Indent }} };
|
||||
{{ Indent }} };
|
||||
{{ Indent }}};
|
||||
{{ Indent }}{%- if IsMultyMeta %}
|
||||
{{ Indent }}template<> const refl::UClass* _Multy<{{FullName}}>::{{ MetaName }}()
|
||||
{{ Indent }}{%- if MetaType == 1 %}
|
||||
{{ Indent }}const refl::UClass* _Multy<{{FullName}}>::get_{{ MetaName }}()
|
||||
{{ Indent }}{
|
||||
{{ Indent }} static const auto s_cls = refl::UClass_Meta<T, _Meta<T,{{ MetaName }}>>::BuildClass();
|
||||
{{ Indent }} static const auto s_cls = refl::UClass_Meta<T, _Meta<T,{{ MetaName }}>>();
|
||||
{{ Indent }} return &s_cls;
|
||||
{{ Indent }}};
|
||||
{{ Indent }}{%- else %}
|
||||
{{ Indent }}inline const refl::UClass* _Multy<{{FullName}}>::get_{{ MetaName }}()
|
||||
{{ Indent }}{
|
||||
{{ Indent }} return &refl::TypeInfo<T>::StaticClass;
|
||||
{{ Indent }}};
|
||||
{{ Indent }}{%- endif %}
|
||||
@ -1,6 +1,8 @@
|
||||
{{ Indent }}template<> struct MetaImpl<{{FullName}}>{
|
||||
{{ Indent }} using T = class {{FullName}};
|
||||
{{ Indent }} using T = {{FullName}};
|
||||
{{ Indent }}{%- if HasMeta %}
|
||||
{{ Indent }} using MyMeta = _Meta<T, Meta>;
|
||||
{{ Indent }}{%- endif %}
|
||||
{{ Indent }}{%- if IsMultyMeta %}
|
||||
{{ Indent }} using MyMetas = _Multy<T>;
|
||||
{{ Indent }}{%- endif %}
|
||||
|
||||
@ -1,19 +1,14 @@
|
||||
{{ Indent }}template<> struct _Multy<{{FullName}}>{
|
||||
{{ Indent }} using T = class {{FullName}};
|
||||
{{ Indent }} using T = {{FullName}};
|
||||
{{ Indent }}{%- for Meta in MetaList %}
|
||||
{{ Indent }} static const refl::UClass* {{Meta}}();
|
||||
{{ Indent }} static const refl::UClass* get_{{Meta}}();
|
||||
{{ Indent }}{%- endfor %}
|
||||
{{ Indent }} static const refl::UClass* GetMeta(const Name& name) {
|
||||
{{ Indent }}{%- for Meta in MetaList %}
|
||||
{{ Indent }} if (name == FName("{{Meta}}")) {
|
||||
{{ Indent }} return {{Meta}}();
|
||||
{{ Indent }} return get_{{Meta}}();
|
||||
{{ Indent }} }
|
||||
{{ Indent }}{%- endfor %}
|
||||
{{ Indent }}{%- if HasMeta %}
|
||||
{{ Indent }} if (name == FName("Meta")) {
|
||||
{{ Indent }} return &refl::TypeInfo<T>::StaticClass;
|
||||
{{ Indent }} }
|
||||
{{ Indent }}{%- endif %}
|
||||
{{ Indent }} return nullptr;
|
||||
{{ Indent }} }
|
||||
{{ Indent }}};
|
||||
Loading…
Reference in New Issue
Block a user