1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % myents SYSTEM "entities.inc">
8 <reference id="primitives">
9 <title>Primitive Types</title>
11 <title>Overview</title>
13 Primitive types have a single value, these include
14 characters, numbers, and pointers. They are all symbols in
19 <para><constant>:char</constant> - Signed 8-bits. A
20 dereferenced :char pointer returns an character.
24 <para><constant>:unsigned-char</constant> - Unsigned 8-bits. A dereferenced :unsigned-char
25 pointer returns an character.
29 <para><constant>:byte</constant> - Signed 8-bits. A
30 dereferenced :byte pointer returns an integer.
34 <para><constant>:unsigned-byte</constant> - Unsigned 8-bits. A
35 dereferenced :unsigned-byte pointer returns an integer.
39 <para><constant>:short</constant> - Signed 16-bits.
43 <para><constant>:unsigned-short</constant> - Unsigned 16-bits.
47 <para><constant>:int</constant> - Signed 32-bits.</para>
50 <para><constant>:unsigned-int</constant> - Unsigned 32-bits.</para>
53 <para><constant>:long</constant> - Signed 32 or 64 bit integer,
54 depending upon the platform.</para>
57 <para><constant>:unsigned-long</constant> - Unsigned 32 or 64
58 bit integer, depending upon the platform.</para>
61 <para><constant>:long-long</constant> - Signed 64 bits integer
62 for implementations that support this. If implementation
64 this, <constant>'uffi:no-long-long</constant> is pushed on
65 the <variable>cl:*features*</variable> list.</para>
68 <para><constant>:unsigned-long-long</constant> - Unsigned 64
69 bits integer for implementations that support this. If
70 implementation does not support
71 this, <constant>'uffi:no-long-long</constant> is pushed on
72 the <variable>cl:*features*</variable> list.</para>
75 <para><constant>:float</constant> - 32-bit floating point.</para>
78 <para><constant>:double</constant> - 64-bit floating point.</para>
81 <para><constant>:cstring</constant> -
82 A &null; terminated string used for passing and returning characters strings with a &c; function.
86 <para><constant>:void</constant> -
87 The absence of a value. Used to indicate that a function does not return a value.
91 <para><constant>:pointer-void</constant> - Points to a generic object.</para>
94 <para><constant>*</constant> - Used to declare a pointer to an object</para>
99 <refentry id="def-constant">
101 <refname>def-constant</refname>
102 <refpurpose>Binds a symbol to a constant.
104 <refclass>Macro</refclass>
107 <title>Syntax</title>
109 <function>def-constant</function> <replaceable>name value &key export</replaceable>
113 <title>Arguments and Values</title>
116 <term><parameter>name</parameter></term>
118 <para>A symbol that will be bound to the value.
123 <term><parameter>value</parameter></term>
125 <para>An evaluated form that is bound the the name.
130 <term><parameter>export</parameter></term>
132 <para>When &t;, the name is exported from the current package. The default is &nil;</para>
138 <title>Description</title>
139 <para>This is a thin wrapper around <function>defconstant</function>. It evaluates at
140 compile-time and optionally exports the symbol from the package.
144 <title>Examples</title>
146 (def-constant pi2 (* 2 pi))
147 (def-constant exported-pi2 (* 2 pi) :export t)
151 <title>Side Effects</title>
152 <para>Creates a new special variable..</para>
155 <title>Affected by</title>
159 <title>Exceptional Situations</title>
164 <refentry id="def-foreign-type">
166 <refname>def-foreign-type</refname>
167 <refpurpose>Defines a new foreign type.
169 <refclass>Macro</refclass>
172 <title>Syntax</title>
174 <function>def-foreign-type</function> <replaceable>name type</replaceable>
178 <title>Arguments and Values</title>
181 <term><parameter>name</parameter></term>
183 <para>A symbol naming the new foreign type.
188 <term><parameter>value</parameter></term>
190 <para>A form that is not evaluated that defines the new
198 <title>Description</title>
199 <para>Defines a new foreign type.
203 <title>Examples</title>
205 (def-foreign-type my-generic-pointer :pointer-void)
206 (def-foreign-type a-double-float :double-float)
207 (def-foreign-type char-ptr (* :char))
211 <title>Side Effects</title>
212 <para>Defines a new foreign type.
216 <title>Affected by</title>
220 <title>Exceptional Situations</title>
225 <refentry id="null-char-p">
227 <refname>null-char-p</refname>
228 <refpurpose>Tests a character for &null; value.
230 <refclass>Macro</refclass>
233 <title>Syntax</title>
235 <function>null-char-p</function> <replaceable>char</replaceable> => <returnvalue>is-null</returnvalue>
239 <title>Arguments and Values</title>
242 <term><parameter>char</parameter></term>
244 <para>A character or integer.
249 <term><parameter>is-null</parameter></term>
251 <para>A boolean flag indicating if char is a &null; value.
258 <title>Description</title>
260 A predicate testing if a character or integer is &null;. This
261 abstracts the difference in implementations where some return a
262 <computeroutput>character</computeroutput>
264 <computeroutput>integer</computeroutput>
265 whence dereferencing a
266 <computeroutput>C</computeroutput>
271 <title>Examples</title>
273 (def-array-pointer ca :unsigned-char)
274 (let ((fs (convert-to-foreign-string "ab")))
275 (values (null-char-p (deref-array fs 'ca 0))
276 (null-char-p (deref-array fs 'ca 2))))
282 <title>Side Effects</title>
287 <title>Affected by</title>
291 <title>Exceptional Situations</title>