thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James E. King III (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (THRIFT-3029) Getters for fields defined with uppercase names do not work
Date Thu, 01 Aug 2019 01:04:00 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-3029?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

James E. King III closed THRIFT-3029.
-------------------------------------

> Getters for fields defined with uppercase names do not work
> -----------------------------------------------------------
>
>                 Key: THRIFT-3029
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3029
>             Project: Thrift
>          Issue Type: Bug
>          Components: Cocoa - Compiler
>    Affects Versions: 0.9.2
>            Reporter: Wes Henderson
>            Assignee: James E. King III
>            Priority: Critical
>             Fix For: 0.13.0
>
>
> Using a thrift file such as:
> {code:title=foo.thrift|borderStyle=solid}
> struct Foo {
>   1: required i32 Bar;
>   2: required i32 baz;
> }
> {code}
> The generated Objective-C object, "baz" will have working getters but "Bar" will not.
For example, after setting bar to 5 and baz to 9, I get the following output depending on
the syntax:
> {code}
> [foo bar] => 0
> [foo Bar] (private method invoked by performSelector) => 5
> foo.bar => 0
> foo.Bar => 0
> foo.baz => 9
> {code}
> The problem is that the generated header specifies a lowercase getter:
> {code:}
> @property (nonatomic, getter=bar, setter=setBar:) int32_t Bar;
> {code}
> Whereas the .m file uses uppercase:
> {code}
> - (int32_t) Bar {
>   return __Bar;
> }
> {code}
> When the Objective-C compiler sees that there is no lowercase getter implementation provided,
it automatically generates one (this is supposed to be a convenience of the @property syntax).
So effectively, two getters are defined: a lowercase one that does not work, and an uppercase
one that does work but is private.
> As a workaround one can define all their fields beginning with a lowercase letter, if
possible.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message