Page MenuHomeFeedback Tracker

Add/Expose typename::SetVariableValue
Assigned, NormalPublic

Description

We already have typename::GetVariableValue to dynamically get variables of known correct out variable type. I would like to have a corresponding method of typename::SetVariableValue(Class var, int vIdx, out void val).

My goal is to replace the expensive deep copy setup for some of my data that are currently going through JSON with a combination of Managed::Clone() for shallow copies and then go through and add deeper copies on complex class members recursively so I end up with a full truly deep copy.
This is currently not possible because even though I can create a copy for a complex member, there is no way to assign that copy back to the destination instance dynamically. All I get back is a Managed instance, and to assign it I would need to put it into the correct compile-time type. My code however handles user types so I can not possibly know their types in my logic and need to resort to this dynamic scripting.

class TestThingy
{
	int someProp;
}

class TestHolder
{
	string someString;
	ref TestThingy someRef;
}

That would be solved if for the above I could do:

void Copy(Managed instance)
{
    foreach(prop on instance)
    {
        if(prop is complex)
        {
            Managed complexProp;
            instance.Type().GetVariableVale(instance, propVIdx, complexProp);
            instance.Type().SetVariableValue(instance, propVIdx, complexProp.Clone());
        }
    }
}

Details

Severity
Major
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Jul 17 2023, 4:43 PM
Geez changed the task status from New to Assigned.Jul 20 2023, 5:17 PM