First commit!

This commit is contained in:
Adsooi 2021-12-28 00:44:16 +01:00
commit 573d2da85e
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
5 changed files with 175 additions and 0 deletions

7
example/Example.shn Normal file
View file

@ -0,0 +1,7 @@
# Namespace declaration.
namespace Example
# If namespace is set to null (no argument), then the object will be declared globally.
# Otherwise, the object will be declared within the namespace.
# Object declaration, from class name to file name.
class Object "Object.shc"

12
example/Object.shc Normal file
View file

@ -0,0 +1,12 @@
# Property declaration
property Object.name
# Optional constructor.
Object.constructor() {
Object.name = $1
}
# Example function
Object.print() {
echo "Example OOP from $(this.name)!"
}

16
example/script.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
OOP_ROOT=..
. $OOP_ROOT/oop.sh # Import library.
importNamespace Example.shn
Example.Object t1 "Test"
Example.Object t2 "Example"
t1.print
t2.print
t1.name = "New name"
t1.print