/tutorial/cecil/integer/example.e

http://github.com/tybor/Liberty · Specman e · 36 lines · 24 code · 4 blank · 8 comment · 0 complexity · 36d22241aa0015d529cdd75f4f8a7a86 MD5 · raw file

  1. class EXAMPLE
  2. --
  3. -- The Eiffel program is running first, then calls the C program, which is in charge of adding
  4. -- two INTEGERs using the infix "+" feature of class INTEGER.
  5. --
  6. -- To compile this example, use command:
  7. --
  8. -- se c -cecil cecil.se example c_prog.c
  9. --
  10. create {ANY}
  11. make
  12. feature {ANY}
  13. make
  14. local
  15. i1, i2, sum: INTEGER
  16. do
  17. i1 := 2
  18. i2 := 3
  19. io.put_integer(i1)
  20. io.put_string(" + ")
  21. io.put_integer(i2)
  22. io.put_string(" = ")
  23. sum := call_c_prog(i1, i2)
  24. io.put_integer(sum)
  25. io.put_string("%N")
  26. end
  27. feature {}
  28. call_c_prog (i1, i2: INTEGER): INTEGER
  29. external "C"
  30. alias "c_prog"
  31. end
  32. end -- class EXAMPLE