As3 version of protobuf

Source: Internet
Author: User

Protobuf officially supports C ++ Java and python, and others are supported by third parties. Two official as3 versions are recommended:

  • Action Script:
    Http://code.google.com/p/protobuf-actionscript3/
  • Action Script:
    Https://code.google.com/p/protoc-gen-as3/

We are very grateful to the two authors for their contributions and expressed their feelings for improvement.

The first one submitted earlier is not updated for a long time. It is basically unavailable, and enum/extension is not supported. We mainly look at the project of the second link.

Protoc-gen-as3 is doing very well in general, unfortunately there are some shortcomings.

1. Dynamic is added before each class

This is sometimes disgusting. For example, if a developer changes the name of a field in proto and uses the old name in the program, compilation will not report errors. The ideal situation is that the field name of the Protocol has changed and an error must be reported during compilation.

We can use the SED tool to shave this dynamic out.

2. serialization and deserialization method parameters are insufficient.

For example, there is no method similar to the following to specify the serialization length.

    writeTo(bytes:BytesArray, len:int):void

There is a similar problem during deserialization. No one specifies the length of the input data.

3. The message length is not obtained.

The simplest message package format is generally defined as: total_len + protobuf_msg

The write code is similar to this:

Sock. writeunsignedint (totallen); // write the total length protobufmsg. writeto (sock); // write the MSG to the output of the socket

But you cannot write code like above, because you cannot get the length of protobufmsg! In this way, only protobufmsg can be serialized to a bytesarray and the total length can be obtained. In this way, there is an additional process for writing data to bytesarray.

4. No clear () for the entire message ()

Here we mainly want to create a new msgbody object and use it repeatedly. But there is no clear () and there is no way to reuse it. You must constantly delete & New.

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.