You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example
how it works at the moment (which in general is fine but would be nice to quickly clone) is that a var references another object where you sometimes want a copy/clone
#include <AutoItObject_Internal.au3>
$cFoo=IDispatch()
$oFoo1=$cFoo
$oFoo2=$cFoo
$oFoo1.Property1="Nice"
;~ And now the fun comes as they both point to same object
consolewrite($oFoo2.Property1)
Endgoal I would like to reach is that you have
;~ Have a generic method reference that is shared
$cFoo.Method1 = cFoo_Method1
func cFoo_Method1
;~ whatever we want to have shared as a method printing a property of the current object
ConsoleWrite($self.parent.Property1)
endfunc
$oFoo1=cFoo.clone
$oFoo2=cFoo.clone
;~ Have independent propertyvalues
$oFoo1.Property1="Hello world 1"
$oFoo2.Property1="Hello world 2"
$oFoo1.Method1
$oFoo2.Method1
The text was updated successfully, but these errors were encountered:
Hi @junkew.
The clone feature is implemented via the method __assign.
This is done to enable multiple objects to be referenced, a feature i wanted so inheritance from more than one would be possible, to on a very basic level, mimic PHP class extension and traits.
#include <AutoItObject_Internal.au3>$cFoo=IDispatch()
func cFoo_Method1($self)
;~ whatever we want to have shared as a method printing a property of the current objectConsoleWrite($self.parent.Property1)
endfunc$cFoo.Method1 = cFoo_Method1
$oFoo1=$cFoo;~ Have independent propertyvalues$oFoo1.Property1="Hello world 1"$oFoo2=IDispatch()
$oFoo2.__assign($oFoo1)
$oFoo2.Property1="Hello world 2"MsgBox(0, "", $oFoo1.Property1)
MsgBox(0, "", $oFoo2.Property1)
MsgBox(0, "", FuncName($oFoo1.Method1))
MsgBox(0, "", FuncName($oFoo2.Method1))
Would be nice to could write
...
$oFoo2=$oFoo1.clone
...
Example
how it works at the moment (which in general is fine but would be nice to quickly clone) is that a var references another object where you sometimes want a copy/clone
Endgoal I would like to reach is that you have
The text was updated successfully, but these errors were encountered: