MCPcopy Create free account
hub / github.com/anjo76/angelscript / Unprepare

Method Unprepare

sdk/angelscript/source/as_context.cpp:812–867  ·  view source on GitHub ↗

Free all resources

Source from the content-addressed store, hash-verified

810
811// Free all resources
812int asCContext::Unprepare()
813{
814 if( m_status == asEXECUTION_ACTIVE || m_status == asEXECUTION_SUSPENDED )
815 return asCONTEXT_ACTIVE;
816
817 // Set the context as active so that any clean up code can use access it if desired
818 asCThreadLocalData *tld = asPushActiveContext((asIScriptContext *)this);
819 asDWORD count = m_refCount.get();
820 UNUSED_VAR(count);
821
822 // Only clean the stack if the context was prepared but not executed until the end
823 if( m_status != asEXECUTION_UNINITIALIZED &&
824 m_status != asEXECUTION_FINISHED )
825 CleanStack();
826
827 asASSERT( m_needToCleanupArgs == false );
828
829 // Release the returned object (if any)
830 CleanReturnObject();
831
832 // TODO: Unprepare is called during destruction, so nobody
833 // must be allowed to keep an extra reference
834 asASSERT(m_refCount.get() == count);
835 asPopActiveContext(tld, this);
836
837 // Release the object if it is a script object
838 if( m_initialFunction && m_initialFunction->objectType && (m_initialFunction->objectType->flags & asOBJ_SCRIPT_OBJECT) )
839 {
840 asCScriptObject *obj = *(asCScriptObject**)&m_regs.stackFramePointer[0];
841 if( obj )
842 obj->Release();
843 }
844
845 // Release the initial function
846 if( m_initialFunction )
847 {
848 m_initialFunction->Release();
849
850 // Reset stack pointer
851 m_regs.stackPointer = m_originalStackPointer;
852 m_stackIndex = m_originalStackIndex;
853 }
854
855 // Clear function pointers
856 m_initialFunction = 0;
857 m_currentFunction = 0;
858 m_exceptionFunction = 0;
859 m_regs.programPointer = 0;
860
861 // Reset status
862 m_status = asEXECUTION_UNINITIALIZED;
863
864 m_regs.stackFramePointer = 0;
865
866 return 0;
867}
868
869asBYTE asCContext::GetReturnByte()

Callers

nothing calls this directly

Calls 4

asPushActiveContextFunction · 0.85
asPopActiveContextFunction · 0.85
getMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected