/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

  1. class 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. create {ANY}
  11. make
  12. feature {ANY}
  13. make
  14. local
  15. bar_pointer: POINTER
  16. do
  17. bar_pointer := new_bar('x')
  18. do_print(3)
  19. delete_bar(bar_pointer)
  20. end
  21. new_bar (c: CHARACTER): POINTER
  22. -- Creation of a C++ `Bar' object. The file "Bar.h" must be
  23. -- #included and the C++ creation function has one argument
  24. -- (matching with `c') of type EIF_CHARACTER (matching with
  25. -- CHARACTER).
  26. external "[
  27. C++ [new Bar "Bar.h"] (EIF_CHARACTER)
  28. ]"
  29. end
  30. do_print (i: INTEGER)
  31. -- Calling static `Bar::do_print' passing `i' as argument. The file
  32. -- "Bar.h" must be #included (if not yet done).
  33. external "[
  34. C++ [static Bar "Bar.h" ] (EIF_INTEGER)
  35. ]"
  36. end
  37. delete_bar (bar_pointer: POINTER)
  38. -- Calling C++ delete of class `Bar' on `bar_pointer'. The file
  39. -- "Bar.h" must be #included (if not yet done).
  40. external "[
  41. C++ [delete Bar "Bar.h"] ()
  42. ]"
  43. end
  44. end -- class EXAMPLE3