Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Round one at new marshalling framework. Not done yet.
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
-*- Mode: Outline -*- | |||
|
|||
* A random list of things to do | |||
|
|||
** unix-transport.lisp | |||
|
|||
Port to usocket. | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
;;; -*- Mode: Lisp -*- | |||
;;; Copyright (c) 2008 Julian Stecklina | |||
;;; | |||
;;; This file is part of CL-DBUS. Look into LICENSE for license terms. | |||
|
|||
(in-package :blitz.desktop.dbus) | |||
|
|||
(defclass* dbus-type () | |||
(name char alignment)) | |||
|
|||
(defclass* dbus-compound-type (dbus-type) | |||
(element-type)) | |||
|
|||
(eval-when (:load-toplevel :compile-toplevel :execute) | |||
(defmacro define-dbus-type (name type-char alignment &optional (superclass 'dbus-type) slots) | |||
`(defclass* ,(intern (format nil "DBUS-~A" name) (find-package :blitz.desktop.dbus)) | |||
(,superclass) | |||
,slots | |||
(:default-initargs | |||
:name ',name | |||
:char ',type-char | |||
:alignment ,alignment)))) | |||
|
|||
(define-dbus-type boolean #\b 4) | |||
|
|||
(define-dbus-type uint8 #\y 1) | |||
(define-dbus-type int16 #\n 2) | |||
(define-dbus-type uint16 #\q 2) | |||
(define-dbus-type int32 #\i 4) | |||
(define-dbus-type uint32 #\u 4) | |||
(define-dbus-type int64 #\x 8) | |||
(define-dbus-type uint64 #\t 8) | |||
(define-dbus-type double #\d 8) | |||
|
|||
(define-dbus-type string #\s 4) | |||
(define-dbus-type signature #\g 1) | |||
(define-dbus-type object-path #\o 4) | |||
|
|||
(define-dbus-type variant #\v 1) | |||
|
|||
(define-dbus-type struct #\r 8 dbus-compound-type) | |||
(define-dbus-type array #\a 4 dbus-compound-type) | |||
(define-dbus-type dict-entry #\e 8 dbus-compound-type) | |||
|
|||
(defgeneric marshall (type object vector start) | |||
(:documentation "Marshalls OBJECT (interpreted as TYPE) into | |||
VECTOR (starting at START). Returns VECTOR and an index pointing | |||
after the written data.")) | |||
|
|||
(defun dbus-write-byte (vector start byte &optional (repeat 1)) | |||
(iter (repeat repeat) | |||
(for i upfrom 0) | |||
(setf (aref vector (+ start i)) byte))) | |||
|
|||
(defmethod marshall :around ((type dbus-type) object vector start) | |||
(let* ((alignment (alignment-of type)) | |||
(mod (nth-value 1 (truncate start alignment)))) | |||
(dbus-write-byte vector start 0 (- alignment mod)) | |||
(call-next-method type object vector (+ start (- alignment mod))))) | |||
|
|||
(defmethod marshall ((type dbus-boolean) object vector start) | |||
;; Endianness? | |||
;; XXXX | |||
) | |||
;;; EOF |