interface
| 5667 | |
| 5668 | // interface |
| 5669 | int asCScriptEngine::AssignScriptObject(void *dstObj, void *srcObj, const asITypeInfo *type) |
| 5670 | { |
| 5671 | // TODO: Warn about invalid call in message stream (make it optional) |
| 5672 | if( type == 0 || dstObj == 0 || srcObj == 0 ) return asINVALID_ARG; |
| 5673 | |
| 5674 | const asCObjectType *objType = CastToObjectType(const_cast<asCTypeInfo*>(reinterpret_cast<const asCTypeInfo*>(type))); |
| 5675 | if (objType == 0) return asINVALID_ARG; |
| 5676 | |
| 5677 | // If value assign for ref types has been disabled, then don't do anything if the type is a ref type |
| 5678 | if (ep.disallowValueAssignForRefType && (objType->flags & asOBJ_REF) && !(objType->flags & asOBJ_SCOPED)) |
| 5679 | { |
| 5680 | asIScriptContext *ctx = asGetActiveContext(); |
| 5681 | if (ctx) |
| 5682 | ctx->SetException("Cannot do value assignment"); |
| 5683 | return asNOT_SUPPORTED; |
| 5684 | } |
| 5685 | |
| 5686 | // Must not copy if the opAssign is not available and the object is not a POD object |
| 5687 | if (objType->beh.copy) |
| 5688 | { |
| 5689 | asCScriptFunction* func = scriptFunctions[objType->beh.copy]; |
| 5690 | if (func->funcType == asFUNC_SYSTEM) |
| 5691 | CallObjectMethod(dstObj, srcObj, objType->beh.copy); |
| 5692 | else |
| 5693 | { |
| 5694 | // Call the script class' opAssign method |
| 5695 | asASSERT(objType->flags & asOBJ_SCRIPT_OBJECT); |
| 5696 | reinterpret_cast<asCScriptObject*>(dstObj)->CopyFrom(reinterpret_cast<asCScriptObject*>(srcObj)); |
| 5697 | } |
| 5698 | } |
| 5699 | else if (objType->size && (objType->flags & asOBJ_POD)) |
| 5700 | { |
| 5701 | memcpy(dstObj, srcObj, objType->size); |
| 5702 | } |
| 5703 | else |
| 5704 | { |
| 5705 | asIScriptContext* ctx = asGetActiveContext(); |
| 5706 | if (ctx) |
| 5707 | ctx->SetException("Cannot do value assignment"); |
| 5708 | return asNOT_SUPPORTED; |
| 5709 | } |
| 5710 | |
| 5711 | return asSUCCESS; |
| 5712 | } |
| 5713 | |
| 5714 | // interface |
| 5715 | void asCScriptEngine::AddRefScriptObject(void *obj, const asITypeInfo *type) |