31 template <
typename FROM,
typename TO>
33 std::string method_name(
".___converter___" ) ;
36 method_name +=
"Rcpp_" ;
39 method_name +=
"___" ;
42 method_name +=
"Rcpp_" ;
59 operator T*(){
return ptr ; }
69 operator T*(){
return ptr ; }
76 template <
typename Class>
80 return maker(
typeid(Class).name() , xp ) ;
88 #include <Rcpp/module/Module_generated_get_signature.h>
91 #include <Rcpp/module/Module_generated_CppFunction.h>
97 template <
typename Class>
103 virtual SEXP
operator()(Class* , SEXP* ) {
return R_NilValue ; }
108 virtual void signature(std::string& s,
const char* name ){ s = name ; }
111 template <
typename Class,
typename Parent>
133 #include <Rcpp/module/Module_generated_ctor_signature.h>
134 #include <Rcpp/module/Module_generated_Constructor.h>
135 #include <Rcpp/module/Module_generated_Factory.h>
137 #include <Rcpp/module/Module_generated_class_signature.h>
142 template <
typename Class>
147 Constructor_Base<Class>* ctor_,
152 Constructor_Base<Class>*
ctor ;
157 inline void signature(std::string& buffer,
const std::string& class_name){
158 ctor->signature(buffer, class_name) ;
162 template <
typename Class>
167 Factory_Base<Class>* fact_,
177 inline void signature(std::string& buffer,
const std::string& class_name){
178 fact->signature(buffer, class_name) ;
183 template <
typename Class>
196 inline void signature(std::string& s,
const char* name){
202 template <
typename Class>
210 RCPP_DEBUG(
"S4_CppConstructor( SignedConstructor<Class>* m, SEXP class_xp, const std::string& class_name, std::string& buffer" ) ;
212 field(
"class_pointer" ) = class_xp ;
215 field(
"signature" ) = buffer ;
223 template <
typename Class>
237 for(
int i=0; i<n; i++){
239 nargs[i] = met->
nargs() ;
244 signatures[i] = buffer ;
248 field(
"class_pointer" ) = class_xp ;
249 field(
"size" ) = n ;
250 field(
"void" ) = voidness ;
251 field(
"const" ) = constness ;
252 field(
"docstrings" ) = docstrings ;
253 field(
"signatures" ) = signatures ;
254 field(
"nargs" ) = nargs ;
262 #include <Rcpp/module/Module_generated_CppMethod.h>
263 #include <Rcpp/module/Module_generated_Pointer_CppMethod.h>
265 template <
typename Class>
272 virtual SEXP
get(Class* ) {
throw std::range_error(
"cannot retrieve property"); }
273 virtual void set(Class*, SEXP) {
throw std::range_error(
"cannot set property"); }
280 template <
typename Class,
typename Parent>
299 template <
typename Class>
303 virtual void run(Class* ){} ;
306 template <
typename Class>
312 virtual void run(Class*
object){
320 template <
typename Class>
326 RCPP_DEBUG(
"S4_field( CppProperty<Class>* p, const XP_Class& class_xp )" )
330 field(
"class_pointer" ) = class_xp ;
342 template <
typename Enum,
typename Parent>
355 self&
value(
const char* name_, Enum value_ ){
356 values.insert(
PAIR( name_,
static_cast<int>( value_ ) ) ) ;
363 typedef std::map< std::string, int >
MAP ;
372 #include <Rcpp/module/Module_generated_function.h>
376 template <
typename FROM,
typename TO>
377 void converter(
const char* from,
const char* to, TO (*fun)(FROM),
const char* docstring = 0 ){
378 std::string fun_name = internal::get_converter_name<FROM,TO>( from, to ) ;
379 function( fun_name.c_str(), fun, docstring ) ;
390 XP_Class clxp( cl,
false, R_NilValue, R_NilValue ) ;
391 slot(
"module" ) =
XP( p,
false ) ;
392 slot(
"pointer" ) = clxp ;
396 slot(
".Data" ) = buffer ;
398 slot(
"fields" ) = cl->
fields( clxp ) ;
400 slot(
"methods" ) = cl->
getMethods( clxp, buffer ) ;
404 slot(
"enums" ) = cl->
enums ;
405 slot(
"parents" ) = cl->
parents ;
417 slot(
"module" ) =
XP( p,
false ) ;
419 slot(
"pointer" ) = xp ;
426 #define RCPP_MODULE_BOOT(name) _rcpp_module_boot_##name
428 #define RCPP_MODULE(name) \
429 void _rcpp_module_##name##_init() ; \
430 static Rcpp::Module _rcpp_module_##name( # name ) ; \
431 extern "C" SEXP _rcpp_module_boot_##name(){ \
432 ::setCurrentScope( & _rcpp_module_##name ) ; \
433 _rcpp_module_##name##_init( ) ; \
434 Rcpp::XPtr<Rcpp::Module> mod_xp(& _rcpp_module_##name , false); \
435 ::setCurrentScope( 0 ) ; \
438 void _rcpp_module_##name##_init()
442 #define VARIABLE_IS_NOT_USED __attribute__ ((unused))
444 #define VARIABLE_IS_NOT_USED
452 #define GET_MODULE_SYM ( moduleSym == NULL ? moduleSym = Rf_install("Module") : moduleSym )
455 #define LOAD_RCPP_MODULE(NAME) \
456 Shield<SEXP> __load_module_call__( Rf_lang2( GET_MODULE_SYM, _rcpp_module_boot_##NAME() ) ); \
457 Rcpp_fast_eval( __load_module_call__, R_GlobalEnv );
#define VARIABLE_IS_NOT_USED
static VARIABLE_IS_NOT_USED SEXP moduleSym
self & field(const char *name_, T Class::*ptr, const char *docstring=0)
Rcpp::XPtr< Rcpp::Module > XP
CppClass(Module *p, class_Base *cl, std::string &buffer)
XPtr< class_Base > XP_Class
virtual void run(Class *)
CppInheritedMethod(ParentMethod *parent_method_pointer_)
ParentMethod * parent_method_pointer
SEXP operator()(Class *object, SEXP *args)
CppMethod< Parent > ParentMethod
void signature(std::string &s, const char *name)
CppProperty< Class > Base
void set(Class *obj, SEXP s)
CppInheritedProperty(CppProperty< Parent > *parent_property_)
CppProperty< Parent > * parent_property
virtual void signature(std::string &s, const char *name)
virtual SEXP operator()(Class *, SEXP *)
CppObject(Module *p, class_Base *clazz, SEXP xp)
Rcpp::XPtr< Rcpp::Module > XP
CppProperty(const char *doc=0)
virtual SEXP get(Class *)
virtual bool is_readonly()
virtual std::string get_class()
virtual void set(Class *, SEXP)
FunctionFinalizer(Pointer p)
virtual void run(Class *object)
void add_enum(const std::string &parent_class_typeinfo_name, const std::string &enum_name, const std::map< std::string, int > &value)
Reference::Storage Storage
XPtr< class_Base > XP_Class
S4_CppConstructor(SignedConstructor< Class > *m, const XP_Class &class_xp, const std::string &class_name, std::string &buffer)
S4_CppOverloadedMethods(vec_signed_method *m, const XP_Class &class_xp, const char *name, std::string &buffer)
std::vector< signed_method_class * > vec_signed_method
SignedMethod< Class > signed_method_class
Rcpp::XPtr< class_Base > XP_Class
XPtr< class_Base > XP_Class
S4_field(CppProperty< Class > *p, const XP_Class &class_xp)
void signature(std::string &buffer, const std::string &class_name)
Constructor_Base< Class > * ctor
SignedConstructor(Constructor_Base< Class > *ctor_, ValidConstructor valid_, const char *doc)
void signature(std::string &buffer, const std::string &class_name)
SignedFactory(Factory_Base< Class > *fact_, ValidConstructor valid_, const char *doc)
Factory_Base< Class > * fact
void signature(std::string &s, const char *name)
SignedMethod(METHOD *m, ValidMethod valid_, const char *doc)
CppMethod< Class > METHOD
virtual std::string get_typeinfo_name()
virtual Rcpp::List getConstructors(const XP_Class &, std::string &)
virtual Rcpp::List fields(const XP_Class &)
virtual Rcpp::List getMethods(const XP_Class &, std::string &)
std::vector< std::string > parents
std::map< std::string, int > MAP
self & value(const char *name_, Enum value_)
std::string parent_typeinfo_name
enum_< Enum, Parent > self
#define RCPP_CTOR_ASSIGN_WITH_BASE(__CLASS__)
SEXP make_new_object(Class *ptr)
std::string get_converter_name(const char *from, const char *to)
Function_Impl< PreserveStorage > Function
bool(* ValidConstructor)(SEXP *, int)
void converter(const char *from, const char *to, TO(*fun)(FROM), const char *docstring=0)
bool(* ValidMethod)(SEXP *, int)
static Environment_Impl Rcpp_namespace()
Reference_Impl< PreserveStorage > Reference
S4_Impl< PreserveStorage > S4
attribute_hidden Rcpp::Module * getCurrentScope()