Abstract
This paper describes an R package that allows one to read and generate a description of C and C++ source code elements. These descriptions are meta-data about that C/C++ code and can be used for several different purposes. The most obvious application is to programmatically generate bindings/wrappers which are R functions and C routines that allow R users to invoke the original C/C++ routines from within R. We discuss the mechanics of the package and briefly outline one strategy for generating the mappings between R and arbitrary C/C++ code. We also illustrate how we can create new derived C++ classes, some or all of whose methods can be implemented in R via R functions. The meta-data can also be used to generate registration information for R’s dynamic symbol resolution, identify potential re-factoring for the removal of global variables (leading towards thread-safety), and generally collect data for software metrics and analysis. The package currently provides the primitives for reading and working with the meta-data, and has support for generating bindings for most of the common C and C++ constructs. Additional facilities such as determining memory management and computing call graphs from the body of a routine can be built on top of these primitives. Versions of the package are available at http://www.omegahat.org/RGCCTranslationUnit.
Similar content being viewed by others
References
Beazley D et al (1998) SWIG—Simplified Wrapper Interface Generator. http://www.swig.org. Februrary 1998
Fraser C, Hanson D (1995) A retargetable C compiler: design and implementation. Addison-Wesley, USA
Insightful Corporation (2007) S-Plus. http://www.insightful.com
King B (2004) GCC-XML. http://www.gccxml.org. February 2004
Temple Lang D (2000) The RSPerl package for R. http://www.omegahat.org/RSPerl. October 2000
R Development Core Team (2006) Writing R extensions, R foundation for statistical computing, Vienna, Austria, October 2006 (ISBN 3-900051-11-9). http://cran.r-project.org/doc/manuals/R-exts.pdf
R Development Core Team (2008) R: A language and environment for statistical computing. ISBN 3-900051-07-0. http://www.R-project.org
Steffen J, Bröker H-B (2000) cscope. http://cscope.sourceforge.net. April 2000
Stallman RM, Tower L et al (1987) GNU compiler collection. http://gcc.gnu.org
The MathWorks (2007) MATLAB. http://www.mathworks.com/products/matlab
van Rossum G, Drake FL (eds) (2001) Python reference manual. PythonLabs, VA, USA
Winters A (2003) GCC::TranslationUnit Perl Module. http://search.cpan.org/dist/GCC-TranslationUnit. September 2003
Wall L, Christiansen T, Schwartz RL (2000) Programming Perl, 3rd edn. O’Reilly & Associates, Inc, Washington
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
Temple Lang, D. Working with meta-data from C/C++ code in R: the RGCCTranslationUnit package. Comput Stat 24, 283–293 (2009). https://doi.org/10.1007/s00180-008-0128-6
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00180-008-0128-6