diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-14 01:24:30 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-14 01:24:30 +0200 |
commit | df309e5a4372776aada9d27c9f8427609a824490 (patch) | |
tree | ca2c9836c6490a61ab5f51cdd6241901dfc735dc /Lisp | |
parent | c5f208daed4eb63d5a8ff3f8a92bac2a9df08002 (diff) |
Add support for opaque structs and unions in typespecs.
darcs-hash:70b517357c9dab4bbf35c374003187f8433a353e
Diffstat (limited to 'Lisp')
-rw-r--r-- | Lisp/tests.lisp | 8 | ||||
-rw-r--r-- | 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 (#\{ #\}) |