r1584: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 18 Mar 2002 02:27:32 +0000 (02:27 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 18 Mar 2002 02:27:32 +0000 (02:27 +0000)
doc/ref.sgml
examples/array-2d.cl [new file with mode: 0644]
src/objects.cl
src/primitives.cl
test-examples.cl
tests/array-2d.cl [new file with mode: 0644]

index 51d61b4f015601e7f27f14c27c076175ec4c9bc5..e8c45fd222e31318faaf6f6f8f921d368fa21bda 100644 (file)
@@ -496,7 +496,7 @@ structure. It's type is <constant>:pointer-self</constant>.
 
     <refentry id="get-slot-value">
       <refnamediv>
-       <refname>def-slot-value</refname>
+       <refname>get-slot-value</refname>
        <refpurpose>Retrieves a value from a slot of a structure.
        </refpurpose>
        <refclass>Macro</refclass>
@@ -830,7 +830,7 @@ the array.
        <title>Examples</title>
        <programlisting>
 (def-struct ab (a :int) (b :double))
-(allocate-foreign-object 'ab)
+(allocate-foreign-object ab)
 => #&lt;ptr&gt;
        </programlisting>
       </refsect1>
@@ -958,7 +958,7 @@ the array.
       <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
-         <function>def-pointer</function> <replaceable>ptr type</replaceable> => <returnvalue>value</returnvalue>
+         <function>deref-pointer</function> <replaceable>ptr type</replaceable> => <returnvalue>value</returnvalue>
        </synopsis>
       </refsynopsisdiv>
       <refsect1>
diff --git a/examples/array-2d.cl b/examples/array-2d.cl
new file mode 100644 (file)
index 0000000..9e344db
--- /dev/null
@@ -0,0 +1,37 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          array-2d.cl
+;;;; Purpose:       UFFI Example file use 2-dimensional arrays
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Mar 2002
+;;;;
+;;;; $Id: array-2d.cl,v 1.1 2002/03/18 02:27:32 kevin Exp $
+;;;;
+;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;;
+;;;; UFFI users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+;;;; *************************************************************************
+
+(in-package :cl-user)
+
+(uffi:def-constant +column-length+ 10)
+
+(uffi:def-array long-array (:long 10))
+
+(defun test-array-2d ()
+  "Tests 2d array"
+  (let ((a (uffi:allocate-foreign-object long-array)))
+    (dotimes (i +column-length+)
+      (setf (uffi:deref-array a :long i) (* i i)))
+    (dotimes (i +column-length+)
+      (format "~&~D => ~D" i (uffi:deref-array a 'long-array i)))
+    (uffi:free-foreign-object a)))
+
+#+test-uffi
+(test-array-2d)
+
+
index 0f28115a0cbd24565ad81b915475212994923d77..01884302c2679606db6e7af3a7592f0ef8459cce 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: objects.cl,v 1.6 2002/03/17 17:33:30 kevin Exp $
+;;;; $Id: objects.cl,v 1.7 2002/03/18 02:27:28 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
   #+allegro
   obj
   )
+
+(defmacro allocate-byte-array (nsize)
+  #+cmu
+  `(alien:make-alien (alien:unsigned 8) ,nsize)
+  #+lispworks
+  `(fli:allocate-foreign-object :type :byte :nelems ,nsize)
+  #+allegro
+  `(ff:allocate-fobject (array :byte ,nsize))
+)
+
+(defmacro deref-byte-array (array position)
+  #+cmu `(alien:deref ,array ,position)
+  #+lispworks `(fli:dereference ,array :index ,position)
+  #+allegro `(ff:fslot-value-typed '(:array :byte) :c ,array ,position)
+)
+
+
+
+
+)
index 0048668d9779c1bd0289c9d4a6c2efcb03021950..40bc449888746c2d18ec384915f251c302c5b79c 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: primitives.cl,v 1.8 2002/03/17 17:33:30 kevin Exp $
+;;;; $Id: primitives.cl,v 1.9 2002/03/18 02:27:28 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -78,7 +78,8 @@ supports takes advantage of this optimization."
       (:char . c-call:char) 
       (:unsigned-char . (alien:unsigned 8))
       (:byte . (alien:unsigned 8))
-      (:short . c-call:unsigned-short) (:unsigned-short c-call:unsigned-short)
+      (:short . c-call:unsigned-short) 
+      (:unsigned-short . c-call:unsigned-short)
       (:int . alien:integer) (:unsigned-int . c-call:unsigned-int) 
       (:long . c-call:long) (:unsigned-long . c-call:unsigned-long)
       (:float . c-call:float) (:double . c-call:double)
index c8fa0ac449279a419a3660895dadf7793983eced..2a4c100a94c5632b729e6e752c5256a640059314 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: test-examples.cl,v 1.4 2002/03/17 17:33:30 kevin Exp $
+;;;; $Id: test-examples.cl,v 1.5 2002/03/18 02:27:32 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -26,7 +26,8 @@
                               :type "cl"
                               :directory '(:relative "examples"))
                *load-truename*))))
-  
+
+  (load-test "array-2d")
   (load-test "strtol")
   (load-test "gettime")
   (load-test "getenv")
diff --git a/tests/array-2d.cl b/tests/array-2d.cl
new file mode 100644 (file)
index 0000000..9e344db
--- /dev/null
@@ -0,0 +1,37 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          array-2d.cl
+;;;; Purpose:       UFFI Example file use 2-dimensional arrays
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Mar 2002
+;;;;
+;;;; $Id: array-2d.cl,v 1.1 2002/03/18 02:27:32 kevin Exp $
+;;;;
+;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;;
+;;;; UFFI users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+;;;; *************************************************************************
+
+(in-package :cl-user)
+
+(uffi:def-constant +column-length+ 10)
+
+(uffi:def-array long-array (:long 10))
+
+(defun test-array-2d ()
+  "Tests 2d array"
+  (let ((a (uffi:allocate-foreign-object long-array)))
+    (dotimes (i +column-length+)
+      (setf (uffi:deref-array a :long i) (* i i)))
+    (dotimes (i +column-length+)
+      (format "~&~D => ~D" i (uffi:deref-array a 'long-array i)))
+    (uffi:free-foreign-object a)))
+
+#+test-uffi
+(test-array-2d)
+
+