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 ) ;
85 #include <Rcpp/module/Module_generated_get_return_type.h>
86 #include <Rcpp/module/Module_generated_get_signature.h>
89 #include <Rcpp/module/Module_generated_CppFunction.h>
98 template <
typename Class>
109 virtual void signature(std::string& s,
const char* name ){ s = name ; }
112 template <
typename Class,
typename Parent>
134 #include <Rcpp/module/Module_generated_ctor_signature.h>
135 #include <Rcpp/module/Module_generated_Constructor.h>
136 #include <Rcpp/module/Module_generated_Factory.h>
138 #include <Rcpp/module/Module_generated_class_signature.h>
143 template <
typename Class>
148 Constructor_Base<Class>* ctor_,
153 Constructor_Base<Class>*
ctor ;
158 inline void signature(std::string& buffer,
const std::string& class_name){
159 ctor->signature(buffer, class_name) ;
163 template <
typename Class>
168 Factory_Base<Class>* fact_,
178 inline void signature(std::string& buffer,
const std::string& class_name){
179 fact->signature(buffer, class_name) ;
184 template <
typename Class>
197 inline void signature(std::string& s,
const char* name){
203 template <
typename Class>
209 RCPP_DEBUG(
"S4_CppConstructor( SignedConstructor<Class>* m, SEXP class_xp, const std::string& class_name, std::string& buffer" ) ;
211 field(
"class_pointer" ) = class_xp ;
212 field(
"nargs" ) = m->nargs() ;
213 m->signature( buffer, class_name ) ;
214 field(
"signature" ) = buffer ;
215 field(
"docstring" ) = m->docstring ;
225 template <
typename Class>
234 RCPP_DEBUG_2(
"S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp = <%p>, const char* name = %s, std::string& buffer )", name, class_xp.
asSexp() )
236 Rf_PrintValue( class_xp ) ;
244 for(
int i=0;
i<
n;
i++){
251 signatures[
i] = buffer ;
255 field(
"class_pointer" ) = class_xp ;
257 field(
"void" ) = voidness ;
258 field(
"const" ) = constness ;
259 field(
"docstrings" ) = docstrings ;
260 field(
"signatures" ) = signatures ;
261 field(
"nargs" ) = nargs ;
273 #include <Rcpp/module/Module_generated_CppMethod.h>
274 #include <Rcpp/module/Module_generated_Pointer_CppMethod.h>
276 template <
typename Class>
283 virtual SEXP
get(Class* ) {
throw std::range_error(
"cannot retrieve property"); }
284 virtual void set(Class*, SEXP) {
throw std::range_error(
"cannot set property"); }
291 template <
typename Class,
typename Parent>
310 template <
typename Class>
314 virtual void run(Class* ){} ;
317 template <
typename Class>
323 virtual void run(Class*
object){
331 template <
typename Class>
336 RCPP_DEBUG(
"S4_field( CppProperty<Class>* p, const XP_Class& class_xp )" )
340 field(
"class_pointer" ) = class_xp ;
341 field(
"docstring" ) = p->docstring ;
354 template <
typename Enum,
typename Parent>
367 self&
value(
const char* name_, Enum value_ ){
368 values.insert(
PAIR( name_, static_cast<int>( value_ ) ) ) ;
375 typedef std::map< std::string, int >
MAP ;
383 #include <Rcpp/module/Module_generated_function.h>
385 template <
typename FROM,
typename TO>
386 void converter(
const char* from,
const char* to, TO (*fun)(FROM),
const char* docstring = 0 ){
387 std::string fun_name = internal::get_converter_name<FROM,TO>( from, to ) ;
388 function( fun_name.c_str(), fun, docstring ) ;
422 template <
typename T>
operator T()
const {
return (T)
p_fun ; }
431 #define RCPP_MODULE_BOOT(name) _rcpp_module_boot_##name
433 #define RCPP_MODULE(name) \
434 void _rcpp_module_##name##_init() ; \
435 static Rcpp::Module _rcpp_module_##name( # name ) ; \
436 extern "C" SEXP _rcpp_module_boot_##name(){ \
437 ::setCurrentScope( & _rcpp_module_##name ) ; \
438 _rcpp_module_##name##_init( ) ; \
439 Rcpp::XPtr<Rcpp::Module> mod_xp(& _rcpp_module_##name , false); \
440 ::setCurrentScope( 0 ) ; \
443 void _rcpp_module_##name##_init()
447 #define VARIABLE_IS_NOT_USED __attribute__ ((unused))
449 #define VARIABLE_IS_NOT_USED
457 #define GET_MODULE_SYM ( moduleSym == NULL ? moduleSym = Rf_install("Module") : moduleSym )
460 #define LOAD_RCPP_MODULE(NAME) Rf_eval( Rf_lang2( GET_MODULE_SYM, _rcpp_module_boot_##NAME() ), R_GlobalEnv )