The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

X11::Xlib::Struct - Base class for X11 packed structures

DESCRIPTION

Base class for the various exposed C-structs of Xlib, which are represented as a blessed scalar-ref of the raw bytes of the struct. This makes them more efficient than fully inflating/deflating perl hashrefs for every Xlib call.

All attribute accessors are defined in XS.

ATTRIBUTES

display

A reference to an X11::Xlib instance, automatically set by various functions that populate structs. Many times a struct will have pointers that are related to a particular display, so it is desirable to pair the struct with its display pointer in order to be able to inflate those other pointers into objects and be able to call methods on them.

This attribute is implemented "inside-out", so it can't be seen in a dump of the perl data, and requires help from DESTROY to clean up. (handled by this class's destructor)

METHODS

new

  my $struct= X11::Xlib::....->new( %optional_fields );

The constructor sets all fields to their initial value (i.e. zero) and then applies the list of key/value pairs. Warns on unknown field names.

initialize

Set all struct fields to a sensible initial value (like zero)

pack

  $struct->pack( \%fields, $consume, $warn );

Pack field values into the bytes of the struct. Only %fields is required.

If $consume is true, then remove any key of %fields that was processed.

If $warn is true, then emit a warning if any unrecognized field was given.

apply

  $struct->apply( \%fields );
  $struct->apply( field => $val, ... );

Alias for pack(\%fields, 1, 1) . For each given field, update that member of the struct. Emits a warning if the hash contains unknown fields.

unpack

  my $hashref= $struct->unpack();

Extract all fields as Perl data.

bytes

Access the scalar holding the bytes of the struct.

AUTHOR

Olivier Thauvin, <nanardon@nanardon.zarb.org>

Michael Conrad, <mike@nrdvana.net>

COPYRIGHT AND LICENSE

Copyright (C) 2009-2010 by Olivier Thauvin

Copyright (C) 2017-2023 by Michael Conrad

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.