Package: gobject

Function g-value-transform

Lambda List

g-value-transform (src-value dest-value)

Arguments

src-value -- a g-value source value
dest-value -- a g-value target value

Return Value

Whether a transformation rule was found and could be applied. Upon failing transformations, dest-value is left untouched.

Details

Tries to cast the contents of src-value into a type appropriate to store in dest-value, e.g. to transform a "gint" value into a "gfloat" value. Performing transformations between value types might incur precision lossage. Especially transformations into strings might reveal seemingly arbitrary results and should not be relied upon for production code.

Example

;; A transformation from an integer to a string
(defcallback int2string :void ((src-value (:pointer (:struct g-value)))
                               (dest-value (:pointer (:struct g-value))))
  (if (= (g-value-int src-value) 42)
      (setf (g-value-string dest-value) "An important number")
      (setf (g-value-string dest-value) "What is that?")))

;; Register the transformation int2string (g-value-register-transform-func "gint" "gchararray" (callback int2string))
 

See also

2021-4-8