PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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