From 8676f12a7e040d7c3f20584739a74ad1074a4717 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 5 Oct 2022 13:38:00 -1000 Subject: [PATCH] feat: add cython extension for messages (#73) --- build.py | 1 + src/dbus_fast/message.pxd | 23 +++++++++++++++++++++++ src/dbus_fast/message.py | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/dbus_fast/message.pxd diff --git a/build.py b/build.py index 2bf8b26f..c9f91313 100644 --- a/build.py +++ b/build.py @@ -22,6 +22,7 @@ def build(setup_kwargs): dict( ext_modules=cythonize( [ + "src/dbus_fast/message.py", "src/dbus_fast/signature.py", "src/dbus_fast/unpack.py", "src/dbus_fast/_private/marshaller.py", diff --git a/src/dbus_fast/message.pxd b/src/dbus_fast/message.pxd new file mode 100644 index 00000000..cd7d9a80 --- /dev/null +++ b/src/dbus_fast/message.pxd @@ -0,0 +1,23 @@ +"""cdefs for message.py""" + +import cython + + +cdef class Message: + + cdef public str destination + cdef public str path + cdef public str interface + cdef public str member + cdef public object message_type + cdef public object flags + cdef public str error_name + cdef public unsigned int reply_serial + cdef public str sender + cdef public list unix_fds + cdef public str signature + cdef public object signature_tree + cdef public list body + cdef public unsigned int serial + + cpdef _marshall(self, negotiate_unix_fd: bint) diff --git a/src/dbus_fast/message.py b/src/dbus_fast/message.py index d976dc56..7b6626cb 100644 --- a/src/dbus_fast/message.py +++ b/src/dbus_fast/message.py @@ -121,7 +121,7 @@ def __init__( self.error_name = ( error_name if type(error_name) is not ErrorType else error_name.value ) - self.reply_serial = reply_serial + self.reply_serial = reply_serial or 0 self.sender = sender self.unix_fds = unix_fds if type(signature) is SignatureTree: @@ -131,7 +131,7 @@ def __init__( self.signature = signature self.signature_tree = get_signature_tree(signature) self.body = body - self.serial = serial + self.serial = serial or 0 if not validate: return