【导表】移除客户端内导表工具
parent
8db892b2c8
commit
a5e709e63c
|
|
@ -1,32 +0,0 @@
|
|||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/ActorCfg/ItemType.cs,89B22DA9CBF1836DA2C775D6AA3942D,855,1690371134295
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/ActorCfg/ValueItemType.cs,4CC6654B5ED543CCFD0F81E3456927,730,1690371134303
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/AreaCfg/EAreaType.cs,7BA183481291A52E615C148A5F59AE7B,523,1690371134302
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/BuffCfg/EBuffType.cs,D665732DBAA1A0E2BC589CD674FB69E0,911,1690371134306
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/BuffCfg/EExistType.cs,2D091A34ACE816A289ABCF8212581,700,1690371134296
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/BuffCfg/ETriggerType.cs,AE71FC673AF158F6BBE916E5218D2C3,709,1690371134301
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/BulletCfg/EBulletTargetType.cs,4E8F4DF21357EDCDA093461EF15EAB2,711,1690371134305
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/CharacterCfg/Army.cs,C14FA7B4FDE16A5D12D47AB11A23C2C,783,1690371134308
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/CharacterCfg/Efaction.cs,1FAE991E399A9242B66F24C3197C1FA,799,1690371134306
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/CharacterCfg/Ejob.cs,BAE7E98626D96F07F85434146F551,921,1690371134297
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/CharacterCfg/EShootMode.cs,3F9F486255E7B3DA5FA43813A333D,615,1690371134304
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/CharacterCfg/EWeapon.cs,6AB4655FCACE8281837A4DC6ED13B847,770,1690371134296
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/SkillCfg/ESkillType.cs,753DE12FC43FCE71D488FAD3157BBE4C,608,1690371134298
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/SkillCfg/ETargetType.cs,A046FF6CE3DC31638E2BE1EB82DE6C1C,898,1690371134295
|
||||
C:/Users/82158/Perforce/liutao_LT-Work_ProjectNLD_main_1/ProjectNLD/Assets/Config/Data/charactercfg_characterattri.json,C84BCFF556AAC941B8DF9A2CAB05AC8,25187,1690440666100
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/__beans__.xlsx,1FB5D353478A118E335F234A4FE2B5C,10303,1690435392313
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/__enums__.xlsx,2AF124B9C6BACAC1E18BABC4F7F7E758,13514,1690444887326
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/__tables__.xlsx,2EAD6952E642CDF507D75A5B7F3DEF,12723,1690444887097
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/ActorBorn.xlsx,6E1C769C2DFE16DBFFF698480424A5F,10653,1690444887212
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/BuffConfig.xlsx,6C91CE2946B4C9556C99B3053B8D787,23771,1690444887302
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/BulletConfig.xlsx,4530153340EB7B7814BB0B9AD9D93C1,24741,1690444887338
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/CharacterBreak.xlsx,A33DF20950B67479C83B543CBD134,17741,1690444887512
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/CharacterDefault.xlsx,9A62C3B318490D1EB7EB98A4C1698A,29737,1690444887312
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/CharacterLevelExp.xlsx,80E74EB2AFA7F1B334A8D489FED41C13,11558,1690444887328
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/EffectConfig.xlsx,BFF6C17CE3BE091FE84A7391B54AF2,25355,1690444887379
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/GlobalConfig.xlsx,ED264F6CDA5A0FB84820738B6F39C6,14495,1690444887352
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/InfluenceAreaConfig.xlsx,CDAB22883A7D8E44D0378423D2D9833,22615,1690444887690
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/Item.xlsx,1D4962FAE48A5615659593AFD69350,17800,1690444887363
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/ModelSpeed.xlsx,F8D9C729F1B8525FA6C0E2841A259CB1,9541,1690435379416
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/SkillConfig.xlsx,AEABCC7B3C82616DA3B6A1A4CFE17288,26018,1690444887167
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/StringConfig.xlsx,83B75145F2724B31CCC786CF63EBC67,16576,1690444887222
|
||||
C:/Users/82158/Perforce/MiscNLD/config/Datas/SummonConfig.xlsx,C89E4F350F3E7ECB34463BBC44EE23,23513,1690444887240
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<root>
|
||||
|
||||
<topmodule name="cfg"/>
|
||||
|
||||
<patch name="cn"/>
|
||||
<patch name="en"/>
|
||||
|
||||
<group name="client" default="1"/> client
|
||||
<group name="server" default="1"/> server
|
||||
<group name="cehua" default="1"/> editor
|
||||
|
||||
<import name="."/>
|
||||
|
||||
<importexcel name="__tables__.xlsx" type="table"/> 相对data目录
|
||||
<importexcel name="__enums__.xlsx" type="enum"/>相对data目录
|
||||
<importexcel name="__beans__.xlsx" type="bean"/>相对data目录
|
||||
|
||||
<service name="server" manager="Tables" group="server"/>
|
||||
<service name="client" manager="Tables" group="client"/>
|
||||
<service name="cehua" manager="Tables" group="cehua"/>
|
||||
<service name="all" manager="Tables" group="server,client,cehua"/>
|
||||
</root>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,25 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
{{x.cpp_namespace_begin}}
|
||||
{{~if comment != '' ~}}
|
||||
/**
|
||||
* {{comment | html.escape}}
|
||||
*/
|
||||
{{~end~}}
|
||||
enum class {{name}}
|
||||
{
|
||||
{{~ for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
/**
|
||||
* {{item.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
{{item.name}} = {{item.value}},
|
||||
{{~end~}}
|
||||
};
|
||||
{{x.cpp_namespace_end}}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
{{~if comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{comment | html.escape}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
{{~if x.is_flags~}}
|
||||
[System.Flags]
|
||||
{{~end~}}
|
||||
public enum {{name}}
|
||||
{
|
||||
{{~ for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{item.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
{{item.name}} = {{item.value}},
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
enum {{x.flat_buffers_full_name}}:int {
|
||||
{{~if !x.has_zero_value_item~}}
|
||||
__GENERATE_DEFAULT_VALUE = 0,
|
||||
{{~end~}}
|
||||
{{~for item in items ~}}
|
||||
{{x.pb_full_name}}_{{item.name}} = {{item.int_value}},
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
{{~if comment != '' ~}}
|
||||
|
||||
# {{comment | html.escape}}
|
||||
{{~end~}}
|
||||
enum {{x.gdscript_full_name}}{
|
||||
{{~ for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
{{item.name}} = {{item.int_value}}, # {{item.escape_comment}}
|
||||
{{~else~}}
|
||||
{{item.name}} = {{item.int_value}},
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
package {{x.top_module}}
|
||||
|
||||
const (
|
||||
{{~for item in items ~}}
|
||||
{{x.go_full_name}}_{{item.name}} = {{item.int_value}}
|
||||
{{~end~}}
|
||||
)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
package {{namespace_with_top_module}};
|
||||
{{~if comment != '' ~}}
|
||||
/**
|
||||
* {{comment | html.escape}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public final class {{name}} {
|
||||
{{~ for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
/**
|
||||
* {{item.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public static final int {{item.name}} = {{item.int_value}};
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{
|
||||
enums = x.enums
|
||||
beans = x.beans
|
||||
tables = x.tables
|
||||
}}
|
||||
local setmetatable = setmetatable
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
local tinsert = table.insert
|
||||
|
||||
local function SimpleClass()
|
||||
local class = {}
|
||||
class.__index = class
|
||||
class.New = function(...)
|
||||
local ctor = class.ctor
|
||||
local o = ctor and ctor(...) or {}
|
||||
setmetatable(o, class)
|
||||
return o
|
||||
end
|
||||
return class
|
||||
end
|
||||
|
||||
|
||||
local function get_map_size(m)
|
||||
local n = 0
|
||||
for _ in pairs(m) do
|
||||
n = n + 1
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
enum {{x.pb_full_name}} {
|
||||
{{~for item in items ~}}
|
||||
{{x.pb_full_name}}_{{item.name}} = {{item.int_value}};
|
||||
{{~end~}}
|
||||
{{~if items.empty?}}
|
||||
{{x.pb_full_name}}_EMPTY_PLACEHOLDER = 0;
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
enum {{x.pb_full_name}} {
|
||||
{{~if items.empty? || items[0].int_value != 0~}}
|
||||
{{x.pb_full_name}}_EMPTY_PLACEHOLDER = 0;
|
||||
{{~end~}}
|
||||
{{~for item in items ~}}
|
||||
{{x.pb_full_name}}_{{item.name}} = {{item.int_value}};
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
{{~if comment != '' ~}}
|
||||
'''
|
||||
{{comment | html.escape}}
|
||||
'''
|
||||
{{~end~}}
|
||||
class {{x.py_full_name}}(Enum):
|
||||
{{~ for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
'''
|
||||
{{item.escape_comment}}
|
||||
'''
|
||||
{{~end~}}
|
||||
{{item.name}} = {{item.value}}
|
||||
{{~end~}}
|
||||
{{~if (items == empty)~}}
|
||||
pass
|
||||
{{~end~}}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
{{~if comment != '' ~}}
|
||||
/**
|
||||
* {{comment | html.escape}}
|
||||
*/
|
||||
{{~end~}}
|
||||
#[allow(dead_code)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum {{x.rust_full_name}} {
|
||||
{{~for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
/**
|
||||
* {{item.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
{{item.name}} = {{item.int_value}},
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace_with_top_module = x.namespace_with_top_module
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
~}}
|
||||
|
||||
{{x.typescript_namespace_begin}}
|
||||
{{~if comment != '' ~}}
|
||||
/**
|
||||
* {{comment | html.escape}}
|
||||
*/
|
||||
{{~end~}}
|
||||
export enum {{name}} {
|
||||
{{~for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
/**
|
||||
* {{item.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
{{item.name}} = {{item.value}},
|
||||
{{~end~}}
|
||||
}
|
||||
{{x.typescript_namespace_end}}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
|
||||
#include "bright/serialization/ByteBuf.h"
|
||||
#include "bright/CfgBean.hpp"
|
||||
|
||||
using ByteBuf = ::bright::serialization::ByteBuf;
|
||||
|
||||
namespace {{assembly.top_module}}
|
||||
{
|
||||
|
||||
{{~for e in x.enum_codes~}}
|
||||
{{e}}
|
||||
{{~end~}}
|
||||
|
||||
{{~for b in x.beans~}}
|
||||
{{b.cpp_namespace_begin}} class {{b.name}}; {{b.cpp_namespace_end}}
|
||||
{{~end~}}
|
||||
|
||||
{{~for b in x.bean_codes~}}
|
||||
{{b}}
|
||||
{{~end~}}
|
||||
|
||||
{{~for t in x.table_codes~}}
|
||||
{{t}}
|
||||
{{~end~}}
|
||||
|
||||
{{x.tables_code}}
|
||||
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
{{x.cpp_namespace_begin}}
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/**
|
||||
* {{x.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
class {{name}} : public {{if parent_def_type}} {{parent_def_type.cpp_full_name}} {{else}} bright::CfgBean {{end}}
|
||||
{
|
||||
public:
|
||||
|
||||
static bool deserialize{{name}}(ByteBuf& _buf, ::bright::SharedPtr<{{name}}>& _out);
|
||||
|
||||
{{name}}()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{{~if !hierarchy_export_fields.empty?~}}
|
||||
{{name}}({{- for field in hierarchy_export_fields }}{{cpp_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}})
|
||||
{{~if parent_def_type~}}
|
||||
: {{parent_def_type.cpp_full_name}}({{ for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}}, {{end}}{{end}})
|
||||
{{~end~}}
|
||||
{
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
this->{{field.convention_name}} = {{field.name}};
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
virtual ~{{name}}() {}
|
||||
|
||||
bool deserialize(ByteBuf& _buf);
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/**
|
||||
* {{field.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
{{cpp_define_type field.ctype}} {{field.convention_name}};
|
||||
{{~if field.index_field~}}
|
||||
::bright::HashMap<{{cpp_define_type field.index_field.ctype}}, {{cpp_define_type field.ctype.element_type}}> {{field.convention_name}}_Index;
|
||||
{{~end~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{field.cpp_ref_validator_define}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
{{~if !x.is_abstract_type~}}
|
||||
static constexpr int __ID__ = {{x.id}};
|
||||
|
||||
int getTypeId() const { return __ID__; }
|
||||
{{~end~}}
|
||||
|
||||
virtual void resolve(::bright::HashMap<::bright::String, void*>& _tables);
|
||||
};
|
||||
|
||||
{{x.cpp_namespace_end}}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#include <algorithm>
|
||||
#include "gen_types.h"
|
||||
|
||||
using ByteBuf = bright::serialization::ByteBuf;
|
||||
|
||||
namespace {{assembly.top_module}}
|
||||
{
|
||||
{{~for type in x.types~}}
|
||||
|
||||
bool {{type.cpp_full_name}}::deserialize(ByteBuf& _buf)
|
||||
{
|
||||
{{~if type.parent_def_type~}}
|
||||
if (!{{type.parent_def_type.cpp_full_name}}::deserialize(_buf))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
{{~end~}}
|
||||
|
||||
{{~ for field in type.export_fields ~}}
|
||||
{{cpp_deserialize '_buf' field.convention_name field.ctype}}
|
||||
{{~if field.index_field ~}}
|
||||
for(auto& _v : this->{{field.convention_name}})
|
||||
{
|
||||
{{field.convention_name}}_Index.insert({_v->{{field.index_field.convention_name}}, _v});
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool {{type.cpp_full_name}}::deserialize{{type.name}}(ByteBuf& _buf, ::bright::SharedPtr<{{type.cpp_full_name}}>& _out)
|
||||
{
|
||||
{{~if type.is_abstract_type~}}
|
||||
int id;
|
||||
if (!_buf.readInt(id)) return false;
|
||||
switch (id)
|
||||
{
|
||||
{{~for child in type.hierarchy_not_abstract_children~}}
|
||||
case {{child.cpp_full_name}}::__ID__: { _out.reset(new {{child.cpp_full_name}}()); if (_out->deserialize(_buf)) { return true; } else { _out.reset(); return false;} }
|
||||
{{~end~}}
|
||||
default: { _out = nullptr; return false;}
|
||||
}
|
||||
{{~else~}}
|
||||
_out.reset(new {{type.cpp_full_name}}());
|
||||
if (_out->deserialize(_buf))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_out.reset();
|
||||
return false;
|
||||
}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
void {{type.cpp_full_name}}::resolve(::bright::HashMap<::bright::String, void*>& _tables)
|
||||
{
|
||||
{{~if type.parent_def_type~}}
|
||||
{{type.parent_def_type.name}}::resolve(_tables);
|
||||
{{~end~}}
|
||||
{{~ for field in type.export_fields ~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{cpp_ref_validator_resolve field}}
|
||||
{{~else if field.has_recursive_ref~}}
|
||||
{{cpp_recursive_resolve field '_tables'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
{{x.cpp_namespace_begin}}
|
||||
|
||||
{{~
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
~}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/**
|
||||
* {{x.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
|
||||
class {{name}}
|
||||
{
|
||||
{{~if x.is_map_table ~}}
|
||||
private:
|
||||
::bright::HashMap<{{cpp_define_type key_type}}, {{cpp_define_type value_type}}> _dataMap;
|
||||
::bright::Vector<{{cpp_define_type value_type}}> _dataList;
|
||||
|
||||
public:
|
||||
bool load(ByteBuf& _buf)
|
||||
{
|
||||
int n;
|
||||
if (!_buf.readSize(n)) return false;
|
||||
for(; n > 0 ; --n)
|
||||
{
|
||||
{{cpp_define_type value_type}} _v;
|
||||
{{cpp_deserialize '_buf' '_v' value_type}}
|
||||
_dataList.push_back(_v);
|
||||
_dataMap[_v->{{x.index_field.convention_name}}] = _v;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const ::bright::HashMap<{{cpp_define_type key_type}}, {{cpp_define_type value_type}}>& getDataMap() const { return _dataMap; }
|
||||
const ::bright::Vector<{{cpp_define_type value_type}}>& getDataList() const { return _dataList; }
|
||||
|
||||
{{value_type.bean.cpp_full_name}}* getRaw({{cpp_define_type key_type}} key)
|
||||
{
|
||||
auto it = _dataMap.find(key);
|
||||
return it != _dataMap.end() ? it->second.get() : nullptr;
|
||||
}
|
||||
|
||||
{{cpp_define_type value_type}} get({{cpp_define_type key_type}} key)
|
||||
{
|
||||
auto it = _dataMap.find(key);
|
||||
return it != _dataMap.end() ? it->second : nullptr;
|
||||
}
|
||||
|
||||
void resolve(::bright::HashMap<::bright::String, void*>& _tables)
|
||||
{
|
||||
for(auto v : _dataList)
|
||||
{
|
||||
v->resolve(_tables);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else if x.is_list_table~}}
|
||||
private:
|
||||
::bright::Vector<{{cpp_define_type value_type}}> _dataList;
|
||||
{{~if x.is_union_index~}}
|
||||
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
::bright::HashMap<{{cpp_define_type idx.type}}, {{cpp_define_type value_type}}> _dataMap_{{idx.index_field.name}};
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
{{~end~}}
|
||||
|
||||
public:
|
||||
bool load(ByteBuf& _buf)
|
||||
{
|
||||
int n;
|
||||
if (!_buf.readSize(n)) return false;
|
||||
for(; n > 0 ; --n)
|
||||
{
|
||||
{{cpp_define_type value_type}} _v;
|
||||
{{cpp_deserialize '_buf' '_v' value_type}}
|
||||
_dataList.push_back(_v);
|
||||
{{~if x.is_union_index~}}
|
||||
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}}[_v->{{idx.index_field.name}}] = _v;
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
{{~end~}}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const ::bright::Vector<{{cpp_define_type value_type}}>& getDataList() const { return _dataList; }
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
::bright::HashMap<{{cpp_define_type idx.type}}, {{cpp_define_type value_type}}>& getDataMapBy{{idx.index_field.name}}()
|
||||
{
|
||||
return _dataMap_{{idx.index_field.name}};
|
||||
}
|
||||
{{value_type.bean.cpp_full_name}}* getRawBy{{idx.index_field.name}}({{cpp_define_type idx.type}} key)
|
||||
{
|
||||
auto it = _dataMap_{{idx.index_field.name}}.find(key);
|
||||
return it != _dataMap_{{idx.index_field.name}}.end() ? it->second.get() : nullptr;
|
||||
}
|
||||
{{cpp_define_type value_type}} getBy{{idx.index_field.name}}({{cpp_define_type idx.type}} key)
|
||||
{
|
||||
auto it = _dataMap_{{idx.index_field.name}}.find(key);
|
||||
return it != _dataMap_{{idx.index_field.name}}.end() ? it->second : nullptr;
|
||||
}
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
{{value_type.bean.cpp_full_name}}* getRaw(size_t index) const
|
||||
{
|
||||
return _dataList[index].get();
|
||||
}
|
||||
|
||||
{{cpp_define_type value_type}} get(size_t index) const
|
||||
{
|
||||
return _dataList[index];
|
||||
}
|
||||
{{~end~}}
|
||||
void resolve(::bright::HashMap<::bright::String, void*>& _tables)
|
||||
{
|
||||
for(auto v : _dataList)
|
||||
{
|
||||
v->resolve(_tables);
|
||||
}
|
||||
}
|
||||
{{~else~}}
|
||||
private:
|
||||
{{cpp_define_type value_type}} _data;
|
||||
|
||||
public:
|
||||
{{cpp_define_type value_type}} data() const { return _data; }
|
||||
|
||||
bool load(ByteBuf& _buf)
|
||||
{
|
||||
int n;
|
||||
if (!_buf.readSize(n)) return false;
|
||||
if (n != 1) return false;
|
||||
{{cpp_deserialize '_buf' '_data' value_type}}
|
||||
return true;
|
||||
}
|
||||
|
||||
void resolve(::bright::HashMap<::bright::String, void*>& _tables)
|
||||
{
|
||||
_data->resolve(_tables);
|
||||
}
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/**
|
||||
* {{field.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
{{cpp_define_type field.ctype}}& {{field.convention_getter_name}}() const { return _data->{{field.convention_name}}; }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
};
|
||||
{{x.cpp_namespace_end}}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{{~
|
||||
tables = x.tables
|
||||
name = x.name
|
||||
~}}
|
||||
class {{name}}
|
||||
{
|
||||
public:
|
||||
{{~for table in tables ~}}
|
||||
{{~if table.comment != '' ~}}
|
||||
/**
|
||||
* {{table.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
{{table.cpp_full_name}} {{table.name}};
|
||||
{{~end~}}
|
||||
|
||||
bool load(::bright::Loader<ByteBuf> loader)
|
||||
{
|
||||
::bright::HashMap<::bright::String, void*> __tables__;
|
||||
|
||||
ByteBuf buf;
|
||||
{{~for table in tables~}}
|
||||
if (!loader(buf, "{{table.output_data_file}}")) return false;
|
||||
if (!{{table.name}}.load(buf)) return false;
|
||||
__tables__["{{table.full_name}}"] = &{{table.name}};
|
||||
{{~end~}}
|
||||
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.resolve(__tables__);
|
||||
{{~end~}}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#pragma once
|
||||
#include ""CoreMinimal.h""
|
||||
#include ""UCfgObj.h""
|
||||
|
||||
|
||||
{{ue_bp_includes}}
|
||||
|
||||
#include ""{{ue_bp_header_file_name_without_suffix}}.generated.h""
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class X6PROTO_API {{ue_bp_full_name}} : public {{if parent_def_type}} {{parent_def_type.ue_bp_full_name}} {{else}} UCfgObj {{end}}
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
|
||||
{{~for field in export_fields ~}}
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = ""{{field.name}}""))
|
||||
{{field.ctype.ue_bp_cpp_define_type}} {{field.name}};
|
||||
{{~end~}}
|
||||
};
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#pragma once
|
||||
#include ""CoreMinimal.h""
|
||||
|
||||
#include ""{{ue_bp_header_file_name_without_suffix}}.generated.h""
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class {{ue_bp_full_name}} : uint8
|
||||
{
|
||||
{{~if !contains_value_equal0_item~}}
|
||||
__DEFAULT__ = 0,
|
||||
{{~end~}}
|
||||
{{~if contains_any_ue_enum_compatible_item~}}
|
||||
{{~for item in items ~}}
|
||||
{{if item.int_value >= 256}}//{{end}}{{item.name}} = {{item.value}} UMETA(DisplayName = ""{{item.alias_or_name}}""),
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
DUMMY UMETA(DisplayName = ""DUMMY""),
|
||||
{{~end~}}
|
||||
};
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#pragma once
|
||||
#include ""CoreMinimal.h""
|
||||
#include ""FCfgObj.h""
|
||||
|
||||
{{editor_cpp_includes}}
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
||||
{{cpp_namespace_begin}}
|
||||
|
||||
struct X6PROTOEDITOR_API {{ue_fname}} : public {{if parent_def_type}} {{parent_def_type.ue_fname}}{{else}}FCfgObj{{end}}
|
||||
{
|
||||
{{~for field in fields ~}}
|
||||
{{field.ctype.editor_ue_cpp_define_type}} {{field.name}};
|
||||
{{~end~}}
|
||||
|
||||
{{~if !is_abstract_type~}}
|
||||
bool Load(FJsonObject* _json) override;
|
||||
bool Save(FJsonObject*& result) override;
|
||||
{{~end~}}
|
||||
|
||||
static bool Create(FJsonObject* _json, {{ue_fname}}*& result);
|
||||
};
|
||||
|
||||
|
||||
{{cpp_namespace_end}}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#pragma once
|
||||
#include ""CoreMinimal.h""
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
||||
{{cpp_namespace_begin}}
|
||||
|
||||
enum class {{ue_fname}}
|
||||
{
|
||||
{{~for item in items ~}}
|
||||
{{item.name}} = {{item.value}},
|
||||
{{~end~}}
|
||||
};
|
||||
|
||||
bool X6PROTOEDITOR_API {{ue_fname}}ToString({{ue_fname}} value, FString& s);
|
||||
bool X6PROTOEDITOR_API {{ue_fname}}FromString(const FString& s, {{ue_fname}}& x);
|
||||
|
||||
{{cpp_namespace_end}}
|
||||
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
#include ""JsonUtil.h""
|
||||
|
||||
{{includes}}
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
||||
{{~for type in types~}}
|
||||
{{type.cpp_namespace_begin}}
|
||||
{{~if type.is_bean~}}
|
||||
{{~if type.is_abstract_type~}}
|
||||
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
||||
{
|
||||
FString type;
|
||||
if (_json->TryGetStringField(FString(""{{type.json_type_name_key}}""), type))
|
||||
{
|
||||
{{~for child in type.hierarchy_not_abstract_children~}}
|
||||
if (type == ""{{cs_impl_data_type child x}}"")
|
||||
{
|
||||
result = new {{child.ue_fname}}();
|
||||
} else
|
||||
{{~end~}}
|
||||
{
|
||||
result = nullptr;
|
||||
return false;
|
||||
}
|
||||
if (!result->Load(_json))
|
||||
{
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{{~else~}}
|
||||
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
||||
{
|
||||
result = new {{type.ue_fname}}();
|
||||
if (!result->Load(_json))
|
||||
{
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool {{type.ue_fname}}::Save(FJsonObject*& result)
|
||||
{
|
||||
auto _json = new FJsonObject();
|
||||
_json->SetStringField(""{{type.json_type_name_key}}"", ""{{type.name}}"");
|
||||
|
||||
{{~for field in type.hierarchy_fields~}}
|
||||
{{field.editor_ue_cpp_save}}
|
||||
{{~end~}}
|
||||
result = _json;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool {{type.ue_fname}}::Load(FJsonObject* _json)
|
||||
{
|
||||
{{~for field in type.hierarchy_fields~}}
|
||||
{{field.editor_ue_cpp_load}}
|
||||
{{~end~}}
|
||||
return true;
|
||||
}
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
|
||||
bool {{type.ue_fname}}ToString({{type.ue_fname}} value, FString& s)
|
||||
{
|
||||
{{~for item in type.items ~}}
|
||||
if (value == {{type.ue_fname}}::{{item.name}}) { s = ""{{item.name}}""; return true; }
|
||||
{{~end~}}
|
||||
return false;
|
||||
}
|
||||
bool {{type.ue_fname}}FromString(const FString& s, {{type.ue_fname}}& value)
|
||||
{
|
||||
{{~for item in type.items ~}}
|
||||
if (s == ""{{item.name}}"")
|
||||
{
|
||||
value = {{type.ue_fname}}::{{item.name}};
|
||||
return true;
|
||||
}
|
||||
{{~end~}}
|
||||
return false;
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
{{type.cpp_namespace_end}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{x.parent}} {{else}} Bright.Config.BeanBase {{end}}
|
||||
{
|
||||
public {{name}}(ByteBuf _buf) {{if parent_def_type}} : base(_buf) {{end}}
|
||||
{
|
||||
{{~ for field in export_fields ~}}
|
||||
{{cs_deserialize '_buf' field.convention_name field.ctype}}
|
||||
{{~if field.index_field~}}
|
||||
foreach(var _v in {{field.convention_name}})
|
||||
{
|
||||
{{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v);
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static {{name}} Deserialize{{name}}(ByteBuf _buf)
|
||||
{
|
||||
{{~if x.is_abstract_type~}}
|
||||
switch (_buf.ReadInt())
|
||||
{
|
||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||
case {{child.full_name}}.__ID__: return new {{child.full_name}}(_buf);
|
||||
{{~end~}}
|
||||
default: throw new SerializationException();
|
||||
}
|
||||
{{~else~}}
|
||||
return new {{x.full_name}}(_buf);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; }
|
||||
{{~if field.index_field~}}
|
||||
public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>();
|
||||
{{~end~}}
|
||||
{{~if field.gen_ref~}}
|
||||
public {{field.cs_ref_validator_define}}
|
||||
{{~end~}}
|
||||
{{~if (gen_datetime_mills field.ctype) ~}}
|
||||
public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L;
|
||||
{{~end~}}
|
||||
{{~if field.gen_text_key~}}
|
||||
public {{cs_define_text_key_field field}} { get; }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
{{~if !x.is_abstract_type~}}
|
||||
public const int __ID__ = {{x.id}};
|
||||
public override int GetTypeId() => __ID__;
|
||||
{{~end~}}
|
||||
|
||||
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
{{~if parent_def_type~}}
|
||||
base.Resolve(_tables);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{cs_ref_validator_resolve field}}
|
||||
{{~else if field.has_recursive_ref~}}
|
||||
{{cs_recursive_resolve field '_tables'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public {{x.cs_method_modifier}} void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
{{~if parent_def_type~}}
|
||||
base.TranslateText(translator);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_text_key~}}
|
||||
{{cs_translate_text field 'translator'}}
|
||||
{{~else if field.has_recursive_text~}}
|
||||
{{cs_recursive_translate_text field 'translator'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{full_name}}{ "
|
||||
{{~for field in hierarchy_export_fields ~}}
|
||||
+ "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + ","
|
||||
{{~end~}}
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
{{
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
}}
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public partial class {{name}}
|
||||
{
|
||||
{{~if x.is_map_table ~}}
|
||||
private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
|
||||
private readonly List<{{cs_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(ByteBuf _buf)
|
||||
{
|
||||
_dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
|
||||
_dataList = new List<{{cs_define_type value_type}}>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
{{cs_define_type value_type}} _v;
|
||||
{{cs_deserialize '_buf' '_v' value_type}}
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
|
||||
public List<{{cs_define_type value_type}}> DataList => _dataList;
|
||||
|
||||
{{~if value_type.is_dynamic~}}
|
||||
public T GetOrDefaultAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
|
||||
public T GetAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
|
||||
{{~end~}}
|
||||
public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) => _dataMap[key];
|
||||
public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
{{~else if x.is_list_table ~}}
|
||||
private readonly List<{{cs_define_type value_type}}> _dataList;
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
private {{cs_table_union_map_type_name x}} _dataMapUnion;
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(ByteBuf _buf)
|
||||
{
|
||||
_dataList = new List<{{cs_define_type value_type}}>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
{{cs_define_type value_type}} _v;
|
||||
{{cs_deserialize '_buf' '_v' value_type}}
|
||||
_dataList.Add(_v);
|
||||
}
|
||||
{{~if x.is_union_index~}}
|
||||
_dataMapUnion = new {{cs_table_union_map_type_name x}}();
|
||||
foreach(var _v in _dataList)
|
||||
{
|
||||
_dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
|
||||
}
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>();
|
||||
{{~end~}}
|
||||
foreach(var _v in _dataList)
|
||||
{
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
public List<{{cs_define_type value_type}}> DataList => _dataList;
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
|
||||
{{~else if !x.index_list.empty? ~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
{{~else~}}
|
||||
|
||||
private readonly {{cs_define_type value_type}} _data;
|
||||
|
||||
public {{name}}(ByteBuf _buf)
|
||||
{
|
||||
int n = _buf.ReadSize();
|
||||
if (n != 1) throw new SerializationException("table mode=one, but size != 1");
|
||||
{{cs_deserialize '_buf' '_data' value_type}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}};
|
||||
{{~end~}}
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
_data.Resolve(_tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
_data.TranslateText(translator);
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace}}
|
||||
public partial class {{name}}
|
||||
{
|
||||
{{~for table in tables ~}}
|
||||
{{~if table.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{table.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{table.full_name}} {{table.name}} {get; }
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(System.Func<string, ByteBuf> loader)
|
||||
{
|
||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}} = new {{table.full_name}}(loader("{{table.output_data_file}}"));
|
||||
tables.Add("{{table.full_name}}", {{table.name}});
|
||||
{{~end~}}
|
||||
|
||||
PostInit();
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.Resolve(tables);
|
||||
{{~end~}}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.TranslateText(translator);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace}}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
parent = x.parent
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{parent}} {{else}} Bright.Config.BeanBase {{end}}
|
||||
{
|
||||
public {{name}}(JsonElement _json) {{if parent_def_type}} : base(_json) {{end}}
|
||||
{
|
||||
{{~ for field in export_fields ~}}
|
||||
{{cs_json_deserialize '_json' field.convention_name field.name field.ctype}}
|
||||
{{~if field.index_field~}}
|
||||
foreach(var _v in {{field.convention_name}}) { {{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v); }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public {{name}}({{~for field in hierarchy_export_fields }}{{cs_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) {{if parent_def_type}} : base({{- for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}},{{end}}{{end}}) {{end}}
|
||||
{
|
||||
{{~ for field in export_fields ~}}
|
||||
this.{{field.convention_name}} = {{field.name}};
|
||||
{{~if field.index_field~}}
|
||||
foreach(var _v in {{field.convention_name}}) { {{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v); }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static {{name}} Deserialize{{name}}(JsonElement _json)
|
||||
{
|
||||
{{~if x.is_abstract_type~}}
|
||||
switch (_json.GetProperty("{{x.json_type_name_key}}").GetString())
|
||||
{
|
||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||
case "{{cs_impl_data_type child x}}": return new {{child.full_name}}(_json);
|
||||
{{~end~}}
|
||||
default: throw new SerializationException();
|
||||
}
|
||||
{{~else~}}
|
||||
return new {{x.full_name}}(_json);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; }
|
||||
{{~if field.index_field~}}
|
||||
public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>();
|
||||
{{~end~}}
|
||||
{{~if field.gen_ref~}}
|
||||
public {{field.cs_ref_validator_define}}
|
||||
{{~end~}}
|
||||
{{~if (gen_datetime_mills field.ctype) ~}}
|
||||
public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L;
|
||||
{{~end~}}
|
||||
{{~if field.gen_text_key~}}
|
||||
public {{cs_define_text_key_field field}} { get; }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
{{~if !x.is_abstract_type~}}
|
||||
public const int __ID__ = {{x.id}};
|
||||
public override int GetTypeId() => __ID__;
|
||||
{{~end~}}
|
||||
|
||||
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
{{~if parent_def_type~}}
|
||||
base.Resolve(_tables);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{cs_ref_validator_resolve field}}
|
||||
{{~else if field.has_recursive_ref~}}
|
||||
{{cs_recursive_resolve field '_tables'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public {{x.cs_method_modifier}} void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
{{~if parent_def_type~}}
|
||||
base.TranslateText(translator);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_text_key~}}
|
||||
{{cs_translate_text field 'translator'}}
|
||||
{{~else if field.has_recursive_text~}}
|
||||
{{cs_recursive_translate_text field 'translator'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{full_name}}{ "
|
||||
{{~ for field in hierarchy_export_fields ~}}
|
||||
+ "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + ","
|
||||
{{~end~}}
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public sealed partial class {{name}}
|
||||
{
|
||||
{{~if x.is_map_table ~}}
|
||||
private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
|
||||
private readonly List<{{cs_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(JsonElement _json)
|
||||
{
|
||||
_dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
|
||||
_dataList = new List<{{cs_define_type value_type}}>();
|
||||
|
||||
foreach(JsonElement _row in _json.EnumerateArray())
|
||||
{
|
||||
var _v = {{cs_define_type value_type}}.Deserialize{{value_type.bean.name}}(_row);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
|
||||
public List<{{cs_define_type value_type}}> DataList => _dataList;
|
||||
|
||||
{{~if value_type.is_dynamic~}}
|
||||
public T GetOrDefaultAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
|
||||
public T GetAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
|
||||
{{~end~}}
|
||||
public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) => _dataMap[key];
|
||||
public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else if x.is_list_table ~}}
|
||||
private readonly List<{{cs_define_type value_type}}> _dataList;
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
private {{cs_table_union_map_type_name x}} _dataMapUnion;
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(JsonElement _json)
|
||||
{
|
||||
_dataList = new List<{{cs_define_type value_type}}>();
|
||||
|
||||
foreach(JsonElement _row in _json.EnumerateArray())
|
||||
{
|
||||
var _v = {{cs_define_type value_type}}.Deserialize{{value_type.bean.name}}(_row);
|
||||
_dataList.Add(_v);
|
||||
}
|
||||
{{~if x.is_union_index~}}
|
||||
_dataMapUnion = new {{cs_table_union_map_type_name x}}();
|
||||
foreach(var _v in _dataList)
|
||||
{
|
||||
_dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
|
||||
}
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>();
|
||||
{{~end~}}
|
||||
foreach(var _v in _dataList)
|
||||
{
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public List<{{cs_define_type value_type}}> DataList => _dataList;
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
|
||||
{{~else if !x.index_list.empty? ~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
{{~else~}}
|
||||
|
||||
private readonly {{cs_define_type value_type}} _data;
|
||||
|
||||
public {{name}}(JsonElement _json)
|
||||
{
|
||||
int n = _json.GetArrayLength();
|
||||
if (n != 1) throw new SerializationException("table mode=one, but size != 1");
|
||||
_data = {{cs_define_type value_type}}.Deserialize{{value_type.bean.name}}(_json[0]);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}};
|
||||
{{~end~}}
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
_data.Resolve(_tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
_data.TranslateText(translator);
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Text.Json;
|
||||
{{
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
}}
|
||||
{{cs_start_name_space_grace x.namespace}}
|
||||
|
||||
|
||||
public sealed partial class {{name}}
|
||||
{
|
||||
{{~for table in tables ~}}
|
||||
{{~if table.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{table.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{table.full_name}} {{table.name}} {get; }
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(System.Func<string, JsonElement> loader)
|
||||
{
|
||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}} = new {{table.full_name}}(loader("{{table.output_data_file}}"));
|
||||
tables.Add("{{table.full_name}}", {{table.name}});
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.Resolve(tables);
|
||||
{{~end~}}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.TranslateText(translator);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace}}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using SimpleJSON;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
parent = x.parent
|
||||
hierarchy_fields = x.hierarchy_fields
|
||||
fields = x.fields
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_editor_top_module}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{parent}} {{else}} Bright.Config.EditorBeanBase {{end}}
|
||||
{
|
||||
public {{name}}()
|
||||
{
|
||||
{{~ for field in fields ~}}
|
||||
{{~if (cs_editor_need_init field.ctype) && !field.ctype.is_nullable ~}}
|
||||
{{field.convention_name}} = {{cs_editor_init_value field.ctype}};
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{~if !x.is_abstract_type~}}
|
||||
public override void LoadJson(SimpleJSON.JSONObject _json)
|
||||
{
|
||||
{{~ for field in hierarchy_fields ~}}
|
||||
{
|
||||
var _fieldJson = _json["{{field.name}}"];
|
||||
if (_fieldJson != null)
|
||||
{
|
||||
{{cs_unity_editor_json_load '_fieldJson' field.convention_name field.ctype}}
|
||||
}
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public override void SaveJson(SimpleJSON.JSONObject _json)
|
||||
{
|
||||
{{~if parent~}}
|
||||
_json["{{x.json_type_name_key}}"] = "{{x.full_name}}";
|
||||
{{~end~}}
|
||||
{{~ for field in hierarchy_fields ~}}
|
||||
{{~if field.ctype.is_nullable}}
|
||||
if ({{field.convention_name}} != null)
|
||||
{
|
||||
{{cs_unity_editor_json_save '_json' field.name field.convention_name field.ctype}}
|
||||
}
|
||||
{{~else~}}
|
||||
{
|
||||
{{~if (cs_is_editor_raw_nullable field.ctype)}}
|
||||
if ({{field.convention_name}} == null) { throw new System.ArgumentNullException(); }
|
||||
{{~end~}}
|
||||
{{cs_unity_editor_json_save '_json' field.name field.convention_name field.ctype}}
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
|
||||
public static {{name}} LoadJson{{name}}(SimpleJSON.JSONNode _json)
|
||||
{
|
||||
{{~if x.is_abstract_type~}}
|
||||
string type = _json["{{x.json_type_name_key}}"];
|
||||
{{name}} obj;
|
||||
switch (type)
|
||||
{
|
||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||
{{~if child.namespace == x.namespace && x.namespace != '' ~}}
|
||||
case "{{child.full_name}}":
|
||||
{{~end~}}
|
||||
case "{{cs_impl_data_type child x}}":obj = new {{child.full_name}}(); break;
|
||||
{{~end~}}
|
||||
default: throw new SerializationException();
|
||||
}
|
||||
{{~else~}}
|
||||
{{name}} obj = new {{x.full_name}}();
|
||||
{{~end~}}
|
||||
obj.LoadJson((SimpleJSON.JSONObject)_json);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static void SaveJson{{name}}({{name}} _obj, SimpleJSON.JSONNode _json)
|
||||
{
|
||||
{{~if x.is_abstract_type~}}
|
||||
_json["{{x.json_type_name_key}}"] = _obj.GetType().Name;
|
||||
{{~end~}}
|
||||
_obj.SaveJson((SimpleJSON.JSONObject)_json);
|
||||
}
|
||||
|
||||
{{~ for field in fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_editor_define_type field.ctype}} {{field.convention_name}} { get; set; }
|
||||
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_editor_top_module}}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
comment = x.comment
|
||||
items = x.items
|
||||
itemType = 'Bright.Config.EditorEnumItemInfo'
|
||||
~}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_editor_top_module}}
|
||||
{{~if comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{comment | html.escape}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
{{~if x.is_flags~}}
|
||||
[System.Flags]
|
||||
{{~end~}}
|
||||
public enum {{name}}
|
||||
{
|
||||
{{~ for item in items ~}}
|
||||
{{~if item.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{item.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
{{item.name}} = {{item.value}},
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public static partial class {{name}}_Metadata
|
||||
{
|
||||
{{~ for item in items ~}}
|
||||
public static readonly {{itemType}} {{item.name}} = new {{itemType}}("{{item.name}}", "{{item.alias}}", {{item.int_value}}, "{{item.comment}}");
|
||||
{{~end~}}
|
||||
|
||||
private static readonly System.Collections.Generic.List<{{itemType}}> __items = new System.Collections.Generic.List<{{itemType}}>
|
||||
{
|
||||
{{~ for item in items ~}}
|
||||
{{item.name}},
|
||||
{{~end~}}
|
||||
};
|
||||
|
||||
public static System.Collections.Generic.List<{{itemType}}> GetItems() => __items;
|
||||
|
||||
public static {{itemType}} GetByName(string name)
|
||||
{
|
||||
return __items.Find(c => c.Name == name);
|
||||
}
|
||||
|
||||
public static {{itemType}} GetByNameOrAlias(string name)
|
||||
{
|
||||
return __items.Find(c => c.Name == name || c.Alias == name);
|
||||
}
|
||||
|
||||
public static {{itemType}} GetByValue(int value)
|
||||
{
|
||||
return __items.Find(c => c.Value == value);
|
||||
}
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_editor_top_module}}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using SimpleJSON;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
parent = x.parent
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{parent}} {{else}} Bright.Config.BeanBase {{end}}
|
||||
{
|
||||
public {{name}}(JSONNode _json) {{if parent_def_type}} : base(_json) {{end}}
|
||||
{
|
||||
{{~ for field in export_fields ~}}
|
||||
{{cs_unity_json_deserialize '_json' field.convention_name field.name field.ctype}}
|
||||
{{~if field.index_field~}}
|
||||
foreach(var _v in {{field.convention_name}}) { {{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v); }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public {{name}}({{~for field in hierarchy_export_fields }}{{cs_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) {{if parent_def_type}} : base({{- for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}},{{end}}{{end}}) {{end}}
|
||||
{
|
||||
{{~ for field in export_fields ~}}
|
||||
this.{{field.convention_name}} = {{field.name}};
|
||||
{{~if field.index_field~}}
|
||||
foreach(var _v in {{field.convention_name}}) { {{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v); }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public static {{name}} Deserialize{{name}}(JSONNode _json)
|
||||
{
|
||||
{{~if x.is_abstract_type~}}
|
||||
string type = _json["{{x.json_type_name_key}}"];
|
||||
switch (type)
|
||||
{
|
||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||
case "{{cs_impl_data_type child x}}": return new {{child.full_name}}(_json);
|
||||
{{~end~}}
|
||||
default: throw new SerializationException();
|
||||
}
|
||||
{{~else~}}
|
||||
return new {{x.full_name}}(_json);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; }
|
||||
{{~if field.index_field~}}
|
||||
public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>();
|
||||
{{~end~}}
|
||||
{{~if field.gen_ref~}}
|
||||
public {{field.cs_ref_validator_define}}
|
||||
{{~end~}}
|
||||
{{~if (gen_datetime_mills field.ctype) ~}}
|
||||
public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L;
|
||||
{{~end~}}
|
||||
{{~if field.gen_text_key~}}
|
||||
public {{cs_define_text_key_field field}} { get; }
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
{{~if !x.is_abstract_type~}}
|
||||
public const int __ID__ = {{x.id}};
|
||||
public override int GetTypeId() => __ID__;
|
||||
{{~end~}}
|
||||
|
||||
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
{{~if parent_def_type~}}
|
||||
base.Resolve(_tables);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{cs_ref_validator_resolve field}}
|
||||
{{~else if field.has_recursive_ref~}}
|
||||
{{cs_recursive_resolve field '_tables'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public {{x.cs_method_modifier}} void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
{{~if parent_def_type~}}
|
||||
base.TranslateText(translator);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_text_key~}}
|
||||
{{cs_translate_text field 'translator'}}
|
||||
{{~else if field.has_recursive_text~}}
|
||||
{{cs_recursive_translate_text field 'translator'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{full_name}}{ "
|
||||
{{~ for field in hierarchy_export_fields ~}}
|
||||
+ "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + ","
|
||||
{{~end~}}
|
||||
+ "}";
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using SimpleJSON;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace_with_top_module}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{x.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public sealed partial class {{name}}
|
||||
{
|
||||
{{~if x.is_map_table ~}}
|
||||
private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
|
||||
private readonly List<{{cs_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(JSONNode _json)
|
||||
{
|
||||
_dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
|
||||
_dataList = new List<{{cs_define_type value_type}}>();
|
||||
|
||||
foreach(JSONNode _row in _json.Children)
|
||||
{
|
||||
var _v = {{cs_define_type value_type}}.Deserialize{{value_type.bean.name}}(_row);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
|
||||
public List<{{cs_define_type value_type}}> DataList => _dataList;
|
||||
|
||||
{{~if value_type.is_dynamic~}}
|
||||
public T GetOrDefaultAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
|
||||
public T GetAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
|
||||
{{~end~}}
|
||||
public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) {
|
||||
if (_dataMap.TryGetValue(key, out var v)) {
|
||||
return v;
|
||||
} else {
|
||||
UnityEngine.Debug.LogError($"table {{name}} key not found: {key}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else if x.is_list_table ~}}
|
||||
private readonly List<{{cs_define_type value_type}}> _dataList;
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
private {{cs_table_union_map_type_name x}} _dataMapUnion;
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(JSONNode _json)
|
||||
{
|
||||
_dataList = new List<{{cs_define_type value_type}}>();
|
||||
|
||||
foreach(JSONNode _row in _json.Children)
|
||||
{
|
||||
var _v = {{cs_define_type value_type}}.Deserialize{{value_type.bean.name}}(_row);
|
||||
_dataList.Add(_v);
|
||||
}
|
||||
{{~if x.is_union_index~}}
|
||||
_dataMapUnion = new {{cs_table_union_map_type_name x}}();
|
||||
foreach(var _v in _dataList)
|
||||
{
|
||||
_dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
|
||||
}
|
||||
{{~else if !x.index_list.empty?~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>();
|
||||
{{~end~}}
|
||||
foreach(var _v in _dataList)
|
||||
{
|
||||
{{~for idx in x.index_list~}}
|
||||
_dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public List<{{cs_define_type value_type}}> DataList => _dataList;
|
||||
|
||||
{{~if x.is_union_index~}}
|
||||
public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
|
||||
{{~else if !x.index_list.empty? ~}}
|
||||
{{~for idx in x.index_list~}}
|
||||
public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else~}}
|
||||
|
||||
private readonly {{cs_define_type value_type}} _data;
|
||||
|
||||
public {{name}}(JSONNode _json)
|
||||
{
|
||||
if(!_json.IsArray)
|
||||
{
|
||||
throw new SerializationException();
|
||||
}
|
||||
if (_json.Count != 1) throw new SerializationException("table mode=one, but size != 1");
|
||||
_data = {{cs_define_type value_type}}.Deserialize{{value_type.bean.name}}(_json[0]);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{field.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}};
|
||||
{{~end~}}
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
_data.Resolve(_tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
_data.TranslateText(translator);
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace_with_top_module}}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
using Bright.Serialization;
|
||||
using SimpleJSON;
|
||||
using Framework;
|
||||
using System;
|
||||
{{
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
}}
|
||||
|
||||
{{cs_start_name_space_grace x.namespace}}
|
||||
|
||||
public sealed partial class {{name}}
|
||||
{
|
||||
{{~for table in tables ~}}
|
||||
{{~if table.comment != '' ~}}
|
||||
/// <summary>
|
||||
/// {{table.escape_comment}}
|
||||
/// </summary>
|
||||
{{~end~}}
|
||||
public {{table.full_name}} {{table.name}} {get; }
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(System.Func<string, JSONNode> loader)
|
||||
{
|
||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}} = new {{table.full_name}}(loader("{{table.output_data_file}}"));
|
||||
tables.Add("{{table.full_name}}", {{table.name}});
|
||||
{{~end~}}
|
||||
PostInit();
|
||||
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.Resolve(tables);
|
||||
{{~end~}}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public static void PostPreload(Action<string> loader) {
|
||||
{{~for table in tables ~}}
|
||||
loader("{{table.output_data_file}}");
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public static void AfterLoaded(Action<string> loader) {
|
||||
{{~for table in tables ~}}
|
||||
loader("{{table.output_data_file}}");
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}}.TranslateText(translator);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
{{cs_end_name_space_grace x.namespace}}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
namespace {{x.namespace}};
|
||||
|
||||
// luban internal types begin
|
||||
struct Vector2 {
|
||||
x:float;
|
||||
y:float;
|
||||
}
|
||||
|
||||
struct Vector3 {
|
||||
x:float;
|
||||
y:float;
|
||||
z:float;
|
||||
}
|
||||
|
||||
struct Vector4 {
|
||||
x:float;
|
||||
y:float;
|
||||
z:float;
|
||||
w:float;
|
||||
}
|
||||
// luban internal types end
|
||||
|
||||
{{~for enum in x.enums ~}}
|
||||
{{enum}}
|
||||
{{~end~}}
|
||||
|
||||
{{~for bean in x.beans~}}
|
||||
{{bean}}
|
||||
{{~end~}}
|
||||
|
||||
{{~for map in x.maps~}}
|
||||
table KeyValue_{{flat_buffers_define_type map.key_type}}_{{flat_buffers_define_type map.value_type}} {
|
||||
key: {{flat_buffers_define_type map.key_type}}{{flat_buffers_type_metadata map.key_type}};
|
||||
value: {{flat_buffers_define_type map.value_type}}{{flat_buffers_type_metadata map.value_type}};
|
||||
}
|
||||
{{~end~}}
|
||||
|
||||
{{~for table in x.tables~}}
|
||||
{{table}}
|
||||
{{~end~}}
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
~}}
|
||||
|
||||
{{~if x.is_abstract_type ~}}
|
||||
union {{x.flat_buffers_full_name}} {
|
||||
{{~for c in x.hierarchy_not_abstract_children~}}
|
||||
{{c.flat_buffers_full_name}},
|
||||
{{~end~}}
|
||||
}
|
||||
{{~else~}}
|
||||
table {{x.flat_buffers_full_name}} {
|
||||
{{~for f in hierarchy_export_fields ~}}
|
||||
{{f.name}}:{{flat_buffers_define_type f.ctype}}{{flat_buffers_type_metadata f.ctype}};
|
||||
{{~end~}}
|
||||
}
|
||||
{{~end~}}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
|
||||
echo off
|
||||
|
||||
set FLATC=%1
|
||||
set SCHEMA_FILE=%2
|
||||
set DATA_DIR=%3
|
||||
set OUTPUT_DIR=%4
|
||||
|
||||
{{~for table in tables~}}
|
||||
%FLATC% -o %OUTPUT_DIR% -b %SCHEMA_FILE% --root-type {{if namespace != ''}}{{namespace}}.{{end}}{{table.flat_buffers_full_name}} %DATA_DIR%\{{table.output_data_file}}.json
|
||||
{{~end~}}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
|
||||
@echo off
|
||||
|
||||
FLATC=$1
|
||||
SCHEMA_FILE=$2
|
||||
DATA_DIR=$3
|
||||
OUTPUT_DIR=$4
|
||||
|
||||
{{~for table in tables~}}
|
||||
$FLATC -o $OUTPUT_DIR -b $SCHEMA_FILE --root-type {{if namespace != ''}}{{namespace}}.{{end}}{{table.flat_buffers_full_name}} $DATA_DIR/{{table.output_data_file}}.json
|
||||
{{~end~}}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
value_type = x.value_ttype
|
||||
~}}
|
||||
|
||||
table {{x.flat_buffers_full_name}} {
|
||||
// WARN! The name 'data_list' is used by FlatBuffersJsonExporter. don't modify it!
|
||||
data_list:[{{flat_buffers_define_type value_type}}](required);
|
||||
}
|
||||
|
||||
root_type {{x.flat_buffers_full_name}};
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
{{
|
||||
name = x.gdscript_full_name
|
||||
is_abstract_type = x.is_abstract_type
|
||||
parent_def_type = x.parent_def_type
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
class {{name}}:
|
||||
{{if parent_def_type}}
|
||||
extends {{parent_def_type.gdscript_full_name}}
|
||||
{{end}}
|
||||
{{~if x.is_abstract_type~}}
|
||||
static func from_json(_json_):
|
||||
var type = _json_['{{x.json_type_name_key}}']
|
||||
match type:
|
||||
{{~ for child in x.hierarchy_not_abstract_children~}}
|
||||
"{{cs_impl_data_type child x}}":
|
||||
return {{child.gdscript_full_name}}.new(_json_)
|
||||
{{~end~}}
|
||||
_:
|
||||
assert(false)
|
||||
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
var {{field.convention_name}}
|
||||
{{~end~}}
|
||||
{{~if parent_def_type~}}
|
||||
func _init(_json_).(_json_) -> void:
|
||||
{{~else~}}
|
||||
func _init(_json_) -> void:
|
||||
{{~end~}}
|
||||
{{~if export_fields~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{gdscript_deserialize_field ('self.' + field.convention_name) '_json_' field.name field.ctype}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
{{~if export_fields.empty?}}
|
||||
pass
|
||||
{{~end~}}
|
||||
|
|
@ -1 +0,0 @@
|
|||
class_name Types
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
{{
|
||||
name = x.gdscript_full_name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
}}
|
||||
class {{name}}:
|
||||
{{~if x.is_map_table ~}}
|
||||
var _data_map = {}
|
||||
var _data_list = []
|
||||
|
||||
func _init(_json_) -> void:
|
||||
self._data_map = {}
|
||||
self._data_list = []
|
||||
|
||||
for _json2_ in _json_:
|
||||
var _v
|
||||
{{gdscript_deserialize_value '_v' '_json2_' value_type}}
|
||||
self._data_list.append(_v)
|
||||
self._data_map[_v.{{x.index_field.convention_name}}] = _v
|
||||
|
||||
func get_data_map() -> Dictionary:
|
||||
return self._data_map
|
||||
func get_data_list() -> Array:
|
||||
return self._data_list
|
||||
|
||||
func get(key):
|
||||
return self._data_map.get(key)
|
||||
{{~else if x.multi_key ~}}
|
||||
{{~ for INDEX in x.index_list ~}}
|
||||
var _data_{{INDEX.index_field.convention_name}}_map = {}
|
||||
{{~ end ~}}
|
||||
var _data_list = []
|
||||
|
||||
func _init(_json_) -> void:
|
||||
{{~ for INDEX in x.index_list ~}}
|
||||
self._data_{{INDEX.index_field.convention_name}}_map = {}
|
||||
{{~ end ~}}
|
||||
self._data_list = []
|
||||
|
||||
for _json2_ in _json_:
|
||||
var _v
|
||||
{{gdscript_deserialize_value '_v' '_json2_' value_type}}
|
||||
self._data_list.append(_v)
|
||||
{{~ for INDEX in x.index_list ~}}
|
||||
self._data_{{INDEX.index_field.convention_name}}_map[_v.{{INDEX.index_field.convention_name}}] = _v
|
||||
{{~ end ~}}
|
||||
|
||||
func get_data_map() -> Dictionary:
|
||||
return self._data_{{x.index_field.convention_name }}_map
|
||||
func get_data_list() -> Array:
|
||||
return self._data_list
|
||||
{{~ for INDEX in x.index_list ~}}
|
||||
func get_by_{{INDEX.index_field.convention_name}}({{INDEX.index_field.convention_name}}):
|
||||
return self._data_{{INDEX.index_field.name}}_map.get({{INDEX.index_field.convention_name}})
|
||||
{{~ end ~}}
|
||||
|
||||
func get(key):
|
||||
return self._data_{{x.index_field.convention_name }}_map.get(key)
|
||||
{{~else if x.is_list_table ~}}
|
||||
var _data_list
|
||||
func _init(_json_) -> void:
|
||||
self._data_list = []
|
||||
|
||||
for _json2_ in _json_:
|
||||
var _v
|
||||
{{gdscript_deserialize_value '_v' '_json2_' value_type}}
|
||||
self._data_list.append(_v)
|
||||
|
||||
func get_data_list():
|
||||
return self._data_list
|
||||
|
||||
func get(index):
|
||||
return self._data_list[index]
|
||||
{{~else~}}
|
||||
var _data: Dictionary
|
||||
func _init(_json_) -> void:
|
||||
assert(len(_json_) == 1, 'table mode=one, but size != 1')
|
||||
self._data = _json_[0]
|
||||
|
||||
func get_data() -> Dictionary:
|
||||
return self._data
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
# {{field.escape_comment}}
|
||||
{{~end~}}
|
||||
func {{field.convention_name}}():
|
||||
return self._data.{{field.convention_name}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{{
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
}}
|
||||
{{~ for table in tables ~}}
|
||||
var {{table.name}}: {{table.gdscript_full_name}}
|
||||
{{~end~}}
|
||||
|
||||
func _init(loader) -> void:
|
||||
{{~for table in tables ~}}
|
||||
self.{{table.name}} = {{table.gdscript_full_name}}.new(loader.call('{{table.output_data_file}}'))
|
||||
{{~end~}}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
{{~
|
||||
go_full_name = x.go_full_name
|
||||
parent_def_type = x.parent_def_type
|
||||
is_abstract_type = x.is_abstract_type
|
||||
hierarchy_fields = x.hierarchy_export_fields
|
||||
hierarchy_not_abstract_children = x.hierarchy_not_abstract_children
|
||||
~}}
|
||||
|
||||
package {{x.top_module}}
|
||||
|
||||
import (
|
||||
"{{assembly.args.go_bright_module_name}}/serialization"
|
||||
)
|
||||
|
||||
{{x.go_bin_import}}
|
||||
|
||||
type {{go_full_name}} struct {
|
||||
{{~for field in hierarchy_fields ~}}
|
||||
{{field.convention_name}} {{go_define_type field.ctype}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
const TypeId_{{go_full_name}} = {{x.id}}
|
||||
|
||||
func (*{{go_full_name}}) GetTypeId() int32 {
|
||||
return {{x.id}}
|
||||
}
|
||||
|
||||
func (_v *{{go_full_name}})Serialize(_buf *serialization.ByteBuf) {
|
||||
// not support
|
||||
}
|
||||
|
||||
func (_v *{{go_full_name}})Deserialize(_buf *serialization.ByteBuf) (err error) {
|
||||
{{~for field in hierarchy_fields ~}}
|
||||
{{go_deserialize_field field.ctype ("_v." + field.convention_name) '_buf' 'err'}}
|
||||
{{~end~}}
|
||||
return
|
||||
}
|
||||
|
||||
{{~if is_abstract_type~}}
|
||||
func Deserialize{{go_full_name}}(_buf *serialization.ByteBuf) (interface{}, error) {
|
||||
var id int32
|
||||
var err error
|
||||
if id, err = _buf.ReadInt() ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
{{~for child in hierarchy_not_abstract_children~}}
|
||||
case {{child.id}}: _v := &{{child.go_full_name}}{}; if err = _v.Deserialize(_buf); err != nil { return nil, errors.New("{{child.full_name}}") } else { return _v, nil }
|
||||
{{~end~}}
|
||||
default: return nil, errors.New("unknown type id")
|
||||
}
|
||||
}
|
||||
|
||||
{{~else~}}
|
||||
func Deserialize{{go_full_name}}(_buf *serialization.ByteBuf) (*{{go_full_name}}, error) {
|
||||
v := &{{go_full_name}}{}
|
||||
if err := v.Deserialize(_buf); err == nil {
|
||||
return v, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
{{~end~}}
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
{{~
|
||||
go_full_name = x.go_full_name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
index_field = x.index_field
|
||||
index_field1 = x.index_field1
|
||||
index_field2 = x.index_field2
|
||||
~}}
|
||||
|
||||
package {{x.top_module}}
|
||||
|
||||
import "{{assembly.args.go_bright_module_name}}/serialization"
|
||||
|
||||
{{~if x.is_map_table~}}
|
||||
type {{go_full_name}} struct {
|
||||
_dataMap map[{{go_define_type key_type}}]{{go_define_type value_type}}
|
||||
_dataList []{{go_define_type value_type}}
|
||||
}
|
||||
|
||||
func New{{go_full_name}}(_buf *serialization.ByteBuf) (*{{go_full_name}}, error) {
|
||||
if size, err := _buf.ReadSize() ; err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
_dataList := make([]{{go_define_type value_type}}, 0, size)
|
||||
dataMap := make(map[{{go_define_type key_type}}]{{go_define_type value_type}})
|
||||
|
||||
for i := 0 ; i < size ; i++ {
|
||||
if _v, err2 := {{go_deserialize_type value_type '_buf'}}; err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
{{~if value_type.is_dynamic ~}}
|
||||
{{~for child in value_type.bean.hierarchy_not_abstract_children~}}
|
||||
if __v, __is := _v.(*{{child.go_full_name}}) ; __is {
|
||||
dataMap[__v.{{index_field.convention_name}}] = _v
|
||||
continue
|
||||
}
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
dataMap[_v.{{index_field.convention_name}}] = _v
|
||||
{{~end~}}
|
||||
}
|
||||
}
|
||||
return &{{go_full_name}}{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) GetDataMap() map[{{go_define_type key_type}}]{{go_define_type value_type}} {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) GetDataList() []{{go_define_type value_type}} {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) Get(key {{go_define_type key_type}}) {{go_define_type value_type}} {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
{{~else if x.is_list_table~}}
|
||||
type {{go_full_name}} struct {
|
||||
_dataList []{{go_define_type value_type}}
|
||||
}
|
||||
|
||||
func New{{go_full_name}}(_buf *serialization.ByteBuf) (*{{go_full_name}}, error) {
|
||||
if size, err := _buf.ReadSize() ; err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
_dataList := make([]{{go_define_type value_type}}, 0, size)
|
||||
|
||||
for i := 0 ; i < size ; i++ {
|
||||
if _v, err2 := {{go_deserialize_type value_type '_buf'}}; err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
}
|
||||
}
|
||||
return &{{go_full_name}}{_dataList:_dataList}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) GetDataList() []{{go_define_type value_type}} {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) Get(index int) {{go_define_type value_type}} {
|
||||
return table._dataList[index]
|
||||
}
|
||||
|
||||
{{~else~}}
|
||||
|
||||
import "errors"
|
||||
|
||||
type {{go_full_name}} struct {
|
||||
_data {{go_define_type value_type}}
|
||||
}
|
||||
|
||||
func New{{go_full_name}}(_buf *serialization.ByteBuf) (*{{go_full_name}}, error) {
|
||||
if size, err := _buf.ReadSize() ; err != nil {
|
||||
return nil, err
|
||||
} else if size != 1 {
|
||||
return nil, errors.New(" size != 1 ")
|
||||
} else {
|
||||
if _v, err2 := {{go_deserialize_type value_type '_buf'}}; err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
return &{{go_full_name}}{_data:_v}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) Get() {{go_define_type value_type}} {
|
||||
return table._data
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
|
||||
package {{namespace}}
|
||||
|
||||
import "{{assembly.args.go_bright_module_name}}/serialization"
|
||||
|
||||
type ByteBufLoader func(string) (*serialization.ByteBuf, error)
|
||||
|
||||
type {{name}} struct {
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}} *{{table.go_full_name}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
func NewTables(loader ByteBufLoader) (*{{name}}, error) {
|
||||
var err error
|
||||
var buf *serialization.ByteBuf
|
||||
|
||||
tables := &{{name}}{}
|
||||
{{~for table in tables ~}}
|
||||
if buf, err = loader("{{table.output_data_file}}") ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tables.{{table.name}}, err = New{{table.go_full_name}}(buf) ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
{{~end~}}
|
||||
return tables, nil
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
{{~
|
||||
go_full_name = x.go_full_name
|
||||
parent_def_type = x.parent_def_type
|
||||
is_abstract_type = x.is_abstract_type
|
||||
hierarchy_fields = x.hierarchy_export_fields
|
||||
hierarchy_not_abstract_children = x.hierarchy_not_abstract_children
|
||||
~}}
|
||||
|
||||
package {{x.top_module}}
|
||||
|
||||
{{x.go_json_import}}
|
||||
|
||||
type {{go_full_name}} struct {
|
||||
{{~for field in hierarchy_fields ~}}
|
||||
{{field.convention_name}} {{go_define_type field.ctype}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
const TypeId_{{go_full_name}} = {{x.id}}
|
||||
|
||||
func (*{{go_full_name}}) GetTypeId() int32 {
|
||||
return {{x.id}}
|
||||
}
|
||||
|
||||
func (_v *{{go_full_name}})Deserialize(_buf map[string]interface{}) (err error) {
|
||||
{{~for field in hierarchy_fields ~}}
|
||||
{{go_deserialize_json_field field.ctype ("_v." + field.convention_name) field.name '_buf'}}
|
||||
{{~end~}}
|
||||
return
|
||||
}
|
||||
|
||||
{{~if is_abstract_type~}}
|
||||
func Deserialize{{go_full_name}}(_buf map[string]interface{}) (interface{}, error) {
|
||||
var id string
|
||||
var _ok_ bool
|
||||
if id, _ok_ = _buf["{{x.json_type_name_key}}"].(string) ; !_ok_ {
|
||||
return nil, errors.New("type id missing")
|
||||
}
|
||||
switch id {
|
||||
{{~for child in hierarchy_not_abstract_children~}}
|
||||
case "{{cs_impl_data_type child x}}": _v := &{{child.go_full_name}}{}; if err := _v.Deserialize(_buf); err != nil { return nil, errors.New("{{child.full_name}}") } else { return _v, nil }
|
||||
{{~end~}}
|
||||
default: return nil, errors.New("unknown type id")
|
||||
}
|
||||
}
|
||||
{{~else~}}
|
||||
func Deserialize{{go_full_name}}(_buf map[string]interface{}) (*{{go_full_name}}, error) {
|
||||
v := &{{go_full_name}}{}
|
||||
if err := v.Deserialize(_buf); err == nil {
|
||||
return v, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
{{~end~}}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
{{~
|
||||
go_full_name = x.go_full_name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
index_field = x.index_field
|
||||
index_field1 = x.index_field1
|
||||
index_field2 = x.index_field2
|
||||
~}}
|
||||
|
||||
package {{x.top_module}}
|
||||
|
||||
{{~if x.is_map_table~}}
|
||||
type {{go_full_name}} struct {
|
||||
_dataMap map[{{go_define_type key_type}}]{{go_define_type value_type}}
|
||||
_dataList []{{go_define_type value_type}}
|
||||
}
|
||||
|
||||
func New{{go_full_name}}(_buf []map[string]interface{}) (*{{go_full_name}}, error) {
|
||||
_dataList := make([]{{go_define_type value_type}}, 0, len(_buf))
|
||||
dataMap := make(map[{{go_define_type key_type}}]{{go_define_type value_type}})
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := {{go_deserialize_type value_type '_ele_'}}; err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
{{~if value_type.is_dynamic ~}}
|
||||
{{~for child in value_type.bean.hierarchy_not_abstract_children~}}
|
||||
if __v, __is := _v.(*{{child.go_full_name}}) ; __is {
|
||||
dataMap[__v.{{index_field.convention_name}}] = _v
|
||||
continue
|
||||
}
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
dataMap[_v.{{index_field.convention_name}}] = _v
|
||||
{{~end~}}
|
||||
}
|
||||
}
|
||||
return &{{go_full_name}}{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) GetDataMap() map[{{go_define_type key_type}}]{{go_define_type value_type}} {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) GetDataList() []{{go_define_type value_type}} {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) Get(key {{go_define_type key_type}}) {{go_define_type value_type}} {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
||||
{{~else if x.is_list_table~}}
|
||||
type {{go_full_name}} struct {
|
||||
_dataList []{{go_define_type value_type}}
|
||||
}
|
||||
|
||||
func New{{go_full_name}}(_buf []map[string]interface{}) (*{{go_full_name}}, error) {
|
||||
_dataList := make([]{{go_define_type value_type}}, 0, len(_buf))
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := {{go_deserialize_type value_type '_ele_'}}; err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
}
|
||||
}
|
||||
return &{{go_full_name}}{_dataList:_dataList}, nil
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) GetDataList() []{{go_define_type value_type}} {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) Get(index int) {{go_define_type value_type}} {
|
||||
return table._dataList[index]
|
||||
}
|
||||
|
||||
{{~else~}}
|
||||
|
||||
import "errors"
|
||||
|
||||
type {{go_full_name}} struct {
|
||||
_data {{go_define_type value_type}}
|
||||
}
|
||||
|
||||
func New{{go_full_name}}(_buf []map[string]interface{}) (*{{go_full_name}}, error) {
|
||||
if len(_buf) != 1 {
|
||||
return nil, errors.New(" size != 1 ")
|
||||
} else {
|
||||
if _v, err2 := {{go_deserialize_type value_type '_buf[0]'}}; err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
return &{{go_full_name}}{_data:_v}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (table *{{go_full_name}}) Get() {{go_define_type value_type}} {
|
||||
return table._data
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
|
||||
package {{namespace}}
|
||||
|
||||
type JsonLoader func(string) ([]map[string]interface{}, error)
|
||||
|
||||
type {{name}} struct {
|
||||
{{~for table in tables ~}}
|
||||
{{table.name}} *{{table.go_full_name}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
func NewTables(loader JsonLoader) (*{{name}}, error) {
|
||||
var err error
|
||||
var buf []map[string]interface{}
|
||||
|
||||
tables := &{{name}}{}
|
||||
{{~for table in tables ~}}
|
||||
if buf, err = loader("{{table.output_data_file}}") ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tables.{{table.name}}, err = New{{table.go_full_name}}(buf) ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
{{~end~}}
|
||||
return tables, nil
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
package {{x.namespace_with_top_module}};
|
||||
|
||||
import bright.serialization.*;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/**
|
||||
* {{x.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{x.parent_def_type.full_name_with_top_module}}{{end}} {
|
||||
public {{name}}(ByteBuf _buf) {
|
||||
{{~if parent_def_type~}}
|
||||
super(_buf);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{java_deserialize '_buf' field.convention_name field.ctype}}
|
||||
{{~if field.index_field~}}
|
||||
for({{java_box_define_type field.ctype.element_type}} _v : {{field.convention_name}}) {
|
||||
{{field.convention_name}}_Index.put(_v.{{field.index_field.convention_name}}, _v);
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public {{name}}({{- for field in hierarchy_export_fields }}{{java_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) {
|
||||
{{~if parent_def_type~}}
|
||||
super({{ for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}}, {{end}}{{end}});
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
this.{{field.convention_name}} = {{field.name}};
|
||||
{{~if field.index_field~}}
|
||||
for({{java_box_define_type field.ctype.element_type}} _v : {{field.convention_name}}) {
|
||||
{{field.convention_name}}_Index.put(_v.{{field.index_field.convention_name}}, _v);
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{~if x.is_abstract_type~}}
|
||||
public static {{name}} deserialize{{name}}(ByteBuf _buf) {
|
||||
switch (_buf.readInt()) {
|
||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||
case {{child.full_name_with_top_module}}.__ID__: return new {{child.full_name_with_top_module}}(_buf);
|
||||
{{~end~}}
|
||||
default: throw new SerializationException();
|
||||
}
|
||||
}
|
||||
{{~end~}}
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/**
|
||||
* {{field.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public final {{java_define_type field.ctype}} {{field.convention_name}};
|
||||
{{~if field.index_field~}}
|
||||
public final java.util.HashMap<{{java_box_define_type field.index_field.ctype}}, {{java_box_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new java.util.HashMap<>();
|
||||
{{~end~}}
|
||||
{{~if field.gen_ref~}}
|
||||
public {{field.java_ref_validator_define}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
{{~if !x.is_abstract_type && x.parent_def_type~}}
|
||||
public static final int __ID__ = {{x.id}};
|
||||
|
||||
@Override
|
||||
public int getTypeId() { return __ID__; }
|
||||
{{~else if x.is_abstract_type && !x.parent_def_type~}}
|
||||
public abstract int getTypeId();
|
||||
{{~end~}}
|
||||
|
||||
{{~if parent_def_type~}}
|
||||
@Override
|
||||
{{~end~}}
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
{{~if parent_def_type~}}
|
||||
super.resolve(_tables);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{java_ref_validator_resolve field}}
|
||||
{{~else if field.has_recursive_ref~}}
|
||||
{{java_recursive_resolve field '_tables'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{{full_name}}{ "
|
||||
{{~for field in hierarchy_export_fields ~}}
|
||||
+ "{{field.convention_name}}:" + {{java_to_string field.convention_name field.ctype}} + ","
|
||||
{{~end~}}
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
package {{x.namespace_with_top_module}};
|
||||
|
||||
import bright.serialization.*;
|
||||
|
||||
{{~
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
~}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/**
|
||||
* {{x.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public final class {{name}} {
|
||||
{{~if x.is_map_table ~}}
|
||||
private final java.util.HashMap<{{java_box_define_type key_type}}, {{java_box_define_type value_type}}> _dataMap;
|
||||
private final java.util.ArrayList<{{java_box_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(ByteBuf _buf) {
|
||||
_dataMap = new java.util.HashMap<{{java_box_define_type key_type}}, {{java_box_define_type value_type}}>();
|
||||
_dataList = new java.util.ArrayList<{{java_box_define_type value_type}}>();
|
||||
|
||||
for(int n = _buf.readSize() ; n > 0 ; --n) {
|
||||
{{java_box_define_type value_type}} _v;
|
||||
{{java_deserialize '_buf' '_v' value_type}}
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.{{x.index_field.convention_name}}, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<{{java_box_define_type key_type}}, {{java_box_define_type value_type}}> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<{{java_box_define_type value_type}}> getDataList() { return _dataList; }
|
||||
|
||||
{{~if value_type.is_dynamic~}}
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends {{java_box_define_type value_type}}> T getAs({{java_define_type key_type}} key) { return (T)_dataMap.get(key); }
|
||||
{{~end~}}
|
||||
public {{java_box_define_type value_type}} get({{java_define_type key_type}} key) { return _dataMap.get(key); }
|
||||
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
for({{java_box_define_type value_type}} v : _dataList) {
|
||||
v.resolve(_tables);
|
||||
}
|
||||
}
|
||||
{{~else if x.is_list_table ~}}
|
||||
private final java.util.ArrayList<{{java_box_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(ByteBuf _buf) {
|
||||
_dataList = new java.util.ArrayList<{{java_box_define_type value_type}}>();
|
||||
|
||||
for(int n = _buf.readSize() ; n > 0 ; --n) {
|
||||
{{java_box_define_type value_type}} _v;
|
||||
{{java_deserialize '_buf' '_v' value_type}}
|
||||
_dataList.add(_v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.ArrayList<{{java_box_define_type value_type}}> getDataList() { return _dataList; }
|
||||
|
||||
public {{java_box_define_type value_type}} get(int index) { return _dataList.get(index); }
|
||||
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
for({{java_box_define_type value_type}} v : _dataList) {
|
||||
v.resolve(_tables);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else~}}
|
||||
private final {{java_define_type value_type}} _data;
|
||||
|
||||
public final {{java_define_type value_type}} data() { return _data; }
|
||||
|
||||
public {{name}}(ByteBuf _buf) {
|
||||
int n = _buf.readSize();
|
||||
if (n != 1) throw new SerializationException("table mode=one, but size != 1");
|
||||
{{java_deserialize '_buf' '_data' value_type}}
|
||||
}
|
||||
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/**
|
||||
* {{field.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public {{java_define_type field.ctype}} {{field.convention_getter_name}}() { return _data.{{field.convention_name}}; }
|
||||
{{~end~}}
|
||||
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
_data.resolve(_tables);
|
||||
}
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
package {{namespace}};
|
||||
|
||||
import bright.serialization.*;
|
||||
|
||||
public final class {{name}}
|
||||
{
|
||||
public static interface IByteBufLoader {
|
||||
ByteBuf load(String file) throws java.io.IOException;
|
||||
}
|
||||
|
||||
{{~for table in tables ~}}
|
||||
{{~if table.comment != '' ~}}
|
||||
/**
|
||||
* {{table.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
private final {{table.full_name_with_top_module}} {{table.inner_name}};
|
||||
public {{table.full_name_with_top_module}} get{{table.name}}() { return {{table.inner_name}}; }
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(IByteBufLoader loader) throws java.io.IOException {
|
||||
java.util.HashMap<String, Object> tables = new java.util.HashMap<>();
|
||||
{{~for table in tables ~}}
|
||||
{{table.inner_name}} = new {{table.full_name_with_top_module}}(loader.load("{{table.output_data_file}}"));
|
||||
tables.put("{{table.full_name}}", {{table.inner_name}});
|
||||
{{~end~}}
|
||||
|
||||
{{~ for table in tables ~}}
|
||||
{{table.inner_name}}.resolve(tables);
|
||||
{{~end~}}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
package {{x.namespace_with_top_module}};
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
{{
|
||||
name = x.name
|
||||
parent_def_type = x.parent_def_type
|
||||
export_fields = x.export_fields
|
||||
hierarchy_export_fields = x.hierarchy_export_fields
|
||||
}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/**
|
||||
* {{x.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public {{x.java_class_modifier}} class {{name}}{{if parent_def_type}} extends {{x.parent_def_type.full_name_with_top_module}}{{end}} {
|
||||
public {{name}}(JsonObject __json__) {
|
||||
{{~if parent_def_type~}}
|
||||
super(__json__);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{java_json_deserialize '__json__' field.convention_name field.name field.ctype}}
|
||||
{{~if field.index_field~}}
|
||||
for({{java_box_define_type field.ctype.element_type}} _v : {{field.convention_name}}) {
|
||||
{{field.convention_name}}_Index.put(_v.{{field.index_field.convention_name}}, _v);
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public {{name}}({{- for field in hierarchy_export_fields }}{{java_define_type field.ctype}} {{field.name}}{{if !for.last}},{{end}} {{end}}) {
|
||||
{{~if parent_def_type~}}
|
||||
super({{ for field in parent_def_type.hierarchy_export_fields }}{{field.name}}{{if !for.last}}, {{end}}{{end}});
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
this.{{field.convention_name}} = {{field.name}};
|
||||
{{~if field.index_field~}}
|
||||
for({{java_box_define_type field.ctype.element_type}} _v : {{field.convention_name}}) {
|
||||
{{field.convention_name}}_Index.put(_v.{{field.index_field.convention_name}}, _v);
|
||||
}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
public static {{name}} deserialize{{name}}(JsonObject __json__) {
|
||||
{{~if x.is_abstract_type~}}
|
||||
switch (__json__.get("{{x.json_type_name_key}}").getAsString()) {
|
||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||
case "{{cs_impl_data_type child x}}": return new {{child.full_name_with_top_module}}(__json__);
|
||||
{{~end~}}
|
||||
default: throw new bright.serialization.SerializationException();
|
||||
}
|
||||
{{~else~}}
|
||||
return new {{name}}(__json__);
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/**
|
||||
* {{field.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public final {{java_define_type field.ctype}} {{field.convention_name}};
|
||||
{{~if field.index_field~}}
|
||||
public final java.util.HashMap<{{java_box_define_type field.index_field.ctype}}, {{java_box_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new java.util.HashMap<>();
|
||||
{{~end~}}
|
||||
{{~if field.gen_ref~}}
|
||||
public {{field.java_ref_validator_define}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
|
||||
{{~if !x.is_abstract_type && x.parent_def_type~}}
|
||||
public static final int __ID__ = {{x.id}};
|
||||
|
||||
@Override
|
||||
public int getTypeId() { return __ID__; }
|
||||
{{~else if x.is_abstract_type && !x.parent_def_type~}}
|
||||
public abstract int getTypeId();
|
||||
{{~end~}}
|
||||
|
||||
{{~if parent_def_type~}}
|
||||
@Override
|
||||
{{~end~}}
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
{{~if parent_def_type~}}
|
||||
super.resolve(_tables);
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{~if field.gen_ref~}}
|
||||
{{java_ref_validator_resolve field}}
|
||||
{{~else if field.has_recursive_ref~}}
|
||||
{{java_recursive_resolve field '_tables'}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{{full_name}}{ "
|
||||
{{~for field in hierarchy_export_fields ~}}
|
||||
+ "{{field.convention_name}}:" + {{java_to_string field.convention_name field.ctype}} + ","
|
||||
{{~end~}}
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
package {{x.namespace_with_top_module}};
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
{{~
|
||||
name = x.name
|
||||
key_type = x.key_ttype
|
||||
key_type1 = x.key_ttype1
|
||||
key_type2 = x.key_ttype2
|
||||
value_type = x.value_ttype
|
||||
~}}
|
||||
|
||||
{{~if x.comment != '' ~}}
|
||||
/**
|
||||
* {{x.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public final class {{name}} {
|
||||
{{~if x.is_map_table ~}}
|
||||
private final java.util.HashMap<{{java_box_define_type key_type}}, {{java_box_define_type value_type}}> _dataMap;
|
||||
private final java.util.ArrayList<{{java_box_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(JsonElement __json__) {
|
||||
_dataMap = new java.util.HashMap<{{java_box_define_type key_type}}, {{java_box_define_type value_type}}>();
|
||||
_dataList = new java.util.ArrayList<{{java_box_define_type value_type}}>();
|
||||
|
||||
for(com.google.gson.JsonElement _e_ : __json__.getAsJsonArray()) {
|
||||
{{java_box_define_type value_type}} _v;
|
||||
{{java_deserialize '_e_.getAsJsonObject()' '_v' value_type}}
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.{{x.index_field.convention_name}}, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<{{java_box_define_type key_type}}, {{java_box_define_type value_type}}> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<{{java_box_define_type value_type}}> getDataList() { return _dataList; }
|
||||
|
||||
{{~if value_type.is_dynamic~}}
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends {{java_box_define_type value_type}}> T getAs({{java_define_type key_type}} key) { return (T)_dataMap.get(key); }
|
||||
{{~end~}}
|
||||
public {{java_box_define_type value_type}} get({{java_define_type key_type}} key) { return _dataMap.get(key); }
|
||||
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
for({{java_box_define_type value_type}} v : _dataList) {
|
||||
v.resolve(_tables);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else if x.is_list_table ~}}
|
||||
private final java.util.ArrayList<{{java_box_define_type value_type}}> _dataList;
|
||||
|
||||
public {{name}}(JsonElement __json__) {
|
||||
_dataList = new java.util.ArrayList<{{java_box_define_type value_type}}>();
|
||||
|
||||
for(com.google.gson.JsonElement _e_ : __json__.getAsJsonArray()) {
|
||||
{{java_box_define_type value_type}} _v;
|
||||
{{java_deserialize '_e_.getAsJsonObject()' '_v' value_type}}
|
||||
_dataList.add(_v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.ArrayList<{{java_box_define_type value_type}}> getDataList() { return _dataList; }
|
||||
|
||||
public {{java_box_define_type value_type}} get(int index) { return _dataList.get(index); }
|
||||
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
for({{java_box_define_type value_type}} v : _dataList) {
|
||||
v.resolve(_tables);
|
||||
}
|
||||
}
|
||||
|
||||
{{~else~}}
|
||||
private final {{java_define_type value_type}} _data;
|
||||
|
||||
public final {{java_define_type value_type}} data() { return _data; }
|
||||
|
||||
public {{name}}(JsonElement __json__) {
|
||||
int n = __json__.getAsJsonArray().size();
|
||||
if (n != 1) throw new bright.serialization.SerializationException("table mode=one, but size != 1");
|
||||
{{java_deserialize '__json__.getAsJsonArray().get(0).getAsJsonObject()' '_data' value_type}}
|
||||
}
|
||||
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
/**
|
||||
* {{field.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
public {{java_define_type field.ctype}} {{field.convention_getter_name}}() { return _data.{{field.convention_name}}; }
|
||||
{{~end~}}
|
||||
|
||||
public void resolve(java.util.HashMap<String, Object> _tables) {
|
||||
_data.resolve(_tables);
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
{{~
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
~}}
|
||||
package {{namespace}};
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public final class {{name}}
|
||||
{
|
||||
public interface IJsonLoader {
|
||||
JsonElement load(String file) throws java.io.IOException;
|
||||
}
|
||||
|
||||
{{~for table in tables ~}}
|
||||
{{~if table.comment != '' ~}}
|
||||
/**
|
||||
* {{table.escape_comment}}
|
||||
*/
|
||||
{{~end~}}
|
||||
private final {{table.full_name_with_top_module}} {{table.inner_name}};
|
||||
public {{table.full_name_with_top_module}} get{{table.name}}() { return {{table.inner_name}}; }
|
||||
{{~end~}}
|
||||
|
||||
public {{name}}(IJsonLoader loader) throws java.io.IOException {
|
||||
java.util.HashMap<String, Object> tables = new java.util.HashMap<>();
|
||||
{{~for table in tables ~}}
|
||||
{{table.inner_name}} = new {{table.full_name_with_top_module}}(loader.load("{{table.output_data_file}}"));
|
||||
tables.put("{{table.full_name}}", {{table.inner_name}});
|
||||
{{~end~}}
|
||||
|
||||
{{~ for table in tables ~}}
|
||||
{{table.inner_name}}.resolve(tables);
|
||||
{{~end~}}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue