();
- boolean isNumeric = StringUtils.isNumeric(codeLanguage);
+ var isNumeric = NumberUtils.isNumeric(codeLanguage);
for (var language : CodeLanguage.values()) {
if (isNumeric) {
var code = Integer.valueOf(codeLanguage);
diff --git a/orm/pom.xml b/orm/pom.xml
index c030c29c..1d48b39e 100644
--- a/orm/pom.xml
+++ b/orm/pom.xml
@@ -35,7 +35,6 @@
4.1.84.Final
2.4.17
- 5.3.0
5.3.0
@@ -51,12 +50,6 @@
5.2.3
1.9.0
-
- 4.0.1
-
-
- 8.4.3
-
11
UTF-8
diff --git a/pom.xml b/pom.xml
index 12d39955..2834efd1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@
4.1.84.Final
2.4.17
- 5.3.0
+
5.3.0
@@ -75,12 +75,6 @@
5.2.3
1.9.0
-
- 4.0.1
-
-
- 8.4.3
-
11
UTF-8
diff --git a/protocol/README.md b/protocol/README.md
index f98182c4..ec337288 100644
--- a/protocol/README.md
+++ b/protocol/README.md
@@ -5,7 +5,7 @@ English | [简体中文](./README_CN.md)
- [zfoo protocol](https://github.com/zfoo-project/zfoo/blob/main/protocol/README.md)
It is currently the fastest framework for binary serialization and deserialization in Java, and has the fewest
serialization bytes
-- The protocol is currently natively supported **C++ Java Javascript C# Go Lua GDScript**,It's easy to do cross-platform
+- The protocol is currently natively supported **C++ Java Javascript C# Go Lua GDScript Pythont**,It's easy to do cross-platform
- The protocol can customize the private protocol format to make your protocol more secure, and supports adding fields
and being compatible with previous and subsequent protocols
- Compatible with Protobuf, it supports the generation of Protobuf protocol files, and provides a generation method from
diff --git a/protocol/README_CN.md b/protocol/README_CN.md
index 8942ee17..8c05666d 100644
--- a/protocol/README_CN.md
+++ b/protocol/README_CN.md
@@ -4,7 +4,7 @@
- [zfoo protocol](https://github.com/zfoo-project/zfoo/blob/main/protocol/README.md)
是目前的Java二进制序列化和反序列化速度最快的框架,并且为序列化字节最少的框架
-- 协议目前原生支持 **C++ Java Javascript C# Go Lua GDScript**,可以轻易实现跨平台
+- 协议目前原生支持 **C++ Java Javascript C# Go Lua GDScript Python**,可以轻易实现跨平台
- 协议可以自定义私有协议格式,让你的协议更加安全,支持增加字段和兼容前后版本协议
- 兼容protobuf,支持生成protobuf协议文件,提供从pojo到proto的生成方式
- proto文件到生成pojo的方式已经有不少jetbrains插件可以做到,可以在idea的plugin中搜索proto
diff --git a/protocol/pom.xml b/protocol/pom.xml
index 36816536..39c36b24 100644
--- a/protocol/pom.xml
+++ b/protocol/pom.xml
@@ -35,7 +35,6 @@
4.1.84.Final
2.4.17
- 5.3.0
5.3.0
@@ -51,12 +50,6 @@
5.2.3
1.9.0
-
- 4.0.1
-
-
- 8.4.3
-
11
UTF-8
@@ -132,7 +125,7 @@
com.esotericsoftware
kryo
- ${kryo.version}
+ 5.3.0
test
diff --git a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolFile.java b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolFile.java
index 5e8937fa..7d8a83ba 100644
--- a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolFile.java
+++ b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolFile.java
@@ -25,6 +25,7 @@ import com.zfoo.protocol.serializer.go.GenerateGoUtils;
import com.zfoo.protocol.serializer.javascript.GenerateJsUtils;
import com.zfoo.protocol.serializer.lua.GenerateLuaUtils;
import com.zfoo.protocol.serializer.protobuf.GenerateProtobufUtils;
+import com.zfoo.protocol.serializer.python.GeneratePyUtils;
import com.zfoo.protocol.serializer.typescript.GenerateTsUtils;
import java.io.IOException;
@@ -62,11 +63,8 @@ public abstract class GenerateProtocolFile {
}
/**
- * 生成各种语言的协议文件
- *
- * @param generateOperation
- * @throws IOException
- * @throws ClassNotFoundException
+ * EN: Generate protocol files to various languages
+ * CN: 生成各种语言的协议文件
*/
public static void generate(GenerateOperation generateOperation) throws IOException, ClassNotFoundException {
var protocols = ProtocolManager.protocols;
@@ -172,6 +170,15 @@ public abstract class GenerateProtocolFile {
}
}
+ // 生成Python协议
+ if (generateLanguages.contains(CodeLanguage.Python)) {
+ GeneratePyUtils.init(generateOperation);
+ GeneratePyUtils.createProtocolManager(allSortedGenerateProtocols);
+ for (var protocolRegistration : allSortedGenerateProtocols) {
+ GeneratePyUtils.createPyProtocolFile((ProtocolRegistration) protocolRegistration);
+ }
+ }
+
// 生成Protobuf协议
if (generateLanguages.contains(CodeLanguage.Protobuf)) {
GenerateProtobufUtils.init(generateOperation);
diff --git a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolNote.java b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolNote.java
index eca46d74..1aef10dc 100644
--- a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolNote.java
+++ b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolNote.java
@@ -28,7 +28,8 @@ import java.util.List;
import java.util.Map;
/**
- * 生成协议的时候,协议的文档注释和字段注释会使用这个类
+ * EN: When generating the protocol, the document comments and field comments of the protocol will use this class
+ * CN: 生成协议的时候,协议的文档注释和字段注释会使用这个类
*
* @author godotg
* @version 3.0
@@ -38,14 +39,14 @@ public abstract class GenerateProtocolNote {
// 临时变量,启动完成就会销毁,协议的文档,外层map的key为协议类;pair的key为总的注释,value为属性字段的注释,value表示的map的key为属性名称
// 比如在Test中的ComplexObject生成的pari是如下格式
/**
- * key docTitle:
+ * key is docTitle note:
* // 复杂的对象
* // 包括了各种复杂的结构,数组,List,Set,Map
* //
* // @author godotg
* // @version 1.0
*
- * value aa:
+ * value is field note:
* // byte的包装类型
* // 优先使用基础类型,包装类型会有装箱拆箱
*/
@@ -92,18 +93,19 @@ public abstract class GenerateProtocolNote {
case Lua:
fieldNote = StringUtils.format("-- {}", fieldNote).replace("\n", "\n-- ");
break;
+ case Python:
case GdScript:
fieldNote = StringUtils.format("# {}", fieldNote).replace("\n", "\n# ");
break;
case Enhance:
default:
- throw new RunException("无法识别的枚举类型[{}]", language);
+ throw new RunException("unrecognized enum type [{}]", language);
}
return fieldNote;
}
public static void initProtocolNote(List protocolRegistrations) {
- AssertionUtils.notNull(protocolNoteMap, "[{}]已经初始完成,初始化完成过后不能调用initProtocolDocument", GenerateProtocolNote.class.getSimpleName());
+ AssertionUtils.notNull(protocolNoteMap, "[{}] duplicate initialization", GenerateProtocolNote.class.getSimpleName());
for (var protocolRegistration : protocolRegistrations) {
var protocolClazz = protocolRegistration.protocolConstructor().getDeclaringClass();
diff --git a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java
index 476aad78..b9d83a12 100644
--- a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java
+++ b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java
@@ -53,13 +53,29 @@ public abstract class GenerateProtocolPath {
switch (language) {
case Cpp:
+ break;
case Go:
+ break;
case JavaScript:
+ break;
case TypeScript:
+ break;
case CSharp:
+ break;
case Protobuf:
+ break;
case Lua:
+ break;
case GdScript:
+ break;
+ case Python:
+ if (StringUtils.isBlank(getProtocolPath(protocolId))) {
+ path = StringUtils.PERIOD;
+ } else {
+ path = StringUtils.substringBeforeLast(path, StringUtils.SLASH);
+ path = path.replaceAll(StringUtils.SLASH , StringUtils.PERIOD);
+ }
+ break;
case Enhance:
break;
default:
diff --git a/protocol/src/main/java/com/zfoo/protocol/registration/ProtocolAnalysis.java b/protocol/src/main/java/com/zfoo/protocol/registration/ProtocolAnalysis.java
index 3397f1e2..497b813f 100644
--- a/protocol/src/main/java/com/zfoo/protocol/registration/ProtocolAnalysis.java
+++ b/protocol/src/main/java/com/zfoo/protocol/registration/ProtocolAnalysis.java
@@ -33,6 +33,7 @@ import com.zfoo.protocol.serializer.go.GenerateGoUtils;
import com.zfoo.protocol.serializer.javascript.GenerateJsUtils;
import com.zfoo.protocol.serializer.lua.GenerateLuaUtils;
import com.zfoo.protocol.serializer.protobuf.GenerateProtobufUtils;
+import com.zfoo.protocol.serializer.python.GeneratePyUtils;
import com.zfoo.protocol.serializer.reflect.*;
import com.zfoo.protocol.serializer.typescript.GenerateTsUtils;
import com.zfoo.protocol.util.AssertionUtils;
@@ -347,6 +348,7 @@ public class ProtocolAnalysis {
GenerateTsUtils.clear();
GenerateLuaUtils.clear();
GenerateGdUtils.clear();
+ GeneratePyUtils.clear();
GenerateProtobufUtils.clear();
}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/CodeLanguage.java b/protocol/src/main/java/com/zfoo/protocol/serializer/CodeLanguage.java
index cf426c1b..4d32c3c0 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/CodeLanguage.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/CodeLanguage.java
@@ -23,22 +23,23 @@ public enum CodeLanguage {
*/
Enhance(1),
- Cpp(2),
+ Cpp(1 << 1),
- Go(4),
+ Go(1 << 2),
- JavaScript(8),
+ JavaScript(1 << 3),
- TypeScript(16),
+ TypeScript(1 << 4),
- Lua(32),
+ Lua(1 << 5),
- CSharp(64),
+ CSharp(1 << 6),
- GdScript(128),
+ GdScript(1 << 7),
- Protobuf(256)
- ;
+ Python(1 << 8),
+
+ Protobuf(1 << 12);
public final int id;
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownArraySerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownArraySerializer.java
index 2d041d78..0dd5d9f9 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownArraySerializer.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownArraySerializer.java
@@ -52,6 +52,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeBooleanArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeBooleanArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -78,6 +79,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeBooleanBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeBooleanArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -104,6 +106,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeByteArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeByteArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -130,6 +133,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeByteBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeByteArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -156,6 +160,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeShortArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeShortArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -182,6 +187,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeShortBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeShortArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -208,6 +214,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -234,6 +241,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -260,6 +268,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -286,6 +295,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -312,6 +322,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeFloatArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeFloatArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -338,6 +349,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeFloatBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeFloatArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -364,6 +376,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeDoubleArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeDoubleArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -390,6 +403,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeDoubleBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeDoubleArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -416,6 +430,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeStringArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeStringArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -442,6 +457,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeCharArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeCharArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -468,6 +484,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeCharBoxArray($1, {});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeCharArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -496,6 +513,7 @@ public class CutDownArraySerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writePacketArray($1, {}, {});", EnhanceUtils.byteBufUtils, objectStr, EnhanceUtils.getProtocolRegistrationFieldNameByProtocolId(protocolId)));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, protocolId)).append(LS);
break;
case Lua:
@@ -541,6 +559,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readBooleanArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readBooleanArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readBooleanArray()", array)).append(LS);
break;
@@ -569,6 +590,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readBooleanArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readBooleanArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readBooleanArray()", array)).append(LS);
break;
@@ -597,6 +621,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readByteArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readByteArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readByteArray()", array)).append(LS);
break;
@@ -625,6 +652,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readByteArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readByteArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readByteArray()", array)).append(LS);
break;
@@ -653,6 +683,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readShortArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readShortArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readShortArray()", array)).append(LS);
break;
@@ -681,6 +714,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readShortArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readShortArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readShortArray()", array)).append(LS);
break;
@@ -709,6 +745,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntArray()", array)).append(LS);
break;
@@ -737,6 +776,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntArray()", array)).append(LS);
break;
@@ -765,6 +807,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongArray()", array)).append(LS);
break;
@@ -793,6 +838,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongArray()", array)).append(LS);
break;
@@ -821,6 +869,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readFloatArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readFloatArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readFloatArray()", array)).append(LS);
break;
@@ -849,6 +900,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readFloatArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readFloatArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readFloatArray()", array)).append(LS);
break;
@@ -877,6 +931,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readDoubleArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readDoubleArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readDoubleArray()", array)).append(LS);
break;
@@ -905,6 +962,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readDoubleArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readDoubleArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readDoubleArray()", array)).append(LS);
break;
@@ -933,6 +993,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringArray()", array)).append(LS);
break;
@@ -961,6 +1024,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readCharArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readCharArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readCharArray()", array)).append(LS);
break;
@@ -989,6 +1055,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readCharArray()", array)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readCharArray()", array)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readCharArray()", array)).append(LS);
break;
@@ -1017,6 +1086,9 @@ public class CutDownArraySerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readPacketArray({})", array, protocolId)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readPacketArray({})", array, protocolId)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readPacketArray({})", array, protocolId)).append(LS);
break;
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownListSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownListSerializer.java
index 19bdfed9..df29046b 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownListSerializer.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownListSerializer.java
@@ -51,6 +51,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeBooleanList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeBooleanArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -77,6 +78,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeByteList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeByteArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -103,6 +105,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeShortList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeShortArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -129,6 +132,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -155,6 +159,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -182,6 +187,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeFloatList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeFloatArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -209,6 +215,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeDoubleList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeDoubleArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -236,6 +243,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeStringList($1, (List){});", EnhanceUtils.byteBufUtils, objectStr));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeStringArray({})", objectStr)).append(LS);
break;
case Lua:
@@ -265,6 +273,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writePacketList($1, (List){}, {});", EnhanceUtils.byteBufUtils, objectStr, EnhanceUtils.getProtocolRegistrationFieldNameByProtocolId(protocolId)));
break;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, protocolId)).append(LS);
break;
case Lua:
@@ -307,6 +316,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readBooleanArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readBooleanArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readBooleanArray()", list)).append(LS);
break;
@@ -335,6 +347,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readByteArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readByteArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readByteArray()", list)).append(LS);
break;
@@ -363,6 +378,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readShortArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readShortArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readShortArray()", list)).append(LS);
break;
@@ -391,6 +409,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntArray()", list)).append(LS);
break;
@@ -419,6 +440,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongArray()", list)).append(LS);
break;
@@ -447,6 +471,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readFloatArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readFloatArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readFloatArray()", list)).append(LS);
break;
@@ -475,6 +502,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readDoubleArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readDoubleArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readDoubleArray()", list)).append(LS);
break;
@@ -503,6 +533,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringArray()", list)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringArray()", list)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringArray()", list)).append(LS);
break;
@@ -533,6 +566,9 @@ public class CutDownListSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readPacketArray({})", list, protocolId)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readPacketArray({})", list, protocolId)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readPacketArray({})", list, protocolId)).append(LS);
break;
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownMapSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownMapSerializer.java
index 1507a033..fe40250a 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownMapSerializer.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownMapSerializer.java
@@ -58,6 +58,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntIntMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntIntMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -81,6 +82,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntLongMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntLongMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -104,6 +106,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntStringMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntStringMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -127,6 +130,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeIntPacketMap($1, (Map){}, {});", EnhanceUtils.byteBufUtils, objectStr, EnhanceUtils.getProtocolRegistrationFieldNameByProtocolId(((ObjectProtocolField) valueRegistration).getProtocolId())));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeIntPacketMap({}, {})", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
return true;
case Lua:
@@ -152,6 +156,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongIntMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongIntMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -175,6 +180,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongLongMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongLongMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -198,6 +204,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongStringMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongStringMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -221,6 +228,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeLongPacketMap($1, (Map){}, {});", EnhanceUtils.byteBufUtils, objectStr, EnhanceUtils.getProtocolRegistrationFieldNameByProtocolId(((ObjectProtocolField) valueRegistration).getProtocolId())));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeLongPacketMap({}, {})", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
return true;
case Lua:
@@ -246,6 +254,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeStringIntMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeStringIntMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -269,6 +278,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeStringLongMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeStringLongMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -292,6 +302,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeStringStringMap($1, (Map){});", EnhanceUtils.byteBufUtils, objectStr));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeStringStringMap({})", objectStr)).append(LS);
return true;
case Lua:
@@ -315,6 +326,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
builder.append(StringUtils.format("{}.writeStringPacketMap($1, (Map){}, {});", EnhanceUtils.byteBufUtils, objectStr, EnhanceUtils.getProtocolRegistrationFieldNameByProtocolId(((ObjectProtocolField) valueRegistration).getProtocolId())));
return true;
case GdScript:
+ case Python:
builder.append(StringUtils.format("buffer.writeStringPacketMap({}, {})", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
return true;
case Lua:
@@ -358,6 +370,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntIntMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntIntMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntIntMap()", map)).append(LS);
return map;
@@ -383,6 +398,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntLongMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntLongMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntLongMap()", map)).append(LS);
return map;
@@ -408,6 +426,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntStringMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntStringMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntStringMap()", map)).append(LS);
return map;
@@ -434,6 +455,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntPacketMap({})", map, protocolId)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntPacketMap({})", map, protocolId)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntPacketMap({})", map, protocolId)).append(LS);
return map;
@@ -460,6 +484,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongIntMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongIntMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongIntMap()", map)).append(LS);
return map;
@@ -485,6 +512,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongLongMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongLongMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongLongMap()", map)).append(LS);
return map;
@@ -510,6 +540,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongStringMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongStringMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongStringMap()", map)).append(LS);
return map;
@@ -536,6 +569,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongPacketMap({})", map, protocolId)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongPacketMap({})", map, protocolId)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongPacketMap({})", map, protocolId)).append(LS);
return map;
@@ -563,6 +599,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringIntMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringIntMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringIntMap()", map)).append(LS);
return map;
@@ -588,6 +627,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringLongMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringLongMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringLongMap()", map)).append(LS);
return map;
@@ -613,6 +655,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringStringMap()", map)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringStringMap()", map)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringStringMap()", map)).append(LS);
return map;
@@ -639,6 +684,9 @@ public class CutDownMapSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringPacketMap({})", map, protocolId)).append(LS);
return map;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringPacketMap({})", map, protocolId)).append(LS);
+ return map;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringPacketMap({})", map, protocolId)).append(LS);
return map;
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownSetSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownSetSerializer.java
index c0b7fb87..6fa73301 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownSetSerializer.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/CutDownSetSerializer.java
@@ -54,6 +54,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeBooleanArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeBooleanSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeBooleanArray({})", objectStr)).append(LS);
break;
@@ -80,6 +83,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeByteArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeByteSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeByteArray({})", objectStr)).append(LS);
break;
@@ -106,6 +112,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeShortArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeShortSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeShortArray({})", objectStr)).append(LS);
break;
@@ -132,6 +141,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeIntArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeIntSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeIntArray({})", objectStr)).append(LS);
break;
@@ -158,6 +170,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeLongArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeLongSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeLongArray({})", objectStr)).append(LS);
break;
@@ -184,6 +199,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeFloatArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeFloatSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeFloatArray({})", objectStr)).append(LS);
break;
@@ -210,6 +228,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeDoubleArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeDoubleSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeDoubleArray({})", objectStr)).append(LS);
break;
@@ -236,6 +257,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writeStringArray({})", objectStr)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writeStringSet({})", objectStr)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writeStringArray({})", objectStr)).append(LS);
break;
@@ -265,6 +289,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, protocolId)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("buffer.writePacketSet({}, {})", objectStr, protocolId)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("buffer:writePacketArray({}, {})", objectStr, protocolId)).append(LS);
break;
@@ -305,6 +332,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readBooleanArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readBooleanSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readBooleanArray()", set)).append(LS);
break;
@@ -333,6 +363,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readByteArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readByteSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readByteArray()", set)).append(LS);
break;
@@ -361,6 +394,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readShortArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readShortSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readShortArray()", set)).append(LS);
break;
@@ -389,6 +425,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readIntArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readIntSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readIntArray()", set)).append(LS);
break;
@@ -417,6 +456,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readLongArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readLongSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readLongArray()", set)).append(LS);
break;
@@ -445,6 +487,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readFloatArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readFloatSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readFloatArray()", set)).append(LS);
break;
@@ -473,6 +518,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readDoubleArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readDoubleSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readDoubleArray()", set)).append(LS);
break;
@@ -501,6 +549,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readStringArray()", set)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readStringSet()", set)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readStringArray()", set)).append(LS);
break;
@@ -531,6 +582,9 @@ public class CutDownSetSerializer implements ICutDownSerializer {
case GdScript:
builder.append(StringUtils.format("var {} = buffer.readPacketArray({})", set, protocolId)).append(LS);
break;
+ case Python:
+ builder.append(StringUtils.format("{} = buffer.readPacketSet({})", set, protocolId)).append(LS);
+ break;
case Lua:
builder.append(StringUtils.format("local {} = buffer:readPacketArray({})", set, protocolId)).append(LS);
break;
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java
index 242ed2a6..a1349546 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java
@@ -97,7 +97,7 @@ public abstract class GenerateCppUtils {
FileUtils.writeInputStreamToFile(createFile, fileInputStream);
}
- var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("cpp/ProtocolManagerTemplate.h")));
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("cpp/ProtocolManagerTemplate.h");
var headerBuilder = new StringBuilder();
var initProtocolBuilder = new StringBuilder();
@@ -120,7 +120,7 @@ public abstract class GenerateCppUtils {
var registrationConstructor = registration.getConstructor();
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
- var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("cpp/ProtocolTemplate.h")));
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("cpp/ProtocolTemplate.h");
// protocol object
var defineProtocolName = protocolClazzName.toUpperCase();
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/csharp/GenerateCsUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/csharp/GenerateCsUtils.java
index 4bb3f062..cf142da6 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/csharp/GenerateCsUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/csharp/GenerateCsUtils.java
@@ -106,7 +106,7 @@ public abstract class GenerateCsUtils {
var registrationConstructor = registration.getConstructor();
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
- var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("csharp/ProtocolTemplate.cs")));
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("csharp/ProtocolTemplate.cs");
var classNote = GenerateProtocolNote.classNote(protocolId, CodeLanguage.CSharp);
var fieldDefinition = fieldDefinition(registration);
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/gdscript/GenerateGdUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/gdscript/GenerateGdUtils.java
index 89a3ff1c..678c0d90 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/gdscript/GenerateGdUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/gdscript/GenerateGdUtils.java
@@ -91,10 +91,10 @@ public abstract class GenerateGdUtils {
public static void createProtocolManager(List protocolList) throws IOException {
var byteBufferFile = new File(StringUtils.format("{}/{}", protocolOutputPath, "ByteBuffer.gd"));
- var byteBufferTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("gdscript/buffer/ByteBuffer.gd")));
+ var byteBufferTemplate = ClassUtils.getFileFromClassPathToString("gdscript/buffer/ByteBuffer.gd");
FileUtils.writeStringToFile(byteBufferFile, StringUtils.format(byteBufferTemplate, protocolOutputRootPath), false);
- var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("gdscript/ProtocolManagerTemplate.gd")));
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("gdscript/ProtocolManagerTemplate.gd");
// 生成ProtocolManager.gd文件
var importBuilder = new StringBuilder();
var initList = new ArrayList();
@@ -125,7 +125,7 @@ public abstract class GenerateGdUtils {
var writeObject = writeObject(registration);
var readObject = readObject(registration);
- var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("gdscript/ProtocolTemplate.gd")));
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("gdscript/ProtocolTemplate.gd");
protocolTemplate = StringUtils.format(protocolTemplate, protocolId, protocolClazzName, includeSubProtocol, classNote, fieldDefinition.trim(),
StringUtils.EMPTY_JSON, toStringMethod, writeObject.trim(), readObject.trim());
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java
index 5825d482..89a4ab2a 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java
@@ -96,7 +96,7 @@ public abstract class GenerateGoUtils {
.filter(it -> Objects.nonNull(it))
.forEach(it -> initProtocolBuilder.append(TAB).append(StringUtils.format("Protocols[{}] = new({})", it.protocolId(), it.protocolConstructor().getDeclaringClass().getSimpleName())).append(LS));
- var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("go/ProtocolManagerTemplate.go")));
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("go/ProtocolManagerTemplate.go");
protocolManagerTemplate = StringUtils.format(protocolManagerTemplate, initProtocolBuilder.toString().trim());
FileUtils.writeStringToFile(new File(StringUtils.format("{}/{}", protocolOutputRootPath, "ProtocolManager.go")), protocolManagerTemplate, true);
}
@@ -109,8 +109,8 @@ public abstract class GenerateGoUtils {
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
var protocolTemplate = ArrayUtils.isEmpty(registration.getFields())
- ? StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("go/ProtocolTemplateEmpty.go")))
- : StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("go/ProtocolTemplate.go")));
+ ? ClassUtils.getFileFromClassPathToString("go/ProtocolTemplateEmpty.go")
+ : ClassUtils.getFileFromClassPathToString("go/ProtocolTemplate.go");
var classNote = GenerateProtocolNote.classNote(protocolId, CodeLanguage.Go);
var fieldDefinition = fieldDefinition(registration);
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/javascript/GenerateJsUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/javascript/GenerateJsUtils.java
index 13f43100..689c4a83 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/javascript/GenerateJsUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/javascript/GenerateJsUtils.java
@@ -91,7 +91,7 @@ public abstract class GenerateJsUtils {
}
// 生成ProtocolManager.js文件
- var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("javascript/ProtocolManagerTemplate.js")));
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("javascript/ProtocolManagerTemplate.js");
var importBuilder = new StringBuilder();
var initProtocolBuilder = new StringBuilder();
@@ -115,7 +115,7 @@ public abstract class GenerateJsUtils {
var registrationConstructor = registration.getConstructor();
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
- var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("javascript/ProtocolTemplate.js")));
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("javascript/ProtocolTemplate.js");
var classNote = GenerateProtocolNote.classNote(protocolId, CodeLanguage.JavaScript);
var valueOfMethod = valueOfMethod(registration);
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/lua/GenerateLuaUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/lua/GenerateLuaUtils.java
index 3b4b96e1..1b2262e3 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/lua/GenerateLuaUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/lua/GenerateLuaUtils.java
@@ -90,7 +90,7 @@ public abstract class GenerateLuaUtils {
}
// 生成Protocol.lua文件
- var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("lua/ProtocolManagerTemplate.lua")));
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("lua/ProtocolManagerTemplate.lua");
var fieldBuilder = new StringBuilder();
var protocolBuilder = new StringBuilder();
for (var protocol : protocolList) {
@@ -117,7 +117,7 @@ public abstract class GenerateLuaUtils {
var protocolId = registration.protocolId();
var registrationConstructor = registration.getConstructor();
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
- var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("lua/ProtocolTemplate.lua")));
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("lua/ProtocolTemplate.lua");
var classNote = GenerateProtocolNote.classNote(protocolId, CodeLanguage.Lua);
var valueOfMethod = valueOfMethod(registration);
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/GeneratePyUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/GeneratePyUtils.java
new file mode 100644
index 00000000..96fc5316
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/GeneratePyUtils.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateOperation;
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.generate.GenerateProtocolNote;
+import com.zfoo.protocol.generate.GenerateProtocolPath;
+import com.zfoo.protocol.registration.IProtocolRegistration;
+import com.zfoo.protocol.registration.ProtocolRegistration;
+import com.zfoo.protocol.registration.anno.Compatible;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+import com.zfoo.protocol.serializer.CodeLanguage;
+import com.zfoo.protocol.serializer.csharp.GenerateCsUtils;
+import com.zfoo.protocol.serializer.reflect.*;
+import com.zfoo.protocol.util.ClassUtils;
+import com.zfoo.protocol.util.FileUtils;
+import com.zfoo.protocol.util.ReflectionUtils;
+import com.zfoo.protocol.util.StringUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+import static com.zfoo.protocol.util.StringUtils.TAB;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public abstract class GeneratePyUtils {
+
+ private static String protocolOutputRootPath = "pyProtocol/";
+
+ private static Map pySerializerMap;
+
+
+ public static IPySerializer pySerializer(ISerializer serializer) {
+ return pySerializerMap.get(serializer);
+ }
+
+ public static void init(GenerateOperation generateOperation) {
+ protocolOutputRootPath = FileUtils.joinPath(generateOperation.getProtocolPath(), protocolOutputRootPath);
+
+ FileUtils.deleteFile(new File(protocolOutputRootPath));
+ FileUtils.createDirectory(protocolOutputRootPath);
+
+ pySerializerMap = new HashMap<>();
+ pySerializerMap.put(BooleanSerializer.INSTANCE, new PyBooleanSerializer());
+ pySerializerMap.put(ByteSerializer.INSTANCE, new PyByteSerializer());
+ pySerializerMap.put(ShortSerializer.INSTANCE, new PyShortSerializer());
+ pySerializerMap.put(IntSerializer.INSTANCE, new PyIntSerializer());
+ pySerializerMap.put(LongSerializer.INSTANCE, new PyLongSerializer());
+ pySerializerMap.put(FloatSerializer.INSTANCE, new PyFloatSerializer());
+ pySerializerMap.put(DoubleSerializer.INSTANCE, new PyDoubleSerializer());
+ pySerializerMap.put(CharSerializer.INSTANCE, new PyCharSerializer());
+ pySerializerMap.put(StringSerializer.INSTANCE, new PyStringSerializer());
+ pySerializerMap.put(ArraySerializer.INSTANCE, new PyArraySerializer());
+ pySerializerMap.put(ListSerializer.INSTANCE, new PyListSerializer());
+ pySerializerMap.put(SetSerializer.INSTANCE, new PySetSerializer());
+ pySerializerMap.put(MapSerializer.INSTANCE, new PyMapSerializer());
+ pySerializerMap.put(ObjectProtocolSerializer.INSTANCE, new PyObjectProtocolSerializer());
+ }
+
+ public static void clear() {
+ pySerializerMap = null;
+ protocolOutputRootPath = null;
+ }
+
+ public static void createProtocolManager(List protocolList) throws IOException {
+ var list = List.of("python/ByteBuffer.py");
+ for (var fileName : list) {
+ var fileInputStream = ClassUtils.getFileFromClassPath(fileName);
+ var createFile = new File(StringUtils.format("{}/{}", protocolOutputRootPath, StringUtils.substringAfterFirst(fileName, "python/")));
+ FileUtils.writeInputStreamToFile(createFile, fileInputStream);
+ }
+
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("python/ProtocolManagerTemplate.py");
+
+ var importBuilder = new StringBuilder();
+ var initProtocolBuilder = new StringBuilder();
+ for (var protocol : protocolList) {
+ var protocolId = protocol.protocolId();
+ var protocolName = protocol.protocolConstructor().getDeclaringClass().getSimpleName();
+ var path = GenerateProtocolPath.protocolAbsolutePath(protocolId, CodeLanguage.Python);
+ importBuilder.append(StringUtils.format("from {} import {}", path, protocolName)).append(LS);
+ initProtocolBuilder.append(StringUtils.format("protocols[{}] = {}.{}", protocolId, protocolName, protocolName)).append(LS);
+ }
+
+ protocolManagerTemplate = StringUtils.format(protocolManagerTemplate, importBuilder.toString().trim(), StringUtils.EMPTY_JSON, initProtocolBuilder.toString().trim());
+ FileUtils.writeStringToFile(new File(StringUtils.format("{}/{}", protocolOutputRootPath, "ProtocolManager.py")), protocolManagerTemplate, true);
+ }
+
+ public static void createPyProtocolFile(ProtocolRegistration registration) {
+ GenerateProtocolFile.index.set(0);
+
+ var protocolId = registration.protocolId();
+ var registrationConstructor = registration.getConstructor();
+ var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
+
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("python/ProtocolTemplate.py");
+
+ var classNote = GenerateProtocolNote.classNote(protocolId, CodeLanguage.Python);
+ var fieldDefinition = fieldDefinition(registration);
+ var writeObject = writeObject(registration);
+ var readObject = readObject(registration);
+
+ protocolTemplate = StringUtils.format(protocolTemplate, classNote, protocolClazzName
+ , fieldDefinition.trim(), protocolId, writeObject.trim(), protocolClazzName, readObject.trim());
+ var protocolOutputPath = StringUtils.format("{}/{}/{}.py", protocolOutputRootPath
+ , GenerateProtocolPath.getProtocolPath(protocolId), protocolClazzName);
+ FileUtils.writeStringToFile(new File(protocolOutputPath), protocolTemplate, true);
+ }
+
+ private static String fieldDefinition(ProtocolRegistration registration) {
+ var protocolId = registration.getId();
+ var fields = registration.getFields();
+ var fieldRegistrations = registration.getFieldRegistrations();
+ var pyBuilder = new StringBuilder();
+ // 生成源代码字段的时候,按照原始定义的方式生成
+ var sequencedFields = ReflectionUtils.notStaticAndTransientFields(registration.getConstructor().getDeclaringClass());
+ for (int i = 0; i < sequencedFields.size(); i++) {
+ var field = sequencedFields.get(i);
+ IFieldRegistration fieldRegistration = fieldRegistrations[GenerateProtocolFile.indexOf(fields, field)];
+ var fieldName = field.getName();
+ // 生成注释
+ var fieldNote = GenerateProtocolNote.fieldNote(protocolId, fieldName, CodeLanguage.Python);
+ if (StringUtils.isNotBlank(fieldNote)) {
+ pyBuilder.append(TAB).append(fieldNote).append(LS);
+ }
+ var fieldDefaultValue = pySerializer(fieldRegistration.serializer()).fieldDefaultValue(field, fieldRegistration);
+ // 生成类型的注释
+ pyBuilder.append(StringUtils.format("{}{} = {}", TAB, fieldName, fieldDefaultValue));
+ pyBuilder.append(StringUtils.format(" # {}", GenerateCsUtils.toCsClassName(field.getGenericType().getTypeName())));
+ pyBuilder.append(LS);
+ }
+ return pyBuilder.toString();
+ }
+
+ private static String writeObject(ProtocolRegistration registration) {
+ var fields = registration.getFields();
+ var fieldRegistrations = registration.getFieldRegistrations();
+ var pyBuilder = new StringBuilder();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ var fieldRegistration = fieldRegistrations[i];
+ pySerializer(fieldRegistration.serializer()).writeObject(pyBuilder, "packet." + field.getName(), 2, field, fieldRegistration);
+ }
+ return pyBuilder.toString();
+ }
+
+ private static String readObject(ProtocolRegistration registration) {
+ var fields = registration.getFields();
+ var fieldRegistrations = registration.getFieldRegistrations();
+ var pyBuilder = new StringBuilder();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ var fieldRegistration = fieldRegistrations[i];
+ if (field.isAnnotationPresent(Compatible.class)) {
+ pyBuilder.append(TAB + TAB).append("if not buffer.isReadable():").append(LS);
+ pyBuilder.append(TAB + TAB + TAB).append("return packet").append(LS);
+ pyBuilder.append(TAB + TAB).append("pass").append(LS);
+ }
+ var readObject = pySerializer(fieldRegistration.serializer()).readObject(pyBuilder, 2, field, fieldRegistration);
+ pyBuilder.append(TAB + TAB).append(StringUtils.format("packet.{} = {}", field.getName(), readObject)).append(LS);
+ }
+ return pyBuilder.toString();
+ }
+
+ public static StringBuilder addTab(StringBuilder builder, int deep) {
+ builder.append(TAB.repeat(Math.max(0, deep)));
+ return builder;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/IPySerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/IPySerializer.java
new file mode 100644
index 00000000..8db2caf1
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/IPySerializer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import java.lang.reflect.Field;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public interface IPySerializer {
+
+ String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration);
+
+ void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration);
+
+ String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration);
+
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyArraySerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyArraySerializer.java
new file mode 100644
index 00000000..8f46ddb5
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyArraySerializer.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.ArrayField;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+import com.zfoo.protocol.serializer.CodeLanguage;
+import com.zfoo.protocol.serializer.CutDownArraySerializer;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyArraySerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "[]";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ if (CutDownArraySerializer.getInstance().writeObject(builder, objectStr, field, fieldRegistration, CodeLanguage.Python)) {
+ return;
+ }
+
+ ArrayField arrayField = (ArrayField) fieldRegistration;
+
+ builder.append(StringUtils.format("if {} is None:", objectStr)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append("buffer.writeInt(0)").append(LS);
+ GeneratePyUtils.addTab(builder, deep);
+
+ builder.append("else:").append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("buffer.writeInt(len({}))", objectStr)).append(LS);
+
+ String element = "element" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in {}:", element, objectStr)).append(LS);
+ GeneratePyUtils.pySerializer(arrayField.getArrayElementRegistration().serializer())
+ .writeObject(builder, element, deep + 2, field, arrayField.getArrayElementRegistration());
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ var cutDown = CutDownArraySerializer.getInstance().readObject(builder, field, fieldRegistration, CodeLanguage.Python);
+ if (cutDown != null) {
+ return cutDown;
+ }
+
+ ArrayField arrayField = (ArrayField) fieldRegistration;
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ builder.append(StringUtils.format("{} = []", result)).append(LS);
+
+ String i = "index" + GenerateProtocolFile.index.getAndIncrement();
+ String size = "size" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readInt()", size)).append(LS);
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("if {} > 0:", size)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in range({}):", i, size)).append(LS);
+ String readObject = GeneratePyUtils.pySerializer(arrayField.getArrayElementRegistration().serializer())
+ .readObject(builder, deep + 2, field, arrayField.getArrayElementRegistration());
+ GeneratePyUtils.addTab(builder, deep + 2);
+ builder.append(StringUtils.format("{}.append({})", result, readObject)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyBooleanSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyBooleanSerializer.java
new file mode 100644
index 00000000..7aac0b3a
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyBooleanSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyBooleanSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "False";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeBool({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readBool() ", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyByteSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyByteSerializer.java
new file mode 100644
index 00000000..62a5e043
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyByteSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyByteSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "0";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeByte({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readByte()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyCharSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyCharSerializer.java
new file mode 100644
index 00000000..ae6272e0
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyCharSerializer.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyCharSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "\"\"";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeChar({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readChar()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyDoubleSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyDoubleSerializer.java
new file mode 100644
index 00000000..ece68a52
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyDoubleSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyDoubleSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "0.0";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeDouble({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readDouble()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyFloatSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyFloatSerializer.java
new file mode 100644
index 00000000..1e29b461
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyFloatSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyFloatSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "0.0";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeFloat({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readFloat()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyIntSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyIntSerializer.java
new file mode 100644
index 00000000..2d444c32
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyIntSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyIntSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "0";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeInt({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readInt()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyListSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyListSerializer.java
new file mode 100644
index 00000000..199977ed
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyListSerializer.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+import com.zfoo.protocol.registration.field.ListField;
+import com.zfoo.protocol.serializer.CodeLanguage;
+import com.zfoo.protocol.serializer.CutDownListSerializer;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyListSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "[]";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ if (CutDownListSerializer.getInstance().writeObject(builder, objectStr, field, fieldRegistration, CodeLanguage.Python)) {
+ return;
+ }
+
+ ListField listField = (ListField) fieldRegistration;
+
+ builder.append(StringUtils.format("if {} is None:", objectStr)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append("buffer.writeInt(0)").append(LS);
+ GeneratePyUtils.addTab(builder, deep);
+
+ builder.append("else:").append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("buffer.writeInt(len({}))", objectStr)).append(LS);
+
+ String element = "element" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in {}:", element, objectStr)).append(LS);
+ GeneratePyUtils.pySerializer(listField.getListElementRegistration().serializer())
+ .writeObject(builder, element, deep + 2, field, listField.getListElementRegistration());
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ var cutDown = CutDownListSerializer.getInstance().readObject(builder, field, fieldRegistration, CodeLanguage.Python);
+ if (cutDown != null) {
+ return cutDown;
+ }
+
+ ListField listField = (ListField) fieldRegistration;
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ builder.append(StringUtils.format("{} = []", result)).append(LS);
+
+ String i = "index" + GenerateProtocolFile.index.getAndIncrement();
+ String size = "size" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readInt()", size)).append(LS);
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("if {} > 0:", size)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in range({}):", i, size)).append(LS);
+ String readObject = GeneratePyUtils.pySerializer(listField.getListElementRegistration().serializer())
+ .readObject(builder, deep + 2, field, listField.getListElementRegistration());
+ GeneratePyUtils.addTab(builder, deep + 2);
+ builder.append(StringUtils.format("{}.append({})", result, readObject)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyLongSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyLongSerializer.java
new file mode 100644
index 00000000..4815cd06
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyLongSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyLongSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "0";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeLong({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readLong()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyMapSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyMapSerializer.java
new file mode 100644
index 00000000..4520973b
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyMapSerializer.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+import com.zfoo.protocol.registration.field.MapField;
+import com.zfoo.protocol.serializer.CodeLanguage;
+import com.zfoo.protocol.serializer.CutDownMapSerializer;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyMapSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "{}";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ if (CutDownMapSerializer.getInstance().writeObject(builder, objectStr, field, fieldRegistration, CodeLanguage.Python)) {
+ return;
+ }
+
+ MapField mapField = (MapField) fieldRegistration;
+ builder.append(StringUtils.format("if {} is None:", objectStr)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append("buffer.writeInt(0)").append(LS);
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append("else:").append(LS);
+
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("buffer.writeInt(len({}))", objectStr)).append(LS);
+
+ String key = "key" + GenerateProtocolFile.index.getAndIncrement();
+ String value = "value" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in {}:", key, objectStr)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 2);
+ builder.append(StringUtils.format("{} = {}[{}]", value, objectStr, key)).append(LS);
+ GeneratePyUtils.pySerializer(mapField.getMapKeyRegistration().serializer())
+ .writeObject(builder, key, deep + 2, field, mapField.getMapKeyRegistration());
+ GeneratePyUtils.pySerializer(mapField.getMapValueRegistration().serializer())
+ .writeObject(builder, value, deep + 2, field, mapField.getMapValueRegistration());
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ var cutDown = CutDownMapSerializer.getInstance().readObject(builder, field, fieldRegistration, CodeLanguage.Python);
+ if (cutDown != null) {
+ return cutDown;
+ }
+
+ MapField mapField = (MapField) fieldRegistration;
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ builder.append(StringUtils.format("{} = {}", result)).append(LS);
+
+ GeneratePyUtils.addTab(builder, deep);
+ String size = "size" + GenerateProtocolFile.index.getAndIncrement();
+ builder.append(StringUtils.format("{} = buffer.readInt()", size)).append(LS);
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("if {} > 0:", size)).append(LS);
+
+ String i = "index" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in range({}):", i, size)).append(LS);
+
+ String keyObject = GeneratePyUtils.pySerializer(mapField.getMapKeyRegistration().serializer())
+ .readObject(builder, deep + 2, field, mapField.getMapKeyRegistration());
+
+
+ String valueObject = GeneratePyUtils.pySerializer(mapField.getMapValueRegistration().serializer())
+ .readObject(builder, deep + 2, field, mapField.getMapValueRegistration());
+ GeneratePyUtils.addTab(builder, deep + 2);
+
+ builder.append(StringUtils.format("{}[{}] = {}", result, keyObject, valueObject)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyObjectProtocolSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyObjectProtocolSerializer.java
new file mode 100644
index 00000000..d3812a8d
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyObjectProtocolSerializer.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+import com.zfoo.protocol.registration.field.ObjectProtocolField;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyObjectProtocolSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "None";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ ObjectProtocolField objectProtocolField = (ObjectProtocolField) fieldRegistration;
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writePacket({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ ObjectProtocolField objectProtocolField = (ObjectProtocolField) fieldRegistration;
+ var result = "result" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readPacket({})", result, objectProtocolField.getProtocolId())).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PySetSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PySetSerializer.java
new file mode 100644
index 00000000..60752c6f
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PySetSerializer.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+import com.zfoo.protocol.registration.field.SetField;
+import com.zfoo.protocol.serializer.CodeLanguage;
+import com.zfoo.protocol.serializer.CutDownSetSerializer;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PySetSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "{}";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ if (CutDownSetSerializer.getInstance().writeObject(builder, objectStr, field, fieldRegistration, CodeLanguage.Python)) {
+ return;
+ }
+
+ SetField setField = (SetField) fieldRegistration;
+
+ builder.append(StringUtils.format("if {} is None:", objectStr)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append("buffer.writeInt(0)").append(LS);
+ GeneratePyUtils.addTab(builder, deep);
+
+ builder.append("else:").append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("buffer.writeInt(len({}))", objectStr)).append(LS);
+
+ String element = "element" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in {}:", element, objectStr)).append(LS);
+ GeneratePyUtils.pySerializer(setField.getSetElementRegistration().serializer())
+ .writeObject(builder, element, deep + 2, field, setField.getSetElementRegistration());
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ var cutDown = CutDownSetSerializer.getInstance().readObject(builder, field, fieldRegistration, CodeLanguage.Python);
+ if (cutDown != null) {
+ return cutDown;
+ }
+
+ SetField setField = (SetField) fieldRegistration;
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ builder.append(StringUtils.format("{} = []", result)).append(LS);
+
+ String i = "index" + GenerateProtocolFile.index.getAndIncrement();
+ String size = "size" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readInt()", size)).append(LS);
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("if {} > 0:", size)).append(LS);
+ GeneratePyUtils.addTab(builder, deep + 1);
+ builder.append(StringUtils.format("for {} in range({}):", i, size)).append(LS);
+ String readObject = GeneratePyUtils.pySerializer(setField.getSetElementRegistration().serializer())
+ .readObject(builder, deep + 2, field, setField.getSetElementRegistration());
+ GeneratePyUtils.addTab(builder, deep + 2);
+ builder.append(StringUtils.format("{}.append({})", result, readObject)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyShortSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyShortSerializer.java
new file mode 100644
index 00000000..030d1cb7
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyShortSerializer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyShortSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "0";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeShort({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readShort()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyStringSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyStringSerializer.java
new file mode 100644
index 00000000..490ed1ce
--- /dev/null
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/python/PyStringSerializer.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 The zfoo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+ */
+
+package com.zfoo.protocol.serializer.python;
+
+import com.zfoo.protocol.generate.GenerateProtocolFile;
+import com.zfoo.protocol.registration.field.IFieldRegistration;
+
+import com.zfoo.protocol.util.StringUtils;
+
+import java.lang.reflect.Field;
+
+import static com.zfoo.protocol.util.FileUtils.LS;
+
+/**
+ * @author godotg
+ * @version 3.0
+ */
+public class PyStringSerializer implements IPySerializer {
+ @Override
+ public String fieldDefaultValue(Field field, IFieldRegistration fieldRegistration) {
+ return "\"\"";
+ }
+
+ @Override
+ public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) {
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("buffer.writeString({})", objectStr)).append(LS);
+ }
+
+ @Override
+ public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) {
+ String result = "result" + GenerateProtocolFile.index.getAndIncrement();
+ GeneratePyUtils.addTab(builder, deep);
+ builder.append(StringUtils.format("{} = buffer.readString()", result)).append(LS);
+ return result;
+ }
+}
diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java
index c6a59b55..28356bea 100644
--- a/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java
@@ -96,14 +96,14 @@ public abstract class GenerateTsUtils {
}
// 生成ProtocolManager.ts文件
- var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("typescript/ProtocolManagerTemplate.ts")));
+ var protocolManagerTemplate = ClassUtils.getFileFromClassPathToString("typescript/ProtocolManagerTemplate.ts");
var importBuilder = new StringBuilder();
var initProtocolBuilder = new StringBuilder();
for (var protocol : protocolList) {
var protocolId = protocol.protocolId();
var name = protocol.protocolConstructor().getDeclaringClass().getSimpleName();
- var path = GenerateProtocolPath.protocolAbsolutePath(protocolId, CodeLanguage.GdScript);
+ var path = GenerateProtocolPath.protocolAbsolutePath(protocolId, CodeLanguage.TypeScript);
importBuilder.append(StringUtils.format("import {} from './{}';", name, path)).append(LS);
initProtocolBuilder.append(StringUtils.format("protocols.set({}, {});", protocolId, name)).append(LS);
@@ -121,7 +121,7 @@ public abstract class GenerateTsUtils {
var registrationConstructor = registration.getConstructor();
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
- var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("typescript/ProtocolTemplate.ts")));
+ var protocolTemplate = ClassUtils.getFileFromClassPathToString("typescript/ProtocolTemplate.ts");
var importSubProtocol = importSubProtocol(registration);
var classNote = GenerateProtocolNote.classNote(protocolId, CodeLanguage.TypeScript);
diff --git a/protocol/src/main/java/com/zfoo/protocol/util/StringUtils.java b/protocol/src/main/java/com/zfoo/protocol/util/StringUtils.java
index a9517d9d..bc90836b 100644
--- a/protocol/src/main/java/com/zfoo/protocol/util/StringUtils.java
+++ b/protocol/src/main/java/com/zfoo/protocol/util/StringUtils.java
@@ -16,7 +16,6 @@ import com.zfoo.protocol.collection.ArrayUtils;
import java.nio.charset.Charset;
import java.util.*;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
@@ -80,7 +79,6 @@ public abstract class StringUtils {
public static final String EMPTY_JSON = "{}";
- public static final String SEMICOLON_COMMA = ";|,"; //分号或者逗号
public static final String MULTIPLE_HYPHENS = "-----------------------------------------------------------------------";
@@ -485,15 +483,4 @@ public abstract class StringUtils {
return Character.isWhitespace(ch) || STOP_WORD.contains(ch);
}
- /**
- * 判断是否是正数
- * @param str
- * @return
- */
- public static boolean isNumeric(String str) {
- Pattern pattern = Pattern.compile("[0-9]*");
- Matcher isNum = pattern.matcher(str);
- return isNum.matches();
- }
-
}
diff --git a/protocol/src/main/resources/gdscript/ProtocolManagerTemplate.gd b/protocol/src/main/resources/gdscript/ProtocolManagerTemplate.gd
index 3779a818..2f95eaf4 100644
--- a/protocol/src/main/resources/gdscript/ProtocolManagerTemplate.gd
+++ b/protocol/src/main/resources/gdscript/ProtocolManagerTemplate.gd
@@ -18,7 +18,7 @@ static func write(buffer, packet):
protocol.write(buffer, packet)
static func read(buffer):
- var protocolId = buffer.readShort();
+ var protocolId = buffer.readShort()
var protocol = protocols[protocolId]
- var packet = protocol.read(buffer);
- return packet;
+ var packet = protocol.read(buffer)
+ return packet
diff --git a/protocol/src/main/resources/gdscript/buffer/ByteBuffer.gd b/protocol/src/main/resources/gdscript/buffer/ByteBuffer.gd
index c57b15cf..f0240a12 100644
--- a/protocol/src/main/resources/gdscript/buffer/ByteBuffer.gd
+++ b/protocol/src/main/resources/gdscript/buffer/ByteBuffer.gd
@@ -277,7 +277,7 @@ func writeBooleanArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeBool(element)
@@ -293,7 +293,7 @@ func writeByteArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeByte(element)
@@ -309,7 +309,7 @@ func writeShortArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeShort(element)
@@ -325,7 +325,7 @@ func writeIntArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeInt(element)
@@ -341,7 +341,7 @@ func writeLongArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeLong(element)
@@ -357,7 +357,7 @@ func writeFloatArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeFloat(element)
@@ -373,7 +373,7 @@ func writeDoubleArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeDouble(element)
@@ -389,7 +389,7 @@ func writeCharArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeChar(element)
@@ -405,7 +405,7 @@ func writeStringArray(array):
if (array == null):
writeInt(0)
else:
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
writeString(element)
@@ -423,7 +423,7 @@ func writePacketArray(array, protocolId):
writeInt(0)
else:
var protocolRegistration = ProtocolManager.getProtocol(protocolId)
- writeInt(array.size());
+ writeInt(array.size())
for element in array:
protocolRegistration.write(self, element)
diff --git a/protocol/src/main/resources/python/ByteBuffer.py b/protocol/src/main/resources/python/ByteBuffer.py
new file mode 100644
index 00000000..45775e57
--- /dev/null
+++ b/protocol/src/main/resources/python/ByteBuffer.py
@@ -0,0 +1,907 @@
+import struct
+from . import ProtocolManager
+
+maxSize = 655537
+maxInt = 2147483647
+minInt = -2147483648
+maxLong = 9223372036854775807
+minLong = -9223372036854775808
+empty_str = ""
+
+
+class ByteBuffer():
+ writeOffset = 0
+ readOffset = 0
+ buffer = bytearray(256)
+
+ def setWriteOffset(self, writeOffset):
+ if writeOffset > len(self.buffer):
+ raise ValueError("index out of bounds exception:readerIndex:" + str(self.readOffset) +
+ ", writerIndex:" + str(self.writeOffset) +
+ "(expected:0 <= readerIndex <= writerIndex <= capacity:" + str(len(self.buffer)))
+ self.writeOffset = writeOffset
+
+ def setReadOffset(self, readOffset):
+ if readOffset > self.writeOffset:
+ raise ValueError("index out of bounds exception:readerIndex:" + str(self.readOffset) +
+ ", writerIndex:" + str(self.writeOffset) +
+ "(expected:0 <= readerIndex <= writerIndex <= capacity:" + str(len(self.buffer)))
+ self.readOffset = readOffset
+
+ def isReadable(self):
+ return self.writeOffset > self.readOffset
+ pass
+
+ def getCapacity(self):
+ return len(self.buffer) - self.writeOffset
+
+ def ensureCapacity(self, minCapacity):
+ while (minCapacity - self.getCapacity() > 0):
+ newSize = len(self.buffer) * 2
+ if newSize > maxSize:
+ raise ValueError("out of memory error")
+ # auto grow capacity
+ self.buffer.extend(bytearray(len(self.buffer)))
+
+ def clear(self):
+ self.writeOffset = 0
+ self.readOffset = 0
+ self.buffer = bytearray(256)
+ pass
+
+ def toBytes(self):
+ return self.buffer[0:self.writeOffset]
+
+ def writeBool(self, value):
+ if value:
+ self.writeByte(1)
+ else:
+ self.writeByte(0)
+
+ def readBool(self):
+ if self.readByte():
+ return True
+ else:
+ return False
+
+ def writeByte(self, value):
+ self.ensureCapacity(1)
+ struct.pack_into('>b', self.buffer, self.writeOffset, value)
+ self.writeOffset += 1
+
+ def readByte(self):
+ value = struct.unpack_from('>b', self.buffer, self.readOffset)[0]
+ self.readOffset += 1
+ return value
+
+ def writeBytes(self, value):
+ length = len(value)
+ self.ensureCapacity(length)
+ self.buffer[self.writeOffset:length] = value[:]
+ self.writeOffset += length
+
+ def writeUByte(self, value):
+ self.ensureCapacity(1)
+ struct.pack_into('>B', self.buffer, self.writeOffset, value)
+ self.writeOffset += 1
+
+ def readUByte(self):
+ value = struct.unpack_from('>B', self.buffer, self.readOffset)[0]
+ self.readOffset += 1
+ return value
+
+ def writeShort(self, value):
+ self.ensureCapacity(2)
+ struct.pack_into('>h', self.buffer, self.writeOffset, value)
+ self.writeOffset += 2
+
+ def readShort(self):
+ value = struct.unpack_from('>h', self.buffer, self.readOffset)[0]
+ self.readOffset += 2
+ return value
+
+ def writeRawInt(self, value):
+ self.ensureCapacity(4)
+ struct.pack_into('>i', self.buffer, self.writeOffset, value)
+ self.writeOffset += 4
+
+ def readRawInt(self):
+ value = struct.unpack_from('>i', self.buffer, self.readOffset)[0]
+ self.readOffset += 4
+ return value
+
+ def writeInt(self, value):
+ if not (minInt <= value <= maxInt):
+ raise ValueError('value must range between minInt:-2147483648 and maxInt:2147483647')
+ value = (value << 1) ^ (value >> 31)
+ self.ensureCapacity(5)
+ if value >> 7 == 0:
+ self.writeUByte(value)
+ return
+
+ if value >> 14 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte((value >> 7) & 0x7F)
+ return
+
+ if value >> 21 == 0:
+ self.writeUByte((value & 0x7F) | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte((value >> 14) & 0x7F)
+ return
+
+ if value >> 28 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte((value >> 21) & 0x7F)
+ return
+
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte((value >> 28) & 0x7F)
+ pass
+
+ def readInt(self):
+ b = self.readUByte()
+ value = b & 0x7F
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 7
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 14
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 21
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 28
+ return (value >> 1) ^ -(value & 1)
+
+ def writeLong(self, value):
+ if not (minLong <= value <= maxLong):
+ raise ValueError('value must range between minLong:-9223372036854775808 and maxLong:9223372036854775807')
+ value = (value << 1) ^ (value >> 63)
+ self.ensureCapacity(9)
+ if value >> 7 == 0:
+ self.writeUByte(value)
+ return
+
+ if value >> 14 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte((value >> 7) & 0x7F)
+ return
+
+ if value >> 21 == 0:
+ self.writeUByte((value & 0x7F) | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte((value >> 14) & 0x7F)
+ return
+
+ if value >> 28 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte((value >> 21) & 0x7F)
+ return
+ if value >> 35 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte((value >> 28) & 0x7F)
+ return
+ if value >> 42 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte((value >> 35) & 0x7F)
+ return
+ if value >> 49 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte(((value >> 35) & 0x7F | 0x80))
+ self.writeUByte((value >> 42) & 0x7F)
+ return
+ if value >> 56 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte(((value >> 35) & 0x7F | 0x80))
+ self.writeUByte(((value >> 42) & 0x7F | 0x80))
+ self.writeUByte((value >> 49) & 0x7F)
+ return
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte(((value >> 35) & 0x7F | 0x80))
+ self.writeUByte(((value >> 42) & 0x7F | 0x80))
+ self.writeUByte(((value >> 49) & 0x7F | 0x80))
+ self.writeUByte(value >> 56)
+ pass
+
+ def readLong(self):
+ b = self.readUByte()
+ value = b & 0x7F
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 7
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 14
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 21
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 28
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 35
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 42
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 49
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= b << 56
+ return (value >> 1) ^ -(value & 1)
+
+ def writeFloat(self, value):
+ self.ensureCapacity(4)
+ struct.pack_into('>f', self.buffer, self.writeOffset, value)
+ self.writeOffset += 4
+
+ def readFloat(self):
+ value = struct.unpack_from('>f', self.buffer, self.readOffset)[0]
+ self.readOffset += 4
+ return value
+
+ def writeDouble(self, value):
+ self.ensureCapacity(8)
+ struct.pack_into('>d', self.buffer, self.writeOffset, value)
+ self.writeOffset += 8
+
+ def readDouble(self):
+ value = struct.unpack_from('>d', self.buffer, self.readOffset)[0]
+ self.readOffset += 8
+ return value
+
+ def writeChar(self, value):
+ if len(value) == 0:
+ self.writeInt(0)
+ return
+ self.writeString(value[0])
+
+ def readChar(self):
+ return self.readString()
+
+ def writeString(self, value):
+ if len(value) == 0:
+ self.writeInt(0)
+ return
+ byte_array = bytearray(value, 'utf-8')
+ length = len(byte_array)
+ self.ensureCapacity(5 + length)
+ self.writeInt(length)
+ self.buffer[self.writeOffset:self.writeOffset + length] = byte_array[:]
+ self.writeOffset += length
+
+ def readString(self):
+ length = self.readInt()
+ if (length <= 0):
+ return empty_str
+ byte_array = self.buffer[self.readOffset:self.readOffset + length]
+ # 使用utf-8编码进行解码
+ value = byte_array.decode('utf-8')
+ self.readOffset += length
+ return value
+
+ def writePacketFlag(self, value):
+ if value is None:
+ self.writeBool(False)
+ else:
+ self.writeBool(True)
+ pass
+
+ def writePacket(self, packet, protocolId):
+ protocolRegistration = ProtocolManager.getProtocol(protocolId)
+ protocolRegistration.write(self, packet)
+
+ def readPacket(self, protocolId):
+ protocolRegistration = ProtocolManager.getProtocol(protocolId)
+ return protocolRegistration.read(self)
+
+ def writeBooleanArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeBool(element)
+ pass
+
+ def readBooleanArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readBool())
+ return array
+
+ def writeByteArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeByte(element)
+ pass
+
+ def readByteArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readByte())
+ return array
+
+ def writeShortArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeShort(element)
+ pass
+
+ def readShortArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readShort())
+ return array
+
+ def writeIntArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeInt(element)
+ pass
+
+ def readIntArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readInt())
+ return array
+
+ def writeLongArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeLong(element)
+ pass
+
+ def readLongArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readLong())
+ return array
+
+ def writeFloatArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeFloat(element)
+ pass
+
+ def readFloatArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readFloat())
+ return array
+
+ def writeDoubleArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeDouble(element)
+ pass
+
+ def readDoubleArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readDouble())
+ return array
+
+ def writeCharArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeChar(element)
+ pass
+
+ def readCharArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readChar())
+ return array
+
+ def writeStringArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeString(element)
+ pass
+
+ def readStringArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readString())
+ return array
+
+ def writePacketArray(self, array, protocolId):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writePacket(element, protocolId)
+ pass
+
+ def readPacketArray(self, protocolId):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readPacket(protocolId))
+ return array
+
+ def writeIntIntMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writeInt(value)
+ pass
+
+ def readIntIntMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readInt()
+ map[key] = value
+ return map
+
+ def writeIntLongMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writeLong(value)
+ pass
+
+ def readIntLongMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readLong()
+ map[key] = value
+ return map
+
+ def writeIntStringMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writeString(value)
+ pass
+
+ def readIntStringMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readString()
+ map[key] = value
+ return map
+
+ def writeIntPacketMap(self, map, protocolId):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writePacket(value, protocolId)
+ pass
+
+ def readIntPacketMap(self, protocolId):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readPacket(protocolId)
+ map[key] = value
+ return map
+
+ def writeLongIntMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writeInt(value)
+ pass
+
+ def readLongIntMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readInt()
+ map[key] = value
+ return map
+
+ def writeLongLongMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writeLong(value)
+ pass
+
+ def readLongLongMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readLong()
+ map[key] = value
+ return map
+
+ def writeLongStringMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writeString(value)
+ pass
+
+ def readLongStringMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readString()
+ map[key] = value
+ return map
+
+ def writeLongPacketMap(self, map, protocolId):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writePacket(value, protocolId)
+ pass
+
+ def readLongPacketMap(self, protocolId):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readPacket(protocolId)
+ map[key] = value
+ return map
+
+ def writeStringIntMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writeInt(value)
+ pass
+
+ def readStringIntMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readInt()
+ map[key] = value
+ return map
+
+ def writeStringLongMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writeLong(value)
+ pass
+
+ def readStringLongMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readLong()
+ map[key] = value
+ return map
+
+ def writeStringStringMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writeString(value)
+ pass
+
+ def readStringStringMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readString()
+ map[key] = value
+ return map
+
+ def writeStringPacketMap(self, map, protocolId):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writePacket(value, protocolId)
+ pass
+
+ def readStringPacketMap(self, protocolId):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readPacket(protocolId)
+ map[key] = value
+ return map
+
+ def writeBooleanSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeBool(element)
+ pass
+
+ def readBooleanSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readBool())
+ return value
+
+ def writeByteSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeByte(element)
+ pass
+
+ def readByteSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readByte())
+ return value
+
+ def writeShortSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeShort(element)
+ pass
+
+ def readShortSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readShort())
+ return value
+
+ def writeIntSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeInt(element)
+ pass
+
+ def readIntSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readInt())
+ return value
+
+ def writeLongSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeLong(element)
+ pass
+
+ def readLongSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readLong())
+ return value
+
+ def writeFloatSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeFloat(element)
+ pass
+
+ def readFloatSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readFloat())
+ return value
+
+ def writeDoubleSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeDouble(element)
+ pass
+
+ def readDoubleSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readDouble())
+ return value
+
+ def writeCharSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeChar(element)
+ pass
+
+ def readCharValue(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readChar())
+ return value
+
+ def writeStringSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeString(element)
+ pass
+
+ def readStringSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readString())
+ return value
+
+ def writePacketSet(self, value, protocolId):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writePacket(element, protocolId)
+ pass
+
+ def readPacketSet(self, protocolId):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readPacket(protocolId))
+ return value
\ No newline at end of file
diff --git a/protocol/src/main/resources/python/ProtocolManagerTemplate.py b/protocol/src/main/resources/python/ProtocolManagerTemplate.py
new file mode 100644
index 00000000..431d7d9b
--- /dev/null
+++ b/protocol/src/main/resources/python/ProtocolManagerTemplate.py
@@ -0,0 +1,20 @@
+{}
+
+protocols = {}
+
+{}
+
+def getProtocol(protocolId):
+ return protocols[protocolId]
+
+def write(buffer, packet):
+ protocolId = packet.protocolId()
+ buffer.writeShort(protocolId)
+ protocol = protocols[protocolId]
+ protocol.write(buffer, packet)
+
+def read(buffer):
+ protocolId = buffer.readShort()
+ protocol = protocols[protocolId]
+ packet = protocol.read(buffer)
+ return packet
diff --git a/protocol/src/main/resources/python/ProtocolTemplate.py b/protocol/src/main/resources/python/ProtocolTemplate.py
new file mode 100644
index 00000000..8e672b6d
--- /dev/null
+++ b/protocol/src/main/resources/python/ProtocolTemplate.py
@@ -0,0 +1,23 @@
+{}
+class {}:
+
+ {}
+
+ def protocolId(self):
+ return {}
+
+ @classmethod
+ def write(cls, buffer, packet):
+ if buffer.writePacketFlag(packet):
+ return
+ {}
+ pass
+
+ @classmethod
+ def read(cls, buffer):
+ if not buffer.readBool():
+ return None
+ packet = {}()
+ {}
+ return packet
+
diff --git a/protocol/src/test/java/com/zfoo/protocol/SpeedTest.java b/protocol/src/test/java/com/zfoo/protocol/SpeedTest.java
index e820ec97..26dc59d5 100644
--- a/protocol/src/test/java/com/zfoo/protocol/SpeedTest.java
+++ b/protocol/src/test/java/com/zfoo/protocol/SpeedTest.java
@@ -23,6 +23,7 @@ import com.google.protobuf.CodedOutputStream;
import com.zfoo.protocol.collection.ArrayUtils;
import com.zfoo.protocol.generate.GenerateOperation;
import com.zfoo.protocol.packet.*;
+import com.zfoo.protocol.serializer.CodeLanguage;
import com.zfoo.protocol.util.StringUtils;
import io.fury.Fury;
import io.fury.Language;
@@ -375,6 +376,7 @@ public class SpeedTest {
// op.getGenerateLanguages().add(CodeLanguage.Lua);
// op.getGenerateLanguages().add(CodeLanguage.CSharp);
// op.getGenerateLanguages().add(CodeLanguage.GdScript);
+ op.getGenerateLanguages().add(CodeLanguage.Python);
// 需要protocol协议的字段里面都加上JProtobuf注解才能用
// op.setProtocolParam("protobuf=protobuf.xml");
diff --git a/protocol/src/test/python/ProtocolTest.py b/protocol/src/test/python/ProtocolTest.py
new file mode 100644
index 00000000..60676106
--- /dev/null
+++ b/protocol/src/test/python/ProtocolTest.py
@@ -0,0 +1,96 @@
+# encoding: UTF-8
+
+from unittest import TestCase
+import struct
+
+from pyProtocol import ProtocolManager
+from pyProtocol import ByteBuffer
+
+def print_bytearray(array):
+ signed_byte_array = struct.unpack('b' * len(array), array)
+ for byte in signed_byte_array:
+ print(byte) # 以字节形式输出每个字节的值
+
+
+class ByteBufferTestCase(TestCase):
+ def test_complex_object(self):
+ # 打开文件并读取内容
+ with open('NormalObject.bytes', 'rb') as file:
+ content = file.read()
+
+ # 将内容转为bytearray
+ byte_array = bytearray(content)
+ buffer = ByteBuffer.ByteBuffer()
+ buffer.writeBytes(byte_array)
+ obj = ProtocolManager.read(buffer)
+ buffer.clear()
+ ProtocolManager.write(buffer, obj)
+ newObj = ProtocolManager.read(buffer)
+ bytes = buffer.toBytes()
+
+ # 打印bytearray
+ print(byte_array)
+ pass
+
+ def test_bytearray(self):
+ buffer = bytearray(10)
+ for byte in buffer:
+ print(byte) # 以字节形式输出每个字节的值
+ pass
+
+ def test_buffer_raw_int(self):
+ byteBuffer = ByteBuffer.ByteBuffer()
+ byteBuffer.writeRawInt(2147483647)
+ self.assertEqual(byteBuffer.readRawInt(), 2147483647)
+
+ def test_buffer_int(self):
+ byteBuffer = ByteBuffer.ByteBuffer()
+ byteBuffer.writeInt(2147483647)
+ self.assertEqual(byteBuffer.readInt(), 2147483647)
+ byteBuffer.writeInt(-2147483648)
+ self.assertEqual(byteBuffer.readInt(), -2147483648)
+ pass
+
+ def test_buffer_long(self):
+ byteBuffer = ByteBuffer.ByteBuffer()
+ byteBuffer.writeLong(9223372036854775807)
+ self.assertEqual(byteBuffer.readLong(), 9223372036854775807)
+ print_bytearray(byteBuffer.buffer)
+ byteBuffer.writeLong(-9223372036854775808)
+ self.assertEqual(byteBuffer.readLong(), -9223372036854775808)
+ pass
+
+ def test_buffer(self):
+ byteBuffer = ByteBuffer.ByteBuffer()
+ print(byteBuffer.writeOffset)
+ print(byteBuffer.readOffset)
+ print(byteBuffer.getCapacity())
+ byteBuffer.writeBool(True)
+ self.assertEqual(byteBuffer.readBool(), True)
+ byteBuffer.writeByte(-100)
+ self.assertEqual(byteBuffer.readByte(), -100)
+ byteBuffer.writeShort(100)
+
+ self.assertEqual(byteBuffer.readShort(), 100)
+ byteBuffer.writeInt(9999)
+ self.assertEqual(byteBuffer.readInt(), 9999)
+ byteBuffer.writeInt(-9999)
+ self.assertEqual(byteBuffer.readInt(), -9999)
+
+ byteBuffer.writeLong(9999)
+ self.assertEqual(byteBuffer.readLong(), 9999)
+ byteBuffer.writeLong(-9999)
+ self.assertEqual(byteBuffer.readLong(), -9999)
+
+ byteBuffer.writeFloat(99.9)
+ self.assertTrue(abs(byteBuffer.readFloat() - 99.9) < 0.001)
+
+ str = "Hello World!你好"
+ byteBuffer.writeString(str)
+ self.assertEqual(byteBuffer.readString(), str)
+
+ charStr = "A"
+ byteBuffer.writeChar(charStr)
+ self.assertEqual(byteBuffer.readChar(), charStr)
+ print("----------------------------------------------------------------")
+ print_bytearray(byteBuffer.buffer)
diff --git a/protocol/src/test/python/pyProtocol/ByteBuffer.py b/protocol/src/test/python/pyProtocol/ByteBuffer.py
new file mode 100644
index 00000000..45775e57
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/ByteBuffer.py
@@ -0,0 +1,907 @@
+import struct
+from . import ProtocolManager
+
+maxSize = 655537
+maxInt = 2147483647
+minInt = -2147483648
+maxLong = 9223372036854775807
+minLong = -9223372036854775808
+empty_str = ""
+
+
+class ByteBuffer():
+ writeOffset = 0
+ readOffset = 0
+ buffer = bytearray(256)
+
+ def setWriteOffset(self, writeOffset):
+ if writeOffset > len(self.buffer):
+ raise ValueError("index out of bounds exception:readerIndex:" + str(self.readOffset) +
+ ", writerIndex:" + str(self.writeOffset) +
+ "(expected:0 <= readerIndex <= writerIndex <= capacity:" + str(len(self.buffer)))
+ self.writeOffset = writeOffset
+
+ def setReadOffset(self, readOffset):
+ if readOffset > self.writeOffset:
+ raise ValueError("index out of bounds exception:readerIndex:" + str(self.readOffset) +
+ ", writerIndex:" + str(self.writeOffset) +
+ "(expected:0 <= readerIndex <= writerIndex <= capacity:" + str(len(self.buffer)))
+ self.readOffset = readOffset
+
+ def isReadable(self):
+ return self.writeOffset > self.readOffset
+ pass
+
+ def getCapacity(self):
+ return len(self.buffer) - self.writeOffset
+
+ def ensureCapacity(self, minCapacity):
+ while (minCapacity - self.getCapacity() > 0):
+ newSize = len(self.buffer) * 2
+ if newSize > maxSize:
+ raise ValueError("out of memory error")
+ # auto grow capacity
+ self.buffer.extend(bytearray(len(self.buffer)))
+
+ def clear(self):
+ self.writeOffset = 0
+ self.readOffset = 0
+ self.buffer = bytearray(256)
+ pass
+
+ def toBytes(self):
+ return self.buffer[0:self.writeOffset]
+
+ def writeBool(self, value):
+ if value:
+ self.writeByte(1)
+ else:
+ self.writeByte(0)
+
+ def readBool(self):
+ if self.readByte():
+ return True
+ else:
+ return False
+
+ def writeByte(self, value):
+ self.ensureCapacity(1)
+ struct.pack_into('>b', self.buffer, self.writeOffset, value)
+ self.writeOffset += 1
+
+ def readByte(self):
+ value = struct.unpack_from('>b', self.buffer, self.readOffset)[0]
+ self.readOffset += 1
+ return value
+
+ def writeBytes(self, value):
+ length = len(value)
+ self.ensureCapacity(length)
+ self.buffer[self.writeOffset:length] = value[:]
+ self.writeOffset += length
+
+ def writeUByte(self, value):
+ self.ensureCapacity(1)
+ struct.pack_into('>B', self.buffer, self.writeOffset, value)
+ self.writeOffset += 1
+
+ def readUByte(self):
+ value = struct.unpack_from('>B', self.buffer, self.readOffset)[0]
+ self.readOffset += 1
+ return value
+
+ def writeShort(self, value):
+ self.ensureCapacity(2)
+ struct.pack_into('>h', self.buffer, self.writeOffset, value)
+ self.writeOffset += 2
+
+ def readShort(self):
+ value = struct.unpack_from('>h', self.buffer, self.readOffset)[0]
+ self.readOffset += 2
+ return value
+
+ def writeRawInt(self, value):
+ self.ensureCapacity(4)
+ struct.pack_into('>i', self.buffer, self.writeOffset, value)
+ self.writeOffset += 4
+
+ def readRawInt(self):
+ value = struct.unpack_from('>i', self.buffer, self.readOffset)[0]
+ self.readOffset += 4
+ return value
+
+ def writeInt(self, value):
+ if not (minInt <= value <= maxInt):
+ raise ValueError('value must range between minInt:-2147483648 and maxInt:2147483647')
+ value = (value << 1) ^ (value >> 31)
+ self.ensureCapacity(5)
+ if value >> 7 == 0:
+ self.writeUByte(value)
+ return
+
+ if value >> 14 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte((value >> 7) & 0x7F)
+ return
+
+ if value >> 21 == 0:
+ self.writeUByte((value & 0x7F) | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte((value >> 14) & 0x7F)
+ return
+
+ if value >> 28 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte((value >> 21) & 0x7F)
+ return
+
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte((value >> 28) & 0x7F)
+ pass
+
+ def readInt(self):
+ b = self.readUByte()
+ value = b & 0x7F
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 7
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 14
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 21
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 28
+ return (value >> 1) ^ -(value & 1)
+
+ def writeLong(self, value):
+ if not (minLong <= value <= maxLong):
+ raise ValueError('value must range between minLong:-9223372036854775808 and maxLong:9223372036854775807')
+ value = (value << 1) ^ (value >> 63)
+ self.ensureCapacity(9)
+ if value >> 7 == 0:
+ self.writeUByte(value)
+ return
+
+ if value >> 14 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte((value >> 7) & 0x7F)
+ return
+
+ if value >> 21 == 0:
+ self.writeUByte((value & 0x7F) | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte((value >> 14) & 0x7F)
+ return
+
+ if value >> 28 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte((value >> 21) & 0x7F)
+ return
+ if value >> 35 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte((value >> 28) & 0x7F)
+ return
+ if value >> 42 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte((value >> 35) & 0x7F)
+ return
+ if value >> 49 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte(((value >> 35) & 0x7F | 0x80))
+ self.writeUByte((value >> 42) & 0x7F)
+ return
+ if value >> 56 == 0:
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte(((value >> 35) & 0x7F | 0x80))
+ self.writeUByte(((value >> 42) & 0x7F | 0x80))
+ self.writeUByte((value >> 49) & 0x7F)
+ return
+ self.writeUByte(value & 0x7F | 0x80)
+ self.writeUByte(((value >> 7) & 0x7F | 0x80))
+ self.writeUByte(((value >> 14) & 0x7F | 0x80))
+ self.writeUByte(((value >> 21) & 0x7F | 0x80))
+ self.writeUByte(((value >> 28) & 0x7F | 0x80))
+ self.writeUByte(((value >> 35) & 0x7F | 0x80))
+ self.writeUByte(((value >> 42) & 0x7F | 0x80))
+ self.writeUByte(((value >> 49) & 0x7F | 0x80))
+ self.writeUByte(value >> 56)
+ pass
+
+ def readLong(self):
+ b = self.readUByte()
+ value = b & 0x7F
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 7
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 14
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 21
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 28
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 35
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 42
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= (b & 0x7F) << 49
+ if (b & 0x80) != 0:
+ b = self.readUByte()
+ value |= b << 56
+ return (value >> 1) ^ -(value & 1)
+
+ def writeFloat(self, value):
+ self.ensureCapacity(4)
+ struct.pack_into('>f', self.buffer, self.writeOffset, value)
+ self.writeOffset += 4
+
+ def readFloat(self):
+ value = struct.unpack_from('>f', self.buffer, self.readOffset)[0]
+ self.readOffset += 4
+ return value
+
+ def writeDouble(self, value):
+ self.ensureCapacity(8)
+ struct.pack_into('>d', self.buffer, self.writeOffset, value)
+ self.writeOffset += 8
+
+ def readDouble(self):
+ value = struct.unpack_from('>d', self.buffer, self.readOffset)[0]
+ self.readOffset += 8
+ return value
+
+ def writeChar(self, value):
+ if len(value) == 0:
+ self.writeInt(0)
+ return
+ self.writeString(value[0])
+
+ def readChar(self):
+ return self.readString()
+
+ def writeString(self, value):
+ if len(value) == 0:
+ self.writeInt(0)
+ return
+ byte_array = bytearray(value, 'utf-8')
+ length = len(byte_array)
+ self.ensureCapacity(5 + length)
+ self.writeInt(length)
+ self.buffer[self.writeOffset:self.writeOffset + length] = byte_array[:]
+ self.writeOffset += length
+
+ def readString(self):
+ length = self.readInt()
+ if (length <= 0):
+ return empty_str
+ byte_array = self.buffer[self.readOffset:self.readOffset + length]
+ # 使用utf-8编码进行解码
+ value = byte_array.decode('utf-8')
+ self.readOffset += length
+ return value
+
+ def writePacketFlag(self, value):
+ if value is None:
+ self.writeBool(False)
+ else:
+ self.writeBool(True)
+ pass
+
+ def writePacket(self, packet, protocolId):
+ protocolRegistration = ProtocolManager.getProtocol(protocolId)
+ protocolRegistration.write(self, packet)
+
+ def readPacket(self, protocolId):
+ protocolRegistration = ProtocolManager.getProtocol(protocolId)
+ return protocolRegistration.read(self)
+
+ def writeBooleanArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeBool(element)
+ pass
+
+ def readBooleanArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readBool())
+ return array
+
+ def writeByteArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeByte(element)
+ pass
+
+ def readByteArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readByte())
+ return array
+
+ def writeShortArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeShort(element)
+ pass
+
+ def readShortArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readShort())
+ return array
+
+ def writeIntArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeInt(element)
+ pass
+
+ def readIntArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readInt())
+ return array
+
+ def writeLongArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeLong(element)
+ pass
+
+ def readLongArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readLong())
+ return array
+
+ def writeFloatArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeFloat(element)
+ pass
+
+ def readFloatArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readFloat())
+ return array
+
+ def writeDoubleArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeDouble(element)
+ pass
+
+ def readDoubleArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readDouble())
+ return array
+
+ def writeCharArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeChar(element)
+ pass
+
+ def readCharArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readChar())
+ return array
+
+ def writeStringArray(self, array):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writeString(element)
+ pass
+
+ def readStringArray(self):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readString())
+ return array
+
+ def writePacketArray(self, array, protocolId):
+ if array is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(array))
+ for element in array:
+ self.writePacket(element, protocolId)
+ pass
+
+ def readPacketArray(self, protocolId):
+ array = []
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ array.append(self.readPacket(protocolId))
+ return array
+
+ def writeIntIntMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writeInt(value)
+ pass
+
+ def readIntIntMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readInt()
+ map[key] = value
+ return map
+
+ def writeIntLongMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writeLong(value)
+ pass
+
+ def readIntLongMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readLong()
+ map[key] = value
+ return map
+
+ def writeIntStringMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writeString(value)
+ pass
+
+ def readIntStringMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readString()
+ map[key] = value
+ return map
+
+ def writeIntPacketMap(self, map, protocolId):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeInt(key)
+ self.writePacket(value, protocolId)
+ pass
+
+ def readIntPacketMap(self, protocolId):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readInt()
+ value = self.readPacket(protocolId)
+ map[key] = value
+ return map
+
+ def writeLongIntMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writeInt(value)
+ pass
+
+ def readLongIntMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readInt()
+ map[key] = value
+ return map
+
+ def writeLongLongMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writeLong(value)
+ pass
+
+ def readLongLongMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readLong()
+ map[key] = value
+ return map
+
+ def writeLongStringMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writeString(value)
+ pass
+
+ def readLongStringMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readString()
+ map[key] = value
+ return map
+
+ def writeLongPacketMap(self, map, protocolId):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeLong(key)
+ self.writePacket(value, protocolId)
+ pass
+
+ def readLongPacketMap(self, protocolId):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readLong()
+ value = self.readPacket(protocolId)
+ map[key] = value
+ return map
+
+ def writeStringIntMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writeInt(value)
+ pass
+
+ def readStringIntMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readInt()
+ map[key] = value
+ return map
+
+ def writeStringLongMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writeLong(value)
+ pass
+
+ def readStringLongMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readLong()
+ map[key] = value
+ return map
+
+ def writeStringStringMap(self, map):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writeString(value)
+ pass
+
+ def readStringStringMap(self):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readString()
+ map[key] = value
+ return map
+
+ def writeStringPacketMap(self, map, protocolId):
+ if map is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(map))
+ for key, value in map.items():
+ self.writeString(key)
+ self.writePacket(value, protocolId)
+ pass
+
+ def readStringPacketMap(self, protocolId):
+ map = {}
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ key = self.readString()
+ value = self.readPacket(protocolId)
+ map[key] = value
+ return map
+
+ def writeBooleanSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeBool(element)
+ pass
+
+ def readBooleanSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readBool())
+ return value
+
+ def writeByteSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeByte(element)
+ pass
+
+ def readByteSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readByte())
+ return value
+
+ def writeShortSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeShort(element)
+ pass
+
+ def readShortSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readShort())
+ return value
+
+ def writeIntSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeInt(element)
+ pass
+
+ def readIntSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readInt())
+ return value
+
+ def writeLongSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeLong(element)
+ pass
+
+ def readLongSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readLong())
+ return value
+
+ def writeFloatSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeFloat(element)
+ pass
+
+ def readFloatSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readFloat())
+ return value
+
+ def writeDoubleSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeDouble(element)
+ pass
+
+ def readDoubleSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readDouble())
+ return value
+
+ def writeCharSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeChar(element)
+ pass
+
+ def readCharValue(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readChar())
+ return value
+
+ def writeStringSet(self, value):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writeString(element)
+ pass
+
+ def readStringSet(self):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readString())
+ return value
+
+ def writePacketSet(self, value, protocolId):
+ if value is None:
+ self.writeInt(0)
+ else:
+ self.writeInt(len(value))
+ for element in value:
+ self.writePacket(element, protocolId)
+ pass
+
+ def readPacketSet(self, protocolId):
+ value = set()
+ size = self.readInt()
+ if size > 0:
+ for index in range(size):
+ value.add(self.readPacket(protocolId))
+ return value
\ No newline at end of file
diff --git a/protocol/src/test/python/pyProtocol/ComplexObject.py b/protocol/src/test/python/pyProtocol/ComplexObject.py
new file mode 100644
index 00000000..ebdadab3
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/ComplexObject.py
@@ -0,0 +1,411 @@
+# 复杂的对象,包括了各种复杂的结构,数组,List,Set,Map
+class ComplexObject:
+
+ # byte类型,最简单的整形
+ a = 0 # byte
+ # byte的包装类型,优先使用基础类型,包装类型会有装箱拆箱
+ aa = 0 # byte
+ # 数组类型
+ aaa = [] # byte[]
+ aaaa = [] # byte[]
+ b = 0 # short
+ bb = 0 # short
+ bbb = [] # short[]
+ bbbb = [] # short[]
+ c = 0 # int
+ cc = 0 # int
+ ccc = [] # int[]
+ cccc = [] # int[]
+ d = 0 # long
+ dd = 0 # long
+ ddd = [] # long[]
+ dddd = [] # long[]
+ e = 0.0 # float
+ ee = 0.0 # float
+ eee = [] # float[]
+ eeee = [] # float[]
+ f = 0.0 # double
+ ff = 0.0 # double
+ fff = [] # double[]
+ ffff = [] # double[]
+ g = False # bool
+ gg = False # bool
+ ggg = [] # bool[]
+ gggg = [] # bool[]
+ h = "" # char
+ hh = "" # char
+ hhh = [] # char[]
+ hhhh = [] # char[]
+ jj = "" # string
+ jjj = [] # string[]
+ kk = None # ObjectA
+ kkk = [] # ObjectA[]
+ l = [] # List
+ ll = [] # List>>
+ lll = [] # List>
+ llll = [] # List
+ lllll = [] # List>
+ m = {} # Dictionary
+ mm = {} # Dictionary
+ mmm = {} # Dictionary>
+ mmmm = {} # Dictionary>, List>>>
+ mmmmm = {} # Dictionary>, HashSet>>
+ s = {} # HashSet
+ ss = {} # HashSet>>
+ sss = {} # HashSet>
+ ssss = {} # HashSet
+ sssss = {} # HashSet>
+ # 如果要修改协议并且兼容老协议,需要加上Compatible注解,按照增加的顺序添加order
+ myCompatible = 0 # int
+ myObject = None # ObjectA
+
+ def protocolId(self):
+ return 100
+
+ @classmethod
+ def write(cls, buffer, packet):
+ if buffer.writePacketFlag(packet):
+ return
+ buffer.writeByte(packet.a)
+ buffer.writeByte(packet.aa)
+ buffer.writeByteArray(packet.aaa)
+ buffer.writeByteArray(packet.aaaa)
+ buffer.writeShort(packet.b)
+ buffer.writeShort(packet.bb)
+ buffer.writeShortArray(packet.bbb)
+ buffer.writeShortArray(packet.bbbb)
+ buffer.writeInt(packet.c)
+ buffer.writeInt(packet.cc)
+ buffer.writeIntArray(packet.ccc)
+ buffer.writeIntArray(packet.cccc)
+ buffer.writeLong(packet.d)
+ buffer.writeLong(packet.dd)
+ buffer.writeLongArray(packet.ddd)
+ buffer.writeLongArray(packet.dddd)
+ buffer.writeFloat(packet.e)
+ buffer.writeFloat(packet.ee)
+ buffer.writeFloatArray(packet.eee)
+ buffer.writeFloatArray(packet.eeee)
+ buffer.writeDouble(packet.f)
+ buffer.writeDouble(packet.ff)
+ buffer.writeDoubleArray(packet.fff)
+ buffer.writeDoubleArray(packet.ffff)
+ buffer.writeBool(packet.g)
+ buffer.writeBool(packet.gg)
+ buffer.writeBooleanArray(packet.ggg)
+ buffer.writeBooleanArray(packet.gggg)
+ buffer.writeChar(packet.h)
+ buffer.writeChar(packet.hh)
+ buffer.writeCharArray(packet.hhh)
+ buffer.writeCharArray(packet.hhhh)
+ buffer.writeString(packet.jj)
+ buffer.writeStringArray(packet.jjj)
+ buffer.writePacket(packet.kk, 102)
+ buffer.writePacketArray(packet.kkk, 102)
+ buffer.writeIntArray(packet.l)
+ if packet.ll is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.ll))
+ for element0 in packet.ll:
+ if element0 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(element0))
+ for element1 in element0:
+ buffer.writeIntArray(element1)
+ if packet.lll is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.lll))
+ for element2 in packet.lll:
+ buffer.writePacketArray(element2, 102)
+ buffer.writeStringArray(packet.llll)
+ if packet.lllll is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.lllll))
+ for element3 in packet.lllll:
+ buffer.writeIntStringMap(element3)
+ buffer.writeIntStringMap(packet.m)
+ buffer.writeIntPacketMap(packet.mm, 102)
+ if packet.mmm is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.mmm))
+ for key4 in packet.mmm:
+ value5 = packet.mmm[key4]
+ buffer.writePacket(key4, 102)
+ buffer.writeIntArray(value5)
+ if packet.mmmm is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.mmmm))
+ for key6 in packet.mmmm:
+ value7 = packet.mmmm[key6]
+ if key6 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(key6))
+ for element8 in key6:
+ buffer.writePacketArray(element8, 102)
+ if value7 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(value7))
+ for element9 in value7:
+ if element9 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(element9))
+ for element10 in element9:
+ buffer.writeIntArray(element10)
+ if packet.mmmmm is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.mmmmm))
+ for key11 in packet.mmmmm:
+ value12 = packet.mmmmm[key11]
+ if key11 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(key11))
+ for element13 in key11:
+ buffer.writeIntStringMap(element13)
+ if value12 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(value12))
+ for element14 in value12:
+ buffer.writeIntStringMap(element14)
+ buffer.writeIntSet(packet.s)
+ if packet.ss is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.ss))
+ for element15 in packet.ss:
+ if element15 is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(element15))
+ for element16 in element15:
+ buffer.writeIntArray(element16)
+ if packet.sss is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.sss))
+ for element17 in packet.sss:
+ buffer.writePacketSet(element17, 102)
+ buffer.writeStringSet(packet.ssss)
+ if packet.sssss is None:
+ buffer.writeInt(0)
+ else:
+ buffer.writeInt(len(packet.sssss))
+ for element18 in packet.sssss:
+ buffer.writeIntStringMap(element18)
+ buffer.writeInt(packet.myCompatible)
+ buffer.writePacket(packet.myObject, 102)
+ pass
+
+ @classmethod
+ def read(cls, buffer):
+ if not buffer.readBool():
+ return None
+ packet = ComplexObject()
+ result19 = buffer.readByte()
+ packet.a = result19
+ result20 = buffer.readByte()
+ packet.aa = result20
+ array21 = buffer.readByteArray()
+ packet.aaa = array21
+ array22 = buffer.readByteArray()
+ packet.aaaa = array22
+ result23 = buffer.readShort()
+ packet.b = result23
+ result24 = buffer.readShort()
+ packet.bb = result24
+ array25 = buffer.readShortArray()
+ packet.bbb = array25
+ array26 = buffer.readShortArray()
+ packet.bbbb = array26
+ result27 = buffer.readInt()
+ packet.c = result27
+ result28 = buffer.readInt()
+ packet.cc = result28
+ array29 = buffer.readIntArray()
+ packet.ccc = array29
+ array30 = buffer.readIntArray()
+ packet.cccc = array30
+ result31 = buffer.readLong()
+ packet.d = result31
+ result32 = buffer.readLong()
+ packet.dd = result32
+ array33 = buffer.readLongArray()
+ packet.ddd = array33
+ array34 = buffer.readLongArray()
+ packet.dddd = array34
+ result35 = buffer.readFloat()
+ packet.e = result35
+ result36 = buffer.readFloat()
+ packet.ee = result36
+ array37 = buffer.readFloatArray()
+ packet.eee = array37
+ array38 = buffer.readFloatArray()
+ packet.eeee = array38
+ result39 = buffer.readDouble()
+ packet.f = result39
+ result40 = buffer.readDouble()
+ packet.ff = result40
+ array41 = buffer.readDoubleArray()
+ packet.fff = array41
+ array42 = buffer.readDoubleArray()
+ packet.ffff = array42
+ result43 = buffer.readBool()
+ packet.g = result43
+ result44 = buffer.readBool()
+ packet.gg = result44
+ array45 = buffer.readBooleanArray()
+ packet.ggg = array45
+ array46 = buffer.readBooleanArray()
+ packet.gggg = array46
+ result47 = buffer.readChar()
+ packet.h = result47
+ result48 = buffer.readChar()
+ packet.hh = result48
+ array49 = buffer.readCharArray()
+ packet.hhh = array49
+ array50 = buffer.readCharArray()
+ packet.hhhh = array50
+ result51 = buffer.readString()
+ packet.jj = result51
+ array52 = buffer.readStringArray()
+ packet.jjj = array52
+ result53 = buffer.readPacket(102)
+ packet.kk = result53
+ array54 = buffer.readPacketArray(102)
+ packet.kkk = array54
+ list55 = buffer.readIntArray()
+ packet.l = list55
+ result56 = []
+ size58 = buffer.readInt()
+ if size58 > 0:
+ for index57 in range(size58):
+ result59 = []
+ size61 = buffer.readInt()
+ if size61 > 0:
+ for index60 in range(size61):
+ list62 = buffer.readIntArray()
+ result59.append(list62)
+ result56.append(result59)
+ packet.ll = result56
+ result63 = []
+ size65 = buffer.readInt()
+ if size65 > 0:
+ for index64 in range(size65):
+ list66 = buffer.readPacketArray(102)
+ result63.append(list66)
+ packet.lll = result63
+ list67 = buffer.readStringArray()
+ packet.llll = list67
+ result68 = []
+ size70 = buffer.readInt()
+ if size70 > 0:
+ for index69 in range(size70):
+ map71 = buffer.readIntStringMap()
+ result68.append(map71)
+ packet.lllll = result68
+ map72 = buffer.readIntStringMap()
+ packet.m = map72
+ map73 = buffer.readIntPacketMap(102)
+ packet.mm = map73
+ result74 = {}
+ size75 = buffer.readInt()
+ if size75 > 0:
+ for index76 in range(size75):
+ result77 = buffer.readPacket(102)
+ list78 = buffer.readIntArray()
+ result74[result77] = list78
+ packet.mmm = result74
+ result79 = {}
+ size80 = buffer.readInt()
+ if size80 > 0:
+ for index81 in range(size80):
+ result82 = []
+ size84 = buffer.readInt()
+ if size84 > 0:
+ for index83 in range(size84):
+ list85 = buffer.readPacketArray(102)
+ result82.append(list85)
+ result86 = []
+ size88 = buffer.readInt()
+ if size88 > 0:
+ for index87 in range(size88):
+ result89 = []
+ size91 = buffer.readInt()
+ if size91 > 0:
+ for index90 in range(size91):
+ list92 = buffer.readIntArray()
+ result89.append(list92)
+ result86.append(result89)
+ result79[result82] = result86
+ packet.mmmm = result79
+ result93 = {}
+ size94 = buffer.readInt()
+ if size94 > 0:
+ for index95 in range(size94):
+ result96 = []
+ size98 = buffer.readInt()
+ if size98 > 0:
+ for index97 in range(size98):
+ map99 = buffer.readIntStringMap()
+ result96.append(map99)
+ result100 = []
+ size102 = buffer.readInt()
+ if size102 > 0:
+ for index101 in range(size102):
+ map103 = buffer.readIntStringMap()
+ result100.append(map103)
+ result93[result96] = result100
+ packet.mmmmm = result93
+ set104 = buffer.readIntSet()
+ packet.s = set104
+ result105 = []
+ size107 = buffer.readInt()
+ if size107 > 0:
+ for index106 in range(size107):
+ result108 = []
+ size110 = buffer.readInt()
+ if size110 > 0:
+ for index109 in range(size110):
+ list111 = buffer.readIntArray()
+ result108.append(list111)
+ result105.append(result108)
+ packet.ss = result105
+ result112 = []
+ size114 = buffer.readInt()
+ if size114 > 0:
+ for index113 in range(size114):
+ set115 = buffer.readPacketSet(102)
+ result112.append(set115)
+ packet.sss = result112
+ set116 = buffer.readStringSet()
+ packet.ssss = set116
+ result117 = []
+ size119 = buffer.readInt()
+ if size119 > 0:
+ for index118 in range(size119):
+ map120 = buffer.readIntStringMap()
+ result117.append(map120)
+ packet.sssss = result117
+ if not buffer.isReadable():
+ return packet
+ pass
+ result121 = buffer.readInt()
+ packet.myCompatible = result121
+ if not buffer.isReadable():
+ return packet
+ pass
+ result122 = buffer.readPacket(102)
+ packet.myObject = result122
+ return packet
+
diff --git a/protocol/src/test/python/pyProtocol/NormalObject.py b/protocol/src/test/python/pyProtocol/NormalObject.py
new file mode 100644
index 00000000..16a62260
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/NormalObject.py
@@ -0,0 +1,92 @@
+
+class NormalObject:
+
+ a = 0 # byte
+ aaa = [] # byte[]
+ b = 0 # short
+ c = 0 # int
+ d = 0 # long
+ e = 0.0 # float
+ f = 0.0 # double
+ g = False # bool
+ jj = "" # string
+ kk = None # ObjectA
+ l = [] # List
+ ll = [] # List
+ lll = [] # List
+ llll = [] # List
+ m = {} # Dictionary
+ mm = {} # Dictionary
+ s = {} # HashSet
+ ssss = {} # HashSet
+
+ def protocolId(self):
+ return 101
+
+ @classmethod
+ def write(cls, buffer, packet):
+ if buffer.writePacketFlag(packet):
+ return
+ buffer.writeByte(packet.a)
+ buffer.writeByteArray(packet.aaa)
+ buffer.writeShort(packet.b)
+ buffer.writeInt(packet.c)
+ buffer.writeLong(packet.d)
+ buffer.writeFloat(packet.e)
+ buffer.writeDouble(packet.f)
+ buffer.writeBool(packet.g)
+ buffer.writeString(packet.jj)
+ buffer.writePacket(packet.kk, 102)
+ buffer.writeIntArray(packet.l)
+ buffer.writeLongArray(packet.ll)
+ buffer.writePacketArray(packet.lll, 102)
+ buffer.writeStringArray(packet.llll)
+ buffer.writeIntStringMap(packet.m)
+ buffer.writeIntPacketMap(packet.mm, 102)
+ buffer.writeIntSet(packet.s)
+ buffer.writeStringSet(packet.ssss)
+ pass
+
+ @classmethod
+ def read(cls, buffer):
+ if not buffer.readBool():
+ return None
+ packet = NormalObject()
+ result0 = buffer.readByte()
+ packet.a = result0
+ array1 = buffer.readByteArray()
+ packet.aaa = array1
+ result2 = buffer.readShort()
+ packet.b = result2
+ result3 = buffer.readInt()
+ packet.c = result3
+ result4 = buffer.readLong()
+ packet.d = result4
+ result5 = buffer.readFloat()
+ packet.e = result5
+ result6 = buffer.readDouble()
+ packet.f = result6
+ result7 = buffer.readBool()
+ packet.g = result7
+ result8 = buffer.readString()
+ packet.jj = result8
+ result9 = buffer.readPacket(102)
+ packet.kk = result9
+ list10 = buffer.readIntArray()
+ packet.l = list10
+ list11 = buffer.readLongArray()
+ packet.ll = list11
+ list12 = buffer.readPacketArray(102)
+ packet.lll = list12
+ list13 = buffer.readStringArray()
+ packet.llll = list13
+ map14 = buffer.readIntStringMap()
+ packet.m = map14
+ map15 = buffer.readIntPacketMap(102)
+ packet.mm = map15
+ set16 = buffer.readIntSet()
+ packet.s = set16
+ set17 = buffer.readStringSet()
+ packet.ssss = set17
+ return packet
+
diff --git a/protocol/src/test/python/pyProtocol/ObjectA.py b/protocol/src/test/python/pyProtocol/ObjectA.py
new file mode 100644
index 00000000..0e02f78c
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/ObjectA.py
@@ -0,0 +1,32 @@
+
+class ObjectA:
+
+ a = 0 # int
+ m = {} # Dictionary
+ objectB = None # ObjectB
+
+ def protocolId(self):
+ return 102
+
+ @classmethod
+ def write(cls, buffer, packet):
+ if buffer.writePacketFlag(packet):
+ return
+ buffer.writeInt(packet.a)
+ buffer.writeIntStringMap(packet.m)
+ buffer.writePacket(packet.objectB, 103)
+ pass
+
+ @classmethod
+ def read(cls, buffer):
+ if not buffer.readBool():
+ return None
+ packet = ObjectA()
+ result0 = buffer.readInt()
+ packet.a = result0
+ map1 = buffer.readIntStringMap()
+ packet.m = map1
+ result2 = buffer.readPacket(103)
+ packet.objectB = result2
+ return packet
+
diff --git a/protocol/src/test/python/pyProtocol/ObjectB.py b/protocol/src/test/python/pyProtocol/ObjectB.py
new file mode 100644
index 00000000..c5c1ff22
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/ObjectB.py
@@ -0,0 +1,24 @@
+
+class ObjectB:
+
+ flag = False # bool
+
+ def protocolId(self):
+ return 103
+
+ @classmethod
+ def write(cls, buffer, packet):
+ if buffer.writePacketFlag(packet):
+ return
+ buffer.writeBool(packet.flag)
+ pass
+
+ @classmethod
+ def read(cls, buffer):
+ if not buffer.readBool():
+ return None
+ packet = ObjectB()
+ result0 = buffer.readBool()
+ packet.flag = result0
+ return packet
+
diff --git a/protocol/src/test/python/pyProtocol/ProtocolManager.py b/protocol/src/test/python/pyProtocol/ProtocolManager.py
new file mode 100644
index 00000000..118b410e
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/ProtocolManager.py
@@ -0,0 +1,30 @@
+from . import VeryBigObject
+from . import ComplexObject
+from . import NormalObject
+from . import ObjectA
+from . import ObjectB
+from . import SimpleObject
+
+protocols = {}
+
+protocols[0] = VeryBigObject.VeryBigObject
+protocols[100] = ComplexObject.ComplexObject
+protocols[101] = NormalObject.NormalObject
+protocols[102] = ObjectA.ObjectA
+protocols[103] = ObjectB.ObjectB
+protocols[104] = SimpleObject.SimpleObject
+
+def getProtocol(protocolId):
+ return protocols[protocolId]
+
+def write(buffer, packet):
+ protocolId = packet.protocolId()
+ buffer.writeShort(protocolId)
+ protocol = protocols[protocolId]
+ protocol.write(buffer, packet)
+
+def read(buffer):
+ protocolId = buffer.readShort()
+ protocol = protocols[protocolId]
+ packet = protocol.read(buffer)
+ return packet
diff --git a/protocol/src/test/python/pyProtocol/SimpleObject.py b/protocol/src/test/python/pyProtocol/SimpleObject.py
new file mode 100644
index 00000000..d2403a9c
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/SimpleObject.py
@@ -0,0 +1,28 @@
+
+class SimpleObject:
+
+ c = 0 # int
+ g = False # bool
+
+ def protocolId(self):
+ return 104
+
+ @classmethod
+ def write(cls, buffer, packet):
+ if buffer.writePacketFlag(packet):
+ return
+ buffer.writeInt(packet.c)
+ buffer.writeBool(packet.g)
+ pass
+
+ @classmethod
+ def read(cls, buffer):
+ if not buffer.readBool():
+ return None
+ packet = SimpleObject()
+ result0 = buffer.readInt()
+ packet.c = result0
+ result1 = buffer.readBool()
+ packet.g = result1
+ return packet
+
diff --git a/protocol/src/test/python/pyProtocol/VeryBigObject.py b/protocol/src/test/python/pyProtocol/VeryBigObject.py
new file mode 100644
index 00000000..90e70bdd
--- /dev/null
+++ b/protocol/src/test/python/pyProtocol/VeryBigObject.py
@@ -0,0 +1,14804 @@
+
+class VeryBigObject:
+
+ a1 = 0 # byte
+ aa1 = 0 # byte
+ aaa1 = [] # byte[]
+ aaaa1 = [] # byte[]
+ b1 = 0 # short
+ bb1 = 0 # short
+ bbb1 = [] # short[]
+ bbbb1 = [] # short[]
+ c1 = 0 # int
+ cc1 = 0 # int
+ ccc1 = [] # int[]
+ cccc1 = [] # int[]
+ d1 = 0 # long
+ dd1 = 0 # long
+ ddd1 = [] # long[]
+ dddd1 = [] # long[]
+ e1 = 0.0 # float
+ ee1 = 0.0 # float
+ eee1 = [] # float[]
+ eeee1 = [] # float[]
+ f1 = 0.0 # double
+ ff1 = 0.0 # double
+ fff1 = [] # double[]
+ ffff1 = [] # double[]
+ g1 = False # bool
+ gg1 = False # bool
+ ggg1 = [] # bool[]
+ gggg1 = [] # bool[]
+ h1 = "" # char
+ hh1 = "" # char
+ hhh1 = [] # char[]
+ hhhh1 = [] # char[]
+ jj1 = "" # string
+ jjj1 = [] # string[]
+ kk1 = None # ObjectA
+ kkk1 = [] # ObjectA[]
+ l1 = [] # List
+ llll1 = [] # List
+ m1 = {} # Dictionary
+ mm1 = {} # Dictionary
+ s1 = {} # HashSet
+ ssss1 = {} # HashSet
+ a2 = 0 # byte
+ aa2 = 0 # byte
+ aaa2 = [] # byte[]
+ aaaa2 = [] # byte[]
+ b2 = 0 # short
+ bb2 = 0 # short
+ bbb2 = [] # short[]
+ bbbb2 = [] # short[]
+ c2 = 0 # int
+ cc2 = 0 # int
+ ccc2 = [] # int[]
+ cccc2 = [] # int[]
+ d2 = 0 # long
+ dd2 = 0 # long
+ ddd2 = [] # long[]
+ dddd2 = [] # long[]
+ e2 = 0.0 # float
+ ee2 = 0.0 # float
+ eee2 = [] # float[]
+ eeee2 = [] # float[]
+ f2 = 0.0 # double
+ ff2 = 0.0 # double
+ fff2 = [] # double[]
+ ffff2 = [] # double[]
+ g2 = False # bool
+ gg2 = False # bool
+ ggg2 = [] # bool[]
+ gggg2 = [] # bool[]
+ h2 = "" # char
+ hh2 = "" # char
+ hhh2 = [] # char[]
+ hhhh2 = [] # char[]
+ jj2 = "" # string
+ jjj2 = [] # string[]
+ kk2 = None # ObjectA
+ kkk2 = [] # ObjectA[]
+ l2 = [] # List
+ llll2 = [] # List
+ m2 = {} # Dictionary
+ mm2 = {} # Dictionary
+ s2 = {} # HashSet
+ ssss2 = {} # HashSet
+ a3 = 0 # byte
+ aa3 = 0 # byte
+ aaa3 = [] # byte[]
+ aaaa3 = [] # byte[]
+ b3 = 0 # short
+ bb3 = 0 # short
+ bbb3 = [] # short[]
+ bbbb3 = [] # short[]
+ c3 = 0 # int
+ cc3 = 0 # int
+ ccc3 = [] # int[]
+ cccc3 = [] # int[]
+ d3 = 0 # long
+ dd3 = 0 # long
+ ddd3 = [] # long[]
+ dddd3 = [] # long[]
+ e3 = 0.0 # float
+ ee3 = 0.0 # float
+ eee3 = [] # float[]
+ eeee3 = [] # float[]
+ f3 = 0.0 # double
+ ff3 = 0.0 # double
+ fff3 = [] # double[]
+ ffff3 = [] # double[]
+ g3 = False # bool
+ gg3 = False # bool
+ ggg3 = [] # bool[]
+ gggg3 = [] # bool[]
+ h3 = "" # char
+ hh3 = "" # char
+ hhh3 = [] # char[]
+ hhhh3 = [] # char[]
+ jj3 = "" # string
+ jjj3 = [] # string[]
+ kk3 = None # ObjectA
+ kkk3 = [] # ObjectA[]
+ l3 = [] # List
+ llll3 = [] # List
+ m3 = {} # Dictionary
+ mm3 = {} # Dictionary
+ s3 = {} # HashSet
+ ssss3 = {} # HashSet
+ a4 = 0 # byte
+ aa4 = 0 # byte
+ aaa4 = [] # byte[]
+ aaaa4 = [] # byte[]
+ b4 = 0 # short
+ bb4 = 0 # short
+ bbb4 = [] # short[]
+ bbbb4 = [] # short[]
+ c4 = 0 # int
+ cc4 = 0 # int
+ ccc4 = [] # int[]
+ cccc4 = [] # int[]
+ d4 = 0 # long
+ dd4 = 0 # long
+ ddd4 = [] # long[]
+ dddd4 = [] # long[]
+ e4 = 0.0 # float
+ ee4 = 0.0 # float
+ eee4 = [] # float[]
+ eeee4 = [] # float[]
+ f4 = 0.0 # double
+ ff4 = 0.0 # double
+ fff4 = [] # double[]
+ ffff4 = [] # double[]
+ g4 = False # bool
+ gg4 = False # bool
+ ggg4 = [] # bool[]
+ gggg4 = [] # bool[]
+ h4 = "" # char
+ hh4 = "" # char
+ hhh4 = [] # char[]
+ hhhh4 = [] # char[]
+ jj4 = "" # string
+ jjj4 = [] # string[]
+ kk4 = None # ObjectA
+ kkk4 = [] # ObjectA[]
+ l4 = [] # List
+ llll4 = [] # List
+ m4 = {} # Dictionary
+ mm4 = {} # Dictionary
+ s4 = {} # HashSet
+ ssss4 = {} # HashSet
+ a5 = 0 # byte
+ aa5 = 0 # byte
+ aaa5 = [] # byte[]
+ aaaa5 = [] # byte[]
+ b5 = 0 # short
+ bb5 = 0 # short
+ bbb5 = [] # short[]
+ bbbb5 = [] # short[]
+ c5 = 0 # int
+ cc5 = 0 # int
+ ccc5 = [] # int[]
+ cccc5 = [] # int[]
+ d5 = 0 # long
+ dd5 = 0 # long
+ ddd5 = [] # long[]
+ dddd5 = [] # long[]
+ e5 = 0.0 # float
+ ee5 = 0.0 # float
+ eee5 = [] # float[]
+ eeee5 = [] # float[]
+ f5 = 0.0 # double
+ ff5 = 0.0 # double
+ fff5 = [] # double[]
+ ffff5 = [] # double[]
+ g5 = False # bool
+ gg5 = False # bool
+ ggg5 = [] # bool[]
+ gggg5 = [] # bool[]
+ h5 = "" # char
+ hh5 = "" # char
+ hhh5 = [] # char[]
+ hhhh5 = [] # char[]
+ jj5 = "" # string
+ jjj5 = [] # string[]
+ kk5 = None # ObjectA
+ kkk5 = [] # ObjectA[]
+ l5 = [] # List
+ llll5 = [] # List
+ m5 = {} # Dictionary
+ mm5 = {} # Dictionary
+ s5 = {} # HashSet
+ ssss5 = {} # HashSet
+ a6 = 0 # byte
+ aa6 = 0 # byte
+ aaa6 = [] # byte[]
+ aaaa6 = [] # byte[]
+ b6 = 0 # short
+ bb6 = 0 # short
+ bbb6 = [] # short[]
+ bbbb6 = [] # short[]
+ c6 = 0 # int
+ cc6 = 0 # int
+ ccc6 = [] # int[]
+ cccc6 = [] # int[]
+ d6 = 0 # long
+ dd6 = 0 # long
+ ddd6 = [] # long[]
+ dddd6 = [] # long[]
+ e6 = 0.0 # float
+ ee6 = 0.0 # float
+ eee6 = [] # float[]
+ eeee6 = [] # float[]
+ f6 = 0.0 # double
+ ff6 = 0.0 # double
+ fff6 = [] # double[]
+ ffff6 = [] # double[]
+ g6 = False # bool
+ gg6 = False # bool
+ ggg6 = [] # bool[]
+ gggg6 = [] # bool[]
+ h6 = "" # char
+ hh6 = "" # char
+ hhh6 = [] # char[]
+ hhhh6 = [] # char[]
+ jj6 = "" # string
+ jjj6 = [] # string[]
+ kk6 = None # ObjectA
+ kkk6 = [] # ObjectA[]
+ l6 = [] # List
+ llll6 = [] # List
+ m6 = {} # Dictionary
+ mm6 = {} # Dictionary
+ s6 = {} # HashSet
+ ssss6 = {} # HashSet
+ a7 = 0 # byte
+ aa7 = 0 # byte
+ aaa7 = [] # byte[]
+ aaaa7 = [] # byte[]
+ b7 = 0 # short
+ bb7 = 0 # short
+ bbb7 = [] # short[]
+ bbbb7 = [] # short[]
+ c7 = 0 # int
+ cc7 = 0 # int
+ ccc7 = [] # int[]
+ cccc7 = [] # int[]
+ d7 = 0 # long
+ dd7 = 0 # long
+ ddd7 = [] # long[]
+ dddd7 = [] # long[]
+ e7 = 0.0 # float
+ ee7 = 0.0 # float
+ eee7 = [] # float[]
+ eeee7 = [] # float[]
+ f7 = 0.0 # double
+ ff7 = 0.0 # double
+ fff7 = [] # double[]
+ ffff7 = [] # double[]
+ g7 = False # bool
+ gg7 = False # bool
+ ggg7 = [] # bool[]
+ gggg7 = [] # bool[]
+ h7 = "" # char
+ hh7 = "" # char
+ hhh7 = [] # char[]
+ hhhh7 = [] # char[]
+ jj7 = "" # string
+ jjj7 = [] # string[]
+ kk7 = None # ObjectA
+ kkk7 = [] # ObjectA[]
+ l7 = [] # List
+ llll7 = [] # List
+ m7 = {} # Dictionary
+ mm7 = {} # Dictionary
+ s7 = {} # HashSet
+ ssss7 = {} # HashSet
+ a8 = 0 # byte
+ aa8 = 0 # byte
+ aaa8 = [] # byte[]
+ aaaa8 = [] # byte[]
+ b8 = 0 # short
+ bb8 = 0 # short
+ bbb8 = [] # short[]
+ bbbb8 = [] # short[]
+ c8 = 0 # int
+ cc8 = 0 # int
+ ccc8 = [] # int[]
+ cccc8 = [] # int[]
+ d8 = 0 # long
+ dd8 = 0 # long
+ ddd8 = [] # long[]
+ dddd8 = [] # long[]
+ e8 = 0.0 # float
+ ee8 = 0.0 # float
+ eee8 = [] # float[]
+ eeee8 = [] # float[]
+ f8 = 0.0 # double
+ ff8 = 0.0 # double
+ fff8 = [] # double[]
+ ffff8 = [] # double[]
+ g8 = False # bool
+ gg8 = False # bool
+ ggg8 = [] # bool[]
+ gggg8 = [] # bool[]
+ h8 = "" # char
+ hh8 = "" # char
+ hhh8 = [] # char[]
+ hhhh8 = [] # char[]
+ jj8 = "" # string
+ jjj8 = [] # string[]
+ kk8 = None # ObjectA
+ kkk8 = [] # ObjectA[]
+ l8 = [] # List
+ llll8 = [] # List
+ m8 = {} # Dictionary
+ mm8 = {} # Dictionary
+ s8 = {} # HashSet
+ ssss8 = {} # HashSet
+ a9 = 0 # byte
+ aa9 = 0 # byte
+ aaa9 = [] # byte[]
+ aaaa9 = [] # byte[]
+ b9 = 0 # short
+ bb9 = 0 # short
+ bbb9 = [] # short[]
+ bbbb9 = [] # short[]
+ c9 = 0 # int
+ cc9 = 0 # int
+ ccc9 = [] # int[]
+ cccc9 = [] # int[]
+ d9 = 0 # long
+ dd9 = 0 # long
+ ddd9 = [] # long[]
+ dddd9 = [] # long[]
+ e9 = 0.0 # float
+ ee9 = 0.0 # float
+ eee9 = [] # float[]
+ eeee9 = [] # float[]
+ f9 = 0.0 # double
+ ff9 = 0.0 # double
+ fff9 = [] # double[]
+ ffff9 = [] # double[]
+ g9 = False # bool
+ gg9 = False # bool
+ ggg9 = [] # bool[]
+ gggg9 = [] # bool[]
+ h9 = "" # char
+ hh9 = "" # char
+ hhh9 = [] # char[]
+ hhhh9 = [] # char[]
+ jj9 = "" # string
+ jjj9 = [] # string[]
+ kk9 = None # ObjectA
+ kkk9 = [] # ObjectA[]
+ l9 = [] # List
+ llll9 = [] # List
+ m9 = {} # Dictionary
+ mm9 = {} # Dictionary
+ s9 = {} # HashSet
+ ssss9 = {} # HashSet
+ a10 = 0 # byte
+ aa10 = 0 # byte
+ aaa10 = [] # byte[]
+ aaaa10 = [] # byte[]
+ b10 = 0 # short
+ bb10 = 0 # short
+ bbb10 = [] # short[]
+ bbbb10 = [] # short[]
+ c10 = 0 # int
+ cc10 = 0 # int
+ ccc10 = [] # int[]
+ cccc10 = [] # int[]
+ d10 = 0 # long
+ dd10 = 0 # long
+ ddd10 = [] # long[]
+ dddd10 = [] # long[]
+ e10 = 0.0 # float
+ ee10 = 0.0 # float
+ eee10 = [] # float[]
+ eeee10 = [] # float[]
+ f10 = 0.0 # double
+ ff10 = 0.0 # double
+ fff10 = [] # double[]
+ ffff10 = [] # double[]
+ g10 = False # bool
+ gg10 = False # bool
+ ggg10 = [] # bool[]
+ gggg10 = [] # bool[]
+ h10 = "" # char
+ hh10 = "" # char
+ hhh10 = [] # char[]
+ hhhh10 = [] # char[]
+ jj10 = "" # string
+ jjj10 = [] # string[]
+ kk10 = None # ObjectA
+ kkk10 = [] # ObjectA[]
+ l10 = [] # List
+ llll10 = [] # List
+ m10 = {} # Dictionary
+ mm10 = {} # Dictionary
+ s10 = {} # HashSet
+ ssss10 = {} # HashSet
+ a11 = 0 # byte
+ aa11 = 0 # byte
+ aaa11 = [] # byte[]
+ aaaa11 = [] # byte[]
+ b11 = 0 # short
+ bb11 = 0 # short
+ bbb11 = [] # short[]
+ bbbb11 = [] # short[]
+ c11 = 0 # int
+ cc11 = 0 # int
+ ccc11 = [] # int[]
+ cccc11 = [] # int[]
+ d11 = 0 # long
+ dd11 = 0 # long
+ ddd11 = [] # long[]
+ dddd11 = [] # long[]
+ e11 = 0.0 # float
+ ee11 = 0.0 # float
+ eee11 = [] # float[]
+ eeee11 = [] # float[]
+ f11 = 0.0 # double
+ ff11 = 0.0 # double
+ fff11 = [] # double[]
+ ffff11 = [] # double[]
+ g11 = False # bool
+ gg11 = False # bool
+ ggg11 = [] # bool[]
+ gggg11 = [] # bool[]
+ h11 = "" # char
+ hh11 = "" # char
+ hhh11 = [] # char[]
+ hhhh11 = [] # char[]
+ jj11 = "" # string
+ jjj11 = [] # string[]
+ kk11 = None # ObjectA
+ kkk11 = [] # ObjectA[]
+ l11 = [] # List
+ llll11 = [] # List
+ m11 = {} # Dictionary
+ mm11 = {} # Dictionary
+ s11 = {} # HashSet
+ ssss11 = {} # HashSet
+ a12 = 0 # byte
+ aa12 = 0 # byte
+ aaa12 = [] # byte[]
+ aaaa12 = [] # byte[]
+ b12 = 0 # short
+ bb12 = 0 # short
+ bbb12 = [] # short[]
+ bbbb12 = [] # short[]
+ c12 = 0 # int
+ cc12 = 0 # int
+ ccc12 = [] # int[]
+ cccc12 = [] # int[]
+ d12 = 0 # long
+ dd12 = 0 # long
+ ddd12 = [] # long[]
+ dddd12 = [] # long[]
+ e12 = 0.0 # float
+ ee12 = 0.0 # float
+ eee12 = [] # float[]
+ eeee12 = [] # float[]
+ f12 = 0.0 # double
+ ff12 = 0.0 # double
+ fff12 = [] # double[]
+ ffff12 = [] # double[]
+ g12 = False # bool
+ gg12 = False # bool
+ ggg12 = [] # bool[]
+ gggg12 = [] # bool[]
+ h12 = "" # char
+ hh12 = "" # char
+ hhh12 = [] # char[]
+ hhhh12 = [] # char[]
+ jj12 = "" # string
+ jjj12 = [] # string[]
+ kk12 = None # ObjectA
+ kkk12 = [] # ObjectA[]
+ l12 = [] # List
+ llll12 = [] # List
+ m12 = {} # Dictionary
+ mm12 = {} # Dictionary
+ s12 = {} # HashSet
+ ssss12 = {} # HashSet
+ a13 = 0 # byte
+ aa13 = 0 # byte
+ aaa13 = [] # byte[]
+ aaaa13 = [] # byte[]
+ b13 = 0 # short
+ bb13 = 0 # short
+ bbb13 = [] # short[]
+ bbbb13 = [] # short[]
+ c13 = 0 # int
+ cc13 = 0 # int
+ ccc13 = [] # int[]
+ cccc13 = [] # int[]
+ d13 = 0 # long
+ dd13 = 0 # long
+ ddd13 = [] # long[]
+ dddd13 = [] # long[]
+ e13 = 0.0 # float
+ ee13 = 0.0 # float
+ eee13 = [] # float[]
+ eeee13 = [] # float[]
+ f13 = 0.0 # double
+ ff13 = 0.0 # double
+ fff13 = [] # double[]
+ ffff13 = [] # double[]
+ g13 = False # bool
+ gg13 = False # bool
+ ggg13 = [] # bool[]
+ gggg13 = [] # bool[]
+ h13 = "" # char
+ hh13 = "" # char
+ hhh13 = [] # char[]
+ hhhh13 = [] # char[]
+ jj13 = "" # string
+ jjj13 = [] # string[]
+ kk13 = None # ObjectA
+ kkk13 = [] # ObjectA[]
+ l13 = [] # List
+ llll13 = [] # List
+ m13 = {} # Dictionary
+ mm13 = {} # Dictionary
+ s13 = {} # HashSet
+ ssss13 = {} # HashSet
+ a14 = 0 # byte
+ aa14 = 0 # byte
+ aaa14 = [] # byte[]
+ aaaa14 = [] # byte[]
+ b14 = 0 # short
+ bb14 = 0 # short
+ bbb14 = [] # short[]
+ bbbb14 = [] # short[]
+ c14 = 0 # int
+ cc14 = 0 # int
+ ccc14 = [] # int[]
+ cccc14 = [] # int[]
+ d14 = 0 # long
+ dd14 = 0 # long
+ ddd14 = [] # long[]
+ dddd14 = [] # long[]
+ e14 = 0.0 # float
+ ee14 = 0.0 # float
+ eee14 = [] # float[]
+ eeee14 = [] # float[]
+ f14 = 0.0 # double
+ ff14 = 0.0 # double
+ fff14 = [] # double[]
+ ffff14 = [] # double[]
+ g14 = False # bool
+ gg14 = False # bool
+ ggg14 = [] # bool[]
+ gggg14 = [] # bool[]
+ h14 = "" # char
+ hh14 = "" # char
+ hhh14 = [] # char[]
+ hhhh14 = [] # char[]
+ jj14 = "" # string
+ jjj14 = [] # string[]
+ kk14 = None # ObjectA
+ kkk14 = [] # ObjectA[]
+ l14 = [] # List
+ llll14 = [] # List
+ m14 = {} # Dictionary
+ mm14 = {} # Dictionary
+ s14 = {} # HashSet
+ ssss14 = {} # HashSet
+ a15 = 0 # byte
+ aa15 = 0 # byte
+ aaa15 = [] # byte[]
+ aaaa15 = [] # byte[]
+ b15 = 0 # short
+ bb15 = 0 # short
+ bbb15 = [] # short[]
+ bbbb15 = [] # short[]
+ c15 = 0 # int
+ cc15 = 0 # int
+ ccc15 = [] # int[]
+ cccc15 = [] # int[]
+ d15 = 0 # long
+ dd15 = 0 # long
+ ddd15 = [] # long[]
+ dddd15 = [] # long[]
+ e15 = 0.0 # float
+ ee15 = 0.0 # float
+ eee15 = [] # float[]
+ eeee15 = [] # float[]
+ f15 = 0.0 # double
+ ff15 = 0.0 # double
+ fff15 = [] # double[]
+ ffff15 = [] # double[]
+ g15 = False # bool
+ gg15 = False # bool
+ ggg15 = [] # bool[]
+ gggg15 = [] # bool[]
+ h15 = "" # char
+ hh15 = "" # char
+ hhh15 = [] # char[]
+ hhhh15 = [] # char[]
+ jj15 = "" # string
+ jjj15 = [] # string[]
+ kk15 = None # ObjectA
+ kkk15 = [] # ObjectA[]
+ l15 = [] # List
+ llll15 = [] # List
+ m15 = {} # Dictionary
+ mm15 = {} # Dictionary
+ s15 = {} # HashSet
+ ssss15 = {} # HashSet
+ a16 = 0 # byte
+ aa16 = 0 # byte
+ aaa16 = [] # byte[]
+ aaaa16 = [] # byte[]
+ b16 = 0 # short
+ bb16 = 0 # short
+ bbb16 = [] # short[]
+ bbbb16 = [] # short[]
+ c16 = 0 # int
+ cc16 = 0 # int
+ ccc16 = [] # int[]
+ cccc16 = [] # int[]
+ d16 = 0 # long
+ dd16 = 0 # long
+ ddd16 = [] # long[]
+ dddd16 = [] # long[]
+ e16 = 0.0 # float
+ ee16 = 0.0 # float
+ eee16 = [] # float[]
+ eeee16 = [] # float[]
+ f16 = 0.0 # double
+ ff16 = 0.0 # double
+ fff16 = [] # double[]
+ ffff16 = [] # double[]
+ g16 = False # bool
+ gg16 = False # bool
+ ggg16 = [] # bool[]
+ gggg16 = [] # bool[]
+ h16 = "" # char
+ hh16 = "" # char
+ hhh16 = [] # char[]
+ hhhh16 = [] # char[]
+ jj16 = "" # string
+ jjj16 = [] # string[]
+ kk16 = None # ObjectA
+ kkk16 = [] # ObjectA[]
+ l16 = [] # List
+ llll16 = [] # List
+ m16 = {} # Dictionary
+ mm16 = {} # Dictionary
+ s16 = {} # HashSet
+ ssss16 = {} # HashSet
+ a17 = 0 # byte
+ aa17 = 0 # byte
+ aaa17 = [] # byte[]
+ aaaa17 = [] # byte[]
+ b17 = 0 # short
+ bb17 = 0 # short
+ bbb17 = [] # short[]
+ bbbb17 = [] # short[]
+ c17 = 0 # int
+ cc17 = 0 # int
+ ccc17 = [] # int[]
+ cccc17 = [] # int[]
+ d17 = 0 # long
+ dd17 = 0 # long
+ ddd17 = [] # long[]
+ dddd17 = [] # long[]
+ e17 = 0.0 # float
+ ee17 = 0.0 # float
+ eee17 = [] # float[]
+ eeee17 = [] # float[]
+ f17 = 0.0 # double
+ ff17 = 0.0 # double
+ fff17 = [] # double[]
+ ffff17 = [] # double[]
+ g17 = False # bool
+ gg17 = False # bool
+ ggg17 = [] # bool[]
+ gggg17 = [] # bool[]
+ h17 = "" # char
+ hh17 = "" # char
+ hhh17 = [] # char[]
+ hhhh17 = [] # char[]
+ jj17 = "" # string
+ jjj17 = [] # string[]
+ kk17 = None # ObjectA
+ kkk17 = [] # ObjectA[]
+ l17 = [] # List
+ llll17 = [] # List
+ m17 = {} # Dictionary
+ mm17 = {} # Dictionary
+ s17 = {} # HashSet
+ ssss17 = {} # HashSet
+ a18 = 0 # byte
+ aa18 = 0 # byte
+ aaa18 = [] # byte[]
+ aaaa18 = [] # byte[]
+ b18 = 0 # short
+ bb18 = 0 # short
+ bbb18 = [] # short[]
+ bbbb18 = [] # short[]
+ c18 = 0 # int
+ cc18 = 0 # int
+ ccc18 = [] # int[]
+ cccc18 = [] # int[]
+ d18 = 0 # long
+ dd18 = 0 # long
+ ddd18 = [] # long[]
+ dddd18 = [] # long[]
+ e18 = 0.0 # float
+ ee18 = 0.0 # float
+ eee18 = [] # float[]
+ eeee18 = [] # float[]
+ f18 = 0.0 # double
+ ff18 = 0.0 # double
+ fff18 = [] # double[]
+ ffff18 = [] # double[]
+ g18 = False # bool
+ gg18 = False # bool
+ ggg18 = [] # bool[]
+ gggg18 = [] # bool[]
+ h18 = "" # char
+ hh18 = "" # char
+ hhh18 = [] # char[]
+ hhhh18 = [] # char[]
+ jj18 = "" # string
+ jjj18 = [] # string[]
+ kk18 = None # ObjectA
+ kkk18 = [] # ObjectA[]
+ l18 = [] # List
+ llll18 = [] # List
+ m18 = {} # Dictionary
+ mm18 = {} # Dictionary
+ s18 = {} # HashSet
+ ssss18 = {} # HashSet
+ a19 = 0 # byte
+ aa19 = 0 # byte
+ aaa19 = [] # byte[]
+ aaaa19 = [] # byte[]
+ b19 = 0 # short
+ bb19 = 0 # short
+ bbb19 = [] # short[]
+ bbbb19 = [] # short[]
+ c19 = 0 # int
+ cc19 = 0 # int
+ ccc19 = [] # int[]
+ cccc19 = [] # int[]
+ d19 = 0 # long
+ dd19 = 0 # long
+ ddd19 = [] # long[]
+ dddd19 = [] # long[]
+ e19 = 0.0 # float
+ ee19 = 0.0 # float
+ eee19 = [] # float[]
+ eeee19 = [] # float[]
+ f19 = 0.0 # double
+ ff19 = 0.0 # double
+ fff19 = [] # double[]
+ ffff19 = [] # double[]
+ g19 = False # bool
+ gg19 = False # bool
+ ggg19 = [] # bool[]
+ gggg19 = [] # bool[]
+ h19 = "" # char
+ hh19 = "" # char
+ hhh19 = [] # char[]
+ hhhh19 = [] # char[]
+ jj19 = "" # string
+ jjj19 = [] # string[]
+ kk19 = None # ObjectA
+ kkk19 = [] # ObjectA[]
+ l19 = [] # List
+ llll19 = [] # List
+ m19 = {} # Dictionary
+ mm19 = {} # Dictionary
+ s19 = {} # HashSet
+ ssss19 = {} # HashSet
+ a20 = 0 # byte
+ aa20 = 0 # byte
+ aaa20 = [] # byte[]
+ aaaa20 = [] # byte[]
+ b20 = 0 # short
+ bb20 = 0 # short
+ bbb20 = [] # short[]
+ bbbb20 = [] # short[]
+ c20 = 0 # int
+ cc20 = 0 # int
+ ccc20 = [] # int[]
+ cccc20 = [] # int[]
+ d20 = 0 # long
+ dd20 = 0 # long
+ ddd20 = [] # long[]
+ dddd20 = [] # long[]
+ e20 = 0.0 # float
+ ee20 = 0.0 # float
+ eee20 = [] # float[]
+ eeee20 = [] # float[]
+ f20 = 0.0 # double
+ ff20 = 0.0 # double
+ fff20 = [] # double[]
+ ffff20 = [] # double[]
+ g20 = False # bool
+ gg20 = False # bool
+ ggg20 = [] # bool[]
+ gggg20 = [] # bool[]
+ h20 = "" # char
+ hh20 = "" # char
+ hhh20 = [] # char[]
+ hhhh20 = [] # char[]
+ jj20 = "" # string
+ jjj20 = [] # string[]
+ kk20 = None # ObjectA
+ kkk20 = [] # ObjectA[]
+ l20 = [] # List
+ llll20 = [] # List
+ m20 = {} # Dictionary
+ mm20 = {} # Dictionary
+ s20 = {} # HashSet
+ ssss20 = {} # HashSet
+ a21 = 0 # byte
+ aa21 = 0 # byte
+ aaa21 = [] # byte[]
+ aaaa21 = [] # byte[]
+ b21 = 0 # short
+ bb21 = 0 # short
+ bbb21 = [] # short[]
+ bbbb21 = [] # short[]
+ c21 = 0 # int
+ cc21 = 0 # int
+ ccc21 = [] # int[]
+ cccc21 = [] # int[]
+ d21 = 0 # long
+ dd21 = 0 # long
+ ddd21 = [] # long[]
+ dddd21 = [] # long[]
+ e21 = 0.0 # float
+ ee21 = 0.0 # float
+ eee21 = [] # float[]
+ eeee21 = [] # float[]
+ f21 = 0.0 # double
+ ff21 = 0.0 # double
+ fff21 = [] # double[]
+ ffff21 = [] # double[]
+ g21 = False # bool
+ gg21 = False # bool
+ ggg21 = [] # bool[]
+ gggg21 = [] # bool[]
+ h21 = "" # char
+ hh21 = "" # char
+ hhh21 = [] # char[]
+ hhhh21 = [] # char[]
+ jj21 = "" # string
+ jjj21 = [] # string[]
+ kk21 = None # ObjectA
+ kkk21 = [] # ObjectA[]
+ l21 = [] # List
+ llll21 = [] # List
+ m21 = {} # Dictionary
+ mm21 = {} # Dictionary
+ s21 = {} # HashSet
+ ssss21 = {} # HashSet
+ a22 = 0 # byte
+ aa22 = 0 # byte
+ aaa22 = [] # byte[]
+ aaaa22 = [] # byte[]
+ b22 = 0 # short
+ bb22 = 0 # short
+ bbb22 = [] # short[]
+ bbbb22 = [] # short[]
+ c22 = 0 # int
+ cc22 = 0 # int
+ ccc22 = [] # int[]
+ cccc22 = [] # int[]
+ d22 = 0 # long
+ dd22 = 0 # long
+ ddd22 = [] # long[]
+ dddd22 = [] # long[]
+ e22 = 0.0 # float
+ ee22 = 0.0 # float
+ eee22 = [] # float[]
+ eeee22 = [] # float[]
+ f22 = 0.0 # double
+ ff22 = 0.0 # double
+ fff22 = [] # double[]
+ ffff22 = [] # double[]
+ g22 = False # bool
+ gg22 = False # bool
+ ggg22 = [] # bool[]
+ gggg22 = [] # bool[]
+ h22 = "" # char
+ hh22 = "" # char
+ hhh22 = [] # char[]
+ hhhh22 = [] # char[]
+ jj22 = "" # string
+ jjj22 = [] # string[]
+ kk22 = None # ObjectA
+ kkk22 = [] # ObjectA[]
+ l22 = [] # List
+ llll22 = [] # List
+ m22 = {} # Dictionary
+ mm22 = {} # Dictionary
+ s22 = {} # HashSet
+ ssss22 = {} # HashSet
+ a23 = 0 # byte
+ aa23 = 0 # byte
+ aaa23 = [] # byte[]
+ aaaa23 = [] # byte[]
+ b23 = 0 # short
+ bb23 = 0 # short
+ bbb23 = [] # short[]
+ bbbb23 = [] # short[]
+ c23 = 0 # int
+ cc23 = 0 # int
+ ccc23 = [] # int[]
+ cccc23 = [] # int[]
+ d23 = 0 # long
+ dd23 = 0 # long
+ ddd23 = [] # long[]
+ dddd23 = [] # long[]
+ e23 = 0.0 # float
+ ee23 = 0.0 # float
+ eee23 = [] # float[]
+ eeee23 = [] # float[]
+ f23 = 0.0 # double
+ ff23 = 0.0 # double
+ fff23 = [] # double[]
+ ffff23 = [] # double[]
+ g23 = False # bool
+ gg23 = False # bool
+ ggg23 = [] # bool[]
+ gggg23 = [] # bool[]
+ h23 = "" # char
+ hh23 = "" # char
+ hhh23 = [] # char[]
+ hhhh23 = [] # char[]
+ jj23 = "" # string
+ jjj23 = [] # string[]
+ kk23 = None # ObjectA
+ kkk23 = [] # ObjectA[]
+ l23 = [] # List
+ llll23 = [] # List
+ m23 = {} # Dictionary
+ mm23 = {} # Dictionary
+ s23 = {} # HashSet
+ ssss23 = {} # HashSet
+ a24 = 0 # byte
+ aa24 = 0 # byte
+ aaa24 = [] # byte[]
+ aaaa24 = [] # byte[]
+ b24 = 0 # short
+ bb24 = 0 # short
+ bbb24 = [] # short[]
+ bbbb24 = [] # short[]
+ c24 = 0 # int
+ cc24 = 0 # int
+ ccc24 = [] # int[]
+ cccc24 = [] # int[]
+ d24 = 0 # long
+ dd24 = 0 # long
+ ddd24 = [] # long[]
+ dddd24 = [] # long[]
+ e24 = 0.0 # float
+ ee24 = 0.0 # float
+ eee24 = [] # float[]
+ eeee24 = [] # float[]
+ f24 = 0.0 # double
+ ff24 = 0.0 # double
+ fff24 = [] # double[]
+ ffff24 = [] # double[]
+ g24 = False # bool
+ gg24 = False # bool
+ ggg24 = [] # bool[]
+ gggg24 = [] # bool[]
+ h24 = "" # char
+ hh24 = "" # char
+ hhh24 = [] # char[]
+ hhhh24 = [] # char[]
+ jj24 = "" # string
+ jjj24 = [] # string[]
+ kk24 = None # ObjectA
+ kkk24 = [] # ObjectA[]
+ l24 = [] # List
+ llll24 = [] # List
+ m24 = {} # Dictionary
+ mm24 = {} # Dictionary
+ s24 = {} # HashSet
+ ssss24 = {} # HashSet
+ a25 = 0 # byte
+ aa25 = 0 # byte
+ aaa25 = [] # byte[]
+ aaaa25 = [] # byte[]
+ b25 = 0 # short
+ bb25 = 0 # short
+ bbb25 = [] # short[]
+ bbbb25 = [] # short[]
+ c25 = 0 # int
+ cc25 = 0 # int
+ ccc25 = [] # int[]
+ cccc25 = [] # int[]
+ d25 = 0 # long
+ dd25 = 0 # long
+ ddd25 = [] # long[]
+ dddd25 = [] # long[]
+ e25 = 0.0 # float
+ ee25 = 0.0 # float
+ eee25 = [] # float[]
+ eeee25 = [] # float[]
+ f25 = 0.0 # double
+ ff25 = 0.0 # double
+ fff25 = [] # double[]
+ ffff25 = [] # double[]
+ g25 = False # bool
+ gg25 = False # bool
+ ggg25 = [] # bool[]
+ gggg25 = [] # bool[]
+ h25 = "" # char
+ hh25 = "" # char
+ hhh25 = [] # char[]
+ hhhh25 = [] # char[]
+ jj25 = "" # string
+ jjj25 = [] # string[]
+ kk25 = None # ObjectA
+ kkk25 = [] # ObjectA[]
+ l25 = [] # List
+ llll25 = [] # List
+ m25 = {} # Dictionary
+ mm25 = {} # Dictionary
+ s25 = {} # HashSet
+ ssss25 = {} # HashSet
+ a26 = 0 # byte
+ aa26 = 0 # byte
+ aaa26 = [] # byte[]
+ aaaa26 = [] # byte[]
+ b26 = 0 # short
+ bb26 = 0 # short
+ bbb26 = [] # short[]
+ bbbb26 = [] # short[]
+ c26 = 0 # int
+ cc26 = 0 # int
+ ccc26 = [] # int[]
+ cccc26 = [] # int[]
+ d26 = 0 # long
+ dd26 = 0 # long
+ ddd26 = [] # long[]
+ dddd26 = [] # long[]
+ e26 = 0.0 # float
+ ee26 = 0.0 # float
+ eee26 = [] # float[]
+ eeee26 = [] # float[]
+ f26 = 0.0 # double
+ ff26 = 0.0 # double
+ fff26 = [] # double[]
+ ffff26 = [] # double[]
+ g26 = False # bool
+ gg26 = False # bool
+ ggg26 = [] # bool[]
+ gggg26 = [] # bool[]
+ h26 = "" # char
+ hh26 = "" # char
+ hhh26 = [] # char[]
+ hhhh26 = [] # char[]
+ jj26 = "" # string
+ jjj26 = [] # string[]
+ kk26 = None # ObjectA
+ kkk26 = [] # ObjectA[]
+ l26 = [] # List
+ llll26 = [] # List
+ m26 = {} # Dictionary
+ mm26 = {} # Dictionary
+ s26 = {} # HashSet
+ ssss26 = {} # HashSet
+ a27 = 0 # byte
+ aa27 = 0 # byte
+ aaa27 = [] # byte[]
+ aaaa27 = [] # byte[]
+ b27 = 0 # short
+ bb27 = 0 # short
+ bbb27 = [] # short[]
+ bbbb27 = [] # short[]
+ c27 = 0 # int
+ cc27 = 0 # int
+ ccc27 = [] # int[]
+ cccc27 = [] # int[]
+ d27 = 0 # long
+ dd27 = 0 # long
+ ddd27 = [] # long[]
+ dddd27 = [] # long[]
+ e27 = 0.0 # float
+ ee27 = 0.0 # float
+ eee27 = [] # float[]
+ eeee27 = [] # float[]
+ f27 = 0.0 # double
+ ff27 = 0.0 # double
+ fff27 = [] # double[]
+ ffff27 = [] # double[]
+ g27 = False # bool
+ gg27 = False # bool
+ ggg27 = [] # bool[]
+ gggg27 = [] # bool[]
+ h27 = "" # char
+ hh27 = "" # char
+ hhh27 = [] # char[]
+ hhhh27 = [] # char[]
+ jj27 = "" # string
+ jjj27 = [] # string[]
+ kk27 = None # ObjectA
+ kkk27 = [] # ObjectA[]
+ l27 = [] # List
+ llll27 = [] # List
+ m27 = {} # Dictionary
+ mm27 = {} # Dictionary
+ s27 = {} # HashSet
+ ssss27 = {} # HashSet
+ a28 = 0 # byte
+ aa28 = 0 # byte
+ aaa28 = [] # byte[]
+ aaaa28 = [] # byte[]
+ b28 = 0 # short
+ bb28 = 0 # short
+ bbb28 = [] # short[]
+ bbbb28 = [] # short[]
+ c28 = 0 # int
+ cc28 = 0 # int
+ ccc28 = [] # int[]
+ cccc28 = [] # int[]
+ d28 = 0 # long
+ dd28 = 0 # long
+ ddd28 = [] # long[]
+ dddd28 = [] # long[]
+ e28 = 0.0 # float
+ ee28 = 0.0 # float
+ eee28 = [] # float[]
+ eeee28 = [] # float[]
+ f28 = 0.0 # double
+ ff28 = 0.0 # double
+ fff28 = [] # double[]
+ ffff28 = [] # double[]
+ g28 = False # bool
+ gg28 = False # bool
+ ggg28 = [] # bool[]
+ gggg28 = [] # bool[]
+ h28 = "" # char
+ hh28 = "" # char
+ hhh28 = [] # char[]
+ hhhh28 = [] # char[]
+ jj28 = "" # string
+ jjj28 = [] # string[]
+ kk28 = None # ObjectA
+ kkk28 = [] # ObjectA[]
+ l28 = [] # List
+ llll28 = [] # List
+ m28 = {} # Dictionary
+ mm28 = {} # Dictionary
+ s28 = {} # HashSet
+ ssss28 = {} # HashSet
+ a29 = 0 # byte
+ aa29 = 0 # byte
+ aaa29 = [] # byte[]
+ aaaa29 = [] # byte[]
+ b29 = 0 # short
+ bb29 = 0 # short
+ bbb29 = [] # short[]
+ bbbb29 = [] # short[]
+ c29 = 0 # int
+ cc29 = 0 # int
+ ccc29 = [] # int[]
+ cccc29 = [] # int[]
+ d29 = 0 # long
+ dd29 = 0 # long
+ ddd29 = [] # long[]
+ dddd29 = [] # long[]
+ e29 = 0.0 # float
+ ee29 = 0.0 # float
+ eee29 = [] # float[]
+ eeee29 = [] # float[]
+ f29 = 0.0 # double
+ ff29 = 0.0 # double
+ fff29 = [] # double[]
+ ffff29 = [] # double[]
+ g29 = False # bool
+ gg29 = False # bool
+ ggg29 = [] # bool[]
+ gggg29 = [] # bool[]
+ h29 = "" # char
+ hh29 = "" # char
+ hhh29 = [] # char[]
+ hhhh29 = [] # char[]
+ jj29 = "" # string
+ jjj29 = [] # string[]
+ kk29 = None # ObjectA
+ kkk29 = [] # ObjectA[]
+ l29 = [] # List
+ llll29 = [] # List
+ m29 = {} # Dictionary
+ mm29 = {} # Dictionary
+ s29 = {} # HashSet
+ ssss29 = {} # HashSet
+ a30 = 0 # byte
+ aa30 = 0 # byte
+ aaa30 = [] # byte[]
+ aaaa30 = [] # byte[]
+ b30 = 0 # short
+ bb30 = 0 # short
+ bbb30 = [] # short[]
+ bbbb30 = [] # short[]
+ c30 = 0 # int
+ cc30 = 0 # int
+ ccc30 = [] # int[]
+ cccc30 = [] # int[]
+ d30 = 0 # long
+ dd30 = 0 # long
+ ddd30 = [] # long[]
+ dddd30 = [] # long[]
+ e30 = 0.0 # float
+ ee30 = 0.0 # float
+ eee30 = [] # float[]
+ eeee30 = [] # float[]
+ f30 = 0.0 # double
+ ff30 = 0.0 # double
+ fff30 = [] # double[]
+ ffff30 = [] # double[]
+ g30 = False # bool
+ gg30 = False # bool
+ ggg30 = [] # bool[]
+ gggg30 = [] # bool[]
+ h30 = "" # char
+ hh30 = "" # char
+ hhh30 = [] # char[]
+ hhhh30 = [] # char[]
+ jj30 = "" # string
+ jjj30 = [] # string[]
+ kk30 = None # ObjectA
+ kkk30 = [] # ObjectA[]
+ l30 = [] # List
+ llll30 = [] # List
+ m30 = {} # Dictionary
+ mm30 = {} # Dictionary
+ s30 = {} # HashSet
+ ssss30 = {} # HashSet
+ a31 = 0 # byte
+ aa31 = 0 # byte
+ aaa31 = [] # byte[]
+ aaaa31 = [] # byte[]
+ b31 = 0 # short
+ bb31 = 0 # short
+ bbb31 = [] # short[]
+ bbbb31 = [] # short[]
+ c31 = 0 # int
+ cc31 = 0 # int
+ ccc31 = [] # int[]
+ cccc31 = [] # int[]
+ d31 = 0 # long
+ dd31 = 0 # long
+ ddd31 = [] # long[]
+ dddd31 = [] # long[]
+ e31 = 0.0 # float
+ ee31 = 0.0 # float
+ eee31 = [] # float[]
+ eeee31 = [] # float[]
+ f31 = 0.0 # double
+ ff31 = 0.0 # double
+ fff31 = [] # double[]
+ ffff31 = [] # double[]
+ g31 = False # bool
+ gg31 = False # bool
+ ggg31 = [] # bool[]
+ gggg31 = [] # bool[]
+ h31 = "" # char
+ hh31 = "" # char
+ hhh31 = [] # char[]
+ hhhh31 = [] # char[]
+ jj31 = "" # string
+ jjj31 = [] # string[]
+ kk31 = None # ObjectA
+ kkk31 = [] # ObjectA[]
+ l31 = [] # List
+ llll31 = [] # List
+ m31 = {} # Dictionary
+ mm31 = {} # Dictionary
+ s31 = {} # HashSet
+ ssss31 = {} # HashSet
+ a32 = 0 # byte
+ aa32 = 0 # byte
+ aaa32 = [] # byte[]
+ aaaa32 = [] # byte[]
+ b32 = 0 # short
+ bb32 = 0 # short
+ bbb32 = [] # short[]
+ bbbb32 = [] # short[]
+ c32 = 0 # int
+ cc32 = 0 # int
+ ccc32 = [] # int[]
+ cccc32 = [] # int[]
+ d32 = 0 # long
+ dd32 = 0 # long
+ ddd32 = [] # long[]
+ dddd32 = [] # long[]
+ e32 = 0.0 # float
+ ee32 = 0.0 # float
+ eee32 = [] # float[]
+ eeee32 = [] # float[]
+ f32 = 0.0 # double
+ ff32 = 0.0 # double
+ fff32 = [] # double[]
+ ffff32 = [] # double[]
+ g32 = False # bool
+ gg32 = False # bool
+ ggg32 = [] # bool[]
+ gggg32 = [] # bool[]
+ h32 = "" # char
+ hh32 = "" # char
+ hhh32 = [] # char[]
+ hhhh32 = [] # char[]
+ jj32 = "" # string
+ jjj32 = [] # string[]
+ kk32 = None # ObjectA
+ kkk32 = [] # ObjectA[]
+ l32 = [] # List
+ llll32 = [] # List
+ m32 = {} # Dictionary
+ mm32 = {} # Dictionary
+ s32 = {} # HashSet
+ ssss32 = {} # HashSet
+ a33 = 0 # byte
+ aa33 = 0 # byte
+ aaa33 = [] # byte[]
+ aaaa33 = [] # byte[]
+ b33 = 0 # short
+ bb33 = 0 # short
+ bbb33 = [] # short[]
+ bbbb33 = [] # short[]
+ c33 = 0 # int
+ cc33 = 0 # int
+ ccc33 = [] # int[]
+ cccc33 = [] # int[]
+ d33 = 0 # long
+ dd33 = 0 # long
+ ddd33 = [] # long[]
+ dddd33 = [] # long[]
+ e33 = 0.0 # float
+ ee33 = 0.0 # float
+ eee33 = [] # float[]
+ eeee33 = [] # float[]
+ f33 = 0.0 # double
+ ff33 = 0.0 # double
+ fff33 = [] # double[]
+ ffff33 = [] # double[]
+ g33 = False # bool
+ gg33 = False # bool
+ ggg33 = [] # bool[]
+ gggg33 = [] # bool[]
+ h33 = "" # char
+ hh33 = "" # char
+ hhh33 = [] # char[]
+ hhhh33 = [] # char[]
+ jj33 = "" # string
+ jjj33 = [] # string[]
+ kk33 = None # ObjectA
+ kkk33 = [] # ObjectA[]
+ l33 = [] # List
+ llll33 = [] # List
+ m33 = {} # Dictionary
+ mm33 = {} # Dictionary
+ s33 = {} # HashSet
+ ssss33 = {} # HashSet
+ a34 = 0 # byte
+ aa34 = 0 # byte
+ aaa34 = [] # byte[]
+ aaaa34 = [] # byte[]
+ b34 = 0 # short
+ bb34 = 0 # short
+ bbb34 = [] # short[]
+ bbbb34 = [] # short[]
+ c34 = 0 # int
+ cc34 = 0 # int
+ ccc34 = [] # int[]
+ cccc34 = [] # int[]
+ d34 = 0 # long
+ dd34 = 0 # long
+ ddd34 = [] # long[]
+ dddd34 = [] # long[]
+ e34 = 0.0 # float
+ ee34 = 0.0 # float
+ eee34 = [] # float[]
+ eeee34 = [] # float[]
+ f34 = 0.0 # double
+ ff34 = 0.0 # double
+ fff34 = [] # double[]
+ ffff34 = [] # double[]
+ g34 = False # bool
+ gg34 = False # bool
+ ggg34 = [] # bool[]
+ gggg34 = [] # bool[]
+ h34 = "" # char
+ hh34 = "" # char
+ hhh34 = [] # char[]
+ hhhh34 = [] # char[]
+ jj34 = "" # string
+ jjj34 = [] # string[]
+ kk34 = None # ObjectA
+ kkk34 = [] # ObjectA[]
+ l34 = [] # List
+ llll34 = [] # List
+ m34 = {} # Dictionary
+ mm34 = {} # Dictionary
+ s34 = {} # HashSet
+ ssss34 = {} # HashSet
+ a35 = 0 # byte
+ aa35 = 0 # byte
+ aaa35 = [] # byte[]
+ aaaa35 = [] # byte[]
+ b35 = 0 # short
+ bb35 = 0 # short
+ bbb35 = [] # short[]
+ bbbb35 = [] # short[]
+ c35 = 0 # int
+ cc35 = 0 # int
+ ccc35 = [] # int[]
+ cccc35 = [] # int[]
+ d35 = 0 # long
+ dd35 = 0 # long
+ ddd35 = [] # long[]
+ dddd35 = [] # long[]
+ e35 = 0.0 # float
+ ee35 = 0.0 # float
+ eee35 = [] # float[]
+ eeee35 = [] # float[]
+ f35 = 0.0 # double
+ ff35 = 0.0 # double
+ fff35 = [] # double[]
+ ffff35 = [] # double[]
+ g35 = False # bool
+ gg35 = False # bool
+ ggg35 = [] # bool[]
+ gggg35 = [] # bool[]
+ h35 = "" # char
+ hh35 = "" # char
+ hhh35 = [] # char[]
+ hhhh35 = [] # char[]
+ jj35 = "" # string
+ jjj35 = [] # string[]
+ kk35 = None # ObjectA
+ kkk35 = [] # ObjectA[]
+ l35 = [] # List
+ llll35 = [] # List
+ m35 = {} # Dictionary
+ mm35 = {} # Dictionary
+ s35 = {} # HashSet
+ ssss35 = {} # HashSet
+ a36 = 0 # byte
+ aa36 = 0 # byte
+ aaa36 = [] # byte[]
+ aaaa36 = [] # byte[]
+ b36 = 0 # short
+ bb36 = 0 # short
+ bbb36 = [] # short[]
+ bbbb36 = [] # short[]
+ c36 = 0 # int
+ cc36 = 0 # int
+ ccc36 = [] # int[]
+ cccc36 = [] # int[]
+ d36 = 0 # long
+ dd36 = 0 # long
+ ddd36 = [] # long[]
+ dddd36 = [] # long[]
+ e36 = 0.0 # float
+ ee36 = 0.0 # float
+ eee36 = [] # float[]
+ eeee36 = [] # float[]
+ f36 = 0.0 # double
+ ff36 = 0.0 # double
+ fff36 = [] # double[]
+ ffff36 = [] # double[]
+ g36 = False # bool
+ gg36 = False # bool
+ ggg36 = [] # bool[]
+ gggg36 = [] # bool[]
+ h36 = "" # char
+ hh36 = "" # char
+ hhh36 = [] # char[]
+ hhhh36 = [] # char[]
+ jj36 = "" # string
+ jjj36 = [] # string[]
+ kk36 = None # ObjectA
+ kkk36 = [] # ObjectA[]
+ l36 = [] # List
+ llll36 = [] # List
+ m36 = {} # Dictionary
+ mm36 = {} # Dictionary
+ s36 = {} # HashSet
+ ssss36 = {} # HashSet
+ a37 = 0 # byte
+ aa37 = 0 # byte
+ aaa37 = [] # byte[]
+ aaaa37 = [] # byte[]
+ b37 = 0 # short
+ bb37 = 0 # short
+ bbb37 = [] # short[]
+ bbbb37 = [] # short[]
+ c37 = 0 # int
+ cc37 = 0 # int
+ ccc37 = [] # int[]
+ cccc37 = [] # int[]
+ d37 = 0 # long
+ dd37 = 0 # long
+ ddd37 = [] # long[]
+ dddd37 = [] # long[]
+ e37 = 0.0 # float
+ ee37 = 0.0 # float
+ eee37 = [] # float[]
+ eeee37 = [] # float[]
+ f37 = 0.0 # double
+ ff37 = 0.0 # double
+ fff37 = [] # double[]
+ ffff37 = [] # double[]
+ g37 = False # bool
+ gg37 = False # bool
+ ggg37 = [] # bool[]
+ gggg37 = [] # bool[]
+ h37 = "" # char
+ hh37 = "" # char
+ hhh37 = [] # char[]
+ hhhh37 = [] # char[]
+ jj37 = "" # string
+ jjj37 = [] # string[]
+ kk37 = None # ObjectA
+ kkk37 = [] # ObjectA[]
+ l37 = [] # List
+ llll37 = [] # List
+ m37 = {} # Dictionary
+ mm37 = {} # Dictionary