/tutorial/external/C/c_glue2.c

http://github.com/tybor/Liberty · C · 40 lines · 25 code · 9 blank · 6 comment · 0 complexity · e0bca70ea86bdd25445c06e0751cb14f MD5 · raw file

  1. /* Hand-written C code to be used with example2.e */
  2. #include <stdio.h>
  3. void write_integer_attribute(int*attribute) {
  4. /*
  5. Assume an Eiffel INTEGER is really mapped as a C int.
  6. Have a look is sys/runtime/base.h
  7. One can also use the -cecil interface to be always compatible.
  8. */
  9. *attribute=2;
  10. }
  11. void call_back_1(void* target, void*routine_ptr) {
  12. ((void (*)(void*))routine_ptr)(target);
  13. }
  14. int call_back_2(void* target, void*routine_ptr) {
  15. return (((int (*)(void*))routine_ptr)(target));
  16. }
  17. int call_back_3(void* target, void*routine_ptr, void*eiffel_string) {
  18. return (((int (*)(void*,void*))routine_ptr)(target,eiffel_string));
  19. }
  20. int call_back_4(void* target, void*routine_ptr, void*eiffel_string) {
  21. return (((int (*)(void*,void*,char))routine_ptr)(target,eiffel_string,'G'));
  22. }
  23. void call_back_5(void* target, void*routine_ptr) {
  24. (((void (*)(void*,void*))routine_ptr)(target,target));
  25. }
  26. void call_back_6(void* target, void*routine_ptr) {
  27. (((void (*)(void*))routine_ptr)(target));
  28. }
  29. int call_back_7(void* target, void*routine_ptr) {
  30. return ((((int (*)(void*))routine_ptr)(target)));
  31. }