[MacRuby-devel] Objcetive C methods not "visible" from MacRuby

Uliano Guerrini uliano.guerrini at gmail.com
Sun Nov 29 00:15:53 PST 2009


To start playing with mixed Cocoa and MacRuby classes I created a Foo Objcetive C Framework containing just one class Roo:

#import <Cocoa/Cocoa.h>
@interface Roo : NSObject {
	float aValue;
	NSNumber *anotherValue;
	NSMutableString *aString;
}
@property float aValue;
@property(retain) NSNumber *anotherValue;
@property(retain) NSMutableString *aString;
@end

#import "Roo.h"
@implementation Roo
@synthesize aValue;
@synthesize anotherValue;
@synthesize aString;
@end

added garbage collection support and stated the public role of the header file 

then I copied the Foo.framework into ~/Library/Frameworks and

MacBook:~ uliano$ macirb
irb(main):001:0> framework 'Foo'
=> true
irb(main):002:0> a=Roo.new
=> #<Roo:0x20009f520>
irb(main):003:0> a.aValue=12
=> 12
irb(main):004:0> a.anotherValue=150
=> 150
irb(main):005:0> a.anotherValue/a.aValue
=> 12.5
irb(main):006:0> a.aString='Pancetta affumicata!'
=> "Pancetta affumicata!"
irb(main):007:0> a.aString+a.anotherValue.to_s
=> "Pancetta affumicata!150"

wonderful! isn't it?

well not completely: I expected to find aValue, setAValue, anotherValue, ... in the list of methods of a but this is not the case

irb(main):008:0> a.methods.sort
=> [:!, :!=, :!~, :==, :===, :=~, :Complex, :Rational, :__callee__, :__id__, :__method__, :__native__?, :__send__, :__type__, :clone, :define_singleton_method, :dup, :enum_for, :eql?, :equal?, :extend, :freeze, :frozen?, :hash, :inspect, :instance_eval, :instance_exec, :instance_of?, :instance_variable_defined?, :instance_variable_get, :instance_variable_set, :instance_variables, :is_a?, :kind_of?, :load_bridge_support_file, :method, :methods, :nil?, :object_id, :private_methods, :protected_methods, :public_method, :public_methods, :public_send, :respond_to?, :send, :singleton_methods, :taint, :tainted?, :tap, :to_enum, :to_s, :trust, :untaint, :untrust, :untrusted?]

so I thought that it was just too magic that everything worked so smoothly without doing nothing, maybe to have the correct behavior something should be done with the bridgesupport metadata whom I know nothing and I tried

MacBook:~ uliano$ cd /Library/BridgeSupport/
MacBook:BridgeSupport uliano$ gen_bridge_metadata -f Foo -o Foo.bridgesupport  MacBook:BridgeSupport uliano$ cat Foo.bridgesupport 
<?xml version='1.0'?>
<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd">
<signatures version='0.9'>
<depends_on path='/System/Library/Frameworks/Cocoa.framework'/>
<depends_on path='/System/Library/Frameworks/CoreFoundation.framework'/>
</signatures>MacBook:BridgeSupport uliano$ 

not a clue about any method!

I'm stuck here. How can I have Obcjetive C methods "visibile" from MacRuby?

uliano





More information about the MacRuby-devel mailing list