feat: add a cython pxd for services (#180)

This commit is contained in:
J. Nick Koston 2022-12-08 14:21:42 -10:00 committed by GitHub
parent b5232b3d9d
commit f3c925079a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 2 deletions

View File

@ -25,6 +25,7 @@ def build(setup_kwargs):
"src/dbus_fast/aio/message_reader.py",
"src/dbus_fast/message.py",
"src/dbus_fast/message_bus.py",
"src/dbus_fast/service.py",
"src/dbus_fast/signature.py",
"src/dbus_fast/unpack.py",
"src/dbus_fast/_private/marshaller.py",

View File

@ -1,15 +1,17 @@
import cython
from .message cimport Message
from .service cimport ServiceInterface, _Method
cdef object MessageType
cdef object DBusError
cdef object MessageFlag
cdef object ServiceInterface
cdef object MESSAGE_TYPE_CALL
cdef object MESSAGE_TYPE_SIGNAL
cdef object assert_object_path_valid
cdef object assert_bus_name_valid
cdef class SendReply:
@ -39,4 +41,8 @@ cdef class BaseMessageBus:
cpdef _process_message(self, Message msg)
@cython.locals(
method=_Method,
interface=ServiceInterface
)
cdef _find_message_handler(self, Message msg)

View File

@ -886,7 +886,16 @@ class BaseMessageBus:
signature_tree=method.out_signature_tree,
replace_fds=self._negotiate_unix_fd,
)
send_reply(Message.new_method_return(msg, method.out_signature, body, fds))
send_reply(
Message(
message_type=MessageType.METHOD_RETURN,
reply_serial=msg.serial,
destination=msg.sender,
signature=method.out_signature,
body=body,
unix_fds=fds,
)
)
return handler

24
src/dbus_fast/service.pxd Normal file
View File

@ -0,0 +1,24 @@
"""cdefs for service.py"""
import cython
cdef class _Method:
cdef public object name
cdef public object fn
cdef public object disabled
cdef public object introspection
cdef public object in_signature
cdef public object out_signature
cdef public object in_signature_tree
cdef public object out_signature_tree
cdef class ServiceInterface:
cdef public object name
cdef list __methods
cdef list __properties
cdef list __signals
cdef set __buses
cdef dict __handlers