mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 22:33:17 +00:00
- marked all places where an incomplete parameter list may be passed to the VM by a native call by redirecting VMCall to an intermediate VMCallWithDefaults. This function must later fill in the missing arguments from the default.
This commit is contained in:
parent
acbdfddb26
commit
c24da62cdd
6 changed files with 16 additions and 11 deletions
|
@ -175,13 +175,13 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info,
|
|||
|
||||
if (stateret == nullptr)
|
||||
{
|
||||
VMCall(ActionFunc, params, ActionFunc->ImplicitArgs, nullptr, 0);
|
||||
VMCallWithDefaults(ActionFunc, params, ActionFunc->ImplicitArgs, nullptr, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
VMReturn ret;
|
||||
ret.PointerAt((void **)stateret);
|
||||
VMCall(ActionFunc, params, ActionFunc->ImplicitArgs, &ret, 1);
|
||||
VMCallWithDefaults(ActionFunc, params, ActionFunc->ImplicitArgs, &ret, 1);
|
||||
}
|
||||
}
|
||||
catch (CVMAbortException &err)
|
||||
|
|
|
@ -1211,7 +1211,7 @@ DMenuItemBase * CreateOptionMenuItemSubmenu(const char *label, FName cmd, int ce
|
|||
auto c = PClass::FindClass("OptionMenuItemSubmenu");
|
||||
auto p = c->CreateNew();
|
||||
FString namestr = label;
|
||||
VMValue params[] = { p, &namestr, cmd.GetIndex(), center };
|
||||
VMValue params[] = { p, &namestr, cmd.GetIndex(), center, false };
|
||||
auto f = dyn_cast<PFunction>(c->FindSymbol("Init", false));
|
||||
VMCall(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||
return (DMenuItemBase*)p;
|
||||
|
@ -1233,7 +1233,7 @@ DMenuItemBase * CreateOptionMenuItemCommand(const char *label, FName cmd, bool c
|
|||
auto c = PClass::FindClass("OptionMenuItemCommand");
|
||||
auto p = c->CreateNew();
|
||||
FString namestr = label;
|
||||
VMValue params[] = { p, &namestr, cmd.GetIndex(), centered };
|
||||
VMValue params[] = { p, &namestr, cmd.GetIndex(), centered, false };
|
||||
auto f = dyn_cast<PFunction>(c->FindSymbol("Init", false));
|
||||
VMCall(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||
auto unsafe = dyn_cast<PField>(c->FindSymbol("mUnsafe", false));
|
||||
|
|
|
@ -477,7 +477,7 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
|
|||
}
|
||||
DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew();
|
||||
params[0] = item;
|
||||
VMCall(func->Variants[0].Implementation, ¶ms[0], params.Size(), nullptr, 0);
|
||||
VMCallWithDefaults(func->Variants[0].Implementation, ¶ms[0], params.Size(), nullptr, 0);
|
||||
desc->mItems.Push((DMenuItemBase*)item);
|
||||
|
||||
if (cls->IsDescendantOf("ListMenuItemSelectable"))
|
||||
|
@ -917,7 +917,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
|
|||
|
||||
DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew();
|
||||
params[0] = item;
|
||||
VMCall(func->Variants[0].Implementation, ¶ms[0], params.Size(), nullptr, 0);
|
||||
VMCallWithDefaults(func->Variants[0].Implementation, ¶ms[0], params.Size(), nullptr, 0);
|
||||
desc->mItems.Push((DMenuItemBase*)item);
|
||||
|
||||
success = true;
|
||||
|
|
|
@ -5448,7 +5448,7 @@ static int ScriptCall(AActor *activator, unsigned argc, int32_t *args)
|
|||
// The return value can be the same types as the parameter types, plus void
|
||||
if (func->Proto->ReturnTypes.Size() == 0)
|
||||
{
|
||||
VMCall(func, ¶ms[0], params.Size(), nullptr, 0);
|
||||
VMCallWithDefaults(func, ¶ms[0], params.Size(), nullptr, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5470,20 +5470,20 @@ static int ScriptCall(AActor *activator, unsigned argc, int32_t *args)
|
|||
{
|
||||
double d;
|
||||
VMReturn ret(&d);
|
||||
VMCall(func, ¶ms[0], params.Size(), &ret, 1);
|
||||
VMCallWithDefaults(func, ¶ms[0], params.Size(), &ret, 1);
|
||||
retval = DoubleToACS(d);
|
||||
}
|
||||
else if (rettype == TypeString)
|
||||
{
|
||||
FString d;
|
||||
VMReturn ret(&d);
|
||||
VMCall(func, ¶ms[0], params.Size(), &ret, 1);
|
||||
VMCallWithDefaults(func, ¶ms[0], params.Size(), &ret, 1);
|
||||
retval = GlobalACSStrings.AddString(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
// All other return values can not be handled so ignore them.
|
||||
VMCall(func, ¶ms[0], params.Size(), nullptr, 0);
|
||||
VMCallWithDefaults(func, ¶ms[0], params.Size(), nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
|
|||
try
|
||||
{
|
||||
state->CheckCallerType(actor, this);
|
||||
VMCall(state->ActionFunc, params, state->ActionFunc->ImplicitArgs, wantret, numret);
|
||||
VMCallWithDefaults(state->ActionFunc, params, state->ActionFunc->ImplicitArgs, wantret, numret);
|
||||
}
|
||||
catch (CVMAbortException &err)
|
||||
{
|
||||
|
|
|
@ -377,6 +377,11 @@ private:
|
|||
|
||||
int VMCall(VMFunction *func, VMValue *params, int numparams, VMReturn *results, int numresults/*, VMException **trap = NULL*/);
|
||||
|
||||
inline int VMCallWithDefaults(VMFunction *func, VMValue *params, int numparams, VMReturn *results, int numresults/*, VMException **trap = NULL*/)
|
||||
{
|
||||
VMCall(func, params, numparams, results, numresults);
|
||||
}
|
||||
|
||||
// Use this in the prototype for a native function.
|
||||
#define VM_ARGS VMValue *param, TArray<VMValue> &defaultparam, int numparam, VMReturn *ret, int numret
|
||||
#define VM_ARGS_NAMES param, defaultparam, numparam, ret, numret
|
||||
|
|
Loading…
Reference in a new issue