[Rcpp-commits] r3967 - in pkg/Rcpp: . R inst/include/Rcpp inst/include/Rcpp/module man src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 14 17:25:05 CET 2012
Author: romain
Date: 2012-11-14 17:25:05 +0100 (Wed, 14 Nov 2012)
New Revision: 3967
Added:
pkg/Rcpp/inst/include/Rcpp/module/class_Base.h
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/R/00_classes.R
pkg/Rcpp/inst/include/Rcpp/Module.h
pkg/Rcpp/inst/include/Rcpp/module/class.h
pkg/Rcpp/man/CppClass-class.Rd
pkg/Rcpp/src/Module.cpp
Log:
list of parent classes
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/ChangeLog 2012-11-14 16:25:05 UTC (rev 3967)
@@ -6,6 +6,10 @@
2012-11-14 Romain Francois <romain at r-enthusiasts.com>
* include/Rcpp/internal/wrap.h: fix for wrap( std::complex<double> )
+ * include/Rcpp/module/class_Base.h: factored out from Module.h
+ * R/00_classes.R: the C++Class gains the parents slot to hold information
+ about parent classes of the class
+ * src/Module.cpp : The CppClass constructor fills the parents slot of C++Class
2012-11-13 Dirk Eddelbuettel <edd at debian.org>
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/DESCRIPTION 2012-11-14 16:25:05 UTC (rev 3967)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Seamless R and C++ Integration
-Version: 0.10.0
+Version: 0.10.0.1
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Douglas Bates, John Chambers and JJ Allaire
Modified: pkg/Rcpp/R/00_classes.R
===================================================================
--- pkg/Rcpp/R/00_classes.R 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/R/00_classes.R 2012-11-14 16:25:05 UTC (rev 3967)
@@ -79,7 +79,8 @@
generator = "refGenerator",
docstring = "character",
typeid = "character",
- enums = "list"
+ enums = "list",
+ parents = "character"
),
contains = "character"
)
Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h 2012-11-14 16:25:05 UTC (rev 3967)
@@ -87,71 +87,7 @@
// templates CppFunction0, ..., CppFunction65
#include <Rcpp/module/Module_generated_CppFunction.h>
-
- class class_Base {
- public:
- class_Base() : name(), docstring() {} ;
- class_Base(const char* name_, const char* doc) :
- name(name_), docstring( doc == 0 ? "" : doc ), enums() {} ;
-
- virtual Rcpp::List fields(SEXP){ return Rcpp::List(0); }
- virtual Rcpp::List getMethods(SEXP, std::string&){ return Rcpp::List(0); }
- virtual Rcpp::List getConstructors(SEXP, std::string&){ return Rcpp::List(0); }
-
- virtual void run_finalizer(SEXP){ }
-
- virtual bool has_default_constructor(){ return false ; }
- virtual bool has_method( const std::string& ){
- return false ;
- }
- virtual bool has_property( const std::string& ) {
- return false ;
- }
- virtual SEXP newInstance(SEXP *, int){
- return R_NilValue;
- }
- virtual SEXP invoke( SEXP, SEXP, SEXP *, int ){
- return R_NilValue ;
- }
- virtual SEXP invoke_void( SEXP, SEXP, SEXP *, int ){
- return R_NilValue ;
- }
- virtual SEXP invoke_notvoid( SEXP, SEXP, SEXP *, int ){
- return R_NilValue ;
- }
-
- virtual Rcpp::CharacterVector method_names(){ return Rcpp::CharacterVector(0) ; }
- virtual Rcpp::CharacterVector property_names(){ return Rcpp::CharacterVector(0) ; }
- virtual bool property_is_readonly(const std::string& ) { return false ; }
- virtual std::string property_class(const std::string& ) { return "" ; }
- virtual Rcpp::IntegerVector methods_arity(){ return Rcpp::IntegerVector(0) ; }
- virtual Rcpp::LogicalVector methods_voidness(){ return Rcpp::LogicalVector(0); }
- virtual Rcpp::List property_classes(){ return Rcpp::List(0); }
-
- virtual Rcpp::CharacterVector complete(){ return Rcpp::CharacterVector(0) ; }
- virtual ~class_Base(){}
-
- virtual SEXP getProperty( SEXP, SEXP ) {
- throw std::range_error( "cannot retrieve property" ) ;
- }
- virtual void setProperty( SEXP, SEXP, SEXP) {
- throw std::range_error( "cannot set property" ) ;
- }
- virtual std::string get_typeinfo_name(){ return "" ; }
- bool has_typeinfo_name( const std::string& name_ ){
- return get_typeinfo_name().compare(name_) == 0;
- }
- void add_enum( const std::string& enum_name, const std::map<std::string, int>& value ) ;
-
- std::string name ;
- std::string docstring ;
-
- typedef std::map< std::string, int > ENUM ;
- typedef std::map< std::string, ENUM > ENUM_MAP ;
- typedef ENUM_MAP::value_type ENUM_MAP_PAIR ;
- ENUM_MAP enums ;
-
- } ;
+#include <Rcpp/module/class_Base.h>
#include <Rcpp/module/Module.h>
}
extern "C" Rcpp::Module* getCurrentScope() ;
Modified: pkg/Rcpp/inst/include/Rcpp/module/class.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/class.h 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/inst/include/Rcpp/module/class.h 2012-11-14 16:25:05 UTC (rev 3967)
@@ -448,6 +448,7 @@
self* class_pointer ;
std::string typeinfo_name ;
+
class_( ) : class_Base(), vec_methods(), properties(), specials(0), constructors(), factories() {};
@@ -499,6 +500,8 @@
) ;
}
+ std::string buffer( "Rcpp_" ) ; buffer += parent ;
+ class_pointer->parents.push_back( buffer.c_str() ) ;
return *this ;
}
Added: pkg/Rcpp/inst/include/Rcpp/module/class_Base.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/class_Base.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/module/class_Base.h 2012-11-14 16:25:05 UTC (rev 3967)
@@ -0,0 +1,89 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// class_Base.h: Rcpp R/C++ interface class library -- Rcpp modules
+//
+// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp_Module_Class_Base_h
+
+class class_Base {
+public:
+ class_Base() : name(), docstring(), enums(), parents() {} ;
+ class_Base(const char* name_, const char* doc) :
+ name(name_), docstring( doc == 0 ? "" : doc ), enums(), parents() {} ;
+
+ virtual Rcpp::List fields(SEXP){ return Rcpp::List(0); }
+ virtual Rcpp::List getMethods(SEXP, std::string&){ return Rcpp::List(0); }
+ virtual Rcpp::List getConstructors(SEXP, std::string&){ return Rcpp::List(0); }
+
+ virtual void run_finalizer(SEXP){ }
+
+ virtual bool has_default_constructor(){ return false ; }
+ virtual bool has_method( const std::string& ){
+ return false ;
+ }
+ virtual bool has_property( const std::string& ) {
+ return false ;
+ }
+ virtual SEXP newInstance(SEXP *, int){
+ return R_NilValue;
+ }
+ virtual SEXP invoke( SEXP, SEXP, SEXP *, int ){
+ return R_NilValue ;
+ }
+ virtual SEXP invoke_void( SEXP, SEXP, SEXP *, int ){
+ return R_NilValue ;
+ }
+ virtual SEXP invoke_notvoid( SEXP, SEXP, SEXP *, int ){
+ return R_NilValue ;
+ }
+
+ virtual Rcpp::CharacterVector method_names(){ return Rcpp::CharacterVector(0) ; }
+ virtual Rcpp::CharacterVector property_names(){ return Rcpp::CharacterVector(0) ; }
+ virtual bool property_is_readonly(const std::string& ) { return false ; }
+ virtual std::string property_class(const std::string& ) { return "" ; }
+ virtual Rcpp::IntegerVector methods_arity(){ return Rcpp::IntegerVector(0) ; }
+ virtual Rcpp::LogicalVector methods_voidness(){ return Rcpp::LogicalVector(0); }
+ virtual Rcpp::List property_classes(){ return Rcpp::List(0); }
+
+ virtual Rcpp::CharacterVector complete(){ return Rcpp::CharacterVector(0) ; }
+ virtual ~class_Base(){}
+
+ virtual SEXP getProperty( SEXP, SEXP ) {
+ throw std::range_error( "cannot retrieve property" ) ;
+ }
+ virtual void setProperty( SEXP, SEXP, SEXP) {
+ throw std::range_error( "cannot set property" ) ;
+ }
+ virtual std::string get_typeinfo_name(){ return "" ; }
+ bool has_typeinfo_name( const std::string& name_ ){
+ return get_typeinfo_name().compare(name_) == 0;
+ }
+ void add_enum( const std::string& enum_name, const std::map<std::string, int>& value ) ;
+
+ std::string name ;
+ std::string docstring ;
+
+ typedef std::map< std::string, int > ENUM ;
+ typedef std::map< std::string, ENUM > ENUM_MAP ;
+ typedef ENUM_MAP::value_type ENUM_MAP_PAIR ;
+ ENUM_MAP enums ;
+ std::vector<std::string> parents ;
+
+} ;
+#endif
Modified: pkg/Rcpp/man/CppClass-class.Rd
===================================================================
--- pkg/Rcpp/man/CppClass-class.Rd 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/man/CppClass-class.Rd 2012-11-14 16:25:05 UTC (rev 3967)
@@ -25,6 +25,7 @@
\item{docstring}{description of the class}
\item{typeid}{unmangled typeid of the class}
\item{enums}{enums of the class}
+ \item{parents}{names of the parent classes of this class}
}
}
\section{Methods}{
Modified: pkg/Rcpp/src/Module.cpp
===================================================================
--- pkg/Rcpp/src/Module.cpp 2012-11-14 14:39:39 UTC (rev 3966)
+++ pkg/Rcpp/src/Module.cpp 2012-11-14 16:25:05 UTC (rev 3967)
@@ -415,7 +415,7 @@
void class_Base::add_enum( const std::string& enum_name, const std::map<std::string, int>& value ){
enums.insert( ENUM_MAP_PAIR( enum_name, value ) ) ;
}
-
+
CppClass::CppClass( SEXP x) : S4(x){}
CppClass::CppClass( Module* p, class_Base* cl, std::string& buffer ) : S4("C++Class") {
@@ -434,6 +434,7 @@
slot( "docstring" ) = cl->docstring ;
slot( "typeid" ) = cl->get_typeinfo_name() ;
slot( "enums" ) = cl->enums ;
+ slot( "parents" ) = cl->parents ;
}
CppObject::CppObject( Module* p, class_Base* clazz, SEXP xp ) : S4("C++Object") {
More information about the Rcpp-commits
mailing list