/src/wrappers/gobject/library/g_flags.e
Specman e | 357 lines | 28 code | 121 blank | 208 comment | 2 complexity | 076c5b69b834e02c8a6d3f43fa2383a1 MD5 | raw file
1indexing 2 description: "Flags type." 3 copyright: "[ 4 Copyright (C) 2006 eiffel-libraries team, GTK+ team 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 hope 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 22 23deferred class G_FLAGS 24 -- The GLib type system provides fundamental types for enumeration 25 -- and flags types. (Flags types are like enumerations, but allow 26 -- their values to be combined by bitwise or). A registered 27 -- enumeration or flags type associates a name and a nickname with 28 -- each allowed value, and the methods g_enum_get_value_by_name(), 29 -- g_enum_get_value_by_nick(), g_flags_get_value_by_name() and 30 -- g_flags_get_value_by_nick() can look up values by their name or 31 -- nickname. When an enumeration or flags type is registered with 32 -- the GLib type system, it can be used as value type for object 33 -- properties, using g_param_spec_enum() or g_param_spec_flags(). 34 35 -- GObject ships with a utility called glib-mkenums that can 36 -- construct suitable type registration functions from C 37 -- enumeration definitions. 38inherit 39 40 G_FLAGS_EXTERNALS 41 C_STRUCT 42 43feature -- size 44 struct_size: INTEGER is 45 external "C inline use <gtk/gtk.h>" 46 alias "sizeof(GFlags)" 47 end 48 49feature {} -- Creation 50 -- G_ENUM_CLASS_TYPE() 51 52 -- #define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) 53 54 -- Returns the type identifier from a given GEnumClass structure. 55 56 -- class : a GEnumClass 57 58 -- ------------------------------------------------------------------------ 59 60 -- G_ENUM_CLASS_TYPE_NAME() 61 62 -- #define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class))) 63 64 -- Returns the static type name from a given GEnumClass structure. 65 66 -- class : a GEnumClass 67 68 -- ------------------------------------------------------------------------ 69 70 -- G_TYPE_IS_ENUM() 71 72 -- #define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM) 73 74 -- Returns whether type "is a" G_TYPE_ENUM. 75 76 -- type : a GType ID. 77 78 -- ------------------------------------------------------------------------ 79 80 -- G_ENUM_CLASS() 81 82 -- #define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass)) 83 84 -- Casts a derived GEnumClass structure into a GEnumClass structure. 85 86 -- class : a valid GEnumClass 87 88 -- ------------------------------------------------------------------------ 89 90 -- G_IS_ENUM_CLASS() 91 92 -- #define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM)) 93 94 -- Checks whether class "is a" valid GEnumClass structure of type 95 -- G_TYPE_ENUM or derived. 96 97 -- class : a GEnumClass 98 99 -- ------------------------------------------------------------------------ 100 101 -- G_TYPE_IS_FLAGS() 102 103 -- #define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS) 104 105 -- Returns whether type "is a" G_TYPE_FLAGS. 106 107 -- type : a GType ID. 108 109 -- ------------------------------------------------------------------------ 110 111 -- G_FLAGS_CLASS() 112 113 -- #define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass)) 114 115 -- Casts a derived GFlagsClass structure into a GFlagsClass structure. 116 117 -- class : a valid GFlagsClass 118 119 -- ------------------------------------------------------------------------ 120 121 -- G_IS_FLAGS_CLASS() 122 123 -- #define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS)) 124 125 -- Checks whether class "is a" valid GFlagsClass structure of type 126 -- G_TYPE_FLAGS or derived. 127 128 -- class : a GFlagsClass 129 130 -- ------------------------------------------------------------------------ 131 132 -- G_FLAGS_CLASS_TYPE() 133 134 -- #define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) 135 136 -- Returns the type identifier from a given GFlagsClass structure. 137 138 -- class : a GFlagsClass 139 140 -- ------------------------------------------------------------------------ 141 142 -- G_FLAGS_CLASS_TYPE_NAME() 143 144 -- #define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class))) 145 146 -- Returns the static type name from a given GFlagsClass structure. 147 148 -- class : a GFlagsClass 149 150 -- ------------------------------------------------------------------------ 151 152 -- GEnumValue 153 154 -- typedef struct { 155 -- gint value; 156 -- gchar *value_name; 157 -- gchar *value_nick; 158 -- } GEnumValue; 159 160 -- A structure which contains a single enum value, it's name, and it's 161 -- nickname. 162 163 -- gint value; the enum value 164 -- gchar *value_name; the name of the value 165 -- gchar *value_nick; the nickname of the value 166 167 -- ------------------------------------------------------------------------ 168 169 -- GFlagsValue 170 171 -- typedef struct { 172 -- guint value; 173 -- gchar *value_name; 174 -- gchar *value_nick; 175 -- } GFlagsValue; 176 177 -- A structure which contains a single flags value, it's name, and it's 178 -- nickname. 179 180 -- guint value; the flags value 181 -- gchar *value_name; the name of the value 182 -- gchar *value_nick; the nickname of the value 183 184 -- ------------------------------------------------------------------------ 185 186 -- g_enum_get_value () 187 188 -- GEnumValue* g_enum_get_value (GEnumClass *enum_class, 189 -- gint value); 190 191 -- Returns the GEnumValue for a value. 192 193 -- enum_class : a GEnumClass 194 -- value : the value to look up 195 -- Returns : the GEnumValue for value, or NULL if value is not a member 196 -- of the enumeration 197 198 -- ------------------------------------------------------------------------ 199 200 -- g_enum_get_value_by_name () 201 202 -- GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class, 203 -- const gchar *name); 204 205 -- Looks up a GEnumValue by name. 206 207 -- enum_class : a GEnumClass 208 -- name : the name to look up 209 -- Returns : the GEnumValue with name name, or NULL if the enumeration 210 -- doesn' t have a member with that name 211 212 -- ------------------------------------------------------------------------ 213 214 -- g_enum_get_value_by_nick () 215 216 -- GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class, 217 -- const gchar *nick); 218 219 -- Looks up a GEnumValue by nickname. 220 221 -- enum_class : a GEnumClass 222 -- nick : the nickname to look up 223 -- Returns : the GEnumValue with nickname nick, or NULL if the 224 -- enumeration doesn' t have a member with that nickname 225 226 -- ------------------------------------------------------------------------ 227 228 -- g_flags_get_first_value () 229 230 -- GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class, 231 -- guint value); 232 233 -- Returns the first GFlagsValue which is set in value. 234 235 -- flags_class : a GFlagsClass 236 -- value : the value 237 -- Returns : the first GFlagsValue which is set in value, or NULL if 238 -- none is set 239 240 -- ------------------------------------------------------------------------ 241 242 -- g_flags_get_value_by_name () 243 244 -- GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, 245 -- const gchar *name); 246 247 -- Looks up a GFlagsValue by name. 248 249 -- flags_class : a GFlagsClass 250 -- name : the name to look up 251 -- Returns : the GFlagsValue with name name, or NULL if there is no 252 -- flag with that name 253 254 -- ------------------------------------------------------------------------ 255 256 -- g_flags_get_value_by_nick () 257 258 -- GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, 259 -- const gchar *nick); 260 261 -- Looks up a GFlagsValue by nickname. 262 263 -- flags_class : a GFlagsClass 264 -- nick : the nickname to look up 265 -- Returns : the GFlagsValue with nickname nick, or NULL if there is no 266 -- flag with that nickname 267 268 -- ------------------------------------------------------------------------ 269 270 -- g_enum_register_static () 271 272 -- GType g_enum_register_static (const gchar *name, 273 -- const GEnumValue *const_static_values); 274 275 -- Registers a new static enumeration type with the name name. 276 277 -- It is normally more convenient to let glib-mkenums generate a 278 -- my_enum_get_type() function from a usual C enumeration definition than 279 -- to write one yourself using g_enum_register_static(). 280 281 -- name : A nul-terminated string used as the name of the 282 -- new type. 283 -- const_static_values : An array of GEnumValue structs for the possible 284 -- enumeration values. The array is terminated by a 285 -- struct with all members being 0. 286 -- Returns : The new type identifier. 287 288 -- ------------------------------------------------------------------------ 289 290 -- g_flags_register_static () 291 292 -- GType g_flags_register_static (const gchar *name, 293 -- const GFlagsValue *const_static_values); 294 295 -- Registers a new static flags type with the name name. 296 297 -- It is normally more convenient to let glib-mkenums generate a 298 -- my_flags_get_type() function from a usual C enumeration definition than 299 -- to write one yourself using g_flags_register_static(). 300 301 -- name : A nul-terminated string used as the name of the 302 -- new type. 303 -- const_static_values : An array of GFlagsValue structs for the possible 304 -- flags values. The array is terminated by a struct 305 -- with all members being 0. 306 -- Returns : The new type identifier. 307 308 -- ------------------------------------------------------------------------ 309 310 -- g_enum_complete_type_info () 311 312 -- void g_enum_complete_type_info (GType g_enum_type, 313 -- GTypeInfo *info, 314 -- const GEnumValue *const_values); 315 316 -- This function is meant to be called from the complete_type_info() 317 -- function of a GTypePlugin implementation, as in the following example: 318 319 -- static void 320 -- my_enum_complete_type_info (GTypePlugin *plugin, 321 -- GType g_type, 322 -- GTypeInfo *info, 323 -- GTypeValueTable *value_table) 324 -- { 325 -- static const GEnumValue values[] = { 326 -- { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" }, 327 -- { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" }, 328 -- { 0, NULL, NULL } 329 -- }; 330 331 -- g_enum_complete_type_info (type, info, values); 332 -- } 333 334 -- g_enum_type : the type identifier of the type being completed 335 -- info : the GTypeInfo struct to be filled in 336 -- const_values : An array of GEnumValue structs for the possible 337 -- enumeration values. The array is terminated by a struct 338 -- with all members being 0. 339 340 -- ------------------------------------------------------------------------ 341 342 -- g_flags_complete_type_info () 343 344 -- void g_flags_complete_type_info (GType g_flags_type, 345 -- GTypeInfo *info, 346 -- const GFlagsValue *const_values); 347 348 -- This function is meant to be called from the complete_type_info() 349 -- function of a GTypePlugin implementation, see the example for 350 -- g_enumeration_complete_type_info() above. 351 352 -- g_flags_type : the type identifier of the type being completed 353 -- info : the GTypeInfo struct to be filled in 354 -- const_values : An array of GFlagsValue structs for the possible 355 -- enumeration values. The array is terminated by a struct 356 -- with all members being 0. 357end -- G_FLAGS