diff --git a/.gitignore b/.gitignore index 9bf182d..0336fe7 100644 --- a/.gitignore +++ b/.gitignore @@ -267,3 +267,4 @@ __pycache__/ /config/output_code /config/output_data +/config/output_lua diff --git a/config/Datas/test/full_type.xlsx b/config/Datas/test/full_type.xlsx index ba9641a..bb5374a 100644 Binary files a/config/Datas/test/full_type.xlsx and b/config/Datas/test/full_type.xlsx differ diff --git a/config/Datas/test/json_datas/1.json b/config/Datas/test/json_datas/1.json index 873e9b9..391f630 100644 --- a/config/Datas/test/json_datas/1.json +++ b/config/Datas/test/json_datas/1.json @@ -13,6 +13,7 @@ "x12": { "x1":10}, "x13":"B", "x14":{"__type__": "DemoD2", "x1":1, "x2":2}, + "s1": {"key":"/asfa", "text":"aabbcc"}, "v2":{"x":1, "y":2}, "v3":{"x":1.1, "y":2.2, "z":3.4}, "v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4}, diff --git a/config/Datas/test/json_datas/2.json b/config/Datas/test/json_datas/2.json index d3be8bb..5c59c81 100644 --- a/config/Datas/test/json_datas/2.json +++ b/config/Datas/test/json_datas/2.json @@ -13,6 +13,7 @@ "x12": { "x1":10}, "x13":"B", "x14":{"__type__": "DemoD2", "x1":1, "x2":2}, + "s1": {"key":"/asfa32", "text":"aabbcc22"}, "v2":{"x":1, "y":2}, "v3":{"x":1.1, "y":2.2, "z":3.4}, "v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4}, diff --git a/config/Datas/test/lua_datas/demo.lua b/config/Datas/test/lua_datas/demo.lua index 5d8daf3..1375dc7 100644 --- a/config/Datas/test/lua_datas/demo.lua +++ b/config/Datas/test/lua_datas/demo.lua @@ -14,6 +14,7 @@ return x12 = {x1=1}, x13 = "D", x14 = { __type__="DemoD2", x1 = 1, x2=3}, + s1 = { key="lua/key1", text="lua text "}, v2 = {x= 1,y = 2}, v3 = {x=0.1, y= 0.2,z=0.3}, v4 = {x=1,y=2,z=3.5,w=4}, diff --git a/config/Datas/test/table_one.xlsx b/config/Datas/test/table_one.xlsx index 2205225..7b5a98e 100644 Binary files a/config/Datas/test/table_one.xlsx and b/config/Datas/test/table_one.xlsx differ diff --git a/config/Datas/test/xml_datas/1.xml b/config/Datas/test/xml_datas/1.xml index b789737..adb9a54 100644 --- a/config/Datas/test/xml_datas/1.xml +++ b/config/Datas/test/xml_datas/1.xml @@ -18,7 +18,7 @@ 1 2 - + xml_key1xml text 1,2 1.2,2.3,3.4 1.2,2.2,3.2,4.3 diff --git a/config/Datas/test/xml_datas/2.xml b/config/Datas/test/xml_datas/2.xml index 7b0ffbf..2bd1dd1 100644 --- a/config/Datas/test/xml_datas/2.xml +++ b/config/Datas/test/xml_datas/2.xml @@ -18,7 +18,7 @@ 1 2 - + xml_key2xml text222 1,2 1.2,2.3,3.4 1.2,2.2,3.2,4.3 diff --git a/config/Defines/test.xml b/config/Defines/test.xml index 62edbee..2d32cbe 100644 --- a/config/Defines/test.xml +++ b/config/Defines/test.xml @@ -58,6 +58,8 @@ 多态数据结构 + + diff --git a/config/output_lua/TbDataFromJson.lua b/config/output_lua/TbDataFromJson.lua deleted file mode 100644 index 3c1ad34..0000000 --- a/config/output_lua/TbDataFromJson.lua +++ /dev/null @@ -1,5 +0,0 @@ -return -{ -[1] = {x4=1,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},}, -[2] = {x4=2,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},}, -} \ No newline at end of file diff --git a/config/output_lua/TbDataFromLua.lua b/config/output_lua/TbDataFromLua.lua deleted file mode 100644 index 47cc016..0000000 --- a/config/output_lua/TbDataFromLua.lua +++ /dev/null @@ -1,4 +0,0 @@ -return -{ -[1122] = {x4=1122,x1=false,x2=2,x3=128,x5=112233445566,x6=1.3,x7=1122,x8_0=13,x8=12,x9=123,x10='yf',x12={x1=1,},x13=5,x14={ _name='test.DemoD2',x1=1,x2=3,},v2={x=1,y=2},v3={x=0.1,y=0.2,z=0.3},v4={x=1,y=2,z=3.5,w=4},t1=-28800,k1={1,2,},k2={2,3,},k3={3,4,},k4={1,2,},k5={1,3,},k6={1,2,},k7={1,8,},k8={[2]=10,[3]=12,},k9={{y1=1,y2=true,},{y1=10,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=3,},},}, -} \ No newline at end of file diff --git a/config/output_lua/TbDataFromXml.lua b/config/output_lua/TbDataFromXml.lua deleted file mode 100644 index 5d3b12d..0000000 --- a/config/output_lua/TbDataFromXml.lua +++ /dev/null @@ -1,5 +0,0 @@ -return -{ -[1] = {x4=1,x1=true,x2=4,x3=128,x5=112233445566,x6=1.3,x7=1112232.43123,x8_0=123,x8=112233,x9=112334,x10='yf',x12={x1=1,},x13=4,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.2,y=2.3,z=3.4},v4={x=1.2,y=2.2,z=3.2,w=4.3},t1=-28800,k1={1,2,},k2={1,2,},k3={1,2,},k4={1,2,},k5={1,2,},k6={1,2,},k7={1,3,},k8={[2]=10,[3]=30,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},}, -[2] = {x4=2,x1=true,x2=4,x3=128,x5=112233445566,x6=1.3,x7=1112232.43123,x8_0=123,x8=112233,x9=112334,x10='yf',x12={x1=1,},x13=4,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.2,y=2.3,z=3.4},v4={x=1.2,y=2.2,z=3.2,w=4.3},t1=-28800,k1={1,2,},k2={1,2,},k3={1,2,},k4={1,2,},k5={1,2,},k6={1,2,},k7={1,3,},k8={[2]=10,[3]=30,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},}, -} \ No newline at end of file diff --git a/config/output_lua/TbFullTypes.lua b/config/output_lua/TbFullTypes.lua deleted file mode 100644 index 955f7ab..0000000 --- a/config/output_lua/TbFullTypes.lua +++ /dev/null @@ -1,11 +0,0 @@ -return -{ -[1] = {x4=10000,x1=true,x2=5,x3=1,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=3,},},}, -[3] = {x4=10001,x1=true,x2=5,x3=3,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=5,},},}, -[4] = {x4=10002,x1=true,x2=5,x3=4,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=1577808000,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=6,},},}, -[5] = {x4=10003,x1=true,x2=5,x3=5,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=7,},},}, -[6] = {x4=10001,x1=true,x2=5,x3=6,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=1577808000,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=8,},},}, -[7] = {x4=10002,x1=true,x2=5,x3=7,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=9,},},}, -[8] = {x4=10003,x1=true,x2=5,x3=8,x5=2,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=1577808000,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=10,},},}, -[9] = {x4=1,x1=true,x2=5,x3=9,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=11,},},}, -} \ No newline at end of file diff --git a/config/output_lua/TbMultiRowRecord.lua b/config/output_lua/TbMultiRowRecord.lua deleted file mode 100644 index f593027..0000000 --- a/config/output_lua/TbMultiRowRecord.lua +++ /dev/null @@ -1,6 +0,0 @@ -return -{ -[1] = {id=1,name='xxx',one_rows={{id=1,x=2,},},multi_rows1={{id=1,x=2,},},multi_rows2={{id=1,x=2,},},multi_rows3={{id=1,x=2,y=3,},},multi_rows4={[1]={id=1,x=2,y=3,},},}, -[2] = {id=2,name='xxx',one_rows={{id=2,x=4,},},multi_rows1={{id=2,x=4,},},multi_rows2={{id=3,x=4,},{id=3,x=4,},},multi_rows3={{id=2,x=3,y=4,},{id=2,x=3,y=4,},},multi_rows4={[2]={id=4,x=5,y=4,},},}, -[3] = {id=3,name='ds',one_rows={{id=1,x=2,},},multi_rows1={{id=1,x=2,},{id=2,x=4,},},multi_rows2={{id=3,x=4,},{id=3,x=4,},},multi_rows3={{id=1,x=2,y=3,},{id=2,x=3,y=4,},},multi_rows4={[1]={id=1,x=2,y=3,},[2]={id=4,x=5,y=4,},[3]={id=4,x=5,y=4,},},}, -} \ No newline at end of file diff --git a/config/output_lua/TbMultiRowTitle.lua b/config/output_lua/TbMultiRowTitle.lua deleted file mode 100644 index c5ce13f..0000000 --- a/config/output_lua/TbMultiRowTitle.lua +++ /dev/null @@ -1,4 +0,0 @@ -return -{ -[1] = {id=1,name='xxx',x1={y2={z2=2,z3=3,},y3=4,},x2={{z2=1,z3=2,},{z2=3,z3=4,},},x3={{z2=1,z3=2,},{z2=3,z3=4,},},}, -} \ No newline at end of file diff --git a/config/output_lua/TbSingleton.lua b/config/output_lua/TbSingleton.lua deleted file mode 100644 index acb8f3e..0000000 --- a/config/output_lua/TbSingleton.lua +++ /dev/null @@ -1,2 +0,0 @@ -return -{id=5,name='aabbcc',date={ _name='test.DemoD5',x1=1,time={start_time=398966400,end_time=936806400,},},} \ No newline at end of file diff --git a/config/output_lua/TbTwoKey.lua b/config/output_lua/TbTwoKey.lua deleted file mode 100644 index 3fc4f5d..0000000 --- a/config/output_lua/TbTwoKey.lua +++ /dev/null @@ -1,8 +0,0 @@ -return -{ -[128] = -{ -[1] = {x4=1,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},}, -[2] = {x4=2,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},}, -}, -} \ No newline at end of file diff --git a/config/output_lua/Types.lua b/config/output_lua/Types.lua deleted file mode 100644 index 9ddd9c8..0000000 --- a/config/output_lua/Types.lua +++ /dev/null @@ -1,331 +0,0 @@ - ---[[------------------------------------------------------------------------------ --- --- This code was generated by a tool. --- Changes to this file may cause incorrect behavior and will be lost if --- the code is regenerated. --- ---]]------------------------------------------------------------------------------ - - - -local consts = -{ - ---@class test.DemoConst - ---@field public x1 int - ---@field public x2 long - ---@field public x3 float - ---@field public x4 double - ['test.DemoConst'] = { x1=0, x2=3242, x3=444.3, x4=55.3, }; -} - -local enums = -{ - ---@class test.DemoEnum - ---@field public A int - ---@field public B int - ---@field public C int - ---@field public D int - ['test.DemoEnum'] = { A=1, B=2, C=4, D=5, }; - ---@class test.ETestUeType - ---@field public WHITE int - ---@field public BLACK int - ['test.ETestUeType'] = { WHITE=0, BLACK=1, }; - ---@class test.ETestEmptyEnum - ['test.ETestEmptyEnum'] = { }; - ---@class test.ETestEmptyEnum2 - ---@field public SMALL_THAN_256 int - ---@field public X_256 int - ---@field public X_257 int - ['test.ETestEmptyEnum2'] = { SMALL_THAN_256=255, X_256=256, X_257=257, }; -} - -local beans = {} ----@class test.DemoType1 ----@field public x1 int -beans['test.DemoType1'] = -{ - { name='x1', type='int'}, -} - ----@class test.DemoDynamic ----@field public x1 int -beans['test.DemoDynamic'] = -{ - { name='x1', type='int'}, -} - ----@class test.DemoD2 :test.DemoDynamic ----@field public x2 int -beans['test.DemoD2'] = -{ - { name='x1', type='int'}, - { name='x2', type='int'}, -} - ----@class test.DemoD3 :test.DemoDynamic ----@field public x3 int -beans['test.DemoD3'] = -{ - { name='x1', type='int'}, - { name='x3', type='int'}, -} - ----@class test.DemoE1 :test.DemoD3 ----@field public x4 int -beans['test.DemoE1'] = -{ - { name='x1', type='int'}, - { name='x3', type='int'}, - { name='x4', type='int'}, -} - ----@class test.DemoD5 :test.DemoDynamic ----@field public time test.DateTimeRange -beans['test.DemoD5'] = -{ - { name='x1', type='int'}, - { name='time', type='test.DateTimeRange'}, -} - ----@class test.DemoE2 ----@field public y1 int ----@field public y2 bool -beans['test.DemoE2'] = -{ - { name='y1', type='int'}, - { name='y2', type='bool'}, -} - ----@class test.DemoType2 ----@field public x4 int ----@field public x1 bool ----@field public x2 byte ----@field public x3 short ----@field public x5 long ----@field public x6 float ----@field public x7 double ----@field public x8_0 short ----@field public x8 int ----@field public x9 long ----@field public x10 string ----@field public x12 test.DemoType1 ----@field public x13 test.DemoEnum ----@field public x14 test.DemoDynamic ----@field public v2 vector2 ----@field public v3 vector3 ----@field public v4 vector4 ----@field public t1 int ----@field public k1 int[] ----@field public k2 int[] ----@field public k3 int[] ----@field public k4 int[] ----@field public k5 int[] ----@field public k6 int[] ----@field public k7 int[] ----@field public k8 table ----@field public k9 test.DemoE2[] ----@field public k15 test.DemoDynamic[] -beans['test.DemoType2'] = -{ - { name='x4', type='int'}, - { name='x1', type='bool'}, - { name='x2', type='byte'}, - { name='x3', type='short'}, - { name='x5', type='long'}, - { name='x6', type='float'}, - { name='x7', type='double'}, - { name='x8_0', type='short'}, - { name='x8', type='int'}, - { name='x9', type='long'}, - { name='x10', type='string'}, - { name='x12', type='test.DemoType1'}, - { name='x13', type='test.DemoEnum'}, - { name='x14', type='test.DemoDynamic'}, - { name='v2', type='vector2'}, - { name='v3', type='vector3'}, - { name='v4', type='vector4'}, - { name='t1', type='int'}, - { name='k1', type='int[]'}, - { name='k2', type='int[]'}, - { name='k3', type='int[]'}, - { name='k4', type='int[]'}, - { name='k5', type='int[]'}, - { name='k6', type='int[]'}, - { name='k7', type='int[]'}, - { name='k8', type='table'}, - { name='k9', type='test.DemoE2[]'}, - { name='k15', type='test.DemoDynamic[]'}, -} - ----@class test.DateTimeRange ----@field public start_time int ----@field public end_time int -beans['test.DateTimeRange'] = -{ - { name='start_time', type='int'}, - { name='end_time', type='int'}, -} - ----@class test.DemoSingletonType ----@field public id int ----@field public name string ----@field public date test.DemoDynamic -beans['test.DemoSingletonType'] = -{ - { name='id', type='int'}, - { name='name', type='string'}, - { name='date', type='test.DemoDynamic'}, -} - ----@class test.MultiRowType1 ----@field public id int ----@field public x int -beans['test.MultiRowType1'] = -{ - { name='id', type='int'}, - { name='x', type='int'}, -} - ----@class test.MultiRowType2 ----@field public id int ----@field public x int ----@field public y float -beans['test.MultiRowType2'] = -{ - { name='id', type='int'}, - { name='x', type='int'}, - { name='y', type='float'}, -} - ----@class test.MultiRowRecord ----@field public id int ----@field public name string ----@field public one_rows test.MultiRowType1[] ----@field public multi_rows1 test.MultiRowType1[] ----@field public multi_rows2 test.MultiRowType1[] ----@field public multi_rows3 test.MultiRowType2[] ----@field public multi_rows4 table -beans['test.MultiRowRecord'] = -{ - { name='id', type='int'}, - { name='name', type='string'}, - { name='one_rows', type='test.MultiRowType1[]'}, - { name='multi_rows1', type='test.MultiRowType1[]'}, - { name='multi_rows2', type='test.MultiRowType1[]'}, - { name='multi_rows3', type='test.MultiRowType2[]'}, - { name='multi_rows4', type='table'}, -} - ----@class test.TestUeType ----@field public x1 bool ----@field public x2 byte ----@field public x3 short ----@field public x4 int ----@field public x5 long ----@field public x6 float ----@field public x10 string ----@field public x12 test.DemoType1 ----@field public x13 test.ETestUeType ----@field public v2 vector2 ----@field public v3 vector3 ----@field public v4 vector4 ----@field public t1 int ----@field public k1 int[] ----@field public k2 int[] ----@field public k3 int[] ----@field public k4 int[] ----@field public k5 int[] ----@field public k6 int[] ----@field public k7 int[] ----@field public k8 table ----@field public k9 test.DemoE2[] -beans['test.TestUeType'] = -{ - { name='x1', type='bool'}, - { name='x2', type='byte'}, - { name='x3', type='short'}, - { name='x4', type='int'}, - { name='x5', type='long'}, - { name='x6', type='float'}, - { name='x10', type='string'}, - { name='x12', type='test.DemoType1'}, - { name='x13', type='test.ETestUeType'}, - { name='v2', type='vector2'}, - { name='v3', type='vector3'}, - { name='v4', type='vector4'}, - { name='t1', type='int'}, - { name='k1', type='int[]'}, - { name='k2', type='int[]'}, - { name='k3', type='int[]'}, - { name='k4', type='int[]'}, - { name='k5', type='int[]'}, - { name='k6', type='int[]'}, - { name='k7', type='int[]'}, - { name='k8', type='table'}, - { name='k9', type='test.DemoE2[]'}, -} - ----@class test.H1 ----@field public y2 test.H2 ----@field public y3 int -beans['test.H1'] = -{ - { name='y2', type='test.H2'}, - { name='y3', type='int'}, -} - ----@class test.H2 ----@field public z2 int ----@field public z3 int -beans['test.H2'] = -{ - { name='z2', type='int'}, - { name='z3', type='int'}, -} - ----@class test.MultiRowTitle ----@field public id int ----@field public name string ----@field public x1 test.H1 ----@field public x2 test.H2[] ----@field public x3 test.H2[] -beans['test.MultiRowTitle'] = -{ - { name='id', type='int'}, - { name='name', type='string'}, - { name='x1', type='test.H1'}, - { name='x2', type='test.H2[]'}, - { name='x3', type='test.H2[]'}, -} - ----@class test.login.RoleInfo ----@field public role_id long -beans['test.login.RoleInfo'] = -{ - { name='role_id', type='long'}, -} - - -local tables = -{ - { name='TbFullTypes', file='test.TbFullTypes.bin', mode='map', index='x3', value_type='test.DemoType2' }, - - { name='TbSingleton', file='test.TbSingleton.bin', mode='one', value_type='test.DemoSingletonType'}, - - { name='TbDataFromJson', file='test.TbDataFromJson.bin', mode='map', index='x4', value_type='test.DemoType2' }, - - { name='TbDataFromXml', file='test.TbDataFromXml.bin', mode='map', index='x4', value_type='test.DemoType2' }, - - { name='TbDataFromLua', file='test.TbDataFromLua.bin', mode='map', index='x4', value_type='test.DemoType2' }, - - { name='TbTwoKey', file='test.TbTwoKey.bin', mode='bmap', index1='x3', index2='x4', value_type='test.DemoType2' }, - - { name='TbMultiRowRecord', file='test.TbMultiRowRecord.bin', mode='map', index='id', value_type='test.MultiRowRecord' }, - - { name='TbMultiRowTitle', file='test.TbMultiRowTitle.bin', mode='map', index='id', value_type='test.MultiRowTitle' }, - -} - -return { consts = consts, enums = enums, beans = beans, tables = tables } - diff --git a/config/生成lua数据.bat b/config/生成lua数据.bat index d850d87..49b944c 100644 --- a/config/生成lua数据.bat +++ b/config/生成lua数据.bat @@ -2,7 +2,7 @@ -h %LUBAN_SERVER_IP% ^ -j cfg ^ -- ^ - -d Defines/root.xml ^ + -d Defines/__root__.xml ^ --input_data_dir Datas ^ --output_data_dir output_lua ^ -s client ^ diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs index 8eef8f3..504f086 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs @@ -82,6 +82,8 @@ namespace Luban.Job.Cfg.DataSources.Excel public string CurrentExcelPosition => _datas[Math.Min(_curIndex, _datas.Count - 1)].ToString(); + public int IncludeNullAndEmptySize => _toIndex - _curIndex + 1; + public override string ToString() { var sb = new StringBuilder(); diff --git a/src/Luban.Job.Cfg/Source/Datas/DText.cs b/src/Luban.Job.Cfg/Source/Datas/DText.cs index c898a9f..fc92881 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DText.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DText.cs @@ -4,8 +4,13 @@ namespace Luban.Job.Cfg.Datas { public class DText : DType { - public DText(string x) : base(x) + public string Key { get; } + + public DText(string key, string x) : base(x) { + Key = key; + + System.Console.WriteLine("== text. key:{0} text:{1}", key, x); } public override void Apply(IDataActionVisitor visitor, T x) diff --git a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs index 2859b4e..058c150 100644 --- a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs +++ b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs @@ -39,6 +39,8 @@ namespace Luban.Job.Cfg.Defs public Dictionary CfgTables { get; } = new Dictionary(); + private readonly ConcurrentDictionary _texts = new ConcurrentDictionary(); + public void AddCfgTable(DefTable table) { if (!CfgTables.TryAdd(table.FullName, table)) @@ -109,6 +111,22 @@ namespace Luban.Job.Cfg.Defs return refTypes.Values.ToList(); } + public void AddText(string key, string text) + { + if (key == null || text == null) + { + throw new Exception("text的key或text属性不能为null"); + } + if (key == "" && text != "") + { + throw new InvalidExcelDataException($"text key为空, 但text:{text}不为空"); + } + if (!_texts.TryAdd(key, text) && _texts[key] != text) + { + throw new Exception($"text key:{key} 出现多次,但值不相同. 当前:{text} 之前:{_texts[key]}"); + } + } + public void Load(string outputService, Defines defines, RemoteAgent agent) { this.Agent = agent; diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/ExcelDataCreator.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/ExcelDataCreator.cs index 8719a39..423b502 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/ExcelDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/ExcelDataCreator.cs @@ -7,6 +7,7 @@ using Luban.Job.Common.Types; using Luban.Job.Common.TypeVisitors; using System; using System.Collections.Generic; +using System.Runtime.Serialization; namespace Luban.Job.Cfg.TypeVisitors { @@ -18,6 +19,25 @@ namespace Luban.Job.Cfg.TypeVisitors NULL_STR_AS_NULL = 0x8, } + class InvalidExcelDataException : Exception + { + public InvalidExcelDataException() + { + } + + public InvalidExcelDataException(string message) : base(message) + { + } + + public InvalidExcelDataException(string message, Exception innerException) : base(message, innerException) + { + } + + protected InvalidExcelDataException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } + class ExcelDataCreator : ITypeFuncVisitor { public static ExcelDataCreator Ins { get; } = new ExcelDataCreator(); @@ -32,7 +52,7 @@ namespace Luban.Job.Cfg.TypeVisitors } else { - throw new Exception($"单元格没有填有效数据"); + throw new InvalidExcelDataException($"单元格没有填有效数据"); } } return false; @@ -51,7 +71,7 @@ namespace Luban.Job.Cfg.TypeVisitors case "是": return true; case "false": case "否": return false; - default: throw new Exception($"{s} 不是 bool 类型的值 (true 或 false)"); + default: throw new InvalidExcelDataException($"{s} 不是 bool 类型的值 (true 或 false)"); } } @@ -74,7 +94,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!byte.TryParse(d.ToString(), out byte v)) { - throw new Exception($"{d} 不是 byte 类型值"); + throw new InvalidExcelDataException($"{d} 不是 byte 类型值"); } return new DByte(v); } @@ -88,7 +108,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!short.TryParse(d.ToString(), out short v)) { - throw new Exception($"{d} 不是 short 类型值"); + throw new InvalidExcelDataException($"{d} 不是 short 类型值"); } return new DShort(v); } @@ -102,7 +122,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!short.TryParse(d.ToString(), out short v)) { - throw new Exception($"{d} 不是 short 类型值"); + throw new InvalidExcelDataException($"{d} 不是 short 类型值"); } return new DFshort(v); } @@ -124,7 +144,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!int.TryParse(ds, out var v)) { - throw new Exception($"{d} 不是 int 类型值"); + throw new InvalidExcelDataException($"{d} 不是 int 类型值"); } return new DInt(v); } @@ -146,7 +166,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!int.TryParse(ds, out var v)) { - throw new Exception($"{d} 不是 int 类型值"); + throw new InvalidExcelDataException($"{d} 不是 int 类型值"); } return new DFint(v); } @@ -168,7 +188,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!long.TryParse(ds, out var v)) { - throw new Exception($"{d} 不是 long 类型值"); + throw new InvalidExcelDataException($"{d} 不是 long 类型值"); } return new DLong(v); } @@ -190,7 +210,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!long.TryParse(ds, out var v)) { - throw new Exception($"{d} 不是 long 类型值"); + throw new InvalidExcelDataException($"{d} 不是 long 类型值"); } return new DFlong(v); } @@ -204,7 +224,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!float.TryParse(d.ToString(), out var v)) { - throw new Exception($"{d} 不是 float 类型值"); + throw new InvalidExcelDataException($"{d} 不是 float 类型值"); } return new DFloat(v); } @@ -218,7 +238,7 @@ namespace Luban.Job.Cfg.TypeVisitors } if (!double.TryParse(d.ToString(), out var v)) { - throw new Exception($"{d} 不是 double 类型值"); + throw new InvalidExcelDataException($"{d} 不是 double 类型值"); } return new DDouble(v); } @@ -235,16 +255,11 @@ namespace Luban.Job.Cfg.TypeVisitors public DType Accept(TString type, object converter, ExcelStream x, DefAssembly ass) { - var d = x.Read(x.NamedMode); - if (d == null) + if (x.NamedMode && x.IncludeNullAndEmptySize != 1) { - return new DString(""); + throw new InvalidExcelDataException("excel string类型在标题头对应模式下必须正好占据一个单元格"); } - if (d is string s) - { - return new DString(DataUtil.UnEscapeString(s)); - } - return new DString(d.ToString()); + return new DString(ParseString(x.Read(x.NamedMode))); } public DType Accept(TBytes type, object converter, ExcelStream x, DefAssembly ass) @@ -252,18 +267,32 @@ namespace Luban.Job.Cfg.TypeVisitors throw new NotImplementedException(); } - public DType Accept(TText type, object converter, ExcelStream x, DefAssembly ass) + private static string ParseString(object d) { - var d = x.Read(x.NamedMode); if (d == null) { - return new DString(""); + return ""; } - if (d is string s) + else if (d is string s) { - return new DString(DataUtil.UnEscapeString(s)); + return DataUtil.UnEscapeString(s); } - return new DString(d.ToString()); + else + { + return d.ToString(); + } + } + + public DType Accept(TText type, object converter, ExcelStream x, DefAssembly ass) + { + if (x.NamedMode && x.IncludeNullAndEmptySize != 2) + { + throw new InvalidExcelDataException("excel text 类型在标题头对应模式下必须正好占据2个单元格"); + } + string key = ParseString(x.Read(x.NamedMode)); + string text = ParseString(x.Read(x.NamedMode)); + ass.AddText(key, text); + return new DText(key, text); } private List CreateBeanFields(DefBean bean, ExcelStream stream, DefAssembly ass) @@ -285,7 +314,7 @@ namespace Luban.Job.Cfg.TypeVisitors } catch (Exception e) { - throw new Exception($"读取结构:{bean.FullName} 字段:{f.Name} 出错 ==> {e.Message}", e); + throw new InvalidExcelDataException($"读取结构:{bean.FullName} 字段:{f.Name} 出错 ==> {e.Message}", e); } } return list; @@ -306,7 +335,7 @@ namespace Luban.Job.Cfg.TypeVisitors DefBean implType = (DefBean)originBean.GetNotAbstractChildType(subType); if (implType == null) { - throw new Exception($"type:{fullType} 不是bean类型"); + throw new InvalidExcelDataException($"type:{fullType} 不是bean类型"); } return new DBean(originBean, implType, CreateBeanFields(implType, x, ass)); } @@ -364,7 +393,7 @@ namespace Luban.Job.Cfg.TypeVisitors var value = string.IsNullOrWhiteSpace(sep) ? type.ValueType.Apply(this, null, x, ass) : type.ValueType.Apply(this, null, new ExcelStream(x.ReadCell(), sep, false), ass); if (!datas.TryAdd(key, value)) { - throw new Exception($"map 的 key:{key} 重复"); + throw new InvalidExcelDataException($"map 的 key:{key} 重复"); } } return new DMap(type, datas); diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/JsonDataCreator.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/JsonDataCreator.cs index eb17946..f83edb2 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/JsonDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/JsonDataCreator.cs @@ -81,7 +81,27 @@ namespace Luban.Job.Cfg.TypeVisitors public DType Accept(TText type, JsonElement x, DefAssembly ass) { - return new DText(x.GetString()); + if (!x.TryGetProperty("key", out var keyEle)) + { + throw new Exception("text 缺失 key属性"); + } + if (!x.TryGetProperty("text", out var textEle)) + { + throw new Exception("text 缺失 text属性"); + } + string key = keyEle.GetString(); + if (key == null) + { + throw new Exception("text key不是字符串"); + } + string text = textEle.GetString(); + if (text == null) + { + throw new Exception("text text不是字符串"); + } + + ass.AddText(key, text); + return new DText(key, text); } public DType Accept(TBean type, JsonElement x, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/LuaDataCreator.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/LuaDataCreator.cs index 53235c2..8c3bc6e 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/LuaDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/LuaDataCreator.cs @@ -108,17 +108,40 @@ namespace Luban.Job.Cfg.TypeVisitors public DType Accept(TString type, object x, DefAssembly ass) { - return new DString(x?.ToString()); + if (x is string s) + { + return new DString(s); + } + else + { + throw new Exception($"{x} 不是 double 类型数据"); + } } public DType Accept(TBytes type, object x, DefAssembly ass) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TText type, object x, DefAssembly ass) { - return new DText(x?.ToString()); + var table = (LuaTable)x; + if (table == null) + { + throw new Exception($"字段不是 text类型({{key=xx,text=yy}}}})"); + } + string key = (string)table["key"]; + string text = (string)table["text"]; + if (key == null) + { + throw new Exception("text缺失key属性"); + } + if (text == null) + { + throw new Exception("text缺失text属性"); + } + ass.AddText(key, text); + return new DText(key, text); } public DType Accept(TBean type, object x, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/StringDataCreator.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/StringDataCreator.cs index d4bb248..1444f17 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/StringDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/StringDataCreator.cs @@ -1,4 +1,5 @@ using Luban.Job.Cfg.Datas; +using Luban.Job.Cfg.Utils; using Luban.Job.Common.Types; using Luban.Job.Common.TypeVisitors; using System; @@ -141,57 +142,59 @@ namespace Luban.Job.Cfg.TypeVisitors public DType Accept(TBytes type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TText type, string x) { - return new DText(x); + //var (key, text) = DataUtil.ExtractText(x); + //return new DText(key, text); + throw new NotSupportedException(); } public DType Accept(TBean type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TArray type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TList type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TSet type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TMap type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TVector2 type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TVector3 type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TVector4 type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public DType Accept(TDateTime type, string x) { - throw new NotImplementedException(); + throw new NotSupportedException(); } } } diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/XmlDataCreator.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/XmlDataCreator.cs index 3231e43..6ecca18 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/XmlDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/XmlDataCreator.cs @@ -82,7 +82,10 @@ namespace Luban.Job.Cfg.TypeVisitors public DType Accept(TText type, XElement x, DefAssembly ass) { - return new DText(x.Value); + var key = x.Element("key").Value; + var text = x.Element("text").Value; + ass.AddText(key, text); + return new DText(key, text); } public DType Accept(TBean type, XElement x, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs index fabe806..5064482 100644 --- a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs +++ b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs @@ -73,6 +73,16 @@ namespace Luban.Job.Cfg.Utils return s; } + public static (string Key, string Text) ExtractText(string rawKeyAndText) + { + string[] keyAndText = rawKeyAndText.Split('|'); + if (keyAndText.Length != 2) + { + throw new Exception("text data should like |"); + } + return (keyAndText[0], keyAndText[1]); + } + //public static string Data2String(DType data) //{ // var s = new StringBuilder();