GithubHelp home page GithubHelp logo

sirikata / protojs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielrh/protojs

211.0 211.0 24.0 285 KB

Protobuf implementation in javascript

Home Page: http://sirikata.com

License: Other

C++ 50.69% C 2.84% Shell 0.70% JavaScript 45.77%

protojs's Issues

[osx] make error

ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [pbj] Error 1

PROTO.warn used before it's defined

The definition of PROTO.DefineProperty calls PROTO.warn on lines 83 and 87 of protobuf.js. However, PROTO.warn is not defined until line 118. If a browser like IE8 does not support DefineProperty, then it will attempt to call PROTO.warn before it's defined.

default value issue

With this proto file:

 package Test;

 message MyTest {
        enum MyTestEnum {
                ZERO = 0 ;
                ONE  = 1 ;
        }
        optional MyTestEnum value = 2 [default = ZERO];
 }

...I get this JS output:

 "use strict";
 /** @suppress {duplicate}*/var Test;
 if (typeof(Test)=="undefined") {Test = {};}

 Test.MyTest = PROTO.Message("Test.MyTest",{
        MyTestEnum: PROTO.Enum("Test.MyTest.MyTestEnum",{
                ZERO :0,
                ONE :1  }),
        value: {
                options: {default_value:Test.MyTest.MyTestEnum.ZERO},
                multiplicity: PROTO.optional,
                type: function(){return Test.MyTest.MyTestEnum;},
                id: 2
        }});

...which produces (in Firefox):

 TypeError: Test.MyTest is undefined

...and in Chrome:

 Uncaught TypeError: Cannot read property 'MyTestEnum' of undefined 

...in both cases, the offending line is:

                  options: {default_value:Test.MyTest.MyTestEnum.ZERO},

...changing the default value from the enum "ZERO" to a literal value of "0" fixes the problem.

This .proto file works fine in at least three other protobuf systems - so I presume that it's legal.

Use isNaN instead of comparing to NaN

When compiling the script with the google closure tools, the following warnings occur:

inc\third_party\protobuf.js:1175: WARNING - Comparison again NaN is always false. Did you mean isNaN()?
if (n == NaN) {
^

inc\third_party\protobuf.js:1188: WARNING - Comparison again NaN is always false. Did you mean isNaN()?
if (n == NaN) {
^

inc\third_party\protobuf.js:1339: WARNING - Comparison again NaN is always false. Did you mean isNaN()?
if (n == NaN) {
^

According to the compiler, isNaN should be used in this code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.