Skip to content

Atry/protoc-gen-as3

Repository files navigation

Build Status

What is it?

protoc-gen-as3 is a Protocol Buffers plugin for ActionScript 3.

This project aims to support Protocol Buffers in ActionScript 3 with minimum API and best performance. protoc-gen-as3's serialize/deserialize performance is near native AMF's writeObject/readObject, although protoc-gen-as3 runs in AVM2 while writeObject/readObject runs natively.

Features

I have implemented almost all protobuf features (more than any other protobuf's AS3 implementation) in protoc-gen-as3:

  • All basic types
  • Nested messages
  • Enumerations
  • Packed and non-packed repeated fields
  • Extensions
  • RPC services
    • Custom options for services and methods
  • ActionScript metadata tag generation:
  • Text format
  • Unknown fields

Unsupported features

These features are supported by Google's C++/Java/Python implementation, but not in protoc-gen-as3:

  • Groups (a deprecated feature)
  • Custom options for messages, enums and files

How to use it?

Download

Dowload and extract this tarball.

Generate code

Unlike other protobuf's as3 compilers, protoc-gen-as3 does not require you to modify original protobuf's source code. You can just use protoc binary (version 2.3+) with this plugin to generate ActionScript 3 source code:

protoc --plugin=protoc-gen-as3=path/to/protoc-gen-as3[.bat] --as3_out=output-path your.proto

Write your own code

Then, you can use the generated files to serialize and deserialize in protobuf format by invoking mergeFrom() and writeTo() method.

Before compiling, don't forget to let your ActionScript 3 compiler include protobuf.swc and the generated source files.

See AdvancedUsage and ASDoc for more information.