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

Method CreateScriptObjectCopy

sdk/angelscript/source/as_scriptengine.cpp:5577–5642  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

5575
5576// interface
5577void *asCScriptEngine::CreateScriptObjectCopy(void *origObj, const asITypeInfo *type)
5578{
5579 if( origObj == 0 || type == 0 ) return 0;
5580
5581 const asCObjectType* ot = CastToObjectType(const_cast<asCTypeInfo*>(reinterpret_cast<const asCTypeInfo*>(type)));
5582 if (ot == 0) return 0;
5583
5584 void *newObj = 0;
5585
5586 if ((ot->flags & asOBJ_SCRIPT_OBJECT) && ot->beh.copyfactory)
5587 {
5588 // Call the script class' default factory with a context
5589 newObj = ScriptObjectCopyFactory(ot, origObj, this);
5590 }
5591 else if (ot->beh.copyfactory)
5592 {
5593 // Call the copy factory which will allocate the memory then copy the original object
5594#ifdef AS_NO_EXCEPTIONS
5595 newObj = CallGlobalFunctionRetPtr(ot->beh.copyfactory, origObj);
5596#else
5597 try
5598 {
5599 newObj = CallGlobalFunctionRetPtr(ot->beh.copyfactory, origObj);
5600 }
5601 catch (...)
5602 {
5603 asCContext *ctx = reinterpret_cast<asCContext*>(asGetActiveContext());
5604 if (ctx)
5605 ctx->HandleAppException();
5606 }
5607#endif
5608 }
5609 else if(ot->beh.copyconstruct )
5610 {
5611 // Manually allocate the memory, then call the copy constructor
5612 newObj = CallAlloc(ot);
5613#ifdef AS_NO_EXCEPTIONS
5614 CallObjectMethod(newObj, origObj, ot->beh.copyconstruct);
5615#else
5616 try
5617 {
5618 CallObjectMethod(newObj, origObj, ot->beh.copyconstruct);
5619 }
5620 catch(...)
5621 {
5622 asCContext *ctx = reinterpret_cast<asCContext*>(asGetActiveContext());
5623 if( ctx )
5624 ctx->HandleAppException();
5625
5626 // Free the memory
5627 CallFree(newObj);
5628 newObj = 0;
5629 }
5630#endif
5631 }
5632 else
5633 {
5634 // Allocate the object and then do a value assign

Callers 9

SetArgObjectMethod · 0.80
SetMethod · 0.80
scriptany.cppFile · 0.80
StoreMethod · 0.80
TestFunction · 0.80
SetMethod · 0.80
CHandleTypeClass · 0.80
TestFunction · 0.80

Calls 3

CastToObjectTypeFunction · 0.85
ScriptObjectCopyFactoryFunction · 0.85
HandleAppExceptionMethod · 0.80

Tested by 3

TestFunction · 0.64
SetMethod · 0.64
TestFunction · 0.64