Hi,

I'd like to give some explanation about the ARC patch for iOS and MacOS.

On 2011/11/14, at 14:36, HIRANO Satoshi wrote:
> - Works for iOS and MacOS.
> - The runtime and generated code are compatible with both ARC compilation 
> mode and non-ARC compilation mode.

There is no compiler option for switching ARC and Non-ARC. It's fully automatic.

You must use retain_stub/release_stub instead of retain/release when you alter 
the runtime.
TObjective-C.h includes magic macros like this;

   #if __has_feature(objc_arc)
   #define retain_stub self
   #define release_stub self
   #else
   #define retain_stub retain
   #define release_stub release
   #endif

o = [obj retain_stub]     is replaced with 
o = [obj self]         in case of ARC compilation.

[obj release_stub] is replace with [obj self]. It takes a little bit time but 
not harmful.

> - Initialization of struct/exception/map/list/set with defalut values is 
> implemented.

The Cocoa (Objective-C) generator ignored default values in 
struct/map/list/set. I found the generated code did not include default 
initializer. For example, "nobody" is not set when you create a Person object 
even if you write like this;

   struct Person {
        1: string name = "nobody",
        2: i32 age
   }

I added some code to generate the default initializer like this. It should 
handle any nested combination of struct/exception/map/list/set.

   - (id) init {
       self = [super init];
       [self setName:@"nobody"];
       return self;
   }

> - Now it generates much better code for initializing constants. The current 
> thrift compiler generates buggy code.

The current compiler can compile this example, because generated code has 
initWithName:age:.

    const Person stationMaster = {'name' : "John",  'age' : 49 }

But the following example fails, because generated code does not have 
initWithName:.

   const Person stationMaster = {'name' : "John"}

I ported the latest code for generating constant initializer from Java 
generator. The new compiler does not use initWithXXXX, but uses property 
setters repeatedly and recursively instead.


There are some more bug fixes.

I found memory leak in transport/TSocketClient.m. I fixed it by adding two 
CFRelease()s.

Objective-C compiler complains that transport/TSocketClient is not a compliant 
of NSStreamDelegate. I  fixed it with proper #ifdef. This problem is mentioned 
in the following JIRA page but not fixed.

    https://issues.apache.org/jira/browse/THRIFT-762


Have fun!

@@@@@@@@@@@@@@  Life is beautiful and full of surprises.

HIRANO Satoshi, Ph.D.         <[email protected]>
AIST: National Institute of Advanced Industrial Science and Technology


Reply via email to