delete include
This commit is contained in:
parent
19ca675bf1
commit
fad17f3b5d
@ -1,6 +1,8 @@
|
|||||||
using CommandLine;
|
using CommandLine;
|
||||||
using CppAst;
|
using CppAst;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
namespace refl
|
namespace refl
|
||||||
{
|
{
|
||||||
[Verb("build",HelpText = "Generate custom code based on the parsed AST.")]
|
[Verb("build",HelpText = "Generate custom code based on the parsed AST.")]
|
||||||
@ -30,6 +32,7 @@ namespace refl
|
|||||||
[Option('h', "help", HelpText = "Display this help message.")]
|
[Option('h', "help", HelpText = "Display this help message.")]
|
||||||
public bool Help { get; set; } = false;
|
public bool Help { get; set; } = false;
|
||||||
|
|
||||||
|
static string InputFile = "cpp_input.h";
|
||||||
static CppParserOptions MakeParserOptions(CmdBuildOption opt)
|
static CppParserOptions MakeParserOptions(CmdBuildOption opt)
|
||||||
{
|
{
|
||||||
var parse = new CppParserOptions
|
var parse = new CppParserOptions
|
||||||
@ -56,6 +59,19 @@ namespace refl
|
|||||||
}
|
}
|
||||||
return parse;
|
return parse;
|
||||||
}
|
}
|
||||||
|
public static List<string> PrepareFileList(List<string> file_list)
|
||||||
|
{
|
||||||
|
StringBuilder code = new StringBuilder();
|
||||||
|
foreach (var file in file_list)
|
||||||
|
{
|
||||||
|
string fileContent = File.ReadAllText(file);
|
||||||
|
code.AppendLine(fileContent.Replace("#include", "//#include"));
|
||||||
|
}
|
||||||
|
file_list.Clear();
|
||||||
|
file_list.Add(InputFile);
|
||||||
|
File.WriteAllText(InputFile, code.ToString());
|
||||||
|
return file_list;
|
||||||
|
}
|
||||||
public static int CMD_CheckBuildOption(CmdBuildOption opt)
|
public static int CMD_CheckBuildOption(CmdBuildOption opt)
|
||||||
{
|
{
|
||||||
if(opt.InputFiles == null || !Gen.InitTemplate(opt.Template))
|
if(opt.InputFiles == null || !Gen.InitTemplate(opt.Template))
|
||||||
@ -73,7 +89,7 @@ namespace refl
|
|||||||
{
|
{
|
||||||
file_list = opt.InputFiles.Skip(1).ToList();
|
file_list = opt.InputFiles.Skip(1).ToList();
|
||||||
}
|
}
|
||||||
var compilation = CppAst.CppParser.ParseFiles(file_list, parse_opt);
|
var compilation = CppAst.CppParser.ParseFiles(PrepareFileList(file_list), parse_opt);
|
||||||
if (opt.Verbose)
|
if (opt.Verbose)
|
||||||
{
|
{
|
||||||
// Print diagnostic messages
|
// Print diagnostic messages
|
||||||
|
|||||||
@ -63,8 +63,8 @@ namespace refl
|
|||||||
}
|
}
|
||||||
public void OutFile(string file_name, string? dir,string target)
|
public void OutFile(string file_name, string? dir,string target)
|
||||||
{
|
{
|
||||||
Meta.AppendLine("\r\n");
|
Meta.AppendLine("");
|
||||||
Output.AppendLine("}\r\n");
|
Output.AppendLine("}");
|
||||||
foreach (var pair in FileList)
|
foreach (var pair in FileList)
|
||||||
{
|
{
|
||||||
string path = $"{pair.Key}_{file_name}".ToLower();
|
string path = $"{pair.Key}_{file_name}".ToLower();
|
||||||
@ -72,7 +72,7 @@ namespace refl
|
|||||||
{
|
{
|
||||||
path = Path.Combine(dir, path);
|
path = Path.Combine(dir, path);
|
||||||
}
|
}
|
||||||
pair.Value.AppendLine("}\r\n");
|
pair.Value.AppendLine("}");
|
||||||
File.WriteAllText(path, pair.Value.ToString());
|
File.WriteAllText(path, pair.Value.ToString());
|
||||||
if (pair.Key == "Meta")
|
if (pair.Key == "Meta")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -54,7 +54,7 @@ namespace refl
|
|||||||
{
|
{
|
||||||
data.Name = cls.Name;
|
data.Name = cls.Name;
|
||||||
data.ParentName = cls.ParentName;
|
data.ParentName = cls.ParentName;
|
||||||
bool isMulty = cls.Fields.Count > 0;
|
bool isMulty = cls.Fields.Count > 1;
|
||||||
foreach (var pair in cls.Fields)
|
foreach (var pair in cls.Fields)
|
||||||
{
|
{
|
||||||
data.FieldList.Clear();
|
data.FieldList.Clear();
|
||||||
@ -74,7 +74,7 @@ namespace refl
|
|||||||
data.MemberCount = pair.Value.MemberList.Count;
|
data.MemberCount = pair.Value.MemberList.Count;
|
||||||
data.CtorCount = pair.Value.CtorList.Count;
|
data.CtorCount = pair.Value.CtorList.Count;
|
||||||
data.MetaType = isMulty ? 1 : 0;
|
data.MetaType = isMulty ? 1 : 0;
|
||||||
if (pair.Key.Equals("Meta"))
|
if (isMulty && pair.Key.Equals("Meta"))
|
||||||
{
|
{
|
||||||
data.MetaType = 2;
|
data.MetaType = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,86 +1,32 @@
|
|||||||
#include "refl/refl.h"
|
#pragma once
|
||||||
#include <objbase.h>
|
#include "type.h"
|
||||||
#include <string>
|
#include "guid.h"
|
||||||
#include <vector>
|
#include "resource_bundle.h"
|
||||||
using std::string;
|
namespace engineapi
|
||||||
using std::vector;
|
{
|
||||||
|
struct SerializedMeta
|
||||||
using std::string_view;
|
|
||||||
namespace test {
|
|
||||||
struct Guid
|
|
||||||
{
|
{
|
||||||
UPROPERTY({})
|
UPROPERTY({})
|
||||||
unsigned int Data1;
|
Guid guid;
|
||||||
UPROPERTY({})
|
UPROPERTY({})
|
||||||
unsigned short Data2;
|
string name;
|
||||||
UPROPERTY({})
|
UPROPERTY({})
|
||||||
unsigned short Data3;
|
string t_hash{};
|
||||||
UPROPERTY({})
|
UPROPERTY({})
|
||||||
unsigned char Data4[8];
|
string metadata;
|
||||||
constexpr Guid() noexcept
|
};
|
||||||
: Data1{ 0 }, Data2{ 0 }, Data3{ 0 }, Data4{ 0,0,0,0,0,0,0,0 }
|
struct ResourceBundle;
|
||||||
{}
|
|
||||||
|
|
||||||
USING_OVERLOAD_CTOR(Guid, const string_view&)
|
struct MetaBundle
|
||||||
UFUNCTION({}, ref = USING_CTOR_NAME)
|
{
|
||||||
Guid(const std::string_view& str) noexcept
|
UPROPERTY({})
|
||||||
: Guid{}
|
vector<SerializedMeta> metadatas;
|
||||||
{
|
|
||||||
sscanf_s(str.data(),
|
|
||||||
"%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
|
|
||||||
&Data1, &Data2, &Data3,
|
|
||||||
&Data4[0], &Data4[1], &Data4[2], &Data4[3],
|
|
||||||
&Data4[4], &Data4[5], &Data4[6], &Data4[7]);
|
|
||||||
|
|
||||||
}
|
MetaBundle() = default;
|
||||||
constexpr Guid(unsigned int a, unsigned short b, unsigned short c, unsigned long long d)
|
|
||||||
: Data1{ a }
|
|
||||||
, Data2{ b }
|
|
||||||
, Data3{ c }
|
|
||||||
, Data4{
|
|
||||||
(unsigned char)(d >> 56 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 48 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 40 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 32 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 24 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 16 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 8 & 0xFF)
|
|
||||||
, (unsigned char)(d >> 0 & 0xFF)
|
|
||||||
}
|
|
||||||
{};
|
|
||||||
auto operator<=>(const Guid&) const noexcept = default;
|
|
||||||
operator bool() const noexcept
|
|
||||||
{
|
|
||||||
return *reinterpret_cast<const GUID*>(this) != GUID_NULL;
|
|
||||||
}
|
|
||||||
USING_OVERLOAD_CLASS_FUNC(void, Guid, int)
|
|
||||||
UFUNCTION({}, ref = USING_FUNC_NAME)
|
|
||||||
void test(int x) {
|
|
||||||
|
|
||||||
}
|
|
||||||
USING_OVERLOAD_FUNC(void, Guid, float)
|
|
||||||
UFUNCTION({}, ref = USING_FUNC_NAME)
|
|
||||||
void test(float x) {
|
|
||||||
|
|
||||||
}
|
|
||||||
operator std::string() const
|
|
||||||
{
|
|
||||||
char guid_cstr[39];
|
|
||||||
snprintf(guid_cstr, sizeof(guid_cstr),
|
|
||||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
|
||||||
Data1, Data2, Data3,
|
|
||||||
Data4[0], Data4[1], Data4[2], Data4[3],
|
|
||||||
Data4[4], Data4[5], Data4[6], Data4[7]);
|
|
||||||
return std::string{ guid_cstr };
|
|
||||||
}
|
|
||||||
static Guid Make()
|
|
||||||
{
|
|
||||||
Guid guid;
|
|
||||||
const auto res = CoCreateGuid((GUID*)&guid);
|
|
||||||
return guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
const SerializedMeta* FetchMeta() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#include "meta_bundle.inl"
|
||||||
#include "guid_gen.inl"
|
#include "meta_bundle_gen.inl"
|
||||||
@ -20,8 +20,4 @@
|
|||||||
<ProjectReference Include="..\CppAst\CppAst.csproj" />
|
<ProjectReference Include="..\CppAst\CppAst.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="cpp\gen\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
{{ Indent }} static const auto s_cls = refl::UClass_Meta<T, _Meta<T,{{ MetaName }}>>();
|
{{ Indent }} static const auto s_cls = refl::UClass_Meta<T, _Meta<T,{{ MetaName }}>>();
|
||||||
{{ Indent }} return &s_cls;
|
{{ Indent }} return &s_cls;
|
||||||
{{ Indent }}};
|
{{ Indent }}};
|
||||||
{{ Indent }}{%- else %}
|
{{ Indent }}{%- elsif MetaType == 2 %}
|
||||||
{{ Indent }}inline const refl::UClass* _Multy<{{FullName}}>::get_{{ MetaName }}()
|
{{ Indent }}inline const refl::UClass* _Multy<{{FullName}}>::get_{{ MetaName }}()
|
||||||
{{ Indent }}{
|
{{ Indent }}{
|
||||||
{{ Indent }} return &refl::TypeInfo<T>::StaticClass;
|
{{ Indent }} return &refl::TypeInfo<T>::StaticClass;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user