Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriterPrototype use non-exist zero property #508

Closed
dreamershl opened this issue Dec 1, 2016 · 0 comments
Closed

WriterPrototype use non-exist zero property #508

dreamershl opened this issue Dec 1, 2016 · 0 comments

Comments

@dreamershl
Copy link

dreamershl commented Dec 1, 2016

Is it possible to add the string type support as before? Since javascript doesn't support long natively, my app always use the Long.toString(). When encode the message, the previous version will use the Long to parse the string back to Long. But in the new version, this can't be supported anymore.

  1. longbits.js doesn't export this zero

     var zero = new LongBits(0, 0);
    
  2. writer.js directly use it. when the value isn't valid uint64, the exception will be thrown

    WriterPrototype.uint64 = function write_uint64(value) {
       var bits;
       if (typeof value === 'number')
          bits = value ? LongBits.fromNumber(value) : LongBits.zero;
       else if (value.low || value.high)
          bits = new LongBits(value.low >>> 0, value.high >>> 0);
     else
        bits = LongBits.zero;
     return this.push(writeVarint64, bits.length(), bits);
      };
    
dreamershl added a commit to dreamershl/protobuf.js that referenced this issue Dec 1, 2016
dreamershl added a commit to dreamershl/protobuf.js that referenced this issue Dec 1, 2016
dreamershl added a commit to dreamershl/protobuf.js that referenced this issue Dec 1, 2016
@dcodeIO dcodeIO closed this as completed in 6e5fdb6 Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants