Skip to content

Commit

Permalink
feat: add a cython pxd for services (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Dec 9, 2022
1 parent b5232b3 commit f3c9250
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion src/dbus_fast/message_bus.pxd
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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)
11 changes: 10 additions & 1 deletion src/dbus_fast/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,16 @@ def handler(msg: Message, send_reply: Callable[[Message], None]) -> None:
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

Expand Down
24 changes: 24 additions & 0 deletions src/dbus_fast/service.pxd
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f3c9250

Please sign in to comment.