mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-04-21 07:40:38 +02:00
2004-07-18 Seth Nickell <seth@gnome.org>
* python/dbus.py: * python/dbus_bindings.pyx.in: * python/tests/test-client.py: Add dbus.ByteArray and dbus_bindings.ByteArray types so that byte streams can be passed back. Give jdahlin the heaps of credit that are so rightfully his.
This commit is contained in:
parent
5afe4265ea
commit
5d0ed9c704
4 changed files with 33 additions and 12 deletions
12
ChangeLog
12
ChangeLog
|
|
@ -1,3 +1,15 @@
|
|||
2004-07-18 Seth Nickell <seth@gnome.org>
|
||||
|
||||
* python/dbus.py:
|
||||
* python/dbus_bindings.pyx.in:
|
||||
* python/tests/test-client.py:
|
||||
|
||||
Add dbus.ByteArray and dbus_bindings.ByteArray
|
||||
types so that byte streams can be passed back.
|
||||
|
||||
Give jdahlin the heaps of credit that are so
|
||||
rightfully his.
|
||||
|
||||
2004-07-12 Seth Nickell <seth@gnome.org>
|
||||
|
||||
* python/dbus.py:
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ class ObjectTree:
|
|||
self._connection.register_fallback(base_path, self._unregister_cb, self._message_cb)
|
||||
|
||||
def relative_path_to_object_path(self, relative_path):
|
||||
return self._base_path + relative_path
|
||||
return ObjectPath(self._base_path + relative_path)
|
||||
|
||||
def broadcast_signal(self, interface, signal_name, relative_path):
|
||||
object_path = self.relative_path_to_object_path(relative_path)
|
||||
|
|
@ -393,3 +393,4 @@ class RemoteService:
|
|||
return RemoteObject(self, object_path, interface)
|
||||
|
||||
ObjectPath = dbus_bindings.ObjectPath
|
||||
ByteArray = dbus_bindings.ByteArray
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
# -*- Mode: Python -*-
|
||||
|
||||
# jdahlin is the most coolest and awesomest person in the world
|
||||
# and wrote all the good parts of this code. all the bad parts
|
||||
# where python conditionals have a ( ) around them, thus violating
|
||||
# PEP-8 were written by the lame wannabe python programmer seth
|
||||
|
||||
#include "dbus_h_wrapper.h"
|
||||
|
||||
cdef extern from "stdlib.h":
|
||||
|
|
@ -17,7 +22,7 @@ cdef extern from "dbus-glib.h":
|
|||
cdef extern from "Python.h":
|
||||
void Py_XINCREF (object)
|
||||
void Py_XDECREF (object)
|
||||
|
||||
object PyString_FromStringAndSize(char *, int)
|
||||
|
||||
ctypedef struct DBusError:
|
||||
char *name
|
||||
|
|
@ -66,6 +71,10 @@ class ObjectPath(str):
|
|||
def __init__(self, value):
|
||||
str.__init__(value)
|
||||
|
||||
class ByteArray(str):
|
||||
def __init__(self, value):
|
||||
str.__init__(value)
|
||||
|
||||
|
||||
#forward delcerations
|
||||
cdef class Connection
|
||||
|
|
@ -536,13 +545,11 @@ cdef class MessageIter:
|
|||
|
||||
def get_byte_array(self):
|
||||
cdef int len
|
||||
cdef unsigned char *retval
|
||||
cdef unsigned char *bytearray
|
||||
cdef int i
|
||||
dbus_message_iter_get_byte_array(self.iter, &retval, <int*>&len)
|
||||
list = []
|
||||
for i from 0 <= i < len:
|
||||
list.append(chr(retval[i]))
|
||||
return list
|
||||
dbus_message_iter_get_byte_array(self.iter, &bytearray, <int*>&len)
|
||||
python_string = PyString_FromStringAndSize(<char *>bytearray, len)
|
||||
return python_string
|
||||
|
||||
# FIXME: implement dbus_message_iter_get_boolean_array
|
||||
|
||||
|
|
@ -633,6 +640,8 @@ cdef class MessageIter:
|
|||
retval = self.append_nil()
|
||||
elif isinstance(value, ObjectPath):
|
||||
retval = self.append_object_path(value)
|
||||
elif isinstance(value, ByteArray):
|
||||
retval = self.append_byte_array(value)
|
||||
else:
|
||||
raise TypeError, "Argument of unknown type '%s'" % (value_type)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import dbus
|
||||
import dbus_bindings
|
||||
|
||||
def ensure_same(expected, received):
|
||||
if type(received) != type(expected):
|
||||
|
|
@ -56,8 +55,8 @@ TestEcho(chr(120))
|
|||
TestEcho(10)
|
||||
TestEcho(39.5)
|
||||
TestEcho("HelloWorld")
|
||||
TestEcho(dbus_bindings.ObjectPath("/test/path"))
|
||||
|
||||
TestEcho(dbus.ObjectPath("/test/path"))
|
||||
TestEcho(dbus.ByteArray("blahblahblah"))
|
||||
|
||||
string_list = []
|
||||
for i in range(200):
|
||||
|
|
@ -69,7 +68,7 @@ TestEchoList(int_list)
|
|||
|
||||
path_list = []
|
||||
for i in range(200):
|
||||
path_list.append(dbus_bindings.ObjectPath("/some/object/path" + str(i)))
|
||||
path_list.append(dbus.ObjectPath("/some/object/path" + str(i)))
|
||||
TestEchoList(path_list)
|
||||
|
||||
double_list = []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue