A diff against R-devel to allow Objective-C source in R packages. Yes, its basically trivial :-) -------------- next part -------------- A non-text attachment was scrubbed... Name: ObjC.diff Type: application/octet-stream Size: 1547 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20041030/2c9e7855/ObjC.obj -------------- next part -------------- --- Byron Ellis (ellis@stat.harvard.edu) "Oook" -- The Librarian
patch for Obj-C building in R
2 messages · Byron Ellis, Simon Urbanek
I have put together a small and crude package that allows you to send messages to Obj-C objects and classes and create references to objects, classes and selectors. For historical reasons it's called Cocoa (although Obj-C is strictly speaking not Cocoa) and you can get it from my nightly builds page ( http://www.rosuda.org/R/nightly/ ). It is interesting only for developers as it's only the first step in a complete Obj-C/R suite, but since some people seemed to be interested in this, I thought I share it here. Some (admittedly stupid) examples: # Class sc = [NSString class] > sc<-.MCall("NSString","class") > sc Obj-C class: NSString # NSString *s = [NSString stringWithString:@"hello"] > s <- .MCall("NSString","stringWithString:","hello") > s hello # [s stringByAppendingString: @" World!") > s2 <- .MCall(s, "stringByAppendingString:", " World!") > s2 hello World! # [s respondsToSelector: @selector(length)] > .MCall(s, "respondsToSelector:", .MSelector("length")) [1] TRUE (the M is front of the calls was motivated by the .m extension of Obj-C code) and if you use Cocoa inside R.app you can do many stupid things like: c<-.MCall("RController", "getRController") .MCall(c, "toggleHistory:", c) Currently only boolean, id and Class results are supported and only strings are automatically converted to NSString as arguments. Main work to be done now is the support for scalar types, especially Cocoa-native types like NSRange and so on. Anyone interested in this is welcome to enhance the code ... Comments are very welcome, too. But again, this is just a draft - no documentation, no guarantees ;). Cheers, Simon