Protocol Core Modules
*********************


Interface
=========

"Interface" objects are only created as a subclass of Interface.  The
Interface class wraps the protocol objects, and serves to initialize a
set of parameters for the Interface and provide decorators for
defining "Message" objects on the interface.

class pywayland.protocol_core.Interface

   Wrapper class for wl_wayland structs

   Base class for interfaces that are defined by the wayland.xml class
   and generated by the scanner.  Sub-classes should use the
   "InterfaceMeta" metaclass, which will define subclass.events and
   subclass.requests, the lists of the methods on this interface.
   These class variables are populated by the "Interface.event()" and
   "Interface.request()" decorators.

   classmethod event(*arguments: Argument, version: int | None = None) -> Callable

      Decorator for interface events

      Adds the decorated method to the list of events of the interface
      (server-side method).

      Parameters:
         * **signature** (*string*) -- Encodes the types of the
           arguments to the decorated function.

         * **types** (*list*) -- List of the types of any objects
           included in the argument list, None if otherwise.

   classmethod request(*arguments: Argument, version: int | None = None)

      Decorator for interface requests

      Adds the decorated method to the list of requests of the
      interface (client-side method).

      Parameters:
         * **signature** (*string*) -- Encodes the types of the
           arguments to the decorated function.

         * **types** (*list*) -- List of the types of any objects
           included in the argument list, None if otherwise.


Interface Metaclass
===================

This metaclass initializes lists for the requests and events on an
interface and initializes a cdata struct for the class.

class pywayland.protocol_core.interface.InterfaceMeta(name, bases, dct)

   Metaclass for Interfaces

   Initializes empty lists for events and requests for the given
   class.


Proxy
=====

"Proxy" objects are not created directly, and users should generally
not create a proxy class on their own.  Proxy classes give client side
access to the interfaces defined by the Wayland protocol.  Proxies are
returned from the server after calling protocol methods which return
"new_id"'s.

class pywayland.protocol_core.Proxy(ptr, display=None)

   destroy() -> None

      Frees the pointer associated with the Proxy

   property destroyed: bool

      Determine if proxy has been destroyed

      Returns true if the proxy has been destroyed.


Resource
========

class pywayland.protocol_core.Resource(client, version: int | None = None, id: int = 0)

   A server-side Interface object for the client

   Not created directly, created from the "Interface" object.

   Parameters:
      * **client** ("Client" or cdata for "wl_client *") -- The client
        that the Resource is for

      * **version** (*int*) -- The version to use for the "Interface",
        uses current version if not specified

      * **id** (*int*) -- The id for the item

   add_destroy_listener(listener) -> None

      Add a listener for the destroy signal

      Parameters:
         **listener** ("Listener") -- The listener object

   destroy() -> None

      Destroy the Resource


Global
======

class pywayland.protocol_core.Global(display, version=None)

   A server-side Interface object for the server

   Not created directly, created from the "Interface" object.

   Parameters:
      * **display** ("Display") -- The display the object is created
        on

      * **version** (*int*) -- The version to use for the "Interface",
        uses current version if not specified

   destroy()

      Destroy the global object


Message
=======

"Message" objects are used to wrap the method calls on the protocol
objects.  The Message objects are added to the "Interface"'s as either
requests (client-side functions) or events (server-side functions).

class pywayland.protocol_core.message.Message(func: Callable, arguments: list[Argument], version: int | None)

   Wrapper class for *wl_message* structs

   Base class that correspond to the methods defined on an interface
   in the wayland.xml protocol, and are generated by the scanner.
   Subclasses specify the type of method, whether it is a server-side
   or client-side method.

   Parameters:
      * **func** (*function*) -- The function that is represented by
        the message

      * **signature** (*string*) -- The signature of the arguments of
        the message

      * **types** (*list*) -- List of the types of any objects
        included in the argument list, None if otherwise.

   arguments_to_c(*args)

      Create an array of *wl_argument* C structs

      Generate the CFFI cdata array of *wl_argument* structs that
      correspond to the arguments of the method as specified by the
      method signature.

      Parameters:
         **args** (*list*) -- Input arguments

      Returns:
         cdata *union wl_argument []* of args

   build_message_struct(wl_message_struct) -> tuple

      Bulid the wl_message struct for this message

      Parameters:
         **wl_message_struct** -- The wl_message cdata struct to use
         to build the message struct.

      Returns:
         A tuple of elements which must be kept alive for the message
         struct to remain valid.

   c_to_arguments(args_ptr)

      Create a list of arguments

      Generate the arguments of the method from a CFFI cdata array of
      *wl_argument* structs that correspond to the arguments of the
      method as specified by the method signature.

      Parameters:
         **args_ptr** (cdata *union wl_argument []*) -- Input
         arguments

      Returns:
         list of args


Argument
========

class pywayland.protocol_core.argument.Argument(argument_type: 'ArgumentType', nullable: 'bool' = False, interface: 'type[Interface] | None' = None)


ArgumentType
============

class pywayland.protocol_core.argument.ArgumentType(*values)
