Requirements for Interface Builder to correctly parse MacRuby files?
Hello Laurent et al, In an attempt to ease code management for a large document class, I split the code for my NSDocument subclass into a number of separate Ruby files. e.g. MyDocument-base.rb, MyDocument-commands.rb, and so on, reopening the Ruby class and adding more methods in each file. When the class was in a single source file (eg. MyDocument.rb), Interface Builder would correctly parse this and recognise outlets and action methods. Splitting the class into separate files had the effect of causing Interface Builder to no longer recognise outlets and action methods. Can you please explain how and when IB parses Ruby source files and why splitting a class into separate files breaks the parsing? Is this documented somewhere? Any suggestions for a way around this? Thanks, Paul Howson Queensland Australia
Hi Paul, In theory, splitting files should not be an issue. Keep in mind that the IB parser is very rudimentary at the moment (we are working on a much better solution for a future release), so if you define classes into modules it may not work. A good way to know exactly what IB will read is to call the parser by yourself, manually, from the command line: $ /Developer/usr/bin/rb_nibtool -f MyController.rb You should see on the terminal a property list, basically an array of dictionaries, each one being a class with outlets/actions sub- dictionaries. Laurent On Feb 1, 2010, at 6:53 PM, Paul Howson wrote:
Hello Laurent et al,
In an attempt to ease code management for a large document class, I split the code for my NSDocument subclass into a number of separate Ruby files. e.g. MyDocument-base.rb, MyDocument-commands.rb, and so on, reopening the Ruby class and adding more methods in each file.
When the class was in a single source file (eg. MyDocument.rb), Interface Builder would correctly parse this and recognise outlets and action methods.
Splitting the class into separate files had the effect of causing Interface Builder to no longer recognise outlets and action methods.
Can you please explain how and when IB parses Ruby source files and why splitting a class into separate files breaks the parsing?
Is this documented somewhere?
Any suggestions for a way around this?
Thanks, Paul Howson Queensland Australia _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On 02/02/2010, at 2:14 PM, Laurent Sansonetti wrote:
Hi Paul,
In theory, splitting files should not be an issue. Keep in mind that the IB parser is very rudimentary at the moment (we are working on a much better solution for a future release), so if you define classes into modules it may not work.
A good way to know exactly what IB will read is to call the parser by yourself, manually, from the command line:
$ /Developer/usr/bin/rb_nibtool -f MyController.rb
You should see on the terminal a property list, basically an array of dictionaries, each one being a class with outlets/actions sub-dictionaries.
Laurent
Thanks Laurent. That flushed out the problem. When re-opening classes across multiple files, I was not declaring the superclass relationship again. e.g. FILE 1: class A < NSDocument … end FILE 2: class A … end When the Ruby compiler sees FILE 2 it already knows A is a subclass of NSDocument. But the Interface Builder parser obviously treats files in isolation and needs to be told about that relationship in each file. Problem solved. Paul
participants (2)
-
Laurent Sansonetti
-
Paul Howson