@@ -675,8 +675,11 @@ namespace attributes {
675675 // for generating C++ interfaces
676676 std::vector<Attribute> cppExports_;
677677
678- // for generating native routine registration
678+ // for generating Rcpp::export native routine registration
679679 std::vector<Attribute> nativeRoutines_;
680+
681+ // for generating module native routine registration
682+ std::vector<std::string> modules_;
680683 };
681684
682685 // Class which manages generating PackageName_RcppExports.h header file
@@ -1888,6 +1891,9 @@ namespace attributes {
18881891 }
18891892 } // #nocov end
18901893
1894+ // record modules
1895+ const std::vector<std::string>& modules = attributes.modules ();
1896+ modules_.insert (modules_.end (), modules.begin (), modules.end ());
18911897
18921898 // verbose if requested
18931899 if (verbose) { // #nocov start
@@ -1955,7 +1961,7 @@ namespace attributes {
19551961 }
19561962
19571963 // write native routines
1958- if (!hasPackageInit && !nativeRoutines_.empty ()) {
1964+ if (!hasPackageInit && ( !nativeRoutines_.empty () || !modules_. empty () )) {
19591965
19601966 // build list of routines we will register
19611967 std::vector<std::string> routineNames;
@@ -1965,6 +1971,11 @@ namespace attributes {
19651971 routineNames.push_back (package () + " _" + attr.function ().name ());
19661972 routineArgs.push_back (attr.function ().arguments ().size ());
19671973 }
1974+ std::string kRcppModuleBoot = " _rcpp_module_boot_" ;
1975+ for (std::size_t i=0 ;i<modules_.size (); i++) {
1976+ routineNames.push_back (kRcppModuleBoot + modules_[i]);
1977+ routineArgs.push_back (0 );
1978+ }
19681979 if (hasCppInterface ()) {
19691980 routineNames.push_back (registerCCallableExportedName ());
19701981 routineArgs.push_back (0 );
@@ -1976,6 +1987,11 @@ namespace attributes {
19761987 std::vector<std::string> declarations = extraRoutines[" declarations" ];
19771988 std::vector<std::string> callEntries = extraRoutines[" call_entries" ];
19781989
1990+ // add declarations for modules
1991+ for (std::size_t i=0 ;i<modules_.size (); i++) {
1992+ declarations.push_back (" RcppExport SEXP " + kRcppModuleBoot + modules_[i] + " ();" );
1993+ }
1994+
19791995 // generate declarations
19801996 if (declarations.size () > 0 ) {
19811997 ostr () << std::endl;
0 commit comments