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 bits, depending upon the platform.</para>
56 <para><constant>:unsigned-long</constant> - Unsigned 32 or 64 bits, depending upon the platform.</para>
59 <para><constant>:float</constant> - 32-bit floating point.</para>
62 <para><constant>:double</constant> - 64-bit floating point.</para>
65 <para><constant>:cstring</constant> -
66 A &null; terminated string used for passing and returning characters strings with a &c; function.
70 <para><constant>:void</constant> -
71 The absence of a value. Used to indicate that a function does not return a value.
75 <para><constant>:pointer-void</constant> - Points to a generic object.</para>
78 <para><constant>*</constant> - Used to declare a pointer to an object</para>
83 <refentry id="def-constant">
85 <refname>def-constant</refname>
86 <refpurpose>Binds a symbol to a constant.
88 <refclass>Macro</refclass>
93 <function>def-constant</function> <replaceable>name value &key export</replaceable>
97 <title>Arguments and Values</title>
100 <term><parameter>name</parameter></term>
102 <para>A symbol that will be bound to the value.
107 <term><parameter>value</parameter></term>
109 <para>An evaluated form that is bound the the name.
114 <term><parameter>export</parameter></term>
116 <para>When &t;, the name is exported from the current package. The default is &nil;</para>
122 <title>Description</title>
123 <para>This is a thin wrapper around <function>defconstant</function>. It evaluates at
124 compile-time and optionally exports the symbol from the package.
128 <title>Examples</title>
130 (def-constant pi2 (* 2 pi))
131 (def-constant exported-pi2 (* 2 pi) :export t)
135 <title>Side Effects</title>
136 <para>Creates a new special variable..</para>
139 <title>Affected by</title>
143 <title>Exceptional Situations</title>
148 <refentry id="def-foreign-type">
150 <refname>def-foreign-type</refname>
151 <refpurpose>Defines a new foreign type.
153 <refclass>Macro</refclass>
156 <title>Syntax</title>
158 <function>def-foreign-type</function> <replaceable>name type</replaceable>
162 <title>Arguments and Values</title>
165 <term><parameter>name</parameter></term>
167 <para>A symbol naming the new foreign type.
172 <term><parameter>value</parameter></term>
174 <para>A form that is not evaluated that defines the new
182 <title>Description</title>
183 <para>Defines a new foreign type.
187 <title>Examples</title>
189 (def-foreign-type my-generic-pointer :pointer-void)
190 (def-foreign-type a-double-float :double-float)
191 (def-foreign-type char-ptr (* :char))
195 <title>Side Effects</title>
196 <para>Defines a new foreign type.
200 <title>Affected by</title>
204 <title>Exceptional Situations</title>
209 <refentry id="null-char-p">
211 <refname>null-char-p</refname>
212 <refpurpose>Tests a character for &null; value.
214 <refclass>Macro</refclass>
217 <title>Syntax</title>
219 <function>null-char-p</function> <replaceable>char</replaceable> => <returnvalue>is-null</returnvalue>
223 <title>Arguments and Values</title>
226 <term><parameter>char</parameter></term>
228 <para>A character or integer.
233 <term><parameter>is-null</parameter></term>
235 <para>A boolean flag indicating if char is a &null; value.
242 <title>Description</title>
244 A predicate testing if a character or integer is &null;. This
245 abstracts the difference in implementations where some return a
246 <computeroutput>character</computeroutput>
248 <computeroutput>integer</computeroutput>
249 whence dereferencing a
250 <computeroutput>C</computeroutput>
255 <title>Examples</title>
257 (def-array-pointer ca :unsigned-char)
258 (let ((fs (convert-to-foreign-string "ab")))
259 (values (null-char-p (deref-array fs 'ca 0))
260 (null-char-p (deref-array fs 'ca 2))))
266 <title>Side Effects</title>
271 <title>Affected by</title>
275 <title>Exceptional Situations</title>