Next: , Previous: , Up: Argument Conversion   [Contents][Index]


2.4.8 Arrays

There are many different types of native arrays, and the Guile types expected for GObject procedures that native arrays varies depending on the type required.

Typically, for simple native arrays of numerical types – integers, floating points, etc – a Guile bytevector needs to be used. For these bytevectors, always use native-endianness.

When a native array of gunichar values is expected, a Guile string can be used.

When a native array of strings is expected, a Guile list or vector of strings can be used.

For native arrays of GObject objects, structs, unions, flags, enums, and GTypes, a list is used instead of a bytevector.

If the native procedure expects a zero-terminated array, Guile-GI will provide that automatically. There is no need to add you own zero.

Some GObject procedures write output information into preallocated arrays. For those procedures, the Guile caller will need to create and pass in a bytevector of the appropriate size.

Warning: It is best not to use any of GLib’s Array and ByteArray procedures directly. Since arrays get converted to bytevectors, these procedures will likely fail to do anything sensible.