You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Nevo Hed (JIRA)" <ji...@apache.org> on 2011/04/06 01:48:06 UTC

[jira] [Created] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Add the ability to specify symbolic default value for optional boolean
----------------------------------------------------------------------

                 Key: THRIFT-1130
                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
             Project: Thrift
          Issue Type: Improvement
          Components: Compiler (General)
    Affects Versions: 0.6, 0.5
            Reporter: Nevo Hed
            Priority: Minor


When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'


Example thrift file:
struct AtscStrmRecordRequestT {
    1: optional bool bDoSomething = true,
    2: required string whatever;
}


With current error
$ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
[ERROR:/rtmp/x.thrift:2] (last token was 'true')
Cannot use reserved language keyword: "true"


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Closed] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Bryan Duxbury (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-1130.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 0.8
         Assignee: Nevo Hed

Hm, looks like my concerns were unfounded. Sorry for letting this sit so long. I just committed the patch.
                
> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Assignee: Nevo Hed
>            Priority: Minor
>             Fix For: 0.8
>
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Nevo Hed (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13126969#comment-13126969 ] 

Nevo Hed commented on THRIFT-1130:
----------------------------------

Thanks!

On Thu, Oct 13, 2011 at 5:35 PM, Bryan Duxbury (Closed) (JIRA) <


                
> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Assignee: Nevo Hed
>            Priority: Minor
>             Fix For: 0.8
>
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Nevo Hed (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13017751#comment-13017751 ] 

Nevo Hed commented on THRIFT-1130:
----------------------------------

This was my concern too, and my threshold for passage was to ensure that it
will provide an error, obviously its not the same error as it originally
did.

At the end of the day, this seems to be pretty much like a c-pre-processor
macros:
#define true 1
#define false 0

The the items NOT in my negative tests that WOULD fail are attempts to use
true/false as field numbers (for example)

What you are asking for is a negative test (which I performed locally), I
only saw one but it is commented out (so its not in any automated test)
Is this how you would like to see it?  If not can you point me at an example
of a negative test in ThriftTest.thrift?

This is what I tried and what I had in mind ...


struct boolDefValTst {
    // positive tests:
    1: optional bool      myBool_1 = true,
    2: optional bool      myBool_2 = false,
    3: optional bool      myBool_3 = 1,
    4: optional bool      myBool_4 = 0,
    5: optional bool      myBool_5,
    6: optional i32       myI32_1 = true,

    // negative tests:
    // (uncomment each, one at a time to test)
    // - Test that we get an error using boolean constants as field names
    //7:  optional i32    true,    // [ERROR:...] (last token was 'true')
syntax error
    //8:  optional i32    false,   // [ERROR:...] (last token was 'false')
syntax error
    // -  Test that we get an error using boolean constants type names
    //9:  optional true   myI32_2, // [ERROR:...] (last token was 'true')
syntax error
    //10: optional false  myI32_3, // [ERROR:...] (last token was 'false')
syntax error
    // - Test that we get an error using boolean constants as values for
incompatible types
    //11: optional string   myStr1 = true, // [FAILURE:...] type error:
const "myStr" was declared as string
}


Thanks





> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Priority: Minor
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Nevo Hed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nevo Hed updated THRIFT-1130:
-----------------------------

    Description: 
When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'

Example thrift file:

struct AtscStrmRecordRequestT {

    1: optional bool bDoSomething = true,

    2: required string whatever;

}


With current error
{quote}
$ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
[ERROR:/rtmp/x.thrift:2] (last token was 'true')
Cannot use reserved language keyword: "true"
{quote}

  was:
When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'

{quote}
Example thrift file:
struct AtscStrmRecordRequestT {
    1: optional bool bDoSomething = true,
    2: required string whatever;
}
{quote}

With current error
{quote}
$ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
[ERROR:/rtmp/x.thrift:2] (last token was 'true')
Cannot use reserved language keyword: "true"
{quote}


> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Priority: Minor
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Nevo Hed (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016419#comment-13016419 ] 

Nevo Hed commented on THRIFT-1130:
----------------------------------

Hopefully this is monitored ... I can't find anywhere a way to change my
JIRA email -
need to change it from
  nhed@bamboo-entertainment.com
to
  nhed@bamboom.com

(username nhed)

Thanks
 -Nevo


> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Priority: Minor
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Nevo Hed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nevo Hed updated THRIFT-1130:
-----------------------------

    Description: 
When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'

{quote}
Example thrift file:
struct AtscStrmRecordRequestT {
    1: optional bool bDoSomething = true,
    2: required string whatever;
}
{quote}

With current error
{quote}
$ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
[ERROR:/rtmp/x.thrift:2] (last token was 'true')
Cannot use reserved language keyword: "true"
{quote}

  was:
When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'


Example thrift file:
struct AtscStrmRecordRequestT {
    1: optional bool bDoSomething = true,
    2: required string whatever;
}


With current error
$ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
[ERROR:/rtmp/x.thrift:2] (last token was 'true')
Cannot use reserved language keyword: "true"


     Patch Info: [Patch Available]

> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Priority: Minor
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> {quote}
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> {quote}
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Hudson (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13126985#comment-13126985 ] 

Hudson commented on THRIFT-1130:
--------------------------------

Integrated in Thrift #296 (See [https://builds.apache.org/job/Thrift/296/])
    THRIFT-1130. compiler: Add the ability to specify symbolic default value for optional boolean

Patch: Nevo Hed

bryanduxbury : http://svn.apache.org/viewvc/?view=rev&rev=1183115
Files : 
* /thrift/trunk/compiler/cpp/src/thriftl.ll
* /thrift/trunk/test/ThriftTest.thrift

                
> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Assignee: Nevo Hed
>            Priority: Minor
>             Fix For: 0.8
>
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13017589#comment-13017589 ] 

Bryan Duxbury commented on THRIFT-1130:
---------------------------------------

I haven't tested this patch yet, but my concern is that by adding these tokens, you may possibly have broken string literals or identifiers named "true" and "false". Can you add some examples to ThriftTest.thrift that exercises these corner cases?

> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Priority: Minor
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (THRIFT-1130) Add the ability to specify symbolic default value for optional boolean

Posted by "Nevo Hed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nevo Hed updated THRIFT-1130:
-----------------------------

    Attachment: bool.patch

Not sure if this is the best fix, but seems to be rather minimalistic

By the way - this is my first attempt at  contribution here, please let me know if there is some other procedure should be followed.

> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-1130
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1130
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.5, 0.6
>            Reporter: Nevo Hed
>            Priority: Minor
>         Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type bool the user now needs to enter a numeric value (0, or 1).  It would be nice if they could specify a symbolic value such as 'true' & 'false'
> {quote}
> Example thrift file:
> struct AtscStrmRecordRequestT {
>     1: optional bool bDoSomething = true,
>     2: required string whatever;
> }
> {quote}
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift 
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira