delete include
This commit is contained in:
parent
19ca675bf1
commit
fad17f3b5d
@ -1,6 +1,8 @@
|
||||
using CommandLine;
|
||||
using CppAst;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace refl
|
||||
{
|
||||
[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.")]
|
||||
public bool Help { get; set; } = false;
|
||||
|
||||
static string InputFile = "cpp_input.h";
|
||||
static CppParserOptions MakeParserOptions(CmdBuildOption opt)
|
||||
{
|
||||
var parse = new CppParserOptions
|
||||
@ -56,6 +59,19 @@ namespace refl
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(opt.InputFiles == null || !Gen.InitTemplate(opt.Template))
|
||||
@ -73,7 +89,7 @@ namespace refl
|
||||
{
|
||||
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)
|
||||
{
|
||||
// Print diagnostic messages
|
||||
|
||||
@ -63,8 +63,8 @@ namespace refl
|
||||
}
|
||||
public void OutFile(string file_name, string? dir,string target)
|
||||
{
|
||||
Meta.AppendLine("\r\n");
|
||||
Output.AppendLine("}\r\n");
|
||||
Meta.AppendLine("");
|
||||
Output.AppendLine("}");
|
||||
foreach (var pair in FileList)
|
||||
{
|
||||
string path = $"{pair.Key}_{file_name}".ToLower();
|
||||
@ -72,7 +72,7 @@ namespace refl
|
||||
{
|
||||
path = Path.Combine(dir, path);
|
||||
}
|
||||
pair.Value.AppendLine("}\r\n");
|
||||
pair.Value.AppendLine("}");
|
||||
File.WriteAllText(path, pair.Value.ToString());
|
||||
if (pair.Key == "Meta")
|
||||
{
|
||||
|
||||
@ -54,7 +54,7 @@ namespace refl
|
||||
{
|
||||
data.Name = cls.Name;
|
||||
data.ParentName = cls.ParentName;
|
||||
bool isMulty = cls.Fields.Count > 0;
|
||||
bool isMulty = cls.Fields.Count > 1;
|
||||
foreach (var pair in cls.Fields)
|
||||
{
|
||||
data.FieldList.Clear();
|
||||
@ -74,7 +74,7 @@ namespace refl
|
||||
data.MemberCount = pair.Value.MemberList.Count;
|
||||
data.CtorCount = pair.Value.CtorList.Count;
|
||||
data.MetaType = isMulty ? 1 : 0;
|
||||
if (pair.Key.Equals("Meta"))
|
||||
if (isMulty && pair.Key.Equals("Meta"))
|
||||
{
|
||||
data.MetaType = 2;
|
||||
}
|
||||
|
||||
@ -1,86 +1,32 @@
|
||||
#include "refl/refl.h"
|
||||
#include <objbase.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using std::string_view;
|
||||
namespace test {
|
||||
struct Guid
|
||||
#pragma once
|
||||
#include "type.h"
|
||||
#include "guid.h"
|
||||
#include "resource_bundle.h"
|
||||
namespace engineapi
|
||||
{
|
||||
struct SerializedMeta
|
||||
{
|
||||
UPROPERTY({})
|
||||
unsigned int Data1;
|
||||
Guid guid;
|
||||
UPROPERTY({})
|
||||
unsigned short Data2;
|
||||
string name;
|
||||
UPROPERTY({})
|
||||
unsigned short Data3;
|
||||
string t_hash{};
|
||||
UPROPERTY({})
|
||||
unsigned char Data4[8];
|
||||
constexpr Guid() noexcept
|
||||
: Data1{ 0 }, Data2{ 0 }, Data3{ 0 }, Data4{ 0,0,0,0,0,0,0,0 }
|
||||
{}
|
||||
string metadata;
|
||||
};
|
||||
struct ResourceBundle;
|
||||
|
||||
USING_OVERLOAD_CTOR(Guid, const string_view&)
|
||||
UFUNCTION({}, ref = USING_CTOR_NAME)
|
||||
Guid(const std::string_view& str) noexcept
|
||||
: Guid{}
|
||||
{
|
||||
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]);
|
||||
struct MetaBundle
|
||||
{
|
||||
UPROPERTY({})
|
||||
vector<SerializedMeta> metadatas;
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
MetaBundle() = default;
|
||||
|
||||
template<typename T>
|
||||
const SerializedMeta* FetchMeta() const;
|
||||
};
|
||||
}
|
||||
|
||||
#include "guid_gen.inl"
|
||||
#include "meta_bundle.inl"
|
||||
#include "meta_bundle_gen.inl"
|
||||
@ -20,8 +20,4 @@
|
||||
<ProjectReference Include="..\CppAst\CppAst.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="cpp\gen\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
{{ Indent }} static const auto s_cls = refl::UClass_Meta<T, _Meta<T,{{ MetaName }}>>();
|
||||
{{ Indent }} return &s_cls;
|
||||
{{ Indent }}};
|
||||
{{ Indent }}{%- else %}
|
||||
{{ Indent }}{%- elsif MetaType == 2 %}
|
||||
{{ Indent }}inline const refl::UClass* _Multy<{{FullName}}>::get_{{ MetaName }}()
|
||||
{{ Indent }}{
|
||||
{{ Indent }} return &refl::TypeInfo<T>::StaticClass;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user