First commit!
This commit is contained in:
commit
573d2da85e
5 changed files with 175 additions and 0 deletions
7
example/Example.shn
Normal file
7
example/Example.shn
Normal 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
12
example/Object.shc
Normal 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
16
example/script.sh
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue