From: Logan Capaldo Date: 2006-08-07T22:12:58+09:00 Subject: Re: writing native ObjC extension to ruby ?? On Aug 7, 2006, at 8:45 AM, Une b�vue wrote: > Logan Capaldo wrote: > >> That shouldn't matter assuming its like >> >> - objCMethod >> { >> CallCarbonFunction( ) >> } > > OK fine, however Tim Burks at the page > > > says : > >> We have to use RubyCocoa/Objective-C object allocation >> and initialization. Instead of calling Jukebox.new >> to create our jukebox objects, we have to perform >> the standard Objective-C two step initialization. >> First call alloc, then the init function, >> in this case initWithUnit. > > then i would have better to write my ext in C (rather than in ObjC) > because the try out i've done using ObjC wrapper of C for RubyCocoa > needs those steps : > > require 'osx/cocoa' > require 'jukebox' > OSX::ns_import :Jukebox > > j = OSX::Jukebox.alloc.initWithUnit(13) > j.seekDisc(3, :track, 16) > [...] > GC.start > disposing of jukebox with unit id 13 > > > whereas with my ObjC class i've used only : > > OSX.ns_import('MyAlias') # the ObjC class > @ns_alias=OSX::MyAlias.alloc.initWithAliasPath(@ns_alias_path) > > and i get everything i need about "MyAlias" > > however definitely i would prefer doing that more shortly (as with C > ext) : > > trick=MyAlias.new > > as said by Tim Burks > > then, now, i wonder if i could call carbon methods : > CFURLCreateWithFileSystemPath > CFURLGetFSRef ... > FSResolveAliasFile > CFURLCreateFromFSRef > CFURLCopyFileSystemPath > > as easily in C than in ObjC (i never a line of C, only 30 lines of > ObjC) > > ??? > Sure you can, Carbon is a C api (and a relatively sane one at that, it's almost OO in many ways). > -- > une b�vue >