[Rubycocoa-devel 615] Re: bit fields / ary + class methods overriding

Back to archive index

Fujimoto Hisa hisa****@fobj*****
Tue Jan 16 17:00:51 JST 2007


Hi Laurent,
thanks for your work!

On 2007/01/16, at 11:52, Laurent Sansonetti wrote:
> Hi,
>
> Quick description of what changed in the SVN today!
>
> First, we now support bit fields and ary Objective-C encodings
> (respectively _C_ARY_B and _C_BFLD). It means that these encodings are
> properly converted to Ruby and Libffi types.
>
> This was necessary to wrap the NSDecimal structure:
>
> typedef struct {
>      signed   int _exponent:8;
>      unsigned int _length:4;     // length == 0 && isNegative -> NaN
>      unsigned int _isNegative:1;
>      unsigned int _isCompact:1;
>      unsigned int _reserved:18;
>      unsigned short _mantissa[NSDecimalMaxSize];
> } NSDecimal;
>
> Now this structure is properly usable from Ruby (I added test cases to
> be sure). Note that the fields are private (I added a new 'opaque'
> attribute to the Foundation metadata file). You have to use the public
> API to play with it.
>
> Second, it is now finally possible to override class methods from  
> Ruby!
>
> $ irb -r osx/foundation
>>> include OSX
> => Object
>>> class Foo < NSObject
>>>   def self.version
>>>     42
>>>   end
>>> end
> => nil
>>> Foo.oc_version
> => 42
>
> It's only available via subclassing though. I didn't updated
> objc_export. I think that we should have a separate DSL method for  
> this.
>
> Like:
>
> class NSObject
>    def self.myMethod
>      42
>    end
>    objc_export_singleton :myMethod, 'int'
> end
>
> We need a good name, and objc_export_singleton looks a bit long to me.
> Any suggestion?

mmmh, i should see this case when thinking about objc_export.

i would prefer a bit objc_class_export rather than
objc_export_singleton though almost no difference.

--
hisa






More information about the Rubycocoa-devel mailing list
Back to archive index