21 #ifndef Rcpp_Module_Module_h
22 #define Rcpp_Module_Module_h
31 typedef std::map<std::string,CppFunction*>
MAP ;
34 typedef std::map<std::string,class_Base*>
CLASS_MAP ;
35 typedef std::pair<const std::string,class_Base*>
CLASS_PAIR ;
53 inline SEXP
invoke(
const std::string& name_, SEXP* args,
int nargs){
54 MAP::iterator it =
functions.find( name_ );
56 throw std::range_error(
"no such function" ) ;
59 if( fun->
nargs() > nargs ){
60 throw std::range_error(
"incorrect number of arguments" ) ;
64 _[
"result"] = fun->operator()( args ),
77 for(
size_t i=0; i<n; i++, ++it){
78 x[i] = (it->second)->nargs() ;
79 names[i] = it->first ;
92 for(
size_t i=0; i<n; i++, ++it){
93 names[i] = it->first ;
104 CLASS_MAP::iterator it =
classes.begin() ;
105 for(
size_t i=0; i<n; i++, ++it){
106 names[i] = it->first ;
127 for( ; i<nf; i++, ++it) {
129 if( (it->second)->nargs() == 0 ) {
136 CLASS_MAP::iterator cit =
classes.begin() ;
137 for(
size_t j=0; j<nc; j++, i++, ++cit){
138 res[i] = cit->first ;
158 for(
size_t i=0; i<n; i++, ++it){
159 if( name_.compare( it->first ) == 0){
183 for(
size_t i=0; i<n; i++, ++it){
184 if( name_.compare( it->first ) == 0){
212 CLASS_MAP::iterator it =
classes.find(cl) ;
213 if( it ==
classes.end() )
throw std::range_error(
"no such class" ) ;
219 void add_enum(
const std::string& parent_class_typeinfo_name,
const std::string& enum_name,
const std::map<std::string, int>& value ){
224 if( it->second->has_typeinfo_name(parent_class_typeinfo_name) ){
225 target_class = it->second ;
230 target_class->
add_enum( enum_name, value ) ;
virtual DL_FUNC get_function_ptr()=0
virtual SEXP get_formals()
virtual void signature(std::string &, const char *)
void AddClass(const char *name_, class_Base *cptr)
IntegerVector functions_arity()
void Add(const char *name_, CppFunction *ptr)
Module(const char *name_)
std::pair< const std::string, class_Base * > CLASS_PAIR
class_Base * get_class_pointer(const std::string &cl)
std::map< std::string, CppFunction * > MAP
SEXP invoke(const std::string &name_, SEXP *args, int nargs)
std::map< std::string, class_Base * > CLASS_MAP
bool has_function(const std::string &m)
void add_enum(const std::string &parent_class_typeinfo_name, const std::string &enum_name, const std::map< std::string, int > &value)
bool has_class(const std::string &m)
std::pair< const std::string, CppFunction * > FUNCTION_PAIR
CppClass get_class(const std::string &cl)
SEXP get_function(const std::string &name_)
CharacterVector functions_names()
CharacterVector class_names()
CharacterVector complete()
CLASS_MAP::iterator CLASS_ITERATOR
DL_FUNC get_function_ptr(const std::string &name_)
void add_enum(const std::string &enum_name, const std::map< std::string, int > &value)
sugar::Sign< INTSXP, NA, T > sign(const VectorBase< INTSXP, NA, T > &t)
static internal::NamedPlaceHolder _