Protocolbuffer supports java, python, and c ++ by default. Other languages need to compile their own code generator code in other languages.
However, the official website also mentioned support for ActionScript3. Click here to view details.
The protobuf-actionscript3 includes the serial number of ActionScript3 and the deserialization as source code. as well as the C ++ code of the protoc as3 Code Generator
In addition, the protobuf-actionscript3 also needs an encryption library as3crypto support, need to download together
Of course, the protobuf library is also the most important.
The following describes how to compile a protoc code generator that supports as3:
1. Copy the compiler \ as3 directory in the protobuf-actionscript3 library to src \ google \ protobuf \ compiler in the protobuf library. The directory structure is as follows:
As3 \
Cpp \
Java \
Python \
Code_generator.cc
Command_line_interface.cc
...
2. Open the sln in the protobuf project and add all files under the newly added as3 directory in libprotoc.
3. Add it to main. cc of the protoc Project
Google: protobuf: compiler: as3: As3Generator as3_generator;
Cli. RegisterGenerator ("-- as3_out", & as3_generator,
"Generate ActionScript source file .");
4. Open as3_file.h
Comment out the following code:
Namespace protobuf {
Class FileDescriptor; // descriptor. h
Namespace io {
Class Printer; // printer. h
}
Namespace compiler {
Class OutputDirectory; // code_generator.h
}
}
Add in
# Include <google/protobuf/stubs/common. h>
# Include <google/protobuf/compiler/code_generator.h>
# Include <google/protobuf/io/printer. h>
5. Compile protoc.exe
6. Prepare the proto file and use protoc.exe to generate it in a way similar to CPP.
7. Integrate the as3-lib in protobuf-actionscript and the downloaded encrypted swc into your flash project.