MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / Unprepare

Method Unprepare

src/server/angelscript/angelscript/source/as_context.cpp:515–573  ·  view source on GitHub ↗

Free all resources

Source from the content-addressed store, hash-verified

513
514// Free all resources
515int asCContext::Unprepare()
516{
517 if( m_status == asEXECUTION_ACTIVE || m_status == asEXECUTION_SUSPENDED )
518 return asCONTEXT_ACTIVE;
519
520 // Set the context as active so that any clean up code can use access it if desired
521 asCThreadLocalData *tld = asPushActiveContext((asIScriptContext *)this);
522 asDWORD count = m_refCount.get();
523 UNUSED_VAR(count);
524
525 // Only clean the stack if the context was prepared but not executed until the end
526 if( m_status != asEXECUTION_UNINITIALIZED &&
527 m_status != asEXECUTION_FINISHED )
528 CleanStack();
529
530 asASSERT( m_needToCleanupArgs == false );
531
532 // Release the returned object (if any)
533 CleanReturnObject();
534
535 // TODO: Unprepare is called during destruction, so nobody
536 // must be allowed to keep an extra reference
537 asASSERT(m_refCount.get() == count);
538 asPopActiveContext(tld, this);
539
540 // Release the object if it is a script object
541 if( m_initialFunction && m_initialFunction->objectType && (m_initialFunction->objectType->flags & asOBJ_SCRIPT_OBJECT) )
542 {
543 asCScriptObject *obj = *(asCScriptObject**)&m_regs.stackFramePointer[0];
544 if( obj )
545 obj->Release();
546 }
547
548 // Release the initial function
549 if( m_initialFunction )
550 {
551 m_initialFunction->Release();
552
553 // Reset stack pointer
554 m_regs.stackPointer = m_originalStackPointer;
555
556 // Make sure the stack pointer is pointing to the original position,
557 // otherwise something is wrong with the way it is being updated
558 asASSERT( IsNested() || m_stackIndex > 0 || (m_regs.stackPointer == m_stackBlocks[0] + m_stackBlockSize) );
559 }
560
561 // Clear function pointers
562 m_initialFunction = 0;
563 m_currentFunction = 0;
564 m_exceptionFunction = 0;
565 m_regs.programPointer = 0;
566
567 // Reset status
568 m_status = asEXECUTION_UNINITIALIZED;
569
570 m_regs.stackFramePointer = 0;
571
572 return 0;

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