allow __py__ functions for python-only optimizations

This commit is contained in:
David Rose 2010-06-16 21:57:37 +00:00
parent 754e341ee2
commit d51e49516a

View File

@ -275,11 +275,20 @@ std::string nonClassNameFromCppName(const std::string &cppName_in)
} }
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
std::string methodNameFromCppName(const std::string &cppName, const std::string &className) { std::string
methodNameFromCppName(const std::string &cppName, const std::string &className) {
std::string origName = cppName;
if (origName.substr(0, 6) == "__py__") {
// By convention, a leading prefix of "__py__" is stripped. This
// indicates a Python-specific variant of a particular method.
origName = origName.substr(6);
}
std::string methodName; std::string methodName;
const std::string badChars("!@#$%^&*()<>,.-=+~{}?"); const std::string badChars("!@#$%^&*()<>,.-=+~{}?");
int nextCap = 0; int nextCap = 0;
for(std::string::const_iterator chr = cppName.begin(); chr != cppName.end(); chr++) for(std::string::const_iterator chr = origName.begin(); chr != origName.end(); chr++)
{ {
if (badChars.find(*chr) != std::string::npos) if (badChars.find(*chr) != std::string::npos)
{ {
@ -301,7 +310,7 @@ std::string methodNameFromCppName(const std::string &cppName, const std::string
for(int x = 0; methodRenameDictionary[x]._from != NULL; x++) for(int x = 0; methodRenameDictionary[x]._from != NULL; x++)
{ {
if(cppName == methodRenameDictionary[x]._from) if(origName == methodRenameDictionary[x]._from)
{ {
methodName = methodRenameDictionary[x]._to; methodName = methodRenameDictionary[x]._to;
} }
@ -318,7 +327,7 @@ std::string methodNameFromCppName(const std::string &cppName, const std::string
} }
// # Mangle names that happen to be python keywords so they are not anymore // # Mangle names that happen to be python keywords so they are not anymore
methodName = checkKeyword(methodName); methodName = checkKeyword(methodName);
return methodName; return methodName;
} }