Skip to content

cocoa packages

5 messages · Jan de Leeuw, stefano iacus, Byron Ellis +1 more

#
Hi all, a bit inspired this evening. Managed (with a small change to 
SHLIB and INSTALL to make it recognize .m files) to successfully build 
a small proof-of-concept package that

1) installs some extra menus (and items) into the main menu bar
2) attach those menu items to a controller object inside the package
3) locate and instantiate a NIB located within the package in response 
to a menu call.

Its very simple code, email me and I'll send you the somewhat ugly 
package as it stands (it ain't pretty).

I think it could be useful for adding S-PLUS-like functionality to the 
R GUI. Maybe for use in things like introductory statistics courses (or 
Computational Biology courses). On the whole, a lot prettier than 
Tcl/Tk and with some more work we could probably write selector targets 
in R (a la CamelBones or PyObjC).

Its 4am, good night

(BTW, Stefano, I was working on adding the navigation buttons when this 
occurred to me. I promise :-) )


---
Byron Ellis (ellis@stat.harvard.edu)
"Oook" -- The Librarian
#
That's good news. One way to get rid of the remaining vestiges of X11  
is to
get rid of Tcl/Tk alltogether and allow people to write interfaces to  
packages
in Cocoa (with a Cocoa Rcmdr as an extreme version). I have been
asking Duncan for RObjC or RCocoa, and at some point in time there
actually was some form of RObjC, but it got lost in the intricate mazes  
of the
Omega project.
On Oct 26, 2004, at 4:02 AM, Byron Ellis wrote:

            
===
Jan de Leeuw; Distinguished Professor and Chair, UCLA Department of  
Statistics;
Editor: Journal of Multivariate Analysis, Journal of Statistical  
Software
US mail: 8125 Math Sciences Bldg, Box 951554, Los Angeles, CA 90095-1554
phone (310)-825-9550;  fax (310)-206-5658;  email: deleeuw@stat.ucla.edu
homepage: http://gifi.stat.ucla.edu
   
------------------------------------------------------------------------ 
-------------------------
           No matter where you go, there you are. --- Buckaroo Banzai
                    http://gifi.stat.ucla.edu/sounds/nomatter.au
#
Or once iWidgets comes to Cocoa which I think is the plan (Simon?)
stefano
On Oct 26, 2004, at 5:36 PM, Jan de Leeuw wrote:

            
#
Or something similar. Unlike RCmdr we're not constrained by the  
limitations of Tcl/Tk so similar functionality can be integrated more  
smoothly into the GUI (though having a Best Practices library for that  
sort of thing would probably be a good idea---rules for playing nice  
wrt menus and what not). And, being Obj-C based, packages can do  
basically whatever they want (poseAsClass: anyone?).


re: R<->Obj-C

Off the top of my head, I might do something like this:

SEXP CreateObjCFunction(SEXP selector) {
	SEL s = sel_registerMethod(CHAR(STRING_ELT(selector,0)));
	NSInvocation *invoker= [NSInvocation
		invocationWithMethodSignature:[NSObject  
instanceMethodSignatureForSelector:s]];
	[invoker setSelector:s];
	return WRAP_NSINVOCATION_IN_SEXP(invoker);
}

to create, effectively function objects that are then invoked by

SEXP Invoke(SEXP nsinv,SEXP target,SEXP args) {
	NSInvocation *invoker = INVOCATION_FROM_SEXP(nsinv);
	int i;
	for(i=0;i<[[invoker methodSignature] numberOfArguments]-2;i++) {
		/* Do setArgument with appropriate SEXP conversion here */
		/* setArgument:... atIndex:i+2 */
	}
	return ObjCToSEXP([invoker invokeWithTarget:SEXP_TO_ID(target)]);
}

As usual, the big hurdle is type coercion, ObjC<->SEXP... Though Simon  
has already done a fair amount of that work.

Maybe now that I'm back on the Left Side we should visit Duncan  
sometime. :-)
On Oct 26, 2004, at 8:36 AM, Jan de Leeuw wrote:

            
---
Byron Ellis (ellis@stat.harvard.edu)
"Oook" -- The Librarian
#
On Oct 26, 2004, at 1:02 PM, Byron Ellis wrote:

            
I agree that replacing tcl/tk is long overdue. You may have a look at 
the iWidgets package - I was trying to define a platform- and 
toolkit-independent API for widgets with that. It is implemented in 
Java and works on most platforms, but it would be great to have a Cocoa 
package with the same functionality and same API. The big thing then 
would be that you can actually use the same R code on any platform - on 
Mac it would happen to be Cocoa based. iWidgets come bundled with JGR ( 
http://www.rosuda.org/JGR/ ) if you want to run the demos, but you can 
also download the sources from our R repository ( 
http://www.rosuda.org/R/ ).

As of the Obj-C glue, well, you said it ;) It's not rocket science, 
just a lot of work ... I have very little time atm, but I may have a 
quiet minute this weekend to polish the REngine code ...

Cheers,
Simon