Re: [MacRuby-devel] NSEvent MacRuby (updated)
You can check which macruby version you have, like so: % macruby -v MacRuby 0.8 (ruby 1.9.2) [universal-darwin10.0, x86_64] Also: * which OS versions do you have? * did you install the BridgeSupport preview pkg? Eloy On 15 nov 2010, at 13:51, András Zalavári wrote: > (I'm not sure if the previous mail was sent otherwise sorry for the multiple > posts) > > Hello, I'm new to MacRuby. I found an unexpected behavior of NSEvent. > > first of all in Cocoa [NSEvent mouseLocation] would return an NSPoint, with > the mouse position. MacRuby NSEvent.mouseLocation return an NSPoint, but > without the appropriate values. > > > irb(main):001:0> framework 'cocoa' > 2010-11-15 13:45:35.880 macruby[669:903] +[NSATSGlyphGenerator initialize] > invocation. The class is deprecated. > => true > irb(main):002:0> NSEvent.mouseLocation > => # > > > > it does not even work within a mouseUp method, with an NSEvent instance. > > I tried the same code on an iMac, and it returns the appropriate code, as a > CGPoint. > so there must be differences between the two. > I even got this warning Message NSATSGlyphGenerator on the MacBook, which I > dont on the iMac > > Please help figure out the solution! > > > Thanks > Andras Zalavari > > > > I'm using Macbook, and MacRuby 7.0... or 7.1? > how to check the version of MacRuby > > t? > ___ > 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
Re: [MacRuby-devel] Conforming to a protocol
I don't have an example of a class that uses conformsToProtocol: on the delegate, so I can't give you a code example, but I would try to override the conformsToProtocol: class and instance methods and return true for those you support. On 15 nov 2010, at 00:15, Martijn Walraven wrote: > Hi, > > I was wondering if there is any way to formally indicate a MacRuby class > conforms to an Objective-C protocol. I encountered some code that uses > conformsToProtocol: instead of respondsToSelector: as a check before invoking > delegate methods, and the only way I could get a delegate written in MacRuby > to work was to create an Objective-C class with the same name and specify the > required protocols in the interface declaration there. > > Thanks, > > Martijn > ___ > 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
Re: [MacRuby-devel] calling Objective-C method with block parameter
Did you install BridgeSupport preview 1? http://www.macruby.org/blog/2010/10/08/bridgesupport-preview.html It is required to use C blocks. Thanks, - Matt On Mon, Nov 15, 2010 at 2:51 AM, Alan Skipp wrote: > Hello everyone, > I'm attempting to call a method on an Objective-C object which takes a > block as its parameter, but I'm not having much luck. I can happily create > the object in Macruby and send the message with a Proc. The NSLog call > within the Objective-C method body succeeds, but the 'block()' doesn't. Am I > doing something obviously wrong here? (I'm using a nightly build from > sometime last week). > > > This is the Objective-C method: > > - (void)callBlock:(void (^)())block; > { > NSLog(@"block: %@", block); > block(); > } > > Here is the ruby code: > > b = TestBlock.new > b.callBlock( Proc.new { puts "hello" } ) > > > The output is as follows: > > *block: #* > * > Program received signal: “EXC_BAD_ACCESS”. > * > > ___ > 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
Re: [MacRuby-devel] Weird behaviour for a weird line of code
On Mon, Nov 15, 2010 at 3:50 PM, Ryan Davis wrote: > > On Nov 14, 2010, at 18:37 , Mark Rada wrote: > >> Now, when I try this out in macirb: (Case #3) >> >> require 'uri' >> test = URI.parse url unless (url = 'http://macruby.org/').nil? # error >> test = URI.parse url unless (url = 'http://wikipedia.org/').nil? # works >> >> If it doesn't work in the second case, why does it start working in the >> third case? > > First off, I hate this style of coding. If you didn't assign in a conditional > you'd avoid all of this crap to begin with. Assigning in conditionals is just > a sloppy and error prone way of coding and you should avoid it. This has been > a known anti-pattern in any algol-esque language since at least the 80s. I'm not sure I understand what you mean. Are you saying it's bad to do the *first* assignment to a variable inside a conditional? Or it's bad to assign inside a conditional in any case? I can understand the first, but I'm not sure how you would work around the second, unless you used a more functional style like x = (n > 2 ? true : false) or x = (if n > 2; true; else false; end) ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] calling Objective-C method with block parameter
Also, it is to note that if the block lives inside a framework you've made (or downladed – one that is not part of the system), you'll have to generate the BridgeSupport files yourselves. This is important because the runtime needs to know that you're trying to use blocks, and you instruct it to use them by creating and using the said BridgeSupport files :-) -- Thibault Martin-Lagardette On Nov 16, 2010, at 23:10, Matt Aimonetti wrote: > Did you install BridgeSupport preview 1? > http://www.macruby.org/blog/2010/10/08/bridgesupport-preview.html > It is required to use C blocks. > > Thanks, > > - Matt > > > On Mon, Nov 15, 2010 at 2:51 AM, Alan Skipp wrote: > Hello everyone, > I'm attempting to call a method on an Objective-C object which takes a block > as its parameter, but I'm not having much luck. I can happily create the > object in Macruby and send the message with a Proc. The NSLog call within the > Objective-C method body succeeds, but the 'block()' doesn't. Am I doing > something obviously wrong here? (I'm using a nightly build from sometime last > week). > > > This is the Objective-C method: > > - (void)callBlock:(void (^)())block; > { > NSLog(@"block: %@", block); > block(); > } > > Here is the ruby code: > > b = TestBlock.new > b.callBlock( Proc.new { puts "hello" } ) > > > The output is as follows: > > block: # > Program received signal: “EXC_BAD_ACCESS”. > > ___ > 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 ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Weird behaviour for a weird line of code
On Tue, Nov 16, 2010 at 4:14 PM, Eric Christopherson < echristopher...@gmail.com> wrote: > On Mon, Nov 15, 2010 at 3:50 PM, Ryan Davis > wrote: > > First off, I hate this style of coding. If you didn't assign in a > conditional you'd avoid all of this crap to begin with. Assigning in > conditionals is just a sloppy and error prone way of coding and you should > avoid it. This has been a known anti-pattern in any algol-esque language > since at least the 80s. > > I'm not sure I understand what you mean. Are you saying it's bad to do > the *first* assignment to a variable inside a conditional? Or it's bad > to assign inside a conditional in any case? It's bad to assign inside a condition in any case. > I can understand the > first, but I'm not sure how you would work around the second, unless > you used a more functional style like > > x = (n > 2 ? true : false) > > or > > x = (if n > 2; true; else false; end) > Um... just do: x = n > 2 Jeff purpleworkshops.com ___ > 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
Re: [MacRuby-devel] Weird behaviour for a weird line of code
On Nov 16, 2010, at 14:14 , Eric Christopherson wrote: > I'm not sure I understand what you mean. Are you saying it's bad to do > the *first* assignment to a variable inside a conditional? Or it's bad > to assign inside a conditional in any case? I can understand the > first, but I'm not sure how you would work around the second, unless > you used a more functional style like > > x = (n > 2 ? true : false) > > or > > x = (if n > 2; true; else false; end) this is not an assignment inside a conditional. It is a conditional inside an assignment. And as Jeff pointed out, while just an example, it is a very contrived example (that hits one of my biggest pet peeves). an assignment inside a conditional is do_something(x) if x = logical_statement or if x = logical_statement then do_something(x) else do_something_else end and whether you're coding in ruby, C/++, or whatever... it is almost always considered bad form. Avoid it not only for the reasons I mentioned before, but also to avoid the beat downs you'll get whenever you ask for our community's help. I cannot guarantee your safety otherwise. ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Weird behaviour for a weird line of code
On 2010-11-16, at 21:22 , Ryan Davis wrote: > > an assignment inside a conditional is > > do_something(x) if x = logical_statement I'm particularly fond of: x = logical_statement and do_something(x) Hate me now. ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Weird xcode / macruby differences
Hey would anyone be able to fill me in on whats going wrong here (or how to find out more on whats up) ~ ∴ macgem list --local *** LOCAL GEMS *** rake (0.8.7) sqlite3-ruby (1.3.2) ~ ∴ macruby -e "require 'rubygems'; require 'sqlite3'; p $:" ["/Users/ashleyis/.rvm/gems/macruby-0.7.1/gems/sqlite3-ruby-1.3.2/bin", "/Users/ashleyis/.rvm/gems/macruby-0.7.1/gems/sqlite3-ruby-1.3.2/lib", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby/1.9.2", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby/1.9.2/universal-darwin10.0", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby/1.9.2", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby/1.9.2/universal-darwin10.0", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/1.9.2", "/Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/1.9.2/universal-darwin10.0", "."] rubygems has pulled in the correct gem. now on xcode: puts $: require 'rubygems' puts $: require 'sqlite3' puts $: 2010-11-17 14:52:28.651 sqlitebrowser[78482:a0f] +[NSATSGlyphGenerator initialize] invocation. The class is deprecated. /Users/ashleyis/Documents/Projects/sqlitebrowser/build/Debug/sqlitebrowser.app/Contents/Resources /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby/1.9.2 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby/1.9.2/universal-darwin10.0 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby/1.9.2 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby/1.9.2/universal-darwin10.0 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/1.9.2 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/1.9.2/universal-darwin10.0 . /Users/ashleyis/Documents/Projects/sqlitebrowser/build/Debug/sqlitebrowser.app/Contents/Resources /Users/ashleyis/.rvm/gems/ruby-1.9.2-p0/gems/bundler08-0.8.5/bin /Users/ashleyis/.rvm/gems/ruby-1.9.2-p0/gems/bundler08-0.8.5/lib /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby/1.9.2 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby/1.9.2/universal-darwin10.0 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/site_ruby /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby/1.9.2 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby/1.9.2/universal-darwin10.0 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/vendor_ruby /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/1.9.2 /Library/Frameworks/MacRuby.framework/Versions/0.7.1/usr/lib/ruby/1.9.2/universal-darwin10.0 . /Users/ashleyis/Documents/Projects/sqlitebrowser/build/Debug/sqlitebrowser.app/Contents/Resources/rb_main.rb:11:in `': dlopen(/Users/ashleyis/.rvm/gems/ruby-1.9.2-p0/gems/ffi-0.6.3/lib/ffi_c.bundle, 9): no suitable image found. Did find: /Users/ashleyis/.rvm/gems/ruby-1.9.2-p0/gems/ffi-0.6.3/lib/ffi_c.bundle: mach-o, but wrong architecture - /Users/ashleyis/.rvm/gems/ruby-1.9.2-p0/gems/ffi-0.6.3/lib/ffi_c.bundle (LoadError) it seems to be pulling from my 1.9.2-p0 gems folder instead of macruby-0.7.1 (and grabbing bundler) ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel