Re: [MacRuby-devel] scientific plotting engine

2010-12-30 Thread Brian Chapados
Hi Jonathan, If you want an open source framework, use CorePlot (http://code.google.com/p/core-plot/). If you're willing to pay money for something that looks awesome, is easier to use and well-maintained, check out DataGraph (both the App and Framework: http://www.visualdatatools.com/DataGraph/F

Re: [MacRuby-devel] MacRuby 0.5 vs. CG Bitmap Context

2010-03-06 Thread Brian Chapados
Hi Scott, The problem is due to the way the macruby Pointer class handles types, which apparently is due to an LLVM issue... The Pointer class is defined in compiler.cpp. See this comment: --- VALUE rb_pointer_new(const char *type_str, void *val, size_t len) { // LLVM doesn't allow to get a p

Re: [MacRuby-devel] My class's initialize not called

2010-01-21 Thread Brian Chapados
Hi Steve (et al), So, there are a couple things going on here. Cocoa classes use the concept of a "designated initializer" method, which is a name for the instance method that calls the initializer method of the superclass. This chain continues until you hit [NSObject#init]. To figure this out fr

Re: [MacRuby-devel] Pointer.new_with_type("v")-is-unsized shocker

2010-01-20 Thread Brian Chapados
Hi Carlo, In case it helps, you might be able to use one of the existing keychain wrappers / code rather than rolling your own (listing): http://www.cocoadev.com/index.pl?KeyChain There is also a nice keychain wrapper for iPhone, but I'm not sure if it works on OS X: http://github.com/ldanderse

Re: [MacRuby-devel] Would a macruby-newbie List Be Worthwhile?

2009-12-16 Thread Brian Chapados
On Wed, Dec 16, 2009 at 9:11 AM, steve ross wrote: > On Dec 16, 2009, at 1:07 AM, John Shea wrote: >> >> The second part, filling with data (presumably you will only need to do this >> once, because then the data can be saved with the app). >> There are many ways to add data. >> >> The easiest I

Re: [MacRuby-devel] UTF8 Strings

2009-12-06 Thread Brian Chapados
On Sun, Dec 6, 2009 at 3:02 PM, S. Ross wrote: > Yes, well I did read the documentation but thanks for the suggestion. I just > mistyped in my email. I'm also specifying the Cocoa framework. > > None of that seems to explain why initWithData:error returns null. In the original code you showed, yo

Re: [MacRuby-devel] [MacRuby] #454: String#getbyte not working?

2009-11-25 Thread Brian Chapados
I'm pretty sure you can use NSString#characterAtIndex s = "Brian" s.characterAtIndex(0) # => 66 Brian On Wed, Nov 25, 2009 at 4:46 PM, MacRuby wrote: > #454: String#getbyte not working? > --+- >  Reporter:  p...@…          

Re: [MacRuby-devel] kvo vs referenced hash

2009-09-08 Thread Brian Chapados
e approach explained by Brian > where game items listen for notifications and update themselves based on the > notification. > For some reasons, I think it would be easier for the game controller to know > about the game items and call #update on each of them directly. > > - Matt >

Re: [MacRuby-devel] kvo vs referenced hash

2009-09-08 Thread Brian Chapados
I am also not sure that I fully understand this scenario, but it doesn't appear that you would need KVO. Do the "tasks" or the "Brain" have any properties to observe? As Ben points out, KVO really shines when you need to keep a UI in sync with the state of a model. If "tasks" just need to know wh

Re: [MacRuby-devel] Mixing Objective-C and Ruby classes

2009-05-21 Thread Brian Chapados
>> I updated the gists with the new Obj-C code and hotcocoa file. >> Obj-C: http://gist.github.com/114521 >> hotcocoa: http://gist.github.com/114523 >> >> Brian >> >> >> On Wed, May 20, 2009 at 9:11 AM, Brian Chapados wrote: >> > I didn't

Re: [MacRuby-devel] Mixing Objective-C and Ruby classes

2009-05-20 Thread Brian Chapados
eems to be available on both platforms. I updated the gists with the new Obj-C code and hotcocoa file. Obj-C: http://gist.github.com/114521 hotcocoa: http://gist.github.com/114523 Brian On Wed, May 20, 2009 at 9:11 AM, Brian Chapados wrote: > I didn't use the hotcocoa cli interface to gener

Re: [MacRuby-devel] Mixing Objective-C and Ruby classes

2009-05-20 Thread Brian Chapados
7;ll try it out tonight and let you know how it >> goes. >> Thanks a lot for walking me through this. >> On Wed, May 20, 2009 at 12:47 PM, Brian Chapados wrote: >>> >>> I'm not sure how you're testing this, but beware of doing this from a >>> c

Re: [MacRuby-devel] Mixing Objective-C and Ruby classes

2009-05-19 Thread Brian Chapados
; -- backtrace of native function call (Use addr2line) -- > 0x10010f2c1 > 0x100029334 > 0x100029418 > 0x1000c240d > 0x7fff803763fa > 0x0 > 0x7fff8108094d > 0x105a31e8c > 0x100121855 > 0x10010af7d > 0x10010074f > 0x1001056e2 > 0x10010596c > 0x100030c96 > 0x100

Re: [MacRuby-devel] Mixing Objective-C and Ruby classes

2009-05-19 Thread Brian Chapados
Those symbols are defined in the Carbon framework. Try compiling with: cc shortcut.m -o shortcut.bundle -g -framework Foundation -framework Carbon -dynamiclib -fobjc-gc -arch i386 -arch x86_64 On Tue, May 19, 2009 at 1:32 PM, isaac kearse wrote: > Hi Guys, > I am writing a hotcocoa app, and I wa

Re: [MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread Brian Chapados
You might have already figured this out, but in case it helps... Be careful not to confuse the TableView delegate with the DataSource delegate. Check out the TableView programming guide: http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/TableView.html You can use two different s

Re: [MacRuby-devel] [hotcocoa] http wrapper, what do you think?

2009-03-30 Thread Brian Chapados
ee with your goal of just making the standard use cases easy. It is nice to have a block right next to the download call, as it is easy to understand the logic. If something requires more complicated handling, then delegate option is always available. Anyway, I'll see if I can make any pr

Re: [MacRuby-devel] [hotcocoa] http wrapper, what do you think?

2009-03-30 Thread Brian Chapados
Seems like a good idea that would be useful even outside of HotCocoa. Especially for simple cases, I think if Obj-C had blocks, this would be a good place to use them. For more control, the delegate pattern actually works really well. It's good that you have a way to do both. Does the delegate obj

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

2009-03-30 Thread Brian Chapados
In this case, you could use the KVC[1] (key-value coding) accessor (#valueForKey:) to access the ivar. class Example def methodB self.valueForKey("instVarB") end end [1]: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html Brian On Mon, Mar

Re: [MacRuby-devel] [MacRuby] #240: no such file to load -- stringio.rb.bundle when starting irb/gems

2009-03-30 Thread Brian Chapados
When you built MacRuby, did you have the RUBYOPT env set? If so, unset it. See the comments for this: http://www.macruby.org/trac/ticket/226#comment:7 Brian On Mon, Mar 30, 2009 at 6:36 AM, MacRuby wrote: > #240: no such file to load -- stringio.rb.bundle when starting irb/gems > -

Re: [MacRuby-devel] Accessing bytes within NSData

2009-03-24 Thread Brian Chapados
Hi Pete, Since you have an NSData object, you should be able to convert it to a String (NSString) and then use unpack. For example: socket_port = NSSocketPort.alloc.initWithTCPPort(1) addr = socket_port.address addr_str = NSString.alloc.initWithData(addr, encoding:NSString.defaultCStringEnco

Re: [MacRuby-devel] Interfacing with C (not objective C)

2009-03-17 Thread Brian Chapados
I think that if you need to make use extensive use of C functions/libraries, then the least painful route is to wrap this functionality in Objective-C classes.  Writing Objective-C classes that call your C code is easier than writing C ruby extensions.  At least in my opinion, this is why MacRuby m

Re: [MacRuby-devel] ruby gems just for MacRuby

2009-03-09 Thread Brian Chapados
If we just need a way to check that we are on MacRuby before loading, we could check that: Object.name == "NSObject" Brian On Mon, Mar 9, 2009 at 5:43 PM, Matt Aimonetti wrote: > Nic, > >  Any suggestions to deal with macruby only gems? I don't think macruby can > be considered a platform so an

Re: [MacRuby-devel] ruby gems just for MacRuby

2009-03-09 Thread Brian Chapados
Unless there is an issue in the library code, usually building for at least ppc/x86 only involves choosing from a drop down in xcode or a few compiler flags on the command line. It shouldn't take much time and is only a few extra bytes. On Mon, Mar 9, 2009 at 2:32 PM, Matt Aimonetti wrote: > Sor

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-03-06 Thread Brian Chapados
ve a pointer to something that looks like an array of longs (and > it seems to satisfy the CGGetActiveDisplayList function). But how is it > possible when everything here is an object and not a series of neatly > aligned bytes ? > Anyway, you are right. The part of Cocoa OpenGL I am porting

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Brian Chapados
= Pointer.ptr To a BOOL? p = Pointer.to(:BOOL) Need the value? p.value Those are the most common types I've needed. On Wed, Feb 25, 2009 at 11:11 AM, Matt Aimonetti wrote: > Brian, what's up with this syntax: info = > Pointer.new_with_type("^{_CGLRendererInfoObject=}")

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Brian Chapados
CGLRendererInfo is a pointer to a struct: typedef struct _CGLRendererInfoObject *CGLRendererInfoObj; try creating a pointer to void or to the struct: info = Pointer.new_with_type("^v") # void *info; or info = Pointer.new_with_type("^{_CGLRendererInfoObject=}") # CGLRendererInfo *info I th

Re: [MacRuby-devel] Using 'Pointer.new_with_type'

2009-02-09 Thread Brian Chapados
mkstemp is defined in the standard C library. To use it, you would need to define a new bridged function in MacRuby on the fly. I don't think there is a way to do this right now. As a work-around, you could wrap the C function calls in methods defined in an Obj-C class and build a framework. The

Re: [MacRuby-devel] Framework callbacks in macirb

2009-02-09 Thread Brian Chapados
It is well worth your time to learn the basics of C and Objective-C, even if your ultimate goal is to mainly use MacRuby (http://www.joelonsoftware.com/articles/LeakyAbstractions.html ect.). They are small languages, and everything you need is covered in about 200 pages[1,2]. The cocoa libraries ar

Re: [MacRuby-devel] Pointer to memory. was: Pointers for BOOL types

2009-01-09 Thread Brian Chapados
If it helps, for CGBitmapContextCreate you just pass NULL ('nil' in MacRuby) for the void *data parameter and let CoreGraphics handle allocating memory. Unless you really need to do the allocation yourself, it is significantly less painful and less error-prone to have it done automatically, especia