PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/external/C++/example3.e

http://github.com/tybor/Liberty
Specman e | 50 lines | 28 code | 6 blank | 16 comment | 0 complexity | 60bc177c9a5964b08241497293a5ddef MD5 | raw file
 1class EXAMPLE3
 2   --
 3   -- How to compile :
 4   --                   g++ -c Bar.cpp
 5   --                   compile -o example3 example3 Bar.o
 6   --
 7   -- As well as :
 8   --                   compile -o example3 example3 Bar.cpp
 9   --
10
11create {ANY}
12   make
13
14feature {ANY}
15   make
16      local
17         bar_pointer: POINTER
18      do
19         bar_pointer := new_bar('x')
20         do_print(3)
21         delete_bar(bar_pointer)
22      end
23
24   new_bar (c: CHARACTER): POINTER
25         -- Creation of a C++ `Bar' object. The file "Bar.h" must be
26         -- #included and the C++ creation function has one argument
27         -- (matching with `c') of type EIF_CHARACTER (matching with
28         -- CHARACTER).
29      external "[
30                 C++ [new Bar "Bar.h"] (EIF_CHARACTER)
31               ]"
32      end
33
34   do_print (i: INTEGER)
35         -- Calling static `Bar::do_print' passing `i' as argument. The file
36         -- "Bar.h" must be #included (if not yet done).
37      external "[
38                 C++ [static Bar "Bar.h" ] (EIF_INTEGER)
39               ]"
40      end
41
42   delete_bar (bar_pointer: POINTER)
43         -- Calling C++ delete of class `Bar' on `bar_pointer'. The file
44         -- "Bar.h" must be #included (if not yet done).
45      external "[
46                 C++ [delete Bar "Bar.h"] ()
47               ]"
48      end
49
50end -- class EXAMPLE3