From df309e5a4372776aada9d27c9f8427609a824490 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Fri, 14 Sep 2007 01:24:30 +0200 Subject: Add support for opaque structs and unions in typespecs. darcs-hash:70b517357c9dab4bbf35c374003187f8433a353e --- Lisp/tests.lisp | 8 ++++++-- Lisp/type-conversion.lisp | 27 +++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Lisp/tests.lisp b/Lisp/tests.lisp index 7d6ddb9..1404f86 100644 --- a/Lisp/tests.lisp +++ b/Lisp/tests.lisp @@ -5,7 +5,7 @@ (:shadowing-import-from #:objcl #:struct #:union #:pointer #:oneway #:out #:in #:inout #:const #:parse-typespec #:objc-class - #:bit-field)) + #:bit-field #:opaque)) (in-package #:mulk.objective-cl.tests) @@ -123,7 +123,11 @@ (:string ()) (struct () "Untermulk" (struct () "Unteruntermulk")) - (:int ())))))) + (:int ())))) + ((ensure-same (parse-typespec "^^{OpaqueStruct}") + '(pointer () + (pointer () + (struct (opaque) "OpaqueStruct"))))))) (deftestsuite data-coercion (objective-cl) diff --git a/Lisp/type-conversion.lisp b/Lisp/type-conversion.lisp index 05bb08e..715e906 100644 --- a/Lisp/type-conversion.lisp +++ b/Lisp/type-conversion.lisp @@ -102,14 +102,33 @@ Returns: (VALUES typespec byte-position string-position)" (push qualifier qualifiers)))) (values (case init-char ((#\{ #\() - (let ((name-end (position #\= typestring :start start))) + (let* ((=-token (position #\= typestring :start start)) + (name-end (or =-token + ;; An opaque struct whose contents + ;; we don't know. + (position (ecase init-char + (#\{ #\}) + (#\( #\))) + typestring + :start start) + (error "Premature end of file in~ + typespec: ~A." + typestring))) + (struct-name (subseq typestring + (1+ string-position) + name-end))) (list* (ecase init-char (#\{ 'struct) (#\( 'union)) - qualifiers - (subseq typestring (1+ start) name-end) + (if =-token + qualifiers + (cons 'opaque qualifiers)) + struct-name (progn - (setq string-position (1+ name-end)) ; skip #\= + (setq string-position + (if =-token + (1+ name-end) ; skip #\= + name-end)) (loop until (char= (char typestring string-position) (ecase init-char (#\{ #\}) -- cgit v1.2.3