src/squirrel_helper.hpp
branchnoai
changeset 9679 788e083db48b
parent 9658 e7675771bca4
child 9722 ebf0ece7d8f6
equal deleted inserted replaced
9678:c78400096127 9679:788e083db48b
   634 	 */
   634 	 */
   635 	template <typename Tcls>
   635 	template <typename Tcls>
   636 	static SQInteger DefSQDestructorCallback(SQUserPointer p, SQInteger size)
   636 	static SQInteger DefSQDestructorCallback(SQUserPointer p, SQInteger size)
   637 	{
   637 	{
   638 		/* Remove the real instance too */
   638 		/* Remove the real instance too */
   639 		if (p != NULL) delete (Tcls *)p;
   639 		if (p != NULL) ((Tcls *)p)->Release();
   640 		return 0;
   640 		return 0;
   641 	}
   641 	}
   642 
   642 
   643 	/**
   643 	/**
   644 	 * A general template to handle creating of instance with any amount of
   644 	 * A general template to handle creating of instance with any amount of
   650 	{
   650 	{
   651 		/* Create the real instance */
   651 		/* Create the real instance */
   652 		Tcls *instance = HelperT<Tmethod>::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm);
   652 		Tcls *instance = HelperT<Tmethod>::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm);
   653 		sq_setinstanceup(vm, -Tnparam, instance);
   653 		sq_setinstanceup(vm, -Tnparam, instance);
   654 		sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
   654 		sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
       
   655 		instance->AddRef();
   655 		return 0;
   656 		return 0;
   656 	}
   657 	}
   657 
   658 
   658 }; // namespace SQConvert
   659 }; // namespace SQConvert
   659 
   660