diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 38780df02..92080dff1 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -2718,6 +2718,59 @@ DefineEngineMethod(SimObject, getMethodSigs, ArrayObject*, (bool commands), (fal return dictionary; } + +DefineEngineFunction(getMethodSigsNS, ArrayObject*, (StringTableEntry className, bool commands), (false), + "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 = Con::lookupNamespace(className); + if (!ns) + return 0; + + ArrayObject* dictionary = new ArrayObject(); + dictionary->registerObject(); + + VectorPtr vec(__FILE__, __LINE__); + ns->getEntryList(&vec); + for (Vector< Namespace::Entry* >::iterator j = vec.begin(); j != vec.end(); j++) + { + Namespace::Entry* e = *j; + + if (commands) + { + if ((e->mType < Namespace::Entry::ConsoleFunctionType)) + continue; + } + else + { + 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 {