perf[protocol]: 使用模板生成协议

This commit is contained in:
jaysunxiao committed 2022-05-16 23:15:24 +08:00
1 parent 3a59f06043
commit 5eb2530eae
39 files changed
+40 -40

No files matched your search

@@ -18,9 +18,9 @@ import com.zfoo.protocol.registration.ProtocolAnalysis;
import com.zfoo.protocol.registration.ProtocolRegistration; import com.zfoo.protocol.registration.ProtocolRegistration;
import com.zfoo.protocol.serializer.CodeLanguage; import com.zfoo.protocol.serializer.CodeLanguage;
import com.zfoo.protocol.serializer.cpp.GenerateCppUtils; import com.zfoo.protocol.serializer.cpp.GenerateCppUtils;
import com.zfoo.protocol.serializer.cs.GenerateCsUtils; import com.zfoo.protocol.serializer.csharp.GenerateCsUtils;
import com.zfoo.protocol.serializer.gd.GenerateGdUtils; import com.zfoo.protocol.serializer.gd.GenerateGdUtils;
import com.zfoo.protocol.serializer.js.GenerateJsUtils; import com.zfoo.protocol.serializer.javascript.GenerateJsUtils;
import com.zfoo.protocol.serializer.lua.GenerateLuaUtils; import com.zfoo.protocol.serializer.lua.GenerateLuaUtils;
import com.zfoo.protocol.serializer.protobuf.GenerateProtobufUtils; import com.zfoo.protocol.serializer.protobuf.GenerateProtobufUtils;
@@ -23,9 +23,9 @@ import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.generate.GenerateProtocolPath; import com.zfoo.protocol.generate.GenerateProtocolPath;
import com.zfoo.protocol.registration.field.*; import com.zfoo.protocol.registration.field.*;
import com.zfoo.protocol.serializer.cpp.GenerateCppUtils; import com.zfoo.protocol.serializer.cpp.GenerateCppUtils;
import com.zfoo.protocol.serializer.cs.GenerateCsUtils; import com.zfoo.protocol.serializer.csharp.GenerateCsUtils;
import com.zfoo.protocol.serializer.gd.GenerateGdUtils; import com.zfoo.protocol.serializer.gd.GenerateGdUtils;
import com.zfoo.protocol.serializer.js.GenerateJsUtils; import com.zfoo.protocol.serializer.javascript.GenerateJsUtils;
import com.zfoo.protocol.serializer.lua.GenerateLuaUtils; import com.zfoo.protocol.serializer.lua.GenerateLuaUtils;
import com.zfoo.protocol.serializer.protobuf.GenerateProtobufUtils; import com.zfoo.protocol.serializer.protobuf.GenerateProtobufUtils;
import com.zfoo.protocol.serializer.reflect.*; import com.zfoo.protocol.serializer.reflect.*;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.ArrayField; import com.zfoo.protocol.registration.field.ArrayField;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.generate.GenerateOperation; import com.zfoo.protocol.generate.GenerateOperation;
import com.zfoo.protocol.generate.GenerateProtocolDocument; import com.zfoo.protocol.generate.GenerateProtocolDocument;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.cs; package com.zfoo.protocol.serializer.csharp;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateOperation; import com.zfoo.protocol.generate.GenerateOperation;
import com.zfoo.protocol.generate.GenerateProtocolDocument; import com.zfoo.protocol.generate.GenerateProtocolDocument;
@@ -80,15 +80,15 @@ public abstract class GenerateJsUtils {
} }
public static void createProtocolManager(List<IProtocolRegistration> protocolList) throws IOException { public static void createProtocolManager(List<IProtocolRegistration> protocolList) throws IOException {
var list = List.of("js/buffer/ByteBuffer.js", "js/buffer/long.js", "js/buffer/longbits.js"); var list = List.of("javascript/buffer/ByteBuffer.js", "javascript/buffer/long.js", "javascript/buffer/longbits.js");
for (var fileName : list) { for (var fileName : list) {
var fileInputStream = ClassUtils.getFileFromClassPath(fileName); var fileInputStream = ClassUtils.getFileFromClassPath(fileName);
var createFile = new File(StringUtils.format("{}/{}", protocolOutputRootPath, StringUtils.substringAfterFirst(fileName, "js/"))); var createFile = new File(StringUtils.format("{}/{}", protocolOutputRootPath, StringUtils.substringAfterFirst(fileName, "javascript/")));
FileUtils.writeInputStreamToFile(createFile, fileInputStream); FileUtils.writeInputStreamToFile(createFile, fileInputStream);
} }
// 生成ProtocolManager.js文件 // 生成ProtocolManager.js文件
var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("js/ProtocolManagerTemplate.js"))); var protocolManagerTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("javascript/ProtocolManagerTemplate.js")));
var importBuilder = new StringBuilder(); var importBuilder = new StringBuilder();
var initProtocolBuilder = new StringBuilder(); var initProtocolBuilder = new StringBuilder();
@@ -117,7 +117,7 @@ public abstract class GenerateJsUtils {
var registrationConstructor = registration.getConstructor(); var registrationConstructor = registration.getConstructor();
var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName(); var protocolClazzName = registrationConstructor.getDeclaringClass().getSimpleName();
var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("js/ProtocolTemplate.js"))); var protocolTemplate = StringUtils.bytesToString(IOUtils.toByteArray(ClassUtils.getFileFromClassPath("javascript/ProtocolTemplate.js")));
var docTitle = docTitle(registration); var docTitle = docTitle(registration);
var valueOfMethod = valueOfMethod(registration); var valueOfMethod = valueOfMethod(registration);
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.ArrayField; import com.zfoo.protocol.registration.field.ArrayField;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
*/ */
package com.zfoo.protocol.serializer.js; package com.zfoo.protocol.serializer.javascript;
import com.zfoo.protocol.generate.GenerateProtocolFile; import com.zfoo.protocol.generate.GenerateProtocolFile;
import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.IFieldRegistration;