/test/lib/foreign_interface/test_fi01.e

http://github.com/tybor/Liberty · Specman e · 37 lines · 27 code · 9 blank · 1 comment · 0 complexity · cd257c6396d0f9d0ca73b6bedb9566fb MD5 · raw file

  1. class TEST_FI01
  2. insert
  3. EIFFELTEST_TOOLS
  4. create {}
  5. make
  6. feature {}
  7. value: INTEGER_32 17
  8. callback_value: INTEGER
  9. make
  10. local
  11. a: FOREIGN_AGENT
  12. p: FOREIGN_PARAMETERS
  13. v: FOREIGN_TYPED_OBJECT[INTEGER_32]
  14. do
  15. -- Eiffel idiosyncracy: when calling an Eiffel feature, add Current's pointer as the first parameter
  16. create {FOREIGN_EXTERNAL_FUNCTION} a.make($callback, {FAST_ARRAY[FOREIGN_TYPE] << types.pointer, types.sint32 >>}, types.sint32)
  17. p.set({FAST_ARRAY[FOREIGN_OBJECT] << types.create_pointer(to_pointer), types.create_sint32(value) >>})
  18. v ::= a.item(p)
  19. assert(callback_value = value)
  20. assert(v.item = value)
  21. end
  22. types: FOREIGN_TYPES
  23. callback (v: like value): INTEGER
  24. do
  25. callback_value := v
  26. Result := v
  27. end
  28. end