Without any usability, but fun ⦠(just to start the new year
)
[code]
struct parentStruct
(
-- Public Struct Data and Functions
parentVar_01,
parentVar_02 = 5,
parentVar_03 = "Hello",
fn parentFN_01 = parentVar_01 * parentVar_02,
fn parentFN_02 data = data * 3 * this._parentVar_01,
-- FOR INHERITANCE
-------------------------------------------------
-- Inherit Functions (Fixed, always the same for parent and children)
fn _getHeader = this.stHeader,
fn _getPublic = this.stPublic,
fn _getPrivate = this.stPrivate,
fn _getClose = this.stClose,
-------------------------------------------------
-------------------------------------------------
-- Fixed Inherit Function ONLY for first parent
fn _createDerivedClass child=
(
txtPublic = this.stPublic + child._getPublic()
txtPrivate = this.stPrivate + child._getPrivate()
txtClose = this.stClose + "\n" + child._getClose()
txt = "struct " + child._getHeader() + "("
txt += txtPublic
txt += this.stInheritFN
txt += "private " + txtPrivate
txt += "stHeader = \"" + child._getHeader() + "\","
txtPublic = substituteString txtPublic "\\" "\\\\"
txtPublic = substituteString txtPublic "\"" "\\\""
txt += "stPublic = \"" + txtPublic + "\","
txtPrivate = substituteString txtPrivate "\\" "\\\\"
txtPrivate = substituteString txtPrivate "\"" "\\\""
txt += "stPrivate = \"" + txtPrivate + "\","
fixtxtClose = substituteString txtClose "\\" "\\\\"
fixtxtClose = substituteString fixtxtClose "\"" "\\\""
txt += "stClose = \"" + fixtxtClose + "\","
fixstInheritFN = substituteString this.stInheritFN "\\" "\\\\"
fixstInheritFN = substituteString fixstInheritFN "\"" "\\\""
txt += "stInheritFN = \"" + fixstInheritFN + "\","
txt += "on create do (" + txtClose + "))"
derivedClass = execute txt
),
--------------------------------------------------------
private
-- Private Struct Data and Functions
_parentVar_01 = 10,
-- FOR INHERITANCE
------------------------------------------
-- Data needed for inheritance
-- Must fill for each parent and child (it's a copy of struct definition)
stHeader = "parentStruct",
stPublic =
"
parentVar_01,
parentVar_02 = 5,
parentVar_03 = \"Hello\",
fn parentFN_01 = parentVar_01 * parentVar_02,
fn parentFN_02 data = data * 3 * this._parentVar_01,
",
stPrivate =
"
_parentVar_01 = 10,
",
stClose = "",
--------------------------------------
-- Fixed data and functions ONLY for first parent
stInheritFN =
"
fn _getHeader = this.stHeader,
fn _getPublic = this.stPublic,
fn _getPrivate = this.stPrivate,
fn _getClose = this.stClose,
fn _createDerivedClass child=
(
txtPublic = this.stPublic + child._getPublic()
txtPrivate = this.stPrivate + child._getPrivate()
txtClose = this.stClose + \"\\n\" + child._getClose()
txt = \"struct \" + child._getHeader() + \"(\"
txt += txtPublic
txt += this.stInheritFN
txt += \"private \" + txtPrivate
txt += \"stHeader = \\\"\" + child._getHeader() + \"\\\",\"
txtPublic = substituteString txtPublic \"\\\\\" \"\\\\\\\\\"
txtPublic = substituteString txtPublic \"\\\"\" \"\\\\\\\"\"
txt += \"stPublic = \\\"\" + txtPublic + \"\\\",\"
txtPrivate = substituteString txtPrivate \"\\\\\" \"\\\\\\\\\"
txtPrivate = substituteString txtPrivate \"\\\"\" \"\\\\\\\"\"
txt += \"stPrivate = \\\"\" + txtPrivate + \"\\\",\"
fixtxtClose = substituteString txtClose \"\\\\\" \"\\\\\\\\\"
fixtxtClose = substituteString fixtxtClose \"\\\"\" \"\\\\\\\"\"
txt += \"stClose = \\\"\" + fixtxtClose + \"\\\",\"
fixstInheritFN = substituteString this.stInheritFN \"\\\\\" \"\\\\\\\\\"
fixstInheritFN = substituteString fixstInheritFN \"\\\"\" \"\\\\\\\"\"
txt += \"stInheritFN = \\\"\" + fixstInheritFN + \"\\\",\"
txt += \"on create do (\" + txtClose + \"))\"
derivedClass = execute txt
),
",
-------------------------------
on create do ()
)
parentStruct = parentStruct()
struct ChildStruct
(
childVar_01,
childVar_02 = 7,
fn childFN_01 = childVar_01 * childVar_02,
-- FOR INHERITANCE
-------------------------------------------------
-- Inherit Functions (Fixed, always the same for parent and children)
fn _getHeader = this.stHeader,
fn _getPublic = this.stPublic,
fn _getPrivate = this.stPrivate,
fn _getClose = this.stClose,
-------------------------------------------------
private
-- FOR INHERITANCE
------------------------------------------
-- Data needed for inheritance
-- Must fill for each parent and child (it's a copy of struct definition)
stHeader = "ChildStruct",
stPublic =
"
childVar_01,
childVar_02 = 7,
fn childFN_01 = childVar_01 * childVar_02,
",
stPrivate = "",
stClose =
"
print childVar_02
print \"Creating\"
",
------------------------------------------
on create do
(
print childVar_02
print "Creating"
)
)
ChildStruct = ChildStruct()
completeChildStruct = parentStruct._createDerivedClass ChildStruct
completeChildStruct = completeChildStruct()
struct subChildStruct
(
subchildVar_01 = 55,
-- FOR INHERITANCE
-------------------------------------------------
-- Inherit Functions (Fixed, always the same for parent and children)
fn _getHeader = this.stHeader,
fn _getPublic = this.stPublic,
fn _getPrivate = this.stPrivate,
fn _getClose = this.stClose,
-------------------------------------------------
private
_subchildVar_01 = 66,
-- FOR INHERITANCE
------------------------------------------
-- Data needed for inheritance
-- Must fill for each parent and child (it's a copy of struct definition)
stHeader = "subChildStruct",
stPublic =
"
subchildVar_01 = 55,
",
stPrivate =
"
_subchildVar_01 = 66,
",
stClose =
"
",
------------------------------------------
on create do
(
)
)
subChildStruct = subChildStruct()
RecompleteChildStruct = completeChildStruct._createDerivedClass subChildStruct
RecompleteChildStruct = RecompleteChildStruct()
[code]