/src/wrappers/gobject/library/g_param_spec.e

http://github.com/tybor/Liberty · Specman e · 1053 lines · 284 code · 243 blank · 526 comment · 3 complexity · a444c2faa81aa46c0405dce333ba11be MD5 · raw file

  1. indexing
  2. description: "GParamSpec, Metadata for parameter specifications"
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. Copyright (C) 2008 Raphael Mack
  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. This library is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. 02110-1301 USA
  18. ]"
  19. class G_PARAM_SPEC
  20. -- GParamSpec is an object structure that encapsulates the metadata
  21. -- required to specify parameters, such as e.g. GObject properties.
  22. -- Parameter names need to start with a letter (a-z or
  23. -- A-Z). Subsequent characters can be letters, numbers or a
  24. -- '-'. All other characters are replaced by a '-' during
  25. -- construction.
  26. -- Note: this class in an Eiffel-only design would have been deferred.
  27. -- It is used as a quicker way to handle parameter specification
  28. -- of unknown type without having to write a big inspect clause.
  29. -- When the parameter specification type is known it is better to
  30. -- use the correct heir; i.e. G_PARAM_SPEC_BOOLEAN.
  31. inherit
  32. C_STRUCT
  33. redefine
  34. from_external_pointer
  35. end
  36. MIXED_MEMORY_HANDLING
  37. -- TODO: check it C_OWNED is actually better.
  38. -- undefine from_external_pointer end
  39. insert
  40. G_PARAM_SPEC_EXTERNALS
  41. G_TYPE_EXTERNALS
  42. creation from_external_pointer
  43. feature -- Creation
  44. from_external_pointer (a_ptr: POINTER) is
  45. -- TODO: G_PARAM_SPEC should be deferred and its place should be taken by specialized heirs such as G_PARAM_SPEC_BOOLEAN
  46. do
  47. Precursor {C_STRUCT} (a_ptr)
  48. owner_class := g_type_class_peek (get_owner_type (a_ptr))
  49. param_id := get_param_id (a_ptr)
  50. end
  51. feature -- Flags
  52. flags: INTEGER is
  53. do
  54. Result := get_flags (handle)
  55. ensure are_valid_param_flags (Result)
  56. end
  57. is_readable: BOOLEAN is
  58. -- Is Current parameter readable?
  59. do
  60. Result:= (flags & g_param_readable).to_boolean
  61. end
  62. is_writable: BOOLEAN is
  63. -- Is Current parameter writable?
  64. do
  65. Result:= (flags & g_param_writable).to_boolean
  66. end
  67. is_set_at_construction: BOOLEAN is
  68. -- Will the parameter be set upon object construction?
  69. do
  70. Result:= (flags & g_param_construct).to_boolean
  71. end
  72. is_set_only_at_construction: BOOLEAN is
  73. -- Will the parameter only be set upon object construction?
  74. do
  75. Result:= (flags & g_param_construct_only).to_boolean
  76. end
  77. -- TODO: find a better, not-clashing name for is_readable: BOOLEAN
  78. -- is -- Is strict validation not required upon parameter
  79. -- conversion? (see `convert') do Result:=
  80. -- flags.bit_test(g_param_lax_validation_bit) end
  81. -- Doesn't work in GTK 2.6
  82. -- is_static_name: BOOLEAN is
  83. -- Is the string used as name when constructing the parameter
  84. -- guaranteed to remain valid and unmodified for the lifetime
  85. -- of the parameter?
  86. -- do
  87. -- Result:= (flags & g_param_static_name).to_boolean
  88. -- end
  89. -- Doesn't work in GTK 2.6
  90. -- is_static_blurb: BOOLEAN is
  91. -- Is the string used as blurb when constructing the parameter
  92. -- guaranteed to remain valid and unmodified for the lifetime
  93. -- of the parameter?
  94. -- do
  95. -- Result:= (flags & g_param_static_blurb).to_boolean
  96. -- end
  97. is_readwrite: BOOLEAN is
  98. -- Is parameter read/write?
  99. do
  100. Result := (flags & g_param_readwrite).to_boolean
  101. ensure definition: Result implies (is_readable and is_writable)
  102. end
  103. feature
  104. set_default (a_value: G_VALUE) is
  105. -- Sets `a_value' to its default value as specified in Current.
  106. require valid_value: a_value /= Void
  107. -- TODO a GValue of correct type for current
  108. do
  109. g_param_value_set_default (handle, a_value.handle)
  110. end
  111. is_default_value (a_value: G_VALUE): BOOLEAN is
  112. -- Does `a_value' contains the default value specified in
  113. -- Current?
  114. require
  115. value_not_void: a_value /= Void
  116. correct_value_type: a_value.type = value_gtype
  117. do
  118. Result:=(g_param_value_defaults(handle,a_value.handle)).to_boolean
  119. end
  120. validate (a_value: G_VALUE): BOOLEAN is
  121. -- Has `a_value' to be changed to comply with the
  122. -- specifications set out by Current? For example, a
  123. -- G_PARAM_SPEC_INT might require that integers stored in
  124. -- value may not be smaller than -42 and not be greater than
  125. -- +42. If value contains an integer outside of this range,
  126. -- it is modified accordingly, so the resulting value will
  127. -- fit into the range -42 .. +42.
  128. require valid_value: a_value /= Void
  129. -- TODO a GValue of correct type for current
  130. do
  131. Result:=(g_param_value_validate(handle,a_value.handle)).to_boolean
  132. end
  133. convert (a_source, a_destination: G_VALUE; strict_validation: BOOLEAN): BOOLEAN is
  134. -- Transforms `a_source' into `a_destination' if possible,
  135. -- and then validates `a_destination', in order for it to
  136. -- conform to Current. If `strict_validation' is True this
  137. -- function will only succeed if the transformed
  138. -- `a_destination' complied to Current without
  139. -- modifications. True if transformation and validation were
  140. -- successful, False otherwise and dest_value is left
  141. -- untouched.
  142. require -- TODO valid destination of corret type for Current
  143. do
  144. Result:=(g_param_value_convert(handle,
  145. a_source.handle, a_destination.handle,
  146. strict_validation.to_integer)).to_boolean
  147. end
  148. compare (value1,value2: G_VALUE): INTEGER is
  149. -- Compares value1 with value2 according to Current, and
  150. -- return -1, 0 or +1, if value1 is found to be less than,
  151. -- equal to or greater than value2, respectively.
  152. require -- TODO value1 and 2: a GValue of correct type for pspec
  153. do
  154. Result := (g_param_values_cmp (handle,value1.handle,value2.handle))
  155. end
  156. feature -- queries
  157. name: STRING is
  158. -- the name of a G_PARAM_SPEC
  159. do
  160. --create
  161. --Result.from_external_copy(g_param_spec_get_name(handle))
  162. create {CONST_STRING} Result.from_external(g_param_spec_get_name(handle))
  163. end
  164. nick: STRING is
  165. -- the nick of a G_PARAM_SPEC
  166. do
  167. --create
  168. --Result.from_external_copy(g_param_spec_get_nick(handle))
  169. create {CONST_STRING} Result.from_external(g_param_spec_get_nick(handle))
  170. end
  171. blurb: STRING is
  172. -- the blurb of a G_PARAM_SPEC
  173. do
  174. -- create Result.from_external_copy(g_param_spec_get_blurb(handle))
  175. create {CONST_STRING} Result.from_external(g_param_spec_get_blurb(handle))
  176. end
  177. feature
  178. is_initialized: BOOLEAN is
  179. -- Is hidden implementation data correctly initialized?
  180. do
  181. Result := (owner_class.is_not_null and (param_id /= 0))
  182. end
  183. feature {WRAPPER} -- Implementation
  184. owner_class: POINTER
  185. -- The GObjectClass the created and installed the corresponding property
  186. param_id: INTEGER
  187. -- The parameter id to be passed to the property
  188. -- setter/getter function
  189. feature -- name validity
  190. is_a_valid_name (a_string: STRING): BOOLEAN is
  191. -- Does `a_string' comply with the rules for G_PARAM_SPEC names?
  192. do
  193. -- When creating and looking up a GParamSpec, either separator can be used, but they cannot be mixed. Using '-' is considerably more efficient and in fact required when using property names as detail strings for signals.
  194. not_yet_implemented
  195. end
  196. type_name: STRING is
  197. -- the GType name of this parameter spec.
  198. do
  199. create Result.from_external_copy (g_param_spec_type(handle))
  200. ensure result_not_void: Result /= Void
  201. end
  202. value_gtype: INTEGER is
  203. -- the GType to initialize a GValue for this parameter.
  204. do
  205. Result:= g_param_spec_value_type (handle)
  206. ensure
  207. is_valid_gtype: -- TODO: since this require a somehow
  208. -- complete G_TYPES class
  209. end
  210. feature {} -- Creation
  211. make_integer (a_name,a_nick,a_blurb: STRING;
  212. a_min,a_max,a_default: INTEGER; some_flags: INTEGER) is
  213. -- Creates a parameter specification for an integer setting.
  214. -- `a_name' is the canonical name of the property specified,
  215. -- `a_nick' is the nick name for the property specified,
  216. -- `a_blurb' is a description of the property specified.
  217. --`a_default' is the default value for the property
  218. --`some_flags' are flags for the property specified
  219. require
  220. max_greater_than_min: a_min < a_max
  221. default_in_range: a_default.in_range (a_min, a_max)
  222. do
  223. handle := g_param_spec_int (a_name.to_external, a_nick.to_external, a_blurb.to_external,
  224. a_min, a_max, a_default,
  225. some_flags)
  226. -- Note: where Gobject type system took this?
  227. owner_class := g_type_class_peek(get_owner_type(handle))
  228. param_id := get_param_id (handle)
  229. ensure is_integer: is_integer
  230. end
  231. feature -- Boolean parameter
  232. is_boolean: BOOLEAN is
  233. -- Is this a boolean parameter?
  234. do
  235. Result := g_is_param_spec_boolean (handle).to_boolean
  236. end
  237. default_boolean: BOOLEAN is
  238. -- default boolean value
  239. do
  240. Result := default_gboolean(handle).to_boolean
  241. end
  242. feature -- Integer parameter
  243. is_integer: BOOLEAN is
  244. -- Is this an integer parameter?
  245. do
  246. Result := g_is_param_spec_int (handle).to_boolean
  247. end
  248. default_integer: INTEGER is
  249. -- The default integer value
  250. require is_integer: is_integer
  251. do
  252. Result := get_default_int (handle)
  253. end
  254. minimum_integer: INTEGER is
  255. -- The minimum integer value
  256. require is_integer: is_integer
  257. do
  258. Result := get_min_int (handle)
  259. end
  260. maximum_integer: INTEGER is
  261. -- The maximum integer value
  262. require is_integer: is_integer
  263. do
  264. Result := get_max_int (handle)
  265. end
  266. feature {} -- Natural parameter
  267. is_natural: BOOLEAN is
  268. -- Is this a natural parameter?
  269. do
  270. Result := (g_is_param_spec_uint (handle).to_boolean)
  271. end
  272. default_natural: INTEGER is
  273. -- The default natural value
  274. require is_natural: is_natural
  275. do
  276. Result := get_default_uint (handle)
  277. end
  278. minimum_natural: INTEGER is
  279. -- The minimum natural value
  280. require is_natural: is_natural
  281. do
  282. Result := get_min_uint (handle)
  283. end
  284. maximum_natural: INTEGER is
  285. -- The maximum natural value
  286. require is_natural: is_natural
  287. do
  288. Result := get_max_uint (handle)
  289. end
  290. feature -- TODO: INTEGER_64 (int64) parameter
  291. feature -- TODO: long parameter. Note: could it be the same of INTEGER_64?
  292. feature -- TODO: unsigned long parameter. Note: could it be the same of an eventual NATURAL_64?
  293. feature -- TODO: NATURAL_64 (uint64) parameter
  294. feature -- TODO: REAL_32 (float) parameter
  295. is_real_32: BOOLEAN is
  296. -- Is this an integer parameter?
  297. do
  298. Result := g_is_param_spec_float (handle).to_boolean
  299. end
  300. default_real_32: REAL_32 is
  301. -- The default integer value
  302. require is_real_32: is_real_32
  303. do
  304. Result := get_default_float (handle)
  305. end
  306. minimum_real_32: REAL_32 is
  307. -- The minimum real_32 value
  308. require is_real_32: is_real_32
  309. do
  310. Result := get_min_float (handle)
  311. end
  312. maximum_real_32: REAL_32 is
  313. -- The maximum real_32 value
  314. require is_real_32: is_real_32
  315. do
  316. Result := get_max_float (handle)
  317. end
  318. feature -- TODO: REAL_64 (double) parameter
  319. is_real_64: BOOLEAN is
  320. -- Is this an real_64 parameter?
  321. do
  322. Result := g_is_param_spec_double (handle).to_boolean
  323. end
  324. default_real_64: REAL_64 is
  325. -- The default integer value
  326. require is_real_64: is_real_64
  327. do
  328. Result := get_default_double (handle)
  329. end
  330. minimum_real_64: REAL_64 is
  331. -- The minimum real_64 value
  332. require is_real_64: is_real_64
  333. do
  334. Result := get_min_double (handle)
  335. end
  336. maximum_real_64: REAL_64 is
  337. -- The maximum real_64 value
  338. require is_real_64: is_real_64
  339. do
  340. Result := get_max_double (handle)
  341. end
  342. feature -- TODO: enum parameter. Note: this need a wrapper for G_ENUM
  343. is_enum: BOOLEAN is
  344. -- Is this an enumeration (Enum in C) parameter?
  345. do
  346. Result := (g_is_param_spec_enum (handle).to_boolean)
  347. end
  348. feature -- TODO: flags parameter. Note: this could need a wrapper for G_FLAG_CLASS and G_FLAG_VALUE
  349. feature -- TODO: STRING parameter
  350. is_string: BOOLEAN is
  351. -- Is this a string parameter?
  352. do
  353. Result := (g_is_param_spec_string (handle).to_boolean)
  354. end
  355. feature -- TODO: G_PARAM_SPEC parameter
  356. -- Note: call me dumb but it seems a little too recursive IMHO. Paolo 2006-06-28
  357. feature -- TODO: G_BOXED parameter. Note: this require a wrapper for G_BOXED
  358. feature -- TODO: POINTER parameter. Note: is this really needed? Paolo 2006-06-28
  359. feature -- TODO: G_OBJECT parameter
  360. feature -- TODO: UNICODE CHARACTER parameter
  361. feature -- CHARACTER parameter
  362. is_character: BOOLEAN is
  363. -- Is this a character parameter?
  364. do
  365. Result := g_is_param_spec_char (handle).to_boolean
  366. end
  367. default_character: CHARACTER is
  368. -- The default character value
  369. require is_character: is_character
  370. do
  371. Result := def_char (handle).to_character
  372. end
  373. minimum_character: CHARACTER is
  374. -- The minimum character value
  375. require is_character: is_character
  376. do
  377. Result := min_char (handle).to_character
  378. end
  379. maximum_character: CHARACTER is
  380. -- The maximum character value
  381. require is_character: is_character
  382. do
  383. Result := max_char (handle).to_character
  384. end
  385. feature -- TODO: (if meaningful) unsigned char parameter
  386. feature -- TODO: G_VALUE_ARRAY parameter
  387. feature -- TODO: override parameter
  388. feature -- TODO: (if meaningful) G_TYPE parameter
  389. feature {} -- Unwrapped API
  390. -- GParamSpec
  391. -- typedef struct {
  392. -- GTypeInstance g_type_instance;
  393. -- gchar *name;
  394. -- GParamFlags flags;
  395. -- GType value_type;
  396. -- GType owner_type; /* class or interface using this property */
  397. -- } GParamSpec;
  398. -- All fields of the GParamSpec struct are private and should not be used
  399. -- directly, except for the following:
  400. -- GTypeInstance g_type_instance; private GTypeInstance portion
  401. -- gchar *name; name of this parameter
  402. -- GParamFlags flags; GParamFlags flags for this parameter
  403. -- GType value_type; the GValue type for this parameter
  404. -- GType owner_type; GType type that uses (introduces) this
  405. -- paremeter
  406. -- -----------------------------------------------------------------------
  407. -- GParamSpecClass
  408. -- typedef struct {
  409. -- GTypeClass g_type_class;
  410. -- GType value_type;
  411. -- void (*finalize) (GParamSpec *pspec);
  412. -- /* GParam methods */
  413. -- void (*value_set_default) (GParamSpec *pspec,
  414. -- GValue *value);
  415. -- gboolean (*value_validate) (GParamSpec *pspec,
  416. -- GValue *value);
  417. -- gint (*values_cmp) (GParamSpec *pspec,
  418. -- const GValue *value1,
  419. -- const GValue *value2);
  420. -- } GParamSpecClass;
  421. -- The class structure for the GParamSpec type. Normally, GParamSpec
  422. -- classes are filled by g_param_type_register_static().
  423. -- GTypeClass g_type_class; the parent class
  424. -- GType value_type; the GValue type for this parameter
  425. -- finalize () The instance finalization function (optional),
  426. -- should chain up to the finalize method of the
  427. -- parent class.
  428. -- value_set_default () Resets a value to the default value for this
  429. -- type (recommended, the default is
  430. -- g_value_reset()), see
  431. -- g_param_value_set_default().
  432. -- value_validate () Ensures that the contents of value comply with
  433. -- the specifications set out by this type
  434. -- (optional), see g_param_value_set_validate().
  435. -- values_cmp () Compares value1 with value2 according to this
  436. -- type (recommended, the default is memcmp()),
  437. -- see g_param_values_cmp().
  438. -- -----------------------------------------------------------------------
  439. -- enum GParamFlags
  440. -- typedef enum
  441. -- {
  442. -- G_PARAM_READABLE = 1 < < 0,
  443. -- G_PARAM_WRITABLE = 1 < < 1,
  444. -- G_PARAM_CONSTRUCT = 1 < < 2,
  445. -- G_PARAM_CONSTRUCT_ONLY = 1 < < 3,
  446. -- G_PARAM_LAX_VALIDATION = 1 < < 4,
  447. -- G_PARAM_STATIC_NAME = 1 < < 5,
  448. -- #ifndef G_DISABLE_DEPRECATED
  449. -- G_PARAM_PRIVATE = G_PARAM_STATIC_NAME,
  450. -- #endif
  451. -- G_PARAM_STATIC_NICK = 1 < < 6,
  452. -- G_PARAM_STATIC_BLURB = 1 < < 7
  453. -- } GParamFlags;
  454. -- Through the GParamFlags flag values, certain aspects of parameters can
  455. -- be configured.
  456. -- G_PARAM_READABLE the parameter is readable
  457. -- G_PARAM_WRITABLE the parameter is writable
  458. -- G_PARAM_CONSTRUCT the parameter will be set upon object
  459. -- construction
  460. -- G_PARAM_CONSTRUCT_ONLY the parameter will only be set upon object
  461. -- construction
  462. -- G_PARAM_LAX_VALIDATION upon parameter conversion (see
  463. -- g_param_value_convert()) strict validation is
  464. -- not required
  465. -- G_PARAM_STATIC_NAME the string used as name when constructing the
  466. -- parameter is guaranteed to remain valid and
  467. -- unmodified for the lifetime of the parameter.
  468. -- Since 2.8
  469. -- G_PARAM_STATIC_BLURB the string used as blurb when constructing the
  470. -- parameter is guaranteed to remain valid and
  471. -- unmodified for the lifetime of the parameter.
  472. -- Since 2.8
  473. -- -----------------------------------------------------------------------
  474. -- G_PARAM_READWRITE
  475. -- #define G_PARAM_READWRITE (G_PARAM_READABLE | G_PARAM_WRITABLE)
  476. -- GParamFlags value alias for G_PARAM_READABLE | G_PARAM_WRITABLE.
  477. -- -----------------------------------------------------------------------
  478. -- G_PARAM_MASK
  479. -- #define G_PARAM_MASK (0x000000ff)
  480. -- Mask containing the bits of GParamSpec.flags which are reserved for
  481. -- GLib.
  482. -- -----------------------------------------------------------------------
  483. -- G_PARAM_USER_SHIFT
  484. -- #define G_PARAM_USER_SHIFT (8)
  485. -- Minimum shift count to be used for user defined flags, to be stored in
  486. -- GParamSpec.flags.
  487. -- -----------------------------------------------------------------------
  488. -- g_param_spec_ref ()
  489. -- GParamSpec* g_param_spec_ref (GParamSpec *pspec);
  490. -- Increments the reference count of pspec.
  491. -- pspec : a valid GParamSpec
  492. -- Returns : the GParamSpec that was passed into this function
  493. -- -----------------------------------------------------------------------
  494. -- g_param_spec_unref ()
  495. -- void g_param_spec_unref (GParamSpec *pspec);
  496. -- Decrements the reference count of a pspec.
  497. -- pspec : a valid GParamSpec
  498. -- -----------------------------------------------------------------------
  499. -- g_param_spec_sink ()
  500. -- void g_param_spec_sink (GParamSpec *pspec);
  501. -- The initial reference count of a newly created GParamSpec is 1, even
  502. -- though no one has explicitly called g_param_spec_ref() on it yet. So
  503. -- the initial reference count is flagged as "floating", until someone
  504. -- calls g_param_spec_ref (pspec); g_param_spec_sink (pspec); in sequence
  505. -- on it, taking over the initial reference count (thus ending up with a
  506. -- pspec that has a reference count of 1 still, but is not flagged
  507. -- "floating" anymore).
  508. -- pspec : a valid GParamSpec
  509. -- -----------------------------------------------------------------------
  510. -- g_param_spec_ref_sink ()
  511. -- GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec);
  512. -- Convenience function to ref and sink a GParamSpec.
  513. -- pspec : a valid GParamSpec
  514. -- Returns : the GParamSpec that was passed into this function
  515. -- Since 2.10
  516. -- -----------------------------------------------------------------------
  517. -- g_param_value_set_default ()
  518. -- void g_param_value_set_default (GParamSpec *pspec,
  519. -- GValue *value);
  520. -- Sets value to its default value as specified in pspec.
  521. -- pspec : a valid GParamSpec
  522. -- value : a GValue of correct type for pspec
  523. -- -----------------------------------------------------------------------
  524. -- g_param_value_defaults ()
  525. -- gboolean g_param_value_defaults (GParamSpec *pspec,
  526. -- GValue *value);
  527. -- Checks whether value contains the default value as specified in pspec.
  528. -- pspec : a valid GParamSpec
  529. -- value : a GValue of correct type for pspec
  530. -- Returns : whether value contains the canonical defualt for this pspec
  531. -- -----------------------------------------------------------------------
  532. -- g_param_value_validate ()
  533. -- gboolean g_param_value_validate (GParamSpec *pspec,
  534. -- GValue *value);
  535. -- Ensures that the contents of value comply with the specifications set
  536. -- out by pspec. For example, a GParamSpecInt might require that integers
  537. -- stored in value may not be smaller than -42 and not be greater than
  538. -- +42. If value contains an integer outside of this range, it is modified
  539. -- accordingly, so the resulting value will fit into the range -42 .. +42.
  540. -- pspec : a valid GParamSpec
  541. -- value : a GValue of correct type for pspec
  542. -- Returns : whether modifying value was necessary to ensure validity
  543. -- -----------------------------------------------------------------------
  544. -- g_param_value_convert ()
  545. -- gboolean g_param_value_convert (GParamSpec *pspec,
  546. -- const GValue *src_value,
  547. -- GValue *dest_value,
  548. -- gboolean strict_validation);
  549. -- Transforms src_value into dest_value if possible, and then validates
  550. -- dest_value, in order for it to conform to pspec. If strict_validation
  551. -- is TRUE this function will only succeed if the transformed dest_value
  552. -- complied to pspec without modifications. See also
  553. -- g_value_type_transformable(), g_value_transform() and
  554. -- g_param_value_validate().
  555. -- pspec : a valid GParamSpec
  556. -- src_value : souce GValue
  557. -- dest_value : destination GValue of correct type for pspec
  558. -- strict_validation : TRUE requires dest_value to conform to pspec
  559. -- without modifications
  560. -- Returns : TRUE if transformation and validation were
  561. -- successful, FALSE otherwise and dest_value is left
  562. -- untouched.
  563. -- -----------------------------------------------------------------------
  564. -- g_param_values_cmp ()
  565. -- gint g_param_values_cmp (GParamSpec *pspec,
  566. -- const GValue *value1,
  567. -- const GValue *value2);
  568. -- Compares value1 with value2 according to pspec, and return -1, 0 or +1,
  569. -- if value1 is found to be less than, equal to or greater than value2,
  570. -- respectively.
  571. -- pspec : a valid GParamSpec
  572. -- value1 : a GValue of correct type for pspec
  573. -- value2 : a GValue of correct type for pspec
  574. -- Returns : -1, 0 or +1, for a less than, equal to or greater than result
  575. -- -----------------------------------------------------------------------
  576. -- g_param_spec_get_name ()
  577. -- const gchar* g_param_spec_get_name (GParamSpec *pspec);
  578. -- Returns the name of a GParamSpec.
  579. -- pspec : a valid GParamSpec
  580. -- Returns : the name of pspec.
  581. -- -----------------------------------------------------------------------
  582. -- g_param_spec_get_nick ()
  583. -- const gchar* g_param_spec_get_nick (GParamSpec *pspec);
  584. -- Returns the nickname of a GParamSpec.
  585. -- pspec : a valid GParamSpec
  586. -- Returns : the nickname of pspec.
  587. -- -----------------------------------------------------------------------
  588. -- g_param_spec_get_blurb ()
  589. -- const gchar* g_param_spec_get_blurb (GParamSpec *pspec);
  590. -- Returns the short description of a GParamSpec.
  591. -- pspec : a valid GParamSpec
  592. -- Returns : the short description of pspec.
  593. -- -----------------------------------------------------------------------
  594. -- g_param_spec_get_qdata ()
  595. -- gpointer g_param_spec_get_qdata (GParamSpec *pspec,
  596. -- GQuark quark);
  597. -- Gets back user data pointers stored via g_param_spec_set_qdata().
  598. -- pspec : a valid GParamSpec
  599. -- quark : a GQuark, naming the user data pointer
  600. -- Returns : the user data pointer set, or NULL
  601. -- -----------------------------------------------------------------------
  602. -- g_param_spec_set_qdata ()
  603. -- void g_param_spec_set_qdata (GParamSpec *pspec,
  604. -- GQuark quark,
  605. -- gpointer data);
  606. -- Sets an opaque, named pointer on a GParamSpec. The name is specified
  607. -- through a GQuark (retrieved e.g. via g_quark_from_static_string()), and
  608. -- the pointer can be gotten back from the pspec with
  609. -- g_param_spec_get_qdata(). Setting a previously set user data pointer,
  610. -- overrides (frees) the old pointer set, using NULL as pointer
  611. -- essentially removes the data stored.
  612. -- pspec : the GParamSpec to set store a user data pointer
  613. -- quark : a GQuark, naming the user data pointer
  614. -- data : an opaque user data pointer
  615. -- -----------------------------------------------------------------------
  616. -- g_param_spec_set_qdata_full ()
  617. -- void g_param_spec_set_qdata_full (GParamSpec *pspec,
  618. -- GQuark quark,
  619. -- gpointer data,
  620. -- GDestroyNotify destroy);
  621. -- This function works like g_param_spec_set_qdata(), but in addition, a
  622. -- void (*destroy) (gpointer) function may be specified which is called
  623. -- with data as argument when the pspec is finalized, or the data is being
  624. -- overwritten by a call to g_param_spec_set_qdata() with the same quark.
  625. -- pspec : the GParamSpec to set store a user data pointer
  626. -- quark : a GQuark, naming the user data pointer
  627. -- data : an opaque user data pointer
  628. -- destroy : function to invoke with data as argument, when data needs to
  629. -- be freed
  630. -- -----------------------------------------------------------------------
  631. -- g_param_spec_steal_qdata ()
  632. -- gpointer g_param_spec_steal_qdata (GParamSpec *pspec,
  633. -- GQuark quark);
  634. -- Gets back user data pointers stored via g_param_spec_set_qdata() and
  635. -- removes the data from pspec without invoking it's destroy() function
  636. -- (if any was set). Usually, calling this function is only required to
  637. -- update user data pointers with a destroy notifier.
  638. -- pspec : the GParamSpec to get a stored user data pointer from
  639. -- quark : a GQuark, naming the user data pointer
  640. -- Returns : the user data pointer set, or NULL
  641. -- -----------------------------------------------------------------------
  642. -- g_param_spec_get_redirect_target ()
  643. -- GParamSpec* g_param_spec_get_redirect_target
  644. -- (GParamSpec *pspec);
  645. -- If the paramspec redirects operations to another paramspec, returns
  646. -- that paramspec. Redirect is used typically for providing a new
  647. -- implementation of a property in a derived type while preserving all the
  648. -- properties from the parent type. Redirection is established by creating
  649. -- a property of type GParamSpecOverride. See g_object_override_property()
  650. -- for an example of the use of this capability.
  651. -- pspec : a GParamSpec
  652. -- Returns : paramspec to which requests on this paramspec should be
  653. -- redirected, or NULL if none.
  654. -- Since 2.4
  655. -- -----------------------------------------------------------------------
  656. -- g_param_spec_internal ()
  657. -- gpointer g_param_spec_internal (GType param_type,
  658. -- const gchar *name,
  659. -- const gchar *nick,
  660. -- const gchar *blurb,
  661. -- GParamFlags flags);
  662. -- Creates a new GParamSpec instance.
  663. -- A property name consists of segments consisting of ASCII letters and
  664. -- digits, separated by either the '-' or '_' character. The first
  665. -- character of a property name must be a letter. Names which violate
  666. -- these rules lead to undefined behaviour.
  667. -- When creating and looking up a GParamSpec, either separator can be
  668. -- used, but they cannot be mixed. Using '-' is considerably more
  669. -- efficient and in fact required when using property names as detail
  670. -- strings for signals.
  671. -- param_type : the GType for the property; must be derived from
  672. -- G_TYPE_PARAM
  673. -- name : the canonical name of the property
  674. -- nick : the nickname of the property
  675. -- blurb : a short description of the property
  676. -- flags : a combination of GParamFlags
  677. -- Returns : a newly allocated GParamSpec instance
  678. -- -----------------------------------------------------------------------
  679. -- GParamSpecTypeInfo
  680. -- typedef struct {
  681. -- /* type system portion */
  682. -- guint16 instance_size; /* obligatory */
  683. -- guint16 n_preallocs; /* optional */
  684. -- void (*instance_init) (GParamSpec *pspec); /* optional */
  685. -- /* class portion */
  686. -- GType value_type; /* obligatory */
  687. -- void (*finalize) (GParamSpec *pspec); /* optional */
  688. -- void (*value_set_default) (GParamSpec *pspec, /* recommended */
  689. -- GValue *value);
  690. -- gboolean (*value_validate) (GParamSpec *pspec, /* optional */
  691. -- GValue *value);
  692. -- gint (*values_cmp) (GParamSpec *pspec, /* recommended */
  693. -- const GValue *value1,
  694. -- const GValue *value2);
  695. -- } GParamSpecTypeInfo;
  696. -- This structure is used to provide the type system with the information
  697. -- required to initialize and destruct (finalize) a parameter's class and
  698. -- instances thereof. The initialized structure is passed to the
  699. -- g_param_type_register_static() The type system will perform a deep copy
  700. -- of this structure, so it's memory does not need to be persistent across
  701. -- invocation of g_param_type_register_static().
  702. -- guint16 instance_size; Size of the instance (object) structure.
  703. -- guint16 n_preallocs; Prior to GLib 2.10, it specified the number of
  704. -- pre-allocated (cached) instances to reserve
  705. -- memory for (0 indicates no caching). Since GLib
  706. -- 2.10, it is ignored, since instances are
  707. -- allocated with the slice allocator now.
  708. -- instance_init () Location of the instance initialization function
  709. -- (optional).
  710. -- GType value_type; The GType of values conforming to this
  711. -- GParamSpec
  712. -- finalize () The instance finalization function (optional).
  713. -- value_set_default () Resets a value to the default value for pspec
  714. -- (recommended, the default is g_value_reset()),
  715. -- see g_param_value_set_default().
  716. -- value_validate () Ensures that the contents of value comply with
  717. -- the specifications set out by pspec (optional),
  718. -- see g_param_value_set_validate().
  719. -- values_cmp () Compares value1 with value2 according to pspec
  720. -- (recommended, the default is memcmp()), see
  721. -- g_param_values_cmp().
  722. -- -----------------------------------------------------------------------
  723. -- g_param_type_register_static ()
  724. -- GType g_param_type_register_static (const gchar *name,
  725. -- const GParamSpecTypeInfo *pspec_info);
  726. -- Registers name as the name of a new static type derived from
  727. -- G_TYPE_PARAM. The type system uses the information contained in the
  728. -- GParamSpecTypeInfo structure pointed to by info to manage the
  729. -- GParamSpec type and its instances.
  730. -- name : 0-terminated string used as the name of the new GParamSpec
  731. -- type.
  732. -- pspec_info : The GParamSpecTypeInfo for this GParamSpec type.
  733. -- Returns : The new type identifier.
  734. -- -----------------------------------------------------------------------
  735. -- GParamSpecPool
  736. -- typedef struct _GParamSpecPool GParamSpecPool;
  737. -- A GParamSpecPool maintains a collection of GParamSpecs which can be
  738. -- quickly accessed by owner and name. The implementation of the GObject
  739. -- property system uses such a pool to store the GParamSpecs of the
  740. -- properties all object types.
  741. -- -----------------------------------------------------------------------
  742. -- g_param_spec_pool_new ()
  743. -- GParamSpecPool* g_param_spec_pool_new (gboolean type_prefixing);
  744. -- Creates a new GParamSpecPool.
  745. -- If type_prefixing is TRUE, lookups in the newly created pool will allow
  746. -- to specify the owner as a colon-separated prefix of the property name,
  747. -- like "GtkContainer:border-width". This feature is deprecated, so you
  748. -- should always set type_prefixing to FALSE.
  749. -- type_prefixing : Whether the pool will support type-prefixed property
  750. -- names.
  751. -- Returns : a newly allocated GParamSpecPool.
  752. -- -----------------------------------------------------------------------
  753. -- g_param_spec_pool_insert ()
  754. -- void g_param_spec_pool_insert (GParamSpecPool *pool,
  755. -- GParamSpec *pspec,
  756. -- GType owner_type);
  757. -- Inserts a GParamSpec in the pool.
  758. -- pool : a GParamSpecPool.
  759. -- pspec : the GParamSpec to insert
  760. -- owner_type : a GType identifying the owner of pspec
  761. -- -----------------------------------------------------------------------
  762. -- g_param_spec_pool_remove ()
  763. -- void g_param_spec_pool_remove (GParamSpecPool *pool,
  764. -- GParamSpec *pspec);
  765. -- Removes a GParamSpec from the pool.
  766. -- pool : a GParamSpecPool
  767. -- pspec : the GParamSpec to remove
  768. -- -----------------------------------------------------------------------
  769. -- g_param_spec_pool_lookup ()
  770. -- GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool,
  771. -- const gchar *param_name,
  772. -- GType owner_type,
  773. -- gboolean walk_ancestors);
  774. -- Looks up a GParamSpec in the pool.
  775. -- pool : a GParamSpecPool
  776. -- param_name : the name to look for
  777. -- owner_type : the owner to look for
  778. -- walk_ancestors : If TRUE, also try to find a GParamSpec with param_name
  779. -- owned by an ancestor of owner_type.
  780. -- Returns : The found GParamSpec, or NULL if no matching
  781. -- GParamSpec was found.
  782. -- -----------------------------------------------------------------------
  783. -- g_param_spec_pool_list ()
  784. -- GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool,
  785. -- GType owner_type,
  786. -- guint *n_pspecs_p);
  787. -- Gets an array of all GParamSpecs owned by owner_type in the pool.
  788. -- pool : a GParamSpecPool
  789. -- owner_type : the owner to look for
  790. -- n_pspecs_p : return location for the length of the returned array
  791. -- Returns : a newly allocated array containing pointers to all
  792. -- GParamSpecs owned by owner_type in the pool
  793. -- -----------------------------------------------------------------------
  794. -- g_param_spec_pool_list_owned ()
  795. -- GList* g_param_spec_pool_list_owned (GParamSpecPool *pool,
  796. -- GType owner_type);
  797. -- Gets an GList of all GParamSpecs owned by owner_type in the pool.
  798. -- pool : a GParamSpecPool
  799. -- owner_type : the owner to look for
  800. -- Returns : a GList of all GParamSpecs owned by owner_type in the
  801. -- poolGParamSpecs.
  802. feature -- size
  803. struct_size: INTEGER is
  804. external "C use <glib-object.h>"
  805. alias "sizeof(GParamSpec)"
  806. end
  807. -- invariant
  808. -- is_shared: is_shared
  809. -- initialized: is_initialized
  810. end