mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-13 09:20:47 +00:00
Merge pull request #964 from Azaezel/alpha41/protoMethods
new method, getMethodSigs. spits out callback proto-functions
This commit is contained in:
commit
6c8dfdbe4c
3 changed files with 87 additions and 0 deletions
|
|
@ -1776,6 +1776,45 @@ String Namespace::Entry::getPrototypeString() const
|
||||||
return str.end();
|
return str.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Namespace::Entry::getPrototypeSig() const
|
||||||
|
{
|
||||||
|
StringBuilder str;
|
||||||
|
|
||||||
|
// Add function name and arguments.
|
||||||
|
|
||||||
|
if (mType == ScriptCallbackType)
|
||||||
|
str.append(cb.mCallbackName);
|
||||||
|
else
|
||||||
|
str.append(mFunctionName);
|
||||||
|
if (mHeader)
|
||||||
|
{
|
||||||
|
Vector< String > argList;
|
||||||
|
sParseList(mHeader->mArgString, argList);
|
||||||
|
|
||||||
|
const U32 numArgs = argList.size();
|
||||||
|
|
||||||
|
str.append("(%this");
|
||||||
|
|
||||||
|
if (numArgs > 0)
|
||||||
|
str.append(',');
|
||||||
|
for (U32 i = 0; i < numArgs; ++i)
|
||||||
|
{
|
||||||
|
// Add separator if not first arg.
|
||||||
|
|
||||||
|
String name;
|
||||||
|
String type;
|
||||||
|
|
||||||
|
if (i > 0)
|
||||||
|
str.append(',');
|
||||||
|
str.append('%');
|
||||||
|
sGetArgNameAndType(argList[i], type, name);
|
||||||
|
str.append(name);
|
||||||
|
}
|
||||||
|
str.append(')');
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.end();
|
||||||
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
StringTableEntry Namespace::mActivePackages[Namespace::MaxActivePackages];
|
StringTableEntry Namespace::mActivePackages[Namespace::MaxActivePackages];
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,10 @@ public:
|
||||||
/// Return a full prototype string for the function including return type, function name,
|
/// Return a full prototype string for the function including return type, function name,
|
||||||
/// and arguments.
|
/// and arguments.
|
||||||
String getPrototypeString() const;
|
String getPrototypeString() const;
|
||||||
|
|
||||||
|
/// Return a minimalized prototype string for the function including return type, function name,
|
||||||
|
/// and arguments.
|
||||||
|
String getPrototypeSig() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
Entry* mEntryList;
|
Entry* mEntryList;
|
||||||
|
|
|
||||||
|
|
@ -2655,6 +2655,50 @@ DefineEngineMethod( SimObject, dumpMethods, ArrayObject*, (),,
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(SimObject, getMethodSigs, ArrayObject*, (), ,
|
||||||
|
"List the methods defined on this object.\n\n"
|
||||||
|
"Each description is a newline-separated vector with the following elements:\n"
|
||||||
|
"- method prototype string.\n"
|
||||||
|
"- Documentation string (not including prototype). This takes up the remainder of the vector.\n"
|
||||||
|
"@return An ArrayObject populated with (name,description) pairs of all methods defined on the object.")
|
||||||
|
{
|
||||||
|
Namespace* ns = object->getNamespace();
|
||||||
|
if (!ns)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ArrayObject* dictionary = new ArrayObject();
|
||||||
|
dictionary->registerObject();
|
||||||
|
|
||||||
|
VectorPtr<Namespace::Entry*> vec(__FILE__, __LINE__);
|
||||||
|
ns->getEntryList(&vec);
|
||||||
|
for (Vector< Namespace::Entry* >::iterator j = vec.begin(); j != vec.end(); j++)
|
||||||
|
{
|
||||||
|
Namespace::Entry* e = *j;
|
||||||
|
|
||||||
|
if (e->mType != Namespace::Entry::ScriptCallbackType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
StringBuilder str;
|
||||||
|
str.append("function ");
|
||||||
|
str.append(ns->getName());
|
||||||
|
str.append("::");
|
||||||
|
str.append(e->getPrototypeSig());
|
||||||
|
str.append('\n');
|
||||||
|
str.append("{");
|
||||||
|
String docs = e->getDocString();
|
||||||
|
if (!docs.isEmpty())
|
||||||
|
{
|
||||||
|
str.append("\n/*");
|
||||||
|
str.append(docs);
|
||||||
|
str.append("\n*/");
|
||||||
|
}
|
||||||
|
str.append('\n');
|
||||||
|
str.append("}");
|
||||||
|
dictionary->push_back(e->mFunctionName, str.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue