refl support static member
This commit is contained in:
parent
efb590c2cd
commit
d79da31749
@ -22,11 +22,13 @@ namespace refl
|
|||||||
internal class FieldMeta
|
internal class FieldMeta
|
||||||
{
|
{
|
||||||
public List<FieldData> MemberList { get; set; }
|
public List<FieldData> MemberList { get; set; }
|
||||||
|
public List<FieldData> StaticMemberList { get; set; }
|
||||||
public List<FieldData> MethodList { get; set; }
|
public List<FieldData> MethodList { get; set; }
|
||||||
public List<FieldData> CtorList { get; set; }
|
public List<FieldData> CtorList { get; set; }
|
||||||
public FieldMeta()
|
public FieldMeta()
|
||||||
{
|
{
|
||||||
MemberList = new List<FieldData>();
|
MemberList = new List<FieldData>();
|
||||||
|
StaticMemberList = new List<FieldData>();
|
||||||
MethodList = new List<FieldData>();
|
MethodList = new List<FieldData>();
|
||||||
CtorList = new List<FieldData>();
|
CtorList = new List<FieldData>();
|
||||||
}
|
}
|
||||||
@ -90,7 +92,14 @@ namespace refl
|
|||||||
{
|
{
|
||||||
cls_meta.Fields.Add(key, new FieldMeta());
|
cls_meta.Fields.Add(key, new FieldMeta());
|
||||||
}
|
}
|
||||||
cls_meta.Fields[key].MemberList.Add(new FieldData(field.Name, value));
|
if(field.StorageQualifier == CppStorageQualifier.Static)
|
||||||
|
{
|
||||||
|
cls_meta.Fields[key].StaticMemberList.Add(new FieldData(field.Name, value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cls_meta.Fields[key].MemberList.Add(new FieldData(field.Name, value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var func in cppClass.Constructors)
|
foreach (var func in cppClass.Constructors)
|
||||||
|
|||||||
@ -27,6 +27,7 @@ namespace refl
|
|||||||
public string MetaName { get; set; } = "";
|
public string MetaName { get; set; } = "";
|
||||||
public int MetaType { get; set; } = 0;
|
public int MetaType { get; set; } = 0;
|
||||||
public int MemberCount { get; set; } = 0;
|
public int MemberCount { get; set; } = 0;
|
||||||
|
public int StaticMemberCount { get; set; } = 0;
|
||||||
public int CtorCount { get; set; } = 0;
|
public int CtorCount { get; set; } = 0;
|
||||||
public int LastAttrIndex { get; set; } = 0;
|
public int LastAttrIndex { get; set; } = 0;
|
||||||
public List<FieldMetaImplData> FieldList = new List<FieldMetaImplData>();
|
public List<FieldMetaImplData> FieldList = new List<FieldMetaImplData>();
|
||||||
@ -64,6 +65,10 @@ namespace refl
|
|||||||
data.FieldList.Add(new FieldMetaImplData(field, 1));
|
data.FieldList.Add(new FieldMetaImplData(field, 1));
|
||||||
}
|
}
|
||||||
data.LastAttrIndex = data.FieldList.Count;
|
data.LastAttrIndex = data.FieldList.Count;
|
||||||
|
foreach (var field in pair.Value.StaticMemberList)
|
||||||
|
{
|
||||||
|
data.FieldList.Add(new FieldMetaImplData(field, 1));
|
||||||
|
}
|
||||||
foreach (var field in pair.Value.CtorList)
|
foreach (var field in pair.Value.CtorList)
|
||||||
{
|
{
|
||||||
data.FieldList.Add(new FieldMetaImplData(field, 2));
|
data.FieldList.Add(new FieldMetaImplData(field, 2));
|
||||||
@ -74,6 +79,7 @@ namespace refl
|
|||||||
data.FieldList.Add(new FieldMetaImplData(field, type));
|
data.FieldList.Add(new FieldMetaImplData(field, type));
|
||||||
}
|
}
|
||||||
data.MemberCount = pair.Value.MemberList.Count;
|
data.MemberCount = pair.Value.MemberList.Count;
|
||||||
|
data.StaticMemberCount = pair.Value.StaticMemberList.Count;
|
||||||
data.CtorCount = pair.Value.CtorList.Count;
|
data.CtorCount = pair.Value.CtorList.Count;
|
||||||
data.MetaType = isMulty ? 1 : 0;
|
data.MetaType = isMulty ? 1 : 0;
|
||||||
if (isMulty && pair.Key.Equals("Meta"))
|
if (isMulty && pair.Key.Equals("Meta"))
|
||||||
|
|||||||
@ -2,6 +2,7 @@ namespace gen{
|
|||||||
template<> struct MetaImpl<{{FullName}}, string_hash("{{MetaName}}")> : public refl::MetaHelp {
|
template<> struct MetaImpl<{{FullName}}, string_hash("{{MetaName}}")> : public refl::MetaHelp {
|
||||||
using T = {{FullName}};
|
using T = {{FullName}};
|
||||||
consteval static int MemberCount() { return {{MemberCount}}; };
|
consteval static int MemberCount() { return {{MemberCount}}; };
|
||||||
|
consteval static int StaticMemberCount() { return {{StaticMemberCount}}; };
|
||||||
consteval static int CtorCount() { return {{CtorCount}}; };
|
consteval static int CtorCount() { return {{CtorCount}}; };
|
||||||
consteval static auto Fields(){
|
consteval static auto Fields(){
|
||||||
return std::make_tuple({% for field in FieldList limit:LastAttrIndex%}{%- if field.Type == 1 %}FProperty(&T::{{field.Name}},"{{field.Name}}"){% unless forloop.last %}, {% endunless %}{%- endif %}{% endfor %});
|
return std::make_tuple({% for field in FieldList limit:LastAttrIndex%}{%- if field.Type == 1 %}FProperty(&T::{{field.Name}},"{{field.Name}}"){% unless forloop.last %}, {% endunless %}{%- endif %}{% endfor %});
|
||||||
@ -10,13 +11,13 @@ namespace gen{
|
|||||||
return std::array{
|
return std::array{
|
||||||
{%- for field in FieldList %}
|
{%- for field in FieldList %}
|
||||||
{%- if field.Type == 1 %}
|
{%- if field.Type == 1 %}
|
||||||
MemberField(&T::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}),
|
MemberField(&T::{{field.Name}}, "{{field.Name}}", {{field.Meta}}),
|
||||||
{%- elsif field.Type == 2 %}
|
{%- elsif field.Type == 2 %}
|
||||||
CtorField((T::{{field.Ref}})nullptr, {{field.Meta}}),
|
CtorField((T::{{field.Ref}})nullptr, {{field.Meta}}),
|
||||||
{%- elsif field.Type == 3 %}
|
{%- elsif field.Type == 3 %}
|
||||||
MethodField(&T::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}),
|
MethodField(&T::{{field.Name}}, "{{field.Name}}", {{field.Meta}}),
|
||||||
{%- else %}
|
{%- else %}
|
||||||
MethodField((T::{{field.Ref}})&T::{{field.Name}}, FName("{{field.Name}}"), {{field.Meta}}),
|
MethodField((T::{{field.Ref}})&T::{{field.Name}}, "{{field.Name}}", {{field.Meta}}),
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user