GitHub user radekg opened a pull request:
https://github.com/apache/thrift/pull/353
THRIFT-2939: Js on par with nodejs
The generated code for regular JS differs from NodeJS code. NodeJS uses
direct return values from `read<Type>()` while regular JS code expects a value
from `read<Type>()` to be an object with `.value` property.
This makes it impossible to share generated code between browser JS and
NodeJS. The fix is rather simple:
- do not append `.value` in generated code while accessing values read from
protocol / transport
- do not return an object with the value property from read, return result
read
I am not sure why such difference. Both environment implementations take an
input, which is a protocol, and execute the same read methods. There is no need
to have an additional complexity in regular JS.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/radekg/thrift js-on-par-with-nodejs
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/353.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #353
----
commit 8c94a6e62690a87cb2150bb07d21708fd7941e46
Author: radekg <[email protected]>
Date: 2015-01-01T19:35:01Z
Initialise tpos and tstack in the Protocol constructor so writing to a
protocol without a message does not fail.
commit 4cfe690bc0d0bde0eab01212d5cffb636afa19b0
Author: radekg <[email protected]>
Date: 2015-01-11T10:51:40Z
Merge remote-tracking branch 'upstream/master'
commit a8e5b1c73de2b90044b7dac5ec004867eada2ab4
Author: radekg <[email protected]>
Date: 2015-01-11T12:25:08Z
Make the generated JS code on par with nodejs - no .value in generated code
and simple types returned from appropriate read. Makes the generated code
portable.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---