/src/wrappers/common/attic/dummy_factory.e

http://github.com/tybor/Liberty · Specman e · 46 lines · 24 code · 5 blank · 17 comment · 0 complexity · 9eb7d9dfc25c2d0d020e26fad26743b4 MD5 · raw file

  1. note
  2. description:
  3. "Dummy wrapper factory."
  4. copyright:
  5. "(C) 2007 Paolo Redaelli"
  6. license:
  7. "LGPL v2 or later"
  8. date:
  9. "$Date:$"
  10. revision:
  11. "$Revision:$"
  12. class DUMMY_FACTORY[ITEM_ -> SHARED_C_STRUCT]
  13. -- A dummy factory.
  14. -- Sometimes a wrapper needs to convert an Eiffel COLLECTION into
  15. -- an array to be passed to the underlying C library; it is useful
  16. -- for such an array to be implemented using C_ARRAY or
  17. -- NULL_TERMINATED_C_ARRAY, so that memory is handled by the
  18. -- Garbage Collector. They expect to be provided a wrapper factory
  19. -- to use to create new wrappers from the pointers retrieved from
  20. -- the underlying array.
  21. -- Note: when the called function take property of the array it
  22. -- wrond to use this design. The Eiffel GC will soon free the array
  23. -- robbing it from function it belongs to and causing horrible
  24. -- crashes. Paolo 2007-09-02
  25. inherit
  26. WRAPPER_FACTORY[ITEM_]
  27. create {ANY}
  28. default_create
  29. feature {WRAPPER, WRAPPER_HANDLER} -- Implementation
  30. wrapper (a_pointer: POINTER): ITEM_
  31. -- A wrapper for the structure at address `a_pointer'. The
  32. -- default implementation in WRAPPER_FACTORY "creates" a new
  33. -- wrapper every time, while their heirs are allowed to
  34. -- provide implementations that fits better to peculiar
  35. -- memory handling schemes.
  36. do
  37. raise(do_not_use_me)
  38. end
  39. feature {} --
  40. do_not_use_me: STRING "DUMMY_FACTORY.wrapper invoked. This is clearly a bug; please inform the developers of the application, since another implementation of WRAPPER_FACTORY should be used."
  41. end -- class DUMMY_FACTORY