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