src/melon/modules/object/object_module.c
static TByte cloneFunc(VM* vm)
{
    melM_arg(vm, obj, MELON_TYPE_OBJECT, 0);
    melM_argOptional(vm, deep, MELON_TYPE_BOOL, 1);

    melM_stackEnsure(&vm->stack, vm->stack.top + 1);
    Value* result = melM_stackAllocRaw(&vm->stack);
    result->type = MELON_TYPE_OBJECT;
    result->pack.obj = melCloneObject(
        vm, 
        obj->pack.obj, 
        deep->type != MELON_TYPE_NULL ? deep->pack.value.boolean : 0
    );

    return 1;
}
/***
 * Clones an `Object` returning a copy of the original.
 * When a deep clone is performed only objects will be cloned,
 * values which are not objects but are managed by the GC (eg: arrays)
 * will still point to the same value and will be reference assigned.
 * 
 * @arg obj The object to be cloned
 * @arg ?deep `true` if it should be cloned recursively
 * 
 * @returns The cloned object.
 */
Clones an `Object` returning a copy of the original.
When a deep clone is performed only objects will be cloned,
values which are not objects but are managed by the GC
will still point to the same value and will be reference assigned.

@arg obj The object to be cloned
@arg ?deep `true` if it should be cloned recursively

@returns The cloned object.
Clones an ` Object ` returning a copy of the original . When a deep clone is performed only objects will be cloned values which are not objects but are managed by the GC will still point to the same value and will be reference assigned . @arg obj The object to be cloned @arg ?deep ` true ` if it should be cloned recursively @returns The cloned object .
static TByte cloneFunc(VM* vm)
{
    melM_arg(vm, obj, MELON_TYPE_OBJECT, 0);
    melM_argOptional(vm, deep, MELON_TYPE_BOOL, 1);
    melM_stackEnsure(&vm->stack, vm->stack.top + 1);
    Value* result = melM_stackAllocRaw(&vm->stack);
    result->type = MELON_TYPE_OBJECT;
    result->pack.obj = melCloneObject(
        vm, 
        obj->pack.obj, 
        deep->type != MELON_TYPE_NULL ? deep->pack.value.boolean : 0
    );
    return 1;
}
static TByte cloneFunc ( VM * vm ) { melM_arg ( vm , obj , MELON_TYPE_OBJECT , 0 ) ; melM_argOptional ( vm , deep , MELON_TYPE_BOOL , 1 ) ; melM_stackEnsure ( & vm -> stack , vm -> stack . top + 1 ) ; Value * result = melM_stackAllocRaw ( & vm -> stack ) ; result -> type = MELON_TYPE_OBJECT ; result -> pack . obj = melCloneObject ( vm , obj -> pack . obj , deep -> type != MELON_TYPE_NULL ? deep -> pack . value . boolean : 0 ) ; return 1 ; }
Clones an `Object` returning a copy of the original.
Clones an ` Object ` returning a copy of the original .