Adding proper signatures.

This commit is contained in:
Adsooi 2022-01-01 16:39:35 +01:00
parent 8d92cad720
commit c9ba5c03f0
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160

30
oop.sh
View file

@ -29,8 +29,8 @@ declare -Ag _namespacesClasses
# This dictionnary links all files for static namespaces. # This dictionnary links all files for static namespaces.
declare -Ag _namespacesStaticClasses declare -Ag _namespacesStaticClasses
# Namespace declaration. # Declares the current namespace.
# Signature: ([string namespaceName]) # Signature: ([string namespaceName]) -> void
namespace() { namespace() {
_namespace=$1; _namespace=$1;
} }
@ -40,7 +40,7 @@ namespace() {
# properly resolved. # properly resolved.
# For example, if the object Object exists within namespace Example, it # For example, if the object Object exists within namespace Example, it
# will be accessible with "Example.Object". # will be accessible with "Example.Object".
# Signature: (<string namespaceFile>) # Signature: (<string namespaceFile>) -> void
importNamespace() { importNamespace() {
namespaceFile=$1 namespaceFile=$1
# Save the path in order to get the absolute path of the file. # Save the path in order to get the absolute path of the file.
@ -51,7 +51,7 @@ importNamespace() {
# Aliases the classes in global namespace. # Aliases the classes in global namespace.
# For example, if the object Object exists within namespace Example, it # For example, if the object Object exists within namespace Example, it
# will be accessible with "Example.Object" and "Object". # will be accessible with "Example.Object" and "Object".
# Signature: (<string namespaceName>) # Signature: (<string namespaceName>) -> void
using() { using() {
namespaceName=$1 namespaceName=$1
# Import static classes # Import static classes
@ -79,14 +79,14 @@ using() {
# A "property holder" is a dictionnary maintaining the values of properties for a specific variable. # A "property holder" is a dictionnary maintaining the values of properties for a specific variable.
# One is created each time an object is declared, but this function can also be used for namespaces to have global # One is created each time an object is declared, but this function can also be used for namespaces to have global
# properties. # properties.
# Signature: (<string name>) # Signature: (<string name>) -> void
createPropertyHolder() { createPropertyHolder() {
name=$1 name=$1
eval "declare -Ag _${name}_properties" eval "declare -Ag _${name}_properties"
} }
# Creates an object instance. # Creates an object instance of `type` in variable `variableName`.
# Signature: (<string type>, <string associatedFile>, <string variableName>, [string[] constructorArguments]) # Signature: (<string type>, <string associatedFile>, <string variableName>, [string[] constructorArguments]) -> void
_createObject() { _createObject() {
type=$1 type=$1
associatedFile=$2 associatedFile=$2
@ -108,8 +108,8 @@ _createObject() {
$varName.constructor $constructorArguments $varName.constructor $constructorArguments
} }
# Object creation. # Declares a new class named `type` in the current namespace being defined in `associatedFile`.
# Signature: (<string type>, <string associatedFile>) # Signature: (<string type>, <string associatedFile>) -> void
class() { class() {
type=$1 # Type of the object as declared within the file. type=$1 # Type of the object as declared within the file.
associatedFile=$2 associatedFile=$2
@ -134,8 +134,8 @@ class() {
fi fi
} }
# Static class creation # Declares a new static class named `type` in the current namespace being defined in `associatedFile`.
# Signature: (<string type>, <string associatedFile>) # Signature: (<string type>, <string associatedFile>) -> void
static_class() { static_class() {
type=$1 # Type of the object as declared within the file. type=$1 # Type of the object as declared within the file.
associatedFile=$2 associatedFile=$2
@ -161,8 +161,8 @@ static_class() {
fi fi
} }
# Associated function for properties # Gets or sets the value of the property `propertyName` of an object set to variable `variableName`.
# Signature: (<string variableName>, <string propertyName>, [string operator, string value]) # Signature: (<string variableName>, <string propertyName>, [string operator, string value]) -> string|void
_accessProperty() { _accessProperty() {
varName=$1 varName=$1
prop=$2 prop=$2
@ -174,8 +174,8 @@ _accessProperty() {
fi fi
} }
# Declares a property with an optional default value. # Declares a property `propertyFullName` with an optional default value `propertyValue`.
# Signature: (<string propertyFullName>, [string propertyValue]) # Signature: (<string propertyFullName>, [string propertyValue]) -> void
property() { property() {
propertyFullName=$1 propertyFullName=$1
propertyValue=$2 propertyValue=$2