misc/vim: inform the user when no results are found
[nit.git] / examples / callback_chimpanze.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2013 Matthieu Lucas <lucasmatthieu@gmail.com>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # This sample has been implemented to show you how simple is it to play
18 # with native callbacks (C) through an high level with NIT program.
19
20 module callback_chimpanze
21 import callback_monkey
22
23 class Chimpanze
24 super MonkeyActionCallable
25
26 fun create
27 do
28 var monkey = new Monkey
29 print "Hum, I'm sleeping ..."
30 # Invoking method which will take some time to compute, and
31 # will be back in wokeUp method with information.
32 # - Callback method defined in MonkeyActionCallable Interface
33 monkey.wokeUpAction(self, "Hey, I'm awake.")
34 end
35
36 # Inherit callback method, defined by MonkeyActionCallable interface
37 # - Back of wokeUpAction method
38 redef fun wokeUp( sender:Monkey, message:Object )
39 do
40 print message
41 end
42 end
43
44 var m = new Chimpanze
45 m.create