mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- declared most native getters in Actor as const.
- made the self pointer of const functions readonly. This seems to work fine. Both calling a non-const function and trying to assign a value to a member fail with an error message.
This commit is contained in:
parent
4c5794b6d5
commit
7dbc6939c4
3 changed files with 31 additions and 21 deletions
|
@ -110,12 +110,13 @@ void SetImplicitArgs(TArray<PType *> *args, TArray<DWORD> *argflags, TArray<FNam
|
|||
if (funcflags & VARF_Method)
|
||||
{
|
||||
// implied self pointer
|
||||
if (args != nullptr) args->Push(NewPointer(cls));
|
||||
if (args != nullptr) args->Push(NewPointer(cls, !!(funcflags & VARF_ReadOnly)));
|
||||
if (argflags != nullptr) argflags->Push(VARF_Implicit | VARF_ReadOnly);
|
||||
if (argnames != nullptr) argnames->Push(NAME_self);
|
||||
}
|
||||
if (funcflags & VARF_Action)
|
||||
{
|
||||
assert(!(funcflags & VARF_ReadOnly));
|
||||
// implied caller and callingstate pointers
|
||||
if (args != nullptr)
|
||||
{
|
||||
|
|
|
@ -2156,6 +2156,15 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
}
|
||||
if (f->Flags & ZCC_Action)
|
||||
{
|
||||
if (varflags & VARF_ReadOnly)
|
||||
{
|
||||
Error(f, "Action functions cannot be declared const");
|
||||
varflags &= ~VARF_ReadOnly;
|
||||
}
|
||||
if (varflags & VARF_UI)
|
||||
{
|
||||
Error(f, "Action functions cannot be declared UI");
|
||||
}
|
||||
// Non-Actors cannot have action functions.
|
||||
if (!c->Type()->IsKindOf(RUNTIME_CLASS(PClassActor)))
|
||||
{
|
||||
|
|
|
@ -468,15 +468,15 @@ class Actor : Thinker native
|
|||
native bool UpdateWaterLevel (bool splash = true);
|
||||
native bool IsZeroDamage();
|
||||
native void ClearInterpolation();
|
||||
native Vector3 PosRelative(sector sec);
|
||||
native Vector3 PosRelative(sector sec) const;
|
||||
|
||||
native void HandleSpawnFlags();
|
||||
native void ExplodeMissile(line lin = null, Actor target = null, bool onsky = false);
|
||||
native void RestoreDamage();
|
||||
native int SpawnHealth();
|
||||
native int SpawnHealth() const;
|
||||
native void SetDamage(int dmg);
|
||||
native double Distance2D(Actor other);
|
||||
native double Distance3D(Actor other);
|
||||
native double Distance2D(Actor other) const;
|
||||
native double Distance3D(Actor other) const;
|
||||
native void SetOrigin(vector3 newpos, bool moving);
|
||||
native void SetXYZ(vector3 newpos);
|
||||
native Actor GetPointer(int aaptr);
|
||||
|
@ -511,7 +511,7 @@ class Actor : Thinker native
|
|||
native void BloodSplatter (Vector3 pos, double hitangle, bool axe = false);
|
||||
native bool HitWater (sector sec, Vector3 pos, bool checkabove = false, bool alert = true, bool force = false);
|
||||
native void PlaySpawnSound(Actor missile);
|
||||
native bool CountsAsKill();
|
||||
native bool CountsAsKill() const;
|
||||
|
||||
native bool Teleport(Vector3 pos, double angle, int flags);
|
||||
native void TraceBleed(int damage, Actor missile);
|
||||
|
@ -559,21 +559,21 @@ class Actor : Thinker native
|
|||
native void LinkToWorld(LinkContext ctx = null);
|
||||
native void UnlinkFromWorld(out LinkContext ctx = null);
|
||||
native bool CanSeek(Actor target);
|
||||
native double AngleTo(Actor target, bool absolute = false);
|
||||
native double AngleTo(Actor target, bool absolute = false) const;
|
||||
native void AddZ(double zadd, bool moving = true);
|
||||
native void SetZ(double z);
|
||||
native vector2 Vec2To(Actor other);
|
||||
native vector3 Vec3To(Actor other);
|
||||
native vector3 Vec3Offset(double x, double y, double z, bool absolute = false);
|
||||
native vector3 Vec3Angle(double length, double angle, double z = 0, bool absolute = false);
|
||||
native vector2 Vec2Angle(double length, double angle, bool absolute = false);
|
||||
native vector2 Vec2Offset(double x, double y, bool absolute = false);
|
||||
native vector3 Vec2OffsetZ(double x, double y, double atz, bool absolute = false);
|
||||
native void VelFromAngle(double speed = 0, double angle = 0);
|
||||
native void Vel3DFromAngle(double speed, double angle, double pitch);
|
||||
native vector2 Vec2To(Actor other) const;
|
||||
native vector3 Vec3To(Actor other) const;
|
||||
native vector3 Vec3Offset(double x, double y, double z, bool absolute = false) const;
|
||||
native vector3 Vec3Angle(double length, double angle, double z = 0, bool absolute = false) const;
|
||||
native vector2 Vec2Angle(double length, double angle, bool absolute = false) const;
|
||||
native vector2 Vec2Offset(double x, double y, bool absolute = false) const;
|
||||
native vector3 Vec2OffsetZ(double x, double y, double atz, bool absolute = false) const;
|
||||
native void VelFromAngle(double speed = 0, double angle = 0) const;
|
||||
native void Vel3DFromAngle(double speed, double angle, double pitch) const;
|
||||
native void Thrust(double speed = 0, double angle = 0);
|
||||
native bool isFriend(Actor other);
|
||||
native bool isHostile(Actor other);
|
||||
native bool isFriend(Actor other) const;
|
||||
native bool isHostile(Actor other) const;
|
||||
native void AdjustFloorClip();
|
||||
native DropItem GetDropItems();
|
||||
native void CopyFriendliness (Actor other, bool changeTarget, bool resetHealth = true);
|
||||
|
@ -588,8 +588,8 @@ class Actor : Thinker native
|
|||
native void Howl();
|
||||
native void DrawSplash (int count, double angle, int kind);
|
||||
native void GiveSecret(bool printmsg = true, bool playsound = true);
|
||||
native double GetCameraHeight();
|
||||
native double GetGravity();
|
||||
native double GetCameraHeight() const;
|
||||
native double GetGravity() const;
|
||||
|
||||
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
|
||||
native void AddInventory(Inventory inv);
|
||||
|
@ -613,7 +613,7 @@ class Actor : Thinker native
|
|||
native double GetDistance(bool checkz, int ptr = AAPTR_TARGET);
|
||||
native double GetAngle(int flags, int ptr = AAPTR_TARGET);
|
||||
native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
|
||||
native int GetSpawnHealth();
|
||||
native int GetSpawnHealth() const;
|
||||
native double GetCrouchFactor(int ptr = AAPTR_PLAYER1);
|
||||
native double GetCVar(string cvar);
|
||||
native int GetPlayerInput(int inputnum, int ptr = AAPTR_DEFAULT);
|
||||
|
|
Loading…
Reference in a new issue