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

Method SetReturnObject

sdk/angelscript/source/as_generic.cpp:448–488  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

446
447// interface
448int asCGeneric::SetReturnObject(void *obj)
449{
450 asCDataType *dt = &sysFunction->returnType;
451 if( !dt->IsObject() && !dt->IsFuncdef() )
452 return asINVALID_TYPE;
453
454 if( dt->IsReference() )
455 {
456 *(void**)&returnVal = obj;
457 return 0;
458 }
459
460 if( dt->IsObjectHandle() )
461 {
462 // Increase the reference counter
463 if (dt->IsFuncdef())
464 {
465 if (obj)
466 reinterpret_cast<asIScriptFunction*>(obj)->AddRef();
467 }
468 else
469 {
470 asSTypeBehaviour *beh = &CastToObjectType(dt->GetTypeInfo())->beh;
471 if (obj && beh && beh->addref)
472 engine->CallObjectMethod(obj, beh->addref);
473 }
474 }
475 else
476 {
477 // If function returns object by value the memory is already allocated.
478 // Here we should just initialize that memory by calling the copy constructor
479 // or the default constructor followed by the assignment operator
480 void *mem = (void*)*(asPWORD*)&stackPointer[-AS_PTR_SIZE];
481 engine->ConstructScriptObjectCopy(mem, obj, CastToObjectType(dt->GetTypeInfo()));
482 return 0;
483 }
484
485 objectRegister = obj;
486
487 return 0;
488}
489
490// internal
491void *asCGeneric::GetReturnPointer()

Callers 15

StringAddGenericFunction · 0.80
AddString2DoubleGenericFunction · 0.80
AddString2FloatGenericFunction · 0.80
AddString2IntGenericFunction · 0.80
AddString2UIntGenericFunction · 0.80
AddString2BoolGenericFunction · 0.80
AddDouble2StringGenericFunction · 0.80
AddFloat2StringGenericFunction · 0.80
AddInt2StringGenericFunction · 0.80

Calls 9

CastToObjectTypeFunction · 0.85
IsObjectMethod · 0.80
IsFuncdefMethod · 0.80
IsObjectHandleMethod · 0.80
GetTypeInfoMethod · 0.80
CallObjectMethodMethod · 0.80
IsReferenceMethod · 0.45
AddRefMethod · 0.45

Tested by 15

StringAddGenericFunction · 0.64
AddString2IntGenericFunction · 0.64
SuspendObj_genFunction · 0.64
ExceptionObj_genFunction · 0.64
ExceptionHandle_genFunction · 0.64
testSetReturnObjectFunction · 0.64
ReturnObjGenericFunction · 0.64
GenMethod1Function · 0.64
GenAssignFunction · 0.64
GenericString_AssignmentFunction · 0.64
GenericString_FactoryFunction · 0.64