And I never instantiated a class in-line in Xojo thinking it does not work because when I tested:
Msgbox (new Date(2014,8,1,23,59,59)).SQLDateTime // Got a compiler Error
Never thought that recasting a Date to a Date would make it work: Msgbox Date(new Date(2014,8,1,23,59,59)).SQLDateTime
Class myClass
Public theData As Integer = 123
sub Constructor( )
end sub
Function Clone() As myClass
Dim c As New myClass
c.theData = theData
Return c
End Function
Function DestructiveTest() As integer
theData = 0
Return doAWeirdThingsReturningAnInteger(self)
End Function
End class
Dim a As New myClass // a.theData = 123
msgBox Str(a.Clone().DestructiveTest()) // Should return an integer status obtained from a copy of the object
// whose contents where modified, but this copy was just discarded after.
MsgBox str(a.theData) // Still 123
A few things to note about the serialization/cloning
It currently does not handle circular references.
It currently does not support multi-dimensional arrays (My understanding as this is currently a limitation of introspection with XOJO)
All objects serialized/cloned must have a public constructor that takes no parameters
Use:
dim myObject as new myClass()
dim myClone as myClass = myClass(myObject.Clone)
If you want to add this to your own project you will need the Serialization Class and the Clone Method copied into your project.
Just a warning. There are a few other incomplete classes in this project. One is working on a Xojo Entity Framework for databases and another to do linq like expressions.
Right - there are some interesting things (like this that are / were intended to work that don’t)
Joes been working on a list of things that “should” work that don’t