[Rcpp-commits] r1407 - in pkg/Rcpp: R inst man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 3 09:52:58 CEST 2010


Author: romain
Date: 2010-06-03 09:52:53 +0200 (Thu, 03 Jun 2010)
New Revision: 1407

Modified:
   pkg/Rcpp/R/Module.R
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/man/CppClass-class.Rd
   pkg/Rcpp/man/CppObject-class.Rd
   pkg/Rcpp/src/RcppCommon.cpp
Log:
adding show methods for C++Class and C++Object

Modified: pkg/Rcpp/R/Module.R
===================================================================
--- pkg/Rcpp/R/Module.R	2010-06-02 19:53:47 UTC (rev 1406)
+++ pkg/Rcpp/R/Module.R	2010-06-03 07:52:53 UTC (rev 1407)
@@ -182,3 +182,25 @@
 	invisible(NULL)
 } )
 
+setMethod( "show", "C++Object", function(object){
+	txt <- sprintf( "C++ object <%s> of class '%s' <%s>", 
+		externalptr_address(object at pointer), 
+		.Call( "Class__name", object at cppclass, PACKAGE = "Rcpp" ), 
+		externalptr_address(object at cppclass)
+	)
+	writeLines( txt )
+} )
+
+setMethod( "show", "C++Class", function(object){
+	txt <- sprintf( "C++ class '%s' <%s>", 
+		.Call( "Class__name", object at pointer, PACKAGE = "Rcpp" ), 
+		externalptr_address(object at pointer) )
+	writeLines( txt )
+	
+	met <- .Call( "CppClass__methods", object at pointer, PACKAGE = "Rcpp" )
+	if( length( met ) ){
+		txt <- sprintf( "\n%d methods : \n%s", length(met), paste( sprintf("    %s", met), collapse = "\n") )
+		writeLines( txt )
+	}
+} )
+

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-06-02 19:53:47 UTC (rev 1406)
+++ pkg/Rcpp/inst/ChangeLog	2010-06-03 07:52:53 UTC (rev 1407)
@@ -1,3 +1,7 @@
+2010-06-03  Romain Francois <romain at r-enthusiasts.com>
+
+	* src/RcppCommn.cpp: added show method for C++Object and C++Class
+
 2010-06-02  Romain Francois <romain at r-enthusiasts.com>
 
 	* inst/include/Rcpp/traits/r_type_traits.h: added missing support for

Modified: pkg/Rcpp/man/CppClass-class.Rd
===================================================================
--- pkg/Rcpp/man/CppClass-class.Rd	2010-06-02 19:53:47 UTC (rev 1406)
+++ pkg/Rcpp/man/CppClass-class.Rd	2010-06-03 07:52:53 UTC (rev 1407)
@@ -3,6 +3,7 @@
 \docType{class}
 \alias{C++Class-class}
 \alias{new,C++Class-method}
+\alias{show,C++Class-method}
 
 \title{Reflection information for an internal c++ class}
 \description{
@@ -24,6 +25,7 @@
     of this class using its default constructor. This creates
     instances of the class \linkS4class{"C++Object"}
     }
+    \item{show}{\code{signature(object = "C++Class")}: prints the class. }
 	 }
 }
 \keyword{classes}

Modified: pkg/Rcpp/man/CppObject-class.Rd
===================================================================
--- pkg/Rcpp/man/CppObject-class.Rd	2010-06-02 19:53:47 UTC (rev 1406)
+++ pkg/Rcpp/man/CppObject-class.Rd	2010-06-03 07:52:53 UTC (rev 1407)
@@ -3,6 +3,7 @@
 \docType{class}
 \alias{C++Object-class}
 \alias{$,C++Object-method}
+\alias{show,C++Object-method}
 
 \title{c++ internal objects}
 \description{
@@ -27,6 +28,7 @@
 \section{Methods}{
   \describe{
     \item{$}{\code{signature(x = "C++Object")}: invokes a method on the object }
+	\item{show}{\code{signature(object = "C++Object")}: print the object }
 	 }
 }
 \keyword{classes}

Modified: pkg/Rcpp/src/RcppCommon.cpp
===================================================================
--- pkg/Rcpp/src/RcppCommon.cpp	2010-06-02 19:53:47 UTC (rev 1406)
+++ pkg/Rcpp/src/RcppCommon.cpp	2010-06-03 07:52:53 UTC (rev 1407)
@@ -201,7 +201,7 @@
 
 SEXP as_character_externalptr(SEXP xp){
 	char buffer[20] ;
-	sprintf( buffer, "<%p>", EXTPTR_PTR(x) ) ;
-	return wrap( (const char*)buffer ) ;
+	sprintf( buffer, "%p", EXTPTR_PTR(xp) ) ;
+	return Rcpp::wrap( (const char*)buffer ) ;
 }
 



More information about the Rcpp-commits mailing list