【特性】新增cfg 所有语言对table mode=list的代码生成

main
walon 2021-12-01 14:12:11 +08:00
parent ba4bb014a9
commit 85937685b6
20 changed files with 420 additions and 10 deletions

View File

@ -55,7 +55,7 @@ luban相较于常规的excel导表工具有以下核心优势
- 支持数据标签。 可以选择导出符合要求的数据,发布正式数据时策划不必手动注释掉那些测试数据了 - 支持数据标签。 可以选择导出符合要求的数据,发布正式数据时策划不必手动注释掉那些测试数据了
- 强大的数据校验能力。支持内建数据格式检查支持ref表引用检查策划不用担心填错id;支持path资源检查策划不用担心填错资源路径;支持range检查 - 强大的数据校验能力。支持内建数据格式检查支持ref表引用检查策划不用担心填错id;支持path资源检查策划不用担心填错资源路径;支持range检查
- 支持常量别名。策划不必再为诸如 升级丹 这样的道具手写具体道具id了 - 支持常量别名。策划不必再为诸如 升级丹 这样的道具手写具体道具id了
- 支持多种常见数据表模式。 one(单例表)、map常规key-value表 - 支持多种常见数据表模式。 singleton(单例表)、map常规key-value表、**list(支持无索引、多主键联合索引、多主键独立索引)**
- 支持res资源标记。可以一键导出配置中引用的所有资源列表(icon,ui,assetbundle等等) - 支持res资源标记。可以一键导出配置中引用的所有资源列表(icon,ui,assetbundle等等)
- 统一了自定义编辑器的配置数据。与Unity和UE4的自定义编辑器良好配合为编辑器生成合适的加载与保存json配置的的c#(Unity)或c++(UE4)代码。保存的json配置能够被luban识别和处理。 - 统一了自定义编辑器的配置数据。与Unity和UE4的自定义编辑器良好配合为编辑器生成合适的加载与保存json配置的的c#(Unity)或c++(UE4)代码。保存的json配置能够被luban识别和处理。
- 支持emmylua anntations。生成的lua包含符合emmylua 格式anntations信息。配合emmylua有良好的配置代码提示能力 - 支持emmylua anntations。生成的lua包含符合emmylua 格式anntations信息。配合emmylua有良好的配置代码提示能力
@ -423,7 +423,66 @@ xml中定义如下
</tr> </tr>
</table> </table>
### 列表表 (无主键)
有时候只想得到一个记录列表无主键。mode="list"并且index为空表示无主键表。
定义表
```xml
<table name="TbNotKeyList" value="NotKeyList" mode="list" input="not_key_list.xlsx"/>
```
示例数据表
|##|x|y|z| num|
|-|-|-|-|-|
|##type|int|long|string|int|
||1|1|aaa|123|
||1|1|bbb|124|
||1|2|aaa|134|
||2|1|aaa|124|
||5|6|xxx|898|
### 多主键表(联合索引)
多个key构成联合唯一主键。使用"+"分割key表示联合关系。
定义表
```xml
<table name="TbUnionMultiKey" value="UnionMultiKey" index="key1+key2+key3" input="union_multi_key.xlsx"/>
```
示例数据表
|##|key1|key2|key3| num|
|-|-|-|-|-|
|##type|int|long|string|int|
||1|1|aaa|123|
||1|1|bbb|124|
||1|2|aaa|134|
||2|1|aaa|124|
||5|6|xxx|898|
### 多主键表(独立索引)
多个key各自独立唯一索引。与联合索引写法区别在于使用 ","来划分key表示独立关系。
定义表
```xml
<table name="TbMultiKey" value="MultiKey" index="key1,key2,key3" input="multi_key.xlsx"/>
```
示例数据表
|##|key1|key2|key3| num|
|-|-|-|-|-|
|##type|int|long|string|int|
||1|2|aaa|123|
||2|4|bbb|124|
||3|6|ccc|134|
||4|8|ddd|124|
||5|1|eee|898|
### 单例表 ### 单例表
有一些配置全局只有一份,比如 公会模块的开启等级,背包初始大小,背包上限。此时使用单例表来配置这些数据比较合适。 有一些配置全局只有一份,比如 公会模块的开启等级,背包初始大小,背包上限。此时使用单例表来配置这些数据比较合适。

View File

@ -30,5 +30,18 @@ namespace Luban.Job.Cfg.DataExporters
} }
s.Append('}'); s.Append('}');
} }
public void ExportTableList(DefTable t, List<Record> records, StringBuilder s)
{
s.Append("return").AppendLine();
s.Append('{').AppendLine();
foreach (Record r in records)
{
DBean d = r.Data;
s.Append(d.Apply(ToLuaLiteralVisitor.Ins));
s.Append(',').AppendLine();
}
s.Append('}');
}
} }
} }

View File

@ -26,7 +26,7 @@ namespace Luban.Job.Cfg.Defs
public RefValidator Ref { get; private set; } public RefValidator Ref { get; private set; }
// 如果ref了多个表不再生成 xxx_ref之类的字段也不会resolve // 如果ref了多个表不再生成 xxx_ref之类的字段也不会resolve
public bool GenRef => Ref != null && Ref.Tables.Count == 1; public bool GenRef => Ref != null && Ref.GenRef;
public bool HasRecursiveRef => (CType.IsBean) public bool HasRecursiveRef => (CType.IsBean)
|| (CType is TArray ta && ta.ElementType.IsBean) || (CType is TArray ta && ta.ElementType.IsBean)

View File

@ -132,7 +132,7 @@ namespace Luban.Job.Cfg.Defs
} }
case ETableMode.LIST: case ETableMode.LIST:
{ {
var indexs = Index.Split(',', '|', '+', '&').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList(); var indexs = Index.Split('+', ',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList();
foreach (var idx in indexs) foreach (var idx in indexs)
{ {
if (ValueTType.GetBeanAs<DefBean>().TryGetField(idx, out var f, out var i)) if (ValueTType.GetBeanAs<DefBean>().TryGetField(idx, out var f, out var i))
@ -147,7 +147,7 @@ namespace Luban.Job.Cfg.Defs
} }
} }
// 如果不是 union index, 每个key必须唯一否则 (key1,..,key n)唯一 // 如果不是 union index, 每个key必须唯一否则 (key1,..,key n)唯一
IsUnionIndex = IndexList.Count > 1 && !Index.Contains('|'); IsUnionIndex = IndexList.Count > 1 && !Index.Contains(',');
break; break;
} }
default: throw new Exception($"unknown mode:'{Mode}'"); default: throw new Exception($"unknown mode:'{Mode}'");

View File

@ -80,6 +80,11 @@ namespace Luban.Job.Cfg.Utils
LuaExportor.Ins.ExportTableMap(table, records, content); LuaExportor.Ins.ExportTableMap(table, records, content);
break; break;
} }
case ETableMode.LIST:
{
LuaExportor.Ins.ExportTableList(table, records, content);
break;
}
default: default:
{ {
throw new NotSupportedException(); throw new NotSupportedException();

View File

@ -16,17 +16,14 @@ namespace Luban.Job.Cfg.Validators
public class RefValidator : IValidator public class RefValidator : IValidator
{ {
public static string GetActualTableName(string table)
{
return table.EndsWith("?") ? table.Substring(0, table.Length - 1) : table;
}
public List<string> Tables { get; } public List<string> Tables { get; }
public string FirstTable => GetActualTableName(Tables[0]); public string FirstTable => GetActualTableName(Tables[0]);
public TType Type { get; } public TType Type { get; }
public bool GenRef { get; private set; }
public RefValidator(TType type, string tablesStr) public RefValidator(TType type, string tablesStr)
{ {
Type = type; Type = type;
@ -90,7 +87,14 @@ namespace Luban.Job.Cfg.Validators
#endif #endif
} }
private (string TableName, string FieldName, bool IgnoreDefault) ParseRefString(string refStr)
private static string GetActualTableName(string table)
{
var (actualTable, _, _) = ParseRefString(table);
return actualTable;
}
private static (string TableName, string FieldName, bool IgnoreDefault) ParseRefString(string refStr)
{ {
bool ignoreDefault = false; bool ignoreDefault = false;
@ -126,6 +130,7 @@ namespace Luban.Job.Cfg.Validators
} }
var assembly = ((DefField)def).Assembly; var assembly = ((DefField)def).Assembly;
bool first = true;
foreach (var table in Tables) foreach (var table in Tables)
{ {
var (actualTable, indexName, ignoreDefault) = ParseRefString(table); var (actualTable, indexName, ignoreDefault) = ParseRefString(table);
@ -162,6 +167,10 @@ namespace Luban.Job.Cfg.Validators
} }
else if (ct.IsMapTable) else if (ct.IsMapTable)
{ {
if (first && Tables.Count == 1)
{
GenRef = true;
}
if (!string.IsNullOrEmpty(indexName)) if (!string.IsNullOrEmpty(indexName))
{ {
throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 是map表不能索引子字段"); throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 是map表不能索引子字段");
@ -188,6 +197,7 @@ namespace Luban.Job.Cfg.Validators
throw new Exception($"type:'{hostTypeName}' field:'{fieldName}' 类型:'{Type.TypeName}' 与 被引用的list表:'{actualTable}' key:{indexName} 类型:'{indexField.Type.TypeName}' 不一致"); throw new Exception($"type:'{hostTypeName}' field:'{fieldName}' 类型:'{Type.TypeName}' 与 被引用的list表:'{actualTable}' key:{indexName} 类型:'{indexField.Type.TypeName}' 不一致");
} }
} }
first = false;
} }
} }
} }

View File

@ -58,6 +58,43 @@ class {{name}}
} }
} }
{{~else if x.is_list_table~}}
private:
::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);
}
return true;
}
const ::bright::Vector<{{cpp_define_type value_type}}>& getDataList() const { return _dataList; }
{{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];
}
void resolve(::bright::HashMap<::bright::String, void*>& _tables)
{
for(auto v : _dataList)
{
v->resolve(_tables);
}
}
{{~else~}} {{~else~}}
private: private:
{{cpp_define_type value_type}} _data; {{cpp_define_type value_type}} _data;

View File

@ -61,7 +61,40 @@ public sealed class {{name}}
v.TranslateText(translator); v.TranslateText(translator);
} }
} }
{{~else if x.is_list_table ~}}
private readonly List<{{cs_define_type value_type}}> _dataList;
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}}
}
}
public List<{{cs_define_type value_type}}> DataList => _dataList;
public {{cs_define_type value_type}} Get(int index) => _dataList[index];
public {{cs_define_type value_type}} this[int index] => _dataList[index];
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
{{~else~}} {{~else~}}
private readonly {{cs_define_type value_type}} _data; private readonly {{cs_define_type value_type}} _data;

View File

@ -63,7 +63,41 @@ public sealed class {{name}}
v.TranslateText(translator); v.TranslateText(translator);
} }
} }
{{~else if x.is_list_table ~}}
private readonly List<{{cs_define_type value_type}}> _dataList;
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);
}
}
public List<{{cs_define_type value_type}}> DataList => _dataList;
public {{cs_define_type value_type}} Get(int index) => _dataList[index];
public {{cs_define_type value_type}} this[int index] => _dataList[index];
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
{{~else~}} {{~else~}}
private readonly {{cs_define_type value_type}} _data; private readonly {{cs_define_type value_type}} _data;

View File

@ -56,6 +56,41 @@ public sealed class {{name}}
} }
} }
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;
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);
}
}
public List<{{cs_define_type value_type}}> DataList => _dataList;
public {{cs_define_type value_type}} Get(int index) => _dataList[index];
public {{cs_define_type value_type}} this[int index] => _dataList[index];
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
}
public void TranslateText(System.Func<string, string, string> translator) public void TranslateText(System.Func<string, string, string> translator)
{ {
foreach(var v in _dataList) foreach(var v in _dataList)

View File

@ -59,6 +59,35 @@ func (table *{{go_full_name}}) Get(key {{go_define_type key_type}}) {{go_define_
return table._dataMap[key] 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~}} {{~else~}}

View File

@ -53,6 +53,31 @@ func (table *{{go_full_name}}) Get(key {{go_define_type key_type}}) {{go_define_
} }
{{~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~}} {{~else~}}
import "errors" import "errors"

View File

@ -41,6 +41,28 @@ public final class {{name}} {
{{~end~}} {{~end~}}
public {{java_box_define_type value_type}} get({{java_define_type key_type}} key) { return _dataMap.get(key); } 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) { public void resolve(java.util.HashMap<String, Object> _tables) {
for({{java_box_define_type value_type}} v : _dataList) { for({{java_box_define_type value_type}} v : _dataList) {
v.resolve(_tables); v.resolve(_tables);

View File

@ -47,6 +47,29 @@ public final class {{name}} {
} }
} }
{{~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~}} {{~else~}}
private final {{java_define_type value_type}} _data; private final {{java_define_type value_type}} _data;

View File

@ -114,6 +114,8 @@ local function InitTypes(methods)
{{~for table in tables ~}} {{~for table in tables ~}}
{{~if table.is_map_table ~}} {{~if table.is_map_table ~}}
{ name='{{table.name}}', file='{{table.output_data_file}}', mode='map', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' }, { name='{{table.name}}', file='{{table.output_data_file}}', mode='map', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' },
{{~else if table.is_list_table ~}}
{ name='{{table.name}}', file='{{table.output_data_file}}', mode='list', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' },
{{~else~}} {{~else~}}
{ name='{{table.name}}', file='{{table.output_data_file}}', mode='one', value_type='{{table.value_ttype.bean.full_name}}'}, { name='{{table.name}}', file='{{table.output_data_file}}', mode='one', value_type='{{table.value_ttype.bean.full_name}}'},
{{~end~}} {{~end~}}

View File

@ -29,6 +29,8 @@ local tables =
{{~for table in tables ~}} {{~for table in tables ~}}
{{~if table.is_map_table ~}} {{~if table.is_map_table ~}}
{ name='{{table.name}}', file='{{table.output_data_file}}', mode='map', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' }, { name='{{table.name}}', file='{{table.output_data_file}}', mode='map', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' },
{{~else if table.is_list_table ~}}
{ name='{{table.name}}', file='{{table.output_data_file}}', mode='list', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' },
{{~else~}} {{~else~}}
{ name='{{table.name}}', file='{{table.output_data_file}}', mode='one', value_type='{{table.value_ttype.bean.full_name}}'}, { name='{{table.name}}', file='{{table.output_data_file}}', mode='one', value_type='{{table.value_ttype.bean.full_name}}'},
{{end}} {{end}}

View File

@ -22,6 +22,18 @@ class {{name}}:
def getDataList(self) : return self._dataList def getDataList(self) : return self._dataList
def get(self, key) : return self._dataMap.get(key) def get(self, key) : return self._dataMap.get(key)
{{~else if x.is_list_table ~}}
def __init__(self, _json_ ):
self._dataList = []
for _json2_ in _json_:
{{py3_deserialize_value '_v' '_json2_' value_type}}
self._dataList.append(_v)
def getDataList(self) : return self._dataList
def get(self, index) : return self._dataList[index]
{{~else~}} {{~else~}}

View File

@ -13,6 +13,8 @@ pub struct {{name}} {
{{~if x.is_map_table ~}} {{~if x.is_map_table ~}}
data_list: Vec<std::rc::Rc<{{rust_define_type value_type}}>>, data_list: Vec<std::rc::Rc<{{rust_define_type value_type}}>>,
data_map: std::collections::HashMap<{{rust_define_type key_type}}, std::rc::Rc<{{rust_define_type value_type}}>>, data_map: std::collections::HashMap<{{rust_define_type key_type}}, std::rc::Rc<{{rust_define_type value_type}}>>,
{{~else if x.is_list_table ~}}
data_list: Vec<std::rc::Rc<{{rust_define_type value_type}}>>,
{{~else~}} {{~else~}}
data: {{rust_class_name value_type}}, data: {{rust_class_name value_type}},
{{~end~}} {{~end~}}
@ -54,6 +56,30 @@ impl {{name}}{
pub fn get_data_list(self:&{{name}}) -> &Vec<std::rc::Rc<{{rust_define_type value_type}}>> { &self.data_list } pub fn get_data_list(self:&{{name}}) -> &Vec<std::rc::Rc<{{rust_define_type value_type}}>> { &self.data_list }
#[allow(dead_code)] #[allow(dead_code)]
pub fn get(self:&{{name}}, key: &{{rust_define_type key_type}}) -> std::option::Option<&std::rc::Rc<{{rust_define_type value_type}}>> { self.data_map.get(key) } pub fn get(self:&{{name}}, key: &{{rust_define_type key_type}}) -> std::option::Option<&std::rc::Rc<{{rust_define_type value_type}}>> { self.data_map.get(key) }
{{~else if x.is_list_table ~}}
if !__js.is_array() {
return Err(LoadError{});
}
let mut t = {{name}} {
data_list : Vec::new(),
};
for __e in __js.members() {
let __v = std::rc::Rc::new(match {{rust_class_name value_type}}::new(__e) {
Ok(x) => x,
Err(err) => return Err(err),
});
let __v2 = std::rc::Rc::clone(&__v);
t.data_list.push(__v);
}
Ok(t)
}
#[allow(dead_code)]
pub fn get_data_list(self:&{{name}}) -> &Vec<std::rc::Rc<{{rust_define_type value_type}}>> { &self.data_list }
#[allow(dead_code)]
pub fn get(self:&{{name}}, index: usize) -> &std::rc::Rc<{{rust_define_type value_type}}> { &self.data_list[index] }
{{~else~}} {{~else~}}
if !__js.is_array() || __js.len() != 1 { if !__js.is_array() || __js.len() != 1 {
return Err(LoadError{}); return Err(LoadError{});

View File

@ -33,6 +33,28 @@ export class {{name}} {
get(key: {{ts_define_type key_type}}): {{ts_define_type value_type}} | undefined { return this._dataMap.get(key) } get(key: {{ts_define_type key_type}}): {{ts_define_type value_type}} | undefined { return this._dataMap.get(key) }
resolve(_tables: Map<string, any>) {
for(var v of this._dataList) {
v.resolve(_tables)
}
}
{{~else if x.is_list_table ~}}
private _dataList: {{ts_define_type value_type}}[]
constructor(_buf_: ByteBuf) {
this._dataList = []
for(let n = _buf_.ReadInt() ; n > 0 ; n--) {
let _v: {{ts_define_type value_type}}
{{ts_bin_constructor '_v' '_buf_' value_type}}
this._dataList.push(_v)
}
}
getDataList(): {{ts_define_type value_type}}[] { return this._dataList }
get(index: number): {{ts_define_type value_type}} | undefined { return this._dataList[index] }
resolve(_tables: Map<string, any>) { resolve(_tables: Map<string, any>) {
for(var v of this._dataList) { for(var v of this._dataList) {
v.resolve(_tables) v.resolve(_tables)

View File

@ -31,6 +31,27 @@ export class {{name}}{
get(key: {{ts_define_type key_type}}): {{ts_define_type value_type}} | undefined { return this._dataMap.get(key); } get(key: {{ts_define_type key_type}}): {{ts_define_type value_type}} | undefined { return this._dataMap.get(key); }
resolve(_tables: Map<string, any>) {
for(var v of this._dataList) {
v.resolve(_tables)
}
}
{{~else if x.is_list_table ~}}
private _dataList: {{ts_define_type value_type}}[]
constructor(_json_: any) {
this._dataList = []
for(var _json2_ of _json_) {
let _v: {{ts_define_type value_type}}
{{ts_json_constructor '_v' '_json2_' value_type}}
this._dataList.push(_v)
}
}
getDataList(): {{ts_define_type value_type}}[] { return this._dataList }
get(index: number): {{ts_define_type value_type}} | undefined { return this._dataList[index] }
resolve(_tables: Map<string, any>) { resolve(_tables: Map<string, any>) {
for(var v of this._dataList) { for(var v of this._dataList) {
v.resolve(_tables) v.resolve(_tables)