mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-14 01:40:50 +00:00
Merge remote-tracking branch 'refs/remotes/GarageGames/development' into ColorPickerAdvanced
This commit is contained in:
commit
2ff18cfc3f
629 changed files with 33887 additions and 3352 deletions
|
|
@ -103,7 +103,7 @@ S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void*
|
|||
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
||||
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
||||
|
||||
S32 result = dAtoi( Con::executef( (const char*)smCompareFunction, ea->value, eb->key ) );
|
||||
S32 result = dAtoi(Con::executef((const char*)smCompareFunction, ea->key, eb->key));
|
||||
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
||||
return ( smDecreasing ? -res : res );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,6 @@ void IfStmtNode::propagateSwitchExpr(ExprNode *left, bool string)
|
|||
|
||||
U32 IfStmtNode::compileStmt(CodeStream &codeStream, U32 ip)
|
||||
{
|
||||
U32 start = ip;
|
||||
U32 endifIp, elseIp;
|
||||
addBreakLine(codeStream);
|
||||
|
||||
|
|
@ -340,7 +339,6 @@ U32 LoopStmtNode::compileStmt(CodeStream &codeStream, U32 ip)
|
|||
addBreakLine(codeStream);
|
||||
codeStream.pushFixScope(true);
|
||||
|
||||
U32 start = ip;
|
||||
if(initExpr)
|
||||
ip = initExpr->compile(codeStream, ip, TypeReqNone);
|
||||
|
||||
|
|
@ -1565,8 +1563,6 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream &codeStream, U32 ip)
|
|||
|
||||
CodeBlock::smInFunction = false;
|
||||
|
||||
|
||||
U32 start = ip;
|
||||
codeStream.emit(OP_FUNC_DECL);
|
||||
codeStream.emitSTE(fnName);
|
||||
codeStream.emitSTE(nameSpace);
|
||||
|
|
|
|||
|
|
@ -209,6 +209,13 @@ namespace Con
|
|||
return ret;
|
||||
}
|
||||
|
||||
char* getBoolArg(bool arg)
|
||||
{
|
||||
char *ret = STR.getArgBuffer(32);
|
||||
dSprintf(ret, 32, "%d", arg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *getStringArg( const char *arg )
|
||||
{
|
||||
U32 len = dStrlen( arg ) + 1;
|
||||
|
|
@ -435,7 +442,8 @@ static void setFieldComponent( SimObject* object, StringTableEntry field, const
|
|||
|
||||
ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
|
||||
#ifdef TORQUE_VALIDATE_STACK
|
||||
U32 stackStart = STR.mStartStackSize;
|
||||
U32 consoleStackStart = CSTK.mStackPos;
|
||||
#endif
|
||||
|
|
@ -2245,9 +2253,9 @@ execFinished:
|
|||
|
||||
decRefCount();
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
//AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec");
|
||||
//AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec");
|
||||
#ifdef TORQUE_VALIDATE_STACK
|
||||
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 returnValue;
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ protected:
|
|||
U8 *data; ///< Allocated data (size is BlockSize)
|
||||
U32 size; ///< Bytes used in data
|
||||
CodeData *next; ///< Next block
|
||||
};
|
||||
} CodeData;
|
||||
|
||||
/// @name Emitted code
|
||||
/// {
|
||||
|
|
|
|||
|
|
@ -1566,6 +1566,494 @@ void popInstantGroup()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
typedef HashMap<StringTableEntry, StringTableEntry> typePathExpandoMap;
|
||||
static typePathExpandoMap PathExpandos;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void addPathExpando(const char* pExpandoName, const char* pPath)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pExpandoName != NULL, "Expando name cannot be NULL.");
|
||||
AssertFatal(pPath != NULL, "Expando path cannot be NULL.");
|
||||
|
||||
// Fetch expando name.
|
||||
StringTableEntry expandoName = StringTable->insert(pExpandoName);
|
||||
|
||||
// Fetch the length of the path.
|
||||
S32 pathLength = dStrlen(pPath);
|
||||
|
||||
char pathBuffer[1024];
|
||||
|
||||
// Sanity!
|
||||
if (pathLength == 0 || pathLength >= sizeof(pathBuffer))
|
||||
{
|
||||
Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
if (!Con::stripRepeatSlashes(pathBuffer, pPath, sizeof(pathBuffer)))
|
||||
{
|
||||
Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch new path length.
|
||||
pathLength = dStrlen(pathBuffer);
|
||||
|
||||
// Sanity!
|
||||
if (pathLength == 0)
|
||||
{
|
||||
Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove any terminating slash.
|
||||
if (pathBuffer[pathLength - 1] == '/')
|
||||
pathBuffer[pathLength - 1] = 0;
|
||||
|
||||
// Fetch expanded path.
|
||||
StringTableEntry expandedPath = StringTable->insert(pathBuffer);
|
||||
|
||||
// Info.
|
||||
#if defined(TORQUE_DEBUG)
|
||||
Con::printf("Adding path expando of '%s' as '%s'.", expandoName, expandedPath);
|
||||
#endif
|
||||
|
||||
// Find any existing path expando.
|
||||
typePathExpandoMap::iterator expandoItr = PathExpandos.find(pExpandoName);
|
||||
|
||||
// Does the expando exist?
|
||||
if (expandoItr != PathExpandos.end())
|
||||
{
|
||||
// Yes, so modify the path.
|
||||
expandoItr->value = expandedPath;
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert expando.
|
||||
PathExpandos.insert(expandoName, expandedPath);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry getPathExpando(const char* pExpandoName)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pExpandoName != NULL, "Expando name cannot be NULL.");
|
||||
|
||||
// Fetch expando name.
|
||||
StringTableEntry expandoName = StringTable->insert(pExpandoName);
|
||||
|
||||
// Find any existing path expando.
|
||||
typePathExpandoMap::iterator expandoItr = PathExpandos.find(expandoName);
|
||||
|
||||
// Does the expando exist?
|
||||
if (expandoItr != PathExpandos.end())
|
||||
{
|
||||
// Yes, so return it.
|
||||
return expandoItr->value;
|
||||
}
|
||||
|
||||
// Not found.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void removePathExpando(const char* pExpandoName)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pExpandoName != NULL, "Expando name cannot be NULL.");
|
||||
|
||||
// Fetch expando name.
|
||||
StringTableEntry expandoName = StringTable->insert(pExpandoName);
|
||||
|
||||
// Find any existing path expando.
|
||||
typePathExpandoMap::iterator expandoItr = PathExpandos.find(expandoName);
|
||||
|
||||
// Does the expando exist?
|
||||
if (expandoItr == PathExpandos.end())
|
||||
{
|
||||
// No, so warn.
|
||||
#if defined(TORQUE_DEBUG)
|
||||
Con::warnf("Removing path expando of '%s' but it does not exist.", expandoName);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Info.
|
||||
#if defined(TORQUE_DEBUG)
|
||||
Con::printf("Removing path expando of '%s' as '%s'.", expandoName, expandoItr->value);
|
||||
#endif
|
||||
// Remove expando.
|
||||
PathExpandos.erase(expandoItr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool isPathExpando(const char* pExpandoName)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pExpandoName != NULL, "Expando name cannot be NULL.");
|
||||
|
||||
// Fetch expando name.
|
||||
StringTableEntry expandoName = StringTable->insert(pExpandoName);
|
||||
|
||||
return PathExpandos.contains(expandoName);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
U32 getPathExpandoCount(void)
|
||||
{
|
||||
return PathExpandos.size();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry getPathExpandoKey(U32 expandoIndex)
|
||||
{
|
||||
// Finish if index is out of range.
|
||||
if (expandoIndex >= PathExpandos.size())
|
||||
return NULL;
|
||||
|
||||
// Find indexed iterator.
|
||||
typePathExpandoMap::iterator expandoItr = PathExpandos.begin();
|
||||
while (expandoIndex > 0) { ++expandoItr; --expandoIndex; }
|
||||
|
||||
return expandoItr->key;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry getPathExpandoValue(U32 expandoIndex)
|
||||
{
|
||||
// Finish if index is out of range.
|
||||
if (expandoIndex >= PathExpandos.size())
|
||||
return NULL;
|
||||
|
||||
// Find indexed iterator.
|
||||
typePathExpandoMap::iterator expandoItr = PathExpandos.begin();
|
||||
while (expandoIndex > 0) { ++expandoItr; --expandoIndex; }
|
||||
|
||||
return expandoItr->value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint, const bool ensureTrailingSlash)
|
||||
{
|
||||
char pathBuffer[2048];
|
||||
const char* pSrc = pSrcPath;
|
||||
char* pSlash;
|
||||
|
||||
// Fetch leading character.
|
||||
const char leadingToken = *pSrc;
|
||||
|
||||
// Fetch following token.
|
||||
const char followingToken = leadingToken != 0 ? pSrc[1] : 0;
|
||||
|
||||
// Expando.
|
||||
if (leadingToken == '^')
|
||||
{
|
||||
// Initial prefix search.
|
||||
const char* pPrefixSrc = pSrc + 1;
|
||||
char* pPrefixDst = pathBuffer;
|
||||
|
||||
// Search for end of expando.
|
||||
while (*pPrefixSrc != '/' && *pPrefixSrc != 0)
|
||||
{
|
||||
// Copy prefix character.
|
||||
*pPrefixDst++ = *pPrefixSrc++;
|
||||
}
|
||||
|
||||
// Yes, so terminate the expando string.
|
||||
*pPrefixDst = 0;
|
||||
|
||||
// Fetch the expando path.
|
||||
StringTableEntry expandoPath = getPathExpando(pathBuffer);
|
||||
|
||||
// Does the expando exist?
|
||||
if (expandoPath == NULL)
|
||||
{
|
||||
// No, so error.
|
||||
Con::errorf("expandPath() : Could not find path expando '%s' for path '%s'.", pathBuffer, pSrcPath);
|
||||
|
||||
// Are we ensuring the trailing slash?
|
||||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pDstPath, pSrcPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, so just use the source path.
|
||||
dStrcpy(pDstPath, pSrcPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skip the expando and the following slash.
|
||||
pSrc += dStrlen(pathBuffer) + 1;
|
||||
|
||||
// Format the output path.
|
||||
dSprintf(pathBuffer, sizeof(pathBuffer), "%s/%s", expandoPath, pSrc);
|
||||
|
||||
// Are we ensuring the trailing slash?
|
||||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer);
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
Con::stripRepeatSlashes(pDstPath, pathBuffer, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Script-Relative.
|
||||
if (leadingToken == '.')
|
||||
{
|
||||
// Fetch the code-block file-path.
|
||||
const StringTableEntry codeblockFullPath = CodeBlock::getCurrentCodeBlockFullPath();
|
||||
|
||||
// Do we have a code block full path?
|
||||
if (codeblockFullPath == NULL)
|
||||
{
|
||||
// No, so error.
|
||||
Con::errorf("expandPath() : Could not find relative path from code-block for path '%s'.", pSrcPath);
|
||||
|
||||
// Are we ensuring the trailing slash?
|
||||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pDstPath, pSrcPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, so just use the source path.
|
||||
dStrcpy(pDstPath, pSrcPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Yes, so use it as the prefix.
|
||||
dStrncpy(pathBuffer, codeblockFullPath, sizeof(pathBuffer) - 1);
|
||||
|
||||
// Find the final slash in the code-block.
|
||||
pSlash = dStrrchr(pathBuffer, '/');
|
||||
|
||||
// Is this a parent directory token?
|
||||
if (followingToken == '.')
|
||||
{
|
||||
// Yes, so terminate after the slash so we include it.
|
||||
pSlash[1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, it's a current directory token so terminate at the slash so we don't include it.
|
||||
pSlash[0] = 0;
|
||||
|
||||
// Skip the current directory token.
|
||||
pSrc++;
|
||||
}
|
||||
|
||||
// Format the output path.
|
||||
dStrncat(pathBuffer, "/", sizeof(pathBuffer) - 1 - strlen(pathBuffer));
|
||||
dStrncat(pathBuffer, pSrc, sizeof(pathBuffer) - 1 - strlen(pathBuffer));
|
||||
|
||||
// Are we ensuring the trailing slash?
|
||||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer);
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
Con::stripRepeatSlashes(pDstPath, pathBuffer, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// All else.
|
||||
|
||||
//Using a special case here because the code below barfs on trying to build a full path for apk reading
|
||||
#ifdef TORQUE_OS_ANDROID
|
||||
if (leadingToken == '/' || strstr(pSrcPath, "/") == NULL)
|
||||
Platform::makeFullPathName(pSrcPath, pathBuffer, sizeof(pathBuffer), pWorkingDirectoryHint);
|
||||
else
|
||||
dSprintf(pathBuffer, sizeof(pathBuffer), "/%s", pSrcPath);
|
||||
#else
|
||||
Platform::makeFullPathName(pSrcPath, pathBuffer, sizeof(pathBuffer), pWorkingDirectoryHint);
|
||||
#endif
|
||||
|
||||
// Are we ensuring the trailing slash?
|
||||
if (ensureTrailingSlash)
|
||||
{
|
||||
// Yes, so ensure it.
|
||||
Con::ensureTrailingSlash(pathBuffer, pathBuffer);
|
||||
}
|
||||
|
||||
// Strip repeat slashes.
|
||||
Con::stripRepeatSlashes(pDstPath, pathBuffer, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool isBasePath(const char* SrcPath, const char* pBasePath)
|
||||
{
|
||||
char expandBuffer[1024];
|
||||
Con::expandPath(expandBuffer, sizeof(expandBuffer), SrcPath);
|
||||
return dStrnicmp(pBasePath, expandBuffer, dStrlen(pBasePath)) == 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void collapsePath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint)
|
||||
{
|
||||
// Check path against expandos. If there are multiple matches, choose the
|
||||
// expando that produces the shortest relative path.
|
||||
|
||||
char pathBuffer[2048];
|
||||
|
||||
// Fetch expando count.
|
||||
const U32 expandoCount = getPathExpandoCount();
|
||||
|
||||
// Iterate expandos.
|
||||
U32 expandoRelativePathLength = U32_MAX;
|
||||
for (U32 expandoIndex = 0; expandoIndex < expandoCount; ++expandoIndex)
|
||||
{
|
||||
// Fetch expando value (path).
|
||||
StringTableEntry expandoValue = getPathExpandoValue(expandoIndex);
|
||||
|
||||
// Skip if not the base path.
|
||||
if (!isBasePath(pSrcPath, expandoValue))
|
||||
continue;
|
||||
|
||||
// Fetch path relative to expando path.
|
||||
StringTableEntry relativePath = Platform::makeRelativePathName(pSrcPath, expandoValue);
|
||||
|
||||
// If the relative path is simply a period
|
||||
if (relativePath[0] == '.')
|
||||
relativePath++;
|
||||
|
||||
if (dStrlen(relativePath) > expandoRelativePathLength)
|
||||
{
|
||||
// This expando covers less of the path than any previous one found.
|
||||
// We will keep the previous one.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Keep track of the relative path length
|
||||
expandoRelativePathLength = dStrlen(relativePath);
|
||||
|
||||
// Fetch expando key (name).
|
||||
StringTableEntry expandoName = getPathExpandoKey(expandoIndex);
|
||||
|
||||
// Format against expando.
|
||||
dSprintf(pathBuffer, sizeof(pathBuffer), "^%s/%s", expandoName, relativePath);
|
||||
}
|
||||
|
||||
// Check if we've found a suitable expando
|
||||
if (expandoRelativePathLength != U32_MAX)
|
||||
{
|
||||
// Strip repeat slashes.
|
||||
Con::stripRepeatSlashes(pDstPath, pathBuffer, size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the working directory.
|
||||
StringTableEntry workingDirectory = pWorkingDirectoryHint != NULL ? pWorkingDirectoryHint : Platform::getCurrentDirectory();
|
||||
|
||||
// Fetch path relative to current directory.
|
||||
StringTableEntry relativePath = Platform::makeRelativePathName(pSrcPath, workingDirectory);
|
||||
|
||||
// If the relative path is simply a period
|
||||
if (relativePath[0] == '.' && relativePath[1] != '.')
|
||||
relativePath++;
|
||||
|
||||
// Format against expando.
|
||||
dSprintf(pathBuffer, sizeof(pathBuffer), "%s/%s", workingDirectory, relativePath);
|
||||
|
||||
// Strip repeat slashes.
|
||||
Con::stripRepeatSlashes(pDstPath, pathBuffer, size);
|
||||
}
|
||||
|
||||
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath)
|
||||
{
|
||||
// Copy to target.
|
||||
dStrcpy(pDstPath, pSrcPath);
|
||||
|
||||
// Find trailing character index.
|
||||
S32 trailIndex = dStrlen(pDstPath);
|
||||
|
||||
// Ignore if empty string.
|
||||
if (trailIndex == 0)
|
||||
return;
|
||||
|
||||
// Finish if the trailing slash already exists.
|
||||
if (pDstPath[trailIndex - 1] == '/')
|
||||
return;
|
||||
|
||||
// Add trailing slash.
|
||||
pDstPath[trailIndex++] = '/';
|
||||
pDstPath[trailIndex] = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize)
|
||||
{
|
||||
// Note original destination.
|
||||
char* pOriginalDst = pDstPath;
|
||||
|
||||
// Reset last source character.
|
||||
char lastSrcChar = 0;
|
||||
|
||||
// Search source...
|
||||
while (dstSize > 0)
|
||||
{
|
||||
// Fetch characters.
|
||||
const char srcChar = *pSrcPath++;
|
||||
|
||||
// Do we have a repeat slash?
|
||||
if (srcChar == '/' && lastSrcChar == '/')
|
||||
{
|
||||
// Yes, so skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
// No, so copy character.
|
||||
*pDstPath++ = srcChar;
|
||||
|
||||
// Finish if end of source.
|
||||
if (srcChar == 0)
|
||||
return true;
|
||||
|
||||
// Reduce room left in destination.
|
||||
dstSize--;
|
||||
|
||||
// Set last character.
|
||||
lastSrcChar = srcChar;
|
||||
}
|
||||
|
||||
// Terminate the destination string as we ran out of room.
|
||||
*pOriginalDst = 0;
|
||||
|
||||
// Fail!
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end of Console namespace
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ public:
|
|||
|
||||
void cleanup()
|
||||
{
|
||||
if (bufferLen > 0)
|
||||
if ((type <= TypeInternalString) && (bufferLen > 0))
|
||||
{
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
|
|
@ -201,6 +201,8 @@ public:
|
|||
ival = 0;
|
||||
fval = 0;
|
||||
}
|
||||
ConsoleValue(){ init(); };
|
||||
~ConsoleValue(){ cleanup(); };
|
||||
};
|
||||
|
||||
// Proxy class for console variables
|
||||
|
|
@ -484,6 +486,20 @@ namespace Con
|
|||
bool expandToolScriptFilename(char *filename, U32 size, const char *src);
|
||||
bool collapseScriptFilename(char *filename, U32 size, const char *src);
|
||||
|
||||
bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint = NULL, const bool ensureTrailingSlash = false);
|
||||
void collapsePath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint = NULL);
|
||||
bool isBasePath(const char* SrcPath, const char* pBasePath);
|
||||
void ensureTrailingSlash(char* pDstPath, const char* pSrcPath);
|
||||
bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize);
|
||||
|
||||
void addPathExpando(const char* pExpandoName, const char* pPath);
|
||||
void removePathExpando(const char* pExpandoName);
|
||||
bool isPathExpando(const char* pExpandoName);
|
||||
StringTableEntry getPathExpando(const char* pExpandoName);
|
||||
U32 getPathExpandoCount(void);
|
||||
StringTableEntry getPathExpandoKey(U32 expandoIndex);
|
||||
StringTableEntry getPathExpandoValue(U32 expandoIndex);
|
||||
|
||||
bool isCurrentScriptToolScript();
|
||||
|
||||
StringTableEntry getModNameFromPath(const char *path);
|
||||
|
|
@ -737,6 +753,13 @@ namespace Con
|
|||
/// @see Con::errorf()
|
||||
void errorf(ConsoleLogEntry::Type type, const char *_format, ...);
|
||||
|
||||
//some additions from t2d
|
||||
/// Prints a separator to the console.
|
||||
inline void printSeparator(void) { printf("--------------------------------------------------------------------------------"); }
|
||||
|
||||
/// Prints a separator to the console.
|
||||
inline void printBlankLine(void) { printf(""); }
|
||||
|
||||
/// @}
|
||||
|
||||
/// Returns true when called from the main thread, false otherwise
|
||||
|
|
@ -813,6 +836,7 @@ namespace Con
|
|||
char* getArgBuffer(U32 bufferSize);
|
||||
char* getFloatArg(F64 arg);
|
||||
char* getIntArg (S32 arg);
|
||||
char* getBoolArg(bool arg);
|
||||
char* getStringArg( const char* arg );
|
||||
char* getStringArg( const String& arg );
|
||||
/// @}
|
||||
|
|
@ -1098,9 +1122,9 @@ struct ConsoleDocFragment
|
|||
static ConsoleDocFragment* smFirst;
|
||||
|
||||
ConsoleDocFragment( const char* text, const char* inClass = NULL, const char* definition = NULL )
|
||||
: mText( text ),
|
||||
mClass( inClass ),
|
||||
: mClass( inClass ),
|
||||
mDefinition( definition ),
|
||||
mText( text ),
|
||||
mNext( smFirst )
|
||||
{
|
||||
smFirst = this;
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@
|
|||
#include "math/mPoint3.h"
|
||||
#include "math/mathTypes.h"
|
||||
|
||||
#ifdef TORQUE_DEMO_PURCHASE
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#endif
|
||||
|
||||
// This is a temporary hack to get tools using the library to
|
||||
// link in this module which contains no other references.
|
||||
bool LinkConsoleFunctions = false;
|
||||
|
|
@ -483,7 +479,7 @@ DefineConsoleFunction( strreplace, const char*, ( const char* source, const char
|
|||
if(!scan)
|
||||
{
|
||||
dStrcpy(ret + dstp, source + scanp);
|
||||
break;
|
||||
return ret;
|
||||
}
|
||||
U32 len = scan - (source + scanp);
|
||||
dStrncpy(ret + dstp, source + scanp, len);
|
||||
|
|
@ -1681,6 +1677,7 @@ DefineEngineFunction( gotoWebPage, void, ( const char* address ),,
|
|||
DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/splash.bmp"),
|
||||
"Display a startup splash window suitable for showing while the engine still starts up.\n\n"
|
||||
"@note This is currently only implemented on Windows.\n\n"
|
||||
"@param path relative path to splash screen image to display.\n"
|
||||
"@return True if the splash window could be successfully initialized.\n\n"
|
||||
"@ingroup Platform" )
|
||||
{
|
||||
|
|
@ -2352,7 +2349,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
|
|||
"@endtsexample\n\n"
|
||||
"@ingroup Scripting")
|
||||
{
|
||||
if(dStrIsEmpty(varName))
|
||||
if(String::isEmpty(varName))
|
||||
{
|
||||
Con::errorf("isDefined() - did you forget to put quotes around the variable name?");
|
||||
return false;
|
||||
|
|
@ -2428,7 +2425,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
|
|||
{
|
||||
if (dStrlen(value) > 0)
|
||||
return true;
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
else if (!String::isEmpty(varValue))
|
||||
{
|
||||
obj->setDataField(valName, 0, varValue);
|
||||
}
|
||||
|
|
@ -2445,7 +2442,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
|
|||
|
||||
if (ent)
|
||||
return true;
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
else if (!String::isEmpty(varValue))
|
||||
{
|
||||
gEvalState.getCurrentFrame().setVariable(name, varValue);
|
||||
}
|
||||
|
|
@ -2460,7 +2457,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
|
|||
|
||||
if (ent)
|
||||
return true;
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
else if (!String::isEmpty(varValue))
|
||||
{
|
||||
gEvalState.globalVars.setVariable(name, varValue);
|
||||
}
|
||||
|
|
@ -2470,7 +2467,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
|
|||
// Is it an object?
|
||||
if (dStrcmp(varName, "0") && dStrcmp(varName, "") && (Sim::findObject(varName) != NULL))
|
||||
return true;
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
else if (!String::isEmpty(varValue))
|
||||
{
|
||||
Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, varValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,25 @@ bool AbstractClassRep::initialized = false;
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
AbstractClassRep* AbstractClassRep::findFieldRoot(StringTableEntry fieldName)
|
||||
{
|
||||
// Find the field.
|
||||
const Field* pField = findField(fieldName);
|
||||
|
||||
// Finish if not found.
|
||||
if (pField == NULL)
|
||||
return NULL;
|
||||
|
||||
// We're the root if we have no parent.
|
||||
if (getParentClass() == NULL)
|
||||
return this;
|
||||
|
||||
// Find the field root via the parent.
|
||||
AbstractClassRep* pFieldRoot = getParentClass()->findFieldRoot(fieldName);
|
||||
|
||||
// We're the root if the parent does not have it else return the field root.
|
||||
return pFieldRoot == NULL ? this : pFieldRoot;
|
||||
}
|
||||
|
||||
void AbstractClassRep::init()
|
||||
{
|
||||
|
|
@ -349,6 +367,7 @@ void ConsoleObject::addGroup(const char* in_pGroupname, const char* in_pGroupDoc
|
|||
f.validator = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
|
||||
// Add to field list.
|
||||
sg_tempFieldList.push_back(f);
|
||||
|
|
@ -371,6 +390,7 @@ void ConsoleObject::endGroup(const char* in_pGroupname)
|
|||
f.validator = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
f.elementCount = 0;
|
||||
|
||||
// Add to field list.
|
||||
|
|
@ -393,6 +413,7 @@ void ConsoleObject::addArray( const char *arrayName, S32 count )
|
|||
f.validator = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
|
||||
// Add to field list.
|
||||
sg_tempFieldList.push_back(f);
|
||||
|
|
@ -412,6 +433,7 @@ void ConsoleObject::endArray( const char *arrayName )
|
|||
f.validator = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
f.elementCount = 0;
|
||||
|
||||
// Add to field list.
|
||||
|
|
@ -433,13 +455,77 @@ void ConsoleObject::addField(const char* in_pFieldname,
|
|||
flags );
|
||||
}
|
||||
|
||||
void ConsoleObject::addField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
addField(
|
||||
in_pFieldname,
|
||||
in_fieldType,
|
||||
in_fieldOffset,
|
||||
in_writeDataFn,
|
||||
1,
|
||||
in_pFieldDocs,
|
||||
flags);
|
||||
}
|
||||
|
||||
void ConsoleObject::addField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
addField(in_pFieldname,
|
||||
in_fieldType,
|
||||
in_fieldOffset,
|
||||
&defaultProtectedWriteFn,
|
||||
in_elementCount,
|
||||
in_pFieldDocs,
|
||||
flags);
|
||||
}
|
||||
|
||||
void ConsoleObject::addField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
|
||||
if (in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
|
||||
f.type = in_fieldType;
|
||||
f.offset = in_fieldOffset;
|
||||
f.elementCount = in_elementCount;
|
||||
f.validator = NULL;
|
||||
f.flag = flags;
|
||||
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = in_writeDataFn;
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, "ConsoleObject::addField - invalid console type");
|
||||
f.table = conType->getEnumTable();
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
}
|
||||
|
||||
void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags )
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
addProtectedField(
|
||||
in_pFieldname,
|
||||
|
|
@ -447,67 +533,81 @@ void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
|||
in_fieldOffset,
|
||||
in_setDataFn,
|
||||
in_getDataFn,
|
||||
&defaultProtectedWriteFn,
|
||||
1,
|
||||
in_pFieldDocs,
|
||||
flags );
|
||||
}
|
||||
|
||||
|
||||
void ConsoleObject::addField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags )
|
||||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
|
||||
if(in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
|
||||
f.type = in_fieldType;
|
||||
f.offset = in_fieldOffset;
|
||||
f.elementCount = in_elementCount;
|
||||
f.validator = NULL;
|
||||
f.flag = flags;
|
||||
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType( in_fieldType );
|
||||
AssertFatal( conType, "ConsoleObject::addField - invalid console type" );
|
||||
f.table = conType->getEnumTable();
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
flags);
|
||||
}
|
||||
|
||||
void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags )
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
addProtectedField(
|
||||
in_pFieldname,
|
||||
in_fieldType,
|
||||
in_fieldOffset,
|
||||
in_setDataFn,
|
||||
in_getDataFn,
|
||||
in_writeDataFn,
|
||||
1,
|
||||
in_pFieldDocs,
|
||||
flags);
|
||||
}
|
||||
|
||||
void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
addProtectedField(
|
||||
in_pFieldname,
|
||||
in_fieldType,
|
||||
in_fieldOffset,
|
||||
in_setDataFn,
|
||||
in_getDataFn,
|
||||
&defaultProtectedWriteFn,
|
||||
in_elementCount,
|
||||
in_pFieldDocs,
|
||||
flags);
|
||||
}
|
||||
void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags)
|
||||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
|
||||
if(in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
if (in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
|
||||
f.type = in_fieldType;
|
||||
f.offset = in_fieldOffset;
|
||||
f.type = in_fieldType;
|
||||
f.offset = in_fieldOffset;
|
||||
f.elementCount = in_elementCount;
|
||||
f.validator = NULL;
|
||||
f.flag = flags;
|
||||
f.validator = NULL;
|
||||
f.flag = flags;
|
||||
|
||||
f.setDataFn = in_setDataFn;
|
||||
f.getDataFn = in_getDataFn;
|
||||
f.writeDataFn = in_writeDataFn;
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType( in_fieldType );
|
||||
AssertFatal( conType, "ConsoleObject::addProtectedField - invalid console type" );
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, "ConsoleObject::addProtectedField - invalid console type");
|
||||
f.table = conType->getEnumTable();
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
|
|
@ -529,6 +629,7 @@ void ConsoleObject::addFieldV(const char* in_pFieldname,
|
|||
f.table = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
f.validator = v;
|
||||
v->fieldIndex = sg_tempFieldList.size();
|
||||
|
||||
|
|
@ -546,6 +647,7 @@ void ConsoleObject::addDeprecatedField(const char *fieldName)
|
|||
f.validator = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
}
|
||||
|
|
@ -847,12 +949,13 @@ DefineEngineFunction(linkNamespaces, bool, ( String childNSName, String parentNS
|
|||
|
||||
Namespace *childNS = Namespace::find(childNSSTE);
|
||||
Namespace *parentNS = Namespace::find(parentNSSTE);
|
||||
Namespace *currentParent = childNS->getParent();
|
||||
|
||||
if (!childNS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Namespace *currentParent = childNS->getParent();
|
||||
|
||||
// Link to new NS if applicable
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@
|
|||
#ifndef _SIMOBJECTREF_H_
|
||||
#include "console/simObjectRef.h"
|
||||
#endif
|
||||
|
||||
#ifndef TINYXML_INCLUDED
|
||||
#include "tinyxml.h"
|
||||
#endif
|
||||
|
||||
/// @file
|
||||
/// Legacy console object system.
|
||||
|
|
@ -201,13 +203,16 @@ public:
|
|||
|
||||
typedef ConsoleBaseType Parent;
|
||||
|
||||
/// Allows the writing of a custom TAML schema.
|
||||
typedef void(*WriteCustomTamlSchema)(const AbstractClassRep* pClassRep, TiXmlElement* pParentElement);
|
||||
|
||||
/// @name 'Tructors
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// @param conIdPtr Pointer to the static S32 console ID.
|
||||
/// @param conTypeName Console type name.
|
||||
AbstractClassRep( S32* conIdPtr, const char* typeName )
|
||||
AbstractClassRep( S32* conIdPtr, const char* typeName )
|
||||
: Parent( sizeof( void* ), conIdPtr, typeName )
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION( mFieldList );
|
||||
|
|
@ -318,10 +323,13 @@ public:
|
|||
|
||||
/// Return the namespace that contains the methods of this class.
|
||||
Namespace* getNameSpace() const { return mNamespace; }
|
||||
|
||||
|
||||
/// Return the AbstractClassRep of the class that this class is derived from.
|
||||
AbstractClassRep* getParentClass() const { return parentClass; }
|
||||
|
||||
|
||||
virtual AbstractClassRep* getContainerChildClass(const bool recurse) = 0;
|
||||
virtual WriteCustomTamlSchema getCustomTamlSchema(void) = 0;
|
||||
|
||||
/// Return the size of instances of this class in bytes.
|
||||
S32 getSizeof() const { return mClassSizeof; }
|
||||
|
||||
|
|
@ -376,6 +384,8 @@ public:
|
|||
|
||||
virtual ConsoleObject* create () const = 0;
|
||||
|
||||
AbstractClassRep* findFieldRoot(StringTableEntry fieldName);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void init();
|
||||
|
|
@ -386,7 +396,7 @@ protected:
|
|||
Namespace * mNamespace;
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
bool mIsRenderEnabled;
|
||||
|
|
@ -394,23 +404,23 @@ public:
|
|||
|
||||
bool isRenderEnabled() const { return mIsRenderEnabled; }
|
||||
bool isSelectionEnabled() const { return mIsSelectionEnabled; }
|
||||
|
||||
|
||||
/// @name Categories
|
||||
/// @{
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
const char* mCategory;
|
||||
const char* mDescription;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/// Return the space separated category path for the class.
|
||||
const char* getCategory() const { return mCategory; }
|
||||
|
||||
|
||||
/// Return a short description string suitable for displaying in tooltips.
|
||||
const char* getDescription() const { return mDescription; }
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
/// @name Fields
|
||||
|
|
@ -421,12 +431,15 @@ public:
|
|||
typedef bool (*SetDataNotify)( void *obj, const char *array, const char *data );
|
||||
typedef const char *(*GetDataNotify)( void *obj, const char *data );
|
||||
|
||||
/// This is a function pointer typedef to support optional writing for fields.
|
||||
typedef bool(*WriteDataNotify)(void* obj, StringTableEntry pFieldName);
|
||||
|
||||
/// These are special field type values used to mark
|
||||
/// groups and arrays in the field list.
|
||||
/// @see Field::type
|
||||
/// @see addArray, endArray
|
||||
/// @see addGroup, endGroup
|
||||
/// @see addGroup, endGroup
|
||||
/// @see addGroup, endGroup
|
||||
/// @see addGroup, endGroup
|
||||
/// @see addDeprecatedField
|
||||
enum ACRFieldTypes
|
||||
{
|
||||
|
|
@ -434,35 +447,35 @@ public:
|
|||
/// types greater or equal to this one are not
|
||||
/// console data types.
|
||||
ARCFirstCustomField = 0xFFFFFFFB,
|
||||
|
||||
|
||||
/// Marks the start of a fixed size array of fields.
|
||||
/// @see addArray
|
||||
StartArrayFieldType = 0xFFFFFFFB,
|
||||
|
||||
|
||||
/// Marks the end of a fixed size array of fields.
|
||||
/// @see endArray
|
||||
EndArrayFieldType = 0xFFFFFFFC,
|
||||
|
||||
|
||||
/// Marks the beginning of a group of fields.
|
||||
/// @see addGroup
|
||||
StartGroupFieldType = 0xFFFFFFFD,
|
||||
|
||||
|
||||
/// Marks the beginning of a group of fields.
|
||||
/// @see endGroup
|
||||
EndGroupFieldType = 0xFFFFFFFE,
|
||||
|
||||
/// Marks a field that is depreciated and no
|
||||
|
||||
/// Marks a field that is depreciated and no
|
||||
/// longer stores a value.
|
||||
/// @see addDeprecatedField
|
||||
DeprecatedFieldType = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
|
||||
enum FieldFlags
|
||||
{
|
||||
FIELD_HideInInspectors = BIT( 0 ), ///< Do not show the field in inspectors.
|
||||
};
|
||||
|
||||
struct Field
|
||||
struct Field
|
||||
{
|
||||
Field()
|
||||
: pFieldname( NULL ),
|
||||
|
|
@ -494,6 +507,7 @@ public:
|
|||
TypeValidator *validator; ///< Validator, if any.
|
||||
SetDataNotify setDataFn; ///< Set data notify Fn
|
||||
GetDataNotify getDataFn; ///< Get data notify Fn
|
||||
WriteDataNotify writeDataFn; ///< Function to determine whether data should be written or not.
|
||||
};
|
||||
typedef Vector<Field> FieldList;
|
||||
|
||||
|
|
@ -507,10 +521,10 @@ public:
|
|||
|
||||
/// @name Console Type Interface
|
||||
/// @{
|
||||
|
||||
|
||||
virtual void* getNativeVariable() { return new ( AbstractClassRep* ); } // Any pointer-sized allocation will do.
|
||||
virtual void deleteNativeVariable( void* var ) { delete reinterpret_cast< AbstractClassRep** >( var ); }
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
/// @name Abstract Class Database
|
||||
|
|
@ -556,10 +570,10 @@ template< class T >
|
|||
class ConcreteClassRep : public AbstractClassRep
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static EnginePropertyTable _smPropertyTable;
|
||||
static EnginePropertyTable& smPropertyTable;
|
||||
|
||||
|
||||
ConcreteClassRep( const char* name,
|
||||
const char* conTypeName,
|
||||
S32* conTypeIdPtr,
|
||||
|
|
@ -573,10 +587,10 @@ class ConcreteClassRep : public AbstractClassRep
|
|||
mClassName = StringTable->insert( name );
|
||||
mCategory = T::__category();
|
||||
mTypeInfo = _MAPTYPE< T >();
|
||||
|
||||
|
||||
if( mTypeInfo )
|
||||
const_cast< EngineTypeInfo* >( mTypeInfo )->mPropertyTable = &smPropertyTable;
|
||||
|
||||
|
||||
if( &T::__description != parentDesc )
|
||||
mDescription = T::__description();
|
||||
|
||||
|
|
@ -595,6 +609,27 @@ class ConcreteClassRep : public AbstractClassRep
|
|||
registerClassRep(this);
|
||||
};
|
||||
|
||||
virtual AbstractClassRep* getContainerChildClass(const bool recurse)
|
||||
{
|
||||
// Fetch container children type.
|
||||
AbstractClassRep* pChildren = T::getContainerChildStaticClassRep();
|
||||
if (!recurse || pChildren != NULL)
|
||||
return pChildren;
|
||||
|
||||
// Fetch parent type.
|
||||
AbstractClassRep* pParent = T::getParentStaticClassRep();
|
||||
if (pParent == NULL)
|
||||
return NULL;
|
||||
|
||||
// Get parent container children.
|
||||
return pParent->getContainerChildClass(recurse);
|
||||
}
|
||||
|
||||
virtual WriteCustomTamlSchema getCustomTamlSchema(void)
|
||||
{
|
||||
return T::getStaticWriteCustomTamlSchema();
|
||||
}
|
||||
|
||||
/// Perform class specific initialization tasks.
|
||||
///
|
||||
/// Link namespaces, call initPersistFields() and consoleInit().
|
||||
|
|
@ -603,7 +638,7 @@ class ConcreteClassRep : public AbstractClassRep
|
|||
// Get handle to our parent class, if any, and ourselves (we are our parent's child).
|
||||
AbstractClassRep *parent = T::getParentStaticClassRep();
|
||||
AbstractClassRep *child = T::getStaticClassRep();
|
||||
|
||||
|
||||
// If we got reps, then link those namespaces! (To get proper inheritance.)
|
||||
if(parent && child)
|
||||
Con::classLinkNamespaces(parent->getNameSpace(), child->getNameSpace());
|
||||
|
|
@ -618,7 +653,7 @@ class ConcreteClassRep : public AbstractClassRep
|
|||
|
||||
/// Wrap constructor.
|
||||
ConsoleObject* create() const { return new T; }
|
||||
|
||||
|
||||
/// @name Console Type Interface
|
||||
/// @{
|
||||
|
||||
|
|
@ -632,16 +667,16 @@ class ConcreteClassRep : public AbstractClassRep
|
|||
else
|
||||
Con::errorf( "Cannot set multiple args to a single ConsoleObject*.");
|
||||
}
|
||||
|
||||
|
||||
virtual const char* getData( void* dptr, const EnumTable* tbl, BitSet32 flag )
|
||||
{
|
||||
T** obj = ( T** ) dptr;
|
||||
return Con::getReturnBuffer( T::__getObjectId( *obj ) );
|
||||
}
|
||||
|
||||
|
||||
virtual const char* getTypeClassName() { return mClassName; }
|
||||
virtual const bool isDatablock() { return T::__smIsDatablock; };
|
||||
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
||||
|
|
@ -652,7 +687,7 @@ template< typename T > EnginePropertyTable& ConcreteClassRep< T >::smPropertyTab
|
|||
//------------------------------------------------------------------------------
|
||||
// Forward declaration of this function so it can be used in the class
|
||||
const char *defaultProtectedGetFn( void *obj, const char *data );
|
||||
|
||||
bool defaultProtectedWriteFn(void* obj, StringTableEntry pFieldName);
|
||||
|
||||
//=============================================================================
|
||||
// ConsoleObject.
|
||||
|
|
@ -712,7 +747,7 @@ const char *defaultProtectedGetFn( void *obj, const char *data );
|
|||
class ConsoleObject : public EngineObject
|
||||
{
|
||||
DECLARE_ABSTRACT_CLASS( ConsoleObject, EngineObject );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/// @deprecated This is disallowed.
|
||||
|
|
@ -721,7 +756,7 @@ protected:
|
|||
public:
|
||||
|
||||
ConsoleObject() {}
|
||||
|
||||
|
||||
/// Get a reference to a field by name.
|
||||
const AbstractClassRep::Field *findField(StringTableEntry fieldName) const;
|
||||
|
||||
|
|
@ -730,7 +765,7 @@ public:
|
|||
|
||||
/// Set the value of a field.
|
||||
bool setField(const char *fieldName, const char *value);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/// @name Object Creation
|
||||
|
|
@ -760,11 +795,11 @@ public:
|
|||
static void endGroup(const char* in_pGroupname);
|
||||
|
||||
/// Marks the start of a fixed size array of fields.
|
||||
/// @see console_autodoc
|
||||
/// @see console_autodoc
|
||||
static void addArray( const char *arrayName, S32 count );
|
||||
|
||||
/// Marks the end of an array of fields.
|
||||
/// @see console_autodoc
|
||||
/// @see console_autodoc
|
||||
static void endArray( const char *arrayName );
|
||||
|
||||
/// Register a complex field.
|
||||
|
|
@ -781,6 +816,14 @@ public:
|
|||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0 );
|
||||
|
||||
static void addField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn,
|
||||
const U32 in_elementCount = 1,
|
||||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0);
|
||||
|
||||
/// Register a simple field.
|
||||
///
|
||||
/// @param in_pFieldname Name of the field.
|
||||
|
|
@ -793,6 +836,13 @@ public:
|
|||
const char* in_pFieldDocs,
|
||||
U32 flags = 0 );
|
||||
|
||||
static void addField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn,
|
||||
const char* in_pFieldDocs,
|
||||
U32 flags = 0);
|
||||
|
||||
/// Register a validated field.
|
||||
///
|
||||
/// A validated field is just like a normal field except that you can't
|
||||
|
|
@ -821,10 +871,20 @@ public:
|
|||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn,
|
||||
const U32 in_elementCount,
|
||||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0 );
|
||||
AbstractClassRep::GetDataNotify in_getDataFn = &defaultProtectedGetFn,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn = &defaultProtectedWriteFn,
|
||||
const U32 in_elementCount = 1,
|
||||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0);
|
||||
|
||||
static void addProtectedField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn = &defaultProtectedGetFn,
|
||||
const U32 in_elementCount = 1,
|
||||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0);
|
||||
|
||||
/// Register a simple protected field.
|
||||
///
|
||||
|
|
@ -839,8 +899,17 @@ public:
|
|||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn = &defaultProtectedGetFn,
|
||||
AbstractClassRep::WriteDataNotify in_writeDataFn = &defaultProtectedWriteFn,
|
||||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0 );
|
||||
U32 flags = 0);
|
||||
|
||||
static void addProtectedField(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
AbstractClassRep::SetDataNotify in_setDataFn,
|
||||
AbstractClassRep::GetDataNotify in_getDataFn = &defaultProtectedGetFn,
|
||||
const char* in_pFieldDocs = NULL,
|
||||
U32 flags = 0);
|
||||
|
||||
/// Add a deprecated field.
|
||||
///
|
||||
|
|
@ -855,16 +924,16 @@ public:
|
|||
static bool removeField(const char* in_pFieldname);
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
/// @name Logging
|
||||
/// @{
|
||||
|
||||
|
||||
/// Overload this in subclasses to change the message formatting.
|
||||
/// @param fmt A printf style format string.
|
||||
/// @param args A va_list containing the args passed ot a log function.
|
||||
/// @note It is suggested that you use String::VToString.
|
||||
virtual String _getLogMessage(const char* fmt, va_list args) const;
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
|
|
@ -873,16 +942,16 @@ public:
|
|||
/// These functions will try to print out a message along the lines
|
||||
/// of "ObjectClass - ObjectName(ObjectId) - formatted message"
|
||||
/// @{
|
||||
|
||||
|
||||
/// Logs with Con::printf.
|
||||
void logMessage(const char* fmt, ...) const;
|
||||
|
||||
|
||||
/// Logs with Con::warnf.
|
||||
void logWarning(const char* fmt, ...) const;
|
||||
|
||||
|
||||
/// Logs with Con::errorf.
|
||||
void logError(const char* fmt, ...) const;
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
/// Register dynamic fields in a subclass of ConsoleObject.
|
||||
|
|
@ -943,16 +1012,16 @@ public:
|
|||
|
||||
static const char* __category() { return ""; }
|
||||
static const char* __description() { return ""; }
|
||||
|
||||
|
||||
/// Subclasses of ConsoleObjects that are datablocks should redefine this static member variable
|
||||
/// and set it to true.
|
||||
static const bool __smIsDatablock = false;
|
||||
|
||||
|
||||
/// @name Object IDs and lookup.
|
||||
/// For a subclass hierarchy based on ConsoleObject to become functional for use as a console object type,
|
||||
/// the hierarchy must implement a naming scheme and indexing function for looking up objects by name.
|
||||
/// @{
|
||||
|
||||
|
||||
static ConsoleObject* __findObject( const char* ) { return NULL; }
|
||||
static const char* __getObjectId( ConsoleObject* ) { return ""; }
|
||||
};
|
||||
|
|
@ -1045,11 +1114,13 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
|
|||
static AbstractClassRep* getParentStaticClassRep(); \
|
||||
static AbstractClassRep* getStaticClassRep(); \
|
||||
static SimObjectRefConsoleBaseType< className > ptrRefType; \
|
||||
virtual AbstractClassRep* getClassRep() const
|
||||
|
||||
static AbstractClassRep::WriteCustomTamlSchema getStaticWriteCustomTamlSchema(); \
|
||||
static AbstractClassRep* getContainerChildStaticClassRep(); \
|
||||
virtual AbstractClassRep* getClassRep() const
|
||||
|
||||
#define DECLARE_CATEGORY( string ) \
|
||||
static const char* __category() { return string; }
|
||||
|
||||
|
||||
#define DECLARE_DESCRIPTION( string ) \
|
||||
static const char* __description() { return string; }
|
||||
|
||||
|
|
@ -1061,6 +1132,44 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
|
|||
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
|
||||
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
|
||||
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
|
||||
AbstractClassRep* className::getContainerChildStaticClassRep() { return NULL; } \
|
||||
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return NULL; } \
|
||||
ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description )
|
||||
|
||||
#define IMPLEMENT_CONOBJECT_CHILDREN( className ) \
|
||||
IMPLEMENT_CLASS( className, NULL ) \
|
||||
END_IMPLEMENT_CLASS; \
|
||||
S32 className::_smTypeId; \
|
||||
SimObjectRefConsoleBaseType< className > className::ptrRefType( "Type" #className "Ref" ); \
|
||||
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
|
||||
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
|
||||
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
|
||||
AbstractClassRep* className::getContainerChildStaticClassRep() { return Children::getStaticClassRep(); } \
|
||||
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return NULL; } \
|
||||
ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description )
|
||||
|
||||
#define IMPLEMENT_CONOBJECT_SCHEMA( className, schema ) \
|
||||
IMPLEMENT_CLASS( className, NULL ) \
|
||||
END_IMPLEMENT_CLASS; \
|
||||
S32 className::_smTypeId; \
|
||||
SimObjectRefConsoleBaseType< className > className::ptrRefType( "Type" #className "Ref" ); \
|
||||
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
|
||||
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
|
||||
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
|
||||
AbstractClassRep* className::getContainerChildStaticClassRep() { return NULL; } \
|
||||
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return schema; } \
|
||||
ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description )
|
||||
|
||||
#define IMPLEMENT_CONOBJECT_CHILDREN_SCHEMA( className, schema ) \
|
||||
IMPLEMENT_CLASS( className, NULL ) \
|
||||
END_IMPLEMENT_CLASS; \
|
||||
S32 className::_smTypeId; \
|
||||
SimObjectRefConsoleBaseType< className > className::ptrRefType( "Type" #className "Ref" ); \
|
||||
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
|
||||
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
|
||||
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
|
||||
AbstractClassRep* className::getContainerChildStaticClassRep() { return Children::getStaticClassRep(); } \
|
||||
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return schema; } \
|
||||
ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description )
|
||||
|
||||
#define IMPLEMENT_CO_NETOBJECT_V1( className ) \
|
||||
|
|
@ -1071,6 +1180,8 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
|
|||
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
|
||||
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
|
||||
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
|
||||
AbstractClassRep* className::getContainerChildStaticClassRep() { return NULL; } \
|
||||
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return NULL; } \
|
||||
ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, NetClassGroupGameMask, NetClassTypeObject, 0, className::getParentStaticClassRep(), &Parent::__description )
|
||||
|
||||
#define IMPLEMENT_CO_DATABLOCK_V1( className ) \
|
||||
|
|
@ -1081,8 +1192,10 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
|
|||
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
|
||||
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
|
||||
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
|
||||
AbstractClassRep* className::getContainerChildStaticClassRep() { return NULL; } \
|
||||
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return NULL; } \
|
||||
ConcreteClassRep<className> className::dynClassRep(#className, "Type" #className, &_smTypeId, NetClassGroupGameMask, NetClassTypeDataBlock, 0, className::getParentStaticClassRep(), &Parent::__description )
|
||||
|
||||
|
||||
// Support for adding properties to classes CONOBJECT style.
|
||||
#define PROPERTY_TABLE( className ) \
|
||||
namespace { namespace _ ## className { \
|
||||
|
|
@ -1092,13 +1205,13 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
|
|||
ConcreteClassRep< className >::smPropertyTable = _ ## className::_propTable; \
|
||||
namespace { namespace _ ## className { \
|
||||
EnginePropertyTable::Property _props[] = {
|
||||
|
||||
|
||||
#define END_PROPERTY_TABLE \
|
||||
{ NULL } \
|
||||
}; \
|
||||
EnginePropertyTable _propTable( sizeof( _props ) / sizeof( _props[ 0 ] ) - 1, _props ); \
|
||||
} }
|
||||
|
||||
|
||||
/// Add an auto-doc for a class.
|
||||
#define ConsoleDocClass( className, docString ) \
|
||||
CLASSDOC( className, docString )
|
||||
|
|
@ -1108,7 +1221,7 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
|
|||
//------------------------------------------------------------------------------
|
||||
// Protected field default get/set functions
|
||||
//
|
||||
// The reason for these functions is that it will save one branch per console
|
||||
// The reason for these functions is that it will save one branch per console
|
||||
// data request and script functions will still execute at the same speed as
|
||||
// before the modifications to allow protected static fields. These will just
|
||||
// inline and the code should be roughly the same size, and just as fast as
|
||||
|
|
@ -1133,6 +1246,21 @@ inline const char *emptyStringProtectedGetFn( void *obj, const char *data )
|
|||
return "";
|
||||
}
|
||||
|
||||
inline bool defaultProtectedWriteFn(void* obj, StringTableEntry pFieldName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool defaultProtectedNotSetFn(void* obj, const char *array, const char* data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool defaultProtectedNotWriteFn(void* obj, StringTableEntry pFieldName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
#endif //_CONSOLEOBJECT_H_
|
||||
|
|
|
|||
|
|
@ -50,24 +50,21 @@ bool addConsoleParser(char *ext, fnGetCurrentFile gcf, fnGetCurrentLine gcl, fnP
|
|||
AssertFatal(ext && gcf && gcl && p && r, "AddConsoleParser called with one or more NULL arguments");
|
||||
|
||||
ConsoleParser * pParser = new ConsoleParser;
|
||||
if(pParser != NULL)
|
||||
{
|
||||
pParser->ext = ext;
|
||||
pParser->getCurrentFile = gcf;
|
||||
pParser->getCurrentLine = gcl;
|
||||
pParser->parse = p;
|
||||
pParser->restart = r;
|
||||
pParser->setScanBuffer = ssb;
|
||||
|
||||
if(def)
|
||||
gDefaultParser = pParser;
|
||||
pParser->ext = ext;
|
||||
pParser->getCurrentFile = gcf;
|
||||
pParser->getCurrentLine = gcl;
|
||||
pParser->parse = p;
|
||||
pParser->restart = r;
|
||||
pParser->setScanBuffer = ssb;
|
||||
|
||||
pParser->next = gParserList;
|
||||
gParserList = pParser;
|
||||
if (def)
|
||||
gDefaultParser = pParser;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
pParser->next = gParserList;
|
||||
gParserList = pParser;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleParser * getParserForFile(const char *filename)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeString
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( string, TypeString, const char* )
|
||||
ConsoleType( string, TypeString, const char*, "" )
|
||||
ImplementConsoleTypeCasters( TypeString, const char* );
|
||||
|
||||
ConsoleGetType( TypeString )
|
||||
|
|
@ -53,7 +53,7 @@ ConsoleSetType( TypeString )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeCaseString
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( caseString, TypeCaseString, const char* )
|
||||
ConsoleType(caseString, TypeCaseString, const char*, "")
|
||||
|
||||
ConsoleSetType( TypeCaseString )
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ ConsoleGetType( TypeCaseString )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeRealString
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( string, TypeRealString, String )
|
||||
ConsoleType(string, TypeRealString, String, "")
|
||||
ImplementConsoleTypeCasters( TypeRealString, String )
|
||||
|
||||
ConsoleGetType( TypeRealString )
|
||||
|
|
@ -94,7 +94,7 @@ ConsoleSetType( TypeRealString )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeCommand
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( string, TypeCommand, String )
|
||||
ConsoleType(string, TypeCommand, String, "")
|
||||
|
||||
ConsoleGetType( TypeCommand )
|
||||
{
|
||||
|
|
@ -284,7 +284,7 @@ ConsoleProcessData( TypeShapeFilename )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeS8
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( char, TypeS8, S8 )
|
||||
ConsoleType(char, TypeS8, S8, "")
|
||||
ImplementConsoleTypeCasters( TypeS8, S8 )
|
||||
|
||||
ConsoleGetType( TypeS8 )
|
||||
|
|
@ -306,7 +306,7 @@ ConsoleSetType( TypeS8 )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeS32
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( int, TypeS32, S32 )
|
||||
ConsoleType(int, TypeS32, S32, "")
|
||||
ImplementConsoleTypeCasters(TypeS32, S32)
|
||||
|
||||
ConsoleGetType( TypeS32 )
|
||||
|
|
@ -329,7 +329,7 @@ ConsoleSetType( TypeS32 )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeS32Vector
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( intList, TypeS32Vector, Vector<S32> )
|
||||
ConsoleType(intList, TypeS32Vector, Vector<S32>, "")
|
||||
ImplementConsoleTypeCasters( TypeS32Vector, Vector< S32 > )
|
||||
|
||||
ConsoleGetType( TypeS32Vector )
|
||||
|
|
@ -386,7 +386,7 @@ ConsoleSetType( TypeS32Vector )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeF32
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( float, TypeF32, F32 )
|
||||
ConsoleType(float, TypeF32, F32, "")
|
||||
ImplementConsoleTypeCasters(TypeF32, F32)
|
||||
|
||||
ConsoleGetType( TypeF32 )
|
||||
|
|
@ -407,7 +407,7 @@ ConsoleSetType( TypeF32 )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeF32Vector
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( floatList, TypeF32Vector, Vector<F32> )
|
||||
ConsoleType(floatList, TypeF32Vector, Vector<F32>, "")
|
||||
ImplementConsoleTypeCasters( TypeF32Vector, Vector< F32 > )
|
||||
|
||||
ConsoleGetType( TypeF32Vector )
|
||||
|
|
@ -464,7 +464,7 @@ ConsoleSetType( TypeF32Vector )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeBool
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( bool, TypeBool, bool )
|
||||
ConsoleType(bool, TypeBool, bool, "")
|
||||
ImplementConsoleTypeCasters( TypeBool, bool )
|
||||
|
||||
ConsoleGetType( TypeBool )
|
||||
|
|
@ -484,7 +484,7 @@ ConsoleSetType( TypeBool )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeBoolVector
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( boolList, TypeBoolVector, Vector<bool> )
|
||||
ConsoleType(boolList, TypeBoolVector, Vector<bool>, "")
|
||||
ImplementConsoleTypeCasters( TypeBoolVector, Vector< bool > )
|
||||
|
||||
ConsoleGetType( TypeBoolVector )
|
||||
|
|
@ -541,7 +541,7 @@ ConsoleSetType( TypeBoolVector )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeFlag
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( flag, TypeFlag, S32 )
|
||||
ConsoleType(flag, TypeFlag, S32, "")
|
||||
|
||||
ConsoleGetType( TypeFlag )
|
||||
{
|
||||
|
|
@ -567,7 +567,7 @@ ConsoleSetType( TypeFlag )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeColorF
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( ColorF, TypeColorF, ColorF )
|
||||
ConsoleType(ColorF, TypeColorF, ColorF, "")
|
||||
ImplementConsoleTypeCasters( TypeColorF, ColorF )
|
||||
|
||||
ConsoleGetType( TypeColorF )
|
||||
|
|
@ -640,7 +640,7 @@ ConsoleSetType( TypeColorF )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeColorI
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( ColorI, TypeColorI, ColorI )
|
||||
ConsoleType(ColorI, TypeColorI, ColorI, "")
|
||||
ImplementConsoleTypeCasters( TypeColorI, ColorI )
|
||||
|
||||
ConsoleGetType( TypeColorI )
|
||||
|
|
@ -713,7 +713,7 @@ ConsoleSetType( TypeColorI )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeSimObjectName
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( SimObject, TypeSimObjectName, SimObject* )
|
||||
ConsoleType(SimObject, TypeSimObjectName, SimObject*, "")
|
||||
|
||||
ConsoleSetType( TypeSimObjectName )
|
||||
{
|
||||
|
|
@ -738,7 +738,7 @@ ConsoleGetType( TypeSimObjectName )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeName
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( string, TypeName, const char* )
|
||||
ConsoleType(string, TypeName, const char*, "")
|
||||
|
||||
ConsoleGetType( TypeName )
|
||||
{
|
||||
|
|
@ -753,7 +753,7 @@ ConsoleSetType( TypeName )
|
|||
//------------------------------------------------------------------------------
|
||||
// TypeParticleParameterString
|
||||
//------------------------------------------------------------------------------
|
||||
ConsoleType( string, TypeParticleParameterString, const char* )
|
||||
ConsoleType(string, TypeParticleParameterString, const char*, "")
|
||||
|
||||
ConsoleGetType( TypeParticleParameterString )
|
||||
{
|
||||
|
|
@ -772,7 +772,7 @@ ConsoleSetType( TypeParticleParameterString )
|
|||
// TypeMaterialName
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleType( string, TypeMaterialName, String )
|
||||
ConsoleType(string, TypeMaterialName, String, "")
|
||||
|
||||
ConsoleGetType( TypeMaterialName )
|
||||
{
|
||||
|
|
@ -794,7 +794,7 @@ ConsoleSetType( TypeMaterialName )
|
|||
// TypeTerrainMaterialIndex
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleType( int, TypeTerrainMaterialIndex, S32 )
|
||||
ConsoleType(int, TypeTerrainMaterialIndex, S32, "")
|
||||
|
||||
ConsoleGetType( TypeTerrainMaterialIndex )
|
||||
{
|
||||
|
|
@ -816,7 +816,7 @@ ConsoleSetType( TypeTerrainMaterialIndex )
|
|||
// TypeTerrainMaterialName
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleType( string, TypeTerrainMaterialName, const char* )
|
||||
ConsoleType(string, TypeTerrainMaterialName, const char*, "")
|
||||
|
||||
ConsoleGetType( TypeTerrainMaterialName )
|
||||
{
|
||||
|
|
@ -835,7 +835,7 @@ ConsoleSetType( TypeTerrainMaterialName )
|
|||
// TypeCubemapName
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleType( string, TypeCubemapName, String )
|
||||
ConsoleType(string, TypeCubemapName, String, "")
|
||||
|
||||
ConsoleGetType( TypeCubemapName )
|
||||
{
|
||||
|
|
@ -856,7 +856,7 @@ ConsoleSetType( TypeCubemapName )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeRectUV
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( RectF, TypeRectUV, RectF )
|
||||
ConsoleType(RectF, TypeRectUV, RectF, "")
|
||||
|
||||
ConsoleGetType( TypeRectUV )
|
||||
{
|
||||
|
|
@ -882,7 +882,7 @@ ConsoleSetType( TypeRectUV )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeUUID
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( uuid, TypeUUID, Torque::UUID )
|
||||
ConsoleType(uuid, TypeUUID, Torque::UUID, "")
|
||||
ImplementConsoleTypeCasters( TypeUUID, Torque::UUID )
|
||||
|
||||
ConsoleGetType( TypeUUID )
|
||||
|
|
@ -906,7 +906,7 @@ ConsoleSetType( TypeUUID )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypePID
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( pid, TypePID, SimPersistID* )
|
||||
ConsoleType(pid, TypePID, SimPersistID*, "")
|
||||
ImplementConsoleTypeCasters( TypePID, SimPersistID* )
|
||||
|
||||
ConsoleGetType( TypePID )
|
||||
|
|
@ -945,7 +945,7 @@ ConsoleSetType( TypePID )
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeSimPersistId
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType( SimPersistId, TypeSimPersistId, SimPersistID* )
|
||||
ConsoleType(SimPersistId, TypeSimPersistId, SimPersistID*, "")
|
||||
|
||||
ConsoleGetType( TypeSimPersistId )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,11 +48,7 @@
|
|||
/// @{
|
||||
|
||||
#ifndef Offset
|
||||
#if defined(TORQUE_COMPILER_GCC) && (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
|
||||
#define Offset(m,T) ((int)(&((T *)1)->m) - 1)
|
||||
#else
|
||||
#define Offset(x, cls) ((dsize_t)((const char *)&(((cls *)0)->x)-(const char *)0))
|
||||
#endif
|
||||
#define Offset(x, cls) offsetof(cls, x)
|
||||
#endif
|
||||
|
||||
class GFXShader;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@
|
|||
#include "console/engineTypeInfo.h"
|
||||
#endif
|
||||
|
||||
#ifndef _STRINGTABLE_H_
|
||||
#include "core/stringTable.h"
|
||||
#endif
|
||||
|
||||
/// @file
|
||||
/// Support for legacy TorqueScript console types.
|
||||
|
|
@ -151,6 +154,8 @@ class ConsoleBaseType
|
|||
virtual const bool isDatablock() { return false; };
|
||||
|
||||
virtual const char* prepData( const char* data, char* buffer, U32 bufferLen ) { return data; };
|
||||
|
||||
virtual StringTableEntry getTypePrefix(void) const { return StringTable->EmptyString(); }
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
|
@ -259,7 +264,7 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
|
|||
DefineConsoleType( type, nativeType ) \
|
||||
template<> inline const EngineTypeInfo* _MAPTYPE< nativeType >() { return NULL; }
|
||||
|
||||
#define ConsoleType( typeName, type, nativeType ) \
|
||||
#define ConsoleType( typeName, type, nativeType, typePrefix ) \
|
||||
S32 type; \
|
||||
class ConsoleType##type : public ConsoleBaseType \
|
||||
{ \
|
||||
|
|
@ -275,6 +280,7 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
|
|||
virtual const char *getTypeClassName() { return #typeName ; } \
|
||||
virtual void *getNativeVariable() { T* var = new T; return (void*)var; } \
|
||||
virtual void deleteNativeVariable(void* var) { T* nativeVar = reinterpret_cast<T*>(var); delete nativeVar; } \
|
||||
virtual StringTableEntry getTypePrefix( void ) const { return StringTable->insert( typePrefix ); } \
|
||||
}; \
|
||||
ConsoleType ## type gConsoleType ## type ## Instance;
|
||||
|
||||
|
|
@ -304,6 +310,9 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
|
|||
}; \
|
||||
ConsoleType ## type gConsoleType ## type ## Instance;
|
||||
|
||||
#define ConsoleTypeFieldPrefix( type, typePrefix ) \
|
||||
StringTableEntry ConsoleType##type::getTypePrefix( void ) const { return StringTable->insert( typePrefix ); }
|
||||
|
||||
#define ConsoleSetType( type ) \
|
||||
void ConsoleType##type::setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag)
|
||||
|
||||
|
|
@ -318,6 +327,10 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
|
|||
DECLARE_ENUM( type ); \
|
||||
DefineConsoleType( Type ## type, type );
|
||||
|
||||
#define DefineEnumType_R( type ) \
|
||||
DECLARE_ENUM_R( type ); \
|
||||
DefineConsoleType( Type ## type, type );
|
||||
|
||||
#define _ConsoleEnumType( typeName, type, nativeType ) \
|
||||
S32 type; \
|
||||
ImplementConsoleTypeCasters( type, nativeType ) \
|
||||
|
|
@ -347,6 +360,10 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
|
|||
DECLARE_BITFIELD( type ); \
|
||||
DefineConsoleType( Type ## type, type );
|
||||
|
||||
#define DefineBitfieldType_R( type ) \
|
||||
DECLARE_BITFIELD_R( type ); \
|
||||
DefineConsoleType( Type ## type, type );
|
||||
|
||||
#define _ConsoleBitfieldType( typeName, type, nativeType ) \
|
||||
S32 type; \
|
||||
ImplementConsoleTypeCasters( type, nativeType ) \
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ static bool dumpEngineDocs( const char *outputFile )
|
|||
// Dump pre-declarations for any groups we encountered
|
||||
// so that we don't have to explicitly define them.
|
||||
HashTable<String,U32>::Iterator iter = smDocGroups.begin();
|
||||
for ( ; iter != smDocGroups.end(); iter++ )
|
||||
for (; iter != smDocGroups.end(); ++iter)
|
||||
stream.writeText( String::ToString( "/*! @addtogroup %s */\r\n\r\n", iter->key.c_str() ) );
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,11 @@ struct EngineFunctionDefaultArguments
|
|||
|
||||
|
||||
// Need byte-aligned packing for the default argument structures.
|
||||
#ifdef _WIN64
|
||||
#pragma pack( push, 4 )
|
||||
#else
|
||||
#pragma pack( push, 1 )
|
||||
#endif
|
||||
|
||||
|
||||
// Structure encapsulating default arguments to an engine API function.
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@
|
|||
|
||||
|
||||
|
||||
DECLARE_PRIMITIVE( bool );
|
||||
DECLARE_PRIMITIVE( S8 );
|
||||
DECLARE_PRIMITIVE( U8 );
|
||||
DECLARE_PRIMITIVE( S32 );
|
||||
DECLARE_PRIMITIVE( U32 );
|
||||
DECLARE_PRIMITIVE( F32 );
|
||||
DECLARE_PRIMITIVE( F64 );
|
||||
DECLARE_PRIMITIVE( void* );
|
||||
DECLARE_PRIMITIVE_R( bool );
|
||||
DECLARE_PRIMITIVE_R(S8);
|
||||
DECLARE_PRIMITIVE_R(U8);
|
||||
DECLARE_PRIMITIVE_R(S32);
|
||||
DECLARE_PRIMITIVE_R(U32);
|
||||
DECLARE_PRIMITIVE_R(F32);
|
||||
DECLARE_PRIMITIVE_R(F64);
|
||||
DECLARE_PRIMITIVE_R(void*);
|
||||
|
||||
|
||||
//FIXME: this allows String to be used as a struct field type
|
||||
|
|
@ -52,7 +52,7 @@ DECLARE_PRIMITIVE( void* );
|
|||
// are considered to be owned by the API layer itself. The rule here is that such
|
||||
// a string is only valid until the next API call is made. Usually, control layers
|
||||
// will immediately copy and convert strings to their own string type.
|
||||
_DECLARE_TYPE( String );
|
||||
_DECLARE_TYPE_R(String);
|
||||
template<>
|
||||
struct EngineTypeTraits< String > : public _EnginePrimitiveTypeTraits< String >
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ class ColorI;
|
|||
class ColorF;
|
||||
|
||||
|
||||
DECLARE_STRUCT( Vector< bool > );
|
||||
DECLARE_STRUCT( Vector< S32 > );
|
||||
DECLARE_STRUCT( Vector< F32 > );
|
||||
DECLARE_STRUCT( Torque::UUID );
|
||||
DECLARE_STRUCT( ColorI );
|
||||
DECLARE_STRUCT( ColorF );
|
||||
DECLARE_STRUCT_R(Vector< bool >);
|
||||
DECLARE_STRUCT_R(Vector< S32 >);
|
||||
DECLARE_STRUCT_R(Vector< F32 >);
|
||||
DECLARE_STRUCT_R(Torque::UUID);
|
||||
DECLARE_STRUCT_R(ColorI);
|
||||
DECLARE_STRUCT_R(ColorF);
|
||||
|
||||
#endif // !_ENGINESTRUCTS_H_
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ enum EngineTypeKind
|
|||
EngineTypeKindClass ///< Pointer to opaque EngineObject.
|
||||
};
|
||||
|
||||
DECLARE_ENUM( EngineTypeKind );
|
||||
DECLARE_ENUM_R( EngineTypeKind );
|
||||
|
||||
/// Flags for an EngineTypeInfo.
|
||||
enum EngineTypeFlags
|
||||
|
|
@ -173,8 +173,8 @@ class EngineFieldTable
|
|||
/// Construct a field table from a NULL-terminated array of Field
|
||||
/// records.
|
||||
EngineFieldTable( const Field* fields )
|
||||
: mFields( fields ),
|
||||
mNumFields( 0 )
|
||||
: mNumFields( 0 ),
|
||||
mFields( fields )
|
||||
{
|
||||
while( fields[ mNumFields ].getName() )
|
||||
mNumFields ++;
|
||||
|
|
|
|||
|
|
@ -416,6 +416,16 @@ namespace _Private {
|
|||
|
||||
|
||||
#define _DECLARE_TYPE( type ) \
|
||||
template<> const EngineTypeInfo* TYPE< type >(); \
|
||||
template<> struct _SCOPE< type > { \
|
||||
EngineExportScope& operator()() const { \
|
||||
return *static_cast< EngineExportScope* >( \
|
||||
const_cast< EngineTypeInfo* >( ( TYPE< type >() ) ) \
|
||||
); \
|
||||
} \
|
||||
};
|
||||
|
||||
#define _DECLARE_TYPE_R( type ) \
|
||||
template<> const EngineTypeInfo* TYPE< type >(); \
|
||||
template<> struct _SCOPE< type > { \
|
||||
EngineExportScope& operator()() const { \
|
||||
|
|
@ -432,22 +442,42 @@ namespace _Private {
|
|||
_DECLARE_TYPE( type ) \
|
||||
template<> \
|
||||
struct EngineTypeTraits< type > : public _EnginePrimitiveTypeTraits< type > {};
|
||||
|
||||
#define _DECLARE_PRIMITIVE_R( type ) \
|
||||
_DECLARE_TYPE_R( type ) \
|
||||
template<> \
|
||||
struct EngineTypeTraits< type > : public _EnginePrimitiveTypeTraits< type > {};
|
||||
|
||||
#define _DECLARE_ENUM( type ) \
|
||||
_DECLARE_TYPE( type ) \
|
||||
template<> \
|
||||
struct _EngineTypeTraits< type > : public _EngineEnumTypeTraits< type > {};
|
||||
|
||||
|
||||
#define _DECLARE_ENUM_R( type ) \
|
||||
_DECLARE_TYPE_R( type ) \
|
||||
template<> \
|
||||
struct _EngineTypeTraits< type > : public _EngineEnumTypeTraits< type > {};
|
||||
|
||||
#define _DECLARE_BITFIELD( type ) \
|
||||
_DECLARE_TYPE( type ) \
|
||||
template<> \
|
||||
struct _EngineTypeTraits< type > : public _EngineBitfieldTypeTraits< type > {};
|
||||
|
||||
#define _DECLARE_BITFIELD_R( type ) \
|
||||
_DECLARE_TYPE_R( type ) \
|
||||
template<> \
|
||||
struct _EngineTypeTraits< type > : public _EngineBitfieldTypeTraits< type > {};
|
||||
|
||||
|
||||
#define _DECLARE_STRUCT( type ) \
|
||||
_DECLARE_TYPE( type ) \
|
||||
template<> \
|
||||
struct _EngineTypeTraits< type > : public _EngineStructTypeTraits< type > {};
|
||||
|
||||
#define _DECLARE_STRUCT_R( type ) \
|
||||
_DECLARE_TYPE_R( type ) \
|
||||
template<> \
|
||||
struct _EngineTypeTraits< type > : public _EngineStructTypeTraits< type > {};
|
||||
|
||||
#define _IMPLEMENT_TYPE( type, exportName ) \
|
||||
template<> \
|
||||
|
|
@ -524,6 +554,10 @@ namespace _Private {
|
|||
#define DECLARE_PRIMITIVE( type ) \
|
||||
_DECLARE_PRIMITIVE( type )
|
||||
|
||||
///
|
||||
#define DECLARE_PRIMITIVE_R( type ) \
|
||||
_DECLARE_PRIMITIVE_R( type )
|
||||
|
||||
///
|
||||
#define IMPLEMENT_PRIMITIVE( type, exportName, scope, doc ) \
|
||||
_IMPLEMENT_PRIMITIVE( type, exportName, scope, doc )
|
||||
|
|
@ -531,11 +565,19 @@ namespace _Private {
|
|||
///
|
||||
#define DECLARE_ENUM( type ) \
|
||||
_DECLARE_ENUM( type )
|
||||
|
||||
///
|
||||
#define DECLARE_ENUM_R( type ) \
|
||||
_DECLARE_ENUM_R( type )
|
||||
|
||||
///
|
||||
#define DECLARE_BITFIELD( type ) \
|
||||
_DECLARE_BITFIELD( type )
|
||||
|
||||
///
|
||||
#define DECLARE_BITFIELD_R( type ) \
|
||||
_DECLARE_BITFIELD_R( type )
|
||||
|
||||
///
|
||||
#define IMPLEMENT_ENUM( type, exportName, scope, doc ) \
|
||||
_IMPLEMENT_ENUM( type, exportName, scope, doc )
|
||||
|
|
@ -556,6 +598,10 @@ namespace _Private {
|
|||
#define DECLARE_STRUCT( type ) \
|
||||
_DECLARE_STRUCT( type )
|
||||
|
||||
///
|
||||
#define DECLARE_STRUCT_R( type ) \
|
||||
_DECLARE_STRUCT_R( type )
|
||||
|
||||
///
|
||||
#define IMPLEMENT_STRUCT( type, exportName, scope, doc ) \
|
||||
_IMPLEMENT_STRUCT( type, exportName, scope, doc )
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* sim
|
|||
const AbstractClassRep::FieldList& staticFields = pSimObject->getFieldList();
|
||||
|
||||
// Did we specify a groups list?
|
||||
if ( dStrIsEmpty(groupList) )
|
||||
if ( String::isEmpty(groupList) )
|
||||
{
|
||||
// No, so return all fields...
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ static S32 buildFileList(const char* pattern, bool recurse, bool multiMatch)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( findFirstFile, String, ( const char* pattern, bool recurse ), ( true ),
|
||||
DefineEngineFunction( findFirstFile, String, ( const char* pattern, bool recurse ), ( "", true ),
|
||||
"@brief Returns the first file in the directory system matching the given pattern.\n\n"
|
||||
|
||||
"Use the corresponding findNextFile() to step through "
|
||||
|
|
@ -209,7 +209,7 @@ DefineEngineFunction( findNextFile, String, ( const char* pattern ), ( "" ),
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( getFileCount, S32, ( const char* pattern, bool recurse ), ( true ),
|
||||
DefineEngineFunction( getFileCount, S32, ( const char* pattern, bool recurse ), ( "", true ),
|
||||
"@brief Returns the number of files in the directory tree that match the given patterns\n\n"
|
||||
|
||||
"This function differs from getFileCountMultiExpr() in that it supports a single search "
|
||||
|
|
@ -245,7 +245,7 @@ DefineEngineFunction( getFileCount, S32, ( const char* pattern, bool recurse ),
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool recurse ), (true),
|
||||
DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool recurse ), ( "", true),
|
||||
"@brief Returns the first file in the directory system matching the given patterns.\n\n"
|
||||
|
||||
"Use the corresponding findNextFileMultiExpr() to step through "
|
||||
|
|
@ -327,7 +327,7 @@ DefineEngineFunction(findNextFileMultiExpr, String, ( const char* pattern ), (""
|
|||
return sgFindFilesResults[sgFindFilesPos++];
|
||||
}
|
||||
|
||||
DefineEngineFunction(getFileCountMultiExpr, S32, ( const char* pattern, bool recurse ), (true),
|
||||
DefineEngineFunction(getFileCountMultiExpr, S32, ( const char* pattern, bool recurse ), ( "", true),
|
||||
"@brief Returns the number of files in the directory tree that match the given patterns\n\n"
|
||||
|
||||
"If you're interested in a list of files that match the given patterns and not just "
|
||||
|
|
@ -452,7 +452,7 @@ DefineEngineFunction(stopFileChangeNotifications, void, (),,
|
|||
}
|
||||
|
||||
|
||||
DefineEngineFunction(getDirectoryList, String, ( const char* path, S32 depth ), ( 0 ),
|
||||
DefineEngineFunction(getDirectoryList, String, ( const char* path, S32 depth ), ( "", 0 ),
|
||||
"@brief Gathers a list of directories starting at the given path.\n\n"
|
||||
|
||||
"@param path String containing the path of the directory\n"
|
||||
|
|
@ -686,7 +686,7 @@ DefineEngineFunction(getWorkingDirectory, String, (),,
|
|||
// are just string processing functions. They are needed by the 3D tools which
|
||||
// are not currently built with TORQUE_TOOLS defined.
|
||||
|
||||
DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd ), (""),
|
||||
DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd ), ( "", ""),
|
||||
"@brief Converts a relative file path to a full path\n\n"
|
||||
|
||||
"For example, \"./console.log\" becomes \"C:/Torque/t3d/examples/FPS Example/game/console.log\"\n"
|
||||
|
|
@ -701,7 +701,7 @@ DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd )
|
|||
return buf;
|
||||
}
|
||||
|
||||
DefineEngineFunction(makeRelativePath, String, ( const char* path, const char* to ), (""),
|
||||
DefineEngineFunction(makeRelativePath, String, ( const char* path, const char* to ), ( "", ""),
|
||||
"@brief Turns a full or local path to a relative one\n\n"
|
||||
|
||||
"For example, \"./game/art\" becomes \"game/art\"\n"
|
||||
|
|
@ -714,7 +714,7 @@ DefineEngineFunction(makeRelativePath, String, ( const char* path, const char* t
|
|||
return Platform::makeRelativePathName( path, dStrlen(to) > 1 ? to : NULL );
|
||||
}
|
||||
|
||||
DefineEngineFunction(pathConcat, String, ( const char* path, const char* file),,
|
||||
DefineEngineFunction(pathConcat, String, ( const char* path, const char* file), ( "", ""),
|
||||
"@brief Combines two separate strings containing a file path and file name together into a single string\n\n"
|
||||
|
||||
"@param path String containing file path\n"
|
||||
|
|
@ -783,7 +783,7 @@ DefineEngineFunction( openFile, void, ( const char* file ),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( pathCopy, bool, ( const char* fromFile, const char* toFile, bool noOverwrite ), ( true ),
|
||||
DefineEngineFunction( pathCopy, bool, ( const char* fromFile, const char* toFile, bool noOverwrite ), ( "", "", true ),
|
||||
"@brief Copy a file to a new location.\n"
|
||||
"@param fromFile %Path of the file to copy.\n"
|
||||
"@param toFile %Path where to copy @a fromFile to.\n"
|
||||
|
|
|
|||
|
|
@ -60,6 +60,27 @@ public:
|
|||
parentClass = parent;
|
||||
};
|
||||
|
||||
virtual AbstractClassRep* getContainerChildClass(const bool recurse)
|
||||
{
|
||||
// Fetch container children type.
|
||||
AbstractClassRep* pChildren = T::getContainerChildStaticClassRep();
|
||||
if (!recurse || pChildren != NULL)
|
||||
return pChildren;
|
||||
|
||||
// Fetch parent type.
|
||||
AbstractClassRep* pParent = T::getParentStaticClassRep();
|
||||
if (pParent == NULL)
|
||||
return NULL;
|
||||
|
||||
// Get parent container children.
|
||||
return pParent->getContainerChildClass(recurse);
|
||||
}
|
||||
|
||||
virtual WriteCustomTamlSchema getCustomTamlSchema(void)
|
||||
{
|
||||
return T::getStaticWriteCustomTamlSchema();
|
||||
}
|
||||
|
||||
/// Perform class specific initialization tasks.
|
||||
///
|
||||
/// Link namespaces, call initPersistFields() and consoleInit().
|
||||
|
|
|
|||
|
|
@ -230,6 +230,11 @@ bool expandOldScriptFilename(char *filename, U32 size, const char *src)
|
|||
else if (dStrncmp(src, "./", 2) == 0)
|
||||
// dot path means load from current codeblock/mod path
|
||||
slash = dStrrchr(cbName, '/');
|
||||
else if (dStrncmp(src, "^", 1) == 0)
|
||||
{
|
||||
Platform::makeFullPathName(src + 1, filename, size);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise path must be fully specified
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ typedef U32 SimObjectId;
|
|||
enum SimObjectsConstants
|
||||
{
|
||||
DataBlockObjectIdFirst = 3,
|
||||
DataBlockObjectIdBitSize = 10,
|
||||
DataBlockObjectIdBitSize = 14,
|
||||
DataBlockObjectIdLast = DataBlockObjectIdFirst + (1 << DataBlockObjectIdBitSize) - 1,
|
||||
|
||||
MessageObjectIdFirst = DataBlockObjectIdLast + 1,
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ public:
|
|||
Entry *next;
|
||||
ConsoleBaseType *type;
|
||||
};
|
||||
private:
|
||||
enum
|
||||
{
|
||||
HashTableSize = 19
|
||||
};
|
||||
Entry *mHashTable[HashTableSize];
|
||||
|
||||
private:
|
||||
static Entry *smFreeList;
|
||||
|
||||
void freeEntry(Entry *entry);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include "core/frameAllocator.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
#include "core/fileObject.h"
|
||||
|
||||
#include "persistence/taml/tamlCustom.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( SimObject );
|
||||
|
||||
|
|
@ -437,6 +437,97 @@ SimPersistID* SimObject::getOrCreatePersistentId()
|
|||
return mPersistentId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SimObject::onTamlCustomRead(TamlCustomNodes const& customNodes)
|
||||
{
|
||||
// Debug Profiling.
|
||||
//PROFILE_SCOPE(SimObject_OnTamlCustomRead);
|
||||
|
||||
// Fetch field list.
|
||||
const AbstractClassRep::FieldList& fieldList = getFieldList();
|
||||
const U32 fieldCount = fieldList.size();
|
||||
for (U32 index = 0; index < fieldCount; ++index)
|
||||
{
|
||||
// Fetch field.
|
||||
const AbstractClassRep::Field* pField = &fieldList[index];
|
||||
|
||||
// Ignore if field not appropriate.
|
||||
if (pField->type == AbstractClassRep::StartArrayFieldType || pField->elementCount > 1)
|
||||
{
|
||||
// Find cell custom node.
|
||||
const TamlCustomNode* pCustomCellNodes = NULL;
|
||||
if (pField->pGroupname != NULL)
|
||||
pCustomCellNodes = customNodes.findNode(pField->pGroupname);
|
||||
if (!pCustomCellNodes)
|
||||
{
|
||||
char* niceFieldName = const_cast<char *>(pField->pFieldname);
|
||||
niceFieldName[0] = dToupper(niceFieldName[0]);
|
||||
String str_niceFieldName = String(niceFieldName);
|
||||
pCustomCellNodes = customNodes.findNode(str_niceFieldName + "s");
|
||||
}
|
||||
|
||||
// Continue if we have explicit cells.
|
||||
if (pCustomCellNodes != NULL)
|
||||
{
|
||||
// Fetch children cell nodes.
|
||||
const TamlCustomNodeVector& cellNodes = pCustomCellNodes->getChildren();
|
||||
|
||||
U8 idx = 0;
|
||||
// Iterate cells.
|
||||
for (TamlCustomNodeVector::const_iterator cellNodeItr = cellNodes.begin(); cellNodeItr != cellNodes.end(); ++cellNodeItr)
|
||||
{
|
||||
char buf[5];
|
||||
dSprintf(buf, 5, "%d", idx);
|
||||
|
||||
// Fetch cell node.
|
||||
TamlCustomNode* pCellNode = *cellNodeItr;
|
||||
|
||||
// Fetch node name.
|
||||
StringTableEntry nodeName = pCellNode->getNodeName();
|
||||
|
||||
// Is this a valid alias?
|
||||
if (nodeName != pField->pFieldname)
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf("SimObject::onTamlCustomRead() - Encountered an unknown custom name of '%s'. Only '%s' is valid.", nodeName, pField->pFieldname);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch fields.
|
||||
const TamlCustomFieldVector& fields = pCellNode->getFields();
|
||||
|
||||
// Iterate property fields.
|
||||
for (TamlCustomFieldVector::const_iterator fieldItr = fields.begin(); fieldItr != fields.end(); ++fieldItr)
|
||||
{
|
||||
// Fetch field.
|
||||
const TamlCustomField* pField = *fieldItr;
|
||||
|
||||
// Fetch field name.
|
||||
StringTableEntry fieldName = pField->getFieldName();
|
||||
|
||||
const AbstractClassRep::Field* field = findField(fieldName);
|
||||
|
||||
// Check common fields.
|
||||
if (field)
|
||||
{
|
||||
setDataField(fieldName, buf, pField->getFieldValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unknown name so warn.
|
||||
Con::warnf("SimObject::onTamlCustomRead() - Encountered an unknown custom field name of '%s'.", fieldName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SimObject::_setPersistentID( void* object, const char* index, const char* data )
|
||||
|
|
@ -925,6 +1016,220 @@ const char *SimObject::getDataField(StringTableEntry slotName, const char *array
|
|||
return "";
|
||||
}
|
||||
|
||||
|
||||
const char *SimObject::getPrefixedDataField(StringTableEntry fieldName, const char *array)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(fieldName != NULL, "Cannot get field value with NULL field name.");
|
||||
|
||||
// Fetch field value.
|
||||
const char* pFieldValue = getDataField(fieldName, array);
|
||||
|
||||
// Sanity.
|
||||
//AssertFatal(pFieldValue != NULL, "Field value cannot be NULL.");
|
||||
if (!pFieldValue)
|
||||
return NULL;
|
||||
|
||||
// Return without the prefix if there's no value.
|
||||
if (*pFieldValue == 0)
|
||||
return StringTable->EmptyString();
|
||||
|
||||
// Fetch the field prefix.
|
||||
StringTableEntry fieldPrefix = getDataFieldPrefix(fieldName);
|
||||
|
||||
// Sanity!
|
||||
AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
|
||||
|
||||
// Calculate a buffer size including prefix.
|
||||
const U32 valueBufferSize = dStrlen(fieldPrefix) + dStrlen(pFieldValue) + 1;
|
||||
|
||||
// Fetch a buffer.
|
||||
char* pValueBuffer = Con::getReturnBuffer(valueBufferSize);
|
||||
|
||||
// Format the value buffer.
|
||||
dSprintf(pValueBuffer, valueBufferSize, "%s%s", fieldPrefix, pFieldValue);
|
||||
|
||||
return pValueBuffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SimObject::setPrefixedDataField(StringTableEntry fieldName, const char *array, const char *value)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(fieldName != NULL, "Cannot set object field value with NULL field name.");
|
||||
AssertFatal(value != NULL, "Field value cannot be NULL.");
|
||||
|
||||
// Set value without prefix if there's no value.
|
||||
if (*value == 0)
|
||||
{
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the field prefix.
|
||||
StringTableEntry fieldPrefix = getDataFieldPrefix(fieldName);
|
||||
|
||||
// Sanity.
|
||||
AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
|
||||
|
||||
// Do we have a field prefix?
|
||||
if (fieldPrefix == StringTable->EmptyString())
|
||||
{
|
||||
// No, so set the data field in the usual way.
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Yes, so fetch the length of the field prefix.
|
||||
const U32 fieldPrefixLength = dStrlen(fieldPrefix);
|
||||
|
||||
// Yes, so does it start with the object field prefix?
|
||||
if (dStrnicmp(value, fieldPrefix, fieldPrefixLength) != 0)
|
||||
{
|
||||
// No, so set the data field in the usual way.
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Yes, so set the data excluding the prefix.
|
||||
setDataField(fieldName, NULL, value + fieldPrefixLength);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const char *SimObject::getPrefixedDynamicDataField(StringTableEntry fieldName, const char *array, const S32 fieldType)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(fieldName != NULL, "Cannot get field value with NULL field name.");
|
||||
|
||||
// Fetch field value.
|
||||
const char* pFieldValue = getDataField(fieldName, array);
|
||||
|
||||
// Sanity.
|
||||
AssertFatal(pFieldValue != NULL, "Field value cannot be NULL.");
|
||||
|
||||
// Return the field if no field type is specified.
|
||||
if (fieldType == -1)
|
||||
return pFieldValue;
|
||||
|
||||
// Return without the prefix if there's no value.
|
||||
if (*pFieldValue == 0)
|
||||
return StringTable->EmptyString();
|
||||
|
||||
// Fetch the console base type.
|
||||
ConsoleBaseType* pConsoleBaseType = ConsoleBaseType::getType(fieldType);
|
||||
|
||||
// Did we find the console base type?
|
||||
if (pConsoleBaseType == NULL)
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf("getPrefixedDynamicDataField() - Invalid field type '%d' specified for field '%s' with value '%s'.",
|
||||
fieldType, fieldName, pFieldValue);
|
||||
}
|
||||
|
||||
// Fetch the field prefix.
|
||||
StringTableEntry fieldPrefix = pConsoleBaseType->getTypePrefix();
|
||||
|
||||
// Sanity!
|
||||
AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
|
||||
|
||||
// Calculate a buffer size including prefix.
|
||||
const U32 valueBufferSize = dStrlen(fieldPrefix) + dStrlen(pFieldValue) + 1;
|
||||
|
||||
// Fetch a buffer.
|
||||
char* pValueBuffer = Con::getReturnBuffer(valueBufferSize);
|
||||
|
||||
// Format the value buffer.
|
||||
dSprintf(pValueBuffer, valueBufferSize, "%s%s", fieldPrefix, pFieldValue);
|
||||
|
||||
return pValueBuffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SimObject::setPrefixedDynamicDataField(StringTableEntry fieldName, const char *array, const char *value, const S32 fieldType)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(fieldName != NULL, "Cannot set object field value with NULL field name.");
|
||||
AssertFatal(value != NULL, "Field value cannot be NULL.");
|
||||
|
||||
// Set value without prefix if no field type was specified.
|
||||
if (fieldType == -1)
|
||||
{
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the console base type.
|
||||
ConsoleBaseType* pConsoleBaseType = ConsoleBaseType::getType(fieldType);
|
||||
|
||||
// Did we find the console base type?
|
||||
if (pConsoleBaseType == NULL)
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf("setPrefixedDynamicDataField() - Invalid field type '%d' specified for field '%s' with value '%s'.",
|
||||
fieldType, fieldName, value);
|
||||
}
|
||||
|
||||
// Set value without prefix if there's no value or we didn't find the console base type.
|
||||
if (*value == 0 || pConsoleBaseType == NULL)
|
||||
{
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the field prefix.
|
||||
StringTableEntry fieldPrefix = pConsoleBaseType->getTypePrefix();
|
||||
|
||||
// Sanity.
|
||||
AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
|
||||
|
||||
// Do we have a field prefix?
|
||||
if (fieldPrefix == StringTable->EmptyString())
|
||||
{
|
||||
// No, so set the data field in the usual way.
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Yes, so fetch the length of the field prefix.
|
||||
const U32 fieldPrefixLength = dStrlen(fieldPrefix);
|
||||
|
||||
// Yes, so does it start with the object field prefix?
|
||||
if (dStrnicmp(value, fieldPrefix, fieldPrefixLength) != 0)
|
||||
{
|
||||
// No, so set the data field in the usual way.
|
||||
setDataField(fieldName, NULL, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Yes, so set the data excluding the prefix.
|
||||
setDataField(fieldName, NULL, value + fieldPrefixLength);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry SimObject::getDataFieldPrefix(StringTableEntry fieldName)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(fieldName != NULL, "Cannot get field prefix with NULL field name.");
|
||||
|
||||
// Find the field.
|
||||
const AbstractClassRep::Field* pField = findField(fieldName);
|
||||
|
||||
// Return nothing if field was not found.
|
||||
if (pField == NULL)
|
||||
return StringTable->EmptyString();
|
||||
|
||||
// Yes, so fetch the console base type.
|
||||
ConsoleBaseType* pConsoleBaseType = ConsoleBaseType::getType(pField->type);
|
||||
|
||||
// Fetch the type prefix.
|
||||
return pConsoleBaseType->getTypePrefix();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
U32 SimObject::getDataFieldType( StringTableEntry slotName, const char* array )
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
#include "core/bitSet.h"
|
||||
#endif
|
||||
|
||||
#ifndef _TAML_CALLBACKS_H_
|
||||
#include "persistence/taml/tamlCallbacks.h"
|
||||
#endif
|
||||
|
||||
class Stream;
|
||||
class LightManager;
|
||||
|
|
@ -226,7 +229,7 @@ class SimPersistID;
|
|||
/// set automatically by the console constructor code.
|
||||
///
|
||||
/// @nosubgrouping
|
||||
class SimObject: public ConsoleObject
|
||||
class SimObject: public ConsoleObject, public TamlCallbacks
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -298,6 +301,8 @@ class SimObject: public ConsoleObject
|
|||
/// Flags internal to the object management system.
|
||||
BitSet32 mFlags;
|
||||
|
||||
StringTableEntry mProgenitorFile;
|
||||
|
||||
/// Object we are copying fields from.
|
||||
SimObject* mCopySource;
|
||||
|
||||
|
|
@ -348,13 +353,42 @@ class SimObject: public ConsoleObject
|
|||
static bool setSuperClass(void *object, const char *index, const char *data)
|
||||
{ static_cast<SimObject*>(object)->setSuperClassNamespace(data); return false; };
|
||||
|
||||
static bool writeObjectName(void* obj, StringTableEntry pFieldName)
|
||||
{ SimObject* simObject = static_cast<SimObject*>(obj); return simObject->objectName != NULL && simObject->objectName != StringTable->EmptyString(); }
|
||||
static bool writeCanSaveDynamicFields(void* obj, StringTableEntry pFieldName)
|
||||
{ return static_cast<SimObject*>(obj)->mCanSaveFieldDictionary == false; }
|
||||
static bool writeInternalName(void* obj, StringTableEntry pFieldName)
|
||||
{ SimObject* simObject = static_cast<SimObject*>(obj); return simObject->mInternalName != NULL && simObject->mInternalName != StringTable->EmptyString(); }
|
||||
static bool setParentGroup(void* obj, const char* data);
|
||||
static bool writeParentGroup(void* obj, StringTableEntry pFieldName)
|
||||
{ return static_cast<SimObject*>(obj)->mGroup != NULL; }
|
||||
static bool writeSuperclass(void* obj, StringTableEntry pFieldName)
|
||||
{ SimObject* simObject = static_cast<SimObject*>(obj); return simObject->mSuperClassName != NULL && simObject->mSuperClassName != StringTable->EmptyString(); }
|
||||
static bool writeClass(void* obj, StringTableEntry pFieldName)
|
||||
{ SimObject* simObject = static_cast<SimObject*>(obj); return simObject->mClassName != NULL && simObject->mClassName != StringTable->EmptyString(); }
|
||||
static bool writeClassName(void* obj, StringTableEntry pFieldName)
|
||||
{ SimObject* simObject = static_cast<SimObject*>(obj); return simObject->mClassName != NULL && simObject->mClassName != StringTable->EmptyString(); }
|
||||
|
||||
|
||||
// Group hierarchy protected set method
|
||||
static bool setProtectedParent(void *object, const char *index, const char *data);
|
||||
|
||||
// Object name protected set method
|
||||
static bool setProtectedName(void *object, const char *index, const char *data);
|
||||
|
||||
public:
|
||||
inline void setProgenitorFile(const char* pFile) { mProgenitorFile = StringTable->insert(pFile); }
|
||||
inline StringTableEntry getProgenitorFile(void) const { return mProgenitorFile; }
|
||||
|
||||
protected:
|
||||
/// Taml callbacks.
|
||||
virtual void onTamlPreWrite(void) {}
|
||||
virtual void onTamlPostWrite(void) {}
|
||||
virtual void onTamlPreRead(void) {}
|
||||
virtual void onTamlPostRead(const TamlCustomNodes& customNodes) {}
|
||||
virtual void onTamlAddParent(SimObject* pParentObject) {}
|
||||
virtual void onTamlCustomWrite(TamlCustomNodes& customNodes) {}
|
||||
virtual void onTamlCustomRead(const TamlCustomNodes& customNodes);
|
||||
|
||||
/// Id number for this object.
|
||||
SimObjectId mId;
|
||||
|
|
@ -461,6 +495,16 @@ class SimObject: public ConsoleObject
|
|||
/// @param value Value to store.
|
||||
void setDataField(StringTableEntry slotName, const char *array, const char *value);
|
||||
|
||||
const char *getPrefixedDataField(StringTableEntry fieldName, const char *array);
|
||||
|
||||
void setPrefixedDataField(StringTableEntry fieldName, const char *array, const char *value);
|
||||
|
||||
const char *getPrefixedDynamicDataField(StringTableEntry fieldName, const char *array, const S32 fieldType = -1);
|
||||
|
||||
void setPrefixedDynamicDataField(StringTableEntry fieldName, const char *array, const char *value, const S32 fieldType = -1);
|
||||
|
||||
StringTableEntry getDataFieldPrefix(StringTableEntry fieldName);
|
||||
|
||||
/// Get the type of a field on the object.
|
||||
///
|
||||
/// @param slotName Field to access.
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ public:
|
|||
static S32 _smTypeId;
|
||||
|
||||
SimObjectRef()
|
||||
: mId( 0 ),
|
||||
mObject( NULL ),
|
||||
mName( "" )
|
||||
: mName( "" ),
|
||||
mId( 0 ),
|
||||
mObject( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -178,4 +178,4 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif // _SIMOBJECTREF_H_
|
||||
#endif // _SIMOBJECTREF_H_
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "core/util/tSignal.h"
|
||||
#endif
|
||||
|
||||
#include "persistence/taml/tamlChildren.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/// A set of SimObjects.
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
class SimSet: public SimObject
|
||||
class SimSet : public SimObject, public TamlChildren
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -152,8 +153,10 @@ class SimSet: public SimObject
|
|||
iterator end() { return objectList.end(); }
|
||||
value operator[] (S32 index) { return objectList[U32(index)]; }
|
||||
|
||||
iterator find( iterator first, iterator last, SimObject *obj)
|
||||
inline iterator find( iterator first, iterator last, SimObject *obj)
|
||||
{ return ::find(first, last, obj); }
|
||||
inline iterator find(SimObject *obj)
|
||||
{ return ::find(begin(), end(), obj); }
|
||||
|
||||
/// Reorder the position of "obj" to either be the last object in the list or, if
|
||||
/// "target" is given, to come before "target" in the list of children.
|
||||
|
|
@ -222,7 +225,7 @@ class SimSet: public SimObject
|
|||
/// @note The child sets themselves count towards the total too.
|
||||
U32 sizeRecursive();
|
||||
|
||||
SimObject* findObjectByInternalName(StringTableEntry internalName, bool searchChildren = false);
|
||||
virtual SimObject* findObjectByInternalName(StringTableEntry internalName, bool searchChildren = false);
|
||||
SimObject* findObjectByLineNumber(const char* fileName, S32 declarationLine, bool searchChildren = false);
|
||||
|
||||
/// Find the given object in this set. Returns NULL if the object
|
||||
|
|
@ -277,6 +280,32 @@ class SimSet: public SimObject
|
|||
virtual bool readObject(Stream *stream);
|
||||
|
||||
virtual SimSet* clone();
|
||||
|
||||
// TamlChildren
|
||||
virtual U32 getTamlChildCount(void) const
|
||||
{
|
||||
return (U32)size();
|
||||
}
|
||||
|
||||
virtual SimObject* getTamlChild(const U32 childIndex) const
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(childIndex < (U32)size(), "SimSet::getTamlChild() - Child index is out of range.");
|
||||
|
||||
// For when the assert is not used.
|
||||
if (childIndex >= (U32)size())
|
||||
return NULL;
|
||||
|
||||
return at(childIndex);
|
||||
}
|
||||
|
||||
virtual void addTamlChild(SimObject* pSimObject)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pSimObject != NULL, "SimSet::addTamlChild() - Cannot add a NULL child object.");
|
||||
|
||||
addObject(pSimObject);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef TORQUE_DEBUG_GUARD
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ void Point3NormalizeValidator::validateType(SimObject *object, void *typePtr)
|
|||
namespace CommonValidators
|
||||
{
|
||||
FRangeValidator PositiveFloat(0.0f, F32_MAX);
|
||||
FRangeValidator PositiveNonZeroFloat(F32( POINT_EPSILON ) , F32_MAX);
|
||||
FRangeValidator PositiveNonZeroFloat((F32)POINT_EPSILON, F32_MAX);
|
||||
FRangeValidator NormalizedFloat(0.0f, 1.0f);
|
||||
Point3NormalizeValidator NormalizedPoint3(1.0f);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue