/tutorial/cecil/simple/example.e

http://github.com/tybor/Liberty · Specman e · 49 lines · 30 code · 6 blank · 13 comment · 0 complexity · 9ad603ff8c4d9c8f74aaf2fbcd3da354 MD5 · raw file

  1. class EXAMPLE
  2. --
  3. -- The Eiffel program is running first, then calls the C program which is in charge of calling the
  4. -- Eiffel feature `show_values' of this EXAMPLE class.
  5. --
  6. -- To compile this example, use command:
  7. --
  8. -- se c -cecil cecil.se example c_prog.c
  9. --
  10. -- Is is also possible to C precompile the c_prog.c file doing:
  11. --
  12. -- gcc -c c_prog.c
  13. -- se c -cecil cecil.se example c_prog.o
  14. --
  15. create {ANY}
  16. make
  17. feature {ANY}
  18. make
  19. do
  20. values := {ARRAY[INTEGER] 1, << 1, 2, 3 >> }
  21. call_c_prog(Current)
  22. end
  23. show_values
  24. local
  25. i: INTEGER
  26. do
  27. from
  28. i := values.lower
  29. until
  30. i > values.upper
  31. loop
  32. io.put_integer(values.item(i))
  33. io.put_new_line
  34. i := i + 1
  35. end
  36. end
  37. feature {}
  38. values: ARRAY[INTEGER]
  39. call_c_prog (current_object: like Current)
  40. external "C"
  41. alias "c_prog"
  42. end
  43. end -- class EXAMPLE