[R-SIG-Mac] cocoa packages
Byron Ellis
bellis at hsph.harvard.edu
Tue Oct 26 21:35:50 CEST 2004
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:
> 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:
>
>> 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 at stat.harvard.edu)
>> "Oook" -- The Librarian
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>
>>
> ===
> 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 at 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
>
> -----------------------------------------------------------------------
> --------------------------
>
>
---
Byron Ellis (ellis at stat.harvard.edu)
"Oook" -- The Librarian
More information about the R-SIG-Mac
mailing list