double-complex c-type
double-imaginary c-type
enum c-type
+ find-simple-c-type function
cl:float function class c-type
float-complex c-type
float-imaginary c-type
\begin{describe}{mac}
{define-simple-c-type
- \=@{ @<name> @! (@<name>^+) @} @<string> \+\\
+ \=@{ @<name> @! (@<name>^+) @}
+ @{ @<string> @! (@<string>^*) @} \+\\
@[[ @|:export| @<export-flag> @]]
\-\nlret @<name>}
Define type specifiers for a new simple C type. Each symbol @<name> is
defined as a symbolic type specifier for the (unique interned) simple C
- type whose name is the value of @<string>. Further, each @<name> is
- defined to be a type operator: the type specifier @|(@<name>
+ type whose name is the value of (the first) @<string>. Further, each
+ @<name> is defined to be a type operator: the type specifier @|(@<name>
@<qualifier>^*)| evaluates to the (unique interned) simple C type whose
- name is @<string> and which has the @<qualifiers> (which are evaluated).
+ name is (the first) @<string> and which has the @<qualifiers> (which are
+ evaluated).
- Furthermore, a variable @|c-type-@<name>| is defined, for the first @<name>
- only, and initialized with the newly constructed C type object.
+ Each of the @<string>s is associated with the resulting type for retrieval
+ by \descref{find-simple-c-type}{fun}. Furthermore, a variable
+ @|c-type-@<name>| is defined, for the first @<name> only, and initialized
+ with the newly constructed C type object.
If @<export-flag> is true, then the @|c-type-@<name>| variable name, and
all of the @<name>s, are exported from the current package.
\end{describe}
+\begin{describe}{fun}
+ {find-simple-c-type @<string> @> @{ @<simple-c-type> @! @|nil| @}}
+ If @<string> is the name of a simple C type, as established by the
+ \descref{define-simple-c-type}[macro]{mac}, then return the corresponding
+ @|simple-c-type| object; otherwise, return @|nil|.
+\end{describe}
+
\begin{describe}{cls}{tagged-c-type (qualifiable-c-type)
\&key :qualifiers :tag}
Provides common behaviour for C tagged types. A @<tag> is a string
:case :common)
:state nil)))
(with-module-environment (module)
- (dolist (name '("va_list" "size_t" "ptrdiff_t" "wchar_t"))
- (add-to-module module (make-instance 'type-item :name name)))
(flet ((header-name (name)
(concatenate 'string "\"" (string-downcase name) ".h\""))
(add-includes (reason &rest names)
(export 'define-simple-c-type)
(defmacro define-simple-c-type (names type &key export)
"Define each of NAMES to be a simple type called TYPE."
- (let ((names (if (listp names) names (list names))))
- `(progn
- (setf (gethash ,type *simple-type-map*) ',(car names))
- (defctype ,names ,type :export ,export)
- (define-c-type-syntax ,(car names) (&rest quals)
- `(make-simple-type ,',type (list ,@quals))))))
+ (let ((names (if (listp names) names (list names)))
+ (types (if (listp type) type (list type))))
+ (with-gensyms (type name)
+ `(progn
+ (dolist (,type ',types)
+ (setf (gethash ,type *simple-type-map*) ',(car names)))
+ (dolist (,name ',names)
+ (setf (gethash ,name *simple-type-map*) ,(car types)))
+ (defctype ,names ,(car types) :export ,export)
+ (define-c-type-syntax ,(car names) (&rest quals)
+ `(make-simple-type ,',(car types) (list ,@quals)))))))
+
+(export 'find-simple-c-type)
+(defun find-simple-c-type (name)
+ "Return the `simple-c-type' with the given NAME, or nil."
+ (aand (gethash name *simple-type-map*)
+ (make-simple-type (gethash it *simple-type-map*))))
;; Built-in C types.
((value string) (type (eql :id)) (wanted (eql :type)))
(or (and (boundp '*module-type-map*)
(gethash value *module-type-map*))
- (gethash value *declspec-map*)
+ (find-simple-c-type value)
(error "Unknown type `~A'." value)))
;;;--------------------------------------------------------------------------