Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Not sure how to handle types in a generic way...

  • Loading branch information...
commit a1141911e777b9b0d72554a25d1741bf177efdeb 1 parent c2e9112
Julian Stecklina authored

Showing 1 changed file with 40 additions and 33 deletions. Show diff stats Hide diff stats

  1. +40 33 types.lisp
73 types.lisp
@@ -5,21 +5,23 @@
5 5
6 6 (in-package :blitz.desktop.dbus)
7 7
8   -(defclass* dbus-type ()
9   - (name char alignment))
  8 +(defvar *name-to-type* (make-hash-table))
10 9
11   -(defclass* dbus-compound-type (dbus-type)
12   - (element-type))
  10 +(defstruct dbus-type
  11 + name char alignment)
  12 +
  13 +(defmethod print-object ((o dbus-type) s)
  14 + (if *print-readably*
  15 + (call-next-method)
  16 + (print-unreadable-object (o s :type t :identity nil)
  17 + (format s "~A(~A)" (dbus-type-name o) (dbus-type-alignment o)))))
13 18
14 19 (eval-when (:load-toplevel :compile-toplevel :execute)
15   - (defmacro define-dbus-type (name type-char alignment &optional (superclass 'dbus-type) slots)
16   - `(defclass* ,(intern (format nil "DBUS-~A" name) (find-package :blitz.desktop.dbus))
17   - (,superclass)
18   - ,slots
19   - (:default-initargs
20   - :name ',name
21   - :char ',type-char
22   - :alignment ,alignment))))
  20 + (defmacro define-dbus-type (name type-char alignment)
  21 + `(setf (gethash ',type-char *name-to-type*)
  22 + (make-dbus-type :name ',name
  23 + :char ',type-char
  24 + :alignment ',alignment))))
23 25
24 26 (define-dbus-type boolean #\b 4)
25 27
@@ -38,9 +40,9 @@
38 40
39 41 (define-dbus-type variant #\v 1)
40 42
41   -(define-dbus-type struct #\r 8 dbus-compound-type)
42   -(define-dbus-type array #\a 4 dbus-compound-type)
43   -(define-dbus-type dict-entry #\e 8 dbus-compound-type)
  43 +;; (define-dbus-type struct #\r 8 dbus-compound-type)
  44 +;; (define-dbus-type array #\a 4 dbus-compound-type)
  45 +;; (define-dbus-type dict-entry #\e 8 dbus-compound-type)
44 46
45 47 (defgeneric marshall (type object vector start)
46 48 (:documentation "Marshalls OBJECT (interpreted as TYPE) into
@@ -64,23 +66,28 @@ new position in VECTOR."
64 66 (setf (subseq destination start) source)
65 67 (+ start (length source)))
66 68
67   -(defmethod marshall :around ((type dbus-type) object vector start)
68   - ;; Alignment is handled in this around method.
69   - (let* ((alignment (alignment-of type))
70   - (mod (nth-value 1 (truncate start alignment))))
71   - (format t "~A ~A~%" alignment mod)
72   - (values
73   - (call-next-method type object vector
74   - (dbus-write-byte vector 0 start
75   - (mod (- alignment mod) alignment)))
76   - vector)))
77   -
78   -(defmethod marshall ((type dbus-boolean) object vector start)
79   - (dbus-write-sequence vector
80   - (if object
81   - #+ little-endian #(1 0 0 0)
82   - #+ big-endian #(0 0 0 1)
83   - #(0 0 0 0))
84   - start))
  69 +;; (defmethod marshall :around ((type dbus-type) object vector start)
  70 +;; ;; Alignment is handled in this around method.
  71 +;; (let* ((alignment (alignment-of type))
  72 +;; (mod (nth-value 1 (truncate start alignment))))
  73 +;; (format t "~A ~A~%" alignment mod)
  74 +;; (values
  75 +;; (call-next-method type object vector
  76 +;; (dbus-write-byte vector 0 start
  77 +;; (mod (- alignment mod) alignment)))
  78 +;; vector)))
  79 +
  80 +;; (defmethod marshall ((type dbus-boolean) object vector start)
  81 +;; (dbus-write-sequence vector
  82 +;; (if object
  83 +;; #+ little-endian #(1 0 0 0)
  84 +;; #+ big-endian #(0 0 0 1)
  85 +;; #(0 0 0 0))
  86 +;; start))
  87 +
  88 +;;; TODO Parse signature string into list of dbus-type structures.
  89 +;;; How to represent arrays and structs?
  90 +
  91 +;;; TODO
85 92
86 93 ;;; EOF

0 comments on commit a114191

Please sign in to comment.
Something went wrong with that request. Please try again.