mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Start TEngine3.0
Start TEngine3.0
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
|
||||
{{
|
||||
name = x.py_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}}({{parent_def_type.py_full_name}}){{end}}:
|
||||
{{~if x.is_abstract_type~}}
|
||||
_childrenTypes = None
|
||||
|
||||
@staticmethod
|
||||
def fromJson(_json_):
|
||||
childrenTypes = {{name}}._childrenTypes
|
||||
if not childrenTypes:
|
||||
childrenTypes = {{name}}._childrenTypes = {
|
||||
{{~ for child in x.hierarchy_not_abstract_children~}}
|
||||
'{{cs_impl_data_type child x}}': {{child.py_full_name}},
|
||||
{{~end~}}
|
||||
}
|
||||
type = _json_['{{x.json_type_name_key}}']
|
||||
child = {{name}}._childrenTypes.get(type)
|
||||
if child != None:
|
||||
return child(_json_)
|
||||
else:
|
||||
raise Exception()
|
||||
{{~end~}}
|
||||
|
||||
def __init__(self, _json_):
|
||||
{{~if parent_def_type~}}
|
||||
{{parent_def_type.py_full_name}}.__init__(self, _json_)
|
||||
{{~end~}}
|
||||
{{~ for field in export_fields ~}}
|
||||
{{py3_deserialize_field ('self.' + field.convention_name) '_json_' field.name field.ctype}}
|
||||
{{~end~}}
|
||||
{{~if export_fields.empty?}}
|
||||
pass
|
||||
{{~end~}}
|
@@ -0,0 +1,54 @@
|
||||
from enum import Enum
|
||||
import abc
|
||||
|
||||
class Vector2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
def __str__(self):
|
||||
return '{%g,%g}' % (self.x, self.y)
|
||||
|
||||
@staticmethod
|
||||
def fromJson(_json_):
|
||||
x = _json_['x']
|
||||
y = _json_['y']
|
||||
if (x == None or y == None):
|
||||
raise Exception()
|
||||
return Vector2(x, y)
|
||||
|
||||
|
||||
class Vector3:
|
||||
def __init__(self, x, y, z):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
def __str__(self):
|
||||
return '{%f,%f,%f}' % (self.x, self.y, self.z)
|
||||
@staticmethod
|
||||
def fromJson(_json_):
|
||||
x = _json_['x']
|
||||
y = _json_['y']
|
||||
z = _json_['z']
|
||||
if (x == None or y == None or z == None):
|
||||
raise Exception()
|
||||
return Vector3(x, y, z)
|
||||
|
||||
class Vector4:
|
||||
def __init__(self, x, y, z, w):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
self.w = w
|
||||
def __str__(self):
|
||||
return '{%g,%g,%g,%g}' % (self.x, self.y, self.z, self.w)
|
||||
|
||||
@staticmethod
|
||||
def fromJson(_json_):
|
||||
x = _json_['x']
|
||||
y = _json_['y']
|
||||
z = _json_['z']
|
||||
w = _json_['w']
|
||||
if (x == None or y == None or z == None or w == None):
|
||||
raise Exception()
|
||||
return Vector4(x, y, z, w)
|
||||
|
@@ -0,0 +1,54 @@
|
||||
{{
|
||||
name = x.py_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 ~}}
|
||||
|
||||
def __init__(self, _json_ ):
|
||||
self._dataMap = {}
|
||||
self._dataList = []
|
||||
|
||||
for _json2_ in _json_:
|
||||
{{py3_deserialize_value '_v' '_json2_' value_type}}
|
||||
self._dataList.append(_v)
|
||||
self._dataMap[_v.{{x.index_field.convention_name}}] = _v
|
||||
|
||||
def getDataMap(self) : return self._dataMap
|
||||
def getDataList(self) : return self._dataList
|
||||
|
||||
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~}}
|
||||
|
||||
def __init__(self, _json_):
|
||||
if (len(_json_) != 1): raise Exception('table mode=one, but size != 1')
|
||||
{{py3_deserialize_value 'self._data' '_json_[0]' value_type}}
|
||||
|
||||
def getData(self) : return self._data
|
||||
|
||||
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
|
||||
{{~if field.comment != '' ~}}
|
||||
'''
|
||||
{{field.escape_comment}}
|
||||
'''
|
||||
{{~end~}}
|
||||
def {{field.convention_name}}(self) : return self._data.{{field.convention_name}}
|
||||
{{~end~}}
|
||||
{{~end~}}
|
@@ -0,0 +1,15 @@
|
||||
{{
|
||||
name = x.name
|
||||
namespace = x.namespace
|
||||
tables = x.tables
|
||||
}}
|
||||
|
||||
class {{name}}:
|
||||
{{~ for table in tables ~}}
|
||||
#def {{table.name}} : return self._{{table.name}}
|
||||
{{~end~}}
|
||||
|
||||
def __init__(self, loader):
|
||||
{{~for table in tables ~}}
|
||||
self.{{table.name}} = {{table.py_full_name}}(loader('{{table.output_data_file}}'));
|
||||
{{~end~}}
|
Reference in New Issue
Block a user