Esempio n. 1
0
	/** release smart pointer (and decrement ref count) if not null */
	inline void Release()
	{
		if (m_pT != NULL) {
			Tcls *pT = m_pT;
			m_pT = NULL;
			pT->Release();
		}
	}
Esempio n. 2
0
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT)
{
	/* if they are the same, we do nothing */
	if (pT != m_pT) {
		if (pT) pT->AddRef();        // AddRef new pointer if any
		Tcls *pTold = m_pT;          // save original ptr
		m_pT = pT;                   // update m_pT to new value
		if (pTold) pTold->Release(); // release old ptr if any
	}
}
Esempio n. 3
0
	inline SQInteger DefSQConstructorCallback(HSQUIRRELVM vm)
	{
		/* Find the amount of params we got */
		int nparam = sq_gettop(vm);

		try {
			/* Create the real instance */
			Tcls *instance = HelperT<Tmethod>::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm);
			sq_setinstanceup(vm, -Tnparam, instance);
			sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
			instance->AddRef();
			return 0;
		} catch (SQInteger e) {
			sq_pop(vm, nparam);
			return e;
		}
	}
Esempio n. 4
0
	/** release smart pointer (and decrement ref count) if not null */
	FORCEINLINE void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}}
Esempio n. 5
0
	/** add one ref to the underlaying object */
	FORCEINLINE void AddRef() {if (m_pT != NULL) m_pT->AddRef();}
Esempio n. 6
0
	/** add one ref to the underlaying object */
	inline void AddRef()
	{
		if (m_pT != NULL) m_pT->AddRef();
	}