Rcpp Version 1.1.2
Loading...
Searching...
No Matches
class.h
Go to the documentation of this file.
1
2// class.h: Rcpp R/C++ interface class library -- Rcpp modules
3//
4// Copyright (C) 2012 - 2025 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_CLASS_h
22#define Rcpp_Module_CLASS_h
23
24 template <typename Class>
25 class class_ : public class_Base {
26 public:
28 typedef CppMethod<Class> method_class ;
29
30 typedef SignedMethod<Class> signed_method_class ;
31 typedef std::vector<signed_method_class*> vec_signed_method ;
32 typedef std::map<std::string,vec_signed_method*> map_vec_signed_method ;
33 typedef std::pair<std::string,vec_signed_method*> vec_signed_method_pair ;
34
35 typedef std::map<std::string,method_class*> METHOD_MAP ;
36 typedef std::pair<const std::string,method_class*> PAIR ;
39 typedef CppFinalizer<Class> finalizer_class ;
40
41 typedef Constructor_Base<Class> constructor_class ;
42 typedef SignedConstructor<Class> signed_constructor_class ;
43 typedef std::vector<signed_constructor_class*> vec_signed_constructor ;
44
45 typedef Factory_Base<Class> factory_class ;
46 typedef SignedFactory<Class> signed_factory_class ;
47 typedef std::vector<signed_factory_class*> vec_signed_factory ;
48
49 typedef CppProperty<Class> prop_class ;
50 typedef std::map<std::string,prop_class*> PROPERTY_MAP ;
51 typedef std::pair<const std::string,prop_class*> PROP_PAIR ;
53 class_( const char* name_, const char* doc = 0) :
54 class_Base(name_, doc),
56 properties(),
63 {
65 }
66
67 private:
68
70
71 // check if we already have it
73 RCPP_DEBUG_MODULE_2( "class_<%s>::get_instance(). [cached] class_pointer = <%p>\n", DEMANGLE(Class), class_pointer ) ;
74 return class_pointer ;
75 }
76
77 // check if it exists in the module
78 Module* module = getCurrentScope() ;
79 if( module->has_class(name) ){
80 RCPP_DEBUG_MODULE_2( "class_<%s>::get_instance(). [from module] class_pointer = class_pointer\n", DEMANGLE(Class), class_pointer ) ;
81 class_pointer = dynamic_cast<self*>( module->get_class_pointer(name) ) ;
82 } else {
83 class_pointer = new self ;
84 class_pointer->name = name ;
85 class_pointer->docstring = docstring ;
87 class_pointer->typeinfo_name = typeid(Class).name() ;
88 module->AddClass( name.c_str(), class_pointer ) ;
89 RCPP_DEBUG_MODULE_2( "class_<%s>::get_instance(). [freshly created] class_pointer = class_pointer\n", DEMANGLE(Class), class_pointer ) ;
91 }
92 return class_pointer ;
93 }
94
95 public:
96
98
99 self& AddConstructor( constructor_class* ctor, ValidConstructor valid, const char* docstring = 0 ){
100 class_pointer->constructors.push_back( new signed_constructor_class( ctor, valid, docstring ) );
101 return *this ;
102 }
103
104 self& AddFactory( factory_class* fact, ValidConstructor valid, const char* docstring = 0 ){
105 class_pointer->factories.push_back( new signed_factory_class( fact, valid, docstring ) ) ;
106 return *this ;
107 }
108
109 self& default_constructor( const char* docstring= 0, ValidConstructor valid = &yes_arity<0> ){
110 return constructor( docstring, valid ) ;
111 }
112
113 template <typename... T>
114 self& constructor( const char* docstring = 0, ValidConstructor valid = &yes_arity<sizeof...(T)> ){
115 AddConstructor( new Constructor<Class,T...> , valid, docstring ) ;
116 return *this ;
117 }
118 template <typename... T>
119 self& factory( Class* (*fun)(T...), const char* docstring = 0, ValidConstructor valid = &yes_arity<sizeof...(T)> ){
120 AddFactory( new Factory<Class,T...>(fun) , valid, docstring ) ;
121 return *this ;
122 }
123
124 public:
125
126 std::string get_typeinfo_name(){
127 return typeinfo_name ;
128 }
129
130 SEXP newInstance( SEXP* args, int nargs ){
133 size_t n = constructors.size() ;
134 for( size_t i=0; i<n; i++ ){
135 p = constructors[i];
136 bool ok = (p->valid)(args, nargs) ;
137 if( ok ){
138 Class* ptr = p->ctor->get_new( args, nargs ) ;
139 return XP( ptr, true ) ;
140 }
141 }
142
143 signed_factory_class* pfact ;
144 n = factories.size() ;
145 for( size_t i=0; i<n; i++){
146 pfact = factories[i] ;
147 bool ok = (pfact->valid)(args, nargs) ;
148 if( ok ){
149 Class* ptr = pfact->fact->get_new( args, nargs ) ;
150 return XP( ptr, true ) ;
151 }
152 }
153
154 throw std::range_error( "no valid constructor available for the argument list" ) ;
156 }
157
159 size_t n = constructors.size() ;
161 for( size_t i=0; i<n; i++ ){
162 p = constructors[i];
163 if( p->nargs() == 0 ) return true ;
164 }
165 n = factories.size() ;
166 signed_factory_class* pfact ;
167 for( size_t i=0; i<n; i++ ){
168 pfact = factories[i];
169 if( pfact->nargs() == 0 ) return true ;
170 }
171 return false ;
172 }
173
174 SEXP invoke( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
176
177 vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
178 typename vec_signed_method::iterator it = mets->begin() ;
179 size_t n = mets->size() ;
180 method_class* m = 0 ;
181 bool ok = false ;
182 for( size_t i=0; i<n; i++, ++it ){
183 if( ( (*it)->valid )( args, nargs) ){
184 m = (*it)->method ;
185 ok = true ;
186 break ;
187 }
188 }
189 if( !ok ){
190 throw std::range_error( "could not find valid method" ) ;
191 }
192 if( m->is_void() ){
193 m->operator()( XP(object), args );
194 return Rcpp::List::create( true ) ;
195 } else {
196 return Rcpp::List::create( false, m->operator()( XP(object), args ) ) ;
197 }
199 }
200
201 SEXP invoke_void( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
203
204 vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
205 typename vec_signed_method::iterator it = mets->begin() ;
206 size_t n = mets->size() ;
207 method_class* m = 0 ;
208 bool ok = false ;
209 for( size_t i=0; i<n; i++, ++it ){
210 if( ( (*it)->valid )( args, nargs) ){
211 m = (*it)->method ;
212 ok = true ;
213 break ;
214 }
215 }
216 if( !ok ){
217 throw std::range_error( "could not find valid method" ) ;
218 }
219 m->operator()( XP(object), args );
221 }
222
223 SEXP invoke_notvoid( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
225
226 vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
227 typename vec_signed_method::iterator it = mets->begin() ;
228 size_t n = mets->size() ;
229 method_class* m = 0 ;
230 bool ok = false ;
231 for( size_t i=0; i<n; i++, ++it ){
232 if( ( (*it)->valid )( args, nargs) ){
233 m = (*it)->method ;
234 ok = true ;
235 break ;
236 }
237 }
238 if( !ok ){
239 throw std::range_error( "could not find valid method" ) ;
240 }
241 return m->operator()( XP(object), args ) ;
243 }
244
245
246 self& AddMethod( const char* name_, method_class* m, ValidMethod valid = &yes, const char* docstring = 0){
247 RCPP_DEBUG_MODULE_1( "AddMethod( %s, method_class* m, ValidMethod valid = &yes, const char* docstring = 0", name_ )
248 self* ptr = get_instance() ;
249 typename map_vec_signed_method::iterator it = ptr->vec_methods.find( name_ ) ;
250 if( it == ptr->vec_methods.end() ){
251 it = ptr->vec_methods.insert( vec_signed_method_pair( name_, new vec_signed_method() ) ).first ;
252 }
253 (it->second)->push_back( new signed_method_class(m, valid, docstring ) ) ;
254 if( *name_ == '[' ) ptr->specials++ ;
255 return *this ;
256 }
257
258 self& AddProperty( const char* name_, prop_class* p){
259 get_instance()->properties.insert( PROP_PAIR( name_, p ) ) ;
260 return *this ;
261 }
262
263 template <typename RESULT_TYPE, typename... T>
264 self& method(const char* name_, RESULT_TYPE (Class::*fun)(T...),
265 const char* docstring = 0, ValidMethod valid = &yes_arity<sizeof...(T)>) {
266 AddMethod( name_, new CppMethodN<Class,RESULT_TYPE,T...>(fun), valid, docstring);
267 return *this;
268 }
269 template <typename RESULT_TYPE, typename... T>
270 self& method(const char* name_, RESULT_TYPE (Class::*fun)(T...) const,
271 const char* docstring = 0, ValidMethod valid = &yes_arity<sizeof...(T)>) {
272 AddMethod( name_, new const_CppMethodN<Class,RESULT_TYPE,T...>(fun), valid, docstring);
273 return *this;
274 }
275 template <typename RESULT_TYPE, typename... T>
276 self& nonconst_method(const char* name_, RESULT_TYPE (Class::*fun)(T...),
277 const char* docstring = 0, ValidMethod valid = &yes_arity<sizeof...(T)>) {
278 AddMethod( name_, new CppMethodN<Class,RESULT_TYPE,T...>(fun), valid, docstring);
279 return *this;
280 }
281 template <typename RESULT_TYPE, typename... T>
282 self& const_method(const char* name_, RESULT_TYPE (Class::*fun)(T...) const,
283 const char* docstring = 0, ValidMethod valid = &yes_arity<sizeof...(T)>) {
284 AddMethod( name_, new const_CppMethodN<Class,RESULT_TYPE,T...>(fun), valid, docstring);
285 return *this;
286 }
287 template <typename RESULT_TYPE, typename... T>
288 self& method(const char* name_, RESULT_TYPE (*fun)(Class*, T...),
289 const char* docstring = 0, ValidMethod valid = &yes_arity<sizeof...(T)>) {
290 AddMethod( name_, new Pointer_CppMethodN<Class,RESULT_TYPE,T...>(fun), valid, docstring);
291 return *this;
292 }
293 template <typename RESULT_TYPE, typename... T>
294 self& const_method(const char* name_, RESULT_TYPE (*fun)(const Class*, T...),
295 const char* docstring = 0, ValidMethod valid = &yes_arity<sizeof...(T)>) {
296 AddMethod( name_, new Const_Pointer_CppMethodN<Class,RESULT_TYPE,T...>(fun), valid, docstring);
297 return *this;
298 }
299
300 bool has_method( const std::string& m){
301 return vec_methods.find(m) != vec_methods.end() ;
302 }
303 bool has_property( const std::string& m){
304 return properties.find(m) != properties.end() ;
305 }
306 bool property_is_readonly( const std::string& p) {
307 typename PROPERTY_MAP::iterator it = properties.find( p ) ;
308 if( it == properties.end() ) throw std::range_error( "no such property" ) ;
309 return it->second->is_readonly() ;
310 }
311 std::string property_class(const std::string& p) {
312 typename PROPERTY_MAP::iterator it = properties.find( p ) ;
313 if( it == properties.end() ) throw std::range_error( "no such property" ) ;
314 return it->second->get_class() ;
315 }
316
318 size_t n = 0 ;
319 size_t s = vec_methods.size() ;
320 typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
321 for( size_t i=0; i<s; i++, ++it){
322 n += (it->second)->size() ;
323 }
324 Rcpp::CharacterVector out(n) ;
325 it = vec_methods.begin() ;
326 size_t k = 0 ;
327 for( size_t i=0; i<s; i++, ++it){
328 n = (it->second)->size() ;
329 std::string name = it->first ;
330 for( size_t j=0; j<n; j++, k++){
331 out[k] = name ;
332 }
333 }
334 return out ;
335 }
336
338 size_t n = 0 ;
339 size_t s = vec_methods.size() ;
340 typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
341 for( size_t i=0; i<s; i++, ++it){
342 n += (it->second)->size() ;
343 }
344 Rcpp::CharacterVector mnames(n) ;
345 Rcpp::IntegerVector res(n) ;
346 it = vec_methods.begin() ;
347 size_t k = 0 ;
348 for( size_t i=0; i<s; i++, ++it){
349 n = (it->second)->size() ;
350 std::string name = it->first ;
351 typename vec_signed_method::iterator m_it = (it->second)->begin() ;
352 for( size_t j=0; j<n; j++, k++, ++m_it){
353 mnames[k] = name ;
354 res[k] = (*m_it)->nargs() ;
355 }
356 }
357 res.names( ) = mnames ;
358 return res ;
359 }
360
362 size_t n = 0 ;
363 size_t s = vec_methods.size() ;
364 typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
365 for( size_t i=0; i<s; i++, ++it){
366 n += (it->second)->size() ;
367 }
368 Rcpp::CharacterVector mnames(n) ;
369 Rcpp::LogicalVector res(n) ;
370 it = vec_methods.begin() ;
371 size_t k = 0 ;
372 for( size_t i=0; i<s; i++, ++it){
373 n = (it->second)->size() ;
374 std::string name = it->first ;
375 typename vec_signed_method::iterator m_it = (it->second)->begin() ;
376 for( size_t j=0; j<n; j++, k++, ++m_it){
377 mnames[k] = name ;
378 res[k] = (*m_it)->is_void() ;
379 }
380 }
381 res.names( ) = mnames ;
382 return res ;
383 }
384
385
387 size_t n = properties.size() ;
388 Rcpp::CharacterVector out(n) ;
389 typename PROPERTY_MAP::iterator it = properties.begin( ) ;
390 for( size_t i=0; i<n; i++, ++it){
391 out[i] = it->first ;
392 }
393 return out ;
394 }
395
397 size_t n = properties.size() ;
398 Rcpp::CharacterVector pnames(n) ;
399 Rcpp::List out(n) ;
400 typename PROPERTY_MAP::iterator it = properties.begin( ) ;
401 for( size_t i=0; i<n; i++, ++it){
402 pnames[i] = it->first ;
403 out[i] = it->second->get_class() ;
404 }
405 out.names() = pnames ;
406 return out ;
407 }
408
410 size_t n = vec_methods.size() - specials ;
411 size_t ntotal = n + properties.size() ;
412 Rcpp::CharacterVector out(ntotal) ;
413 typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
414 std::string buffer ;
415 size_t i=0 ;
416 for( ; i<n; ++it){
417 buffer = it->first ;
418 if( buffer[0] == '[' ) continue ;
419 // if( (it->second)->nargs() == 0){
420 // buffer += "() " ;
421 // } else {
422 // buffer += "( " ;
423 // }
424 buffer += "( " ;
425 out[i] = buffer ;
426 i++ ;
427 }
428 typename PROPERTY_MAP::iterator prop_it = properties.begin();
429 for( ; i<ntotal; i++, ++prop_it){
430 out[i] = prop_it->first ;
431 }
432 return out ;
433 }
434
435 SEXP getProperty( SEXP field_xp , SEXP object) {
437 prop_class* prop = reinterpret_cast< prop_class* >( R_ExternalPtrAddr( field_xp ) ) ;
438 return prop->get( XP(object) );
440 }
441
442 void setProperty( SEXP field_xp, SEXP object, SEXP value) {
444 prop_class* prop = reinterpret_cast< prop_class* >( R_ExternalPtrAddr( field_xp ) ) ;
445 return prop->set( XP(object), value );
447 }
448
449
450 Rcpp::List fields( const XP_Class& class_xp ){
451 size_t n = properties.size() ;
452 Rcpp::CharacterVector pnames(n) ;
453 Rcpp::List out(n) ;
454 typename PROPERTY_MAP::iterator it = properties.begin( ) ;
455 for( size_t i=0; i<n; i++, ++it){
456 pnames[i] = it->first ;
457 out[i] = S4_field<Class>( it->second, class_xp ) ;
458 }
459 out.names() = pnames ;
460 return out ;
461 }
462
463 Rcpp::List getMethods( const XP_Class& class_xp, std::string& buffer){
464 RCPP_DEBUG_MODULE( "Rcpp::List getMethods( const XP_Class& class_xp, std::string& buffer" )
465 #if RCPP_DEBUG_LEVEL > 0
466 Rf_PrintValue( class_xp ) ;
467 #endif
468 size_t n = vec_methods.size() ;
469 Rcpp::CharacterVector mnames(n) ;
470 Rcpp::List res(n) ;
471 typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
473 for( size_t i=0; i<n; i++, ++it){
474 mnames[i] = it->first ;
475 v = it->second ;
476 res[i] = S4_CppOverloadedMethods<Class>( v , class_xp, it->first.c_str(), buffer ) ;
477 }
478 res.names() = mnames ;
479 return res ;
480 }
481
482 Rcpp::List getConstructors( const XP_Class& class_xp, std::string& buffer){
483 size_t n = constructors.size() ;
484 Rcpp::List out(n) ;
485 typename vec_signed_constructor::iterator it = constructors.begin( ) ;
486 for( size_t i=0; i<n; i++, ++it){
487 out[i] = S4_CppConstructor<Class>( *it , class_xp, name, buffer ) ;
488 }
489 return out ;
490 }
491
493
495
496 self& finalizer( void (*f)(Class*) ){
497 SetFinalizer( new FunctionFinalizer<Class>( f ) ) ;
498 return *this ;
499 }
500
501 virtual void run_finalizer( SEXP object ){
502 finalizer_pointer->run( XP(object) ) ;
503 }
504
506 self* ptr = get_instance() ;
507 if( ptr->finalizer_pointer ) delete ptr->finalizer_pointer ;
508 ptr->finalizer_pointer = f ;
509 }
510
513
519 std::string typeinfo_name ;
520
521
522 class_( ) : class_Base(), vec_methods(), properties(), specials(0), constructors(), factories() {};
523
524
525 public:
526
527 template <typename PARENT>
528 self& derives( const char* parent ){
529 typedef class_<PARENT> parent_class_ ;
530 typedef typename parent_class_::signed_method_class parent_signed_method_class ;
531 typedef typename parent_class_::method_class parent_method_class ;
532
533 Module* scope = getCurrentScope() ;
534 parent_class_* parent_class_pointer = reinterpret_cast< parent_class_* > ( scope->get_class_pointer( parent ) );
535
536 // importing methods
537 typename parent_class_::map_vec_signed_method::iterator parent_vec_methods_iterator = parent_class_pointer->vec_methods.begin() ;
538 typename parent_class_::map_vec_signed_method::iterator parent_vec_methods_end = parent_class_pointer->vec_methods.end() ;
539 std::string method_name ;
540 for( ; parent_vec_methods_iterator != parent_vec_methods_end; parent_vec_methods_iterator++){
541 method_name = parent_vec_methods_iterator->first ;
542
543 typedef typename parent_class_::vec_signed_method parent_vec_signed_method ;
544 parent_vec_signed_method* p_methods = parent_vec_methods_iterator->second ;
545 typename parent_vec_signed_method::iterator methods_it = p_methods->begin() ;
546 typename parent_vec_signed_method::iterator methods_end = p_methods->end() ;
547
548 for( ; methods_it != methods_end; methods_it++){
549 parent_signed_method_class* signed_method = *methods_it ;
550 parent_method_class* parent_method = signed_method->method ;
551
552 CppMethod<Class>* method = new CppInheritedMethod<Class,PARENT>( parent_method ) ;
553
554 AddMethod( method_name.c_str(), method, signed_method->valid , signed_method->docstring.c_str() ) ;
555 }
556 }
557
558
559 // importing properties
560 typedef typename parent_class_::PROPERTY_MAP parent_PROPERTY_MAP ;
561 typedef typename parent_PROPERTY_MAP::iterator parent_PROPERTY_MAP_iterator ;
562
563 parent_PROPERTY_MAP_iterator parent_property_it = parent_class_pointer->properties.begin() ;
564 parent_PROPERTY_MAP_iterator parent_property_end = parent_class_pointer->properties.end() ;
565 for( ; parent_property_it != parent_property_end; parent_property_it++){
567 parent_property_it->first.c_str(),
568 new CppInheritedProperty<Class,PARENT>( parent_property_it->second )
569 ) ;
570 }
571
572 std::string buffer( "Rcpp_" ) ; buffer += parent ;
573 get_instance()->parents.push_back( buffer.c_str() ) ;
574 return *this ;
575 }
576
577
578 } ;
579
580#endif
static Vector create()
Definition Vector.h:1134
CppProperty< Class > prop_class
Definition class.h:52
void SetFinalizer(finalizer_class *f)
Definition class.h:505
SignedMethod< Class > signed_method_class
Definition class.h:30
std::map< std::string, prop_class * > PROPERTY_MAP
Definition class.h:50
self & method(const char *name_, RESULT_TYPE(Class::*fun)(T...), const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition class.h:264
self & AddConstructor(constructor_class *ctor, ValidConstructor valid, const char *docstring=0)
Definition class.h:99
vec_signed_constructor constructors
Definition class.h:516
SEXP invoke_notvoid(SEXP method_xp, SEXP object, SEXP *args, int nargs)
Definition class.h:223
SignedFactory< Class > signed_factory_class
Definition class.h:46
CppFinalizer< Class > finalizer_class
Definition class.h:39
Factory_Base< Class > factory_class
Definition class.h:45
bool has_method(const std::string &m)
Definition class.h:300
std::map< std::string, method_class * > METHOD_MAP
Definition class.h:35
class_< Class > self
Definition class.h:27
Rcpp::List property_classes()
Definition class.h:396
class_()
Definition class.h:522
std::map< std::string, vec_signed_method * > map_vec_signed_method
Definition class.h:32
void setProperty(SEXP field_xp, SEXP object, SEXP value)
Definition class.h:442
std::vector< signed_method_class * > vec_signed_method
Definition class.h:31
self & constructor(const char *docstring=0, ValidConstructor valid=&yes_arity< sizeof...(T)>)
Definition class.h:114
self * class_pointer
Definition class.h:518
self & finalizer(void(*f)(Class *))
Definition class.h:496
Rcpp::List getConstructors(const XP_Class &class_xp, std::string &buffer)
Definition class.h:482
CppMethod< Class > method_class
Definition class.h:28
virtual void run_finalizer(SEXP object)
Definition class.h:501
self & default_constructor(const char *docstring=0, ValidConstructor valid=&yes_arity< 0 >)
Definition class.h:109
~class_()
Definition class.h:97
Rcpp::List fields(const XP_Class &class_xp)
Definition class.h:450
class_(const char *name_, const char *doc=0)
Definition class.h:53
std::pair< const std::string, method_class * > PAIR
Definition class.h:36
std::string property_class(const std::string &p)
Definition class.h:311
std::pair< std::string, vec_signed_method * > vec_signed_method_pair
Definition class.h:33
Constructor_Base< Class > constructor_class
Definition class.h:41
self & AddFactory(factory_class *fact, ValidConstructor valid, const char *docstring=0)
Definition class.h:104
Rcpp::CharacterVector property_names()
Definition class.h:386
self & derives(const char *parent)
Definition class.h:528
finalizer_class * finalizer_pointer
Definition class.h:514
SEXP invoke(SEXP method_xp, SEXP object, SEXP *args, int nargs)
Definition class.h:174
self & factory(Class *(*fun)(T...), const char *docstring=0, ValidConstructor valid=&yes_arity< sizeof...(T)>)
Definition class.h:119
std::string typeinfo_name
Definition class.h:519
Rcpp::CharacterVector complete()
Definition class.h:409
PROPERTY_MAP properties
Definition class.h:512
Rcpp::LogicalVector methods_voidness()
Definition class.h:361
Rcpp::CharacterVector method_names()
Definition class.h:317
vec_signed_factory factories
Definition class.h:517
SEXP newInstance(SEXP *args, int nargs)
Definition class.h:130
self & method(const char *name_, RESULT_TYPE(*fun)(Class *, T...), const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition class.h:288
self & nonconst_method(const char *name_, RESULT_TYPE(Class::*fun)(T...), const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition class.h:276
self & method(const char *name_, RESULT_TYPE(Class::*fun)(T...) const, const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition class.h:270
SEXP invoke_void(SEXP method_xp, SEXP object, SEXP *args, int nargs)
Definition class.h:201
std::string get_typeinfo_name()
Definition class.h:126
int specials
Definition class.h:515
Rcpp::List getMethods(const XP_Class &class_xp, std::string &buffer)
Definition class.h:463
std::pair< const std::string, prop_class * > PROP_PAIR
Definition class.h:51
self & AddProperty(const char *name_, prop_class *p)
Definition class.h:258
SEXP getProperty(SEXP field_xp, SEXP object)
Definition class.h:435
bool property_is_readonly(const std::string &p)
Definition class.h:306
bool has_property(const std::string &m)
Definition class.h:303
CppProperty< Class > prop_class
Definition class.h:49
map_vec_signed_method vec_methods
Definition class.h:511
self & AddMethod(const char *name_, method_class *m, ValidMethod valid=&yes, const char *docstring=0)
Definition class.h:246
self * get_instance()
Definition class.h:69
SignedConstructor< Class > signed_constructor_class
Definition class.h:42
std::vector< signed_constructor_class * > vec_signed_constructor
Definition class.h:43
std::vector< signed_factory_class * > vec_signed_factory
Definition class.h:47
Rcpp::XPtr< Class > XP
Definition class.h:38
self & const_method(const char *name_, RESULT_TYPE(Class::*fun)(T...) const, const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition class.h:282
Rcpp::IntegerVector methods_arity()
Definition class.h:337
self & const_method(const char *name_, RESULT_TYPE(*fun)(const Class *, T...), const char *docstring=0, ValidMethod valid=&yes_arity< sizeof...(T)>)
Definition class.h:294
bool has_default_constructor()
Definition class.h:158
#define RCPP_DEBUG_MODULE_1(fmt, MSG)
Definition debug.h:102
#define RCPP_DEBUG_MODULE(MSG)
Definition debug.h:101
#define RCPP_DEBUG_MODULE_2(fmt, M1, M2)
Definition debug.h:103
#define DEMANGLE(__TYPE__)
Definition exceptions.h:403
#define END_RCPP
Definition macros.h:99
#define VOID_END_RCPP
Definition macros.h:60
#define BEGIN_RCPP
Definition macros.h:49
Rcpp::XPtr< Rcpp::class_Base > XP_Class
Definition module.cpp:28
Vector< STRSXP > CharacterVector
Vector< LGLSXP > LogicalVector
Vector< INTSXP > IntegerVector
Vector< VECSXP > List
attribute_hidden Rcpp::Module * getCurrentScope()
Definition routines.h:270