📄 console.h
字号:
char *getFloatArg(F64 arg);
char *getIntArg (S32 arg);
/// @}
/// @name Namespaces
/// @{
Namespace *lookupNamespace(const char *nsName);
bool linkNamespaces(const char *parentName, const char *childName);
/// @note This should only be called from consoleObject.h
bool classLinkNamespaces(Namespace *parent, Namespace *child);
/// @}
/// @name Logging
/// @{
void getLockLog(ConsoleLogEntry * &log, U32 &size);
void unlockLog(void);
void setLogMode(S32 mode);
/// @}
/// @name Dynamic Type System
/// @{
///
/* void registerType( const char *typeName, S32 type, S32 size, GetDataFunction gdf, SetDataFunction sdf, bool isDatablockType = false );
void registerType( const char* typeName, S32 type, S32 size, bool isDatablockType = false );
void registerTypeGet( S32 type, GetDataFunction gdf );
void registerTypeSet( S32 type, SetDataFunction sdf );
const char *getTypeName(S32 type);
bool isDatablockType( S32 type ); */
void setData(S32 type, void *dptr, S32 index, S32 argc, const char **argv, EnumTable *tbl = NULL, BitSet32 flag = 0);
const char *getData(S32 type, void *dptr, S32 index, EnumTable *tbl = NULL, BitSet32 flag = 0);
/// @}
};
extern void expandEscape(char *dest, const char *src);
extern bool collapseEscape(char *buf);
extern S32 HashPointer(StringTableEntry ptr);
/// This is the backend for the ConsoleMethod()/ConsoleFunction() macros.
///
/// See the group ConsoleConstructor Innards for specifics on how this works.
///
/// @see @ref console_autodoc
/// @nosubgrouping
class ConsoleConstructor
{
public:
/// @name Entry Type Fields
///
/// One of these is set based on the type of entry we want
/// inserted in the console.
///
/// @ref console_autodoc
/// @{
StringCallback sc; ///< A function/method that returns a string.
IntCallback ic; ///< A function/method that returns an int.
FloatCallback fc; ///< A function/method that returns a float.
VoidCallback vc; ///< A function/method that returns nothing.
BoolCallback bc; ///< A function/method that returns a bool.
bool group; ///< Indicates that this is a group marker.
bool overload; ///< Indicates that this is an overload marker.
/// @deprecated Unused.
/// @}
/// Minimum/maximum number of arguments for the function.
S32 mina, maxa;
const char *usage; ///< Usage string.
const char *funcName; ///< Function name.
const char *className; ///< Class name.
/// @name ConsoleConstructer Innards
///
/// The ConsoleConstructor class is used as the backend for the ConsoleFunction() and
/// ConsoleMethod() macros. The way it works takes advantage of several properties of
/// C++.
///
/// The ConsoleFunction()/ConsoleMethod() macros wrap the declaration of a ConsoleConstructor.
///
/// @code
/// // The definition of a ConsoleFunction using the macro
/// ConsoleFunction(ExpandFilename, const char*, 2, 2, "(string filename)")
/// {
/// argc;
/// char* ret = Con::getReturnBuffer( 1024 );
/// Con::expandScriptFilename(ret, 1024, argv[1]);
/// return ret;
/// }
///
/// // Resulting code
/// static const char* cExpandFilename(SimObject *, S32, const char **argv);
/// static ConsoleConstructor
/// gExpandFilenameobj(NULL,"ExpandFilename", cExpandFilename,
/// "(string filename)", 2, 2);
/// static const char* cExpandFilename(SimObject *, S32 argc, const char **argv)
/// {
/// argc;
/// char* ret = Con::getReturnBuffer( 1024 );
/// Con::expandScriptFilename(ret, 1024, argv[1]);
/// return ret;
/// }
///
/// // A similar thing happens when you do a ConsoleMethod.
/// @endcode
///
/// As you can see, several global items are defined when you use the ConsoleFunction method.
/// The macro constructs the name of these items from the parameters you passed it. Your
/// implementation of the console function is is placed in a function with a name based on
/// the actual name of the console funnction. In addition, a ConsoleConstructor is declared.
///
/// Because it is defined as a global, the constructor for the ConsoleConstructor is called
/// before execution of main() is started. The constructor is called once for each global
/// ConsoleConstructor variable, in the order in which they were defined (this property only holds true
/// within file scope).
///
/// We have ConsoleConstructor create a linked list at constructor time, by storing a static
/// pointer to the head of the list, and keeping a pointer to the next item in each instance
/// of ConsoleConstructor. init() is a helper function in this process, automatically filling
/// in commonly used fields and updating first and next as needed. In this way, a list of
/// items to add to the console is assemble in memory, ready for use, before we start
/// execution of the program proper.
///
/// In Con::init(), ConsoleConstructor::setup() is called to process this prepared list. Each
/// item in the list is iterated over, and the appropriate Con namespace functions (usually
/// Con::addCommand) are invoked to register the ConsoleFunctions and ConsoleMethods in
/// the appropriate namespaces.
///
/// @see Namespace
/// @see Con
/// @{
ConsoleConstructor *next;
static ConsoleConstructor *first;
void init(const char *cName, const char *fName, const char *usg, S32 minArgs, S32 maxArgs);
static void setup();
/// @}
/// @name Basic Console Constructors
/// @{
ConsoleConstructor(const char *className, const char *funcName, StringCallback sfunc, const char* usage, S32 minArgs, S32 maxArgs);
ConsoleConstructor(const char *className, const char *funcName, IntCallback ifunc, const char* usage, S32 minArgs, S32 maxArgs);
ConsoleConstructor(const char *className, const char *funcName, FloatCallback ffunc, const char* usage, S32 minArgs, S32 maxArgs);
ConsoleConstructor(const char *className, const char *funcName, VoidCallback vfunc, const char* usage, S32 minArgs, S32 maxArgs);
ConsoleConstructor(const char *className, const char *funcName, BoolCallback bfunc, const char* usage, S32 minArgs, S32 maxArgs);
/// @}
/// @name Magic Console Constructors
///
/// These perform various pieces of "magic" related to consoleDoc functionality.
/// @ref console_autodoc
/// @{
/// Indicates a group marker. (A doxygen illusion)
///
/// @see Con::markCommandGroup
/// @ref console_autodoc
ConsoleConstructor(const char *className, const char *groupName, const char* usage);
/// @}
};
/// @name Global Console Definition Macros
///
/// @note If TORQUE_DEBUG is defined, then we gather documentation information, and
/// do some extra sanity checks.
///
/// @see ConsoleConstructor
/// @ref console_autodoc
/// @{
// O hackery of hackeries
#define conmethod_return_const return (const
#define conmethod_return_S32 return (S32
#define conmethod_return_F32 return (F32
#define conmethod_nullify(val)
#define conmethod_return_void conmethod_nullify(void
#define conmethod_return_bool return (bool
#if !defined(TORQUE_SHIPPING)
// Console function macros
# define ConsoleFunctionGroupBegin(groupName, usage) \
static ConsoleConstructor gConsoleFunctionGroup##groupName##__GroupBegin(NULL,#groupName,usage);
# define ConsoleFunction(name,returnType,minArgs,maxArgs,usage1) \
static returnType c##name(SimObject *, S32, const char **argv); \
static ConsoleConstructor g##name##obj(NULL,#name,c##name,usage1,minArgs,maxArgs); \
static returnType c##name(SimObject *, S32 argc, const char **argv)
# define ConsoleFunctionGroupEnd(groupName) \
static ConsoleConstructor gConsoleFunctionGroup##groupName##__GroupEnd(NULL,#groupName,NULL);
// Console method macros
# define ConsoleMethodGroupBegin(className, groupName, usage) \
static ConsoleConstructor className##groupName##__GroupBegin(#className,#groupName,usage);
# define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \
static inline returnType c##className##name(className *, S32, const char **argv); \
static returnType c##className##name##caster(SimObject *object, S32 argc, const char **argv) { \
AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \
conmethod_return_##returnType ) c##className##name(static_cast<className*>(object),argc,argv); \
}; \
static ConsoleConstructor className##name##obj(#className,#name,c##className##name##caster,usage1,minArgs,maxArgs); \
static inline returnType c##className##name(className *object, S32 argc, const char **argv)
# define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1) \
static inline returnType c##className##name(S32, const char **); \
static returnType c##className##name##caster(SimObject *object, S32 argc, const char **argv) { \
conmethod_return_##returnType ) c##className##name(argc,argv); \
}; \
static ConsoleConstructor \
className##name##obj(#className,#name,c##className##name##caster,usage1,minArgs,maxArgs); \
static inline returnType c##className##name(S32 argc, const char **argv)
# define ConsoleMethodGroupEnd(className, groupName) \
static ConsoleConstructor className##groupName##__GroupEnd(#className,#groupName,NULL);
#else
// These do nothing if we don't want doc information.
# define ConsoleFunctionGroupBegin(groupName, usage)
# define ConsoleFunctionGroupEnd(groupName)
# define ConsoleMethodGroupBegin(className, groupName, usage)
# define ConsoleMethodGroupEnd(className, groupName)
// These are identical to what's above, we just want to null out the usage strings.
# define ConsoleFunction(name,returnType,minArgs,maxArgs,usage1) \
static returnType c##name(SimObject *, S32, const char **); \
static ConsoleConstructor g##name##obj(NULL,#name,c##name,"",minArgs,maxArgs);\
static returnType c##name(SimObject *, S32 argc, const char **argv)
# define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \
static inline returnType c##className##name(className *, S32, const char **argv); \
static returnType c##className##name##caster(SimObject *object, S32 argc, const char **argv) { \
conmethod_return_##returnType ) c##className##name(static_cast<className*>(object),argc,argv); \
}; \
static ConsoleConstructor \
className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs); \
static inline returnType c##className##name(className *object, S32 argc, const char **argv)
# define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1) \
static inline returnType c##className##name(S32, const char **); \
static returnType c##className##name##caster(SimObject *object, S32 argc, const char **argv) { \
conmethod_return_##returnType ) c##className##name(argc,argv); \
}; \
static ConsoleConstructor \
className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs); \
static inline returnType c##className##name(S32 argc, const char **argv)
#endif
#ifdef TGE_RPG
#define CallConsoleMethod(className,name,object,argc,argv) c##className##name(object, argc,argv)
#define CallSameMethod(className,name) c##className##name(object, argc,argv)
#define CallConsoleFunction(name,argc,argv) c##name(NULL, argc, argv)
#define CallSameFunction(name) c##name(NULL, argc, argv)
#endif
/// @}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -