From: Eloy D. <elo...@gm...> - 2007-10-13 17:14:04
|
Just to clarify, overriding class methods does work, just not instance methods. Eloy On 10/13/07, Eloy Duran <elo...@gm...> wrote: > Hello all, > > I have a problem where I try to override an instance method of a class > which comes from a framework that I have generated the bridgesupport > for as per instructions on the wiki... > > The code is like this: > > ============================================================== > require 'osx/cocoa' > > OSX.require_framework > File.expand_path('../../vendor/HDCrashReporter.framework', __FILE__) > > class OSX::HDCrashReporter > def sendReport(sender) > puts "Where's the message to this method dude?!" > end > > def self.doCrashSubmitting > puts 'HDCrashReporter class method. This works...' > end > end > > class OSX::NSString > def capitalizedString > puts 'NSString instance method. This does work...' > end > end > > OSX::HDCrashReporter.doCrashSubmitting # prints: HDCrashReporter class > method. This works... > "foo".to_nsstring.capitalizedString # prints: NSString instance > method. This does work... > > OSX::HDCrashReporter.alloc.init.sendReport(nil) > ============================================================== > > > The last call only works if I initialize an instance myself, so if I > call it from the ruby side. > But it doesn't when the method is called as from the interface, at > that point it simply uses the original method. > > The original method is as follows: > > - (IBAction) sendReport: (id) sender > { > // code > } > > I have included the output with $RUBYCOCOA_DEBUG = true > I hope this is helpful... > > Cheers, > Eloy > > 2007-10-13 19:09:25.388 Crasher[20751] OVMIX : Registering (direct > override) Ruby method by selector 'sendReport:' types 'v12@0:4@8' > 2007-10-13 19:09:25.388 Crasher[20751] OVMIX : retrieving closure imp > for method type 'v12@0:4@8' > 2007-10-13 19:09:25.388 Crasher[20751] DATACNV : decoding method > encoding 'v12@0:4@8' manually > 2007-10-13 19:09:25.388 Crasher[20751] DATACNV : retval -> v > 2007-10-13 19:09:25.388 Crasher[20751] DATACNV : argc -> 3 > 2007-10-13 19:09:25.388 Crasher[20751] DATACNV : arg[0] -> @ > 2007-10-13 19:09:25.388 Crasher[20751] DATACNV : arg[1] -> : > 2007-10-13 19:09:25.388 Crasher[20751] DATACNV : arg[2] -> @ > 2007-10-13 19:09:25.388 Crasher[20751] LIBFFI : make closure argc 3 > 2007-10-13 19:09:25.388 Crasher[20751] LIBFFI : arg[0] -> ffi_type 0x46290 > 2007-10-13 19:09:25.388 Crasher[20751] LIBFFI : arg[1] -> ffi_type 0x46290 > 2007-10-13 19:09:25.388 Crasher[20751] LIBFFI : arg[2] -> ffi_type 0x46290 > 2007-10-13 19:09:25.388 Crasher[20751] OVMIX : Registered Ruby method > by selector 'sendReport:' types 'v12@0:4@8' > > 2007-10-13 19:09:25.389 Crasher[20751] OVMIX : Registering (direct > override) Ruby method by selector 'doCrashSubmitting' types 'v8@0:4' > 2007-10-13 19:09:25.389 Crasher[20751] OVMIX : retrieving closure imp > for method type 'v8@0:4' > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : decoding method > encoding 'v8@0:4' manually > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : retval -> v > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : argc -> 2 > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : arg[0] -> @ > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : arg[1] -> : > 2007-10-13 19:09:25.389 Crasher[20751] LIBFFI : make closure argc 2 > 2007-10-13 19:09:25.389 Crasher[20751] LIBFFI : arg[0] -> ffi_type 0x46290 > 2007-10-13 19:09:25.389 Crasher[20751] LIBFFI : arg[1] -> ffi_type 0x46290 > 2007-10-13 19:09:25.389 Crasher[20751] OVMIX : Registered Ruby method > by selector 'doCrashSubmitting' types 'v8@0:4' > > 2007-10-13 19:09:25.389 Crasher[20751] OVMIX : Registering (direct > override) Ruby method by selector 'capitalizedString' types '@8@0:4' > 2007-10-13 19:09:25.389 Crasher[20751] OVMIX : retrieving closure imp > for method type '@8@0:4' > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : decoding method > encoding '@8@0:4' manually > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : retval -> @ > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : argc -> 2 > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : arg[0] -> @ > 2007-10-13 19:09:25.389 Crasher[20751] DATACNV : arg[1] -> : > 2007-10-13 19:09:25.389 Crasher[20751] LIBFFI : make closure argc 2 > 2007-10-13 19:09:25.389 Crasher[20751] LIBFFI : arg[0] -> ffi_type 0x46290 > 2007-10-13 19:09:25.389 Crasher[20751] LIBFFI : arg[1] -> ffi_type 0x46290 > 2007-10-13 19:09:25.390 Crasher[20751] OVMIX : Registered Ruby method > by selector 'capitalizedString' types '@8@0:4' > |