mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 06:34:36 +00:00
Merge branch 'development' into style-cleanup
Conflicts: Engine/source/console/astNodes.cpp Engine/source/console/codeBlock.cpp Engine/source/console/compiledEval.cpp Engine/source/ts/collada/colladaAppMesh.cpp Engine/source/ts/tsShape.cpp Engine/source/ts/tsShapeConstruct.cpp
This commit is contained in:
commit
33ff180593
2053 changed files with 172002 additions and 69530 deletions
|
|
@ -27,7 +27,7 @@ class ICallMethod
|
|||
{
|
||||
public:
|
||||
virtual const char* callMethod( S32 argc, const char* methodName, ... ) = 0;
|
||||
virtual const char* callMethodArgList( U32 argc, const char *argv[], bool callThis = true ) = 0;
|
||||
virtual const char* callMethodArgList( U32 argc, ConsoleValueRef argv[], bool callThis = true ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -158,7 +158,7 @@ SimXMLDocument::~SimXMLDocument()
|
|||
// -----------------------------------------------------------------------------
|
||||
// Included for completeness.
|
||||
// -----------------------------------------------------------------------------
|
||||
bool SimXMLDocument::processArguments(S32 argc, const char** argv)
|
||||
bool SimXMLDocument::processArguments(S32 argc, ConsoleValueRef *argv)
|
||||
{
|
||||
return argc == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class SimXMLDocument: public SimObject
|
|||
// tie in to the script language. The .cc file has more in depth
|
||||
// comments on these.
|
||||
//-----------------------------------------------------------------------
|
||||
bool processArguments(S32 argc, const char** argv);
|
||||
bool processArguments(S32 argc, ConsoleValueRef *argv);
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
static void initPersistFields();
|
||||
|
|
|
|||
|
|
@ -103,10 +103,7 @@ S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void*
|
|||
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
||||
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
||||
|
||||
const char* argv[ 3 ];
|
||||
argv[ 0 ] = smCompareFunction;
|
||||
argv[ 1 ] = ea->key;
|
||||
argv[ 2 ] = eb->key;
|
||||
ConsoleValueRef argv[] = { smCompareFunction, ea->key, eb->key };
|
||||
|
||||
S32 result = dAtoi( Con::execute( 3, argv ) );
|
||||
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
||||
|
|
@ -118,10 +115,7 @@ S32 QSORT_CALLBACK ArrayObject::_valueFunctionCompare( const void* a, const void
|
|||
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
||||
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
||||
|
||||
const char* argv[ 3 ];
|
||||
argv[ 0 ] = smCompareFunction;
|
||||
argv[ 1 ] = ea->value;
|
||||
argv[ 2 ] = eb->value;
|
||||
ConsoleValueRef argv[] = { smCompareFunction, ea->value, eb->value };
|
||||
|
||||
S32 result = dAtoi( Con::execute( 3, argv ) );
|
||||
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class ExprEvalState;
|
|||
class Namespace;
|
||||
class SimObject;
|
||||
class SimGroup;
|
||||
class CodeStream;
|
||||
|
||||
/// Enable this #define if you are seeing the message "precompile size mismatch" in the console.
|
||||
/// This will help track down which node type is causing the error. It could be
|
||||
|
|
@ -38,7 +39,8 @@ enum TypeReq
|
|||
TypeReqNone,
|
||||
TypeReqUInt,
|
||||
TypeReqFloat,
|
||||
TypeReqString
|
||||
TypeReqString,
|
||||
TypeReqVar
|
||||
};
|
||||
|
||||
/// Representation of a node for the scripting language parser.
|
||||
|
|
@ -77,15 +79,13 @@ struct StmtNode
|
|||
/// @name Breaking
|
||||
/// @{
|
||||
|
||||
void addBreakCount();
|
||||
void addBreakLine(U32 ip);
|
||||
void addBreakLine(CodeStream &codeStream);
|
||||
/// @}
|
||||
|
||||
/// @name Compilation
|
||||
/// @{
|
||||
|
||||
virtual U32 precompileStmt(U32 loopCount) = 0;
|
||||
virtual U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint) = 0;
|
||||
virtual U32 compileStmt(CodeStream &codeStream, U32 ip) = 0;
|
||||
virtual void setPackage(StringTableEntry packageName);
|
||||
/// @}
|
||||
};
|
||||
|
|
@ -101,27 +101,26 @@ struct BreakStmtNode : StmtNode
|
|||
{
|
||||
static BreakStmtNode *alloc( S32 lineNumber );
|
||||
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(BreakStmtNode);
|
||||
};
|
||||
|
||||
struct ContinueStmtNode : StmtNode
|
||||
{
|
||||
static ContinueStmtNode *alloc( S32 lineNumber );
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(ContinueStmtNode);
|
||||
};
|
||||
|
||||
/// A mathematical expression.
|
||||
struct ExprNode : StmtNode
|
||||
{
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
|
||||
virtual U32 precompile(TypeReq type) = 0;
|
||||
virtual U32 compile(U32 *codeStream, U32 ip, TypeReq type) = 0;
|
||||
virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type) = 0;
|
||||
virtual TypeReq getPreferredType() = 0;
|
||||
};
|
||||
|
||||
|
|
@ -130,8 +129,8 @@ struct ReturnStmtNode : StmtNode
|
|||
ExprNode *expr;
|
||||
|
||||
static ReturnStmtNode *alloc( S32 lineNumber, ExprNode *expr );
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(ReturnStmtNode);
|
||||
};
|
||||
|
||||
|
|
@ -147,8 +146,8 @@ struct IfStmtNode : StmtNode
|
|||
static IfStmtNode *alloc( S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagateThrough );
|
||||
void propagateSwitchExpr(ExprNode *left, bool string);
|
||||
ExprNode *getSwitchOR(ExprNode *left, ExprNode *list, bool string);
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(IfStmtNode);
|
||||
};
|
||||
|
||||
|
|
@ -165,8 +164,8 @@ struct LoopStmtNode : StmtNode
|
|||
bool integer;
|
||||
|
||||
static LoopStmtNode *alloc( S32 lineNumber, ExprNode *testExpr, ExprNode *initExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop );
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(LoopStmtNode);
|
||||
};
|
||||
|
||||
|
|
@ -190,8 +189,7 @@ struct IterStmtNode : StmtNode
|
|||
|
||||
static IterStmtNode* alloc( S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter );
|
||||
|
||||
U32 precompileStmt( U32 loopCount );
|
||||
U32 compileStmt( U32* codeStream, U32 ip, U32 continuePoint, U32 breakPoint );
|
||||
U32 compileStmt( CodeStream &codeStream, U32 ip );
|
||||
};
|
||||
|
||||
/// A binary mathematical expression (ie, left op right).
|
||||
|
|
@ -205,8 +203,8 @@ struct BinaryExprNode : ExprNode
|
|||
struct FloatBinaryExprNode : BinaryExprNode
|
||||
{
|
||||
static FloatBinaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *left, ExprNode *right );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(FloatBinaryExprNode);
|
||||
};
|
||||
|
|
@ -218,8 +216,8 @@ struct ConditionalExprNode : ExprNode
|
|||
ExprNode *falseExpr;
|
||||
bool integer;
|
||||
static ConditionalExprNode *alloc( S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr );
|
||||
virtual U32 precompile(TypeReq type);
|
||||
virtual U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
virtual TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(ConditionalExprNode);
|
||||
};
|
||||
|
|
@ -232,8 +230,8 @@ struct IntBinaryExprNode : BinaryExprNode
|
|||
static IntBinaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *left, ExprNode *right );
|
||||
|
||||
void getSubTypeOperand();
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(IntBinaryExprNode);
|
||||
};
|
||||
|
|
@ -242,8 +240,8 @@ struct StreqExprNode : BinaryExprNode
|
|||
{
|
||||
bool eq;
|
||||
static StreqExprNode *alloc( S32 lineNumber, ExprNode *left, ExprNode *right, bool eq );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(StreqExprNode);
|
||||
};
|
||||
|
|
@ -252,8 +250,8 @@ struct StrcatExprNode : BinaryExprNode
|
|||
{
|
||||
S32 appendChar;
|
||||
static StrcatExprNode *alloc( S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(StrcatExprNode);
|
||||
};
|
||||
|
|
@ -262,8 +260,8 @@ struct CommaCatExprNode : BinaryExprNode
|
|||
{
|
||||
static CommaCatExprNode *alloc( S32 lineNumber, ExprNode *left, ExprNode *right );
|
||||
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(CommaCatExprNode);
|
||||
};
|
||||
|
|
@ -275,8 +273,8 @@ struct IntUnaryExprNode : ExprNode
|
|||
bool integer;
|
||||
|
||||
static IntUnaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *expr );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(IntUnaryExprNode);
|
||||
};
|
||||
|
|
@ -287,8 +285,8 @@ struct FloatUnaryExprNode : ExprNode
|
|||
ExprNode *expr;
|
||||
|
||||
static FloatUnaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *expr );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(FloatUnaryExprNode);
|
||||
};
|
||||
|
|
@ -299,8 +297,8 @@ struct VarNode : ExprNode
|
|||
ExprNode *arrayIndex;
|
||||
|
||||
static VarNode *alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(VarNode);
|
||||
};
|
||||
|
|
@ -311,8 +309,8 @@ struct IntNode : ExprNode
|
|||
U32 index; // if it's converted to float/string
|
||||
|
||||
static IntNode *alloc( S32 lineNumber, S32 value );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(IntNode);
|
||||
};
|
||||
|
|
@ -323,8 +321,8 @@ struct FloatNode : ExprNode
|
|||
U32 index;
|
||||
|
||||
static FloatNode *alloc( S32 lineNumber, F64 value );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(FloatNode);
|
||||
};
|
||||
|
|
@ -338,8 +336,8 @@ struct StrConstNode : ExprNode
|
|||
bool doc; // Specifies that this string is a documentation block.
|
||||
|
||||
static StrConstNode *alloc( S32 lineNumber, char *str, bool tag, bool doc = false );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(StrConstNode);
|
||||
};
|
||||
|
|
@ -351,8 +349,8 @@ struct ConstantNode : ExprNode
|
|||
U32 index;
|
||||
|
||||
static ConstantNode *alloc( S32 lineNumber, StringTableEntry value );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(ConstantNode);
|
||||
};
|
||||
|
|
@ -365,8 +363,8 @@ struct AssignExprNode : ExprNode
|
|||
TypeReq subType;
|
||||
|
||||
static AssignExprNode *alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(AssignExprNode);
|
||||
};
|
||||
|
|
@ -389,8 +387,8 @@ struct AssignOpExprNode : ExprNode
|
|||
TypeReq subType;
|
||||
|
||||
static AssignOpExprNode *alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(AssignOpExprNode);
|
||||
};
|
||||
|
|
@ -402,8 +400,8 @@ struct TTagSetStmtNode : StmtNode
|
|||
ExprNode *stringExpr;
|
||||
|
||||
static TTagSetStmtNode *alloc( S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr );
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(TTagSetStmtNode);
|
||||
};
|
||||
|
||||
|
|
@ -412,8 +410,8 @@ struct TTagDerefNode : ExprNode
|
|||
ExprNode *expr;
|
||||
|
||||
static TTagDerefNode *alloc( S32 lineNumber, ExprNode *expr );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(TTagDerefNode);
|
||||
};
|
||||
|
|
@ -423,8 +421,8 @@ struct TTagExprNode : ExprNode
|
|||
StringTableEntry tag;
|
||||
|
||||
static TTagExprNode *alloc( S32 lineNumber, StringTableEntry tag );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(TTagExprNode);
|
||||
};
|
||||
|
|
@ -442,8 +440,8 @@ struct FuncCallExprNode : ExprNode
|
|||
};
|
||||
|
||||
static FuncCallExprNode *alloc( S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(FuncCallExprNode);
|
||||
};
|
||||
|
|
@ -455,8 +453,8 @@ struct AssertCallExprNode : ExprNode
|
|||
U32 messageIndex;
|
||||
|
||||
static AssertCallExprNode *alloc( S32 lineNumber, ExprNode *testExpr, const char *message );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(AssertCallExprNode);
|
||||
};
|
||||
|
|
@ -475,8 +473,8 @@ struct SlotAccessNode : ExprNode
|
|||
StringTableEntry slotName;
|
||||
|
||||
static SlotAccessNode *alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(SlotAccessNode);
|
||||
};
|
||||
|
|
@ -495,8 +493,8 @@ struct InternalSlotAccessNode : ExprNode
|
|||
bool recurse;
|
||||
|
||||
static InternalSlotAccessNode *alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(InternalSlotAccessNode);
|
||||
};
|
||||
|
|
@ -509,8 +507,8 @@ struct SlotAssignNode : ExprNode
|
|||
U32 typeID;
|
||||
|
||||
static SlotAssignNode *alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID = -1 );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(SlotAssignNode);
|
||||
};
|
||||
|
|
@ -525,8 +523,8 @@ struct SlotAssignOpNode : ExprNode
|
|||
TypeReq subType;
|
||||
|
||||
static SlotAssignOpNode *alloc( S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr );
|
||||
U32 precompile(TypeReq type);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(SlotAssignOpNode);
|
||||
};
|
||||
|
|
@ -545,10 +543,10 @@ struct ObjectDeclNode : ExprNode
|
|||
bool isSingleton;
|
||||
|
||||
static ObjectDeclNode *alloc( S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton );
|
||||
U32 precompile(TypeReq type);
|
||||
|
||||
U32 precompileSubObject(bool);
|
||||
U32 compile(U32 *codeStream, U32 ip, TypeReq type);
|
||||
U32 compileSubObject(U32 *codeStream, U32 ip, bool);
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compileSubObject(CodeStream &codeStream, U32 ip, bool);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(ObjectDeclNode);
|
||||
};
|
||||
|
|
@ -570,18 +568,13 @@ struct FunctionDeclStmtNode : StmtNode
|
|||
U32 argc;
|
||||
|
||||
static FunctionDeclStmtNode *alloc( S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts );
|
||||
U32 precompileStmt(U32 loopCount);
|
||||
U32 compileStmt(U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
void setPackage(StringTableEntry packageName);
|
||||
DBG_STMT_TYPE(FunctionDeclStmtNode);
|
||||
};
|
||||
|
||||
extern StmtNode *gStatementList;
|
||||
extern void createFunction(const char *fnName, VarNode *args, StmtNode *statements);
|
||||
extern ExprEvalState gEvalState;
|
||||
extern bool lookupFunction(const char *fnName, VarNode **args, StmtNode **statements);
|
||||
typedef const char *(*cfunc)(S32 argc, char **argv);
|
||||
extern bool lookupCFunction(const char *fnName, cfunc *f);
|
||||
|
||||
extern ExprEvalState gEvalState;;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -33,7 +33,6 @@
|
|||
using namespace Compiler;
|
||||
|
||||
bool CodeBlock::smInFunction = false;
|
||||
U32 CodeBlock::smBreakLineCount = 0;
|
||||
CodeBlock * CodeBlock::smCodeBlockList = NULL;
|
||||
CodeBlock * CodeBlock::smCurrentCodeBlock = NULL;
|
||||
ConsoleParser *CodeBlock::smCurrentParser = NULL;
|
||||
|
|
@ -403,14 +402,14 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
|
|||
for(U32 i = 0; i < size; i++)
|
||||
st.read(&mFunctionFloats[i]);
|
||||
}
|
||||
U32 codeSize;
|
||||
st.read(&codeSize);
|
||||
U32 codeLength;
|
||||
st.read(&codeLength);
|
||||
st.read(&mLineBreakPairCount);
|
||||
|
||||
U32 totSize = codeSize + mLineBreakPairCount * 2;
|
||||
U32 totSize = codeLength + mLineBreakPairCount * 2;
|
||||
mCode = new U32[totSize];
|
||||
|
||||
for(i = 0; i < codeSize; i++)
|
||||
for(i = 0; i < codeLength; i++)
|
||||
{
|
||||
U8 b;
|
||||
st.read(&b);
|
||||
|
|
@ -420,10 +419,10 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
|
|||
mCode[i] = b;
|
||||
}
|
||||
|
||||
for(i = codeSize; i < totSize; i++)
|
||||
for(i = codeLength; i < totSize; i++)
|
||||
st.read(&mCode[i]);
|
||||
|
||||
mLineBreakPairs = mCode + codeSize;
|
||||
mLineBreakPairs = mCode + codeLength;
|
||||
|
||||
// StringTable-ize our identifiers.
|
||||
U32 identCount;
|
||||
|
|
@ -456,6 +455,8 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
|
|||
|
||||
bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso)
|
||||
{
|
||||
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
|
||||
|
||||
// This will return true, but return value is ignored
|
||||
char *script;
|
||||
chompUTF8BOM( inScript, &script );
|
||||
|
|
@ -464,7 +465,7 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
|||
|
||||
consoleAllocReset();
|
||||
|
||||
STEtoU32 = compileSTEtoU32;
|
||||
STEtoCode = compileSTEtoCode;
|
||||
|
||||
gStatementList = NULL;
|
||||
|
||||
|
|
@ -497,17 +498,23 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
|||
resetTables();
|
||||
|
||||
smInFunction = false;
|
||||
smBreakLineCount = 0;
|
||||
setBreakCodeBlock(this);
|
||||
|
||||
CodeStream codeStream;
|
||||
U32 lastIp;
|
||||
if(gStatementList)
|
||||
mCodeSize = precompileBlock(gStatementList, 0) + 1;
|
||||
{
|
||||
lastIp = compileBlock(gStatementList, codeStream, 0) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCodeSize = 1;
|
||||
|
||||
mLineBreakPairCount = smBreakLineCount;
|
||||
mCode = new U32[mCodeSize + smBreakLineCount * 2];
|
||||
mLineBreakPairs = mCode + mCodeSize;
|
||||
lastIp = 0;
|
||||
}
|
||||
|
||||
codeStream.emit(OP_RETURN);
|
||||
codeStream.emitCodeStream(&mCodeSize, &mCode, &mLineBreakPairs);
|
||||
|
||||
mLineBreakPairCount = codeStream.getNumLineBreaks();
|
||||
|
||||
// Write string table data...
|
||||
getGlobalStringTable().write(st);
|
||||
|
|
@ -517,18 +524,10 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
|||
getGlobalFloatTable().write(st);
|
||||
getFunctionFloatTable().write(st);
|
||||
|
||||
smBreakLineCount = 0;
|
||||
U32 lastIp;
|
||||
if(gStatementList)
|
||||
lastIp = compileBlock(gStatementList, mCode, 0, 0, 0);
|
||||
else
|
||||
lastIp = 0;
|
||||
|
||||
if(lastIp != mCodeSize - 1)
|
||||
if(lastIp != mCodeSize)
|
||||
Con::errorf(ConsoleLogEntry::General, "CodeBlock::compile - precompile size mismatch, a precompile/compile function pair is probably mismatched.");
|
||||
|
||||
mCode[lastIp++] = OP_RETURN;
|
||||
U32 totSize = mCodeSize + smBreakLineCount * 2;
|
||||
|
||||
U32 totSize = mCodeSize + codeStream.getNumLineBreaks() * 2;
|
||||
st.write(mCodeSize);
|
||||
st.write(mLineBreakPairCount);
|
||||
|
||||
|
|
@ -561,11 +560,13 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
|||
|
||||
const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame)
|
||||
{
|
||||
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
|
||||
|
||||
// Check for a UTF8 script file
|
||||
char *string;
|
||||
chompUTF8BOM( inString, &string );
|
||||
|
||||
STEtoU32 = evalSTEtoU32;
|
||||
STEtoCode = evalSTEtoCode;
|
||||
consoleAllocReset();
|
||||
|
||||
mName = fileName;
|
||||
|
|
@ -617,12 +618,11 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
|
|||
resetTables();
|
||||
|
||||
smInFunction = false;
|
||||
smBreakLineCount = 0;
|
||||
setBreakCodeBlock(this);
|
||||
|
||||
CodeStream codeStream;
|
||||
U32 lastIp = compileBlock(gStatementList, codeStream, 0);
|
||||
|
||||
mCodeSize = precompileBlock(gStatementList, 0) + 1;
|
||||
|
||||
mLineBreakPairCount = smBreakLineCount;
|
||||
mLineBreakPairCount = codeStream.getNumLineBreaks();
|
||||
|
||||
mGlobalStrings = getGlobalStringTable().build();
|
||||
mGlobalStringsMaxLen = getGlobalStringTable().totalLen;
|
||||
|
|
@ -632,20 +632,18 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
|
|||
|
||||
mGlobalFloats = getGlobalFloatTable().build();
|
||||
mFunctionFloats = getFunctionFloatTable().build();
|
||||
|
||||
mCode = new U32[mCodeSize + mLineBreakPairCount * 2];
|
||||
mLineBreakPairs = mCode + mCodeSize;
|
||||
|
||||
smBreakLineCount = 0;
|
||||
U32 lastIp = compileBlock(gStatementList, mCode, 0, 0, 0);
|
||||
mCode[lastIp++] = OP_RETURN;
|
||||
|
||||
codeStream.emit(OP_RETURN);
|
||||
codeStream.emitCodeStream(&mCodeSize, &mCode, &mLineBreakPairs);
|
||||
|
||||
//dumpInstructions(0, false);
|
||||
|
||||
consoleAllocReset();
|
||||
|
||||
if(mLineBreakPairCount && fileName)
|
||||
calcBreakList();
|
||||
|
||||
if(lastIp != mCodeSize)
|
||||
if(lastIp+1 != mCodeSize)
|
||||
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", mCodeSize, lastIp);
|
||||
|
||||
return exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame);
|
||||
|
|
@ -674,7 +672,7 @@ String CodeBlock::getFunctionArgs( U32 ip )
|
|||
U32 fnArgc = mCode[ ip + 5 ];
|
||||
for( U32 i = 0; i < fnArgc; ++ i )
|
||||
{
|
||||
StringTableEntry var = U32toSTE( mCode[ ip + i + 6 ] );
|
||||
StringTableEntry var = CodeToSTE(mCode, ip + (i*2) + 6);
|
||||
|
||||
if( i != 0 )
|
||||
str.append( ", " );
|
||||
|
|
@ -696,41 +694,52 @@ String CodeBlock::getFunctionArgs( U32 ip )
|
|||
void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
||||
{
|
||||
U32 ip = startIp;
|
||||
smInFunction = false;
|
||||
U32 endFuncIp = 0;
|
||||
|
||||
while( ip < mCodeSize )
|
||||
{
|
||||
if (ip > endFuncIp)
|
||||
{
|
||||
smInFunction = false;
|
||||
}
|
||||
|
||||
switch( mCode[ ip ++ ] )
|
||||
{
|
||||
|
||||
case OP_FUNC_DECL:
|
||||
{
|
||||
StringTableEntry fnName = U32toSTE(mCode[ip]);
|
||||
StringTableEntry fnNamespace = U32toSTE(mCode[ip+1]);
|
||||
StringTableEntry fnPackage = U32toSTE(mCode[ip+2]);
|
||||
bool hasBody = bool(mCode[ip+3]);
|
||||
U32 newIp = mCode[ ip + 4 ];
|
||||
U32 argc = mCode[ ip + 5 ];
|
||||
StringTableEntry fnName = CodeToSTE(mCode, ip);
|
||||
StringTableEntry fnNamespace = CodeToSTE(mCode, ip+2);
|
||||
StringTableEntry fnPackage = CodeToSTE(mCode, ip+4);
|
||||
bool hasBody = bool(mCode[ip+6]);
|
||||
U32 newIp = mCode[ ip + 7 ];
|
||||
U32 argc = mCode[ ip + 8 ];
|
||||
endFuncIp = newIp;
|
||||
|
||||
Con::printf( "%i: OP_FUNC_DECL name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i",
|
||||
ip - 1, fnName, fnNamespace, fnPackage, hasBody, newIp, argc );
|
||||
|
||||
// Skip args.
|
||||
|
||||
ip += 6 + argc;
|
||||
ip += 9 + (argc * 2);
|
||||
smInFunction = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_CREATE_OBJECT:
|
||||
{
|
||||
StringTableEntry objParent = U32toSTE(mCode[ip ]);
|
||||
bool isDataBlock = mCode[ip + 1];
|
||||
bool isInternal = mCode[ip + 2];
|
||||
bool isSingleton = mCode[ip + 3];
|
||||
U32 lineNumber = mCode[ip + 4];
|
||||
U32 failJump = mCode[ip + 5];
|
||||
StringTableEntry objParent = CodeToSTE(mCode, ip);
|
||||
bool isDataBlock = mCode[ip + 2];
|
||||
bool isInternal = mCode[ip + 3];
|
||||
bool isSingleton = mCode[ip + 4];
|
||||
U32 lineNumber = mCode[ip + 5];
|
||||
U32 failJump = mCode[ip + 6];
|
||||
|
||||
Con::printf( "%i: OP_CREATE_OBJECT objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i",
|
||||
ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump );
|
||||
|
||||
ip += 6;
|
||||
ip += 7;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -823,6 +832,26 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
break;
|
||||
}
|
||||
|
||||
case OP_RETURN_UINT:
|
||||
{
|
||||
Con::printf( "%i: OP_RETURNUINT", ip - 1 );
|
||||
|
||||
if( upToReturn )
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_RETURN_FLT:
|
||||
{
|
||||
Con::printf( "%i: OP_RETURNFLT", ip - 1 );
|
||||
|
||||
if( upToReturn )
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_CMPEQ:
|
||||
{
|
||||
Con::printf( "%i: OP_CMPEQ", ip - 1 );
|
||||
|
|
@ -957,19 +986,19 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_SETCURVAR:
|
||||
{
|
||||
StringTableEntry var = U32toSTE(mCode[ip]);
|
||||
StringTableEntry var = CodeToSTE(mCode, ip);
|
||||
|
||||
Con::printf( "%i: OP_SETCURVAR var=%s", ip - 1, var );
|
||||
ip++;
|
||||
ip += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_SETCURVAR_CREATE:
|
||||
{
|
||||
StringTableEntry var = U32toSTE(mCode[ip]);
|
||||
StringTableEntry var = CodeToSTE(mCode, ip);
|
||||
|
||||
Con::printf( "%i: OP_SETCURVAR_CREATE var=%s", ip - 1, var );
|
||||
ip++;
|
||||
ip += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1003,6 +1032,12 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
break;
|
||||
}
|
||||
|
||||
case OP_LOADVAR_VAR:
|
||||
{
|
||||
Con::printf( "%i: OP_LOADVAR_VAR", ip - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_SAVEVAR_UINT:
|
||||
{
|
||||
Con::printf( "%i: OP_SAVEVAR_UINT", ip - 1 );
|
||||
|
|
@ -1021,6 +1056,12 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
break;
|
||||
}
|
||||
|
||||
case OP_SAVEVAR_VAR:
|
||||
{
|
||||
Con::printf( "%i: OP_SAVEVAR_VAR", ip - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_SETCUROBJECT:
|
||||
{
|
||||
Con::printf( "%i: OP_SETCUROBJECT", ip - 1 );
|
||||
|
|
@ -1042,9 +1083,10 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_SETCURFIELD:
|
||||
{
|
||||
StringTableEntry curField = U32toSTE(mCode[ip]);
|
||||
StringTableEntry curField = CodeToSTE(mCode, ip);
|
||||
Con::printf( "%i: OP_SETCURFIELD field=%s", ip - 1, curField );
|
||||
++ ip;
|
||||
ip += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_SETCURFIELD_ARRAY:
|
||||
|
|
@ -1151,6 +1193,12 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
break;
|
||||
}
|
||||
|
||||
case OP_COPYVAR_TO_NONE:
|
||||
{
|
||||
Con::printf( "%i: OP_COPYVAR_TO_NONE", ip - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_LOADIMMED_UINT:
|
||||
{
|
||||
U32 val = mCode[ ip ];
|
||||
|
|
@ -1161,7 +1209,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_LOADIMMED_FLT:
|
||||
{
|
||||
F64 val = mFunctionFloats[ mCode[ ip ] ];
|
||||
F64 val = (smInFunction ? mFunctionFloats : mGlobalFloats)[ mCode[ ip ] ];
|
||||
Con::printf( "%i: OP_LOADIMMED_FLT val=%f", ip - 1, val );
|
||||
++ ip;
|
||||
break;
|
||||
|
|
@ -1169,7 +1217,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_TAG_TO_STR:
|
||||
{
|
||||
const char* str = mFunctionStrings + mCode[ ip ];
|
||||
const char* str = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
|
||||
Con::printf( "%i: OP_TAG_TO_STR str=%s", ip - 1, str );
|
||||
++ ip;
|
||||
break;
|
||||
|
|
@ -1177,7 +1225,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_LOADIMMED_STR:
|
||||
{
|
||||
const char* str = mFunctionStrings + mCode[ ip ];
|
||||
const char* str = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
|
||||
Con::printf( "%i: OP_LOADIMMED_STR str=%s", ip - 1, str );
|
||||
++ ip;
|
||||
break;
|
||||
|
|
@ -1185,7 +1233,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_DOCBLOCK_STR:
|
||||
{
|
||||
const char* str = mFunctionStrings + mCode[ ip ];
|
||||
const char* str = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
|
||||
Con::printf( "%i: OP_DOCBLOCK_STR str=%s", ip - 1, str );
|
||||
++ ip;
|
||||
break;
|
||||
|
|
@ -1193,37 +1241,37 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_LOADIMMED_IDENT:
|
||||
{
|
||||
StringTableEntry str = U32toSTE( mCode[ ip ] );
|
||||
StringTableEntry str = CodeToSTE(mCode, ip);
|
||||
Con::printf( "%i: OP_LOADIMMED_IDENT str=%s", ip - 1, str );
|
||||
++ ip;
|
||||
ip += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_CALLFUNC_RESOLVE:
|
||||
{
|
||||
StringTableEntry fnNamespace = U32toSTE(mCode[ip+1]);
|
||||
StringTableEntry fnName = U32toSTE(mCode[ip]);
|
||||
StringTableEntry fnNamespace = CodeToSTE(mCode, ip+2);
|
||||
StringTableEntry fnName = CodeToSTE(mCode, ip);
|
||||
U32 callType = mCode[ip+2];
|
||||
|
||||
Con::printf( "%i: OP_CALLFUNC_RESOLVE name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
|
||||
callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
|
||||
: callType == FuncCallExprNode::MethodCall ? "MethodCall" : "ParentCall" );
|
||||
|
||||
ip += 3;
|
||||
ip += 5;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_CALLFUNC:
|
||||
{
|
||||
StringTableEntry fnNamespace = U32toSTE(mCode[ip+1]);
|
||||
StringTableEntry fnName = U32toSTE(mCode[ip]);
|
||||
U32 callType = mCode[ip+2];
|
||||
StringTableEntry fnNamespace = CodeToSTE(mCode, ip+2);
|
||||
StringTableEntry fnName = CodeToSTE(mCode, ip);
|
||||
U32 callType = mCode[ip+4];
|
||||
|
||||
Con::printf( "%i: OP_CALLFUNC name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
|
||||
callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
|
||||
: callType == FuncCallExprNode::MethodCall ? "MethodCall" : "ParentCall" );
|
||||
|
||||
ip += 3;
|
||||
ip += 5;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1277,6 +1325,24 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
break;
|
||||
}
|
||||
|
||||
case OP_PUSH_UINT:
|
||||
{
|
||||
Con::printf( "%i: OP_PUSH_UINT", ip - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_PUSH_FLT:
|
||||
{
|
||||
Con::printf( "%i: OP_PUSH_FLT", ip - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_PUSH_VAR:
|
||||
{
|
||||
Con::printf( "%i: OP_PUSH_VAR", ip - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_PUSH_FRAME:
|
||||
{
|
||||
Con::printf( "%i: OP_PUSH_FRAME", ip - 1 );
|
||||
|
|
@ -1285,7 +1351,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_ASSERT:
|
||||
{
|
||||
const char* message = mFunctionStrings + mCode[ ip ];
|
||||
const char* message = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
|
||||
Con::printf( "%i: OP_ASSERT message=%s", ip - 1, message );
|
||||
++ ip;
|
||||
break;
|
||||
|
|
@ -1299,31 +1365,34 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
|
||||
case OP_ITER_BEGIN:
|
||||
{
|
||||
StringTableEntry varName = U32toSTE( mCode[ ip ] );
|
||||
U32 failIp = mCode[ ip + 1 ];
|
||||
StringTableEntry varName = CodeToSTE(mCode, ip);
|
||||
U32 failIp = mCode[ ip + 2 ];
|
||||
|
||||
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", varName, failIp );
|
||||
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp );
|
||||
|
||||
++ ip;
|
||||
ip += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_ITER_BEGIN_STR:
|
||||
{
|
||||
StringTableEntry varName = U32toSTE( mCode[ ip ] );
|
||||
U32 failIp = mCode[ ip + 1 ];
|
||||
StringTableEntry varName = CodeToSTE(mCode, ip);
|
||||
U32 failIp = mCode[ ip + 2 ];
|
||||
|
||||
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", varName, failIp );
|
||||
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp );
|
||||
|
||||
ip += 2;
|
||||
ip += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_ITER:
|
||||
{
|
||||
U32 breakIp = mCode[ ip ];
|
||||
|
||||
Con::printf( "%i: OP_ITER breakIp=%i", breakIp );
|
||||
Con::printf( "%i: OP_ITER breakIp=%i", ip - 1, breakIp );
|
||||
|
||||
++ ip;
|
||||
break;
|
||||
}
|
||||
|
||||
case OP_ITER_END:
|
||||
|
|
@ -1337,4 +1406,6 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
smInFunction = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#include "console/consoleParser.h"
|
||||
|
||||
class Stream;
|
||||
class ConsoleValue;
|
||||
class ConsoleValueRef;
|
||||
|
||||
/// Core TorqueScript code management class.
|
||||
///
|
||||
|
|
@ -38,7 +40,6 @@ private:
|
|||
static CodeBlock* smCurrentCodeBlock;
|
||||
|
||||
public:
|
||||
static U32 smBreakLineCount;
|
||||
static bool smInFunction;
|
||||
static Compiler::ConsoleParser * smCurrentParser;
|
||||
|
||||
|
|
@ -146,8 +147,8 @@ public:
|
|||
/// -1 a new frame is created. If the index is out of range the
|
||||
/// top stack frame is used.
|
||||
/// @param packageName The code package name or null.
|
||||
const char *exec(U32 offset, const char *fnName, Namespace *ns, U32 argc,
|
||||
const char **argv, bool noCalls, StringTableEntry packageName,
|
||||
ConsoleValueRef exec(U32 offset, const char *fnName, Namespace *ns, U32 argc,
|
||||
ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName,
|
||||
S32 setFrame = -1);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@
|
|||
#include "materials/materialManager.h"
|
||||
#endif
|
||||
|
||||
// Uncomment to optimize function calls at the expense of potential invalid package lookups
|
||||
//#define COMPILER_OPTIMIZE_FUNCTION_CALLS
|
||||
|
||||
using namespace Compiler;
|
||||
|
||||
enum EvalConstants {
|
||||
|
|
@ -102,7 +105,11 @@ IterStackRecord iterStack[ MaxStackSize ];
|
|||
F64 floatStack[MaxStackSize];
|
||||
S64 intStack[MaxStackSize];
|
||||
|
||||
|
||||
|
||||
|
||||
StringStack STR;
|
||||
ConsoleValueStack CSTK;
|
||||
|
||||
U32 _FLT = 0; ///< Stack pointer for floatStack.
|
||||
U32 _UINT = 0; ///< Stack pointer for intStack.
|
||||
|
|
@ -188,18 +195,16 @@ namespace Con
|
|||
return STR.getArgBuffer(bufferSize);
|
||||
}
|
||||
|
||||
char *getFloatArg(F64 arg)
|
||||
ConsoleValueRef getFloatArg(F64 arg)
|
||||
{
|
||||
char *ret = STR.getArgBuffer(32);
|
||||
dSprintf(ret, 32, "%g", arg);
|
||||
return ret;
|
||||
ConsoleValueRef ref = arg;
|
||||
return ref;
|
||||
}
|
||||
|
||||
char *getIntArg(S32 arg)
|
||||
ConsoleValueRef getIntArg(S32 arg)
|
||||
{
|
||||
char *ret = STR.getArgBuffer(32);
|
||||
dSprintf(ret, 32, "%d", arg);
|
||||
return ret;
|
||||
ConsoleValueRef ref = arg;
|
||||
return ref;
|
||||
}
|
||||
|
||||
char *getStringArg( const char *arg )
|
||||
|
|
@ -281,6 +286,25 @@ inline void ExprEvalState::setStringVariable(const char *val)
|
|||
currentVariable->setStringValue(val);
|
||||
}
|
||||
|
||||
inline void ExprEvalState::setCopyVariable()
|
||||
{
|
||||
if (copyVariable)
|
||||
{
|
||||
switch (copyVariable->value.type)
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
currentVariable->setIntValue(copyVariable->getIntValue());
|
||||
break;
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
currentVariable->setFloatValue(copyVariable->getFloatValue());
|
||||
break;
|
||||
default:
|
||||
currentVariable->setStringValue(copyVariable->getStringValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Gets a component of an object's field value or a variable and returns it
|
||||
|
|
@ -401,14 +425,15 @@ static void setFieldComponent( SimObject* object, StringTableEntry field, const
|
|||
}
|
||||
}
|
||||
|
||||
const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, const char **argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
|
||||
ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
U32 stackStart = STR.mStartStackSize;
|
||||
U32 consoleStackStart = CSTK.mStackPos;
|
||||
#endif
|
||||
|
||||
static char traceBuffer[1024];
|
||||
U32 i;
|
||||
S32 i;
|
||||
|
||||
U32 iterDepth = 0;
|
||||
|
||||
|
|
@ -422,9 +447,9 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
|
|||
if(argv)
|
||||
{
|
||||
// assume this points into a function decl:
|
||||
U32 fnArgc = mCode[ip + 5];
|
||||
thisFunctionName = U32toSTE(mCode[ip]);
|
||||
argc = getMin(argc-1, fnArgc); // argv[0] is func name
|
||||
U32 fnArgc = mCode[ip + 2 + 6];
|
||||
thisFunctionName = CodeToSTE(mCode, ip);
|
||||
S32 wantedArgc = getMin(argc-1, fnArgc); // argv[0] is func name
|
||||
if(gEvalState.traceOn)
|
||||
{
|
||||
traceBuffer[0] = 0;
|
||||
|
|
@ -445,24 +470,35 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
|
|||
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
|
||||
"%s(", thisFunctionName);
|
||||
}
|
||||
for(i = 0; i < argc; i++)
|
||||
for (i = 0; i < wantedArgc; i++)
|
||||
{
|
||||
dStrcat(traceBuffer, argv[i+1]);
|
||||
if(i != argc - 1)
|
||||
dStrcat(traceBuffer, ", ");
|
||||
dStrcat(traceBuffer, argv[i + 1]);
|
||||
if (i != wantedArgc - 1)
|
||||
dStrcat(traceBuffer, ", ");
|
||||
}
|
||||
dStrcat(traceBuffer, ")");
|
||||
Con::printf("%s", traceBuffer);
|
||||
}
|
||||
gEvalState.pushFrame(thisFunctionName, thisNamespace);
|
||||
popFrame = true;
|
||||
for(i = 0; i < argc; i++)
|
||||
|
||||
for(i = 0; i < wantedArgc; i++)
|
||||
{
|
||||
StringTableEntry var = U32toSTE(mCode[ip + i + 6]);
|
||||
StringTableEntry var = CodeToSTE(mCode, ip + (2 + 6 + 1) + (i * 2));
|
||||
gEvalState.setCurVarNameCreate(var);
|
||||
gEvalState.setStringVariable(argv[i+1]);
|
||||
|
||||
ConsoleValueRef ref = argv[i+1];
|
||||
|
||||
if (argv[i+1].isString())
|
||||
gEvalState.setStringVariable(argv[i+1]);
|
||||
else if (argv[i+1].isInt())
|
||||
gEvalState.setIntVariable(argv[i+1]);
|
||||
else if (argv[i+1].isFloat())
|
||||
gEvalState.setFloatVariable(argv[i+1]);
|
||||
else
|
||||
gEvalState.setStringVariable(argv[i+1]);
|
||||
}
|
||||
ip = ip + fnArgc + 6;
|
||||
ip = ip + (fnArgc * 2) + (2 + 6 + 1);
|
||||
curFloatTable = mFunctionFloats;
|
||||
curStringTable = mFunctionStrings;
|
||||
curStringTableLen = mFunctionStringsMaxLen;
|
||||
|
|
@ -497,6 +533,10 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
|
|||
}
|
||||
}
|
||||
|
||||
// Reset the console stack frame which at this point will contain
|
||||
// either nothing or argv[] which we just copied
|
||||
CSTK.resetFrame();
|
||||
|
||||
// Grab the state of the telenet debugger here once
|
||||
// so that the push and pop frames are always balanced.
|
||||
const bool telDebuggerOn = TelDebugger && TelDebugger->isConnected();
|
||||
|
|
@ -530,7 +570,7 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
|
|||
char nsDocBlockClass[nsDocLength];
|
||||
|
||||
U32 callArgc;
|
||||
const char **callArgv;
|
||||
ConsoleValueRef *callArgv;
|
||||
|
||||
static char curFieldArray[256];
|
||||
static char prevFieldArray[256];
|
||||
|
|
@ -543,6 +583,10 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
|
|||
Con::gCurrentRoot = this->mModPath;
|
||||
}
|
||||
const char * val;
|
||||
const char *retValue;
|
||||
|
||||
// note: anything returned is pushed to CSTK and will be invalidated on the next exec()
|
||||
ConsoleValueRef returnValue;
|
||||
|
||||
// The frame temp is used by the variable accessor ops (OP_SAVEFIELD_* and
|
||||
// OP_LOADFIELD_*) to store temporary values for the fields.
|
||||
|
|
@ -559,11 +603,11 @@ breakContinue:
|
|||
case OP_FUNC_DECL:
|
||||
if(!noCalls)
|
||||
{
|
||||
fnName = U32toSTE(mCode[ip]);
|
||||
fnNamespace = U32toSTE(mCode[ip+1]);
|
||||
fnPackage = U32toSTE(mCode[ip+2]);
|
||||
bool hasBody = ( mCode[ ip + 3 ] & 0x01 ) != 0;
|
||||
U32 lineNumber = mCode[ ip + 3 ] >> 1;
|
||||
fnName = CodeToSTE(mCode, ip);
|
||||
fnNamespace = CodeToSTE(mCode, ip+2);
|
||||
fnPackage = CodeToSTE(mCode, ip+4);
|
||||
bool hasBody = ( mCode[ ip + 6 ] & 0x01 ) != 0;
|
||||
U32 lineNumber = mCode[ ip + 6 ] >> 1;
|
||||
|
||||
Namespace::unlinkPackages();
|
||||
ns = Namespace::find(fnNamespace, fnPackage);
|
||||
|
|
@ -586,18 +630,18 @@ breakContinue:
|
|||
|
||||
//Con::printf("Adding function %s::%s (%d)", fnNamespace, fnName, ip);
|
||||
}
|
||||
ip = mCode[ip + 4];
|
||||
ip = mCode[ip + 7];
|
||||
break;
|
||||
|
||||
case OP_CREATE_OBJECT:
|
||||
{
|
||||
// Read some useful info.
|
||||
objParent = U32toSTE(mCode[ip ]);
|
||||
bool isDataBlock = mCode[ip + 1];
|
||||
bool isInternal = mCode[ip + 2];
|
||||
bool isSingleton = mCode[ip + 3];
|
||||
U32 lineNumber = mCode[ip + 4];
|
||||
failJump = mCode[ip + 5];
|
||||
objParent = CodeToSTE(mCode, ip);
|
||||
bool isDataBlock = mCode[ip + 2];
|
||||
bool isInternal = mCode[ip + 3];
|
||||
bool isSingleton = mCode[ip + 4];
|
||||
U32 lineNumber = mCode[ip + 5];
|
||||
failJump = mCode[ip + 6];
|
||||
|
||||
// If we don't allow calls, we certainly don't allow creating objects!
|
||||
// Moved this to after failJump is set. Engine was crashing when
|
||||
|
|
@ -615,8 +659,8 @@ breakContinue:
|
|||
objectCreationStack[ objectCreationStackIndex++ ].failJump = failJump;
|
||||
|
||||
// Get the constructor information off the stack.
|
||||
STR.getArgcArgv(NULL, &callArgc, &callArgv);
|
||||
const char* objectName = callArgv[ 2 ];
|
||||
CSTK.getArgcArgv(NULL, &callArgc, &callArgv);
|
||||
const char *objectName = callArgv[ 2 ];
|
||||
|
||||
// Con::printf("Creating object...");
|
||||
|
||||
|
|
@ -638,6 +682,7 @@ breakContinue:
|
|||
Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare data block %s with a different class.", getFileLine(ip), objectName);
|
||||
ip = failJump;
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -659,18 +704,19 @@ breakContinue:
|
|||
break;
|
||||
}
|
||||
|
||||
SimObject *obj = Sim::findObject( objectName );
|
||||
SimObject *obj = Sim::findObject( (const char*)objectName );
|
||||
if (obj /*&& !obj->isLocalName()*/)
|
||||
{
|
||||
if ( isSingleton )
|
||||
{
|
||||
// Make sure we're not trying to change types
|
||||
if ( dStricmp( obj->getClassName(), callArgv[1] ) != 0 )
|
||||
if ( dStricmp( obj->getClassName(), (const char*)callArgv[1] ) != 0 )
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare object [%s] with a different class [%s] - was [%s].",
|
||||
getFileLine(ip), objectName, callArgv[1], obj->getClassName());
|
||||
getFileLine(ip), objectName, (const char*)callArgv[1], obj->getClassName());
|
||||
ip = failJump;
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -688,13 +734,29 @@ breakContinue:
|
|||
// string stack and may get stomped if deleteObject triggers
|
||||
// script execution.
|
||||
|
||||
const char* savedArgv[ StringStack::MaxArgs ];
|
||||
dMemcpy( savedArgv, callArgv, sizeof( savedArgv[ 0 ] ) * callArgc );
|
||||
ConsoleValueRef savedArgv[ StringStack::MaxArgs ];
|
||||
for (int i=0; i<callArgc; i++) {
|
||||
savedArgv[i] = callArgv[i];
|
||||
}
|
||||
//dMemcpy( savedArgv, callArgv, sizeof( savedArgv[ 0 ] ) * callArgc );
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.pushFrame();
|
||||
STR.pushFrame();
|
||||
// --
|
||||
|
||||
obj->deleteObject();
|
||||
obj = NULL;
|
||||
|
||||
dMemcpy( callArgv, savedArgv, sizeof( callArgv[ 0 ] ) * callArgc );
|
||||
// Prevent stack value corruption
|
||||
CSTK.popFrame();
|
||||
STR.popFrame();
|
||||
// --
|
||||
|
||||
//dMemcpy( callArgv, savedArgv, sizeof( callArgv[ 0 ] ) * callArgc );
|
||||
for (int i=0; i<callArgc; i++) {
|
||||
callArgv[i] = savedArgv[i];
|
||||
}
|
||||
}
|
||||
else if( dStricmp( redefineBehavior, "renameNew" ) == 0 )
|
||||
{
|
||||
|
|
@ -723,6 +785,7 @@ breakContinue:
|
|||
getFileLine(ip), newName.c_str() );
|
||||
ip = failJump;
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
@ -734,6 +797,7 @@ breakContinue:
|
|||
getFileLine(ip), objectName);
|
||||
ip = failJump;
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -741,16 +805,17 @@ breakContinue:
|
|||
}
|
||||
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
|
||||
if(!currentNewObject)
|
||||
{
|
||||
// Well, looks like we have to create a new object.
|
||||
ConsoleObject *object = ConsoleObject::create(callArgv[1]);
|
||||
ConsoleObject *object = ConsoleObject::create((const char*)callArgv[1]);
|
||||
|
||||
// Deal with failure!
|
||||
if(!object)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-conobject class %s.", getFileLine(ip), callArgv[1]);
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-conobject class %s.", getFileLine(ip), (const char*)callArgv[1]);
|
||||
ip = failJump;
|
||||
break;
|
||||
}
|
||||
|
|
@ -766,7 +831,7 @@ breakContinue:
|
|||
else
|
||||
{
|
||||
// They tried to make a non-datablock with a datablock keyword!
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-datablock class %s.", getFileLine(ip), callArgv[1]);
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-datablock class %s.", getFileLine(ip), (const char*)callArgv[1]);
|
||||
// Clean up...
|
||||
delete object;
|
||||
ip = failJump;
|
||||
|
|
@ -780,7 +845,7 @@ breakContinue:
|
|||
// Deal with the case of a non-SimObject.
|
||||
if(!currentNewObject)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-SimObject class %s.", getFileLine(ip), callArgv[1]);
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-SimObject class %s.", getFileLine(ip), (const char*)callArgv[1]);
|
||||
delete object;
|
||||
ip = failJump;
|
||||
break;
|
||||
|
|
@ -807,7 +872,7 @@ breakContinue:
|
|||
else
|
||||
{
|
||||
if ( Con::gObjectCopyFailures == -1 )
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to find parent object %s for %s.", getFileLine(ip), objParent, callArgv[1]);
|
||||
Con::errorf(ConsoleLogEntry::General, "%s: Unable to find parent object %s for %s.", getFileLine(ip), objParent, (const char*)callArgv[1]);
|
||||
else
|
||||
++Con::gObjectCopyFailures;
|
||||
|
||||
|
|
@ -830,15 +895,30 @@ breakContinue:
|
|||
currentNewObject->setOriginalName( objectName );
|
||||
}
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.pushFrame();
|
||||
STR.pushFrame();
|
||||
// --
|
||||
|
||||
// Do the constructor parameters.
|
||||
if(!currentNewObject->processArguments(callArgc-3, callArgv+3))
|
||||
{
|
||||
delete currentNewObject;
|
||||
currentNewObject = NULL;
|
||||
ip = failJump;
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.popFrame();
|
||||
STR.popFrame();
|
||||
// --
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.popFrame();
|
||||
STR.popFrame();
|
||||
// --
|
||||
|
||||
// If it's not a datablock, allow people to modify bits of it.
|
||||
if(!isDataBlock)
|
||||
{
|
||||
|
|
@ -848,7 +928,7 @@ breakContinue:
|
|||
}
|
||||
|
||||
// Advance the IP past the create info...
|
||||
ip += 6;
|
||||
ip += 7;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -863,6 +943,11 @@ breakContinue:
|
|||
|
||||
// Con::printf("Adding object %s", currentNewObject->getName());
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.pushFrame();
|
||||
STR.pushFrame();
|
||||
// --
|
||||
|
||||
// Make sure it wasn't already added, then add it.
|
||||
if(currentNewObject->isProperlyAdded() == false)
|
||||
{
|
||||
|
|
@ -886,6 +971,10 @@ breakContinue:
|
|||
Con::warnf(ConsoleLogEntry::General, "%s: Register object failed for object %s of class %s.", getFileLine(ip), currentNewObject->getName(), currentNewObject->getClassName());
|
||||
delete currentNewObject;
|
||||
ip = failJump;
|
||||
// Prevent stack value corruption
|
||||
CSTK.popFrame();
|
||||
STR.popFrame();
|
||||
// --
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -894,6 +983,8 @@ breakContinue:
|
|||
SimDataBlock *dataBlock = dynamic_cast<SimDataBlock *>(currentNewObject);
|
||||
static String errorStr;
|
||||
|
||||
|
||||
|
||||
// If so, preload it.
|
||||
if(dataBlock && !dataBlock->preload(true, errorStr))
|
||||
{
|
||||
|
|
@ -901,6 +992,11 @@ breakContinue:
|
|||
currentNewObject->getName(), errorStr.c_str());
|
||||
dataBlock->deleteObject();
|
||||
ip = failJump;
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.popFrame();
|
||||
STR.popFrame();
|
||||
// --
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -955,6 +1051,10 @@ breakContinue:
|
|||
else
|
||||
intStack[++_UINT] = currentNewObject->getId();
|
||||
|
||||
// Prevent stack value corruption
|
||||
CSTK.popFrame();
|
||||
STR.popFrame();
|
||||
// --
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1037,6 +1137,29 @@ breakContinue:
|
|||
// We're falling thru here on purpose.
|
||||
|
||||
case OP_RETURN:
|
||||
retValue = STR.getStringValue();
|
||||
|
||||
if( iterDepth > 0 )
|
||||
{
|
||||
// Clear iterator state.
|
||||
while( iterDepth > 0 )
|
||||
{
|
||||
iterStack[ -- _ITER ].mIsStringIter = false;
|
||||
-- iterDepth;
|
||||
}
|
||||
|
||||
STR.rewind();
|
||||
STR.setStringValue( retValue ); // Not nice but works.
|
||||
retValue = STR.getStringValue();
|
||||
}
|
||||
|
||||
// Previously the return value was on the stack and would be returned using STR.getStringValue().
|
||||
// Now though we need to wrap it in a ConsoleValueRef
|
||||
returnValue.value = CSTK.pushStackString(retValue);
|
||||
|
||||
goto execFinished;
|
||||
|
||||
case OP_RETURN_FLT:
|
||||
|
||||
if( iterDepth > 0 )
|
||||
{
|
||||
|
|
@ -1047,10 +1170,27 @@ breakContinue:
|
|||
-- iterDepth;
|
||||
}
|
||||
|
||||
const char* returnValue = STR.getStringValue();
|
||||
STR.rewind();
|
||||
STR.setStringValue( returnValue ); // Not nice but works.
|
||||
}
|
||||
|
||||
returnValue.value = CSTK.pushFLT(floatStack[_FLT]);
|
||||
_FLT--;
|
||||
|
||||
goto execFinished;
|
||||
|
||||
case OP_RETURN_UINT:
|
||||
|
||||
if( iterDepth > 0 )
|
||||
{
|
||||
// Clear iterator state.
|
||||
while( iterDepth > 0 )
|
||||
{
|
||||
iterStack[ -- _ITER ].mIsStringIter = false;
|
||||
-- iterDepth;
|
||||
}
|
||||
}
|
||||
|
||||
returnValue.value = CSTK.pushUINT(intStack[_UINT]);
|
||||
_UINT--;
|
||||
|
||||
goto execFinished;
|
||||
|
||||
|
|
@ -1170,8 +1310,8 @@ breakContinue:
|
|||
break;
|
||||
|
||||
case OP_SETCURVAR:
|
||||
var = U32toSTE(mCode[ip]);
|
||||
ip++;
|
||||
var = CodeToSTE(mCode, ip);
|
||||
ip += 2;
|
||||
|
||||
// If a variable is set, then these must be NULL. It is necessary
|
||||
// to set this here so that the vector parser can appropriately
|
||||
|
|
@ -1190,10 +1330,10 @@ breakContinue:
|
|||
break;
|
||||
|
||||
case OP_SETCURVAR_CREATE:
|
||||
var = U32toSTE(mCode[ip]);
|
||||
ip++;
|
||||
var = CodeToSTE(mCode, ip);
|
||||
ip += 2;
|
||||
|
||||
// See OP_SETCURVAR
|
||||
// See OP_SETCURVAR
|
||||
prevField = NULL;
|
||||
prevObject = NULL;
|
||||
curObject = NULL;
|
||||
|
|
@ -1250,6 +1390,11 @@ breakContinue:
|
|||
STR.setStringValue(val);
|
||||
break;
|
||||
|
||||
case OP_LOADVAR_VAR:
|
||||
// Sets current source of OP_SAVEVAR_VAR
|
||||
gEvalState.copyVariable = gEvalState.currentVariable;
|
||||
break;
|
||||
|
||||
case OP_SAVEVAR_UINT:
|
||||
gEvalState.setIntVariable(intStack[_UINT]);
|
||||
break;
|
||||
|
|
@ -1261,6 +1406,11 @@ breakContinue:
|
|||
case OP_SAVEVAR_STR:
|
||||
gEvalState.setStringVariable(STR.getStringValue());
|
||||
break;
|
||||
|
||||
case OP_SAVEVAR_VAR:
|
||||
// this basically handles %var1 = %var2
|
||||
gEvalState.setCopyVariable();
|
||||
break;
|
||||
|
||||
case OP_SETCUROBJECT:
|
||||
// Save the previous object for parsing vector fields.
|
||||
|
|
@ -1310,9 +1460,9 @@ breakContinue:
|
|||
// Save the previous field for parsing vector fields.
|
||||
prevField = curField;
|
||||
dStrcpy( prevFieldArray, curFieldArray );
|
||||
curField = U32toSTE(mCode[ip]);
|
||||
curField = CodeToSTE(mCode, ip);
|
||||
curFieldArray[0] = 0;
|
||||
ip++;
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case OP_SETCURFIELD_ARRAY:
|
||||
|
|
@ -1448,6 +1598,10 @@ breakContinue:
|
|||
_UINT--;
|
||||
break;
|
||||
|
||||
case OP_COPYVAR_TO_NONE:
|
||||
gEvalState.copyVariable = NULL;
|
||||
break;
|
||||
|
||||
case OP_LOADIMMED_UINT:
|
||||
intStack[_UINT+1] = mCode[ip++];
|
||||
_UINT++;
|
||||
|
|
@ -1504,28 +1658,41 @@ breakContinue:
|
|||
break;
|
||||
|
||||
case OP_LOADIMMED_IDENT:
|
||||
STR.setStringValue(U32toSTE(mCode[ip++]));
|
||||
STR.setStringValue(CodeToSTE(mCode, ip));
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case OP_CALLFUNC_RESOLVE:
|
||||
// This deals with a function that is potentially living in a namespace.
|
||||
fnNamespace = U32toSTE(mCode[ip+1]);
|
||||
fnName = U32toSTE(mCode[ip]);
|
||||
fnNamespace = CodeToSTE(mCode, ip+2);
|
||||
fnName = CodeToSTE(mCode, ip);
|
||||
|
||||
// Try to look it up.
|
||||
ns = Namespace::find(fnNamespace);
|
||||
nsEntry = ns->lookup(fnName);
|
||||
if(!nsEntry)
|
||||
{
|
||||
ip+= 3;
|
||||
ip+= 5;
|
||||
Con::warnf(ConsoleLogEntry::General,
|
||||
"%s: Unable to find function %s%s%s",
|
||||
getFileLine(ip-4), fnNamespace ? fnNamespace : "",
|
||||
getFileLine(ip-7), fnNamespace ? fnNamespace : "",
|
||||
fnNamespace ? "::" : "", fnName);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef COMPILER_OPTIMIZE_FUNCTION_CALLS
|
||||
// Now fall through to OP_CALLFUNC...
|
||||
// Now, rewrite our code a bit (ie, avoid future lookups) and fall
|
||||
// through to OP_CALLFUNC
|
||||
#ifdef TORQUE_CPU_X64
|
||||
*((U64*)(code+ip+2)) = ((U64)nsEntry);
|
||||
#else
|
||||
code[ip+2] = ((U32)nsEntry);
|
||||
#endif
|
||||
code[ip-1] = OP_CALLFUNC;
|
||||
#endif
|
||||
|
||||
case OP_CALLFUNC:
|
||||
{
|
||||
|
|
@ -1535,7 +1702,7 @@ breakContinue:
|
|||
// or just on the object.
|
||||
S32 routingId = 0;
|
||||
|
||||
fnName = U32toSTE(mCode[ip]);
|
||||
fnName = CodeToSTE(mCode, ip);
|
||||
|
||||
//if this is called from inside a function, append the ip and codeptr
|
||||
if( gEvalState.getStackDepth() > 0 )
|
||||
|
|
@ -1544,10 +1711,10 @@ breakContinue:
|
|||
gEvalState.getCurrentFrame().ip = ip - 1;
|
||||
}
|
||||
|
||||
U32 callType = mCode[ip+2];
|
||||
U32 callType = mCode[ip+4];
|
||||
|
||||
ip += 3;
|
||||
STR.getArgcArgv(fnName, &callArgc, &callArgv);
|
||||
ip += 5;
|
||||
CSTK.getArgcArgv(fnName, &callArgc, &callArgv);
|
||||
|
||||
const char *componentReturnValue = "";
|
||||
|
||||
|
|
@ -1555,23 +1722,32 @@ breakContinue:
|
|||
{
|
||||
if( !nsEntry )
|
||||
{
|
||||
// We must not have come from OP_CALLFUNC_RESOLVE, so figure out
|
||||
// our own entry.
|
||||
#ifdef COMPILER_OPTIMIZE_FUNCTION_CALLS
|
||||
#ifdef TORQUE_CPU_X64
|
||||
nsEntry = ((Namespace::Entry *) *((U64*)(code+ip-3)));
|
||||
#else
|
||||
nsEntry = ((Namespace::Entry *) *(code+ip-3));
|
||||
#endif
|
||||
#else
|
||||
nsEntry = Namespace::global()->lookup( fnName );
|
||||
#endif
|
||||
ns = NULL;
|
||||
}
|
||||
ns = NULL;
|
||||
}
|
||||
else if(callType == FuncCallExprNode::MethodCall)
|
||||
{
|
||||
saveObject = gEvalState.thisObject;
|
||||
gEvalState.thisObject = Sim::findObject(callArgv[1]);
|
||||
gEvalState.thisObject = Sim::findObject((const char*)callArgv[1]);
|
||||
if(!gEvalState.thisObject)
|
||||
{
|
||||
// Go back to the previous saved object.
|
||||
gEvalState.thisObject = saveObject;
|
||||
|
||||
Con::warnf(ConsoleLogEntry::General,"%s: Unable to find object: '%s' attempting to call function '%s'", getFileLine(ip-4), callArgv[1], fnName);
|
||||
Con::warnf(ConsoleLogEntry::General,"%s: Unable to find object: '%s' attempting to call function '%s'", getFileLine(ip-4), (const char*)callArgv[1], fnName);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
STR.setStringValue("");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1618,7 +1794,7 @@ breakContinue:
|
|||
{
|
||||
if(!noCalls && !( routingId == MethodOnComponent ) )
|
||||
{
|
||||
Con::warnf(ConsoleLogEntry::General,"%s: Unknown command %s.", getFileLine(ip-4), fnName);
|
||||
Con::warnf(ConsoleLogEntry::General,"%s: Unknown command %s.", getFileLine(ip-6), fnName);
|
||||
if(callType == FuncCallExprNode::MethodCall)
|
||||
{
|
||||
Con::warnf(ConsoleLogEntry::General, " Object %s(%d) %s",
|
||||
|
|
@ -1627,6 +1803,7 @@ breakContinue:
|
|||
}
|
||||
}
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
|
||||
if( routingId == MethodOnComponent )
|
||||
STR.setStringValue( componentReturnValue );
|
||||
|
|
@ -1637,12 +1814,33 @@ breakContinue:
|
|||
}
|
||||
if(nsEntry->mType == Namespace::Entry::ConsoleFunctionType)
|
||||
{
|
||||
const char *ret = "";
|
||||
ConsoleValueRef ret;
|
||||
if(nsEntry->mFunctionOffset)
|
||||
ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage);
|
||||
|
||||
|
||||
STR.popFrame();
|
||||
STR.setStringValue(ret);
|
||||
// Functions are assumed to return strings, so look ahead to see if we can skip the conversion
|
||||
if(mCode[ip] == OP_STR_TO_UINT)
|
||||
{
|
||||
ip++;
|
||||
intStack[++_UINT] = (U32)((S32)ret);
|
||||
}
|
||||
else if(mCode[ip] == OP_STR_TO_FLT)
|
||||
{
|
||||
ip++;
|
||||
floatStack[++_FLT] = (F32)ret;
|
||||
}
|
||||
else if(mCode[ip] == OP_STR_TO_NONE)
|
||||
{
|
||||
STR.setStringValue(ret.getStringValue());
|
||||
ip++;
|
||||
}
|
||||
else
|
||||
STR.setStringValue((const char*)ret);
|
||||
|
||||
// This will clear everything including returnValue
|
||||
CSTK.popFrame();
|
||||
STR.clearFunctionOffset();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1652,17 +1850,18 @@ breakContinue:
|
|||
// which is useful behavior when debugging so I'm ifdefing this out for debug builds.
|
||||
if(nsEntry->mToolOnly && ! Con::isCurrentScriptToolScript())
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "%s: %s::%s - attempting to call tools only function from outside of tools.", getFileLine(ip-4), nsName, fnName);
|
||||
Con::errorf(ConsoleLogEntry::Script, "%s: %s::%s - attempting to call tools only function from outside of tools.", getFileLine(ip-6), nsName, fnName);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if((nsEntry->mMinArgs && S32(callArgc) < nsEntry->mMinArgs) || (nsEntry->mMaxArgs && S32(callArgc) > nsEntry->mMaxArgs))
|
||||
{
|
||||
Con::warnf(ConsoleLogEntry::Script, "%s: %s::%s - wrong number of arguments (got %i, expected min %i and max %i).",
|
||||
getFileLine(ip-4), nsName, fnName,
|
||||
getFileLine(ip-6), nsName, fnName,
|
||||
callArgc, nsEntry->mMinArgs, nsEntry->mMaxArgs);
|
||||
Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", getFileLine(ip-4), nsEntry->mUsage);
|
||||
Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", getFileLine(ip-6), nsEntry->mUsage);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1672,16 +1871,18 @@ breakContinue:
|
|||
{
|
||||
const char *ret = nsEntry->cb.mStringCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
if(ret != STR.getStringValue())
|
||||
STR.setStringValue(ret);
|
||||
else
|
||||
STR.setLen(dStrlen(ret));
|
||||
//else
|
||||
// STR.setLen(dStrlen(ret));
|
||||
break;
|
||||
}
|
||||
case Namespace::Entry::IntCallbackType:
|
||||
{
|
||||
S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
if(mCode[ip] == OP_STR_TO_UINT)
|
||||
{
|
||||
ip++;
|
||||
|
|
@ -1704,6 +1905,7 @@ breakContinue:
|
|||
{
|
||||
F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
if(mCode[ip] == OP_STR_TO_UINT)
|
||||
{
|
||||
ip++;
|
||||
|
|
@ -1725,15 +1927,17 @@ breakContinue:
|
|||
case Namespace::Entry::VoidCallbackType:
|
||||
nsEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
|
||||
if( mCode[ ip ] != OP_STR_TO_NONE && Con::getBoolVariable( "$Con::warnVoidAssignment", true ) )
|
||||
Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-4), fnName, functionName);
|
||||
Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-6), fnName, functionName);
|
||||
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
STR.setStringValue("");
|
||||
break;
|
||||
case Namespace::Entry::BoolCallbackType:
|
||||
{
|
||||
bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
if(mCode[ip] == OP_STR_TO_UINT)
|
||||
{
|
||||
ip++;
|
||||
|
|
@ -1788,10 +1992,26 @@ breakContinue:
|
|||
break;
|
||||
case OP_PUSH:
|
||||
STR.push();
|
||||
CSTK.pushString(STR.getPreviousStringValue());
|
||||
break;
|
||||
case OP_PUSH_UINT:
|
||||
CSTK.pushUINT(intStack[_UINT]);
|
||||
_UINT--;
|
||||
break;
|
||||
case OP_PUSH_FLT:
|
||||
CSTK.pushFLT(floatStack[_FLT]);
|
||||
_FLT--;
|
||||
break;
|
||||
case OP_PUSH_VAR:
|
||||
if (gEvalState.currentVariable)
|
||||
CSTK.pushValue(gEvalState.currentVariable->value);
|
||||
else
|
||||
CSTK.pushString("");
|
||||
break;
|
||||
|
||||
case OP_PUSH_FRAME:
|
||||
STR.pushFrame();
|
||||
CSTK.pushFrame();
|
||||
break;
|
||||
|
||||
case OP_ASSERT:
|
||||
|
|
@ -1844,8 +2064,8 @@ breakContinue:
|
|||
|
||||
case OP_ITER_BEGIN:
|
||||
{
|
||||
StringTableEntry varName = U32toSTE( mCode[ ip ] );
|
||||
U32 failIp = mCode[ ip + 1 ];
|
||||
StringTableEntry varName = CodeToSTE(mCode, ip);
|
||||
U32 failIp = mCode[ ip + 2 ];
|
||||
|
||||
IterStackRecord& iter = iterStack[ _ITER ];
|
||||
|
||||
|
|
@ -1880,7 +2100,7 @@ breakContinue:
|
|||
|
||||
STR.push();
|
||||
|
||||
ip += 2;
|
||||
ip += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2021,7 +2241,8 @@ execFinished:
|
|||
AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec");
|
||||
AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec");
|
||||
#endif
|
||||
return STR.getStringValue();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -60,29 +60,27 @@ namespace Compiler
|
|||
CompilerFloatTable *gCurrentFloatTable, gGlobalFloatTable, gFunctionFloatTable;
|
||||
DataChunker gConsoleAllocator;
|
||||
CompilerIdentTable gIdentTable;
|
||||
CodeBlock *gCurBreakBlock;
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
||||
CodeBlock *getBreakCodeBlock() { return gCurBreakBlock; }
|
||||
void setBreakCodeBlock(CodeBlock *cb) { gCurBreakBlock = cb; }
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
U32 evalSTEtoU32(StringTableEntry ste, U32)
|
||||
void evalSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr)
|
||||
{
|
||||
return *((U32 *) &ste);
|
||||
#ifdef TORQUE_CPU_X64
|
||||
*(U64*)(ptr) = (U64)ste;
|
||||
#else
|
||||
*ptr = (U32)ste;
|
||||
#endif
|
||||
}
|
||||
|
||||
U32 compileSTEtoU32(StringTableEntry ste, U32 ip)
|
||||
|
||||
void compileSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr)
|
||||
{
|
||||
if(ste)
|
||||
getIdentTable().add(ste, ip);
|
||||
return 0;
|
||||
*ptr = 0;
|
||||
*(ptr+1) = 0;
|
||||
}
|
||||
|
||||
U32 (*STEtoU32)(StringTableEntry ste, U32 ip) = evalSTEtoU32;
|
||||
|
||||
void (*STEtoCode)(StringTableEntry ste, U32 ip, U32 *ptr) = evalSTEtoCode;
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
|
@ -286,3 +284,131 @@ void CompilerIdentTable::write(Stream &st)
|
|||
st.write(el->ip);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
U8 *CodeStream::allocCode(U32 sz)
|
||||
{
|
||||
U8 *ptr = NULL;
|
||||
if (mCodeHead)
|
||||
{
|
||||
const U32 bytesLeft = BlockSize - mCodeHead->size;
|
||||
if (bytesLeft > sz)
|
||||
{
|
||||
ptr = mCodeHead->data + mCodeHead->size;
|
||||
mCodeHead->size += sz;
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
||||
CodeData *data = new CodeData;
|
||||
data->data = (U8*)dMalloc(BlockSize);
|
||||
data->size = sz;
|
||||
data->next = NULL;
|
||||
|
||||
if (mCodeHead)
|
||||
mCodeHead->next = data;
|
||||
mCodeHead = data;
|
||||
if (mCode == NULL)
|
||||
mCode = data;
|
||||
return data->data;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CodeStream::fixLoop(U32 loopBlockStart, U32 breakPoint, U32 continuePoint)
|
||||
{
|
||||
AssertFatal(mFixStack.size() > 0, "Fix stack mismatch");
|
||||
|
||||
U32 fixStart = mFixStack[mFixStack.size()-1];
|
||||
for (U32 i=fixStart; i<mFixList.size(); i += 2)
|
||||
{
|
||||
FixType type = (FixType)mFixList[i+1];
|
||||
|
||||
U32 fixedIp = 0;
|
||||
bool valid = true;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case FIXTYPE_LOOPBLOCKSTART:
|
||||
fixedIp = loopBlockStart;
|
||||
break;
|
||||
case FIXTYPE_BREAK:
|
||||
fixedIp = breakPoint;
|
||||
break;
|
||||
case FIXTYPE_CONTINUE:
|
||||
fixedIp = continuePoint;
|
||||
break;
|
||||
default:
|
||||
//Con::warnf("Address %u fixed as %u", mFixList[i], mFixList[i+1]);
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
patch(mFixList[i], fixedIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CodeStream::emitCodeStream(U32 *size, U32 **stream, U32 **lineBreaks)
|
||||
{
|
||||
// Alloc stream
|
||||
U32 numLineBreaks = getNumLineBreaks();
|
||||
*stream = new U32[mCodePos + (numLineBreaks * 2)];
|
||||
dMemset(*stream, '\0', mCodePos + (numLineBreaks * 2));
|
||||
*size = mCodePos;
|
||||
|
||||
// Dump chunks & line breaks
|
||||
U32 outBytes = mCodePos * sizeof(U32);
|
||||
U8 *outPtr = *((U8**)stream);
|
||||
for (CodeData *itr = mCode; itr != NULL; itr = itr->next)
|
||||
{
|
||||
U32 bytesToCopy = itr->size > outBytes ? outBytes : itr->size;
|
||||
dMemcpy(outPtr, itr->data, bytesToCopy);
|
||||
outPtr += bytesToCopy;
|
||||
outBytes -= bytesToCopy;
|
||||
}
|
||||
|
||||
*lineBreaks = *stream + mCodePos;
|
||||
dMemcpy(*lineBreaks, mBreakLines.address(), sizeof(U32) * mBreakLines.size());
|
||||
|
||||
// Apply patches on top
|
||||
for (U32 i=0; i<mPatchList.size(); i++)
|
||||
{
|
||||
PatchEntry &e = mPatchList[i];
|
||||
(*stream)[e.addr] = e.value;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CodeStream::reset()
|
||||
{
|
||||
mCodePos = 0;
|
||||
mFixStack.clear();
|
||||
mFixLoopStack.clear();
|
||||
mFixList.clear();
|
||||
mBreakLines.clear();
|
||||
|
||||
// Pop down to one code block
|
||||
CodeData *itr = mCode ? mCode->next : NULL;
|
||||
while (itr != NULL)
|
||||
{
|
||||
CodeData *next = itr->next;
|
||||
dFree(itr->data);
|
||||
dFree(itr);
|
||||
itr = next;
|
||||
}
|
||||
|
||||
if (mCode)
|
||||
{
|
||||
mCode->size = 0;
|
||||
mCode->next = NULL;
|
||||
mCodeHead = mCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@
|
|||
#ifndef _COMPILER_H_
|
||||
#define _COMPILER_H_
|
||||
|
||||
//#define DEBUG_CODESTREAM
|
||||
|
||||
#ifdef DEBUG_CODESTREAM
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
class Stream;
|
||||
class DataChunker;
|
||||
|
||||
|
|
@ -31,6 +37,9 @@ class DataChunker;
|
|||
#include "console/ast.h"
|
||||
#include "console/codeBlock.h"
|
||||
|
||||
#ifndef _TVECTOR_H_
|
||||
#include "core/util/tVector.h"
|
||||
#endif
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
|
|
@ -49,18 +58,21 @@ namespace Compiler
|
|||
OP_JMPIFF,
|
||||
OP_JMPIF,
|
||||
OP_JMPIFNOT_NP,
|
||||
OP_JMPIF_NP,
|
||||
OP_JMPIF_NP, // 10
|
||||
OP_JMP,
|
||||
OP_RETURN,
|
||||
// fixes a bug when not explicitly returning a value
|
||||
OP_RETURN_VOID,
|
||||
OP_RETURN_FLT,
|
||||
OP_RETURN_UINT,
|
||||
|
||||
OP_CMPEQ,
|
||||
OP_CMPGR,
|
||||
OP_CMPGE,
|
||||
OP_CMPLT,
|
||||
OP_CMPLE,
|
||||
OP_CMPNE,
|
||||
OP_XOR,
|
||||
OP_XOR, // 20
|
||||
OP_MOD,
|
||||
OP_BITAND,
|
||||
OP_BITOR,
|
||||
|
|
@ -71,7 +83,7 @@ namespace Compiler
|
|||
OP_SHR,
|
||||
OP_SHL,
|
||||
OP_AND,
|
||||
OP_OR,
|
||||
OP_OR, // 30
|
||||
|
||||
OP_ADD,
|
||||
OP_SUB,
|
||||
|
|
@ -84,20 +96,22 @@ namespace Compiler
|
|||
OP_SETCURVAR_ARRAY,
|
||||
OP_SETCURVAR_ARRAY_CREATE,
|
||||
|
||||
OP_LOADVAR_UINT,
|
||||
OP_LOADVAR_UINT,// 40
|
||||
OP_LOADVAR_FLT,
|
||||
OP_LOADVAR_STR,
|
||||
OP_LOADVAR_VAR,
|
||||
|
||||
OP_SAVEVAR_UINT,
|
||||
OP_SAVEVAR_FLT,
|
||||
OP_SAVEVAR_STR,
|
||||
OP_SAVEVAR_VAR,
|
||||
|
||||
OP_SETCUROBJECT,
|
||||
OP_SETCUROBJECT_NEW,
|
||||
OP_SETCUROBJECT_INTERNAL,
|
||||
|
||||
OP_SETCURFIELD,
|
||||
OP_SETCURFIELD_ARRAY,
|
||||
OP_SETCURFIELD_ARRAY, // 50
|
||||
OP_SETCURFIELD_TYPE,
|
||||
|
||||
OP_LOADFIELD_UINT,
|
||||
|
|
@ -110,18 +124,19 @@ namespace Compiler
|
|||
|
||||
OP_STR_TO_UINT,
|
||||
OP_STR_TO_FLT,
|
||||
OP_STR_TO_NONE,
|
||||
OP_STR_TO_NONE, // 60
|
||||
OP_FLT_TO_UINT,
|
||||
OP_FLT_TO_STR,
|
||||
OP_FLT_TO_NONE,
|
||||
OP_UINT_TO_FLT,
|
||||
OP_UINT_TO_STR,
|
||||
OP_UINT_TO_NONE,
|
||||
OP_COPYVAR_TO_NONE,
|
||||
|
||||
OP_LOADIMMED_UINT,
|
||||
OP_LOADIMMED_FLT,
|
||||
OP_TAG_TO_STR,
|
||||
OP_LOADIMMED_STR,
|
||||
OP_LOADIMMED_STR, // 70
|
||||
OP_DOCBLOCK_STR,
|
||||
OP_LOADIMMED_IDENT,
|
||||
|
||||
|
|
@ -133,11 +148,14 @@ namespace Compiler
|
|||
OP_ADVANCE_STR_COMMA,
|
||||
OP_ADVANCE_STR_NUL,
|
||||
OP_REWIND_STR,
|
||||
OP_TERMINATE_REWIND_STR,
|
||||
OP_TERMINATE_REWIND_STR, // 80
|
||||
OP_COMPARE_STR,
|
||||
|
||||
OP_PUSH,
|
||||
OP_PUSH_FRAME,
|
||||
OP_PUSH, // String
|
||||
OP_PUSH_UINT, // Integer
|
||||
OP_PUSH_FLT, // Float
|
||||
OP_PUSH_VAR, // Variable
|
||||
OP_PUSH_FRAME, // Frame
|
||||
|
||||
OP_ASSERT,
|
||||
OP_BREAK,
|
||||
|
|
@ -147,14 +165,14 @@ namespace Compiler
|
|||
OP_ITER, ///< Enter foreach loop.
|
||||
OP_ITER_END, ///< End foreach loop.
|
||||
|
||||
OP_INVALID
|
||||
OP_INVALID // 90
|
||||
};
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
F64 consoleStringToNumber(const char *str, StringTableEntry file = 0, U32 line = 0);
|
||||
U32 precompileBlock(StmtNode *block, U32 loopCount);
|
||||
U32 compileBlock(StmtNode *block, U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint);
|
||||
|
||||
U32 compileBlock(StmtNode *block, CodeStream &codeStream, U32 ip);
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
|
@ -218,15 +236,19 @@ namespace Compiler
|
|||
|
||||
//------------------------------------------------------------
|
||||
|
||||
inline StringTableEntry U32toSTE(U32 u)
|
||||
inline StringTableEntry CodeToSTE(U32 *code, U32 ip)
|
||||
{
|
||||
return *((StringTableEntry *) &u);
|
||||
#ifdef TORQUE_CPU_X64
|
||||
return (StringTableEntry)(*((U64*)(code+ip)));
|
||||
#else
|
||||
return (StringTableEntry)(*(code+ip));
|
||||
#endif
|
||||
}
|
||||
|
||||
extern U32 (*STEtoU32)(StringTableEntry ste, U32 ip);
|
||||
|
||||
U32 evalSTEtoU32(StringTableEntry ste, U32);
|
||||
U32 compileSTEtoU32(StringTableEntry ste, U32 ip);
|
||||
extern void (*STEtoCode)(StringTableEntry ste, U32 ip, U32 *ptr);
|
||||
|
||||
void evalSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr);
|
||||
void compileSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr);
|
||||
|
||||
CompilerStringTable *getCurrentStringTable();
|
||||
CompilerStringTable &getGlobalStringTable();
|
||||
|
|
@ -244,9 +266,6 @@ namespace Compiler
|
|||
|
||||
void precompileIdent(StringTableEntry ident);
|
||||
|
||||
CodeBlock *getBreakCodeBlock();
|
||||
void setBreakCodeBlock(CodeBlock *cb);
|
||||
|
||||
/// Helper function to reset the float, string, and ident tables to a base
|
||||
/// starting state.
|
||||
void resetTables();
|
||||
|
|
@ -257,4 +276,170 @@ namespace Compiler
|
|||
extern bool gSyntaxError;
|
||||
};
|
||||
|
||||
/// Utility class to emit and patch bytecode
|
||||
class CodeStream
|
||||
{
|
||||
public:
|
||||
|
||||
enum FixType
|
||||
{
|
||||
// For loops
|
||||
FIXTYPE_LOOPBLOCKSTART,
|
||||
FIXTYPE_BREAK,
|
||||
FIXTYPE_CONTINUE
|
||||
};
|
||||
|
||||
enum Constants
|
||||
{
|
||||
BlockSize = 16384,
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
typedef struct PatchEntry
|
||||
{
|
||||
U32 addr; ///< Address to patch
|
||||
U32 value; ///< Value to place at addr
|
||||
|
||||
PatchEntry() {;}
|
||||
PatchEntry(U32 a, U32 v) : addr(a), value(v) {;}
|
||||
} PatchEntry;
|
||||
|
||||
typedef struct CodeData
|
||||
{
|
||||
U8 *data; ///< Allocated data (size is BlockSize)
|
||||
U32 size; ///< Bytes used in data
|
||||
CodeData *next; ///< Next block
|
||||
};
|
||||
|
||||
/// @name Emitted code
|
||||
/// {
|
||||
CodeData *mCode;
|
||||
CodeData *mCodeHead;
|
||||
U32 mCodePos;
|
||||
/// }
|
||||
|
||||
/// @name Code fixing stacks
|
||||
/// {
|
||||
Vector<U32> mFixList;
|
||||
Vector<U32> mFixStack;
|
||||
Vector<bool> mFixLoopStack;
|
||||
Vector<PatchEntry> mPatchList;
|
||||
/// }
|
||||
|
||||
Vector<U32> mBreakLines; ///< Line numbers
|
||||
|
||||
public:
|
||||
|
||||
CodeStream() : mCode(0), mCodeHead(NULL), mCodePos(0)
|
||||
{
|
||||
}
|
||||
|
||||
~CodeStream()
|
||||
{
|
||||
reset();
|
||||
|
||||
if (mCode)
|
||||
{
|
||||
dFree(mCode->data);
|
||||
delete mCode;
|
||||
}
|
||||
}
|
||||
|
||||
U8 *allocCode(U32 sz);
|
||||
|
||||
inline U32 emit(U32 code)
|
||||
{
|
||||
U32 *ptr = (U32*)allocCode(4);
|
||||
*ptr = code;
|
||||
#ifdef DEBUG_CODESTREAM
|
||||
printf("code[%u] = %u\n", mCodePos, code);
|
||||
#endif
|
||||
return mCodePos++;
|
||||
}
|
||||
|
||||
inline void patch(U32 addr, U32 code)
|
||||
{
|
||||
#ifdef DEBUG_CODESTREAM
|
||||
printf("patch[%u] = %u\n", addr, code);
|
||||
#endif
|
||||
mPatchList.push_back(PatchEntry(addr, code));
|
||||
}
|
||||
|
||||
inline U32 emitSTE(const char *code)
|
||||
{
|
||||
U64 *ptr = (U64*)allocCode(8);
|
||||
*ptr = 0;
|
||||
Compiler::STEtoCode(code, mCodePos, (U32*)ptr);
|
||||
#ifdef DEBUG_CODESTREAM
|
||||
printf("code[%u] = %s\n", mCodePos, code);
|
||||
#endif
|
||||
mCodePos += 2;
|
||||
return mCodePos-2;
|
||||
}
|
||||
|
||||
inline U32 tell()
|
||||
{
|
||||
return mCodePos;
|
||||
}
|
||||
|
||||
inline bool inLoop()
|
||||
{
|
||||
for (U32 i=0; i<mFixLoopStack.size(); i++)
|
||||
{
|
||||
if (mFixLoopStack[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline U32 emitFix(FixType type)
|
||||
{
|
||||
U32 *ptr = (U32*)allocCode(4);
|
||||
*ptr = (U32)type;
|
||||
|
||||
#ifdef DEBUG_CODESTREAM
|
||||
printf("code[%u] = [FIX:%u]\n", mCodePos, (U32)type);
|
||||
#endif
|
||||
|
||||
mFixList.push_back(mCodePos);
|
||||
mFixList.push_back((U32)type);
|
||||
return mCodePos++;
|
||||
}
|
||||
|
||||
inline void pushFixScope(bool isLoop)
|
||||
{
|
||||
mFixStack.push_back(mFixList.size());
|
||||
mFixLoopStack.push_back(isLoop);
|
||||
}
|
||||
|
||||
inline void popFixScope()
|
||||
{
|
||||
AssertFatal(mFixStack.size() > 0, "Fix stack mismatch");
|
||||
|
||||
U32 newSize = mFixStack[mFixStack.size()-1];
|
||||
while (mFixList.size() > newSize)
|
||||
mFixList.pop_back();
|
||||
mFixStack.pop_back();
|
||||
mFixLoopStack.pop_back();
|
||||
}
|
||||
|
||||
void fixLoop(U32 loopBlockStart, U32 breakPoint, U32 continuePoint);
|
||||
|
||||
inline void addBreakLine(U32 lineNumber, U32 ip)
|
||||
{
|
||||
mBreakLines.push_back(lineNumber);
|
||||
mBreakLines.push_back(ip);
|
||||
}
|
||||
|
||||
inline U32 getNumLineBreaks()
|
||||
{
|
||||
return mBreakLines.size() / 2;
|
||||
}
|
||||
|
||||
void emitCodeStream(U32 *size, U32 **stream, U32 **lineBreaks);
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
|
||||
extern StringStack STR;
|
||||
extern ConsoleValueStack CSTK;
|
||||
|
||||
ConsoleDocFragment* ConsoleDocFragment::smFirst;
|
||||
ExprEvalState gEvalState;
|
||||
|
|
@ -709,10 +710,11 @@ void errorf(const char* fmt,...)
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void setVariable(const char *name, const char *value)
|
||||
bool getVariableObjectField(const char *name, SimObject **object, const char **field)
|
||||
{
|
||||
// get the field info from the object..
|
||||
if(name[0] != '$' && dStrchr(name, '.') && !isFunction(name))
|
||||
const char *dot = dStrchr(name, '.');
|
||||
if(name[0] != '$' && dot)
|
||||
{
|
||||
S32 len = dStrlen(name);
|
||||
AssertFatal(len < sizeof(scratchBuffer)-1, "Sim::getVariable - name too long");
|
||||
|
|
@ -721,17 +723,17 @@ void setVariable(const char *name, const char *value)
|
|||
char * token = dStrtok(scratchBuffer, ".");
|
||||
SimObject * obj = Sim::findObject(token);
|
||||
if(!obj)
|
||||
return;
|
||||
return false;
|
||||
|
||||
token = dStrtok(0, ".\0");
|
||||
if(!token)
|
||||
return;
|
||||
return false;
|
||||
|
||||
while(token != NULL)
|
||||
{
|
||||
const char * val = obj->getDataField(StringTable->insert(token), 0);
|
||||
if(!val)
|
||||
return;
|
||||
return false;
|
||||
|
||||
char *fieldToken = token;
|
||||
token = dStrtok(0, ".\0");
|
||||
|
|
@ -739,17 +741,72 @@ void setVariable(const char *name, const char *value)
|
|||
{
|
||||
obj = Sim::findObject(token);
|
||||
if(!obj)
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->setDataField(StringTable->insert(fieldToken), 0, value);
|
||||
*object = obj;
|
||||
*field = fieldToken;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Dictionary::Entry *getLocalVariableEntry(const char *name)
|
||||
{
|
||||
name = prependPercent(name);
|
||||
return gEvalState.getCurrentFrame().lookup(StringTable->insert(name));
|
||||
}
|
||||
|
||||
Dictionary::Entry *getVariableEntry(const char *name)
|
||||
{
|
||||
name = prependDollar(name);
|
||||
gEvalState.globalVars.setVariable(StringTable->insert(name), value);
|
||||
return gEvalState.globalVars.lookup(StringTable->insert(name));
|
||||
}
|
||||
|
||||
Dictionary::Entry *addVariableEntry(const char *name)
|
||||
{
|
||||
name = prependDollar(name);
|
||||
return gEvalState.globalVars.add(StringTable->insert(name));
|
||||
}
|
||||
|
||||
Dictionary::Entry *getAddVariableEntry(const char *name)
|
||||
{
|
||||
name = prependDollar(name);
|
||||
StringTableEntry stName = StringTable->insert(name);
|
||||
Dictionary::Entry *entry = gEvalState.globalVars.lookup(stName);
|
||||
if (!entry)
|
||||
entry = gEvalState.globalVars.add(stName);
|
||||
return entry;
|
||||
}
|
||||
|
||||
Dictionary::Entry *getAddLocalVariableEntry(const char *name)
|
||||
{
|
||||
name = prependPercent(name);
|
||||
StringTableEntry stName = StringTable->insert(name);
|
||||
Dictionary::Entry *entry = gEvalState.getCurrentFrame().lookup(stName);
|
||||
if (!entry)
|
||||
entry = gEvalState.getCurrentFrame().add(stName);
|
||||
return entry;
|
||||
}
|
||||
|
||||
void setVariable(const char *name, const char *value)
|
||||
{
|
||||
SimObject *obj = NULL;
|
||||
const char *objField = NULL;
|
||||
|
||||
if (getVariableObjectField(name, &obj, &objField))
|
||||
{
|
||||
obj->setDataField(StringTable->insert(objField), 0, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = prependDollar(name);
|
||||
gEvalState.globalVars.setVariable(StringTable->insert(name), value);
|
||||
}
|
||||
}
|
||||
|
||||
void setLocalVariable(const char *name, const char *value)
|
||||
|
|
@ -760,21 +817,57 @@ void setLocalVariable(const char *name, const char *value)
|
|||
|
||||
void setBoolVariable(const char *varName, bool value)
|
||||
{
|
||||
setVariable(varName, value ? "1" : "0");
|
||||
SimObject *obj = NULL;
|
||||
const char *objField = NULL;
|
||||
|
||||
if (getVariableObjectField(varName, &obj, &objField))
|
||||
{
|
||||
obj->setDataField(StringTable->insert(objField), 0, value ? "1" : "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
varName = prependDollar(varName);
|
||||
Dictionary::Entry *entry = getAddVariableEntry(varName);
|
||||
entry->setStringValue(value ? "1" : "0");
|
||||
}
|
||||
}
|
||||
|
||||
void setIntVariable(const char *varName, S32 value)
|
||||
{
|
||||
char scratchBuffer[32];
|
||||
dSprintf(scratchBuffer, sizeof(scratchBuffer), "%d", value);
|
||||
setVariable(varName, scratchBuffer);
|
||||
SimObject *obj = NULL;
|
||||
const char *objField = NULL;
|
||||
|
||||
if (getVariableObjectField(varName, &obj, &objField))
|
||||
{
|
||||
char scratchBuffer[32];
|
||||
dSprintf(scratchBuffer, sizeof(scratchBuffer), "%d", value);
|
||||
obj->setDataField(StringTable->insert(objField), 0, scratchBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
varName = prependDollar(varName);
|
||||
Dictionary::Entry *entry = getAddVariableEntry(varName);
|
||||
entry->setIntValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
void setFloatVariable(const char *varName, F32 value)
|
||||
{
|
||||
char scratchBuffer[32];
|
||||
dSprintf(scratchBuffer, sizeof(scratchBuffer), "%g", value);
|
||||
setVariable(varName, scratchBuffer);
|
||||
SimObject *obj = NULL;
|
||||
const char *objField = NULL;
|
||||
|
||||
if (getVariableObjectField(varName, &obj, &objField))
|
||||
{
|
||||
char scratchBuffer[32];
|
||||
dSprintf(scratchBuffer, sizeof(scratchBuffer), "%g", value);
|
||||
obj->setDataField(StringTable->insert(objField), 0, scratchBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
varName = prependDollar(varName);
|
||||
Dictionary::Entry *entry = getAddVariableEntry(varName);
|
||||
entry->setFloatValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -825,13 +918,14 @@ void stripColorChars(char* line)
|
|||
}
|
||||
}
|
||||
|
||||
const char *getVariable(const char *name)
|
||||
//
|
||||
const char *getObjectTokenField(const char *name)
|
||||
{
|
||||
// get the field info from the object..
|
||||
if(name[0] != '$' && dStrchr(name, '.') && !isFunction(name))
|
||||
const char *dot = dStrchr(name, '.');
|
||||
if(name[0] != '$' && dot)
|
||||
{
|
||||
S32 len = dStrlen(name);
|
||||
AssertFatal(len < sizeof(scratchBuffer)-1, "Sim::getVariable - name too long");
|
||||
AssertFatal(len < sizeof(scratchBuffer)-1, "Sim::getVariable - object name too long");
|
||||
dMemcpy(scratchBuffer, name, len+1);
|
||||
|
||||
char * token = dStrtok(scratchBuffer, ".");
|
||||
|
|
@ -861,8 +955,21 @@ const char *getVariable(const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
name = prependDollar(name);
|
||||
return gEvalState.globalVars.getVariable(StringTable->insert(name));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *getVariable(const char *name)
|
||||
{
|
||||
const char *objField = getObjectTokenField(name);
|
||||
if (objField)
|
||||
{
|
||||
return objField;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary::Entry *entry = getVariableEntry(name);
|
||||
return entry ? entry->getStringValue() : "";
|
||||
}
|
||||
}
|
||||
|
||||
const char *getLocalVariable(const char *name)
|
||||
|
|
@ -874,20 +981,45 @@ const char *getLocalVariable(const char *name)
|
|||
|
||||
bool getBoolVariable(const char *varName, bool def)
|
||||
{
|
||||
const char *value = getVariable(varName);
|
||||
return *value ? dAtob(value) : def;
|
||||
const char *objField = getObjectTokenField(varName);
|
||||
if (objField)
|
||||
{
|
||||
return *objField ? dAtob(objField) : def;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary::Entry *entry = getVariableEntry(varName);
|
||||
objField = entry ? entry->getStringValue() : "";
|
||||
return *objField ? dAtob(objField) : def;
|
||||
}
|
||||
}
|
||||
|
||||
S32 getIntVariable(const char *varName, S32 def)
|
||||
{
|
||||
const char *value = getVariable(varName);
|
||||
return *value ? dAtoi(value) : def;
|
||||
const char *objField = getObjectTokenField(varName);
|
||||
if (objField)
|
||||
{
|
||||
return *objField ? dAtoi(objField) : def;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary::Entry *entry = getVariableEntry(varName);
|
||||
return entry ? entry->getIntValue() : def;
|
||||
}
|
||||
}
|
||||
|
||||
F32 getFloatVariable(const char *varName, F32 def)
|
||||
{
|
||||
const char *value = getVariable(varName);
|
||||
return *value ? dAtof(value) : def;
|
||||
const char *objField = getObjectTokenField(varName);
|
||||
if (objField)
|
||||
{
|
||||
return *objField ? dAtof(objField) : def;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary::Entry *entry = getVariableEntry(varName);
|
||||
return entry ? entry->getFloatValue() : def;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -1032,7 +1164,7 @@ const char *evaluatef(const char* string, ...)
|
|||
return newCodeBlock->compileExec(NULL, buffer, false, 0);
|
||||
}
|
||||
|
||||
const char *execute(S32 argc, const char *argv[])
|
||||
const char *execute(S32 argc, ConsoleValueRef argv[])
|
||||
{
|
||||
#ifdef TORQUE_MULTITHREAD
|
||||
if(isMainThread())
|
||||
|
|
@ -1044,10 +1176,11 @@ const char *execute(S32 argc, const char *argv[])
|
|||
|
||||
if(!ent)
|
||||
{
|
||||
warnf(ConsoleLogEntry::Script, "%s: Unknown command.", argv[0]);
|
||||
warnf(ConsoleLogEntry::Script, "%s: Unknown command.", (const char*)argv[0]);
|
||||
|
||||
// Clean up arg buffers, if any.
|
||||
STR.clearFunctionOffset();
|
||||
CSTK.resetFrame();
|
||||
return "";
|
||||
}
|
||||
return ent->execute(argc, argv, &gEvalState);
|
||||
|
|
@ -1064,10 +1197,15 @@ const char *execute(S32 argc, const char *argv[])
|
|||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly)
|
||||
const char *execute(S32 argc, const char *argv[])
|
||||
{
|
||||
StringStackConsoleWrapper args(argc, argv);
|
||||
return execute(args.count(), args);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly)
|
||||
{
|
||||
static char idBuf[16];
|
||||
if(argc < 2)
|
||||
return "";
|
||||
|
||||
|
|
@ -1078,13 +1216,21 @@ const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCa
|
|||
{
|
||||
ICallMethod *com = dynamic_cast<ICallMethod *>(object);
|
||||
if(com)
|
||||
{
|
||||
STR.pushFrame();
|
||||
CSTK.pushFrame();
|
||||
com->callMethodArgList(argc, argv, false);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
}
|
||||
}
|
||||
|
||||
if(object->getNamespace())
|
||||
{
|
||||
dSprintf(idBuf, sizeof(idBuf), "%d", object->getId());
|
||||
argv[1] = idBuf;
|
||||
ConsoleValueRef internalArgv[StringStack::MaxArgs];
|
||||
|
||||
U32 ident = object->getId();
|
||||
ConsoleValueRef oldIdent = argv[1];
|
||||
|
||||
StringTableEntry funcName = StringTable->insert(argv[0]);
|
||||
Namespace::Entry *ent = object->getNamespace()->lookup(funcName);
|
||||
|
|
@ -1095,13 +1241,12 @@ const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCa
|
|||
|
||||
// Clean up arg buffers, if any.
|
||||
STR.clearFunctionOffset();
|
||||
CSTK.resetFrame();
|
||||
return "";
|
||||
}
|
||||
|
||||
// Twiddle %this argument
|
||||
const char *oldArg1 = argv[1];
|
||||
dSprintf(idBuf, sizeof(idBuf), "%d", object->getId());
|
||||
argv[1] = idBuf;
|
||||
argv[1] = (S32)ident;
|
||||
|
||||
SimObject *save = gEvalState.thisObject;
|
||||
gEvalState.thisObject = object;
|
||||
|
|
@ -1109,90 +1254,62 @@ const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCa
|
|||
gEvalState.thisObject = save;
|
||||
|
||||
// Twiddle it back
|
||||
argv[1] = oldArg1;
|
||||
argv[1] = oldIdent;
|
||||
|
||||
return ret;
|
||||
}
|
||||
warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), argv[0]);
|
||||
warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), (const char*)argv[0]);
|
||||
return "";
|
||||
}
|
||||
|
||||
#define B( a ) const char* a = NULL
|
||||
#define A const char*
|
||||
inline const char*_executef(SimObject *obj, S32 checkArgc, S32 argc,
|
||||
A a, B(b), B(c), B(d), B(e), B(f), B(g), B(h), B(i), B(j), B(k))
|
||||
const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly)
|
||||
{
|
||||
StringStackConsoleWrapper args(argc, argv);
|
||||
return execute(object, args.count(), args, thisCallOnly);
|
||||
}
|
||||
|
||||
inline const char*_executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValueRef *argv)
|
||||
{
|
||||
#undef A
|
||||
#undef B
|
||||
const U32 maxArg = 12;
|
||||
AssertWarn(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)");
|
||||
AssertFatal(argc <= maxArg - 1, "Too many args passed to Con::_executef(SimObject*). Please update the function to handle more.");
|
||||
const char* argv[maxArg];
|
||||
argv[0] = a;
|
||||
argv[1] = a;
|
||||
argv[2] = b;
|
||||
argv[3] = c;
|
||||
argv[4] = d;
|
||||
argv[5] = e;
|
||||
argv[6] = f;
|
||||
argv[7] = g;
|
||||
argv[8] = h;
|
||||
argv[9] = i;
|
||||
argv[10] = j;
|
||||
argv[11] = k;
|
||||
return execute(obj, argc+1, argv);
|
||||
return execute(obj, argc, argv);
|
||||
}
|
||||
|
||||
#define A const char*
|
||||
#define A ConsoleValueRef
|
||||
#define OBJ SimObject* obj
|
||||
const char *executef(OBJ, A a) { return _executef(obj, 1, 1, a); }
|
||||
const char *executef(OBJ, A a, A b) { return _executef(obj, 2, 2, a, b); }
|
||||
const char *executef(OBJ, A a, A b, A c) { return _executef(obj, 3, 3, a, b, c); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d) { return _executef(obj, 4, 4, a, b, c, d); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e) { return _executef(obj, 5, 5, a, b, c, d, e); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f) { return _executef(obj, 6, 6, a, b, c, d, e, f); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g) { return _executef(obj, 7, 7, a, b, c, d, e, f, g); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h) { return _executef(obj, 8, 8, a, b, c, d, e, f, g, h); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h, A i) { return _executef(obj, 9, 9, a, b, c, d, e, f, g, h, i); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h, A i, A j) { return _executef(obj,10,10, a, b, c, d, e, f, g, h, i, j); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h, A i, A j, A k) { return _executef(obj,11,11, a, b, c, d, e, f, g, h, i, j, k); }
|
||||
#undef A
|
||||
const char *executef(OBJ, A a) { ConsoleValueRef params[] = {a,ConsoleValueRef()}; return _executef(obj, 2, 2, params); }
|
||||
const char *executef(OBJ, A a, A b) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b}; return _executef(obj, 3, 3, params); }
|
||||
const char *executef(OBJ, A a, A b, A c) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c}; return _executef(obj, 4, 4, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d}; return _executef(obj, 5, 5, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e}; return _executef(obj, 6, 6, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e,f}; return _executef(obj, 7, 7, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e,f,g}; return _executef(obj, 8, 8, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e,f,g,h}; return _executef(obj, 9, 9, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h, A i) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e,f,g,h,i}; return _executef(obj, 10, 10, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h, A i, A j) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e,f,g,h,i,j}; return _executef(obj, 11, 11, params); }
|
||||
const char *executef(OBJ, A a, A b, A c, A d, A e, A f, A g, A h, A i, A j, A k) { ConsoleValueRef params[] = {a,ConsoleValueRef(),b,c,d,e,f,g,h,i,j,k}; return _executef(obj, 12, 12, params); }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#define B( a ) const char* a = NULL
|
||||
#define A const char*
|
||||
inline const char*_executef(S32 checkArgc, S32 argc, A a, B(b), B(c), B(d), B(e), B(f), B(g), B(h), B(i), B(j))
|
||||
inline const char*_executef(S32 checkArgc, S32 argc, ConsoleValueRef *argv)
|
||||
{
|
||||
#undef A
|
||||
#undef B
|
||||
const U32 maxArg = 10;
|
||||
AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef()");
|
||||
AssertFatal(argc <= maxArg, "Too many args passed to Con::_executef(). Please update the function to handle more.");
|
||||
const char* argv[maxArg];
|
||||
argv[0] = a;
|
||||
argv[1] = b;
|
||||
argv[2] = c;
|
||||
argv[3] = d;
|
||||
argv[4] = e;
|
||||
argv[5] = f;
|
||||
argv[6] = g;
|
||||
argv[7] = h;
|
||||
argv[8] = i;
|
||||
argv[9] = j;
|
||||
return execute(argc, argv);
|
||||
}
|
||||
|
||||
#define A const char*
|
||||
const char *executef(A a) { return _executef(1, 1, a); }
|
||||
const char *executef(A a, A b) { return _executef(2, 2, a, b); }
|
||||
const char *executef(A a, A b, A c) { return _executef(3, 3, a, b, c); }
|
||||
const char *executef(A a, A b, A c, A d) { return _executef(4, 4, a, b, c, d); }
|
||||
const char *executef(A a, A b, A c, A d, A e) { return _executef(5, 5, a, b, c, d, e); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f) { return _executef(6, 6, a, b, c, d, e, f); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g) { return _executef(7, 7, a, b, c, d, e, f, g); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g, A h) { return _executef(8, 8, a, b, c, d, e, f, g, h); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g, A h, A i) { return _executef(9, 9, a, b, c, d, e, f, g, h, i); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g, A h, A i, A j) { return _executef(10,10,a, b, c, d, e, f, g, h, i, j); }
|
||||
#define A ConsoleValueRef
|
||||
const char *executef(A a) { ConsoleValueRef params[] = {a}; return _executef(1, 1, params); }
|
||||
const char *executef(A a, A b) { ConsoleValueRef params[] = {a,b}; return _executef(2, 2, params); }
|
||||
const char *executef(A a, A b, A c) { ConsoleValueRef params[] = {a,b,c}; return _executef(3, 3, params); }
|
||||
const char *executef(A a, A b, A c, A d) { ConsoleValueRef params[] = {a,b,c,d}; return _executef(4, 4, params); }
|
||||
const char *executef(A a, A b, A c, A d, A e) { ConsoleValueRef params[] = {a,b,c,d,e}; return _executef(5, 5, params); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f) { ConsoleValueRef params[] = {a,b,c,d,e,f}; return _executef(1, 1, params); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g) { ConsoleValueRef params[] = {a,b,c,d,e,f,g}; return _executef(1, 1, params); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g, A h) { ConsoleValueRef params[] = {a,b,c,d,e,f,g,h}; return _executef(1, 1, params); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g, A h, A i) { ConsoleValueRef params[] = {a,b,c,d,e,f,g,h,i}; return _executef(1, 1, params); }
|
||||
const char *executef(A a, A b, A c, A d, A e, A f, A g, A h, A i, A j) { ConsoleValueRef params[] = {a,b,c,d,e,f,g,h,i,j}; return _executef(1, 1, params); }
|
||||
#undef A
|
||||
|
||||
|
||||
|
|
@ -1313,8 +1430,9 @@ const char *getFormattedData(S32 type, const char *data, const EnumTable *tbl, B
|
|||
Con::setData(type, variable, 0, 1, &data, tbl, flag);
|
||||
const char* formattedVal = Con::getData(type, variable, 0, tbl, flag);
|
||||
|
||||
char* returnBuffer = Con::getReturnBuffer(2048);
|
||||
dSprintf(returnBuffer, 2048, "%s\0", formattedVal );
|
||||
static const U32 bufSize = 2048;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%s\0", formattedVal );
|
||||
|
||||
cbt->deleteNativeVariable(variable);
|
||||
|
||||
|
|
@ -1389,10 +1507,10 @@ StringTableEntry getModNameFromPath(const char *path)
|
|||
void postConsoleInput( RawData data )
|
||||
{
|
||||
// Schedule this to happen at the next time event.
|
||||
char *argv[2];
|
||||
ConsoleValueRef argv[2];
|
||||
argv[0] = "eval";
|
||||
argv[1] = ( char* ) data.data;
|
||||
Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(2, const_cast<const char**>(argv), false));
|
||||
argv[1] = ( const char* ) data.data;
|
||||
Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(2, argv, false));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -1455,3 +1573,247 @@ DefineEngineFunction( logWarning, void, ( const char* message ),,
|
|||
{
|
||||
Con::warnf( "%s", message );
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(const ConsoleValueRef &ref)
|
||||
{
|
||||
value = ref.value;
|
||||
stringStackValue = ref.stringStackValue;
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(const char *newValue) : value(NULL)
|
||||
{
|
||||
*this = newValue;
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(const String &newValue) : value(NULL)
|
||||
{
|
||||
*this = (const char*)(newValue.utf8());
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(U32 newValue) : value(NULL)
|
||||
{
|
||||
*this = newValue;
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(S32 newValue) : value(NULL)
|
||||
{
|
||||
*this = newValue;
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(F32 newValue) : value(NULL)
|
||||
{
|
||||
*this = newValue;
|
||||
}
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(F64 newValue) : value(NULL)
|
||||
{
|
||||
*this = newValue;
|
||||
}
|
||||
|
||||
StringStackWrapper::StringStackWrapper(int targc, ConsoleValueRef targv[])
|
||||
{
|
||||
argv = new const char*[targc];
|
||||
argc = targc;
|
||||
|
||||
for (int i=0; i<targc; i++)
|
||||
{
|
||||
argv[i] = dStrdup(targv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
StringStackWrapper::~StringStackWrapper()
|
||||
{
|
||||
for (int i=0; i<argc; i++)
|
||||
{
|
||||
dFree(argv[i]);
|
||||
}
|
||||
delete[] argv;
|
||||
}
|
||||
|
||||
|
||||
StringStackConsoleWrapper::StringStackConsoleWrapper(int targc, const char** targ)
|
||||
{
|
||||
argv = new ConsoleValueRef[targc];
|
||||
argc = targc;
|
||||
|
||||
for (int i=0; i<targc; i++) {
|
||||
argv[i] = ConsoleValueRef(targ[i]);
|
||||
}
|
||||
}
|
||||
|
||||
StringStackConsoleWrapper::~StringStackConsoleWrapper()
|
||||
{
|
||||
for (int i=0; i<argc; i++)
|
||||
{
|
||||
argv[i] = NULL;
|
||||
}
|
||||
delete[] argv;
|
||||
}
|
||||
|
||||
S32 ConsoleValue::getSignedIntValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return (S32)fval;
|
||||
else
|
||||
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
|
||||
}
|
||||
|
||||
U32 ConsoleValue::getIntValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return ival;
|
||||
else
|
||||
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
|
||||
}
|
||||
|
||||
F32 ConsoleValue::getFloatValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return fval;
|
||||
else
|
||||
return dAtof(Con::getData(type, dataPtr, 0, enumTable));
|
||||
}
|
||||
|
||||
const char *ConsoleValue::getStringValue()
|
||||
{
|
||||
if(type == TypeInternalString || type == TypeInternalStackString)
|
||||
return sval;
|
||||
if(type == TypeInternalFloat)
|
||||
return Con::getData(TypeF32, &fval, 0);
|
||||
else if(type == TypeInternalInt)
|
||||
return Con::getData(TypeS32, &ival, 0);
|
||||
else
|
||||
return Con::getData(type, dataPtr, 0, enumTable);
|
||||
}
|
||||
|
||||
bool ConsoleValue::getBoolValue()
|
||||
{
|
||||
if(type == TypeInternalString || type == TypeInternalStackString)
|
||||
return dAtob(sval);
|
||||
if(type == TypeInternalFloat)
|
||||
return fval > 0;
|
||||
else if(type == TypeInternalInt)
|
||||
return ival > 0;
|
||||
else {
|
||||
const char *value = Con::getData(type, dataPtr, 0, enumTable);
|
||||
return dAtob(value);
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleValue::setIntValue(S32 val)
|
||||
{
|
||||
setFloatValue(val);
|
||||
}
|
||||
|
||||
void ConsoleValue::setIntValue(U32 val)
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
{
|
||||
fval = (F32)val;
|
||||
ival = val;
|
||||
if(sval != typeValueEmpty)
|
||||
{
|
||||
if (type != TypeInternalStackString) dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
}
|
||||
type = TypeInternalInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *dptr = Con::getData(TypeS32, &val, 0);
|
||||
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleValue::setBoolValue(bool val)
|
||||
{
|
||||
return setIntValue(val ? 1 : 0);
|
||||
}
|
||||
|
||||
void ConsoleValue::setFloatValue(F32 val)
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
{
|
||||
fval = val;
|
||||
ival = static_cast<U32>(val);
|
||||
if(sval != typeValueEmpty)
|
||||
{
|
||||
if (type != TypeInternalStackString) dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
}
|
||||
type = TypeInternalFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *dptr = Con::getData(TypeF32, &val, 0);
|
||||
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *ConsoleValueRef::getStringArgValue()
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (stringStackValue == NULL)
|
||||
stringStackValue = Con::getStringArg(value->getStringValue());
|
||||
return stringStackValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern ConsoleValueStack CSTK;
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(const ConsoleValueRef &newValue)
|
||||
{
|
||||
value = newValue.value;
|
||||
stringStackValue = newValue.stringStackValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(const char *newValue)
|
||||
{
|
||||
value = CSTK.pushStackString(newValue);
|
||||
stringStackValue = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(S32 newValue)
|
||||
{
|
||||
value = CSTK.pushFLT(newValue);
|
||||
stringStackValue = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(U32 newValue)
|
||||
{
|
||||
value = CSTK.pushUINT(newValue);
|
||||
stringStackValue = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(F32 newValue)
|
||||
{
|
||||
value = CSTK.pushFLT(newValue);
|
||||
stringStackValue = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(F64 newValue)
|
||||
{
|
||||
value = CSTK.pushFLT(newValue);
|
||||
stringStackValue = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace Con
|
||||
{
|
||||
void resetStackFrame()
|
||||
{
|
||||
CSTK.resetFrame();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,18 @@
|
|||
#ifndef _BITSET_H_
|
||||
#include "core/bitSet.h"
|
||||
#endif
|
||||
#ifndef _REFBASE_H_
|
||||
#include "core/util/refBase.h"
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "core/util/str.h"
|
||||
#include "core/util/journal/journaledSignal.h"
|
||||
|
||||
class SimObject;
|
||||
class Namespace;
|
||||
struct ConsoleFunctionHeader;
|
||||
|
||||
|
||||
class EngineEnumTable;
|
||||
typedef EngineEnumTable EnumTable;
|
||||
|
||||
|
|
@ -110,6 +113,185 @@ struct ConsoleLogEntry
|
|||
};
|
||||
|
||||
typedef const char *StringTableEntry;
|
||||
extern char *typeValueEmpty;
|
||||
|
||||
class ConsoleValue
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
TypeInternalInt = -4,
|
||||
TypeInternalFloat = -3,
|
||||
TypeInternalStackString = -2,
|
||||
TypeInternalString = -1,
|
||||
};
|
||||
|
||||
S32 type;
|
||||
|
||||
public:
|
||||
|
||||
// NOTE: This is protected to ensure no one outside
|
||||
// of this structure is messing with it.
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union
|
||||
|
||||
// An variable is either a real dynamic type or
|
||||
// its one exposed from C++ using a data pointer.
|
||||
//
|
||||
// We use this nameless union and struct setup
|
||||
// to optimize the memory usage.
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
char *sval;
|
||||
U32 ival; // doubles as strlen when type is TypeInternalString
|
||||
F32 fval;
|
||||
U32 bufferLen;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
/// The real data pointer.
|
||||
void *dataPtr;
|
||||
|
||||
/// The enum lookup table for enumerated types.
|
||||
const EnumTable *enumTable;
|
||||
};
|
||||
};
|
||||
|
||||
U32 getIntValue();
|
||||
S32 getSignedIntValue();
|
||||
F32 getFloatValue();
|
||||
const char *getStringValue();
|
||||
bool getBoolValue();
|
||||
|
||||
void setIntValue(U32 val);
|
||||
void setIntValue(S32 val);
|
||||
void setFloatValue(F32 val);
|
||||
void setStringValue(const char *value);
|
||||
void setStackStringValue(const char *value);
|
||||
void setBoolValue(bool val);
|
||||
|
||||
void init()
|
||||
{
|
||||
ival = 0;
|
||||
fval = 0;
|
||||
sval = typeValueEmpty;
|
||||
bufferLen = 0;
|
||||
}
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
if (type <= TypeInternalString &&
|
||||
sval != typeValueEmpty && type != TypeInternalStackString )
|
||||
dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
type = ConsoleValue::TypeInternalString;
|
||||
ival = 0;
|
||||
fval = 0;
|
||||
bufferLen = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Proxy class for console variables
|
||||
// Can point to existing console variables,
|
||||
// or act like a free floating value.
|
||||
class ConsoleValueRef
|
||||
{
|
||||
public:
|
||||
ConsoleValue *value;
|
||||
const char *stringStackValue;
|
||||
|
||||
ConsoleValueRef() : value(0), stringStackValue(0) { ; }
|
||||
~ConsoleValueRef() { ; }
|
||||
|
||||
ConsoleValueRef(const ConsoleValueRef &ref);
|
||||
ConsoleValueRef(const char *value);
|
||||
ConsoleValueRef(const String &ref);
|
||||
ConsoleValueRef(U32 value);
|
||||
ConsoleValueRef(S32 value);
|
||||
ConsoleValueRef(F32 value);
|
||||
ConsoleValueRef(F64 value);
|
||||
|
||||
const char *getStringValue() { return value ? value->getStringValue() : ""; }
|
||||
const char *getStringArgValue();
|
||||
|
||||
inline U32 getIntValue() { return value ? value->getIntValue() : 0; }
|
||||
inline S32 getSignedIntValue() { return value ? value->getSignedIntValue() : 0; }
|
||||
inline F32 getFloatValue() { return value ? value->getFloatValue() : 0.0f; }
|
||||
inline bool getBoolValue() { return value ? value->getBoolValue() : false; }
|
||||
|
||||
inline operator const char*() { return getStringValue(); }
|
||||
inline operator String() { return String(getStringValue()); }
|
||||
inline operator U32() { return getIntValue(); }
|
||||
inline operator S32() { return getSignedIntValue(); }
|
||||
inline operator F32() { return getFloatValue(); }
|
||||
|
||||
inline bool isString() { return value ? value->type >= ConsoleValue::TypeInternalStackString : true; }
|
||||
inline bool isInt() { return value ? value->type == ConsoleValue::TypeInternalInt : false; }
|
||||
inline bool isFloat() { return value ? value->type == ConsoleValue::TypeInternalFloat : false; }
|
||||
|
||||
// Note: operators replace value
|
||||
ConsoleValueRef& operator=(const ConsoleValueRef &other);
|
||||
ConsoleValueRef& operator=(const char *newValue);
|
||||
ConsoleValueRef& operator=(U32 newValue);
|
||||
ConsoleValueRef& operator=(S32 newValue);
|
||||
ConsoleValueRef& operator=(F32 newValue);
|
||||
ConsoleValueRef& operator=(F64 newValue);
|
||||
};
|
||||
|
||||
// Overrides to allow ConsoleValueRefs to be directly converted to S32&F32
|
||||
|
||||
inline S32 dAtoi(ConsoleValueRef &ref)
|
||||
{
|
||||
return ref.getSignedIntValue();
|
||||
}
|
||||
|
||||
inline F32 dAtof(ConsoleValueRef &ref)
|
||||
{
|
||||
return ref.getFloatValue();
|
||||
}
|
||||
|
||||
inline bool dAtob(ConsoleValue &ref)
|
||||
{
|
||||
return ref.getBoolValue();
|
||||
}
|
||||
|
||||
|
||||
// Transparently converts ConsoleValue[] to const char**
|
||||
class StringStackWrapper
|
||||
{
|
||||
public:
|
||||
const char **argv;
|
||||
int argc;
|
||||
|
||||
StringStackWrapper(int targc, ConsoleValueRef targv[]);
|
||||
~StringStackWrapper();
|
||||
|
||||
const char* operator[](int idx) { return argv[idx]; }
|
||||
operator const char**() { return argv; }
|
||||
|
||||
int count() { return argc; }
|
||||
};
|
||||
|
||||
// Transparently converts const char** to ConsoleValue
|
||||
class StringStackConsoleWrapper
|
||||
{
|
||||
public:
|
||||
ConsoleValueRef *argv;
|
||||
int argc;
|
||||
|
||||
StringStackConsoleWrapper(int targc, const char **targv);
|
||||
~StringStackConsoleWrapper();
|
||||
|
||||
ConsoleValueRef& operator[](int idx) { return argv[idx]; }
|
||||
operator ConsoleValueRef*() { return argv; }
|
||||
|
||||
int count() { return argc; }
|
||||
};
|
||||
|
||||
/// @defgroup console_callbacks Scripting Engine Callbacks
|
||||
///
|
||||
|
|
@ -129,11 +311,11 @@ typedef const char *StringTableEntry;
|
|||
/// @{
|
||||
|
||||
///
|
||||
typedef const char * (*StringCallback)(SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef S32 (*IntCallback)(SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef F32 (*FloatCallback)(SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef void (*VoidCallback)(SimObject *obj, S32 argc, const char *argv[]); // We have it return a value so things don't break..
|
||||
typedef bool (*BoolCallback)(SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef const char * (*StringCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||
typedef S32 (*IntCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||
typedef F32 (*FloatCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||
typedef void (*VoidCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); // We have it return a value so things don't break..
|
||||
typedef bool (*BoolCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||
|
||||
typedef void (*ConsumerCallback)(U32 level, const char *consoleLine);
|
||||
/// @}
|
||||
|
|
@ -182,7 +364,9 @@ 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
|
||||
DSOVersion = 46,
|
||||
/// 09/07/14 - jamesu - 46->47 64bit support
|
||||
/// 10/14/14 - jamesu - 47->48 Added opcodes to reduce reliance on strings in function calls
|
||||
DSOVersion = 48,
|
||||
|
||||
MaxLineLength = 512, ///< Maximum length of a line of console input.
|
||||
MaxDataTypes = 256 ///< Maximum number of registered data types.
|
||||
|
|
@ -415,6 +599,11 @@ namespace Con
|
|||
/// @return The string value of the variable or "" if the variable does not exist.
|
||||
const char* getVariable(const char* name);
|
||||
|
||||
/// Retrieve the string value of an object field
|
||||
/// @param name "object.field" string to query
|
||||
/// @return The string value of the variable or NULL if no object is specified
|
||||
const char* getObjectField(const char* name);
|
||||
|
||||
/// Same as setVariable(), but for bools.
|
||||
void setBoolVariable (const char* name,bool var);
|
||||
|
||||
|
|
@ -565,9 +754,11 @@ namespace Con
|
|||
/// char* result = execute(2, argv);
|
||||
/// @endcode
|
||||
const char *execute(S32 argc, const char* argv[]);
|
||||
const char *execute(S32 argc, ConsoleValueRef argv[]);
|
||||
|
||||
/// @see execute(S32 argc, const char* argv[])
|
||||
#define ARG const char*
|
||||
// Note: this can't be ConsoleValueRef& since the compiler will confuse it with SimObject*
|
||||
#define ARG ConsoleValueRef
|
||||
const char *executef( ARG);
|
||||
const char *executef( ARG, ARG);
|
||||
const char *executef( ARG, ARG, ARG);
|
||||
|
|
@ -580,7 +771,6 @@ namespace Con
|
|||
const char *executef( ARG, ARG, ARG, ARG, ARG, ARG, ARG, ARG, ARG, ARG);
|
||||
#undef ARG
|
||||
|
||||
|
||||
/// Call a Torque Script member function of a SimObject from C/C++ code.
|
||||
/// @param object Object on which to execute the method call.
|
||||
/// @param argc Number of elements in the argv parameter (must be >2, see argv)
|
||||
|
|
@ -594,9 +784,10 @@ namespace Con
|
|||
/// char* result = execute(mysimobject, 3, argv);
|
||||
/// @endcode
|
||||
const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly = false);
|
||||
const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly = false);
|
||||
|
||||
/// @see execute(SimObject *, S32 argc, const char *argv[])
|
||||
#define ARG const char*
|
||||
/// @see execute(SimObject *, S32 argc, ConsoleValueRef argv[])
|
||||
#define ARG ConsoleValueRef
|
||||
const char *executef(SimObject *, ARG);
|
||||
const char *executef(SimObject *, ARG, ARG);
|
||||
const char *executef(SimObject *, ARG, ARG, ARG);
|
||||
|
|
@ -640,12 +831,14 @@ 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 );
|
||||
/// @}
|
||||
|
||||
void resetStackFrame();
|
||||
|
||||
/// @name Namespaces
|
||||
/// @{
|
||||
|
||||
|
|
@ -696,7 +889,7 @@ namespace Con
|
|||
|
||||
extern void expandEscape(char *dest, const char *src);
|
||||
extern bool collapseEscape(char *buf);
|
||||
extern S32 HashPointer(StringTableEntry ptr);
|
||||
extern U32 HashPointer(StringTableEntry ptr);
|
||||
|
||||
|
||||
/// Extended information about a console function.
|
||||
|
|
@ -941,14 +1134,14 @@ struct ConsoleDocFragment
|
|||
static ConsoleConstructor cfg_ConsoleFunctionGroup_##groupName##_GroupBegin(NULL,#groupName,usage)
|
||||
|
||||
# define ConsoleFunction(name,returnType,minArgs,maxArgs,usage1) \
|
||||
returnType cf_##name(SimObject *, S32, const char **argv); \
|
||||
returnType cf_##name(SimObject *, S32, ConsoleValueRef *argv); \
|
||||
ConsoleConstructor cc_##name##_obj(NULL,#name,cf_##name,usage1,minArgs,maxArgs); \
|
||||
returnType cf_##name(SimObject *, S32 argc, const char **argv)
|
||||
returnType cf_##name(SimObject *, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleToolFunction(name,returnType,minArgs,maxArgs,usage1) \
|
||||
returnType ctf_##name(SimObject *, S32, const char **argv); \
|
||||
returnType ctf_##name(SimObject *, S32, ConsoleValueRef *argv); \
|
||||
ConsoleConstructor cc_##name##_obj(NULL,#name,ctf_##name,usage1,minArgs,maxArgs, true); \
|
||||
returnType ctf_##name(SimObject *, S32 argc, const char **argv)
|
||||
returnType ctf_##name(SimObject *, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleFunctionGroupEnd(groupName) \
|
||||
static ConsoleConstructor cfg_##groupName##_GroupEnd(NULL,#groupName,NULL)
|
||||
|
|
@ -961,22 +1154,22 @@ struct ConsoleDocFragment
|
|||
static ConsoleConstructor cc_##className##_##groupName##_GroupBegin(#className,#groupName,usage)
|
||||
|
||||
# define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \
|
||||
inline returnType cm_##className##_##name(className *, S32, const char **argv); \
|
||||
returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, const char **argv) { \
|
||||
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, const char **argv)
|
||||
inline returnType cm_##className##_##name(className *object, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1) \
|
||||
inline returnType cm_##className##_##name(S32, const char **); \
|
||||
returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, const char **argv) { \
|
||||
inline returnType cm_##className##_##name(S32, ConsoleValueRef *); \
|
||||
returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \
|
||||
conmethod_return_##returnType ) cm_##className##_##name(argc,argv); \
|
||||
}; \
|
||||
ConsoleConstructor \
|
||||
cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \
|
||||
inline returnType cm_##className##_##name(S32 argc, const char **argv)
|
||||
inline returnType cm_##className##_##name(S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleMethodGroupEnd(className, groupName) \
|
||||
static ConsoleConstructor cc_##className##_##groupName##_GroupEnd(#className,#groupName,NULL)
|
||||
|
|
@ -999,32 +1192,32 @@ struct ConsoleDocFragment
|
|||
|
||||
// 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 returnType c##name(SimObject *, S32, ConsoleValueRef*); \
|
||||
static ConsoleConstructor g##name##obj(NULL,#name,c##name,"",minArgs,maxArgs);\
|
||||
static returnType c##name(SimObject *, S32 argc, const char **argv)
|
||||
static returnType c##name(SimObject *, S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
# define ConsoleToolFunction(name,returnType,minArgs,maxArgs,usage1) \
|
||||
static returnType c##name(SimObject *, S32, const char **); \
|
||||
static returnType c##name(SimObject *, S32, ConsoleValueRef*); \
|
||||
static ConsoleConstructor g##name##obj(NULL,#name,c##name,"",minArgs,maxArgs, true);\
|
||||
static returnType c##name(SimObject *, S32 argc, const char **argv)
|
||||
static returnType c##name(SimObject *, S32 argc, ConsoleValueRef *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) { \
|
||||
static inline returnType c##className##name(className *, S32, ConsoleValueRef *argv); \
|
||||
static returnType c##className##name##caster(SimObject *object, S32 argc, ConsoleValueRef *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)
|
||||
static inline returnType c##className##name(className *object, S32 argc, ConsoleValueRef *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) { \
|
||||
static inline returnType c##className##name(S32, ConsoleValueRef*); \
|
||||
static returnType c##className##name##caster(SimObject *object, S32 argc, ConsoleValueRef *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)
|
||||
static inline returnType c##className##name(S32 argc, ConsoleValueRef *argv)
|
||||
|
||||
#define ConsoleDoc( text )
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
|
|||
"@ingroup Strings\n"
|
||||
"@see http://en.wikipedia.org/wiki/Printf" )
|
||||
{
|
||||
char* pBuffer = Con::getReturnBuffer(64);
|
||||
static const U32 bufSize = 64;
|
||||
char* pBuffer = Con::getReturnBuffer(bufSize);
|
||||
const char *pch = format;
|
||||
|
||||
pBuffer[0] = '\0';
|
||||
|
|
@ -99,7 +100,7 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
|
|||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
dSprintf( pBuffer, 64, format, dAtoi( value ) );
|
||||
dSprintf( pBuffer, bufSize, format, dAtoi( value ) );
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
|
|
@ -107,7 +108,7 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
|
|||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
dSprintf( pBuffer, 64, format, dAtof( value ) );
|
||||
dSprintf( pBuffer, bufSize, format, dAtof( value ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -1206,7 +1207,9 @@ ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, str
|
|||
"@endtsexample\n\n"
|
||||
"@ingroup Strings" )
|
||||
{
|
||||
char *str = (char *) argv[1];
|
||||
char buffer[4096];
|
||||
dStrncpy(buffer, argv[1], 4096);
|
||||
char *str = buffer;
|
||||
const char *token = argv[2];
|
||||
const char *delim = argv[3];
|
||||
|
||||
|
|
@ -1239,7 +1242,9 @@ ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, str
|
|||
str++;
|
||||
}
|
||||
|
||||
return str;
|
||||
char *ret = Con::getReturnBuffer(dStrlen(str)+1);
|
||||
dStrncpy(ret, str, dStrlen(str)+1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
@ -1301,16 +1306,17 @@ ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)"
|
|||
TORQUE_UNUSED(argc);
|
||||
if(argv[1][0] == StringTagPrefixByte)
|
||||
{
|
||||
const char *arg = argv[1];
|
||||
const char * space = dStrchr(argv[1], ' ');
|
||||
|
||||
U32 len;
|
||||
if(space)
|
||||
len = space - argv[1];
|
||||
len = space - arg;
|
||||
else
|
||||
len = dStrlen(argv[1]) + 1;
|
||||
len = dStrlen(arg) + 1;
|
||||
|
||||
char * ret = Con::getReturnBuffer(len);
|
||||
dStrncpy(ret, argv[1] + 1, len - 1);
|
||||
dStrncpy(ret, arg + 1, len - 1);
|
||||
ret[len - 1] = 0;
|
||||
|
||||
return(ret);
|
||||
|
|
@ -1516,11 +1522,12 @@ ConsoleFunction( realQuit, void, 1, 1, "" )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineConsoleFunction( quitWithErrorMessage, void, ( const char* message ),,
|
||||
DefineConsoleFunction( quitWithErrorMessage, void, ( const char* message, S32 status ), (0),
|
||||
"Display an error message box showing the given @a message and then shut down the engine and exit its process.\n"
|
||||
"This function cleanly uninitialized the engine and then exits back to the system with a process "
|
||||
"exit status indicating an error.\n\n"
|
||||
"@param message The message to log to the console and show in an error message box.\n\n"
|
||||
"@param message The message to log to the console and show in an error message box.\n"
|
||||
"@param status The status code to return to the OS.\n\n"
|
||||
"@see quit\n\n"
|
||||
"@ingroup Platform" )
|
||||
{
|
||||
|
|
@ -1531,7 +1538,20 @@ DefineConsoleFunction( quitWithErrorMessage, void, ( const char* message ),,
|
|||
// as the script code should not be allowed to pretty much hard-crash the engine
|
||||
// and prevent proper shutdown. Changed this to use postQuitMessage.
|
||||
|
||||
Platform::postQuitMessage( -1 );
|
||||
Platform::postQuitMessage( status );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineConsoleFunction( quitWithStatus, void, ( S32 status ), (0),
|
||||
"Shut down the engine and exit its process.\n"
|
||||
"This function cleanly uninitializes the engine and then exits back to the system with a given "
|
||||
"return status code.\n\n"
|
||||
"@param status The status code to return to the OS.\n\n"
|
||||
"@see quitWithErrorMessage\n\n"
|
||||
"@ingroup Platform" )
|
||||
{
|
||||
Platform::postQuitMessage(status);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1588,6 +1608,13 @@ DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/s
|
|||
return Platform::displaySplashWindow(path);
|
||||
}
|
||||
|
||||
DefineEngineFunction( closeSplashWindow, void, (),,
|
||||
"Close our startup splash window.\n\n"
|
||||
"@note This is currently only implemented on Windows.\n\n"
|
||||
"@ingroup Platform" )
|
||||
{
|
||||
Platform::closeSplashWindow();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( getWebDeployment, bool, (),,
|
||||
|
|
@ -2360,7 +2387,7 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
if (dStrcmp(argv[1], "0") && dStrcmp(argv[1], "") && (Sim::findObject(argv[1]) != NULL))
|
||||
return true;
|
||||
else if (argc > 2)
|
||||
Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, argv[1]);
|
||||
Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, (const char*)argv[1]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -2395,7 +2422,7 @@ ConsoleFunction( pushInstantGroup, void, 1, 2, "([group])"
|
|||
"@internal")
|
||||
{
|
||||
if( argc > 1 )
|
||||
Con::pushInstantGroup( argv[ 1 ] );
|
||||
Con::pushInstantGroup( (const char*)argv[ 1 ] );
|
||||
else
|
||||
Con::pushInstantGroup();
|
||||
}
|
||||
|
|
@ -2415,7 +2442,7 @@ ConsoleFunction(getPrefsPath, const char *, 1, 2, "([relativeFileName])"
|
|||
"@note Appears to be useless in Torque 3D, should be deprecated\n"
|
||||
"@internal")
|
||||
{
|
||||
const char *filename = Platform::getPrefsPath(argc > 1 ? argv[1] : NULL);
|
||||
const char *filename = Platform::getPrefsPath(argc > 1 ? (const char*)argv[1] : NULL);
|
||||
if(filename == NULL || *filename == 0)
|
||||
return "";
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
//#define DEBUG_SPEW
|
||||
|
||||
|
||||
#define ST_INIT_SIZE 15
|
||||
|
||||
static char scratchBuffer[1024];
|
||||
|
|
@ -168,13 +167,13 @@ void Dictionary::exportVariables(const char *varString, const char *fileName, bo
|
|||
|
||||
for(s = sortList.begin(); s != sortList.end(); s++)
|
||||
{
|
||||
switch((*s)->type)
|
||||
switch((*s)->value.type)
|
||||
{
|
||||
case Entry::TypeInternalInt:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %d;%s", (*s)->name, (*s)->ival, cat);
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %d;%s", (*s)->name, (*s)->value.ival, cat);
|
||||
break;
|
||||
case Entry::TypeInternalFloat:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %g;%s", (*s)->name, (*s)->fval, cat);
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %g;%s", (*s)->name, (*s)->value.fval, cat);
|
||||
break;
|
||||
default:
|
||||
expandEscape(expandBuffer, (*s)->getStringValue());
|
||||
|
|
@ -228,13 +227,13 @@ void Dictionary::exportVariables( const char *varString, Vector<String> *names,
|
|||
|
||||
if ( values )
|
||||
{
|
||||
switch ( (*s)->type )
|
||||
switch ( (*s)->value.type )
|
||||
{
|
||||
case Entry::TypeInternalInt:
|
||||
values->push_back( String::ToString( (*s)->ival ) );
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
values->push_back( String::ToString( (*s)->value.ival ) );
|
||||
break;
|
||||
case Entry::TypeInternalFloat:
|
||||
values->push_back( String::ToString( (*s)->fval ) );
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
values->push_back( String::ToString( (*s)->value.fval ) );
|
||||
break;
|
||||
default:
|
||||
expandEscape( expandBuffer, (*s)->getStringValue() );
|
||||
|
|
@ -262,9 +261,9 @@ void Dictionary::deleteVariables(const char *varString)
|
|||
}
|
||||
}
|
||||
|
||||
S32 HashPointer(StringTableEntry ptr)
|
||||
U32 HashPointer(StringTableEntry ptr)
|
||||
{
|
||||
return (S32)(((dsize_t)ptr) >> 2);
|
||||
return (U32)(((dsize_t)ptr) >> 2);
|
||||
}
|
||||
|
||||
Dictionary::Entry *Dictionary::lookup(StringTableEntry name)
|
||||
|
|
@ -284,6 +283,7 @@ Dictionary::Entry *Dictionary::lookup(StringTableEntry name)
|
|||
Dictionary::Entry *Dictionary::add(StringTableEntry name)
|
||||
{
|
||||
// Try to find an existing match.
|
||||
//printf("Add Variable %s\n", name);
|
||||
|
||||
Entry* ret = lookup( name );
|
||||
if( ret )
|
||||
|
|
@ -307,7 +307,7 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name)
|
|||
for( Entry* entry = hashTable->data[ i ]; entry != NULL; )
|
||||
{
|
||||
Entry* next = entry->nextEntry;
|
||||
S32 index = HashPointer( entry->name ) % newTableSize;
|
||||
U32 index = HashPointer( entry->name ) % newTableSize;
|
||||
|
||||
entry->nextEntry = newTableData[ index ];
|
||||
newTableData[ index ] = entry;
|
||||
|
|
@ -330,7 +330,7 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name)
|
|||
|
||||
ret = hashTable->mChunker.alloc();
|
||||
constructInPlace( ret, name );
|
||||
S32 idx = HashPointer(name) % hashTable->size;
|
||||
U32 idx = HashPointer(name) % hashTable->size;
|
||||
ret->nextEntry = hashTable->data[idx];
|
||||
hashTable->data[idx] = ret;
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ char *typeValueEmpty = "";
|
|||
Dictionary::Entry::Entry(StringTableEntry in_name)
|
||||
{
|
||||
name = in_name;
|
||||
type = TypeInternalString;
|
||||
value.type = ConsoleValue::TypeInternalString;
|
||||
notify = NULL;
|
||||
nextEntry = NULL;
|
||||
mUsage = NULL;
|
||||
|
|
@ -462,17 +462,12 @@ Dictionary::Entry::Entry(StringTableEntry in_name)
|
|||
|
||||
// NOTE: This is data inside a nameless
|
||||
// union, so we don't need to init the rest.
|
||||
ival = 0;
|
||||
fval = 0;
|
||||
sval = typeValueEmpty;
|
||||
bufferLen = 0;
|
||||
value.init();
|
||||
}
|
||||
|
||||
Dictionary::Entry::~Entry()
|
||||
{
|
||||
if ( type <= TypeInternalString &&
|
||||
sval != typeValueEmpty )
|
||||
dFree(sval);
|
||||
value.cleanup();
|
||||
|
||||
if ( notify )
|
||||
delete notify;
|
||||
|
|
@ -497,15 +492,11 @@ const char *Dictionary::getVariable(StringTableEntry name, bool *entValid)
|
|||
return "";
|
||||
}
|
||||
|
||||
void Dictionary::Entry::setStringValue(const char * value)
|
||||
void ConsoleValue::setStringValue(const char * value)
|
||||
{
|
||||
if( mIsConstant )
|
||||
{
|
||||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
||||
return;
|
||||
}
|
||||
if (value == NULL) value = typeValueEmpty;
|
||||
|
||||
if(type <= TypeInternalString)
|
||||
if(type <= ConsoleValue::TypeInternalString)
|
||||
{
|
||||
// Let's not remove empty-string-valued global vars from the dict.
|
||||
// If we remove them, then they won't be exported, and sometimes
|
||||
|
|
@ -519,6 +510,16 @@ void Dictionary::Entry::setStringValue(const char * value)
|
|||
return;
|
||||
}
|
||||
*/
|
||||
if (value == typeValueEmpty)
|
||||
{
|
||||
if (sval && sval != typeValueEmpty && type != TypeInternalStackString) dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
bufferLen = 0;
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
type = TypeInternalString;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 stringLen = dStrlen(value);
|
||||
|
||||
|
|
@ -537,25 +538,92 @@ void Dictionary::Entry::setStringValue(const char * value)
|
|||
ival = 0;
|
||||
}
|
||||
|
||||
type = TypeInternalString;
|
||||
|
||||
// may as well pad to the next cache line
|
||||
U32 newLen = ((stringLen + 1) + 15) & ~15;
|
||||
|
||||
if(sval == typeValueEmpty)
|
||||
|
||||
if(sval == typeValueEmpty || type == TypeInternalStackString)
|
||||
sval = (char *) dMalloc(newLen);
|
||||
else if(newLen > bufferLen)
|
||||
sval = (char *) dRealloc(sval, newLen);
|
||||
|
||||
type = TypeInternalString;
|
||||
|
||||
bufferLen = newLen;
|
||||
dStrcpy(sval, value);
|
||||
}
|
||||
else
|
||||
Con::setData(type, dataPtr, 0, 1, &value, enumTable);
|
||||
}
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if ( notify )
|
||||
notify->trigger();
|
||||
|
||||
void ConsoleValue::setStackStringValue(const char * value)
|
||||
{
|
||||
if (value == NULL) value = typeValueEmpty;
|
||||
|
||||
if(type <= ConsoleValue::TypeInternalString)
|
||||
{
|
||||
if (value == typeValueEmpty)
|
||||
{
|
||||
if (sval && sval != typeValueEmpty && type != ConsoleValue::TypeInternalStackString) dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
bufferLen = 0;
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
type = TypeInternalString;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 stringLen = dStrlen(value);
|
||||
if(stringLen < 256)
|
||||
{
|
||||
fval = dAtof(value);
|
||||
ival = dAtoi(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
}
|
||||
|
||||
type = TypeInternalStackString;
|
||||
sval = (char*)value;
|
||||
bufferLen = stringLen;
|
||||
}
|
||||
else
|
||||
Con::setData(type, dataPtr, 0, 1, &value, enumTable);
|
||||
}
|
||||
|
||||
|
||||
S32 Dictionary::getIntVariable(StringTableEntry name, bool *entValid)
|
||||
{
|
||||
Entry *ent = lookup(name);
|
||||
if(ent)
|
||||
{
|
||||
if(entValid)
|
||||
*entValid = true;
|
||||
return ent->getIntValue();
|
||||
}
|
||||
|
||||
if(entValid)
|
||||
*entValid = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
F32 Dictionary::getFloatVariable(StringTableEntry name, bool *entValid)
|
||||
{
|
||||
Entry *ent = lookup(name);
|
||||
if(ent)
|
||||
{
|
||||
if(entValid)
|
||||
*entValid = true;
|
||||
return ent->getFloatValue();
|
||||
}
|
||||
|
||||
if(entValid)
|
||||
*entValid = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Dictionary::setVariable(StringTableEntry name, const char *value)
|
||||
|
|
@ -582,19 +650,19 @@ Dictionary::Entry* Dictionary::addVariable( const char *name,
|
|||
|
||||
Entry *ent = add(StringTable->insert(name));
|
||||
|
||||
if ( ent->type <= Entry::TypeInternalString &&
|
||||
ent->sval != typeValueEmpty )
|
||||
dFree(ent->sval);
|
||||
if ( ent->value.type <= ConsoleValue::TypeInternalString &&
|
||||
ent->value.sval != typeValueEmpty && ent->value.type != ConsoleValue::TypeInternalStackString )
|
||||
dFree(ent->value.sval);
|
||||
|
||||
ent->type = type;
|
||||
ent->dataPtr = dataPtr;
|
||||
ent->value.type = type;
|
||||
ent->value.dataPtr = dataPtr;
|
||||
ent->mUsage = usage;
|
||||
|
||||
// Fetch enum table, if any.
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType( type );
|
||||
AssertFatal( conType, "Dictionary::addVariable - invalid console type" );
|
||||
ent->enumTable = conType->getEnumTable();
|
||||
ent->value.enumTable = conType->getEnumTable();
|
||||
|
||||
return ent;
|
||||
}
|
||||
|
|
@ -616,7 +684,7 @@ void Dictionary::addVariableNotify( const char *name, const Con::NotifyDelegate
|
|||
return;
|
||||
|
||||
if ( !ent->notify )
|
||||
ent->notify = new Entry::NotifySignal();
|
||||
ent->notify = new Entry::NotifySignal();
|
||||
|
||||
ent->notify->notify( callback );
|
||||
}
|
||||
|
|
@ -1268,7 +1336,7 @@ void Namespace::markGroup(const char* name, const char* usage)
|
|||
|
||||
extern S32 executeBlock(StmtNode *block, ExprEvalState *state);
|
||||
|
||||
const char *Namespace::Entry::execute(S32 argc, const char **argv, ExprEvalState *state)
|
||||
const char *Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprEvalState *state)
|
||||
{
|
||||
if(mType == ConsoleFunctionType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class Namespace
|
|||
void clear();
|
||||
|
||||
///
|
||||
const char *execute( S32 argc, const char** argv, ExprEvalState* state );
|
||||
const char *execute( S32 argc, ConsoleValueRef* argv, ExprEvalState* state );
|
||||
|
||||
/// Return a one-line documentation text string for the function.
|
||||
String getBriefDescription( String* outRemainingDocText = NULL ) const;
|
||||
|
|
@ -275,7 +275,7 @@ class Namespace
|
|||
|
||||
typedef VectorPtr<Namespace::Entry *>::iterator NamespaceEntryListIterator;
|
||||
|
||||
extern char *typeValueEmpty;
|
||||
|
||||
|
||||
class Dictionary
|
||||
{
|
||||
|
|
@ -283,16 +283,9 @@ public:
|
|||
|
||||
struct Entry
|
||||
{
|
||||
enum
|
||||
{
|
||||
TypeInternalInt = -3,
|
||||
TypeInternalFloat = -2,
|
||||
TypeInternalString = -1,
|
||||
};
|
||||
|
||||
StringTableEntry name;
|
||||
ConsoleValue value;
|
||||
Entry *nextEntry;
|
||||
S32 type;
|
||||
|
||||
typedef Signal<void()> NotifySignal;
|
||||
|
||||
|
|
@ -306,72 +299,42 @@ public:
|
|||
/// Whether this is a constant that cannot be assigned to.
|
||||
bool mIsConstant;
|
||||
|
||||
protected:
|
||||
|
||||
// NOTE: This is protected to ensure no one outside
|
||||
// of this structure is messing with it.
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union
|
||||
|
||||
// An variable is either a real dynamic type or
|
||||
// its one exposed from C++ using a data pointer.
|
||||
//
|
||||
// We use this nameless union and struct setup
|
||||
// to optimize the memory usage.
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
char *sval;
|
||||
U32 ival; // doubles as strlen when type is TypeInternalString
|
||||
F32 fval;
|
||||
U32 bufferLen;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
/// The real data pointer.
|
||||
void *dataPtr;
|
||||
|
||||
/// The enum lookup table for enumerated types.
|
||||
const EnumTable *enumTable;
|
||||
};
|
||||
};
|
||||
|
||||
#pragma warning( pop ) // C4201
|
||||
|
||||
public:
|
||||
|
||||
Entry() {
|
||||
name = NULL;
|
||||
notify = NULL;
|
||||
nextEntry = NULL;
|
||||
mUsage = NULL;
|
||||
mIsConstant = false;
|
||||
value.init();
|
||||
}
|
||||
|
||||
Entry(StringTableEntry name);
|
||||
~Entry();
|
||||
|
||||
U32 getIntValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return ival;
|
||||
else
|
||||
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
|
||||
|
||||
Entry *mNext;
|
||||
|
||||
void reset() {
|
||||
name = NULL;
|
||||
value.cleanup();
|
||||
if ( notify )
|
||||
delete notify;
|
||||
}
|
||||
|
||||
F32 getFloatValue()
|
||||
inline U32 getIntValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return fval;
|
||||
else
|
||||
return dAtof(Con::getData(type, dataPtr, 0, enumTable));
|
||||
return value.getIntValue();
|
||||
}
|
||||
|
||||
const char *getStringValue()
|
||||
inline F32 getFloatValue()
|
||||
{
|
||||
if(type == TypeInternalString)
|
||||
return sval;
|
||||
if(type == TypeInternalFloat)
|
||||
return Con::getData(TypeF32, &fval, 0);
|
||||
else if(type == TypeInternalInt)
|
||||
return Con::getData(TypeS32, &ival, 0);
|
||||
else
|
||||
return Con::getData(type, dataPtr, 0, enumTable);
|
||||
return value.getFloatValue();
|
||||
}
|
||||
|
||||
inline const char *getStringValue()
|
||||
{
|
||||
return value.getStringValue();
|
||||
}
|
||||
|
||||
void setIntValue(U32 val)
|
||||
|
|
@ -381,23 +344,8 @@ public:
|
|||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
||||
return;
|
||||
}
|
||||
|
||||
if(type <= TypeInternalString)
|
||||
{
|
||||
fval = (F32)val;
|
||||
ival = val;
|
||||
if(sval != typeValueEmpty)
|
||||
{
|
||||
dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
}
|
||||
type = TypeInternalInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *dptr = Con::getData(TypeS32, &val, 0);
|
||||
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
|
||||
}
|
||||
|
||||
value.setIntValue(val);
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if ( notify )
|
||||
|
|
@ -411,159 +359,163 @@ public:
|
|||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
||||
return;
|
||||
}
|
||||
|
||||
if(type <= TypeInternalString)
|
||||
{
|
||||
fval = val;
|
||||
ival = static_cast<U32>(val);
|
||||
if(sval != typeValueEmpty)
|
||||
{
|
||||
dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
}
|
||||
type = TypeInternalFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *dptr = Con::getData(TypeF32, &val, 0);
|
||||
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
|
||||
}
|
||||
|
||||
value.setFloatValue(val);
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if ( notify )
|
||||
notify->trigger();
|
||||
}
|
||||
|
||||
void setStringValue(const char *value);
|
||||
void setStringValue(const char *newValue)
|
||||
{
|
||||
if( mIsConstant )
|
||||
{
|
||||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
||||
return;
|
||||
}
|
||||
|
||||
value.setStringValue(newValue);
|
||||
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if ( notify )
|
||||
notify->trigger();
|
||||
}
|
||||
};
|
||||
|
||||
struct HashTableData
|
||||
{
|
||||
Dictionary* owner;
|
||||
S32 size;
|
||||
S32 count;
|
||||
Entry **data;
|
||||
FreeListChunker< Entry > mChunker;
|
||||
|
||||
HashTableData( Dictionary* owner )
|
||||
: owner( owner ), size( 0 ), count( 0 ), data( NULL ) {}
|
||||
};
|
||||
struct HashTableData
|
||||
{
|
||||
Dictionary* owner;
|
||||
S32 size;
|
||||
S32 count;
|
||||
Entry **data;
|
||||
FreeListChunker< Entry > mChunker;
|
||||
|
||||
HashTableData( Dictionary* owner )
|
||||
: owner( owner ), size( 0 ), count( 0 ), data( NULL ) {}
|
||||
};
|
||||
|
||||
HashTableData* hashTable;
|
||||
HashTableData ownHashTable;
|
||||
ExprEvalState *exprState;
|
||||
|
||||
StringTableEntry scopeName;
|
||||
Namespace *scopeNamespace;
|
||||
CodeBlock *code;
|
||||
U32 ip;
|
||||
HashTableData* hashTable;
|
||||
HashTableData ownHashTable;
|
||||
ExprEvalState *exprState;
|
||||
|
||||
Dictionary();
|
||||
~Dictionary();
|
||||
StringTableEntry scopeName;
|
||||
Namespace *scopeNamespace;
|
||||
CodeBlock *code;
|
||||
U32 ip;
|
||||
|
||||
Entry *lookup(StringTableEntry name);
|
||||
Entry *add(StringTableEntry name);
|
||||
void setState(ExprEvalState *state, Dictionary* ref=NULL);
|
||||
void remove(Entry *);
|
||||
void reset();
|
||||
Dictionary();
|
||||
~Dictionary();
|
||||
|
||||
void exportVariables( const char *varString, const char *fileName, bool append );
|
||||
void exportVariables( const char *varString, Vector<String> *names, Vector<String> *values );
|
||||
void deleteVariables( const char *varString );
|
||||
Entry *lookup(StringTableEntry name);
|
||||
Entry *add(StringTableEntry name);
|
||||
void setState(ExprEvalState *state, Dictionary* ref=NULL);
|
||||
void remove(Entry *);
|
||||
void reset();
|
||||
|
||||
void setVariable(StringTableEntry name, const char *value);
|
||||
const char *getVariable(StringTableEntry name, bool *valid = NULL);
|
||||
|
||||
U32 getCount() const
|
||||
{
|
||||
void exportVariables( const char *varString, const char *fileName, bool append );
|
||||
void exportVariables( const char *varString, Vector<String> *names, Vector<String> *values );
|
||||
void deleteVariables( const char *varString );
|
||||
|
||||
void setVariable(StringTableEntry name, const char *value);
|
||||
const char *getVariable(StringTableEntry name, bool *valid = NULL);
|
||||
S32 getIntVariable(StringTableEntry name, bool *valid = NULL);
|
||||
F32 getFloatVariable(StringTableEntry name, bool *entValid = NULL);
|
||||
|
||||
U32 getCount() const
|
||||
{
|
||||
return hashTable->count;
|
||||
}
|
||||
bool isOwner() const
|
||||
{
|
||||
}
|
||||
bool isOwner() const
|
||||
{
|
||||
return hashTable->owner;
|
||||
}
|
||||
}
|
||||
|
||||
/// @see Con::addVariable
|
||||
Entry* addVariable( const char *name,
|
||||
S32 type,
|
||||
void *dataPtr,
|
||||
const char* usage );
|
||||
/// @see Con::addVariable
|
||||
Entry* addVariable( const char *name,
|
||||
S32 type,
|
||||
void *dataPtr,
|
||||
const char* usage );
|
||||
|
||||
/// @see Con::removeVariable
|
||||
bool removeVariable(StringTableEntry name);
|
||||
/// @see Con::removeVariable
|
||||
bool removeVariable(StringTableEntry name);
|
||||
|
||||
/// @see Con::addVariableNotify
|
||||
void addVariableNotify( const char *name, const Con::NotifyDelegate &callback );
|
||||
/// @see Con::addVariableNotify
|
||||
void addVariableNotify( const char *name, const Con::NotifyDelegate &callback );
|
||||
|
||||
/// @see Con::removeVariableNotify
|
||||
void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback );
|
||||
/// @see Con::removeVariableNotify
|
||||
void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback );
|
||||
|
||||
/// Return the best tab completion for prevText, with the length
|
||||
/// of the pre-tab string in baseLen.
|
||||
const char *tabComplete(const char *prevText, S32 baseLen, bool);
|
||||
|
||||
/// Run integrity checks for debugging.
|
||||
void validate();
|
||||
/// Return the best tab completion for prevText, with the length
|
||||
/// of the pre-tab string in baseLen.
|
||||
const char *tabComplete(const char *prevText, S32 baseLen, bool);
|
||||
|
||||
/// Run integrity checks for debugging.
|
||||
void validate();
|
||||
};
|
||||
|
||||
class ExprEvalState
|
||||
{
|
||||
public:
|
||||
/// @name Expression Evaluation
|
||||
/// @{
|
||||
/// @name Expression Evaluation
|
||||
/// @{
|
||||
|
||||
///
|
||||
SimObject *thisObject;
|
||||
Dictionary::Entry *currentVariable;
|
||||
bool traceOn;
|
||||
|
||||
U32 mStackDepth;
|
||||
///
|
||||
SimObject *thisObject;
|
||||
Dictionary::Entry *currentVariable;
|
||||
Dictionary::Entry *copyVariable;
|
||||
bool traceOn;
|
||||
|
||||
ExprEvalState();
|
||||
~ExprEvalState();
|
||||
U32 mStackDepth;
|
||||
|
||||
/// @}
|
||||
ExprEvalState();
|
||||
~ExprEvalState();
|
||||
|
||||
/// @name Stack Management
|
||||
/// @{
|
||||
/// @}
|
||||
|
||||
/// The stack of callframes. The extra redirection is necessary since Dictionary holds
|
||||
/// an interior pointer that will become invalid when the object changes address.
|
||||
Vector< Dictionary* > stack;
|
||||
/// @name Stack Management
|
||||
/// @{
|
||||
|
||||
///
|
||||
Dictionary globalVars;
|
||||
|
||||
void setCurVarName(StringTableEntry name);
|
||||
void setCurVarNameCreate(StringTableEntry name);
|
||||
S32 getIntVariable();
|
||||
F64 getFloatVariable();
|
||||
const char *getStringVariable();
|
||||
void setIntVariable(S32 val);
|
||||
void setFloatVariable(F64 val);
|
||||
void setStringVariable(const char *str);
|
||||
/// The stack of callframes. The extra redirection is necessary since Dictionary holds
|
||||
/// an interior pointer that will become invalid when the object changes address.
|
||||
Vector< Dictionary* > stack;
|
||||
|
||||
void pushFrame(StringTableEntry frameName, Namespace *ns);
|
||||
void popFrame();
|
||||
///
|
||||
Dictionary globalVars;
|
||||
|
||||
/// Puts a reference to an existing stack frame
|
||||
/// on the top of the stack.
|
||||
void pushFrameRef(S32 stackIndex);
|
||||
|
||||
U32 getStackDepth() const
|
||||
{
|
||||
return mStackDepth;
|
||||
}
|
||||
|
||||
Dictionary& getCurrentFrame()
|
||||
{
|
||||
void setCurVarName(StringTableEntry name);
|
||||
void setCurVarNameCreate(StringTableEntry name);
|
||||
|
||||
S32 getIntVariable();
|
||||
F64 getFloatVariable();
|
||||
const char *getStringVariable();
|
||||
void setIntVariable(S32 val);
|
||||
void setFloatVariable(F64 val);
|
||||
void setStringVariable(const char *str);
|
||||
void setCopyVariable();
|
||||
|
||||
void pushFrame(StringTableEntry frameName, Namespace *ns);
|
||||
void popFrame();
|
||||
|
||||
/// Puts a reference to an existing stack frame
|
||||
/// on the top of the stack.
|
||||
void pushFrameRef(S32 stackIndex);
|
||||
|
||||
U32 getStackDepth() const
|
||||
{
|
||||
return mStackDepth;
|
||||
}
|
||||
|
||||
Dictionary& getCurrentFrame()
|
||||
{
|
||||
return *( stack[ mStackDepth - 1 ] );
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// Run integrity checks for debugging.
|
||||
void validate();
|
||||
/// @}
|
||||
|
||||
/// Run integrity checks for debugging.
|
||||
void validate();
|
||||
};
|
||||
|
||||
namespace Con
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ void ConsoleLogger::initPersistFields()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ConsoleLogger::processArguments( S32 argc, const char **argv )
|
||||
bool ConsoleLogger::processArguments( S32 argc, ConsoleValueRef *argv )
|
||||
{
|
||||
if( argc == 0 )
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class ConsoleLogger : public SimObject
|
|||
/// // Example script constructor usage.
|
||||
/// %obj = new ConsoleLogger( objName, logFileName, [append = false] );
|
||||
/// @endcode
|
||||
bool processArguments( S32 argc, const char **argv );
|
||||
bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
|
||||
/// Default constructor, make sure to initalize
|
||||
ConsoleLogger();
|
||||
|
|
|
|||
|
|
@ -834,3 +834,44 @@ DefineEngineFunction( sizeof, S32, ( const char *objectOrClass ),,
|
|||
Con::warnf("could not find a class rep for that object or class name.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DefineEngineFunction(linkNamespaces, bool, ( String childNSName, String parentNSName ),,
|
||||
"@brief Links childNS to parentNS.\n\n"
|
||||
"Links childNS to parentNS, or nothing if parentNS is NULL.\n"
|
||||
"Will unlink the namespace from previous namespace if a parent already exists.\n"
|
||||
"@internal\n")
|
||||
{
|
||||
StringTableEntry childNSSTE = StringTable->insert(childNSName.c_str());
|
||||
StringTableEntry parentNSSTE = StringTable->insert(parentNSName.c_str());
|
||||
|
||||
Namespace *childNS = Namespace::find(childNSSTE);
|
||||
Namespace *parentNS = Namespace::find(parentNSSTE);
|
||||
Namespace *currentParent = childNS->getParent();
|
||||
|
||||
if (!childNS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Link to new NS if applicable
|
||||
|
||||
if (currentParent != parentNS)
|
||||
{
|
||||
if (currentParent != NULL)
|
||||
{
|
||||
if (!childNS->unlinkClass(currentParent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (parentNS != NULL)
|
||||
{
|
||||
return childNS->classLinkTo(parentNS);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "core/color.h"
|
||||
#include "console/simBase.h"
|
||||
#include "math/mRect.h"
|
||||
#include "core/strings/stringUnit.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TypeString
|
||||
|
|
@ -288,8 +289,9 @@ ImplementConsoleTypeCasters( TypeS8, S8 )
|
|||
|
||||
ConsoleGetType( TypeS8 )
|
||||
{
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%d", *((U8 *) dptr) );
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%d", *((U8 *) dptr) );
|
||||
return returnBuffer;
|
||||
}
|
||||
|
||||
|
|
@ -309,8 +311,9 @@ ImplementConsoleTypeCasters(TypeS32, S32)
|
|||
|
||||
ConsoleGetType( TypeS32 )
|
||||
{
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%d", *((S32 *) dptr) );
|
||||
static const U32 bufSize = 512;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%d", *((S32 *) dptr) );
|
||||
return returnBuffer;
|
||||
}
|
||||
|
||||
|
|
@ -388,8 +391,9 @@ ImplementConsoleTypeCasters(TypeF32, F32)
|
|||
|
||||
ConsoleGetType( TypeF32 )
|
||||
{
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%g", *((F32 *) dptr) );
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%g", *((F32 *) dptr) );
|
||||
return returnBuffer;
|
||||
}
|
||||
ConsoleSetType( TypeF32 )
|
||||
|
|
@ -486,8 +490,9 @@ ImplementConsoleTypeCasters( TypeBoolVector, Vector< bool > )
|
|||
ConsoleGetType( TypeBoolVector )
|
||||
{
|
||||
Vector<bool> *vec = (Vector<bool>*)dptr;
|
||||
char* returnBuffer = Con::getReturnBuffer(1024);
|
||||
S32 maxReturn = 1024;
|
||||
static const U32 bufSize = 1024;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
S32 maxReturn = bufSize;
|
||||
returnBuffer[0] = '\0';
|
||||
S32 returnLeng = 0;
|
||||
for (Vector<bool>::iterator itr = vec->begin(); itr < vec->end(); itr++)
|
||||
|
|
@ -567,9 +572,20 @@ ImplementConsoleTypeCasters( TypeColorF, ColorF )
|
|||
|
||||
ConsoleGetType( TypeColorF )
|
||||
{
|
||||
ColorF * color = (ColorF*)dptr;
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%g %g %g %g", color->red, color->green, color->blue, color->alpha);
|
||||
// Fetch color.
|
||||
const ColorF* color = (ColorF*)dptr;
|
||||
|
||||
// Fetch stock color name.
|
||||
StringTableEntry colorName = StockColor::name( *color );
|
||||
|
||||
// Write as color name if was found.
|
||||
if ( colorName != StringTable->EmptyString() )
|
||||
return colorName;
|
||||
|
||||
// Format as color components.
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%g %g %g %g", color->red, color->green, color->blue, color->alpha);
|
||||
return(returnBuffer);
|
||||
}
|
||||
|
||||
|
|
@ -578,6 +594,22 @@ ConsoleSetType( TypeColorF )
|
|||
ColorF *tmpColor = (ColorF *) dptr;
|
||||
if(argc == 1)
|
||||
{
|
||||
// Is only a single argument passed?
|
||||
if ( StringUnit::getUnitCount( argv[0], " " ) == 1 )
|
||||
{
|
||||
// Is this a stock color name?
|
||||
if ( !StockColor::isColor(argv[0]) )
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf( "TypeColorF() - Invalid single argument of '%s' could not be interpreted as a stock color name. Using default.", argv[0] );
|
||||
}
|
||||
|
||||
// Set stock color (if it's invalid we'll get the default.
|
||||
tmpColor->set( argv[0] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tmpColor->set(0, 0, 0, 1);
|
||||
F32 r,g,b,a;
|
||||
S32 args = dSscanf(argv[0], "%g %g %g %g", &r, &g, &b, &a);
|
||||
|
|
@ -602,7 +634,7 @@ ConsoleSetType( TypeColorF )
|
|||
tmpColor->alpha = dAtof(argv[3]);
|
||||
}
|
||||
else
|
||||
Con::printf("Color must be set as { r, g, b [,a] }");
|
||||
Con::printf("Color must be set as { r, g, b [,a] }, { r g b [b] } or { stockColorName }");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -613,9 +645,20 @@ ImplementConsoleTypeCasters( TypeColorI, ColorI )
|
|||
|
||||
ConsoleGetType( TypeColorI )
|
||||
{
|
||||
ColorI *color = (ColorI *) dptr;
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%d %d %d %d", color->red, color->green, color->blue, color->alpha);
|
||||
// Fetch color.
|
||||
ColorI* color = (ColorI*)dptr;
|
||||
|
||||
// Fetch stock color name.
|
||||
StringTableEntry colorName = StockColor::name( *color );
|
||||
|
||||
// Write as color name if was found.
|
||||
if ( colorName != StringTable->EmptyString() )
|
||||
return colorName;
|
||||
|
||||
// Format as color components.
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%d %d %d %d", color->red, color->green, color->blue, color->alpha);
|
||||
return returnBuffer;
|
||||
}
|
||||
|
||||
|
|
@ -624,6 +667,22 @@ ConsoleSetType( TypeColorI )
|
|||
ColorI *tmpColor = (ColorI *) dptr;
|
||||
if(argc == 1)
|
||||
{
|
||||
// Is only a single argument passed?
|
||||
if ( StringUnit::getUnitCount( argv[0], " " ) == 1 )
|
||||
{
|
||||
// Is this a stock color name?
|
||||
if ( !StockColor::isColor(argv[0]) )
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf( "TypeColorF() - Invalid single argument of '%s' could not be interpreted as a stock color name. Using default.", argv[0] );
|
||||
}
|
||||
|
||||
// Set stock color (if it's invalid we'll get the default.
|
||||
tmpColor->set( argv[0] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tmpColor->set(0, 0, 0, 255);
|
||||
S32 r,g,b,a;
|
||||
S32 args = dSscanf(argv[0], "%d %d %d %d", &r, &g, &b, &a);
|
||||
|
|
@ -648,7 +707,7 @@ ConsoleSetType( TypeColorI )
|
|||
tmpColor->alpha = dAtoi(argv[3]);
|
||||
}
|
||||
else
|
||||
Con::printf("Color must be set as { r, g, b [,a] }");
|
||||
Con::printf("Color must be set as { r, g, b [,a] }, { r g b [b] } or { stockColorName }");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -670,8 +729,9 @@ ConsoleSetType( TypeSimObjectName )
|
|||
ConsoleGetType( TypeSimObjectName )
|
||||
{
|
||||
SimObject **obj = (SimObject**)dptr;
|
||||
char* returnBuffer = Con::getReturnBuffer(128);
|
||||
dSprintf(returnBuffer, 128, "%s", *obj && (*obj)->getName() ? (*obj)->getName() : "");
|
||||
static const U32 bufSize = 128;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%s", *obj && (*obj)->getName() ? (*obj)->getName() : "");
|
||||
return returnBuffer;
|
||||
}
|
||||
|
||||
|
|
@ -738,8 +798,9 @@ ConsoleType( int, TypeTerrainMaterialIndex, S32 )
|
|||
|
||||
ConsoleGetType( TypeTerrainMaterialIndex )
|
||||
{
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%d", *((S32 *) dptr) );
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%d", *((S32 *) dptr) );
|
||||
return returnBuffer;
|
||||
}
|
||||
|
||||
|
|
@ -800,8 +861,9 @@ ConsoleType( RectF, TypeRectUV, RectF )
|
|||
ConsoleGetType( TypeRectUV )
|
||||
{
|
||||
RectF *rect = (RectF *) dptr;
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "%g %g %g %g", rect->point.x, rect->point.y,
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "%g %g %g %g", rect->point.x, rect->point.y,
|
||||
rect->extent.x, rect->extent.y);
|
||||
return returnBuffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,8 +211,9 @@ class BitfieldConsoleBaseType : public ConsoleBaseType
|
|||
|
||||
virtual const char* getData( void* dptr, const EnumTable*, BitSet32 )
|
||||
{
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer, 256, "0x%08x", *((S32 *) dptr) );
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(returnBuffer, bufSize, "0x%08x", *((S32 *) dptr) );
|
||||
return returnBuffer;
|
||||
}
|
||||
virtual void setData( void* dptr, S32 argc, const char** argv, const EnumTable*, BitSet32 )
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@
|
|||
|
||||
|
||||
// Disable some VC warnings that are irrelevant to us.
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4510 ) // default constructor could not be generated; all the Args structures are never constructed by us
|
||||
#pragma warning( disable : 4610 ) // can never be instantiated; again Args is never constructed by us
|
||||
|
||||
|
|
@ -145,12 +146,12 @@ inline const char* EngineMarshallData( U32 value )
|
|||
/// Marshal data from native into client form stored directly in
|
||||
/// client function invocation vector.
|
||||
template< typename T >
|
||||
inline void EngineMarshallData( const T& arg, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( const T& arg, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
argv[ argc ] = Con::getStringArg( castConsoleTypeToString( arg ) );
|
||||
argc ++;
|
||||
}
|
||||
inline void EngineMarshallData( bool arg, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( bool arg, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
if( arg )
|
||||
argv[ argc ] = "1";
|
||||
|
|
@ -158,33 +159,33 @@ inline void EngineMarshallData( bool arg, S32& argc, const char** argv )
|
|||
argv[ argc ] = "0";
|
||||
argc ++;
|
||||
}
|
||||
inline void EngineMarshallData( S32 arg, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
argv[ argc ] = Con::getIntArg( arg );
|
||||
argv[ argc ] = arg;
|
||||
argc ++;
|
||||
}
|
||||
inline void EngineMarshallData( U32 arg, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
EngineMarshallData( S32( arg ), argc, argv );
|
||||
}
|
||||
inline void EngineMarshallData( F32 arg, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( F32 arg, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
argv[ argc ] = Con::getFloatArg( arg );
|
||||
argv[ argc ] = arg;
|
||||
argc ++;
|
||||
}
|
||||
inline void EngineMarshallData( const char* arg, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
argv[ argc ] = arg;
|
||||
argc ++;
|
||||
}
|
||||
template< typename T >
|
||||
inline void EngineMarshallData( T* object, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( T* object, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
argv[ argc ] = ( object ? object->getIdString() : "0" );
|
||||
argc ++;
|
||||
}
|
||||
template< typename T >
|
||||
inline void EngineMarshallData( const T* object, S32& argc, const char** argv )
|
||||
inline void EngineMarshallData( const T* object, S32& argc, ConsoleValueRef *argv )
|
||||
{
|
||||
argv[ argc ] = ( object ? object->getIdString() : "0" );
|
||||
argc ++;
|
||||
|
|
@ -207,6 +208,11 @@ struct EngineUnmarshallData
|
|||
template<>
|
||||
struct EngineUnmarshallData< S32 >
|
||||
{
|
||||
S32 operator()( ConsoleValueRef &ref ) const
|
||||
{
|
||||
return (S32)ref;
|
||||
}
|
||||
|
||||
S32 operator()( const char* str ) const
|
||||
{
|
||||
return dAtoi( str );
|
||||
|
|
@ -215,6 +221,11 @@ struct EngineUnmarshallData< S32 >
|
|||
template<>
|
||||
struct EngineUnmarshallData< U32 >
|
||||
{
|
||||
U32 operator()( ConsoleValueRef &ref ) const
|
||||
{
|
||||
return (U32)((S32)ref);
|
||||
}
|
||||
|
||||
U32 operator()( const char* str ) const
|
||||
{
|
||||
return dAtoui( str );
|
||||
|
|
@ -223,6 +234,11 @@ struct EngineUnmarshallData< U32 >
|
|||
template<>
|
||||
struct EngineUnmarshallData< F32 >
|
||||
{
|
||||
F32 operator()( ConsoleValueRef &ref ) const
|
||||
{
|
||||
return (F32)ref;
|
||||
}
|
||||
|
||||
F32 operator()( const char* str ) const
|
||||
{
|
||||
return dAtof( str );
|
||||
|
|
@ -1391,12 +1407,12 @@ struct _EngineConsoleThunk< startArgc, R() >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 0;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )(), const _EngineFunctionDefaultArguments< void() >& )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )(), const _EngineFunctionDefaultArguments< void() >& )
|
||||
{
|
||||
return _EngineConsoleThunkReturnValue( fn() );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )() const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType* ) >& )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )() const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType* ) >& )
|
||||
{
|
||||
return _EngineConsoleThunkReturnValue( ( frame->*fn )() );
|
||||
}
|
||||
|
|
@ -1406,12 +1422,12 @@ struct _EngineConsoleThunk< startArgc, void() >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 0;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )(), const _EngineFunctionDefaultArguments< void() >& )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )(), const _EngineFunctionDefaultArguments< void() >& )
|
||||
{
|
||||
fn();
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )() const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType* ) >& )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )() const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType* ) >& )
|
||||
{
|
||||
return ( frame->*fn )();
|
||||
}
|
||||
|
|
@ -1422,13 +1438,13 @@ struct _EngineConsoleThunk< startArgc, R( A ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 1 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A ), const _EngineFunctionDefaultArguments< void( A ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A ), const _EngineFunctionDefaultArguments< void( A ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
return _EngineConsoleThunkReturnValue( fn( a ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
return _EngineConsoleThunkReturnValue( ( frame->*fn )( a ) );
|
||||
|
|
@ -1439,13 +1455,13 @@ struct _EngineConsoleThunk< startArgc, void( A ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 1 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A ), const _EngineFunctionDefaultArguments< void( A ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A ), const _EngineFunctionDefaultArguments< void( A ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
fn( a );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
( frame->*fn )( a );
|
||||
|
|
@ -1457,14 +1473,14 @@ struct _EngineConsoleThunk< startArgc, R( A, B ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 2 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B ), const _EngineFunctionDefaultArguments< void( A, B ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B ), const _EngineFunctionDefaultArguments< void( A, B ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
return _EngineConsoleThunkReturnValue( fn( a, b ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1476,14 +1492,14 @@ struct _EngineConsoleThunk< startArgc, void( A, B ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 2 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B ), const _EngineFunctionDefaultArguments< void( A, B ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B ), const _EngineFunctionDefaultArguments< void( A, B ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
fn( a, b );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1496,7 +1512,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 3 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C ), const _EngineFunctionDefaultArguments< void( A, B, C ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C ), const _EngineFunctionDefaultArguments< void( A, B, C ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1504,7 +1520,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1517,7 +1533,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 3 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C ), const _EngineFunctionDefaultArguments< void( A, B, C ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C ), const _EngineFunctionDefaultArguments< void( A, B, C ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1525,7 +1541,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C ) >
|
|||
fn( a, b, c );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1539,7 +1555,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 4 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D ), const _EngineFunctionDefaultArguments< void( A, B, C, D ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D ), const _EngineFunctionDefaultArguments< void( A, B, C, D ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1548,7 +1564,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1562,7 +1578,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 4 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D ), const _EngineFunctionDefaultArguments< void( A, B, C, D ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D ), const _EngineFunctionDefaultArguments< void( A, B, C, D ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1571,7 +1587,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D ) >
|
|||
fn( a, b, c, d );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1586,7 +1602,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 5 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1596,7 +1612,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1611,7 +1627,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 5 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1621,7 +1637,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E ) >
|
|||
fn( a, b, c, d, e );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1637,7 +1653,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 6 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E, F ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1648,7 +1664,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E, F ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1664,7 +1680,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 6 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E, F ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1675,7 +1691,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F ) >
|
|||
fn( a, b, c, d, e, f );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E, F ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1692,7 +1708,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 7 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E, F, G ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1704,7 +1720,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E, F, G ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1721,7 +1737,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 7 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E, F, G ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1733,7 +1749,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G ) >
|
|||
fn( a, b, c, d, e, f, g );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E, F, G ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1751,7 +1767,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 8 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E, F, G, H ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1764,7 +1780,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1782,7 +1798,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 8 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E, F, G, H ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1795,7 +1811,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H ) >
|
|||
fn( a, b, c, d, e, f, g, h );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1814,7 +1830,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 9 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E, F, G, H, I ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H, I ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1828,7 +1844,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h, i ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1847,7 +1863,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 9 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E, F, G, H, I ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H, I ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1861,7 +1877,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I ) >
|
|||
fn( a, b, c, d, e, f, g, h, i );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1881,7 +1897,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I, J ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 10 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E, F, G, H, I, J ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H, I, J ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1896,7 +1912,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I, J ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h, i, j ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1916,7 +1932,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 10 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E, F, G, H, I, J ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H, I, J ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1931,7 +1947,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J ) >
|
|||
fn( a, b, c, d, e, f, g, h, i, j );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1951,7 +1967,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
{
|
||||
typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
|
||||
static const S32 NUM_ARGS = 11 + startArgc;
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -1967,7 +1983,7 @@ struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h, i, j, k ) );
|
||||
}
|
||||
template< typename Frame >
|
||||
static ReturnType thunk( S32 argc, const char** argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J, K ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J, K ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -1988,7 +2004,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
{
|
||||
typedef void ReturnType;
|
||||
static const S32 NUM_ARGS = 11 + startArgc;
|
||||
static void thunk( S32 argc, const char** argv, void ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
|
||||
|
|
@ -2004,7 +2020,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
fn( a, b, c, d, e, f, g, h, i, j, k );
|
||||
}
|
||||
template< typename Frame >
|
||||
static void thunk( S32 argc, const char** argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J, K ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J, K ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
|
||||
{
|
||||
A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
|
||||
B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
|
||||
|
|
@ -2088,7 +2104,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
( void* ) &fn ## name, \
|
||||
0 \
|
||||
); \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, const char** argv ) \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \
|
||||
{ \
|
||||
return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
|
||||
argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \
|
||||
|
|
@ -2168,7 +2184,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
( void* ) &fn ## className ## _ ## name, \
|
||||
0 \
|
||||
); \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, const char** argv ) \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValueRef *argv ) \
|
||||
{ \
|
||||
_ ## className ## name ## frame frame; \
|
||||
frame.object = static_cast< className* >( object ); \
|
||||
|
|
@ -2225,7 +2241,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
( void* ) &fn ## className ## _ ## name, \
|
||||
0 \
|
||||
); \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, const char** argv )\
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )\
|
||||
{ \
|
||||
return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
|
||||
argc, argv, &_fn ## className ## name ## impl, _fn ## className ## name ## DefaultArgs \
|
||||
|
|
@ -2249,7 +2265,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
#define DefineConsoleFunction( name, returnType, args, defaultArgs, usage ) \
|
||||
static inline returnType _fn ## name ## impl args; \
|
||||
static _EngineFunctionDefaultArguments< void args > _fn ## name ## DefaultArgs defaultArgs; \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, const char** argv ) \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \
|
||||
{ \
|
||||
return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
|
||||
argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \
|
||||
|
|
@ -2274,7 +2290,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
}; \
|
||||
static _EngineFunctionDefaultArguments< _EngineMethodTrampoline< _ ## className ## name ## frame, void args >::FunctionType > \
|
||||
_fn ## className ## name ## DefaultArgs defaultArgs; \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, const char** argv ) \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValueRef *argv ) \
|
||||
{ \
|
||||
_ ## className ## name ## frame frame; \
|
||||
frame.object = static_cast< className* >( object ); \
|
||||
|
|
@ -2296,7 +2312,7 @@ struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
|
|||
#define DefineConsoleStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
|
||||
static inline returnType _fn ## className ## name ## impl args; \
|
||||
static _EngineFunctionDefaultArguments< void args > _fn ## className ## name ## DefaultArgs defaultArgs; \
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, const char** argv )\
|
||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )\
|
||||
{ \
|
||||
return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
|
||||
argc, argv, &_fn ## className ## name ## impl, _fn ## className ## name ## DefaultArgs \
|
||||
|
|
@ -2532,79 +2548,79 @@ struct _EngineCallbackHelper
|
|||
R call() const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject* );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis ) );
|
||||
}
|
||||
template< typename R, typename A >
|
||||
R call( A a ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a ) );
|
||||
}
|
||||
template< typename R, typename A, typename B >
|
||||
R call( A a, B b ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C >
|
||||
R call( A a, B b, C c ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D >
|
||||
R call( A a, B b, C c, D d ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E >
|
||||
R call( A a, B b, C c, D d, E e ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F >
|
||||
R call( A a, B b, C c, D d, E e, F f ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
|
||||
R call( A a, B b, C c, D d, E e, F f, G g ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f, g ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
|
||||
R call( A a, B b, C c, D d, E e, F f, G g, H h ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f, g, h ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
|
||||
R call( A a, B b, C c, D d, E e, F f, G g, H h, I i ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f, g, h, i ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
|
||||
R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I, J );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f, g, h, i, j ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i, j ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
|
||||
R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I, J, K );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f, g, h, i, j, k ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i, j, k ) );
|
||||
}
|
||||
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
|
||||
R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l ) const
|
||||
{
|
||||
typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I, J, K, L l );
|
||||
return R( reinterpret_cast< FunctionType* >( mFn )( mThis, a, b, c, d, e, f, g, h, i, j, k, l ) );
|
||||
return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i, j, k, l ) );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -2619,14 +2635,19 @@ struct _EngineConsoleCallbackHelper
|
|||
|
||||
SimObject* mThis;
|
||||
S32 mArgc;
|
||||
const char* mArgv[ MAX_ARGUMENTS + 2 ];
|
||||
ConsoleValueRef mArgv[ MAX_ARGUMENTS + 2 ];
|
||||
|
||||
const char* _exec()
|
||||
{
|
||||
if( mThis )
|
||||
{
|
||||
// Cannot invoke callback until object has been registered
|
||||
return mThis->isProperlyAdded() ? Con::execute( mThis, mArgc, mArgv ) : "";
|
||||
if (mThis->isProperlyAdded()) {
|
||||
return Con::execute( mThis, mArgc, mArgv );
|
||||
} else {
|
||||
Con::resetStackFrame(); // We might have pushed some vars here
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
return Con::execute( mArgc, mArgv );
|
||||
|
|
@ -2788,7 +2809,6 @@ struct _EngineConsoleCallbackHelper
|
|||
|
||||
|
||||
// Re-enable some VC warnings we disabled for this file.
|
||||
#pragma warning( default : 4510 )
|
||||
#pragma warning( default : 4610 )
|
||||
#pragma warning( pop ) // 4510 and 4610
|
||||
|
||||
#endif // !_ENGINEAPI_H_
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static void dumpVariable( Stream& stream,
|
|||
{
|
||||
// Skip variables defined in script.
|
||||
|
||||
if( entry->type < 0 )
|
||||
if( entry->value.type < 0 )
|
||||
return;
|
||||
|
||||
// Skip internals... don't export them.
|
||||
|
|
@ -149,7 +149,7 @@ static void dumpVariable( Stream& stream,
|
|||
|
||||
// Skip variables for which we can't decipher their type.
|
||||
|
||||
ConsoleBaseType* type = ConsoleBaseType::getType( entry->type );
|
||||
ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.type );
|
||||
if( !type )
|
||||
{
|
||||
Con::errorf( "Can't find type for variable '%s'", entry->name );
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList]
|
|||
}
|
||||
|
||||
// Fetch field list.
|
||||
const char* pFieldList = (argc > 3 ) ? argv[3] : NULL;
|
||||
const char* pFieldList = (argc > 3 ) ? (const char*)argv[3] : NULL;
|
||||
|
||||
// Copy Fields.
|
||||
object->copyFields( pSimObject, pFieldList );
|
||||
|
|
|
|||
|
|
@ -695,8 +695,9 @@ DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd )
|
|||
"@return String containing non-relative directory of path\n"
|
||||
"@ingroup FileSystem")
|
||||
{
|
||||
char *buf = Con::getReturnBuffer(512);
|
||||
Platform::makeFullPathName(path, buf, 512, dStrlen(cwd) > 1 ? cwd : NULL);
|
||||
static const U32 bufSize = 512;
|
||||
char *buf = Con::getReturnBuffer(bufSize);
|
||||
Platform::makeFullPathName(path, buf, bufSize, dStrlen(cwd) > 1 ? cwd : NULL);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -721,8 +722,9 @@ DefineEngineFunction(pathConcat, String, ( const char* path, const char* file),,
|
|||
"@return String containing concatenated file name and path\n"
|
||||
"@ingroup FileSystem")
|
||||
{
|
||||
char *buf = Con::getReturnBuffer(1024);
|
||||
Platform::makeFullPathName(file, buf, 1024, path);
|
||||
static const U32 bufSize = 1024;
|
||||
char *buf = Con::getReturnBuffer(bufSize);
|
||||
Platform::makeFullPathName(file, buf, bufSize, path);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2204,7 +2204,7 @@ ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [fi
|
|||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2213,7 +2213,7 @@ ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [fi
|
|||
|
||||
if( dirtyObject == Sim::getRootGroup() )
|
||||
{
|
||||
Con::errorf( "%s(): Cannot save RootGroup", argv[ 0 ] );
|
||||
Con::errorf( "%s(): Cannot save RootGroup", (const char*)argv[ 0 ] );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2234,7 +2234,7 @@ ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)"
|
|||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2251,7 +2251,7 @@ ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)"
|
|||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -2280,7 +2280,7 @@ ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )"
|
|||
const S32 index = dAtoi( argv[2] );
|
||||
if ( index < 0 || index >= object->getDirtyList().size() )
|
||||
{
|
||||
Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", argv[2] );
|
||||
Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", (const char*)argv[2] );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2333,7 +2333,7 @@ ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject obje
|
|||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -2358,7 +2358,7 @@ ConsoleMethod( PersistenceManager, removeObjectFromFile, void, 3, 4, "(SimObject
|
|||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2380,7 +2380,7 @@ ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object,
|
|||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2390,4 +2390,4 @@ ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object,
|
|||
if (argv[3][0])
|
||||
object->addRemoveField(dirtyObject, argv[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,8 +344,9 @@ ConsoleFunction(expandFilename, const char*, 2, 2, "(string filename)"
|
|||
"@ingroup FileSystem")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
char* ret = Con::getReturnBuffer( 1024 );
|
||||
Con::expandScriptFilename(ret, 1024, argv[1]);
|
||||
static const U32 bufSize = 1024;
|
||||
char* ret = Con::getReturnBuffer( bufSize );
|
||||
Con::expandScriptFilename(ret, bufSize, argv[1]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -355,8 +356,9 @@ ConsoleFunction(expandOldFilename, const char*, 2, 2, "(string filename)"
|
|||
"@ingroup FileSystem")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
char* ret = Con::getReturnBuffer( 1024 );
|
||||
Con::expandOldScriptFilename(ret, 1024, argv[1]);
|
||||
static const U32 bufSize = 1024;
|
||||
char* ret = Con::getReturnBuffer( bufSize );
|
||||
Con::expandOldScriptFilename(ret, bufSize, argv[1]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -368,8 +370,9 @@ ConsoleToolFunction(collapseFilename, const char*, 2, 2, "(string filename)"
|
|||
"@internal Editor use only")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
char* ret = Con::getReturnBuffer( 1024 );
|
||||
Con::collapseScriptFilename(ret, 1024, argv[1]);
|
||||
static const U32 bufSize = 1024;
|
||||
char* ret = Con::getReturnBuffer( bufSize );
|
||||
Con::collapseScriptFilename(ret, bufSize, argv[1]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,20 +138,20 @@ ConsoleDocFragment _spawnObject1(
|
|||
ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, properties, script])"
|
||||
"@hide")
|
||||
{
|
||||
String spawnClass(argv[1]);
|
||||
String spawnClass((const char*)argv[1]);
|
||||
String spawnDataBlock;
|
||||
String spawnName;
|
||||
String spawnProperties;
|
||||
String spawnScript;
|
||||
|
||||
if (argc >= 3)
|
||||
spawnDataBlock = argv[2];
|
||||
spawnDataBlock = (const char*)argv[2];
|
||||
if (argc >= 4)
|
||||
spawnName = argv[3];
|
||||
spawnName = (const char*)argv[3];
|
||||
if (argc >= 5)
|
||||
spawnProperties = argv[4];
|
||||
spawnProperties = (const char*)argv[4];
|
||||
if (argc >= 6)
|
||||
spawnScript = argv[5];
|
||||
spawnScript = (const char*)argv[5];
|
||||
|
||||
SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
#ifndef _MODULE_H_
|
||||
#include "core/module.h"
|
||||
#endif
|
||||
#ifndef _CONSOLE_H_
|
||||
#include "console/console.h"
|
||||
#endif
|
||||
|
||||
// Forward Refs
|
||||
class SimSet;
|
||||
|
|
@ -122,9 +125,15 @@ namespace Sim
|
|||
SimDataBlockGroup *getDataBlockGroup();
|
||||
SimGroup* getRootGroup();
|
||||
|
||||
SimObject* findObject(ConsoleValueRef&);
|
||||
SimObject* findObject(SimObjectId);
|
||||
SimObject* findObject(const char* name);
|
||||
SimObject* findObject(const char* fileName, S32 declarationLine);
|
||||
template<class T> inline bool findObject(ConsoleValueRef &ref,T*&t)
|
||||
{
|
||||
t = dynamic_cast<T*>(findObject(ref));
|
||||
return t != NULL;
|
||||
}
|
||||
template<class T> inline bool findObject(SimObjectId iD,T*&t)
|
||||
{
|
||||
t = dynamic_cast<T*>(findObject(iD));
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
extern S32 HashPointer(StringTableEntry e);
|
||||
extern U32 HashPointer(StringTableEntry e);
|
||||
|
||||
SimNameDictionary::SimNameDictionary()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,30 +28,28 @@
|
|||
// Stupid globals not declared in a header
|
||||
extern ExprEvalState gEvalState;
|
||||
|
||||
SimConsoleEvent::SimConsoleEvent(S32 argc, const char **argv, bool onObject)
|
||||
SimConsoleEvent::SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject)
|
||||
{
|
||||
mOnObject = onObject;
|
||||
mArgc = argc;
|
||||
U32 totalSize = 0;
|
||||
S32 i;
|
||||
for(i = 0; i < argc; i++)
|
||||
totalSize += dStrlen(argv[i]) + 1;
|
||||
totalSize += sizeof(char *) * argc;
|
||||
|
||||
mArgv = (char **) dMalloc(totalSize);
|
||||
char *argBase = (char *) &mArgv[argc];
|
||||
|
||||
for(i = 0; i < argc; i++)
|
||||
mArgv = new ConsoleValueRef[argc];
|
||||
for (int i=0; i<argc; i++)
|
||||
{
|
||||
mArgv[i] = argBase;
|
||||
dStrcpy(mArgv[i], argv[i]);
|
||||
argBase += dStrlen(argv[i]) + 1;
|
||||
mArgv[i].value = new ConsoleValue();
|
||||
mArgv[i].value->type = ConsoleValue::TypeInternalString;
|
||||
mArgv[i].value->init();
|
||||
mArgv[i].value->setStringValue((const char*)argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SimConsoleEvent::~SimConsoleEvent()
|
||||
{
|
||||
dFree(mArgv);
|
||||
for (int i=0; i<mArgc; i++)
|
||||
{
|
||||
delete mArgv[i].value;
|
||||
}
|
||||
delete[] mArgv;
|
||||
}
|
||||
|
||||
void SimConsoleEvent::process(SimObject* object)
|
||||
|
|
@ -60,12 +58,14 @@ void SimConsoleEvent::process(SimObject* object)
|
|||
// Con::printf("Executing schedule: %d", sequenceCount);
|
||||
// #endif
|
||||
if(mOnObject)
|
||||
Con::execute(object, mArgc, const_cast<const char**>( mArgv ));
|
||||
Con::execute(object, mArgc, mArgv );
|
||||
else
|
||||
{
|
||||
// Grab the function name. If '::' doesn't exist, then the schedule is
|
||||
// on a global function.
|
||||
char* func = dStrstr( mArgv[0], (char*)"::" );
|
||||
char funcName[256];
|
||||
dStrncpy(funcName, (const char*)mArgv[0], 256);
|
||||
char* func = dStrstr( funcName, (char*)"::" );
|
||||
if( func )
|
||||
{
|
||||
// Set the first colon to NULL, so we can reference the namespace.
|
||||
|
|
@ -77,18 +77,18 @@ void SimConsoleEvent::process(SimObject* object)
|
|||
func += 2;
|
||||
|
||||
// Lookup the namespace and function entry.
|
||||
Namespace* ns = Namespace::find( StringTable->insert( mArgv[0] ) );
|
||||
Namespace* ns = Namespace::find( StringTable->insert( funcName ) );
|
||||
if( ns )
|
||||
{
|
||||
Namespace::Entry* nse = ns->lookup( StringTable->insert( func ) );
|
||||
if( nse )
|
||||
// Execute.
|
||||
nse->execute( mArgc, (const char**)mArgv, &gEvalState );
|
||||
nse->execute( mArgc, mArgv, &gEvalState );
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
Con::execute(mArgc, const_cast<const char**>( mArgv ));
|
||||
Con::execute(mArgc, mArgv );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ const char *SimConsoleThreadExecCallback::waitForResult()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SimConsoleThreadExecEvent::SimConsoleThreadExecEvent(S32 argc, const char **argv, bool onObject, SimConsoleThreadExecCallback *callback) :
|
||||
SimConsoleThreadExecEvent::SimConsoleThreadExecEvent(S32 argc, ConsoleValueRef *argv, bool onObject, SimConsoleThreadExecCallback *callback) :
|
||||
SimConsoleEvent(argc, argv, onObject), cb(callback)
|
||||
{
|
||||
}
|
||||
|
|
@ -131,9 +131,9 @@ void SimConsoleThreadExecEvent::process(SimObject* object)
|
|||
{
|
||||
const char *retVal;
|
||||
if(mOnObject)
|
||||
retVal = Con::execute(object, mArgc, const_cast<const char**>( mArgv ));
|
||||
retVal = Con::execute(object, mArgc, mArgv);
|
||||
else
|
||||
retVal = Con::execute(mArgc, const_cast<const char**>( mArgv ));
|
||||
retVal = Con::execute(mArgc, mArgv);
|
||||
|
||||
if(cb)
|
||||
cb->handleCallback(retVal);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
// Forward Refs
|
||||
class SimObject;
|
||||
class Semaphore;
|
||||
class ConsoleValue;
|
||||
|
||||
/// Represents a queued event in the sim.
|
||||
///
|
||||
|
|
@ -82,6 +83,8 @@ public:
|
|||
virtual void process(SimObject *object)=0;
|
||||
};
|
||||
|
||||
class ConsoleValueRef;
|
||||
|
||||
/// Implementation of schedule() function.
|
||||
///
|
||||
/// This allows you to set a console function to be
|
||||
|
|
@ -90,7 +93,7 @@ class SimConsoleEvent : public SimEvent
|
|||
{
|
||||
protected:
|
||||
S32 mArgc;
|
||||
char **mArgv;
|
||||
ConsoleValueRef *mArgv;
|
||||
bool mOnObject;
|
||||
public:
|
||||
|
||||
|
|
@ -107,7 +110,7 @@ public:
|
|||
///
|
||||
/// @see Con::execute(S32 argc, const char *argv[])
|
||||
/// @see Con::execute(SimObject *object, S32 argc, const char *argv[])
|
||||
SimConsoleEvent(S32 argc, const char **argv, bool onObject);
|
||||
SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject);
|
||||
|
||||
~SimConsoleEvent();
|
||||
virtual void process(SimObject *object);
|
||||
|
|
@ -131,7 +134,7 @@ class SimConsoleThreadExecEvent : public SimConsoleEvent
|
|||
SimConsoleThreadExecCallback *cb;
|
||||
|
||||
public:
|
||||
SimConsoleThreadExecEvent(S32 argc, const char **argv, bool onObject, SimConsoleThreadExecCallback *callback);
|
||||
SimConsoleThreadExecEvent(S32 argc, ConsoleValueRef *argv, bool onObject, SimConsoleThreadExecCallback *callback);
|
||||
|
||||
virtual void process(SimObject *object);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -328,6 +328,11 @@ SimObject* findObject(const char* fileName, S32 declarationLine)
|
|||
return gRootGroup->findObjectByLineNumber(fileName, declarationLine, true);
|
||||
}
|
||||
|
||||
SimObject* findObject(ConsoleValueRef &ref)
|
||||
{
|
||||
return findObject((const char*)ref);
|
||||
}
|
||||
|
||||
SimObject* findObject(const char* name)
|
||||
{
|
||||
PROFILE_SCOPE(SimFindObject);
|
||||
|
|
@ -367,6 +372,8 @@ SimObject* findObject(const char* name)
|
|||
return NULL;
|
||||
return obj->findObject(temp);
|
||||
}
|
||||
else if (c < '0' || c > '9')
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
S32 len;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ SimObject::~SimObject()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SimObject::processArguments(S32 argc, const char**argv)
|
||||
bool SimObject::processArguments(S32 argc, ConsoleValueRef *argv)
|
||||
{
|
||||
return argc == 0;
|
||||
}
|
||||
|
|
@ -2680,11 +2680,12 @@ DefineConsoleMethod( SimObject, getDynamicField, const char*, ( S32 index ),,
|
|||
++itr;
|
||||
}
|
||||
|
||||
char* buffer = Con::getReturnBuffer(256);
|
||||
static const U32 bufSize = 256;
|
||||
char* buffer = Con::getReturnBuffer(bufSize);
|
||||
if (*itr)
|
||||
{
|
||||
SimFieldDictionary::Entry* entry = *itr;
|
||||
dSprintf(buffer, 256, "%s\t%s", entry->slotName, entry->value);
|
||||
dSprintf(buffer, bufSize, "%s\t%s", entry->slotName, entry->value);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ class SimObject: public ConsoleObject
|
|||
|
||||
virtual ~SimObject();
|
||||
|
||||
virtual bool processArguments(S32 argc, const char **argv); ///< Process constructor options. (ie, new SimObject(1,2,3))
|
||||
virtual bool processArguments(S32 argc, ConsoleValueRef *argv); ///< Process constructor options. (ie, new SimObject(1,2,3))
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ S32 QSORT_CALLBACK SimObjectList::_callbackSort( const void *a, const void *b )
|
|||
static char idB[64];
|
||||
dSprintf( idB, sizeof( idB ), "%d", objB->getId() );
|
||||
|
||||
return dAtoi( Con::executef( smSortScriptCallbackFn, idA, idB ) );
|
||||
return dAtoi( Con::executef( (const char*)smSortScriptCallbackFn, idA, idB ) );
|
||||
}
|
||||
|
||||
void SimObjectList::scriptSort( const String &scriptCallback )
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ SimPersistSet::SimPersistSet()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SimPersistSet::processArguments( S32 argc, const char** argv )
|
||||
bool SimPersistSet::processArguments( S32 argc, ConsoleValueRef *argv )
|
||||
{
|
||||
for( U32 i = 0; i < argc; ++ i )
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ bool SimPersistSet::processArguments( S32 argc, const char** argv )
|
|||
Torque::UUID uuid;
|
||||
if( !uuid.fromString( argv[ i ] ) )
|
||||
{
|
||||
Con::errorf( "SimPersistSet::processArguments - could not read UUID at index %i: %s", i, argv[ i ] );
|
||||
Con::errorf( "SimPersistSet::processArguments - could not read UUID at index %i: %s", i, (const char*)argv[ i ] );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class SimPersistSet : public SimSet
|
|||
// SimSet.
|
||||
virtual void addObject( SimObject* );
|
||||
virtual void write( Stream &stream, U32 tabStop, U32 flags = 0 );
|
||||
virtual bool processArguments( S32 argc, const char** argv );
|
||||
virtual bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
|
||||
DECLARE_CONOBJECT( SimPersistSet );
|
||||
DECLARE_CATEGORY( "Console" );
|
||||
|
|
|
|||
|
|
@ -228,11 +228,11 @@ void SimSet::scriptSort( const String &scriptCallbackFn )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SimSet::callOnChildren( const String &method, S32 argc, const char *argv[], bool executeOnChildGroups )
|
||||
void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups )
|
||||
{
|
||||
// Prep the arguments for the console exec...
|
||||
// Make sure and leave args[1] empty.
|
||||
const char* args[21];
|
||||
ConsoleValueRef args[21];
|
||||
args[0] = method.c_str();
|
||||
for (S32 i = 0; i < argc; i++)
|
||||
args[i + 2] = argv[i];
|
||||
|
|
@ -834,7 +834,7 @@ SimGroup* SimGroup::deepClone()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SimGroup::processArguments(S32, const char **)
|
||||
bool SimGroup::processArguments(S32, ConsoleValueRef *argv)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -909,7 +909,7 @@ ConsoleMethod( SimSet, add, void, 3, 0,
|
|||
if(obj)
|
||||
object->addObject( obj );
|
||||
else
|
||||
Con::printf("Set::add: Object \"%s\" doesn't exist", argv[ i ] );
|
||||
Con::printf("Set::add: Object \"%s\" doesn't exist", (const char*)argv[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -934,7 +934,7 @@ ConsoleMethod( SimSet, remove, void, 3, 0,
|
|||
if(obj && object->find(object->begin(),object->end(),obj) != object->end())
|
||||
object->removeObject(obj);
|
||||
else
|
||||
Con::printf("Set::remove: Object \"%s\" does not exist in set", argv[i]);
|
||||
Con::printf("Set::remove: Object \"%s\" does not exist in set", (const char*)argv[i]);
|
||||
object->unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -973,7 +973,7 @@ ConsoleMethod( SimSet, callOnChildren, void, 3, 0,
|
|||
"@note This method recurses into all SimSets that are children to the set.\n\n"
|
||||
"@see callOnChildrenNoRecurse" )
|
||||
{
|
||||
object->callOnChildren( argv[2], argc - 3, argv + 3 );
|
||||
object->callOnChildren( (const char*)argv[2], argc - 3, argv + 3 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -985,7 +985,7 @@ ConsoleMethod( SimSet, callOnChildrenNoRecurse, void, 3, 0,
|
|||
"@note This method does not recurse into child SimSets.\n\n"
|
||||
"@see callOnChildren" )
|
||||
{
|
||||
object->callOnChildren( argv[2], argc - 3, argv + 3, false );
|
||||
object->callOnChildren( (const char*)argv[2], argc - 3, argv + 3, false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1121,7 +1121,7 @@ DefineEngineMethod( SimSet, pushToBack, void, ( SimObject* obj ),,
|
|||
ConsoleMethod( SimSet, sort, void, 3, 3, "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n"
|
||||
"@param callbackFunction Name of a function that takes two object arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." )
|
||||
{
|
||||
object->scriptSort( argv[2] );
|
||||
object->scriptSort( (const char*)argv[2] );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class SimSet: public SimObject
|
|||
|
||||
/// @}
|
||||
|
||||
void callOnChildren( const String &method, S32 argc, const char *argv[], bool executeOnChildGroups = true );
|
||||
void callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups = true );
|
||||
|
||||
/// Return the number of objects in this set as well as all sets that are contained
|
||||
/// in this set and its children.
|
||||
|
|
@ -434,7 +434,7 @@ class SimGroup: public SimSet
|
|||
virtual SimObject* findObject(const char* name);
|
||||
virtual void onRemove();
|
||||
|
||||
virtual bool processArguments( S32 argc, const char** argv );
|
||||
virtual bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
|
||||
DECLARE_CONOBJECT( SimGroup );
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,22 +20,180 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include "console/consoleInternal.h"
|
||||
#include "console/stringStack.h"
|
||||
|
||||
void StringStack::getArgcArgv(StringTableEntry name, U32 *argc, const char ***in_argv, bool popStackFrame /* = false */)
|
||||
{
|
||||
U32 startStack = mFrameOffsets[mNumFrames-1] + 1;
|
||||
U32 argCount = getMin(mStartStackSize - startStack, (U32)MaxArgs - 1);
|
||||
|
||||
*in_argv = mArgV;
|
||||
mArgV[0] = name;
|
||||
void ConsoleValueStack::getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame /* = false */)
|
||||
{
|
||||
U32 startStack = mStackFrames[mFrame-1];
|
||||
U32 argCount = getMin(mStackPos - startStack, (U32)MaxArgs - 1);
|
||||
|
||||
*in_argv = mArgv;
|
||||
mArgv[0] = name;
|
||||
|
||||
for(U32 i = 0; i < argCount; i++)
|
||||
mArgV[i+1] = mBuffer + mStartOffsets[startStack + i];
|
||||
for(U32 i = 0; i < argCount; i++) {
|
||||
ConsoleValueRef *ref = &mArgv[i+1];
|
||||
ref->value = &mStack[startStack + i];
|
||||
ref->stringStackValue = NULL;
|
||||
}
|
||||
argCount++;
|
||||
|
||||
*argc = argCount;
|
||||
|
||||
if(popStackFrame)
|
||||
popFrame();
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleValueStack::ConsoleValueStack() :
|
||||
mFrame(0),
|
||||
mStackPos(0)
|
||||
{
|
||||
for (int i=0; i<ConsoleValueStack::MaxStackDepth; i++) {
|
||||
mStack[i].init();
|
||||
mStack[i].type = ConsoleValue::TypeInternalString;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleValueStack::~ConsoleValueStack()
|
||||
{
|
||||
}
|
||||
|
||||
void ConsoleValueStack::pushVar(ConsoleValue *variable)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (variable->type)
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
mStack[mStackPos++].setIntValue((S32)variable->getIntValue());
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue());
|
||||
default:
|
||||
mStack[mStackPos++].setStackStringValue(variable->getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleValueStack::pushValue(ConsoleValue &variable)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (variable.type)
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
mStack[mStackPos++].setIntValue((S32)variable.getIntValue());
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue());
|
||||
default:
|
||||
mStack[mStackPos++].setStringValue(variable.getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushString(const char *value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushString %s", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setStringValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushStackString(const char *value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushString %s", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setStackStringValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushUINT(U32 value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushUINT %i", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setIntValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushFLT(float value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushFLT %f", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setFloatValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
static ConsoleValue gNothing;
|
||||
|
||||
ConsoleValue* ConsoleValueStack::pop()
|
||||
{
|
||||
if (mStackPos == 0) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return &gNothing;
|
||||
}
|
||||
|
||||
return &mStack[--mStackPos];
|
||||
}
|
||||
|
||||
void ConsoleValueStack::pushFrame()
|
||||
{
|
||||
//Con::printf("CSTK pushFrame");
|
||||
mStackFrames[mFrame++] = mStackPos;
|
||||
}
|
||||
|
||||
void ConsoleValueStack::resetFrame()
|
||||
{
|
||||
if (mFrame == 0) {
|
||||
mStackPos = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 start = mStackFrames[mFrame-1];
|
||||
//for (U32 i=start; i<mStackPos; i++) {
|
||||
//mStack[i].clear();
|
||||
//}
|
||||
mStackPos = start;
|
||||
//Con::printf("CSTK resetFrame to %i", mStackPos);
|
||||
}
|
||||
|
||||
void ConsoleValueStack::popFrame()
|
||||
{
|
||||
//Con::printf("CSTK popFrame");
|
||||
if (mFrame == 0) {
|
||||
// Go back to start
|
||||
mStackPos = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 start = mStackFrames[mFrame-1];
|
||||
//for (U32 i=start; i<mStackPos; i++) {
|
||||
//mStack[i].clear();
|
||||
//}
|
||||
mStackPos = start;
|
||||
mFrame--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/// Core stack for interpreter operations.
|
||||
///
|
||||
/// This class provides some powerful semantics for working with strings, and is
|
||||
|
|
@ -185,6 +187,11 @@ struct StringStack
|
|||
return mBuffer + mStart;
|
||||
}
|
||||
|
||||
inline const char *getPreviousStringValue()
|
||||
{
|
||||
return mBuffer + mStartOffsets[mStartStackSize-1];
|
||||
}
|
||||
|
||||
/// Advance the start stack, placing a zero length string on the top.
|
||||
///
|
||||
/// @note You should use StringStack::push, not this, if you want to
|
||||
|
|
@ -275,4 +282,43 @@ struct StringStack
|
|||
void getArgcArgv(StringTableEntry name, U32 *argc, const char ***in_argv, bool popStackFrame = false);
|
||||
};
|
||||
|
||||
|
||||
// New console value stack
|
||||
class ConsoleValueStack
|
||||
{
|
||||
enum {
|
||||
MaxStackDepth = 1024,
|
||||
MaxArgs = 20,
|
||||
ReturnBufferSpace = 512
|
||||
};
|
||||
|
||||
public:
|
||||
ConsoleValueStack();
|
||||
~ConsoleValueStack();
|
||||
|
||||
void pushVar(ConsoleValue *variable);
|
||||
void pushValue(ConsoleValue &value);
|
||||
ConsoleValue* pop();
|
||||
|
||||
ConsoleValue *pushString(const char *value);
|
||||
ConsoleValue *pushStackString(const char *value);
|
||||
ConsoleValue *pushUINT(U32 value);
|
||||
ConsoleValue *pushFLT(float value);
|
||||
|
||||
void pushFrame();
|
||||
void popFrame();
|
||||
|
||||
void resetFrame();
|
||||
|
||||
void getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame = false);
|
||||
|
||||
ConsoleValue mStack[MaxStackDepth];
|
||||
U32 mStackFrames[MaxStackDepth];
|
||||
|
||||
U32 mFrame;
|
||||
U32 mStackPos;
|
||||
|
||||
ConsoleValueRef mArgv[MaxArgs];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public:
|
|||
|
||||
void breakProcess();
|
||||
|
||||
virtual void executionStopped(CodeBlock *code, U32 lineNumber);
|
||||
void executionStopped(CodeBlock *code, U32 lineNumber);
|
||||
void send(const char *s);
|
||||
void setDebugParameters(S32 port, const char *password, bool waitForClient);
|
||||
void processConsoleLine(const char *consoleLine);
|
||||
|
|
|
|||
108
Engine/source/console/test/runtimeClassRepTest.cpp
Normal file
108
Engine/source/console/test/runtimeClassRepTest.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "platform/platform.h"
|
||||
#include "console/simBase.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/runtimeClassRep.h"
|
||||
|
||||
class RuntimeRegisteredSimObject : public SimObject
|
||||
{
|
||||
typedef SimObject Parent;
|
||||
|
||||
protected:
|
||||
bool mFoo;
|
||||
|
||||
public:
|
||||
RuntimeRegisteredSimObject() : mFoo(false) {};
|
||||
|
||||
DECLARE_RUNTIME_CONOBJECT(RuntimeRegisteredSimObject);
|
||||
|
||||
static void initPersistFields();
|
||||
};
|
||||
|
||||
IMPLEMENT_RUNTIME_CONOBJECT(RuntimeRegisteredSimObject);
|
||||
|
||||
void RuntimeRegisteredSimObject::initPersistFields()
|
||||
{
|
||||
addField("fooField", TypeBool, Offset(mFoo, RuntimeRegisteredSimObject));
|
||||
}
|
||||
|
||||
TEST(Console, RuntimeClassRep)
|
||||
{
|
||||
// First test to make sure that the test class is not registered (don't
|
||||
// know how it could be, but that's programming for you). Stop the test if
|
||||
// it is.
|
||||
ASSERT_TRUE(!RuntimeRegisteredSimObject::dynRTClassRep.isRegistered())
|
||||
<< "RuntimeRegisteredSimObject class was already registered with the console";
|
||||
|
||||
// This should not be able to find the class, and return null (this may
|
||||
// AssertWarn as well).
|
||||
ConsoleObject *conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
|
||||
EXPECT_TRUE(conobj == NULL)
|
||||
<< "Unregistered AbstractClassRep returned non-NULL value! That is really bad!";
|
||||
|
||||
// Register with console system.
|
||||
RuntimeRegisteredSimObject::dynRTClassRep.consoleRegister();
|
||||
|
||||
// Make sure that the object knows it's registered.
|
||||
EXPECT_TRUE(RuntimeRegisteredSimObject::dynRTClassRep.isRegistered())
|
||||
<< "RuntimeRegisteredSimObject class failed console registration";
|
||||
|
||||
// Now try again to create the instance.
|
||||
conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
|
||||
EXPECT_TRUE(conobj != NULL)
|
||||
<< "AbstractClassRep::create method failed!";
|
||||
|
||||
// Cast the instance, and test it.
|
||||
RuntimeRegisteredSimObject *rtinst =
|
||||
dynamic_cast<RuntimeRegisteredSimObject *>(conobj);
|
||||
EXPECT_TRUE(rtinst != NULL)
|
||||
<< "Casting failed for some reason";
|
||||
|
||||
// Register it with a name.
|
||||
rtinst->registerObject("_utRRTestObject");
|
||||
EXPECT_TRUE(rtinst->isProperlyAdded())
|
||||
<< "registerObject failed on test object";
|
||||
|
||||
// Now execute some script on it.
|
||||
Con::evaluate("_utRRTestObject.fooField = true;");
|
||||
|
||||
// Test to make sure field worked.
|
||||
EXPECT_TRUE(dAtob(rtinst->getDataField(StringTable->insert("fooField"), NULL)))
|
||||
<< "Set property failed on instance.";
|
||||
|
||||
// BALETED
|
||||
rtinst->deleteObject();
|
||||
|
||||
// Unregister the type.
|
||||
RuntimeRegisteredSimObject::dynRTClassRep.consoleUnRegister();
|
||||
|
||||
// And make sure we can't create another one.
|
||||
conobj = ConsoleObject::create("RuntimeRegisteredSimObject");
|
||||
EXPECT_TRUE(conobj == NULL)
|
||||
<< "Unregistration of type failed";
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue