【重构】提取 cfg code_python_27和 code_python_3 关于vector定义的公共字符串。不再重复出现。
【重构】删除 proto typescript 生成代码中行末的';'main
parent
260a1a84a3
commit
9e32c2f4fd
|
|
@ -151,7 +151,7 @@ namespace Luban.Job.Cfg
|
||||||
errMsg = "--output_data_resource_list_file missing";
|
errMsg = "--output_data_resource_list_file missing";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (genTypes.Contains("data_json_monolithic") && string.IsNullOrWhiteSpace(options.OutputDataJsonMonolithicFile))
|
if (genTypes.Contains("output_data_json_monolithic_file") && string.IsNullOrWhiteSpace(options.OutputDataJsonMonolithicFile))
|
||||||
{
|
{
|
||||||
errMsg = "--output_data_json_monolithic_file missing";
|
errMsg = "--output_data_json_monolithic_file missing";
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -660,60 +660,7 @@ export class Vector2 {
|
||||||
{
|
{
|
||||||
var fileContent = new List<string>
|
var fileContent = new List<string>
|
||||||
{
|
{
|
||||||
@"
|
PYTHON_VECTOR_DEFINES
|
||||||
class Vector2:
|
|
||||||
def __init__(self, x, y):
|
|
||||||
self.x = x
|
|
||||||
self.y = y
|
|
||||||
self.a = Vector4(1,2,3,4)
|
|
||||||
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)
|
|
||||||
|
|
||||||
"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var type in exportTypes)
|
foreach (var type in exportTypes)
|
||||||
|
|
@ -775,60 +722,8 @@ class Vector4:
|
||||||
@"
|
@"
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import abc
|
import abc
|
||||||
|
",
|
||||||
class Vector2:
|
PYTHON_VECTOR_DEFINES,
|
||||||
def __init__(self, x, y):
|
|
||||||
self.x = x
|
|
||||||
self.y = y
|
|
||||||
self.a = Vector4(1,2,3,4)
|
|
||||||
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)
|
|
||||||
|
|
||||||
"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var type in exportTypes)
|
foreach (var type in exportTypes)
|
||||||
|
|
@ -913,7 +808,7 @@ class Vector4:
|
||||||
tasks.Add(Task.Run(() =>
|
tasks.Add(Task.Run(() =>
|
||||||
{
|
{
|
||||||
var content = FileHeaderUtil.ConcatAutoGenerationHeader(render.RenderAny(c), ELanguage.CS);
|
var content = FileHeaderUtil.ConcatAutoGenerationHeader(render.RenderAny(c), ELanguage.CS);
|
||||||
var file = RenderFileUtil.GetDefTypePath(c.FullName, ELanguage.GO);
|
var file = RenderFileUtil.GetDefTypePath(c.FullName, ELanguage.CS);
|
||||||
var md5 = CacheFileUtil.GenMd5AndAddCache(file, content);
|
var md5 = CacheFileUtil.GenMd5AndAddCache(file, content);
|
||||||
genCodeFilesInOutputCodeDir.Add(new FileInfo() { FilePath = file, MD5 = md5 });
|
genCodeFilesInOutputCodeDir.Add(new FileInfo() { FilePath = file, MD5 = md5 });
|
||||||
}));
|
}));
|
||||||
|
|
@ -1096,5 +991,59 @@ class Vector4:
|
||||||
|
|
||||||
agent.Session.ReplyRpc<GenJob, GenJobArg, GenJobRes>(rpc, res);
|
agent.Session.ReplyRpc<GenJob, GenJobArg, GenJobRes>(rpc, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const string PYTHON_VECTOR_DEFINES = @"
|
||||||
|
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)
|
||||||
|
|
||||||
|
";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,11 +179,11 @@ export abstract class Protocol implements ISerializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Vector2 {
|
export class Vector2 {
|
||||||
x: number;
|
x: number
|
||||||
y: number;
|
y: number
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
this.x = x;
|
this.x = x
|
||||||
this.y = y;
|
this.y = y
|
||||||
}
|
}
|
||||||
|
|
||||||
to(_buf_: Bright.Serialization.ByteBuf) {
|
to(_buf_: Bright.Serialization.ByteBuf) {
|
||||||
|
|
@ -192,21 +192,21 @@ export class Vector2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
static from(_buf_: Bright.Serialization.ByteBuf): Vector2 {
|
static from(_buf_: Bright.Serialization.ByteBuf): Vector2 {
|
||||||
let x = _buf_.ReadFloat();
|
let x = _buf_.ReadFloat()
|
||||||
let y = _buf_.ReadFloat();
|
let y = _buf_.ReadFloat()
|
||||||
return new Vector2(x, y);
|
return new Vector2(x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class Vector3 {
|
export class Vector3 {
|
||||||
x: number;
|
x: number
|
||||||
y: number;
|
y: number
|
||||||
z: number;
|
z: number
|
||||||
constructor(x: number, y: number, z: number) {
|
constructor(x: number, y: number, z: number) {
|
||||||
this.x = x;
|
this.x = x
|
||||||
this.y = y;
|
this.y = y
|
||||||
this.z = z;
|
this.z = z
|
||||||
}
|
}
|
||||||
|
|
||||||
to(_buf_: Bright.Serialization.ByteBuf) {
|
to(_buf_: Bright.Serialization.ByteBuf) {
|
||||||
|
|
@ -216,23 +216,23 @@ export class Vector2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
static from(_buf_: Bright.Serialization.ByteBuf): Vector3 {
|
static from(_buf_: Bright.Serialization.ByteBuf): Vector3 {
|
||||||
let x = _buf_.ReadFloat();
|
let x = _buf_.ReadFloat()
|
||||||
let y = _buf_.ReadFloat();
|
let y = _buf_.ReadFloat()
|
||||||
let z = _buf_.ReadFloat();
|
let z = _buf_.ReadFloat()
|
||||||
return new Vector3(x, y, z);
|
return new Vector3(x, y, z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Vector4 {
|
export class Vector4 {
|
||||||
x: number;
|
x: number
|
||||||
y: number;
|
y: number
|
||||||
z: number;
|
z: number
|
||||||
w: number;
|
w: number
|
||||||
constructor(x: number, y: number, z: number, w: number) {
|
constructor(x: number, y: number, z: number, w: number) {
|
||||||
this.x = x;
|
this.x = x
|
||||||
this.y = y;
|
this.y = y
|
||||||
this.z = z;
|
this.z = z
|
||||||
this.w = w;
|
this.w = w
|
||||||
}
|
}
|
||||||
|
|
||||||
to(_buf_: Bright.Serialization.ByteBuf) {
|
to(_buf_: Bright.Serialization.ByteBuf) {
|
||||||
|
|
@ -243,11 +243,11 @@ export class Vector2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
static from(_buf_: Bright.Serialization.ByteBuf): Vector4 {
|
static from(_buf_: Bright.Serialization.ByteBuf): Vector4 {
|
||||||
let x = _buf_.ReadFloat();
|
let x = _buf_.ReadFloat()
|
||||||
let y = _buf_.ReadFloat();
|
let y = _buf_.ReadFloat()
|
||||||
let z = _buf_.ReadFloat();
|
let z = _buf_.ReadFloat()
|
||||||
let w = _buf_.ReadFloat();
|
let w = _buf_.ReadFloat()
|
||||||
return new Vector4(x, y, z, w);
|
return new Vector4(x, y, z, w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue