[MacRuby-devel] [PATCH] Added KVO array accessors

2008-11-07 Thread Benjamin Stiglitz
These changes let you write methods for KVO accessing using natural Ruby syntax: class T kvo_array :squares do def size 10 end def [](i) i * i end end end >> T.new.valueForKey('squares') => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] --- lib/hotcocoa.rb |1 + lib/hot

[MacRuby-devel] [PATCH] Support for KVO set accessors

2008-11-07 Thread Benjamin Stiglitz
We had arrays, now let's have sets, too. Refactored out the base redefinition code to make the set case easy to add. --- lib/hotcocoa/kvo_accessors.rb | 39 ++ + 1 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/hotcocoa/kvo_accessors.r

Re: [MacRuby-devel] Hotcocoa design ethos [was Re: [feature request] open url in browser]

2008-11-09 Thread Benjamin Stiglitz
So, which is it, guys? A glorified macro pre-processor with enough canned macros to illustrate how to use the same approach in your own applications, or an attempt to simplify Cocoa programming where it genuinely cries out for simplification, hopefully also in cases which are commonly used

Re: [MacRuby-devel] PBI - MacRuby aux Fines Merbs...

2008-11-12 Thread Benjamin Stiglitz
PS: Credits to Laurent who has been making an effort on writing more and more tests for the core part of MacRuby! :) Ditto. I should say that the RubySpec effort is also useful for testing MacRuby, in as much as it provides coverage for the vast majority of the behavior which MacRuby share

Re: [MacRuby-devel] KVO dot notation bug?

2008-11-20 Thread Benjamin Stiglitz
Sure seems like a bug to me. Any ideas? Sounds like it’s related to ticket #164. I’ll be looking into it Real Soon Now™. -Ben ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby

Re: [MacRuby-devel] What's the best way to implement a delegate/action with multiple parameters?

2008-11-21 Thread Benjamin Stiglitz
I'm pretty new to Cocoa, so maybe I'm overlooking the obvious here. I just want to make sure I'm not doing more work than necessary. I'd like to be able to control the minimum size for a NSSplitView. As I understand it, I need to have a delegate with a method that can handle splitView:co

Re: [MacRuby-devel] sub classing with hot cocoa

2008-12-02 Thread Benjamin Stiglitz
I am sure there is an easy answer to this question, but I have not figured it out after some experimenting (nor can I find an example in the examples) What do I do if i want to subclass (say) an NSView ? And yet still employ that subclass with all the rest of the hot cocoa magic? (so with

Re: [MacRuby-devel] attr_accessor on NSManagedObject

2009-01-05 Thread Benjamin Stiglitz
I subclassed a Core Data entity Recipe with PPRecipe < NSManaged object, and created accessors for the fields: class PPRecipe < NSManagedObject attr_accessor :name, :desc, :type, :imagePath, :serves end but these fields now don't save or display correct after I create objects, and restart the a

Re: [MacRuby-devel] NSManagedObject being returned in delegate as Pointer

2009-01-05 Thread Benjamin Stiglitz
In practice, you should avoid passing objects as context to methods like this one, because their implementation won't keep a GC reference to them, so they might disappear during a collection cycle. Since the Cocoa frameworks are GC-aware, these are generally strong pointers. -Ben

Re: [MacRuby-devel] accessing ruby objects from Objective-C

2009-02-10 Thread Benjamin Stiglitz
I describe calling ruby side objects from the ObjC side. I can make it work using dynamic classes but of course that generates compiler warnings (like no '-baz' method found). Of course it still works, but is there any way for my ObjC classes to know at compile time what are the class name

Re: [MacRuby-devel] accessing ruby objects from Objective-C

2009-02-18 Thread Benjamin Stiglitz
That being said, it’d be nice if the runtime could dump a header for the current state of a class, ScriptingBridge-style. I might look into this. That would be awesome. Something like sdef/sdp for Ruby classes maybe those tools would be useful already. Would be trivial to implement, maybe

Re: [MacRuby-devel] Accessing Obj-C InstVars from Ruby

2009-04-01 Thread Benjamin Stiglitz
Is there a way to access instance variables defined in an Objective-C class from a Ruby extension? It is currently not implemented, but it's technically possible. A good work-around is to define accessors (properties) as John mentioned. Maybe we need MacRuby::Runtime to bubble up the Obj

Re: [MacRuby-devel] # of developers

2009-04-01 Thread Benjamin Stiglitz
Here is the blurb: http://www.macruby.org/project.html I should say that I’m not a very frequent contributor, so you can subtract one from the #size of that list. -Ben ___ MacRuby-devel mailing list [email protected] http://lists.m

Re: [MacRuby-devel] Strings, Encodings and IO

2009-04-07 Thread Benjamin Stiglitz
So plan B: We emulate Ruby 1.9 strings behavior on top of of NSString/NSData. I'm really interested in this discussion too. A little background for JRuby: Thanks for the background, Charlie. This sort of history is very instructive. * Java's strings are all UTF-16. In order to represent

Re: [MacRuby-devel] Strings, Encodings and IO

2009-04-08 Thread Benjamin Stiglitz
When doing force_encoding, convert to a ByteString in the old encoding, then try to convert to an NSString in the new encoding. If we succeed, great. If not, leave as a tagged ByteString (and probably whine about it). That's actually wrong. All force_encoding does is change the encoding a

Re: [MacRuby-devel] Cocoa control to replace the GtkTable widget ?

2009-04-08 Thread Benjamin Stiglitz
Question, I would like to know if there is a "cocoa like" of the GtkTable widget http://pygtk.org/pygtk2tutorial/sec-PackingUsingTables.html NSMatrix, sort of. To quote every other post on cocoa-dev: what are you trying to do? -Ben___ MacRuby-deve

Re: [MacRuby-devel] Cocoa control to replace the GtkTable widget ?

2009-04-08 Thread Benjamin Stiglitz
Sorry, thank you for your help I’m not sure if I was able to help! When I asked “what are you trying to do,” I meant: “what does the UI you are trying to create look like?” NSMatrix is only appropriate for certain, very limited interfaces. Otherwise you’ll need to roll your own, or play i

Re: [MacRuby-devel] retrieving password from keychain

2009-04-23 Thread Benjamin Stiglitz
Thanks for the reply Laurent. Yes I did generate a BridgeSupport file and included it in my build. I did try to call the method and pass in a pointer for the item reference (using Pointer.new_for_type('@')) but the object that was assigned after the call was some weird NSCFType object which, whe

Re: [MacRuby-devel] kvo vs referenced hash

2009-09-08 Thread Benjamin Stiglitz
Coming from a Ruby background, I try to understand and pick the best from Obj-C/Cococa and learn how to use brilliant ideas to improve my coding. Tonight I was working on a simple demo app to learn how things are done in the Obj-C world and see how they would transpose to the MacRuby wor

Re: [MacRuby-devel] objc block and ruby block?

2009-09-16 Thread Benjamin Stiglitz
This is currently not implemented. It is not planned for the upcoming release mostly because I don't think it's that important, since all block methods in Cocoa also have methods dealing with function pointers, which will be supported. Not true of some of the new Foundation and AppKit APIs.

Re: [MacRuby-devel] Implementing Undo In RaiseMan / MacRuby

2009-10-27 Thread Benjamin Stiglitz
def insertObject(p, inEmployeesAtIndex:index) NSLog("adding #{p} to #{employees}") # <= Not called, huh? undo = @undoManager undo.prepareWithInvocationTarget(self, removeObjectFromEmployeesAtIndex:index) if !undo.isUndoing undo.setActionName("Insert Person") end