diff --git a/ChangeLog b/ChangeLog index 196511795..2e6c8cbf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-06-02 JJ Allaire + + * src/attributes.cpp: Generate C++ native routines with underscore + prefix to avoid export when standard exportPattern is used in NAMESPACE + 2017-06-29 JJ Allaire * src/attributes.cpp: Replace dot (".") with underscore ("_") in package diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 9201aeeb2..9bf9fe21e 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -9,7 +9,7 @@ \itemize{ \item The \code{tinyformat.h} header now ends in a newline (\ghit{701}). \item Fixed rare protection error that occurred when fetching stack traces - during the construction of an Rcpp exception (Kirill Müller; + during the construction of an Rcpp exception (Kirill Müller; \ghit{706}). \item Compilation is now also possibly on Haiku-OS (Yo Gong in \ghpr{708} addressing \ghit{707}). @@ -31,6 +31,8 @@ addressing \ghit{712}). \item Replace dot (".") with underscore ("_") in package names when generating native routine registrations (fixes \ghit{721}). + \item Generate C++ native routines with underscore ("_") prefix to avoid + exporting when standard exportPattern is used in NAMESPACE } } } diff --git a/src/attributes.cpp b/src/attributes.cpp index 0da40f42e..defd01cb4 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -578,6 +578,7 @@ namespace attributes { const std::string& targetFile() const { return targetFile_; } const std::string& package() const { return package_; } const std::string& packageCpp() const { return packageCpp_; } + const std::string packageCppPrefix() const { return "_" + packageCpp(); } // Abstract interface for code generation virtual void writeBegin() = 0; @@ -611,10 +612,10 @@ namespace attributes { return "RcppExport_validate"; } std::string exportValidationFunctionRegisteredName() { - return packageCpp() + "_" + exportValidationFunction(); + return packageCppPrefix() + "_" + exportValidationFunction(); } std::string registerCCallableExportedName() { // #nocov - return packageCpp() + "_RcppExport_registerCCallable"; // #nocov + return packageCppPrefix() + "_RcppExport_registerCCallable"; // #nocov } // Commit the stream -- is a no-op if the existing code is identical @@ -1822,7 +1823,7 @@ namespace attributes { // write header/preamble std::ostringstream headerStream; headerStream << commentPrefix_ << " Generated by using " - << "Rcpp::compileAttributes()" + << "Rcpp::compileAttributes()" << " -> do not edit by hand" << std::endl; headerStream << commentPrefix_ << " Generator token: " << generatorToken() << std::endl << std::endl; @@ -1872,7 +1873,7 @@ namespace attributes { attributes, true, attributes.hasInterface(kInterfaceCpp), - packageCpp()); + packageCppPrefix()); // track cppExports, signatures, and native routines (we use these // at the end to generate the ValidateSignature and RegisterCCallable @@ -1973,7 +1974,7 @@ namespace attributes { std::vector routineArgs; for (std::size_t i=0;i& arguments = function.arguments(); @@ -2973,8 +2978,8 @@ namespace { public: SourceCppDynlib() {} - SourceCppDynlib(const std::string& cacheDir, - const std::string& cppSourcePath, + SourceCppDynlib(const std::string& cacheDir, + const std::string& cppSourcePath, Rcpp::List platform) : cppSourcePath_(cppSourcePath) @@ -3336,7 +3341,7 @@ namespace { Rcpp::Function dynlibLookupFunc = rcppEnv[".sourceCppDynlibLookup"]; Rcpp::List dynlibList = dynlibLookupFunc(cacheDir, file, code); if (dynlibList.length() > 0) - return SourceCppDynlib(dynlibList); + return SourceCppDynlib(dynlibList); else return SourceCppDynlib(); }