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

Method Prepare

src/server/angelscript/angelscript/source/as_context.cpp:376–512  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

374
375// interface
376int asCContext::Prepare(asIScriptFunction *func)
377{
378 if( func == 0 )
379 {
380 asCString str;
381 str.Format(TXT_FAILED_IN_FUNC_s_WITH_s_s_d, "Prepare", "null", errorNames[-asNO_FUNCTION], asNO_FUNCTION);
382 m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
383 return asNO_FUNCTION;
384 }
385
386 if( m_status == asEXECUTION_ACTIVE || m_status == asEXECUTION_SUSPENDED )
387 {
388 asCString str;
389 str.Format(TXT_FAILED_IN_FUNC_s_WITH_s_s_d, "Prepare", func->GetDeclaration(true, true), errorNames[-asCONTEXT_ACTIVE], asCONTEXT_ACTIVE);
390 m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
391 return asCONTEXT_ACTIVE;
392 }
393
394 // Clean the stack if not done before
395 if( m_status != asEXECUTION_FINISHED && m_status != asEXECUTION_UNINITIALIZED )
396 CleanStack();
397
398 // Release the returned object (if any)
399 CleanReturnObject();
400
401 // Release the object if it is a script object
402 if( m_initialFunction && m_initialFunction->objectType && (m_initialFunction->objectType->flags & asOBJ_SCRIPT_OBJECT) )
403 {
404 asCScriptObject *obj = *(asCScriptObject**)&m_regs.stackFramePointer[0];
405 if( obj )
406 obj->Release();
407
408 *(asPWORD*)&m_regs.stackFramePointer[0] = 0;
409 }
410
411 if( m_initialFunction && m_initialFunction == func )
412 {
413 // If the same function is executed again, we can skip a lot of the setup
414 m_currentFunction = m_initialFunction;
415
416 // Reset stack pointer
417 m_regs.stackPointer = m_originalStackPointer;
418
419 // Make sure the stack pointer is pointing to the original position,
420 // otherwise something is wrong with the way it is being updated
421 asASSERT( IsNested() || m_stackIndex > 0 || (m_regs.stackPointer == m_stackBlocks[0] + m_stackBlockSize) );
422 }
423 else
424 {
425 asASSERT( m_engine );
426
427 // Make sure the function is from the same engine as the context to avoid mixups
428 if( m_engine != func->GetEngine() )
429 {
430 asCString str;
431 str.Format(TXT_FAILED_IN_FUNC_s_WITH_s_s_d, "Prepare", func->GetDeclaration(true, true), errorNames[-asINVALID_ARG], asINVALID_ARG);
432 m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
433 return asINVALID_ARG;

Callers

nothing calls this directly

Calls 12

WriteMessageMethod · 0.80
GetDeclarationMethod · 0.80
DoesReturnOnStackMethod · 0.80
GetSizeInMemoryDWordsMethod · 0.80
GetCapacityMethod · 0.80
AllocateNoConstructMethod · 0.80
FormatMethod · 0.45
AddressOfMethod · 0.45
ReleaseMethod · 0.45
GetEngineMethod · 0.45
AddRefMethod · 0.45

Tested by

no test coverage detected