/tutorial/cecil/string/example.e

http://github.com/tybor/Liberty · Specman e · 36 lines · 18 code · 4 blank · 14 comment · 0 complexity · ac9b3b30843c603902105b7dc2666cd5 MD5 · raw file

  1. class EXAMPLE
  2. --
  3. -- The Eiffel program is running first, creates an empty STRING which is passed to the C world.
  4. -- The C program then modifies the Eiffel STRING calling the Eiffel feature `extend' of class STRING.
  5. -- Finally, the modified STRING is printed.
  6. --
  7. -- To compile this example, use command:
  8. --
  9. -- se c -cecil cecil.se example c_prog.c
  10. --
  11. -- Is is also possible to C precompile the c_prog.c file doing:
  12. --
  13. -- gcc -c c_prog.c
  14. -- se c -cecil cecil.se example c_prog.o
  15. --
  16. create {ANY}
  17. make
  18. feature {ANY}
  19. make
  20. local
  21. string: STRING
  22. do
  23. create string.make(0)
  24. call_c_prog(string)
  25. io.put_string(string)
  26. end
  27. feature {}
  28. call_c_prog (str: STRING)
  29. external "C"
  30. alias "c_prog"
  31. end
  32. end -- class EXAMPLE