From 32853941a7fe190273edeb2444d5ac5e3e2a23b0 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Wed, 29 Dec 2021 13:12:31 +0100 Subject: [PATCH] Adding type and source default functions to give better representation of the origin of the object. --- oop.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/oop.sh b/oop.sh index c34f1ab..cde76bc 100644 --- a/oop.sh +++ b/oop.sh @@ -69,14 +69,17 @@ _createObject() { # Declare dummy constructor. eval "$varName.constructor() { :; }" + # Declare base properties. + eval "$varName.type() { echo $type; }" + eval "$varName.source() { echo $associatedFile; }" # Create property array. eval "declare -Ag _${varName}_properties" + # alias the "varName" variable to itself, so that it can be used and transmitted in other variables (e.g: $varName.name would alias to varName.name) + eval "$varName='$varName'" # Imports the file and replace all "." with the variable name. . <(sed s/this\\./$varName./g <(sed s/$type\\./$varName./g $associatedFile)) # Call the constructor - eval "$varName.constructor $constructorArguments" - # alias the "varName" variable to itself, so that it can be used and transmitted in other variables (e.g: $varName.name would alias to varName.name) - eval "$varName='$varName'" + $varName.constructor $constructorArguments } # Object creation.