資源簡介
layaair_AS3版本可用的protobuf3協議,親測可用。官方目前為止沒有提供AS3版本的protobuf3的API喲~!

代碼片段和文件信息
package?com.google.protobuf.compiler.as3;
import?com.google.protobuf.DescriptorProtos.DescriptorProto;
import?com.google.protobuf.DescriptorProtos.EnumDescriptorProto;
import?com.google.protobuf.DescriptorProtos.FileDescriptorProto;
import?com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest;
import?com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
import?java.io.FileOutputStream;
import?java.util.HashMap;
import?java.util.Map;
public?class?CodeGenerator?{
????public?static?void?main(String[]?args)?{
????????new?CodeGenerator();
????}
????private?HashMap?_classRef?=?new?HashMap<>();
????private?HashMap?_fileToGenerate?=?new?HashMap<>();
????public?CodeGenerator()?{
????????try?{
????????????//writeToFile();
????????????//CodeGeneratorRequest?request?=?CodeGeneratorRequest.parseFrom(new?FileInputStream(“E:\\ttsz\\client\\protobuf-as3\\tools\\protobuf.test“));
????????????CodeGeneratorRequest?request?=?CodeGeneratorRequest.parseFrom(System.in);
????????????CodeGeneratorResponse.Builder?response?=?CodeGeneratorResponse.newBuilder();
????????????for?(FileDescriptorProto?proto?:?request.getProtoFileList())?{
????????????????buildClassRefs(proto);
????????????}
????????????for?(FileDescriptorProto?proto?:?request.getProtoFileList())?{
????????????????if?(request.getFileToGenerateList().contains(proto.getName()))?{
????????????????????if?(“proto3“.equals(proto.getSyntax()))?{
????????????????????????buildMessageGenerators(proto);
????????????????????}?else?{
????????????????????????throw?new?Exception(“need?syntax=\“proto3\“:?“?+?proto.getName());
????????????????????}
????????????????}
????????????}
????????????for?(Map.Entry?entry?:?_fileToGenerate.entrySet())?{
????????????????Printer?printer?=?new?Printer(0);
????????????????entry.getValue().generate(printer);
????????????????CodeGeneratorResponse.File.Builder?file?=?CodeGeneratorResponse.File.newBuilder();
????????????????file.setName(entry.getKey().replace(‘.‘?‘/‘)?+?“.as“);
????????????????file.setContent(printer.toString());
????????????????response.addFile(file);
????????????}
????????????response.build().writeTo(System.out);
????????????System.out.flush();
????????}?catch?(Exception?e)?{
????????????e.printStackTrace();
????????}
????}
????private?void?writeToFile()?{
????????try?{
????????????CodeGeneratorRequest?request1?=?CodeGeneratorRequest.parseFrom(System.in);
????????????FileOutputStream?os?=?new?FileOutputStream(“protobuf.test“);
????????????request1.writeTo(new?FileOutputStream(“protobuf.test“));
????????????System.err.println(“success?xxxxxx“);
????????}?catch?(Throwable?e)?{
????????????e.printStackTrace();
????????}
????}
????private?void?buildClassRefs(FileDescriptorProto?fileProto)?{
????????String?packageName?=?fileProto.getPackage();
????????for?(DescriptorProto?proto?:?fileProto.getMessageTypeList())?{
??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????44??2016-07-01?18:57??protobuf3-layaair-master\.gitignore
?????文件????????329??2016-07-01?18:57??protobuf3-layaair-master\.idea\artifacts\protoc_as3_jar.xm
?????文件????????686??2016-07-01?18:57??protobuf3-layaair-master\.idea\compiler.xm
?????文件?????????74??2016-07-01?18:57??protobuf3-layaair-master\.idea\copyright\profiles_settings.xm
?????文件????????159??2016-07-01?18:57??protobuf3-layaair-master\.idea\encodings.xm
?????文件????????173??2016-07-01?18:57??protobuf3-layaair-master\.idea\flexCompiler.xm
?????文件????????235??2016-07-01?18:57??protobuf3-layaair-master\.idea\inspectionProfiles\profiles_settings.xm
?????文件???????1005??2016-07-01?18:57??protobuf3-layaair-master\.idea\inspectionProfiles\Project_Default.xm
?????文件???????2881??2016-07-01?18:57??protobuf3-layaair-master\.idea\misc.xm
?????文件????????790??2016-07-01?18:57??protobuf3-layaair-master\.idea\modules.xm
?????文件???????8792??2016-07-01?18:57??protobuf3-layaair-master\.idea\uiDesigner.xm
?????文件????????167??2016-07-01?18:57??protobuf3-layaair-master\.idea\vcs.xm
?????文件???????1031??2016-07-01?18:57??protobuf3-layaair-master\protobuf-as3\protobuf-as3.iml
?????文件??????14275??2017-06-02?11:37??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\CodedInputStream.as
?????文件??????13729??2017-06-02?11:37??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\CodedOutputStream.as
?????文件????????483??2017-06-02?11:34??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\Enum.as
?????文件????????793??2017-06-02?11:34??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\FieldDesc
?????文件???????2247??2017-06-02?11:34??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\Int64.as
?????文件???????2406??2017-06-02?11:34??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\InvalidProtocolBufferException.as
?????文件????????509??2017-06-02?11:34??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\MapEntry.as
?????文件????????430??2017-06-02?11:37??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\Message.as
?????文件????????390??2017-06-02?11:37??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\MessageUtil.as
?????文件????????839??2017-06-02?11:34??protobuf3-layaair-master\protobuf-as3\src\com\google\protobuf\WireFormat.as
?????文件????????510??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\protoc-as3.iml
?????文件???????6229??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\src\com\google\protobuf\compiler\as3\CodeGenerator.java
?????文件???????3083??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\src\com\google\protobuf\compiler\as3\EnumGenerator.java
?????文件??????21117??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\src\com\google\protobuf\compiler\as3\FieldGenerator.java
?????文件????????116??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\src\com\google\protobuf\compiler\as3\IGenerator.java
?????文件???????4107??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\src\com\google\protobuf\compiler\as3\MapGenerator.java
?????文件???????8753??2016-07-01?18:57??protobuf3-layaair-master\protoc-as3\src\com\google\protobuf\compiler\as3\MessageGenerator.java
............此處省略67個文件信息
評論
共有 條評論