/src/wrappers/glib/library/utilities/g_option_boolean_entry.e

http://github.com/tybor/Liberty · Specman e · 75 lines · 49 code · 15 blank · 11 comment · 2 complexity · d86a26fc470b59f4b02341c9de1c81b4 MD5 · raw file

  1. indexing
  2. description: "."
  3. copyright: "[
  4. Copyright (C) 2007 Paolo Redaelli, Glib developers
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hopeOA that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class G_OPTION_BOOLEAN_ENTRY
  19. -- A boolean GOptionEntry.
  20. inherit
  21. G_OPTION_ENTRY redefine make, fill_tagged_out_memory end
  22. -- TODO: this should be a REFERENCE[BOOLEAN], but it is not easily
  23. -- implementable because REFERENCE's item is an effective attribute
  24. -- while the option entry at C level in an integer. The following
  25. -- inheriting clauses may be needed: undefine copy redefine is_equal,
  26. -- item, set_item, fill_tagged_out_memory end
  27. creation make
  28. feature
  29. make (a_long_name: STRING; a_short_name: CHARACTER; a_description: STRING) is
  30. local t: like argument_type
  31. do
  32. Precursor (a_long_name,a_short_name, a_description)
  33. t.set_none
  34. goption_entry_struct_set_arg(handle, t.value)
  35. goption_entry_struct_set_arg_data(handle, $hidden_value)
  36. end
  37. feature
  38. -- is_equal (another: like Current): BOOLEAN is
  39. -- do
  40. -- Result := item=another.item
  41. -- end
  42. item: BOOLEAN is
  43. do
  44. Result:=hidden_value.to_boolean
  45. end
  46. set_item(a_boolean: like item) is
  47. do
  48. hidden_value:=a_boolean.to_integer
  49. end
  50. fill_tagged_out_memory is
  51. do
  52. Precursor
  53. item.append_in(tagged_out_memory)
  54. end
  55. feature {} -- Implementation
  56. hidden_value: INTEGER
  57. invariant
  58. boolean: argument_type.is_none
  59. -- Note: the name picked in Glib is quite a poor choice....
  60. end -- class G_OPTION_BOOLEAN_ENTRY