From c81c506df3e21575a54929d811a0abad7d9c8083 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 1 Jan 2021 17:49:15 +0100 Subject: [PATCH] express: Fix PointerToArray comparison operator --- panda/src/express/pointerToArrayBase.h | 6 ++++++ tests/express/test_pointertoarray.py | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index 3c985ff379..898d5c82ad 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -77,6 +77,12 @@ protected: PUBLISHED: INLINE ~PointerToArrayBase(); + +#ifdef CPPPARSER + // These are implemented in PointerToVoid, but expose them here. + INLINE bool operator == (const PointerToArrayBase &other) const; + INLINE bool operator != (const PointerToArrayBase &other) const; +#endif }; #include "pointerToArrayBase.I" diff --git a/tests/express/test_pointertoarray.py b/tests/express/test_pointertoarray.py index fe76c94128..850cdc33ed 100644 --- a/tests/express/test_pointertoarray.py +++ b/tests/express/test_pointertoarray.py @@ -1,3 +1,26 @@ +def test_pta_float_compare(): + from panda3d.core import PTA_float, CPTA_float + + # Two null PTAs + assert PTA_float() == PTA_float() + assert not (PTA_float() != PTA_float()) + + # Two non-null PTAs + assert PTA_float([1]) != PTA_float([1]) + assert not (PTA_float([1]) == PTA_float([1])) + + # A copy of a PTA + pta = PTA_float([1]) + assert pta == PTA_float(pta) + assert not (pta != PTA_float(pta)) + + # A const copy of a PTA + pta = PTA_float([1]) + cpta = CPTA_float(pta) + assert pta == cpta + assert not (pta != cpta) + + def test_pta_float_pickle(): from panda3d.core import PTA_float from direct.stdpy.pickle import dumps, loads, HIGHEST_PROTOCOL