mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
new method, getMethodSigs. spits out callback proto-functions
This commit is contained in:
parent
f903140d22
commit
a8e74787b7
|
|
@ -1776,6 +1776,45 @@ String Namespace::Entry::getPrototypeString() const
|
|||
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];
|
||||
|
|
|
|||
|
|
@ -164,6 +164,10 @@ public:
|
|||
/// Return a full prototype string for the function including return type, function name,
|
||||
/// and arguments.
|
||||
String getPrototypeString() const;
|
||||
|
||||
/// Return a minimalized prototype string for the function including return type, function name,
|
||||
/// and arguments.
|
||||
String getPrototypeSig() const;
|
||||
};
|
||||
|
||||
Entry* mEntryList;
|
||||
|
|
|
|||
|
|
@ -2655,6 +2655,50 @@ DefineEngineMethod( SimObject, dumpMethods, ArrayObject*, (),,
|
|||
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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue