diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index 82b804ba0a..85710d0c09 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -312,6 +312,37 @@ operator [](int n) const { } #endif +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::get_element +// Access: Published +// Description: This method exists mainly to access the elements of +// the array easily from a high-level language such as +// Python, especially on Windows, where the above index +// element accessor methods can't be defined because of +// a confusion with the pointer typecast operator. +//////////////////////////////////////////////////////////////////// +template +INLINE TYPENAME PointerToArray::const_reference PointerToArray:: +get_element(size_type n) const { + return (*this)[n]; +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::set_element +// Access: Published +// Description: This method exists mainly to access the elements of +// the array easily from a high-level language such as +// Python, especially on Windows, where the above index +// element accessor methods can't be defined because of +// a confusion with the pointer typecast operator. +//////////////////////////////////////////////////////////////////// +template +INLINE void PointerToArray:: +set_element(size_type n, const_reference value) { + nassertv(n < _ptr->size()); + (*this)[n] = value; +} + //////////////////////////////////////////////////////////////////// // Function: PointerToArray::push_back // Access: Published diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index f9d586cbcc..8b6d41358f 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -152,6 +152,9 @@ PUBLISHED: INLINE reference operator [](size_type n) const; INLINE reference operator [](int n) const; #endif + INLINE const_reference get_element(size_type n) const; + INLINE void set_element(size_type n, const_reference value); + INLINE void push_back(const Element &x); INLINE void pop_back(); INLINE void make_empty();