mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Improvements to console refactor code
- Prevent stack corruption in a few places - Use correct type in printfs - Reduce type conversions in EngineApi & dAto* - Fix compilation on GCC - Tidy up code
This commit is contained in:
parent
e99eadd61f
commit
08d4f6ebc0
58 changed files with 733 additions and 690 deletions
|
|
@ -123,7 +123,7 @@ public:
|
|||
{
|
||||
TypeInternalInt = -4,
|
||||
TypeInternalFloat = -3,
|
||||
TypeInternalStackString = -2,
|
||||
TypeInternalStackString = -2,
|
||||
TypeInternalString = -1,
|
||||
};
|
||||
|
||||
|
|
@ -197,9 +197,10 @@ public:
|
|||
};
|
||||
|
||||
// Proxy class for console variables
|
||||
// Can point to existing console variables
|
||||
// or act like a free floating value
|
||||
class ConsoleValueRef {
|
||||
// Can point to existing console variables,
|
||||
// or act like a free floating value.
|
||||
class ConsoleValueRef
|
||||
{
|
||||
public:
|
||||
ConsoleValue *value;
|
||||
const char *stringStackValue;
|
||||
|
|
@ -219,13 +220,11 @@ public:
|
|||
|
||||
inline S32 getIntValue() { return value ? value->getIntValue() : 0; }
|
||||
inline F32 getFloatValue() { return value ? value->getFloatValue() : 0.0f; }
|
||||
//inline F64 getDoubleValue() { return value ? value->getDoubleValue() : 0.0; }
|
||||
|
||||
inline operator const char*() { return getStringValue(); }
|
||||
inline operator String() { return String(getStringValue()); }
|
||||
inline operator S32() { return getIntValue(); }
|
||||
inline operator F32() { return getFloatValue(); }
|
||||
//inline operator F64() { return getDoubleValue(); }
|
||||
|
||||
inline bool isString() { return value ? value->type >= ConsoleValue::TypeInternalStackString : true; }
|
||||
inline bool isInt() { return value ? value->type == ConsoleValue::TypeInternalInt : false; }
|
||||
|
|
@ -239,6 +238,19 @@ public:
|
|||
ConsoleValueRef& operator=(F64 newValue);
|
||||
};
|
||||
|
||||
// Overrides to allow ConsoleValueRefs to be directly converted to S32&F32
|
||||
|
||||
inline S32 dAtoi(ConsoleValueRef &ref)
|
||||
{
|
||||
return ref.getIntValue();
|
||||
}
|
||||
|
||||
inline F32 dAtof(ConsoleValueRef &ref)
|
||||
{
|
||||
return ref.getFloatValue();
|
||||
}
|
||||
|
||||
|
||||
// Transparently converts ConsoleValue[] to const char**
|
||||
class StringStackWrapper
|
||||
{
|
||||
|
|
@ -342,6 +354,7 @@ namespace Con
|
|||
/// 09/12/07 - CAF - 43->44 remove newmsg operator
|
||||
/// 09/27/07 - RDB - 44->45 Patch from Andreas Kirsch: Added opcode to support correct void return
|
||||
/// 01/13/09 - TMS - 45->46 Added script assert
|
||||
/// 10/11/12 - JU - 46->47 Added opcodes to reduce reliance on strings in function calls
|
||||
DSOVersion = 47,
|
||||
|
||||
MaxLineLength = 512, ///< Maximum length of a line of console input.
|
||||
|
|
@ -807,8 +820,8 @@ namespace Con
|
|||
char* getReturnBuffer( const StringBuilder& str );
|
||||
|
||||
char* getArgBuffer(U32 bufferSize);
|
||||
char* getFloatArg(F64 arg);
|
||||
char* getIntArg (S32 arg);
|
||||
ConsoleValueRef getFloatArg(F64 arg);
|
||||
ConsoleValueRef getIntArg (S32 arg);
|
||||
char* getStringArg( const char *arg );
|
||||
char* getStringArg( const String& arg );
|
||||
/// @}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue