Rcpp Version 1.1.2
Loading...
Searching...
No Matches
Module.h
Go to the documentation of this file.
1
2// Module.h: Rcpp R/C++ interface class library -- Rcpp modules
3//
4// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois
5//
6// This file is part of Rcpp.
7//
8// Rcpp is free software: you can redistribute it and/or modify it
9// under the terms of the GNU General Public License as published by
10// the Free Software Foundation, either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rcpp is distributed in the hope that it will be useful, but
14// WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20
21#ifndef Rcpp_Module_h
22#define Rcpp_Module_h
24#include <Rcpp/config.h>
25#include <Rcpp/internal/call.h>
27namespace Rcpp{
29 namespace internal{
31 template <typename FROM, typename TO>
32 std::string get_converter_name(const char* from, const char* to){
33 std::string method_name( ".___converter___" ) ;
36 method_name += "Rcpp_" ;
37 }
38 method_name += from ;
39 method_name += "___" ;
42 method_name += "Rcpp_" ;
43 }
44 method_name += to ;
45
46 return method_name ;
47 }
50 }
52 class CppClass ;
53 class CppObject ;
55 template <typename T>
56 class result {
57 public:
58 result( T* ptr_ ) : ptr(ptr_){}
59 operator T*(){ return ptr ; }
60 private:
61 T* ptr;
62 } ;
64 template <typename T>
65 class object {
66 public:
67 typedef T object_type ;
68 object( T* ptr_ ) : ptr(ptr_){}
69 operator T*(){ return ptr ; }
70 T* operator->(){ return ptr ; }
71 T& operator&(){ return *ptr ; }
72 T* ptr ;
73 } ;
75 namespace internal {
76 template <typename Class>
77 SEXP make_new_object( Class* ptr ){
78 Rcpp::XPtr<Class> xp( ptr, true ) ;
79 Function maker = Environment::Rcpp_namespace()[ "cpp_object_maker"] ;
80 return maker( typeid(Class).name() , xp ) ;
81 }
82 }
83
84}
88
89namespace Rcpp {
90 template <typename RESULT_TYPE, typename... T>
91 inline void signature(std::string& s, const char* name) {
92 s.clear();
93 s += get_return_type<RESULT_TYPE>() + " " + name + "(";
94 int n = sizeof...(T);
95 int i = 0;
96 // Using initializer list as c++11 implementation of a fold expression
97 (void)std::initializer_list<int>{
98 (s += get_return_type<T>(), s += (++i == n ? "" : ", "), 0)... };
99 s += ")";
102 template <typename RESULT_TYPE, typename... T>
103 class CppFunctionN : public CppFunction {
104 public:
105 CppFunctionN(RESULT_TYPE (*fun)(T...), const char* docstring = 0) : CppFunction(docstring), ptr_fun(fun) {}
106
107 SEXP operator()(SEXP* args) {
109 return call<decltype(ptr_fun), RESULT_TYPE, T...>(ptr_fun, args);
113 inline int nargs() { return sizeof...(T); }
114 inline bool is_void() { return std::is_void<RESULT_TYPE>::value; }
115 inline void signature(std::string& s, const char* name) { Rcpp::signature<RESULT_TYPE, T...>(s, name); }
116 inline DL_FUNC get_function_ptr() { return (DL_FUNC)ptr_fun; }
117
118 private:
119 RESULT_TYPE (*ptr_fun)(T...);
120 };
121
122 template <typename RESULT_TYPE, typename... T>
123 class CppFunction_WithFormalsN : public CppFunctionN<RESULT_TYPE, T...> {
124 public:
125 CppFunction_WithFormalsN(RESULT_TYPE (*fun)(T...), Rcpp::List formals_, const char* docstring = 0) :
126 CppFunctionN<RESULT_TYPE, T...>(fun, docstring), formals(formals_) {}
128 SEXP get_formals() { return formals; }
129
130 private:
132 };
133}
134
138namespace Rcpp{
139
140 template <typename Class>
141 class CppMethod {
142 public:
144
146 virtual SEXP operator()(Class* /*object*/, SEXP* /*args*/) { return R_NilValue ; }
147 virtual ~CppMethod(){}
148 virtual int nargs(){ return 0 ; }
149 virtual bool is_void(){ return false ; }
150 virtual bool is_const(){ return false ; }
151 virtual void signature(std::string& s, const char* name ){ s = name ; }
152 } ;
153
154 template <typename Class, typename Parent>
155 class CppInheritedMethod : public CppMethod<Class> {
156 public:
160 CppInheritedMethod( ParentMethod* parent_method_pointer_ ) :
161 parent_method_pointer(parent_method_pointer_)
162 {}
163
164 SEXP operator()( Class* object, SEXP* args){
165 return (*parent_method_pointer)( (Parent*)object, args ) ;
167 inline int nargs(){ return parent_method_pointer->nargs() ; }
168 inline bool is_void(){ return parent_method_pointer->is_void() ; }
169 inline bool is_const(){ return parent_method_pointer->is_const() ; }
170 inline void signature(std::string& s, const char* name){ return parent_method_pointer->signature(s, name) ; }
172 private:
174 } ;
176 template <typename... T>
177 inline void ctor_signature(std::string& s, const std::string& classname) {
178 s.assign(classname);
179 s += "(";
180 int n = sizeof...(T);
181 int i = 0;
182 // Using initializer list as c++11 implementation of a fold expression
183 (void)std::initializer_list<int>{
184 (s += get_return_type<T>(), s += (++i == n ? "" : ", "), 0)... };
185 s += ")";
187 template <typename Class>
189 public:
190 virtual Class* get_new( SEXP* args, int nargs ) = 0 ;
191 virtual int nargs() = 0 ;
192 virtual void signature(std::string& s, const std::string& class_name) = 0 ;
193 } ;
194
195 template <typename Class, typename... T>
196 class Constructor: public Constructor_Base<Class> {
197 public:
198 virtual Class* get_new( SEXP* args, int nargs ){
199 return get_new_impl(args, nargs, traits::make_index_sequence<sizeof...(T)>());
201 virtual int nargs(){ return sizeof...(T) ; }
202 virtual void signature(std::string& s, const std::string& class_name ){
203 ctor_signature<T...>(s, class_name) ;
205
206 private:
207 template <int... Is>
209 return new Class( as<T>(args[Is])... ) ;
211 };
212
213 template <typename Class>
215 public:
216 virtual Class* get_new( SEXP* args, int nargs ) = 0 ;
217 virtual int nargs() = 0 ;
218 virtual void signature(std::string& s, const std::string& class_name) = 0 ;
219 } ;
220
221 template <typename Class, typename... T>
222 class Factory : public Factory_Base<Class> {
223 public:
224 Factory( Class* (*fun)(T...) ) : ptr_fun(fun){}
225 virtual Class* get_new( SEXP* args, int nargs ){
226 return get_new( args, traits::make_index_sequence<sizeof...(T)>() ) ;
227 }
228 virtual int nargs(){ return sizeof...(T) ; }
229 virtual void signature(std::string& s, const std::string& class_name ){
231 }
232 private:
233 template<int... I>
235 return ptr_fun( bare_as<T>(args[I])... ) ;
236 }
237 Class* (*ptr_fun)(T...) ;
238 } ;
239
240 inline bool yes( SEXP* /*args*/, int /* nargs */ ){
241 return true ;
243
244 template<int n>
245 bool yes_arity( SEXP* /* args */ , int nargs){
246 return nargs == n ;
248
249 typedef bool (*ValidConstructor)(SEXP*,int) ;
250 typedef bool (*ValidMethod)(SEXP*,int) ;
251
252 template <typename Class>
254 public:
255
258 ValidConstructor valid_,
259 const char* doc
260 ) : ctor(ctor_), valid(valid_), docstring(doc == 0 ? "" : doc){}
261
264 std::string docstring ;
266 inline int nargs(){ return ctor->nargs() ; }
267 inline void signature(std::string& buffer, const std::string& class_name){
268 ctor->signature(buffer, class_name) ;
269 }
270 } ;
272 template <typename Class>
274 public:
275
278 ValidConstructor valid_,
279 const char* doc
280 ) : fact(fact_), valid(valid_), docstring(doc == 0 ? "" : doc){}
281
284 std::string docstring ;
285
286 inline int nargs(){ return fact->nargs() ; }
287 inline void signature(std::string& buffer, const std::string& class_name){
288 fact->signature(buffer, class_name) ;
290 } ;
291
292
293 template <typename Class>
295 public:
297 SignedMethod( METHOD* m, ValidMethod valid_, const char* doc ) : method(m), valid(valid_), docstring(doc == 0 ? "" : doc) {}
298
301 std::string docstring ;
302
303 inline int nargs(){ return method->nargs() ; }
304 inline bool is_void(){ return method->is_void() ; }
305 inline bool is_const(){ return method->is_const() ; }
306 inline void signature(std::string& s, const char* name){
307 method->signature(s, name);
308 }
309
310 } ;
311
312 template <typename Class>
315 public:
317 typedef Reference::Storage Storage ;
319 S4_CppConstructor( SignedConstructor<Class>* m, const XP_Class& class_xp, const std::string& class_name, std::string& buffer ) : Reference( "C++Constructor" ){
320 RCPP_DEBUG( "S4_CppConstructor( SignedConstructor<Class>* m, SEXP class_xp, const std::string& class_name, std::string& buffer" ) ;
321 field( "pointer" ) = Rcpp::XPtr< SignedConstructor<Class> >( m, false ) ;
322 field( "class_pointer" ) = class_xp ;
323 field( "nargs" ) = m->nargs() ;
324 m->signature( buffer, class_name ) ;
325 field( "signature" ) = buffer ;
326 field( "docstring" ) = m->docstring ;
327 }
328
330
331 } ;
332
333 template <typename Class>
336 public:
339 typedef std::vector<signed_method_class*> vec_signed_method ;
340
341 S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp, const char* name, std::string& buffer ) : Reference( "C++OverloadedMethods" ){
342 int n = static_cast<int>(m->size()) ;
343 Rcpp::LogicalVector voidness(n), constness(n) ;
344 Rcpp::CharacterVector docstrings(n), signatures(n) ;
345 Rcpp::IntegerVector nargs(n) ;
347 for( int i=0; i<n; i++){
348 met = m->at(i) ;
349 nargs[i] = met->nargs() ;
350 voidness[i] = met->is_void() ;
351 constness[i] = met->is_const() ;
352 docstrings[i] = met->docstring ;
353 met->signature(buffer, name) ;
354 signatures[i] = buffer ;
355 }
356
357 field( "pointer" ) = Rcpp::XPtr< vec_signed_method >( m, false ) ;
358 field( "class_pointer" ) = class_xp ;
359 field( "size" ) = n ;
360 field( "void" ) = voidness ;
361 field( "const" ) = constness ;
362 field( "docstrings" ) = docstrings ;
363 field( "signatures" ) = signatures ;
364 field( "nargs" ) = nargs ;
365
366 }
367
369
370 } ;
371
372
373 template <bool IsConst,typename Class, typename RESULT_TYPE, typename... T>
374 class CppMethodImplN : public CppMethod<Class> {
375 public:
376 typedef typename std::conditional<IsConst, RESULT_TYPE (Class::*)(T...) const,
377 RESULT_TYPE (Class::*)(T...)>::type Method;
380
382 SEXP operator()(Class* object, SEXP* args) {
383 // Can't pass pointer to member function directly to `call()`, so wrap it in a lambda
384 auto f = [&object, this](T... cpp_args) -> CLEANED_RESULT_TYPE {
385 return (object->*met)(cpp_args...);
386 };
387 return call<decltype(f), CLEANED_RESULT_TYPE, T...>(f, args);
388 }
389 inline int nargs() { return sizeof...(T); }
390 inline bool is_void() { return std::is_void<RESULT_TYPE>::value; }
391 inline bool is_const() { return IsConst; }
392 inline void signature(std::string& s, const char* name) { Rcpp::signature<RESULT_TYPE,T...>(s, name); }
393 private:
395 };
396
397 template <typename Class, typename RESULT_TYPE, typename... T>
398 using CppMethodN = CppMethodImplN<false, Class, RESULT_TYPE, T...>;
399
400 template <typename Class, typename RESULT_TYPE, typename... T>
401 using const_CppMethodN = CppMethodImplN<true, Class, RESULT_TYPE, T...>;
402
403 template <bool IsConst, typename Class, typename RESULT_TYPE, typename... T>
404 class Pointer_CppMethodImplN : public CppMethod<Class> {
405 public:
406 typedef typename std::conditional<IsConst, RESULT_TYPE (*)(const Class*, T...),
407 RESULT_TYPE (*)(Class*, T...)>::type Method;
412 SEXP operator()(Class* object, SEXP* args) {
413 // Need to have `object` as the first argument to the function, so wrap it in a lambda
414 auto f = [&object, this](T... cpp_args) -> CLEANED_RESULT_TYPE {
415 return met(object, cpp_args...);
416 };
417 return call<decltype(f), CLEANED_RESULT_TYPE, T...>(f, args);
418 }
419 inline int nargs() { return sizeof...(T); }
420 inline bool is_void() { return std::is_void<RESULT_TYPE>::value; }
421 inline bool is_const() { return IsConst; }
422 inline void signature(std::string& s, const char* name) { Rcpp::signature<RESULT_TYPE,T...>(s, name); }
423 private:
425 };
426
427 template <typename Class, typename RESULT_TYPE, typename... T>
428 using Pointer_CppMethodN = Pointer_CppMethodImplN<false, Class, RESULT_TYPE, T...>;
429
430 template <typename Class, typename RESULT_TYPE, typename... T>
431 using Const_Pointer_CppMethodN = Pointer_CppMethodImplN<true, Class, RESULT_TYPE, T...>;
432
433
434
435 template <typename Class>
437 public:
439
440 CppProperty(const char* doc = 0) : docstring( doc == 0 ? "" : doc ) {} ;
441 virtual ~CppProperty(){} ;
442 virtual SEXP get(Class* ) { throw std::range_error("cannot retrieve property"); }
443 virtual void set(Class*, SEXP) { throw std::range_error("cannot set property"); }
444 virtual bool is_readonly(){ return false; }
445 virtual std::string get_class(){ return ""; }
446
447 std::string docstring ;
448 } ;
449
450 template <typename Class, typename Parent>
451 class CppInheritedProperty : public CppProperty<Class> {
452 public:
454
456 Base( parent_property_->docstring.c_str() ),
457 parent_property(parent_property_)
458 {}
459
460 SEXP get( Class* obj ){ return parent_property->get( (Parent*)obj ) ; }
461 void set( Class* obj, SEXP s) { parent_property->set( (Parent*)obj, s ) ; }
462 bool is_readonly(){ return parent_property->is_readonly() ; }
463 std::string get_class(){ return parent_property->get_class() ; }
465 private:
467 } ;
468
469 template <typename Class>
471 public:
473 virtual void run(Class* ){} ;
474 } ;
475
476 template <typename Class>
477 class FunctionFinalizer : public CppFinalizer<Class> {
478 public:
479 typedef void (*Pointer)(Class*) ;
481
482 virtual void run(Class* object){
483 finalizer( object ) ;
484 }
485
486 private:
488 } ;
489
490 template <typename Class>
491 class S4_field : public Rcpp::Reference {
493 public:
495 S4_field( CppProperty<Class>* p, const XP_Class& class_xp ) : Reference( "C++Field" ){
496 RCPP_DEBUG( "S4_field( CppProperty<Class>* p, const XP_Class& class_xp )" )
497 field( "read_only" ) = p->is_readonly() ;
498 field( "cpp_class" ) = p->get_class();
499 field( "pointer" ) = Rcpp::XPtr< CppProperty<Class> >( p, false ) ;
500 field( "class_pointer" ) = class_xp ;
501 field( "docstring" ) = p->docstring ;
502 }
503
506 } ;
507
508#include <Rcpp/module/Module_Property.h>
509
510#include <Rcpp/module/class.h>
512 template <typename Enum, typename Parent>
513 class enum_ {
514 public:
517 enum_( const char* name_ ) :
518 name(name_), values(), parent_typeinfo_name( typeid(Parent).name() ){
521 Rcpp::Module* module = getCurrentScope() ;
522 module->add_enum( parent_typeinfo_name, name, values ) ;
523 }
524
525 self& value( const char* name_, Enum value_ ){
526 values.insert( PAIR( name_, static_cast<int>( value_ ) ) ) ;
527 return *this ;
529
530 private:
531
532 std::string name ;
533 typedef std::map< std::string, int > MAP ;
534 typedef MAP::value_type PAIR ;
537
538 } ;
539}
540
541
542namespace Rcpp {
543 template <typename RESULT_TYPE, typename... T>
544 void function(const char* name_, RESULT_TYPE (*fun)(T... t), const char* docstring = 0) {
546 if (scope) {
547 scope->Add(name_, new CppFunctionN<RESULT_TYPE, T...>(fun, docstring));
548 }
549 }
550
551 template <typename RESULT_TYPE, typename... T>
552 void function(const char* name_, RESULT_TYPE (*fun)(T... t), Rcpp::List formals, const char* docstring = 0) {
554 if (scope) {
555 scope->Add(name_, new CppFunction_WithFormalsN<RESULT_TYPE, T...>(fun, formals, docstring));
556 }
557 }
558}
559
560
561namespace Rcpp {
562
563 template <typename FROM, typename TO>
564 void converter( const char* from, const char* to, TO (*fun)(FROM), const char* docstring = 0 ){
565 std::string fun_name = internal::get_converter_name<FROM,TO>( from, to ) ;
566 function( fun_name.c_str(), fun, docstring ) ;
567 }
568
569 class CppClass : public S4{
570 typedef S4 Base;
571 public:
574 CppClass( SEXP x) : S4(x){}; // #nocov
575
576 CppClass( Module* p, class_Base* cl, std::string& buffer ) : S4("C++Class") {
577 XP_Class clxp( cl, false, R_NilValue, R_NilValue ) ;
578 slot( "module" ) = XP( p, false ) ;
579 slot( "pointer" ) = clxp ;
580
581 buffer = "Rcpp_" ;
582 buffer += cl->name ;
583 slot( ".Data" ) = buffer ;
584
585 slot( "fields" ) = cl->fields( clxp ) ;
586
587 slot( "methods" ) = cl->getMethods( clxp, buffer ) ;
588 slot( "constructors") = cl->getConstructors( clxp, buffer ) ;
589 slot( "docstring" ) = cl->docstring ;
590 slot( "typeid" ) = cl->get_typeinfo_name() ;
591 slot( "enums" ) = cl->enums ;
592 slot( "parents" ) = cl->parents ;
593 }
594
596
597 } ;
598
599 class CppObject : public S4{
600 typedef S4 Base;
601 public:
603 CppObject( Module* p, class_Base* clazz, SEXP xp ) : S4("C++Object") {
604 slot( "module" ) = XP( p, false ) ;
605 slot( "cppclass" ) = Rcpp::XPtr<class_Base>( clazz, false ) ;
606 slot( "pointer" ) = xp ;
607 }
609 } ;
610
611}
612
613#define RCPP_MODULE_BOOT(name) _rcpp_module_boot_##name
614
615#define RCPP_MODULE(name) \
616 void _rcpp_module_##name##_init() ; \
617 static Rcpp::Module _rcpp_module_##name( # name ) ; \
618 extern "C" SEXP _rcpp_module_boot_##name(){ \
619 ::setCurrentScope( & _rcpp_module_##name ) ; \
620 _rcpp_module_##name##_init( ) ; \
621 Rcpp::XPtr<Rcpp::Module> mod_xp(& _rcpp_module_##name , false); \
622 ::setCurrentScope( 0 ) ; \
623 return mod_xp ; \
624 } \
625 void _rcpp_module_##name##_init()
626
627// silly little dance to suppress a 'defined but not used variable' warning
628#ifdef __GNUC__
629#define VARIABLE_IS_NOT_USED __attribute__ ((unused))
630#else
631#define VARIABLE_IS_NOT_USED
632#endif
633
634// static variable to hold Rf_install symbol to prevent it from being gc'ed
636
637// helper macro to cache the result of Rf_install("Module"): once
638// it is allocated and in the symbol table it is safe from gc
639#define GET_MODULE_SYM ( moduleSym == NULL ? moduleSym = Rf_install("Module") : moduleSym )
640
641// this macro is called by code wanting to load a module -- see RInside's rinside_module_sample0.cpp
642#define LOAD_RCPP_MODULE(NAME) \
643 Shield<SEXP> __load_module_call__( Rf_lang2( GET_MODULE_SYM, _rcpp_module_boot_##NAME() ) ); \
644 Rcpp_fast_eval( __load_module_call__, R_GlobalEnv );
645
646#endif
#define VARIABLE_IS_NOT_USED
Definition Module.h:631
static VARIABLE_IS_NOT_USED SEXP moduleSym
Definition Module.h:635
self & field(const char *name_, T Class::*ptr, const char *docstring=0)
virtual int nargs()=0
virtual Class * get_new(SEXP *args, int nargs)=0
virtual void signature(std::string &s, const std::string &class_name)=0
virtual int nargs()
Definition Module.h:201
Class * get_new_impl(SEXP *args, int nargs, traits::index_sequence< Is... >)
Definition Module.h:208
virtual void signature(std::string &s, const std::string &class_name)
Definition Module.h:202
virtual Class * get_new(SEXP *args, int nargs)
Definition Module.h:198
CppClass(SEXP x)
Definition Module.h:574
Rcpp::XPtr< Rcpp::Module > XP
Definition Module.h:573
CppClass(Module *p, class_Base *cl, std::string &buffer)
Definition Module.h:576
XPtr< class_Base > XP_Class
Definition Module.h:572
virtual void run(Class *)
Definition Module.h:473
CppFunctionN(RESULT_TYPE(*fun)(T...), const char *docstring=0)
Definition Module.h:105
SEXP operator()(SEXP *args)
Definition Module.h:107
RESULT_TYPE(* ptr_fun)(T...)
Definition Module.h:119
DL_FUNC get_function_ptr()
Definition Module.h:116
void signature(std::string &s, const char *name)
Definition Module.h:115
CppFunction_WithFormalsN(RESULT_TYPE(*fun)(T...), Rcpp::List formals_, const char *docstring=0)
Definition Module.h:125
std::string docstring
Definition CppFunction.h:86
CppFunction(const char *doc=0)
Definition CppFunction.h:54
CppInheritedMethod(ParentMethod *parent_method_pointer_)
Definition Module.h:160
ParentMethod * parent_method_pointer
Definition Module.h:173
Rcpp::XPtr< Class > XP
Definition Module.h:157
SEXP operator()(Class *object, SEXP *args)
Definition Module.h:164
CppMethod< Parent > ParentMethod
Definition Module.h:158
void signature(std::string &s, const char *name)
Definition Module.h:170
CppProperty< Class > Base
Definition Module.h:453
void set(Class *obj, SEXP s)
Definition Module.h:461
CppInheritedProperty(CppProperty< Parent > *parent_property_)
Definition Module.h:455
std::string get_class()
Definition Module.h:463
SEXP get(Class *obj)
Definition Module.h:460
CppProperty< Parent > * parent_property
Definition Module.h:466
SEXP operator()(Class *object, SEXP *args)
Definition Module.h:382
std::conditional< IsConst, RESULT_TYPE(Class::*)(T...) const, RESULT_TYPE(Class::*)(T...)>::type Method
Definition Module.h:377
CppMethod< Class > method_class
Definition Module.h:378
CppMethodImplN(Method m)
Definition Module.h:381
Rcpp::traits::remove_const_and_reference< RESULT_TYPE >::type CLEANED_RESULT_TYPE
Definition Module.h:379
void signature(std::string &s, const char *name)
Definition Module.h:392
virtual ~CppMethod()
Definition Module.h:147
virtual bool is_void()
Definition Module.h:149
virtual bool is_const()
Definition Module.h:150
Rcpp::XPtr< Class > XP
Definition Module.h:143
virtual void signature(std::string &s, const char *name)
Definition Module.h:151
virtual int nargs()
Definition Module.h:148
virtual SEXP operator()(Class *, SEXP *)
Definition Module.h:146
CppObject(Module *p, class_Base *clazz, SEXP xp)
Definition Module.h:603
Rcpp::XPtr< Rcpp::Module > XP
Definition Module.h:602
CppProperty(const char *doc=0)
Definition Module.h:440
virtual SEXP get(Class *)
Definition Module.h:442
Rcpp::XPtr< Class > XP
Definition Module.h:438
virtual ~CppProperty()
Definition Module.h:441
virtual bool is_readonly()
Definition Module.h:444
virtual std::string get_class()
Definition Module.h:445
virtual void set(Class *, SEXP)
Definition Module.h:443
std::string docstring
Definition Module.h:447
virtual Class * get_new(SEXP *args, int nargs)=0
virtual void signature(std::string &s, const std::string &class_name)=0
virtual int nargs()=0
virtual Class * get_new(SEXP *args, int nargs)
Definition Module.h:225
Class * get_new(SEXP *args, traits::index_sequence< I... >)
Definition Module.h:234
virtual int nargs()
Definition Module.h:228
Factory(Class *(*fun)(T...))
Definition Module.h:224
Class *(* ptr_fun)(T...)
Definition Module.h:237
virtual void signature(std::string &s, const std::string &class_name)
Definition Module.h:229
FunctionFinalizer(Pointer p)
Definition Module.h:480
void(* Pointer)(Class *)
Definition Module.h:479
virtual void run(Class *object)
Definition Module.h:482
void Add(const char *name_, CppFunction *ptr)
Definition Module.h:192
Pointer_CppMethodImplN(Method m)
Definition Module.h:411
CppMethod< Class > method_class
Definition Module.h:408
Rcpp::traits::remove_const_and_reference< RESULT_TYPE >::type CLEANED_RESULT_TYPE
Definition Module.h:409
void signature(std::string &s, const char *name)
Definition Module.h:422
std::conditional< IsConst, RESULT_TYPE(*)(constClass *, T...), RESULT_TYPE(*)(Class *, T...)>::type Method
Definition Module.h:407
SEXP operator()(Class *object, SEXP *args)
Definition Module.h:412
Reference::Storage Storage
Definition Module.h:317
XPtr< class_Base > XP_Class
Definition Module.h:316
S4_CppConstructor(SignedConstructor< Class > *m, const XP_Class &class_xp, const std::string &class_name, std::string &buffer)
Definition Module.h:319
S4_CppOverloadedMethods(vec_signed_method *m, const XP_Class &class_xp, const char *name, std::string &buffer)
Definition Module.h:341
std::vector< signed_method_class * > vec_signed_method
Definition Module.h:339
SignedMethod< Class > signed_method_class
Definition Module.h:338
Rcpp::XPtr< class_Base > XP_Class
Definition Module.h:337
XPtr< class_Base > XP_Class
Definition Module.h:494
S4_field(CppProperty< Class > *p, const XP_Class &class_xp)
Definition Module.h:495
Rcpp::Reference Base
Definition Module.h:492
void signature(std::string &buffer, const std::string &class_name)
Definition Module.h:267
Constructor_Base< Class > * ctor
Definition Module.h:262
SignedConstructor(Constructor_Base< Class > *ctor_, ValidConstructor valid_, const char *doc)
Definition Module.h:256
std::string docstring
Definition Module.h:264
ValidConstructor valid
Definition Module.h:263
void signature(std::string &buffer, const std::string &class_name)
Definition Module.h:287
std::string docstring
Definition Module.h:284
SignedFactory(Factory_Base< Class > *fact_, ValidConstructor valid_, const char *doc)
Definition Module.h:276
ValidConstructor valid
Definition Module.h:283
Factory_Base< Class > * fact
Definition Module.h:282
METHOD * method
Definition Module.h:299
void signature(std::string &s, const char *name)
Definition Module.h:306
ValidMethod valid
Definition Module.h:300
SignedMethod(METHOD *m, ValidMethod valid_, const char *doc)
Definition Module.h:297
CppMethod< Class > METHOD
Definition Module.h:296
std::string docstring
Definition Module.h:301
std::string docstring
Definition class_Base.h:86
virtual std::string get_typeinfo_name()
Definition class_Base.h:77
std::string name
Definition class_Base.h:85
virtual Rcpp::List getConstructors(const XP_Class &, std::string &)
Definition class_Base.h:36
virtual Rcpp::List fields(const XP_Class &)
Definition class_Base.h:34
virtual Rcpp::List getMethods(const XP_Class &, std::string &)
Definition class_Base.h:35
std::vector< std::string > parents
Definition class_Base.h:92
self & field(const char *name_, T Class::*ptr, const char *docstring=0)
Definition Module.h:69
SignedMethod< Class > signed_method_class
Definition Module.h:31
self & method(const char *name_, RESULT_TYPE(Class::*fun)(T...), const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition Module.h:265
self & value(const char *name_, Enum value_)
Definition Module.h:525
MAP::value_type PAIR
Definition Module.h:534
std::map< std::string, int > MAP
Definition Module.h:533
std::string name
Definition Module.h:532
enum_(const char *name_)
Definition Module.h:517
MAP values
Definition Module.h:535
std::string parent_typeinfo_name
Definition Module.h:536
enum_< Enum, Parent > self
Definition Module.h:515
T object_type
Definition Module.h:67
T & operator&()
Definition Module.h:71
T * operator->()
Definition Module.h:70
object(T *ptr_)
Definition Module.h:68
result(T *ptr_)
Definition Module.h:58
#define RCPP_DEBUG(MSG)
Definition debug.h:43
#define RCPP_CTOR_ASSIGN_WITH_BASE(__CLASS__)
Definition interface.h:38
#define END_RCPP
Definition macros.h:99
#define BEGIN_RCPP
Definition macros.h:49
internal implementation details
Definition Date.h:43
SEXP make_new_object(Class *ptr)
Definition Module.h:77
std::string get_converter_name(const char *from, const char *to)
Definition Module.h:32
Rcpp API.
Definition algo.h:28
Pointer_CppMethodImplN< false, Class, RESULT_TYPE, T... > Pointer_CppMethodN
Definition Module.h:428
Function_Impl< PreserveStorage > Function
Definition Function.h:144
bool(* ValidConstructor)(SEXP *, int)
Definition Module.h:249
traits::remove_const_and_reference< T >::type bare_as(SEXP x)
Definition as.h:159
void converter(const char *from, const char *to, TO(*fun)(FROM), const char *docstring=0)
Definition Module.h:564
bool(* ValidMethod)(SEXP *, int)
Definition Module.h:250
CppMethodImplN< false, Class, RESULT_TYPE, T... > CppMethodN
Definition Module.h:398
std::string get_return_type()
bool yes_arity(SEXP *, int nargs)
Definition Module.h:245
bool yes(SEXP *, int)
Definition Module.h:240
Vector< STRSXP > CharacterVector
Pointer_CppMethodImplN< true, Class, RESULT_TYPE, T... > Const_Pointer_CppMethodN
Definition Module.h:431
Vector< LGLSXP > LogicalVector
CppMethodImplN< true, Class, RESULT_TYPE, T... > const_CppMethodN
Definition Module.h:401
Vector< INTSXP > IntegerVector
Vector< VECSXP > List
T as(SEXP x)
Definition as.h:150
Reference_Impl< PreserveStorage > Reference
Definition Reference.h:71
void ctor_signature(std::string &s, const std::string &classname)
Definition Module.h:177
void function(const char *name_, RESULT_TYPE(*fun)(T... t), const char *docstring=0)
Definition Module.h:544
void signature(std::string &s, const char *name)
Definition Module.h:91
S4_Impl< PreserveStorage > S4
Definition S4.h:76
attribute_hidden Rcpp::Module * getCurrentScope()
Definition routines.h:270
remove_const< typenameremove_reference< T >::type >::type type