summaryrefslogtreecommitdiffstats
path: root/doc/scriptexamples/class1.kvs
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
commita6d58bb6052ac8cb01805a48c4ad2f129126116f (patch)
treedd867a099fcbb263a8009a9fb22695b87855dad6 /doc/scriptexamples/class1.kvs
downloadkvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.tar.gz
kvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.zip
Added KDE3 version of kvirc
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'doc/scriptexamples/class1.kvs')
-rw-r--r--doc/scriptexamples/class1.kvs102
1 files changed, 102 insertions, 0 deletions
diff --git a/doc/scriptexamples/class1.kvs b/doc/scriptexamples/class1.kvs
new file mode 100644
index 00000000..6098000d
--- /dev/null
+++ b/doc/scriptexamples/class1.kvs
@@ -0,0 +1,102 @@
+# Example of object function overriding and calling
+# This is quite intricated...try to get out of this
+# by examining the code.
+
+class (A,object)
+{
+ # The base class at all
+ # Implements $A::function and $A::virtual
+ function
+ {
+ echo -i=10 "$0\Entering A::function()"
+ $$->$virtual("----$0")
+ echo -i=10 "$0\Exiting A::function()"
+ }
+ virtual
+ {
+ echo -i=10 "$0\This is A::virtual()"
+ }
+}
+
+class (B,A)
+{
+ # Derived from A : inherits $A::function()
+ # overrides $A::virtual
+ virtual
+ {
+ echo -i=20 "$0\Entering B::virtual()"
+ $$->$A::virtual("----$0")
+ echo -i=20 "$0\Exiting B::virtual()"
+ }
+}
+
+class (C,B)
+{
+ # Derived from B : inherits $B::virtual and
+ # overrides $B::function (that is $A::function)
+ function
+ {
+ echo -i=30 "$0\This is C::function"
+ }
+}
+
+echo -i=7 "Ok...now try to gusess what's going on :)"
+
+%o = $new(C,0,test)
+
+echo "# Calling \%o->\$function"
+%o->$function
+echo "# Calling \%o->\$C::function"
+%o->$C::function
+echo "# Calling \%o->\$B::function"
+%o->$B::function
+echo "# Calling \%o->\$A::function"
+%o->$A::function
+echo "# Implementing private \%o->\$function"
+privateimpl(%o,function)
+{
+ # This is a private implementation that
+ # overrides $C::function
+ echo "$0\Entering \$\$::function"
+ $$->$C::function("----$0");
+ echo "$0\Exiting \$\$::function"
+}
+
+echo "# Calling \%o->\$function"
+%o->$function
+echo "# Calling \%o->\$C::function"
+%o->$C::function
+echo "# Calling \%o->\$B::function"
+%o->$B::function
+echo "# Calling \%o->\$A::function"
+%o->$A::function
+echo "# Implementing private \%o->\$virtual"
+privateimpl(%o,virtual)
+{
+ # This is a private implementation that
+ # overrides $C::virtual (that is $B::virtual in fact)
+ echo "$0\Entering \$\$::virtual"
+ $$->$C::virtual("----$0")
+ echo "$0\Exiting \$\$::virtual"
+}
+
+echo "# Calling \%o->\$function"
+%o->$function
+echo "# Calling \%o->\$C::function"
+%o->$C::function
+echo "# Calling \%o->\$B::function"
+%o->$B::function
+echo "# Calling \%o->\$A::function"
+%o->$A::function
+echo "# Removing private \%o->\$function"
+privateimpl(%o,function){}
+echo "# Calling \%o->\$function"
+%o->$function
+echo "# Calling \%o->\$C::function"
+%o->$C::function
+echo "# Calling \%o->\$B::function"
+%o->$B::function
+echo "# Calling \%o->\$A::function"
+%o->$A::function
+
+delete %o