mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
substitution statements conformed to standard class:mVar standard
This commit is contained in:
parent
1c62080f7f
commit
3c97471630
2 changed files with 26 additions and 26 deletions
|
|
@ -62,20 +62,20 @@ SimDataBlock::SimDataBlock()
|
||||||
|
|
||||||
SimDataBlock::SubstitutionStatement::SubstitutionStatement(StringTableEntry slot, S32 idx, const char* value)
|
SimDataBlock::SubstitutionStatement::SubstitutionStatement(StringTableEntry slot, S32 idx, const char* value)
|
||||||
{
|
{
|
||||||
this->slot = slot;
|
this->mSlot = slot;
|
||||||
this->idx = idx;
|
this->mIdx = idx;
|
||||||
this->value = dStrdup(value);
|
this->mValue = dStrdup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimDataBlock::SubstitutionStatement::~SubstitutionStatement()
|
SimDataBlock::SubstitutionStatement::~SubstitutionStatement()
|
||||||
{
|
{
|
||||||
dFree(value);
|
dFree(mValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimDataBlock::SubstitutionStatement::replaceValue(const char* value)
|
void SimDataBlock::SubstitutionStatement::replaceValue(const char* value)
|
||||||
{
|
{
|
||||||
dFree(this->value);
|
dFree(this->mValue);
|
||||||
this->value = dStrdup(value);
|
this->mValue = dStrdup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the copy-constructor for creating temp-clones.
|
// this is the copy-constructor for creating temp-clones.
|
||||||
|
|
@ -109,7 +109,7 @@ void SimDataBlock::addSubstitution(StringTableEntry slot, S32 idx, const char* s
|
||||||
|
|
||||||
for (S32 i = 0; i < substitutions.size(); i++)
|
for (S32 i = 0; i < substitutions.size(); i++)
|
||||||
{
|
{
|
||||||
if (substitutions[i] && substitutions[i]->slot == slot && substitutions[i]->idx == idx)
|
if (substitutions[i] && substitutions[i]->mSlot == slot && substitutions[i]->mIdx == idx)
|
||||||
{
|
{
|
||||||
if (empty_subs)
|
if (empty_subs)
|
||||||
{
|
{
|
||||||
|
|
@ -137,8 +137,8 @@ const char* SimDataBlock::getSubstitution(StringTableEntry slot, S32 idx)
|
||||||
{
|
{
|
||||||
for (S32 i = 0; i < substitutions.size(); i++)
|
for (S32 i = 0; i < substitutions.size(); i++)
|
||||||
{
|
{
|
||||||
if (substitutions[i] && substitutions[i]->slot == slot && substitutions[i]->idx == idx)
|
if (substitutions[i] && substitutions[i]->mSlot == slot && substitutions[i]->mIdx == idx)
|
||||||
return substitutions[i]->value;
|
return substitutions[i]->mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -147,7 +147,7 @@ const char* SimDataBlock::getSubstitution(StringTableEntry slot, S32 idx)
|
||||||
bool SimDataBlock::fieldHasSubstitution(StringTableEntry slot)
|
bool SimDataBlock::fieldHasSubstitution(StringTableEntry slot)
|
||||||
{
|
{
|
||||||
for (S32 i = 0; i < substitutions.size(); i++)
|
for (S32 i = 0; i < substitutions.size(); i++)
|
||||||
if (substitutions[i] && substitutions[i]->slot == slot)
|
if (substitutions[i] && substitutions[i]->mSlot == slot)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +156,7 @@ void SimDataBlock::printSubstitutions()
|
||||||
{
|
{
|
||||||
for (S32 i = 0; i < substitutions.size(); i++)
|
for (S32 i = 0; i < substitutions.size(); i++)
|
||||||
if (substitutions[i])
|
if (substitutions[i])
|
||||||
Con::errorf("SubstitutionStatement[%s] = \"%s\" -- %d", substitutions[i]->slot, substitutions[i]->value, i);
|
Con::errorf("SubstitutionStatement[%s] = \"%s\" -- %d", substitutions[i]->mSlot, substitutions[i]->mValue, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimDataBlock::copySubstitutionsFrom(SimDataBlock* other)
|
void SimDataBlock::copySubstitutionsFrom(SimDataBlock* other)
|
||||||
|
|
@ -170,7 +170,7 @@ void SimDataBlock::copySubstitutionsFrom(SimDataBlock* other)
|
||||||
if (other->substitutions[i])
|
if (other->substitutions[i])
|
||||||
{
|
{
|
||||||
SubstitutionStatement* subs = other->substitutions[i];
|
SubstitutionStatement* subs = other->substitutions[i];
|
||||||
substitutions.push_back(new SubstitutionStatement(subs->slot, subs->idx, subs->value));
|
substitutions.push_back(new SubstitutionStatement(subs->mSlot, subs->mIdx, subs->mValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +212,7 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
||||||
char* b = buffer;
|
char* b = buffer;
|
||||||
|
|
||||||
// perform special token expansion (%% and ##)
|
// perform special token expansion (%% and ##)
|
||||||
const char* v = substitutions[i]->value;
|
const char* v = substitutions[i]->mValue;
|
||||||
while (*v != '\0')
|
while (*v != '\0')
|
||||||
{
|
{
|
||||||
// identify "%%" tokens and replace with <obj> id
|
// identify "%%" tokens and replace with <obj> id
|
||||||
|
|
@ -258,7 +258,7 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
||||||
if (Compiler::gSyntaxError)
|
if (Compiler::gSyntaxError)
|
||||||
{
|
{
|
||||||
Con::errorf("Field Substitution Failed: field=\"%s\" substitution=\"%s\" -- syntax error",
|
Con::errorf("Field Substitution Failed: field=\"%s\" substitution=\"%s\" -- syntax error",
|
||||||
substitutions[i]->slot, substitutions[i]->value);
|
substitutions[i]->mSlot, substitutions[i]->mValue);
|
||||||
Compiler::gSyntaxError = false;
|
Compiler::gSyntaxError = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +267,7 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
||||||
if (result == 0 || result[0] == '\0')
|
if (result == 0 || result[0] == '\0')
|
||||||
{
|
{
|
||||||
Con::errorf("Field Substitution Failed: field=\"%s\" substitution=\"%s\" -- empty result",
|
Con::errorf("Field Substitution Failed: field=\"%s\" substitution=\"%s\" -- empty result",
|
||||||
substitutions[i]->slot, substitutions[i]->value);
|
substitutions[i]->mSlot, substitutions[i]->mValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,29 +282,29 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
||||||
result = "";
|
result = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const AbstractClassRep::Field* field = dblock->getClassRep()->findField(substitutions[i]->slot);
|
const AbstractClassRep::Field* field = dblock->getClassRep()->findField(substitutions[i]->mSlot);
|
||||||
if (!field)
|
if (!field)
|
||||||
{
|
{
|
||||||
// this should be very unlikely...
|
// this should be very unlikely...
|
||||||
Con::errorf("Field Substitution Failed: unknown field, \"%s\".", substitutions[i]->slot);
|
Con::errorf("Field Substitution Failed: unknown field, \"%s\".", substitutions[i]->mSlot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field->keepClearSubsOnly && result[0] != '\0')
|
if (field->keepClearSubsOnly && result[0] != '\0')
|
||||||
{
|
{
|
||||||
Con::errorf("Field Substitution Failed: field \"%s\" of datablock %s only allows \"$$ ~~\" (keep) and \"$$ ~0\" (clear) field substitutions. [%s]",
|
Con::errorf("Field Substitution Failed: field \"%s\" of datablock %s only allows \"$$ ~~\" (keep) and \"$$ ~0\" (clear) field substitutions. [%s]",
|
||||||
substitutions[i]->slot, this->getClassName(), this->getName());
|
substitutions[i]->mSlot, this->getClassName(), this->getName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// substitute the field value with its replacement
|
// substitute the field value with its replacement
|
||||||
Con::setData(field->type, (void*)(((const char*)(dblock)) + field->offset), substitutions[i]->idx, 1, &result, field->table, field->flag);
|
Con::setData(field->type, (void*)(((const char*)(dblock)) + field->offset), substitutions[i]->mIdx, 1, &result, field->table, field->flag);
|
||||||
|
|
||||||
//dStrncpy(buffer, result, 255);
|
//dStrncpy(buffer, result, 255);
|
||||||
//Con::errorf("SUBSTITUTION %s.%s[%d] = %s idx=%s", Con::getIntArg(getId()), substitutions[i]->slot, substitutions[i]->idx, buffer, index_str);
|
//Con::errorf("SUBSTITUTION %s.%s[%d] = %s idx=%s", Con::getIntArg(getId()), substitutions[i]->slot, substitutions[i]->idx, buffer, index_str);
|
||||||
|
|
||||||
// notify subclasses of a field modification
|
// notify subclasses of a field modification
|
||||||
dblock->onStaticModified(substitutions[i]->slot);
|
dblock->onStaticModified(substitutions[i]->mSlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,9 +366,9 @@ void SimDataBlock::packData(BitStream* stream)
|
||||||
if (substitutions[i])
|
if (substitutions[i])
|
||||||
{
|
{
|
||||||
stream->writeFlag(true);
|
stream->writeFlag(true);
|
||||||
stream->writeString(substitutions[i]->slot);
|
stream->writeString(substitutions[i]->mSlot);
|
||||||
stream->write(substitutions[i]->idx);
|
stream->write(substitutions[i]->mIdx);
|
||||||
stream->writeString(substitutions[i]->value);
|
stream->writeString(substitutions[i]->mValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream->writeFlag(false);
|
stream->writeFlag(false);
|
||||||
|
|
|
||||||
|
|
@ -179,9 +179,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
struct SubstitutionStatement
|
struct SubstitutionStatement
|
||||||
{
|
{
|
||||||
StringTableEntry slot;
|
StringTableEntry mSlot;
|
||||||
S32 idx;
|
S32 mIdx;
|
||||||
char* value;
|
char* mValue;
|
||||||
SubstitutionStatement(StringTableEntry slot, S32 idx, const char* value);
|
SubstitutionStatement(StringTableEntry slot, S32 idx, const char* value);
|
||||||
~SubstitutionStatement();
|
~SubstitutionStatement();
|
||||||
void replaceValue(const char* value);
|
void replaceValue(const char* value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue