You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Hudson (JIRA)" <ji...@apache.org> on 2015/06/01 15:51:17 UTC
[jira] [Commented] (THRIFT-3122) Javascript struct constructor
should properly initialize struct and container members from plain js
arguments
[ https://issues.apache.org/jira/browse/THRIFT-3122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567314#comment-14567314 ]
Hudson commented on THRIFT-3122:
--------------------------------
SUCCESS: Integrated in Thrift #1565 (See [https://builds.apache.org/job/Thrift/1565/])
Revert "THRIFT-3122 Javascript struct constructor should properly initialize struct and container members from plain js arguments" (henrique: rev c0e4a8dc07402a03f8627608fbcb84affca200c9)
* lib/nodejs/test/test-cases.js
* test/JsDeepConstructorTest.thrift
* lib/js/test/test-deep-constructor.html
* compiler/cpp/src/generate/t_js_generator.cc
* lib/nodejs/test/deep-constructor.test.js
* lib/js/src/thrift.js
* lib/js/Gruntfile.js
* lib/js/test/deep-constructor.test.js
* lib/nodejs/test/test_driver.js
* lib/nodejs/test/testAll.sh
* lib/nodejs/lib/thrift/thrift.js
* lib/nodejs/lib/thrift/json_protocol.js
> Javascript struct constructor should properly initialize struct and container members from plain js arguments
> -------------------------------------------------------------------------------------------------------------
>
> Key: THRIFT-3122
> URL: https://issues.apache.org/jira/browse/THRIFT-3122
> Project: Thrift
> Issue Type: Improvement
> Components: JavaScript - Compiler
> Reporter: Igor Tkach
> Fix For: 0.9.3
>
>
> Currently constructors for struct types in generated javascript accept {{args}} object and initialize struct's members by simply assigning a value from corresponding {{args}} object property (if not undefined). If struct member is
> another struct it must be explicitly created with constructor and passed as an argument value.
> Given following definitions:
> {code}
> struct A {
> 1: string something
> }
> struct B {
> 1: A value
> }
> {code}
> this works:
> {code:javascript}
> var b1 = new B(
> {
> value: new A(
> {
> something: 'hello'
> }
> )
> }
> );
> {code}
> this doesn't:
> {code:javascript}
> var b2 = new B(
> {
> value: {
> something: 'hello'
> }
> }
> );
> {code}
> Attempt to serialize b2 will result in error because {{b2.a}} doesn't have a {{write}} method.
> This becomes especially problematic when deep objects are used with libraries like [Underscore.js|http://underscorejs.org/], [lodash|https://lodash.com/], [React's immutability helpers|https://facebook.github.io/react/docs/update.html] or [Immutable.js|https://github.com/facebook/immutable-js]: most operations will return or produce plain javascript objects without read/write methods even if Thrift objects were given as input. Manually converting object graphs back to Thrift serializable form is not workable.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)