mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +00:00
Eliminate ConsoleFunction and ConsoleMethod, replace with DefineEngineStringlyVariadic
This commit is contained in:
parent
6b524ae58a
commit
7d91d0a577
18 changed files with 112 additions and 84 deletions
|
|
@ -1191,11 +1191,6 @@ public:
|
|||
# define ConsoleFunctionGroupBegin(groupName, usage) \
|
||||
static ConsoleConstructor cfg_ConsoleFunctionGroup_##groupName##_GroupBegin(NULL,#groupName,usage)
|
||||
|
||||
# define ConsoleFunction(name,returnType,minArgs,maxArgs,usage1) \
|
||||
returnType cf_##name(SimObject *, S32, ConsoleValueRef *argv); \
|
||||
ConsoleConstructor cc_##name##_obj(NULL,#name,cf_##name,usage1,minArgs,maxArgs); \
|
||||
returnType cf_##name(SimObject *, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleToolFunction(name,returnType,minArgs,maxArgs,usage1) \
|
||||
returnType ctf_##name(SimObject *, S32, ConsoleValueRef *argv); \
|
||||
ConsoleConstructor cc_##name##_obj(NULL,#name,ctf_##name,usage1,minArgs,maxArgs, true); \
|
||||
|
|
@ -1211,15 +1206,6 @@ public:
|
|||
# define ConsoleMethodGroupBegin(className, groupName, usage) \
|
||||
static ConsoleConstructor cc_##className##_##groupName##_GroupBegin(#className,#groupName,usage)
|
||||
|
||||
# define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \
|
||||
inline returnType cm_##className##_##name(className *, S32, ConsoleValueRef *argv); \
|
||||
returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \
|
||||
AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \
|
||||
conmethod_return_##returnType ) cm_##className##_##name(static_cast<className*>(object),argc,argv); \
|
||||
}; \
|
||||
ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \
|
||||
inline returnType cm_##className##_##name(className *object, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleMethodGroupEnd(className, groupName) \
|
||||
static ConsoleConstructor cc_##className##_##groupName##_GroupEnd(#className,#groupName,NULL)
|
||||
|
||||
|
|
|
|||
|
|
@ -1200,7 +1200,7 @@ DefineEngineFunction( isValidIP, bool, ( const char* str),,
|
|||
|
||||
// Torque won't normally add another string if it already exists with another casing,
|
||||
// so this forces the addition. It should be called once near the start, such as in main.cs.
|
||||
ConsoleFunction(addCaseSensitiveStrings,void,2,0,"[string1, string2, ...]"
|
||||
DefineEngineStringlyVariadicFunction(addCaseSensitiveStrings,void,2,0,"[string1, string2, ...]"
|
||||
"Adds case sensitive strings to the StringTable.")
|
||||
{
|
||||
for(int i = 1; i < argc; i++)
|
||||
|
|
@ -1879,7 +1879,7 @@ DefineEngineFunction( getTag, const char*, ( const char* textTagString ), , "( s
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( echo, void, 2, 0, "( string message... ) "
|
||||
DefineEngineStringlyVariadicFunction( echo, void, 2, 0, "( string message... ) "
|
||||
"@brief Logs a message to the console.\n\n"
|
||||
"Concatenates all given arguments to a single string and prints the string to the console. "
|
||||
"A newline is added automatically after the text.\n\n"
|
||||
|
|
@ -1902,7 +1902,7 @@ ConsoleFunction( echo, void, 2, 0, "( string message... ) "
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( warn, void, 2, 0, "( string message... ) "
|
||||
DefineEngineStringlyVariadicFunction( warn, void, 2, 0, "( string message... ) "
|
||||
"@brief Logs a warning message to the console.\n\n"
|
||||
"Concatenates all given arguments to a single string and prints the string to the console as a warning "
|
||||
"message (in the in-game console, these will show up using a turquoise font by default). "
|
||||
|
|
@ -1926,7 +1926,7 @@ ConsoleFunction( warn, void, 2, 0, "( string message... ) "
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( error, void, 2, 0, "( string message... ) "
|
||||
DefineEngineStringlyVariadicFunction( error, void, 2, 0, "( string message... ) "
|
||||
"@brief Logs an error message to the console.\n\n"
|
||||
"Concatenates all given arguments to a single string and prints the string to the console as an error "
|
||||
"message (in the in-game console, these will show up using a red font by default). "
|
||||
|
|
@ -2236,7 +2236,7 @@ DefineEngineFunction( generateUUID, Torque::UUID, (),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( call, const char *, 2, 0, "( string functionName, string args... ) "
|
||||
DefineEngineStringlyVariadicFunction( call, const char *, 2, 0, "( string functionName, string args... ) "
|
||||
"Apply the given arguments to the specified global function and return the result of the call.\n\n"
|
||||
"@param functionName The name of the function to call. This function must be in the global namespace, i.e. "
|
||||
"you cannot call a function in a namespace through #call. Use eval() for that.\n"
|
||||
|
|
|
|||
|
|
@ -855,6 +855,64 @@ public:
|
|||
); \
|
||||
static inline returnType _fn ## className ## name ## impl args
|
||||
|
||||
# define DefineEngineStringlyVariadicFunction(name,returnType,minArgs,maxArgs,usage) \
|
||||
static inline returnType _fn ## name ## impl (SimObject *, S32 argc, ConsoleValueRef *argv); \
|
||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
|
||||
(S32 argc, const char** argv) \
|
||||
{ \
|
||||
_CHECK_ENGINE_INITIALIZED( name, returnType ); \
|
||||
StringStackConsoleWrapper args(argc, argv); \
|
||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||
_fn ## name ## impl(NULL, args.count(), args) \
|
||||
); \
|
||||
} \
|
||||
static _EngineFunctionDefaultArguments< void (S32 argc, const char** argv) > _fn ## name ## DefaultArgs; \
|
||||
static EngineFunctionInfo _fn ## name ## FunctionInfo( \
|
||||
#name, \
|
||||
&_SCOPE<>()(), \
|
||||
usage, \
|
||||
#returnType " " #name "(S32 argc, const char** argv)", \
|
||||
"fn" #name, \
|
||||
TYPE< returnType (S32 argc, const char** argv) >(), \
|
||||
&_fn ## name ## DefaultArgs, \
|
||||
( void* ) &fn ## name, \
|
||||
0 \
|
||||
); \
|
||||
ConsoleConstructor cc_##name##_obj(NULL,#name,_fn ## name ## impl,usage,minArgs,maxArgs); \
|
||||
returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define DefineEngineStringlyVariadicMethod(className, name,returnType,minArgs,maxArgs,usage) \
|
||||
static inline returnType _fn ## className ## _ ## name ## impl (className* object, S32 argc, ConsoleValueRef* argv); \
|
||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
|
||||
(className* object, S32 argc, const char** argv) \
|
||||
{ \
|
||||
_CHECK_ENGINE_INITIALIZED( name, returnType ); \
|
||||
StringStackConsoleWrapper args(argc, argv); \
|
||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||
_fn ## className ## _ ## name ## impl(object, args.count(), args) \
|
||||
); \
|
||||
} \
|
||||
static _EngineFunctionDefaultArguments< void (className* object, S32 argc, const char** argv) > _fn ## className ## _ ## name ## DefaultArgs; \
|
||||
static EngineFunctionInfo _fn ## className ## _ ## name ## FunctionInfo( \
|
||||
#name, \
|
||||
&_SCOPE<>()(), \
|
||||
usage, \
|
||||
#returnType " " #name "(SimObject* object, S32 argc, const char** argv)", \
|
||||
"fn" #className "_" #name, \
|
||||
TYPE< returnType (SimObject* object, S32 argc, const char** argv) >(), \
|
||||
&_fn ## className ## _ ## name ## DefaultArgs, \
|
||||
( void* ) &fn ## className ## _ ## name, \
|
||||
0 \
|
||||
); \
|
||||
returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValueRef* argv) { \
|
||||
AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \
|
||||
conmethod_return_##returnType ) _fn ## className ## _ ## name ## impl(static_cast<className*>(object),argc,argv); \
|
||||
}; \
|
||||
ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage,minArgs,maxArgs); \
|
||||
static inline returnType _fn ## className ## _ ## name ## impl(className *object, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
|
||||
|
||||
// The following three macros are only temporary. They allow to define engineAPI functions using the framework
|
||||
// here in this file while being visible only in the new API. When the console interop is removed, these macros
|
||||
// can be removed and all their uses be replaced with their corresponding versions that now still include support
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ DefineEngineFunction( getTimeSinceStart, S32, (S32 scheduleId), ,"getTimeSinceSt
|
|||
return ret;
|
||||
}
|
||||
|
||||
ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1...argN>)")
|
||||
DefineEngineStringlyVariadicFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1...argN>)")
|
||||
{
|
||||
U32 timeDelta = U32(dAtof(argv[1]));
|
||||
SimObject *refObject = Sim::findObject(argv[2]);
|
||||
|
|
|
|||
|
|
@ -2945,7 +2945,7 @@ DefineEngineMethod( SimObject, setFieldType, void, ( const char* fieldName, cons
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( SimObject, call, const char*, 3, 0, "( string method, string args... ) Dynamically call a method on an object.\n"
|
||||
DefineEngineStringlyVariadicMethod( SimObject, call, const char*, 3, 0, "( string method, string args... ) Dynamically call a method on an object.\n"
|
||||
"@param method Name of method to call.\n"
|
||||
"@param args Zero or more arguments for the method.\n"
|
||||
"@return The result of the method call." )
|
||||
|
|
@ -3047,7 +3047,7 @@ DefineEngineMethod( SimObject, delete, void, (),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( SimObject,schedule, S32, 4, 0, "( float time, string method, string args... ) Delay an invocation of a method.\n"
|
||||
DefineEngineStringlyVariadicMethod( SimObject,schedule, S32, 4, 0, "( float time, string method, string args... ) Delay an invocation of a method.\n"
|
||||
"@param time The number of milliseconds after which to invoke the method. This is a soft limit.\n"
|
||||
"@param method The method to call.\n"
|
||||
"@param args The arguments with which to call the method.\n"
|
||||
|
|
|
|||
|
|
@ -895,15 +895,7 @@ DefineEngineMethod( SimSet, listObjects, void, (),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DEFINE_CALLIN( fnSimSet_add, add, SimSet, void, ( SimSet* set, SimObject* object ),,,
|
||||
"Add the given object to the set.\n"
|
||||
"@param object An object." )
|
||||
{
|
||||
if( object )
|
||||
set->addObject( object );
|
||||
}
|
||||
|
||||
ConsoleMethod( SimSet, add, void, 3, 0,
|
||||
DefineEngineStringlyVariadicMethod( SimSet, add, void, 3, 0,
|
||||
"( SimObject objects... ) Add the given objects to the set.\n"
|
||||
"@param objects The objects to add to the set." )
|
||||
{
|
||||
|
|
@ -919,15 +911,7 @@ ConsoleMethod( SimSet, add, void, 3, 0,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DEFINE_CALLIN( fnSimSet_remove, remove, SimSet, void, ( SimSet* set, SimObject* object ),,,
|
||||
"Remove the given object from the set.\n"
|
||||
"@param object An object." )
|
||||
{
|
||||
if( object )
|
||||
set->removeObject( object );
|
||||
}
|
||||
|
||||
ConsoleMethod( SimSet, remove, void, 3, 0,
|
||||
DefineEngineStringlyVariadicMethod( SimSet, remove, void, 3, 0,
|
||||
"( SimObject objects... ) Remove the given objects from the set.\n"
|
||||
"@param objects The objects to remove from the set." )
|
||||
{
|
||||
|
|
@ -970,7 +954,7 @@ DefineEngineMethod( SimSet, getRandom, SimObject*, (),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( SimSet, callOnChildren, void, 3, 0,
|
||||
DefineEngineStringlyVariadicMethod( SimSet, callOnChildren, void, 3, 0,
|
||||
"( string method, string args... ) Call a method on all objects contained in the set.\n\n"
|
||||
"@param method The name of the method to call.\n"
|
||||
"@param args The arguments to the method.\n\n"
|
||||
|
|
@ -982,7 +966,7 @@ ConsoleMethod( SimSet, callOnChildren, void, 3, 0,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( SimSet, callOnChildrenNoRecurse, void, 3, 0,
|
||||
DefineEngineStringlyVariadicMethod( SimSet, callOnChildrenNoRecurse, void, 3, 0,
|
||||
"( string method, string args... ) Call a method on all objects contained in the set.\n\n"
|
||||
"@param method The name of the method to call.\n"
|
||||
"@param args The arguments to the method.\n\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue