mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
allow __py__ functions for python-only optimizations
This commit is contained in:
parent
754e341ee2
commit
d51e49516a
@ -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 methodName;
|
||||
const std::string badChars("!@#$%^&*()<>,.-=+~{}?");
|
||||
int nextCap = 0;
|
||||
for(std::string::const_iterator chr = cppName.begin(); chr != cppName.end(); chr++)
|
||||
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;
|
||||
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);
|
||||
nextCap = 0;
|
||||
methodName += toupper(*chr);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
methodName = checkKeyword(methodName);
|
||||
return methodName;
|
||||
// # Mangle names that happen to be python keywords so they are not anymore
|
||||
methodName = checkKeyword(methodName);
|
||||
return methodName;
|
||||
}
|
||||
|
||||
std::string methodNameFromCppName(InterfaceMaker::Function *func, const std::string &className)
|
||||
|
Loading…
x
Reference in New Issue
Block a user