From 25e96b613bc78d44cf090e0493f62483625eb2a9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 15 Mar 2023 00:14:20 -0500 Subject: [PATCH] better callback filtering for getMethodSigs add a bool filter to getMethodSigs so it can also return script commands example code reminder note: //MainMenuGui.getPrototypeList(); //MainMenuGui.getPrototypeDef("onAdd"); function simObject::getPrototypeList(%this) { %methodArray = %this.getMethodSigs(); %methodCount = %methodArray.count(); for (%i=0;%i<%methodCount;%i++) { %methodDef = getRecord(%methodArray.getValue(%i),0); %methodName = strreplace(%methodDef,"::"," "); %methodName = getWord(strreplace(%methodName,"("," "),2); warn(%methodName); } } function simObject::getPrototypeDef(%this, %funcName) { %methodArray = %this.getMethodSigs(); %methodCount = %methodArray.count(); for (%i=0;%i<%methodCount;%i++) { %methodDef = %methodArray.getValue(%i); %methodName = strreplace(%methodDef,"::"," "); %methodName = getWord(strreplace(%methodName,"("," "),2); if (%funcName $= %methodName) warn(%methodDef); } } --- Engine/source/console/simObject.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 8245f7cea..7d7e3f09d 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -2662,7 +2662,7 @@ DefineEngineMethod( SimObject, dumpMethods, ArrayObject*, (),, return dictionary; } -DefineEngineMethod(SimObject, getMethodSigs, ArrayObject*, (), , +DefineEngineMethod(SimObject, getMethodSigs, ArrayObject*, (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" @@ -2682,9 +2682,16 @@ DefineEngineMethod(SimObject, getMethodSigs, ArrayObject*, (), , { Namespace::Entry* e = *j; - if (e->mType != Namespace::Entry::ScriptCallbackType) - continue; - + 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());