Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,5 @@
on extendAbstractClass (instance, abstractClass)
-- 'raw' instance of abstract class is made parent ("ancestor") of the
-- passed instance, i.e. the passed instance extends the abstract class
instance.setProp(#ancestor, abstractClass.rawNew())
end

View file

@ -0,0 +1,12 @@
-- instantiation of abstract class by calling its constructor fails
on new (me)
-- optional: show error message as alert
_player.alert("Error:"&&me.script&&" is an abstract class")
return VOID
end
on ring (me, n)
repeat with i = 1 to n
put me.ringtone
end repeat
end

View file

@ -0,0 +1,11 @@
property ringtone
on new (me)
extendAbstractClass(me, script("AbstractClass"))
me.ringtone = "Bell"
return me
end
on foo (me)
put "FOO"
end

View file

@ -0,0 +1,10 @@
obj = script("MyClass").new()
obj.ring(3)
-- "Bell"
-- "Bell"
-- "Bell"
-- this fails
test = script("AbstractClass").new()
put test
-- <Void>

View file

@ -0,0 +1,12 @@
on implementsInterface (instance, interfaceClass)
interfaceFuncs = interfaceClass.handlers()
funcs = instance.handlers()
repeat with f in interfaceFuncs
if funcs.getPos(f)=0 then
-- optional: show error message as alert
_player.alert("Error:"&&instance.script&&"doesn't implement interface"&&interfaceClass)
return FALSE
end if
end repeat
return TRUE
end

View file

@ -0,0 +1,3 @@
on foo
on bar
on foobar

View file

@ -0,0 +1,20 @@
on new (me)
-- if this class doesn't implement all functions of the
-- interface class, instantiation fails
if not implementsInterface(me, script("InterfaceClass")) then
return VOID
end if
return me
end
on foo (me)
put "FOO"
end
on bar (me)
put "BAR"
end
on foobar (me)
put "FOOBAR"
end

View file

@ -0,0 +1,3 @@
obj = script("MyClass").new()
put obj -- would show <Void> if interface is not fully implemented
-- <offspring "MyClass" 2 171868>