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,52 +275,61 @@ std::string nonClassNameFromCppName(const std::string &cppName_in)
} }
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
std::string methodNameFromCppName(const std::string &cppName, const std::string &className) { std::string
std::string methodName; methodNameFromCppName(const std::string &cppName, const std::string &className) {
const std::string badChars("!@#$%^&*()<>,.-=+~{}?"); std::string origName = cppName;
int nextCap = 0;
for(std::string::const_iterator chr = cppName.begin(); chr != cppName.end(); chr++) 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;
const std::string badChars("!@#$%^&*()<>,.-=+~{}?");
int nextCap = 0;
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)
{ {
} }
else if (*chr == '_' || *chr == ' ') else if (*chr == '_' || *chr == ' ')
{ {
nextCap = 1; nextCap = 1;
} }
else if (nextCap) else if (nextCap)
{ {
methodName += toupper(*chr); methodName += toupper(*chr);
nextCap = 0; nextCap = 0;
} }
else else
{ {
methodName += *chr; methodName += *chr;
} }
} }
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;
}
}
if(className.size() > 0)
{
string LookUpName = className + '.' + cppName;
for(int x = 0; classRenameDictionary[x]._from != NULL; x++)
{
if(LookUpName == methodRenameDictionary[x]._from)
methodName = methodRenameDictionary[x]._to; methodName = methodRenameDictionary[x]._to;
} }
} }
if(className.size() > 0)
{
string LookUpName = className + '.' + cppName;
for(int x = 0; classRenameDictionary[x]._from != NULL; x++)
{
if(LookUpName == methodRenameDictionary[x]._from)
methodName = methodRenameDictionary[x]._to;
}
}
// # 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;
} }
std::string methodNameFromCppName(InterfaceMaker::Function *func, const std::string &className) std::string methodNameFromCppName(InterfaceMaker::Function *func, const std::string &className)