[ 
https://issues.apache.org/jira/browse/THRIFT-1947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13688154#comment-13688154
 ] 

Vitali Lovich commented on THRIFT-1947:
---------------------------------------

Looks good overall.  Notes:

- Instead of using string concatenation, use a stringstream
- You go through the effort of building dval when you throw it away if there's 
a constant value.
- It's not clear to me why you're casting all the optional values to 0 instead 
of just using the default constructor.
- The enum generation assumes that there's always an enum value that 0 
represents which isn't actually true.  It should probably grab the first one 
specified in the thrift.
- In your second foor loop, I believe you're missing  && !t->is_enum()
- In your TODO, clarify what constitutes "perfect".  Also, some more comments 
about what the second loop is doing & why would be great.
- I'm not clear on why the second loop is necessary & you can't just put it in 
the initializer.  Are you saying that thrift object copy-constructors aren't 
properly implemented?
- The isset should be initialized correctly too.

Can you attach the generated Foo & Bar classes to the issue so that I can more 
easily comment on the generated code?

enum MyEnum {
   SOME_VALUE = 1
   SOME_OTHER_VALUE = 2
}

struct Bar {
   1: list<i32> param1;
}

struct Foo {
   1: optional bool param1 = true;
   2: bool param2 = false;
   3: required bool param3;
   4: list<string> param4;
   5: Bar param5;
   6: optional param6;
   7: MyEnum param7;
   8: optional MyEnum param8 = SOME_OTHER_VALUE;
}

Thanks.
                
> C++ constructor with initializer list should be generated
> ---------------------------------------------------------
>
>                 Key: THRIFT-1947
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1947
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Compiler
>            Reporter: Vitali Lovich
>            Assignee: Kamil Sałaś
>         Attachments: 0001-Thrift-1947.patch
>
>
> It would be really nice if the thrift constructor took in an initializer list 
> like the generated Java constructor does for non-optional fields.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to