mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
Restored explicit assignment operators for VMValue
Unfortunately strings require special handling and so all operators must be available This partly solves https://mantis.zdoom.org/view.php?id=453 (and https://mantis.zdoom.org/view.php?id=459 too)
This commit is contained in:
parent
fb48a1b776
commit
7aa6a6b0b3
1 changed files with 69 additions and 0 deletions
|
@ -481,6 +481,75 @@ struct VMValue
|
|||
atag = tag;
|
||||
Type = REGT_POINTER;
|
||||
}
|
||||
VMValue &operator=(const VMValue &o)
|
||||
{
|
||||
if (o.Type == REGT_STRING)
|
||||
{
|
||||
if (Type == REGT_STRING)
|
||||
{
|
||||
s() = o.s();
|
||||
}
|
||||
else
|
||||
{
|
||||
new(&s()) FString(o.s());
|
||||
Type = REGT_STRING;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Kill();
|
||||
biggest = o.biggest;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
VMValue &operator=(int v)
|
||||
{
|
||||
Kill();
|
||||
i = v;
|
||||
Type = REGT_INT;
|
||||
return *this;
|
||||
}
|
||||
VMValue &operator=(double v)
|
||||
{
|
||||
Kill();
|
||||
f = v;
|
||||
Type = REGT_FLOAT;
|
||||
return *this;
|
||||
}
|
||||
VMValue &operator=(const FString &v)
|
||||
{
|
||||
if (Type == REGT_STRING)
|
||||
{
|
||||
s() = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
::new(&s()) FString(v);
|
||||
Type = REGT_STRING;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
VMValue &operator=(const char *v)
|
||||
{
|
||||
if (Type == REGT_STRING)
|
||||
{
|
||||
s() = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
::new(&s()) FString(v);
|
||||
Type = REGT_STRING;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
VMValue &operator=(DObject *v)
|
||||
{
|
||||
Kill();
|
||||
a = v;
|
||||
atag = ATAG_OBJECT;
|
||||
Type = REGT_POINTER;
|
||||
return *this;
|
||||
}
|
||||
int ToInt()
|
||||
{
|
||||
if (Type == REGT_INT)
|
||||
|
|
Loading…
Reference in a new issue