ConsoleConstructor Class Reference#include <console.h>
List of all members.
Detailed Description
This is the backend for the ConsoleMethod()/ConsoleFunction() macros.
See the group ConsoleConstructor Innards for specifics on how this works.
- See also:
- Console Auto-Documentation
|
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.
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 also:
- Namespace
Con
|
| void | init (const char *cName, const char *fName, const char *usg, S32 minArgs, S32 maxArgs, bool toolOnly=false) |
| void | validate () |
| | Validate there are no duplicate entries for this item.
|
| ConsoleConstructor * | next |
| static void | setup () |
| static ConsoleConstructor * | first |
Basic Console Constructors |
| | ConsoleConstructor (const char *className, const char *funcName, StringCallback sfunc, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly=false) |
| | ConsoleConstructor (const char *className, const char *funcName, IntCallback ifunc, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly=false) |
| | ConsoleConstructor (const char *className, const char *funcName, FloatCallback ffunc, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly=false) |
| | ConsoleConstructor (const char *className, const char *funcName, VoidCallback vfunc, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly=false) |
| | ConsoleConstructor (const char *className, const char *funcName, BoolCallback bfunc, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly=false) |
Magic Console Constructors |
These perform various pieces of "magic" related to consoleDoc functionality. Console Auto-Documentation
|
| | ConsoleConstructor (const char *className, const char *groupName, const char *usage) |
| | Indicates a group marker.
|
| | ConsoleConstructor (const char *className, const char *callbackName, const char *usage, bool isRequired) |
| | Indicates a callback declared with the DECLARE_SCRIPT_CALLBACK macro and friends.
|
Entry Type Fields |
| One of these is set based on the type of entry we want inserted in the console.
Console Auto-Documentation
|
| 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.
|
| bool | ns |
| | Indicates that this is a namespace marker.
|
| bool | callback |
| | Is this a callback into script?
|
Public Attributes |
| S32 | mina |
| | Minimum/maximum number of arguments for the function.
|
| S32 | maxa |
| const char * | usage |
| | Usage string.
|
| const char * | funcName |
| | Function name.
|
| const char * | className |
| | Class name.
|
| bool | toolOnly |
Constructor & Destructor Documentation
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
funcName, |
|
|
StringCallback |
sfunc, |
|
|
const char * |
usage, |
|
|
S32 |
minArgs, |
|
|
S32 |
maxArgs, |
|
|
bool |
toolOnly = false | |
|
) |
| | |
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
funcName, |
|
|
IntCallback |
ifunc, |
|
|
const char * |
usage, |
|
|
S32 |
minArgs, |
|
|
S32 |
maxArgs, |
|
|
bool |
toolOnly = false | |
|
) |
| | |
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
funcName, |
|
|
FloatCallback |
ffunc, |
|
|
const char * |
usage, |
|
|
S32 |
minArgs, |
|
|
S32 |
maxArgs, |
|
|
bool |
toolOnly = false | |
|
) |
| | |
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
funcName, |
|
|
VoidCallback |
vfunc, |
|
|
const char * |
usage, |
|
|
S32 |
minArgs, |
|
|
S32 |
maxArgs, |
|
|
bool |
toolOnly = false | |
|
) |
| | |
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
funcName, |
|
|
BoolCallback |
bfunc, |
|
|
const char * |
usage, |
|
|
S32 |
minArgs, |
|
|
S32 |
maxArgs, |
|
|
bool |
toolOnly = false | |
|
) |
| | |
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
groupName, |
|
|
const char * |
usage | |
|
) |
| | |
| ConsoleConstructor::ConsoleConstructor |
( |
const char * |
className, |
|
|
const char * |
callbackName, |
|
|
const char * |
usage, |
|
|
bool |
isRequired | |
|
) |
| | |
Indicates a callback declared with the DECLARE_SCRIPT_CALLBACK macro and friends.
Member Function Documentation
| void ConsoleConstructor::init |
( |
const char * |
cName, |
|
|
const char * |
fName, |
|
|
const char * |
usg, |
|
|
S32 |
minArgs, |
|
|
S32 |
maxArgs, |
|
|
bool |
toolOnly = false | |
|
) |
| | |
| static void ConsoleConstructor::setup |
( |
|
) |
[static] |
| void ConsoleConstructor::validate |
( |
|
) |
|
Validate there are no duplicate entries for this item.
Member Data Documentation
A function/method that returns a string.
A function/method that returns an int.
A function/method that returns a float.
A function/method that returns nothing.
A function/method that returns a bool.
Indicates that this is a group marker.
Indicates that this is an overload marker.
Indicates that this is a namespace marker.
Is this a callback into script?
Minimum/maximum number of arguments for the function.
|