-
Notifications
You must be signed in to change notification settings - Fork 0
API: Namespaces and Pointers
#Namespaces
libscriptobject is defined in the rs::scriptobject namespace. There are a bunch of other libraries we've developed, they all live in their own namespace below the rs namespace.
Apologies if you find the nested namespaces a PITA, they are there for good reason.
#Pointers
libscriptobject doesn't create normal C++ objects. They are optimized so they occupy a single allocated block regardless of how many fields, their types and values your supply.
Underneath we use placement new which makes using std smart pointers a bit funky. To keep things simple libscriptobject uses its own smart pointer type: ScriptItemPtr. The main benefit here is that the reference count value is part of the allocated memory block and not allocated separately.
ScriptItemPtr is defined as follows:
template <typename T>
class ScriptItemPtr final {
public:
inline T* get() const noexcept { return ptr_; }
inline typename T::allocated_type* getRawPtr() const noexcept;
inline void reset() noexcept;
inline typename ScriptItemPtrBase<T>::count_type count() const noexcept;
inline void operator=(ScriptItemPtr<T>&& rhs) noexcept;
inline void operator=(const ScriptItemPtr<T>& rhs) noexcept;
inline T& operator*() const;
inline T* operator->() const noexcept;
inline bool operator!() const noexcept;
inline void swap(ScriptItemPtr<T>& rhs) noexcept;
};