@@ -1141,6 +1141,11 @@ namespace attributes {
1141
1141
bool parseDependencies)
1142
1142
: sourceFile_(sourceFile), hasPackageInit_(false )
1143
1143
{
1144
+
1145
+ // transform packageName to valid C++ symbol
1146
+ std::string packageNameCpp = packageName;
1147
+ std::replace (packageNameCpp.begin (), packageNameCpp.end (), ' .' , ' _' );
1148
+
1144
1149
// First read the entire file into a std::stringstream so we can check
1145
1150
// it for attributes (we don't want to do any of our more expensive
1146
1151
// processing steps if there are no attributes to parse)
@@ -1151,7 +1156,7 @@ namespace attributes {
1151
1156
// Check for attribute signature
1152
1157
if (contents.find (" [[Rcpp::" ) != std::string::npos ||
1153
1158
contents.find (" RCPP_MODULE" ) != std::string::npos ||
1154
- contents.find (" R_init_" + packageName ) != std::string::npos) {
1159
+ contents.find (" R_init_" + packageNameCpp ) != std::string::npos) {
1155
1160
1156
1161
// Now read into a list of strings (which we can pass to regexec)
1157
1162
// First read into a std::deque (which will handle lots of append
@@ -1230,7 +1235,7 @@ namespace attributes {
1230
1235
// Scan for package init function
1231
1236
hasPackageInit_ = false ;
1232
1237
commentState.reset ();
1233
- std::string pkgInit = " R_init_" + packageName ;
1238
+ std::string pkgInit = " R_init_" + packageNameCpp ;
1234
1239
Rcpp::List initMatches = regexMatches (lines_, " ^[^/]+" + pkgInit + " .*DllInfo.*$" );
1235
1240
for (int i = 0 ; i<initMatches.size (); i++) {
1236
1241
@@ -1968,7 +1973,7 @@ namespace attributes {
1968
1973
std::vector<std::size_t > routineArgs;
1969
1974
for (std::size_t i=0 ;i<nativeRoutines_.size (); i++) {
1970
1975
const Attribute& attr = nativeRoutines_[i];
1971
- routineNames.push_back (package () + " _" + attr.function ().name ());
1976
+ routineNames.push_back (packageCpp () + " _" + attr.function ().name ());
1972
1977
routineArgs.push_back (attr.function ().arguments ().size ());
1973
1978
}
1974
1979
std::string kRcppModuleBoot = " _rcpp_module_boot_" ;
@@ -2016,7 +2021,7 @@ namespace attributes {
2016
2021
2017
2022
ostr () << std::endl;
2018
2023
2019
- ostr () << " RcppExport void R_init_" << package () << " (DllInfo *dll) {" << std::endl;
2024
+ ostr () << " RcppExport void R_init_" << packageCpp () << " (DllInfo *dll) {" << std::endl;
2020
2025
ostr () << " R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);" << std::endl;
2021
2026
ostr () << " R_useDynamicSymbols(dll, FALSE);" << std::endl;
2022
2027
ostr () << " }" << std::endl;
0 commit comments