feat: add cython extension for messages (#73)

This commit is contained in:
J. Nick Koston 2022-10-05 13:38:00 -10:00 committed by GitHub
parent 5db51562bc
commit 8676f12a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -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",

23
src/dbus_fast/message.pxd Normal file
View File

@ -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)

View File

@ -121,7 +121,7 @@ class Message:
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 @@ class Message:
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