Re: [MacRuby-devel] MacRuby not finding a method that Ruby is
I'm still on a 32-bit machine, so can't try 0.5 yet :^( I did manage to find a workaround, however, by creating an alias for the 'initialize' method and then calling it instead of 'super' inside of the 'define_method' call. Ed On Oct 7, 2009, at 10:51 PM, Matt Aimonetti wrote: you might want to try your luck with 0.5 - Matt On Wed, Oct 7, 2009 at 7:37 PM, Edward Hynes m...@dharmagaia.com wrote: Hi, I'm attempting to use the RParsec gem under MacRuby, but am getting a NoMethodError when it loads. I've create a test file that simply adds my local gem directory to the front of the library search path and then calls require 'rparsec'. This file runs fine under Ruby 1.9, but produces the following error when called from MacRuby 0.4. /Users/ehynes/Test/Gems/rparsec/parser.rb:32:in `block in init': super: no superclass method `initialize:' for RParsec::ValueParser:RParsec::ValueParser (NoMethodError) from /Users/ehynes/Test/Gems/rparsec/parsers.rb:621:in `new' from /Users/ehynes/Test/Gems/rparsec/parsers.rb:621:in `module:RParsec' from /Users/ehynes/Test/Gems/rparsec/parsers.rb:3:in `top (required)' from /Users/ehynes/Test/Gems/rparsec.rb:3:in `require' from /Users/ehynes/Test/Gems/rparsec.rb:3:in `block in top (required)' from /Users/ehynes/Test/Gems/rparsec.rb:2:in `each' from /Users/ehynes/Test/Gems/rparsec.rb:2:in `top (required)' from AbcParser.rb:2:in `require' from AbcParser.rb:2:in `main' The method with the error in the Parser class is: def self.init(*vars) parser_checker = {} vars.each_with_index do |var, i| name = var.to_s parser_checker[i] = var if name.include?('parser') ! name.include?('parsers') end define_method(:initialize) do |*params| --- super() # --- line 32 vars.each_with_index do |var, i| param = params[i] if parser_checker.include? i TypeChecker.check_arg_type Parser, param, self, i end instance_variable_set(@+var.to_s, param) end end end Any ideas as to why Ruby can call super in the above method, but MacRuby can't? Is there a fix or workaround that I could use? An alternate parser? Thanks, Ed P.S. I did have to change one line in the RParsec parser.rb file to get it to run under Ruby 1.9, replacing a ':' with a 'then' in a case statement. $ diff parser_original.rb parser.rb 881c881 case c when String: c[0] else c end --- case c when String then c[0] else c end # ':' replaced with 'then' ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel -- Edward Hynes Dharma Gaia LLC Software with the Earth in Mind http://dharmagaia.com ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Initializing Structs with Bytes?
Hi, I'm calling a function, via bridesupport, that returns a void pointer to a c structure. I'd like to instantiate a MacRuby structure using that void pointer. Is there a way to do this? Thanks, Ed ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Xcode Executable Arguments
Hi, I'm working on localization for a MacRuby app and would like to be able to set the language in the Executable Info's Arguments tab in Xcode, but the arguments are being gobbled up by MacRuby. Is there a way to escape or quote executable arguments so that they are passed through to the application? I'm setting the arguments using the defaults command for now, but it would prefer doing so within Xcode if possible. Thanks, Ed -- Edward Hynes Dharma Gaia LLC Software with the Earth in Mind http://dharmagaia.com ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] How to retrieve an observer's context?
I'd like to use contexts when registering some observers, but have been unable to retrieve them, getting a can't convert C/Objective-C value `0x2822731' of type `v' to Ruby object instead. The following code, for example, will trigger the error class Subject attr_accessor :abc end class Observer def observeValueForKeyPath keyPath, ofObject:object, change:change, context:context context[0] end end subject = Subject.new observer = Observer.new subject.addObserver observer, forKeyPath:'abc', options:0, context:'a context' subject.setAbc 'some value' Is there a way to retrieve an observation context? Or is there an alternative way for observers to distinguish among multiple registrations for a given object/keyPath? Thanks, Ed ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] How to retrieve an observer's context?
Hi Laurent, Thanks for the help. Did you mean to set the context ivar on the observer or on the subject? Wouldn't setting it on the observer result in the last registration 'winning' if the observer is watching more than one subject? Ed On Apr 20, 2009, at 4:28 PM, Laurent Sansonetti wrote: Hi Edward, Context arguments in Objective-C are generally void pointers, which makes them hard to use in Ruby. Also, since we run in Objective-C GC mode, objects could potentially be collected since contexts do not set up AFAIK write barriers. I would recommend to set up an instance variable on your observer instead (and pass nil as the context). observer.instance_variable_set(:@context, your_context) And later in your observer method, retrieve the ivar. Laurent ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel