2019-07-02 03:32:09 +00:00

455 lines
21 KiB
Plaintext
Executable File

// 1.12
module lib+ {
module dbus+ {
module so {
struct struct {
dbus_error_init void;
dbus_error_free void;
dbus_error_is_set void;
dbus_bus_add_match void;
dbus_bus_get void;
dbus_bus_get_unique_name void;
dbus_bus_request_name void;
dbus_connection_send void;
dbus_connection_send_with_reply void;
dbus_connection_read_write void;
dbus_connection_pop_message void;
dbus_connection_flush void;
dbus_connection_close void;
dbus_message_new_signal void;
dbus_message_new_method_call void;
dbus_message_new_method_return void;
dbus_message_iter_init void;
dbus_message_iter_init_append void;
dbus_message_iter_next void;
dbus_message_iter_get_basic void;
dbus_message_iter_get_arg_type void;
dbus_message_iter_append_basic void;
dbus_message_get_type void;
dbus_message_is_signal void;
dbus_message_is_method_call void;
dbus_message_unref void;
dbus_pending_call_block void;
dbus_pending_call_steal_reply void;
dbus_pending_call_unref void;
}
var fn struct;
func init() bool {
import rt::c;
return dlsyms(dlopen("libdbus-1.so", RTLD_LAZY), &fn,
"dbus_error_init",
"dbus_error_free",
"dbus_error_is_set",
"dbus_bus_add_match",
"dbus_bus_get",
"dbus_bus_get_unique_name",
"dbus_bus_request_name",
"dbus_connection_send",
"dbus_connection_send_with_reply",
"dbus_connection_read_write",
"dbus_connection_pop_message",
"dbus_connection_flush",
"dbus_connection_close",
"dbus_message_new_signal",
"dbus_message_new_method_call",
"dbus_message_new_method_return",
"dbus_message_iter_init",
"dbus_message_iter_init_append",
"dbus_message_iter_next",
"dbus_message_iter_get_basic",
"dbus_message_iter_get_arg_type",
"dbus_message_iter_append_basic",
"dbus_message_get_type",
"dbus_message_is_signal",
"dbus_message_is_method_call",
"dbus_message_unref",
"dbus_pending_call_block",
"dbus_pending_call_steal_reply",
"dbus_pending_call_unref"
);
}
}
}
module dbus+ {
/**
* Well-known bus types. See dbus_bus_get().
*/
enum DBusBusType;
enum {
DBUS_BUS_SESSION, /**< The login session bus */
DBUS_BUS_SYSTEM, /**< The systemwide bus */
DBUS_BUS_STARTER /**< The bus that started us, if any */
}
/**
* Results that a message handler can return.
*/
enum DBusHandlerResult;
enum {
DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect - no need to run more handlers. */
DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect - see if other handlers want it. */
DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory in order to return #DBUS_HANDLER_RESULT_HANDLED or #DBUS_HANDLER_RESULT_NOT_YET_HANDLED. Please try again later with more memory. */
}
/* Owner flags */
define {
DBUS_NAME_FLAG_ALLOW_REPLACEMENT = 0x1; /**< Allow another service to become the primary owner if requested */
DBUS_NAME_FLAG_REPLACE_EXISTING = 0x2; /**< Request to replace the current primary owner */
DBUS_NAME_FLAG_DO_NOT_QUEUE = 0x4; /**< If we can not become the primary owner do not place us in the queue */
}
/* Replies to request for a name */
define {
DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1; /**< Service has become the primary owner of the requested name */
DBUS_REQUEST_NAME_REPLY_IN_QUEUE = 2; /**< Service could not become the primary owner and has been placed in the queue */
DBUS_REQUEST_NAME_REPLY_EXISTS = 3; /**< Service is already in the queue */
DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER = 4; /**< Service is already the primary owner */
}
/* Replies to releasing a name */
define {
DBUS_RELEASE_NAME_REPLY_RELEASED = 1; /**< Service was released from the given name */
DBUS_RELEASE_NAME_REPLY_NON_EXISTENT = 2; /**< The given name does not exist on the bus */
DBUS_RELEASE_NAME_REPLY_NOT_OWNER = 3; /**< Service is not an owner of the given name */
}
/* Replies to service starts */
define {
DBUS_START_REPLY_SUCCESS = 1; /**< Service was auto started */
DBUS_START_REPLY_ALREADY_RUNNING = 2; /**< Service was already running */
}
typedef dbus_int64_t int64;
typedef dbus_uint64_t unsigned int64;
typedef dbus_int32_t int32;
typedef dbus_uint32_t unsigned int32;
typedef dbus_int16_t int16;
typedef dbus_uint16_t unsigned int16;
typedef dbus_unichar_t dbus_uint32_t;
typedef dbus_bool_t dbus_uint32_t;
/**
* An 8-byte struct you could use to access int64 without having
* int64 support. Use #dbus_int64_t or #dbus_uint64_t instead.
*/
struct DBus8ByteStruct {
first32 dbus_uint32_t; /**< first 32 bits in the 8 bytes (beware endian issues) */
second32 dbus_uint32_t; /**< second 32 bits in the 8 bytes (beware endian issues) */
}
/**
* A simple value union that lets you access bytes as if they
* were various types; useful when dealing with basic types via
* void pointers and varargs.
*
* This union also contains a pointer member (which can be used
* to retrieve a string from dbus_message_iter_get_basic(), for
* instance), so on future platforms it could conceivably be larger
* than 8 bytes.
*/
union DBusBasicValue {
bytes(8) unsigned char; /**< as 8 individual bytes */
i16 dbus_int16_t; /**< as int16 */
u16 dbus_uint16_t; /**< as int16 */
i32 dbus_int32_t; /**< as int32 */
u32 dbus_uint32_t; /**< as int32 */
bool_val dbus_bool_t; /**< as boolean */
i64 dbus_int64_t; /**< as int64 */
u64 dbus_uint64_t; /**< as int64 */
eight DBus8ByteStruct; /**< as 8-byte struct */
dbl double; /**< as double */
byt unsigned char; /**< as byte */
str. char; /**< as char* (string, object path or signature) */
fd int; /**< as Unix file descriptor */
}
/**
* Object representing an exception.
*/
struct DBusError {
name. char; /**< public error name field */
message. char; /**< public error message field */
dummy unsigned int; /**< placeholder */
padding1 void; /**< placeholder */
}
/* documented in dbus-watch.c */
typedef DBusWatch void;
/* documented in dbus-timeout.c */
typedef DBusTimeout void;
/** Opaque type representing preallocated resources so a message can be sent without further memory allocation. */
typedef DBusPreallocatedSend void;
/** Opaque type representing a method call that has not yet received a reply. */
typedef DBusPendingCall void;
/** Opaque type representing a connection to a remote application and associated incoming/outgoing message queues. */
typedef DBusConnection void;
typedef DBusMessage void;
/**
* DBusMessageIter struct; contains no public fields.
*/
struct DBusMessageIter {
dummy1 void; /**< Don't use this */
dummy2 void; /**< Don't use this */
dummy3 dbus_uint32_t; /**< Don't use this */
dummy4 int; /**< Don't use this */
dummy5 int; /**< Don't use this */
dummy6 int; /**< Don't use this */
dummy7 int; /**< Don't use this */
dummy8 int; /**< Don't use this */
dummy9 int; /**< Don't use this */
dummy10 int; /**< Don't use this */
dummy11 int; /**< Don't use this */
pad1 int; /**< Don't use this */
pad2 void; /**< Don't use this */
pad3 void; /**< Don't use this */
}
/* Message byte order */
define {
DBUS_LITTLE_ENDIAN = 'l'; /**< Code marking LSB-first byte order in the wire protocol. */
DBUS_BIG_ENDIAN = 'B'; /**< Code marking MSB-first byte order in the wire protocol. */
}
define {
/** Type code that is never equal to a legitimate type code */
DBUS_TYPE_INVALID = int('\0');
/** #DBUS_TYPE_INVALID as a string literal instead of a int literal */
DBUS_TYPE_INVALID_AS_STRING = "\0";
/* Primitive types */
/** Type code marking an 8-bit unsigned integer */
DBUS_TYPE_BYTE = int('y');
/** #DBUS_TYPE_BYTE as a string literal instead of a int literal */
DBUS_TYPE_BYTE_AS_STRING = "y";
/** Type code marking a boolean */
DBUS_TYPE_BOOLEAN = int('b');
/** #DBUS_TYPE_BOOLEAN as a string literal instead of a int literal */
DBUS_TYPE_BOOLEAN_AS_STRING = "b";
/** Type code marking a 16-bit signed integer */
DBUS_TYPE_INT16 = int('n');
/** #DBUS_TYPE_INT16 as a string literal instead of a int literal */
DBUS_TYPE_INT16_AS_STRING = "n";
/** Type code marking a 16-bit unsigned integer */
DBUS_TYPE_UINT16 = int('q');
/** #DBUS_TYPE_UINT16 as a string literal instead of a int literal */
DBUS_TYPE_UINT16_AS_STRING = "q";
/** Type code marking a 32-bit signed integer */
DBUS_TYPE_INT32 = int('i');
/** #DBUS_TYPE_INT32 as a string literal instead of a int literal */
DBUS_TYPE_INT32_AS_STRING = "i";
/** Type code marking a 32-bit unsigned integer */
DBUS_TYPE_UINT32 = int('u');
/** #DBUS_TYPE_UINT32 as a string literal instead of a int literal */
DBUS_TYPE_UINT32_AS_STRING = "u";
/** Type code marking a 64-bit signed integer */
DBUS_TYPE_INT64 = int('x');
/** #DBUS_TYPE_INT64 as a string literal instead of a int literal */
DBUS_TYPE_INT64_AS_STRING = "x";
/** Type code marking a 64-bit unsigned integer */
DBUS_TYPE_UINT64 = int('t');
/** #DBUS_TYPE_UINT64 as a string literal instead of a int literal */
DBUS_TYPE_UINT64_AS_STRING = "t";
/** Type code marking an 8-byte double in IEEE 754 format */
DBUS_TYPE_DOUBLE = int('d');
/** #DBUS_TYPE_DOUBLE as a string literal instead of a int literal */
DBUS_TYPE_DOUBLE_AS_STRING = "d";
/** Type code marking a UTF-8 encoded, nul-terminated Unicode string */
DBUS_TYPE_STRING = int('s');
/** #DBUS_TYPE_STRING as a string literal instead of a int literal */
DBUS_TYPE_STRING_AS_STRING = "s";
/** Type code marking a D-Bus object path */
DBUS_TYPE_OBJECT_PATH = int('o');
/** #DBUS_TYPE_OBJECT_PATH as a string literal instead of a int literal */
DBUS_TYPE_OBJECT_PATH_AS_STRING = "o";
/** Type code marking a D-Bus type signature */
DBUS_TYPE_SIGNATURE = int('g');
/** #DBUS_TYPE_SIGNATURE as a string literal instead of a int literal */
DBUS_TYPE_SIGNATURE_AS_STRING = "g";
/** Type code marking a unix file descriptor */
DBUS_TYPE_UNIX_FD = int('h');
/** #DBUS_TYPE_UNIX_FD as a string literal instead of a int literal */
DBUS_TYPE_UNIX_FD_AS_STRING = "h";
/* Compound types */
/** Type code marking a D-Bus array type */
DBUS_TYPE_ARRAY = int('a');
/** #DBUS_TYPE_ARRAY as a string literal instead of a int literal */
DBUS_TYPE_ARRAY_AS_STRING = "a";
/** Type code marking a D-Bus variant type */
DBUS_TYPE_VARIANT = int('v');
/** #DBUS_TYPE_VARIANT as a string literal instead of a int literal */
DBUS_TYPE_VARIANT_AS_STRING = "v";
/** STRUCT and DICT_ENTRY are sort of special since their codes can't
* appear in a type string, instead
* DBUS_STRUCT_BEGIN_CHAR/DBUS_DICT_ENTRY_BEGIN_CHAR have to appear
*/
/** Type code used to represent a struct; however, this type code does not appear
* in type signatures, instead #DBUS_STRUCT_BEGIN_CHAR and #DBUS_STRUCT_END_CHAR will
* appear in a signature.
*/
DBUS_TYPE_STRUCT = int('r');
/** #DBUS_TYPE_STRUCT as a string literal instead of a int literal */
DBUS_TYPE_STRUCT_AS_STRING = "r";
/** Type code used to represent a dict entry; however, this type code does not appear
* in type signatures, instead #DBUS_DICT_ENTRY_BEGIN_CHAR and #DBUS_DICT_ENTRY_END_CHAR will
* appear in a signature.
*/
DBUS_TYPE_DICT_ENTRY = int('e');
/** #DBUS_TYPE_DICT_ENTRY as a string literal instead of a int literal */
DBUS_TYPE_DICT_ENTRY_AS_STRING = "e";
/** Does not include #DBUS_TYPE_INVALID, #DBUS_STRUCT_BEGIN_CHAR, #DBUS_STRUCT_END_CHAR,
* #DBUS_DICT_ENTRY_BEGIN_CHAR, or #DBUS_DICT_ENTRY_END_CHAR - i.e. it is the number of
* valid types, not the number of distinct characters that may appear in a type signature.
*/
DBUS_NUMBER_OF_TYPES = 16;
}
define {
/** This value is never a valid message type, see dbus_message_get_type() */
DBUS_MESSAGE_TYPE_INVALID = 0;
/** Message type of a method call message, see dbus_message_get_type() */
DBUS_MESSAGE_TYPE_METHOD_CALL = 1;
/** Message type of a method return message, see dbus_message_get_type() */
DBUS_MESSAGE_TYPE_METHOD_RETURN = 2;
/** Message type of an error reply message, see dbus_message_get_type() */
DBUS_MESSAGE_TYPE_ERROR = 3;
/** Message type of a signal message, see dbus_message_get_type() */
DBUS_MESSAGE_TYPE_SIGNAL = 4;
DBUS_NUM_MESSAGE_TYPES = 5;
}
}
module dbus+ {
inline dbus_error_init(error. DBusError) {
call1<void>(so::fn.dbus_error_init, error);
}
inline dbus_error_free(error. DBusError) {
call1<void>(so::fn.dbus_error_free, error);
}
inline dbus_error_is_set(error. DBusError) dbus_bool_t {
return call1<dbus_bool_t>(so::fn.dbus_error_is_set, error);
}
inline dbus_bus_add_match(connection. DBusConnection, rule. char, error. DBusError) {
call3<void>(so::fn.dbus_bus_add_match, connection, rule, error);
}
inline dbus_bus_get(type DBusBusType, error. DBusError) .DBusConnection {
return call2<void>(so::fn.dbus_bus_get, type, error);
}
inline dbus_bus_get_unique_name(connection. DBusConnection) .char {
return call1<char*>(so::fn.dbus_bus_get_unique_name, connection);
}
inline dbus_bus_request_name(connection. DBusConnection, name. char, flags unsigned int, error. DBusError) int {
return call4<int>(so::fn.dbus_bus_request_name, connection, name, flags, error);
}
inline dbus_connection_send(connection. DBusConnection, message. DBusMessage, client_serial. dbus_uint32_t) dbus_bool_t {
return call3<dbus_bool_t>(so::fn.dbus_connection_send, connection, message, client_serial);
}
inline dbus_connection_send_with_reply(connection. DBusConnection, message. DBusMessage, pending_return++ DBusPendingCall, timeout_milliseconds int) dbus_bool_t {
return call4<dbus_bool_t>(so::fn.dbus_connection_send_with_reply, connection, message, pending_return, timeout_milliseconds);
}
inline dbus_connection_read_write(connection. DBusConnection, timeout_milliseconds int) dbus_bool_t {
return call2<dbus_bool_t>(so::fn.dbus_connection_read_write, connection, timeout_milliseconds);
}
inline dbus_connection_pop_message(connection. DBusConnection) .DBusMessage {
return call1<void>(so::fn.dbus_connection_pop_message, connection);
}
inline dbus_connection_flush(connection. DBusConnection) {
call1<void>(so::fn.dbus_connection_flush, connection);
}
inline dbus_connection_close(connection. DBusConnection) {
call1<void>(so::fn.dbus_connection_close, connection);
}
inline dbus_message_new_signal(path. char, iface. char, name. char) .DBusMessage {
return call3<void>(so::fn.dbus_message_new_signal, path, iface, name);
}
inline dbus_message_new_method_call(bus_name. char, path. char, iface. char, method. char) .DBusMessage {
return call4<void>(so::fn.dbus_message_new_method_call, bus_name, path, iface, method);
}
inline dbus_message_new_method_return(method_call. DBusMessage) .DBusMessage {
return call1<void>(so::fn.dbus_message_new_method_return, method_call);
}
inline dbus_message_iter_init(message. DBusMessage, iter. DBusMessageIter) dbus_bool_t {
return call2<dbus_bool_t>(so::fn.dbus_message_iter_init, message, iter);
}
inline dbus_message_iter_init_append(message. DBusMessage, iter. DBusMessageIter) {
call2<void>(so::fn.dbus_message_iter_init_append, message, iter);
}
inline dbus_message_iter_next(iter. DBusMessageIter) dbus_bool_t {
return call1<dbus_bool_t>(so::fn.dbus_message_iter_next, iter);
}
inline dbus_message_iter_get_basic(iter. DBusMessageIter, value void) {
call2<void>(so::fn.dbus_message_iter_get_basic, iter, value);
}
inline dbus_message_iter_get_arg_type(iter. DBusMessageIter) int {
return call1<int>(so::fn.dbus_message_iter_get_arg_type, iter);
}
inline dbus_message_iter_append_basic(iter. DBusMessageIter, type int, value void) dbus_bool_t {
return call3<dbus_bool_t>(so::fn.dbus_message_iter_append_basic, iter, type, value);
}
inline dbus_message_get_type(message. DBusMessage) int {
return call1<int>(so::fn.dbus_message_get_type, message);
}
inline dbus_message_is_signal(message. DBusMessage, iface. char, signal_name. char) dbus_bool_t {
return call3<dbus_bool_t>(so::fn.dbus_message_is_signal, message, iface, signal_name);
}
inline dbus_message_is_method_call(message. DBusMessage, iface. char, method. char) dbus_bool_t {
return call3<dbus_bool_t>(so::fn.dbus_message_is_method_call, message, iface, method);
}
inline dbus_message_unref(message. DBusMessage) {
call1<void>(so::fn.dbus_message_unref, message);
}
inline dbus_pending_call_block(pending. DBusPendingCall) {
call1<void>(so::fn.dbus_pending_call_block, pending);
}
inline dbus_pending_call_steal_reply(pending. DBusPendingCall) .DBusMessage {
return call1<void>(so::fn.dbus_pending_call_steal_reply, pending);
}
inline dbus_pending_call_unref(pending. DBusPendingCall) {
call1<void>(so::fn.dbus_pending_call_unref, pending);
}
}
}