jarvis657 / protojs Goto Github PK
View Code? Open in Web Editor NEWThis project forked from sirikata/protojs
Protobuf implementation in javascript
Home Page: http://sirikata.com
License: Other
This project forked from sirikata/protojs
Protobuf implementation in javascript
Home Page: http://sirikata.com
License: Other
Protojs is a BSD-licensed protocol buffer library written in JavaScript. http://github.com/sirikata/protojs NOTE: If you're starting a new project, we recommend newer, better supported and maintained options, e.g. https://github.com/dcodeIO/ProtoBuf.js ==== Features: * Fast compiler using ANTLR * Packed field + 2.3.0 autodetection * Full Unicode support (decoding surrogate pairs above 0xffff) * Getters+setters for error checking (and fallback if not supported) * Enums and nested messages * 32-bit and 64-bit floating points * Serializing/deserializing to base64 or array of int * PBJ datatypes (uuid, vector, quaternion, normal) defined in pbj.js ==== Bugs or missing features: * Does not enforce "required", acts the same as "optional" * Default values are not used * Setting a field in a sub-message will not cause the sub-message to be serialized, as the python parser worked before 2.3.0 * It is not possible to serialize to binary string in a cross-browser way, because Javascript uses unicode strings. However, the Stream class can be extended for specific applications * No support for extensions or services * Not compatible with older versions of protobufs ==== Building protojs: The build process is tested on Linux, and should work also on mac or cygwin: First, run "./bootstrap.sh" This script downloads antlr-3.2 from antlr.org. Now, run "make" Builds the "pbj" compiler and a test file from protocol/ into output/ If you want to use the makefile you can put your own .proto files into protocol/. You can also run the pbj file with "pbj input.proto output.proto" If you want to build a directory full of protocol files, run it with "make INPUTDIR=/path/to/protocol". You can optionally specify OUTPUTDIR if you don't want them to go to output. ==== Using the javascript library: The javascript library is intended to be as similar as possible to python protocol buffers. If you have declared the package Example.Test, and made a message called HelloWorld, you can create a message with: var mymsg = new Example.Test.HelloWorld; mymsg.field1 = "value1"; mymsg.inner_msg.field2 = 5; var newmsg = mymsg.repeated_msg.push(); newmsg.field2 = 6; newmsg.field3.push(1) newmsg.field3.push(2) newmsg.field3.push(3) To serialize the message, you must create an instance of a class that extends PROTO.Stream. var serialized = new PROTO.Base64Stream; mymsg.SerializeToStream(serialized); document.write(serialized.getString()); Note that the function names are ParseFromStream and SerializeToStream, not ParseFromString or ParseFromArray as in python or C++. This is because javascript strings are encoded in UTF-16 and cannot handle binary data. ==== Reporting bugs: Send mail to Patrick Horn <[email protected]>, or find me at irc.freenode.net #sirikata If you have a cool feature to add, feel free to fork the project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.