Charlie Friedemann
2012-Jun-06 03:27 UTC
[Rd] tcltk wish: Add tclObj.raw method for converting raw vectors to tclObj
Greetings, I have submitted a bug report / wish to the R Bug tracker (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14939), but I'd like to make this request here as well. Essentially, I was wondering if it would be possible to add another c routine to be called by as.TclObj for raw vectors. Right now, as.raw() is supported for objects of type "tclObj" (IIRC this change was made in 2.9 after someone requested it), however there is no corresponding C routine for converting raw vectors into tclObj. I suppose the best way to do this is to create a new C routine in the tcltk package analogous to the other RObject to Tcl object routines: RTcl_ObjFromRawVector. Create a new tclObj pointer, use Tcl_NewByteArrayObj() from the Tcl C API to create a byte array of the same length as the input raw vector, and then loop through the RAWSXP object assigning each element in the vector to the Tcl byte array. I'd be happy to submit code for this patch if requested. This would be extremely helpful. I am using tcl binary sockets and this functionality would allow me to both read and write raw vectors directly from/to Tcl. I can only read raw vectors directly at the moment and have to use strings to get a raw vector into Tcl. There's also the possibility that this has been attempted and for some reason it didn't work, but I don't know why that would be the case. Thank you for your consideration! Regards, Charlie
Charlie F
2012-Jun-14 01:52 UTC
[Rd] tcltk wish: Add tclObj.raw method for converting raw vectors to tclObj
I have added a proposed patch to the bug report I opened earlier. It can be found here: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14939 A recent version of R-devel modified with this patch builds and checks successfully for me on a i686-pc-linux-gnu (32-bit) system. I don't see why this wouldn't work on other builds as it only modifies some of the tcltk source, and only adds a new routine at that. Regards, Charlie -- View this message in context: http://r.789695.n4.nabble.com/tcltk-wish-Add-tclObj-raw-method-for-converting-raw-vectors-to-tclObj-tp4632511p4633320.html Sent from the R devel mailing list archive at Nabble.com.