Support for adding ActionScript3 to protocolbuffer

Source: Internet
Author: User

 

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.