mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-06-04 19:10:59 +00:00
- scriptified the pistol to test if struct member functions work.
- made APlayerPawn::PlayAttacking(2) virtual script functions so that mods have better control over player animations. Note that these have no native base so they skip the templated interface for managing virtual functions.
This commit is contained in:
parent
de8cacc465
commit
d50da34664
15 changed files with 214 additions and 126 deletions
|
@ -6706,7 +6706,7 @@ FxMemberFunctionCall::~FxMemberFunctionCall()
|
|||
FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
||||
{
|
||||
ABORT(ctx.Class);
|
||||
PClass *cls;
|
||||
PStruct *cls;
|
||||
bool staticonly = false;
|
||||
bool novirtual = false;
|
||||
|
||||
|
@ -6714,11 +6714,19 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
{
|
||||
// If the left side is a class name for a static member function call it needs to be resolved manually
|
||||
// because the resulting value type would cause problems in nearly every other place where identifiers are being used.
|
||||
cls = PClass::FindClass(static_cast<FxIdentifier *>(Self)->Identifier);
|
||||
if (cls != nullptr && cls->bExported)
|
||||
PClass *ccls = PClass::FindClass(static_cast<FxIdentifier *>(Self)->Identifier);
|
||||
if (ccls != nullptr)
|
||||
{
|
||||
staticonly = true;
|
||||
goto isresolved;
|
||||
if (ccls->bExported)
|
||||
{
|
||||
cls = ccls;
|
||||
staticonly = true;
|
||||
goto isresolved;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Todo: static struct members need to work as well.
|
||||
}
|
||||
}
|
||||
SAFE_RESOLVE(Self, ctx);
|
||||
|
@ -6755,9 +6763,9 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
if (Self->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
|
||||
{
|
||||
auto ptype = static_cast<PPointer *>(Self->ValueType)->PointedType;
|
||||
if (ptype->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
if (ptype->IsKindOf(RUNTIME_CLASS(PStruct)))
|
||||
{
|
||||
cls = static_cast<PClass *>(ptype);
|
||||
cls = static_cast<PStruct *>(ptype);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6773,6 +6781,8 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Todo: handle member calls from instantiated structs.
|
||||
|
||||
isresolved:
|
||||
bool error = false;
|
||||
PFunction *afd = FindClassMemberFunction(cls, ctx.Class, MethodName, ScriptPosition, &error);
|
||||
|
@ -6792,7 +6802,8 @@ isresolved:
|
|||
if (staticonly && (afd->Variants[0].Flags & VARF_Method))
|
||||
{
|
||||
auto clstype = dyn_cast<PClass>(ctx.Class);
|
||||
if (clstype == nullptr || !clstype->IsDescendantOf(cls))
|
||||
auto ccls = dyn_cast<PClass>(cls);
|
||||
if (clstype == nullptr || ccls == nullptr || !clstype->IsDescendantOf(ccls))
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Cannot call non-static function %s::%s from here\n", cls->TypeName.GetChars(), MethodName.GetChars());
|
||||
delete this;
|
||||
|
@ -7067,7 +7078,7 @@ VMFunction *FxVMFunctionCall::GetDirectFunction()
|
|||
if (ArgList.Size() == 0 && !(Function->Variants[0].Flags & VARF_Virtual))
|
||||
{
|
||||
unsigned imp = Function->GetImplicitArgs();
|
||||
if (Function->Variants[0].ArgFlags.Size() <= imp || !(Function->Variants[0].ArgFlags[imp] & VARF_Optional)) return nullptr;
|
||||
if (Function->Variants[0].ArgFlags.Size() > imp && !(Function->Variants[0].ArgFlags[imp] & VARF_Optional)) return nullptr;
|
||||
return Function->Variants[0].Implementation;
|
||||
}
|
||||
|
||||
|
|
|
@ -1032,8 +1032,6 @@ struct AFuncDesc
|
|||
// change every single use in case the parameters change.
|
||||
#define DECLARE_ACTION(name) extern VMNativeFunction *AActor_##name##_VMPtr;
|
||||
|
||||
// This distinction is here so that CALL_ACTION produces errors when trying to
|
||||
// access a function that requires parameters.
|
||||
#define DEFINE_ACTION_FUNCTION(cls, name) \
|
||||
static int AF_##cls##_##name(VM_ARGS); \
|
||||
VMNativeFunction *cls##_##name##_VMPtr; \
|
||||
|
@ -1077,6 +1075,10 @@ void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self);
|
|||
PARAM_PROLOGUE; \
|
||||
PARAM_OBJECT(self, type);
|
||||
|
||||
// for structs we need to check for ATAG_GENERIC instead of ATAG_OBJECT
|
||||
#define PARAM_SELF_STRUCT_PROLOGUE(type) \
|
||||
PARAM_PROLOGUE; \
|
||||
PARAM_POINTER(self, type);
|
||||
|
||||
class PFunction;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue