/tutorial/external/C++/example2.e
Specman e | 72 lines | 42 code | 8 blank | 22 comment | 0 complexity | dbee19fe0e5893601656f51cad7161ff MD5 | raw file
1class EXAMPLE2 2 -- 3 -- How to compile: 4 -- g++ -c Foo.cpp 5 -- compile -o example2 example2 Foo.o 6 -- 7 -- As well as: 8 -- compile -o example2 example2 Foo.cpp 9 -- 10 11create {ANY} 12 make 13 14feature {ANY} 15 make 16 local 17 foo_pointer: POINTER 18 do 19 foo_pointer := new_foo 20 set_integer(foo_pointer, 3) 21 io.put_integer(get_integer(foo_pointer)) 22 io.put_new_line 23 set_real(foo_pointer, 3.0) 24 io.put_real(get_real(foo_pointer)) 25 io.put_new_line 26 end 27 28 new_foo: POINTER 29 -- Creation of a C++ `Foo' object. The file "Foo.h" must be 30 -- #included and the C++ creation function has no argument. 31 external "[ 32 C++ [new Foo "Foo.h"] () 33 ]" 34 end 35 36 set_integer (foo_pointer: POINTER; i: INTEGER) 37 -- Calling C++ `set_integer' member function of C++ class `Foo' 38 -- using `foo_pointer' as target. This member procedure as 39 -- an argument (matching with `i') of type EIF_INTEGER (which match 40 -- with INTEGER). The file "Foo.h" must be #included (if not 41 -- yet done). 42 external "[ 43 C++ [Foo "Foo.h"] (EIF_INTEGER) 44 ]" 45 end 46 47 get_integer (foo_pointer: POINTER): INTEGER 48 -- Calling a C++ `get_integer' member function using `foo_pointer' as 49 -- target. The file "Foo.h" must be #included (if not yet done). 50 external "[ 51 C++ [Foo "Foo.h"] (): int 52 ]" 53 end 54 55 set_real (foo_pointer: POINTER; r: REAL) 56 -- Calling `set_real' C++ member procedure using `foo_pointer' as target 57 -- and `r' as argument. The file "Foo.h" must be #included (if not 58 -- yet done). 59 external "[ 60 C++ [Foo "Foo.h"] (EIF_REAL) 61 ]" 62 end 63 64 get_real (foo_pointer: POINTER): REAL 65 -- Calling `get_real' C++ member function using `foo_pointer' as target. 66 -- The file "Foo.h" must be #included (if not yet done). 67 external "[ 68 C++ [Foo "Foo.h"] (): float 69 ]" 70 end 71 72end -- class EXAMPLE2