1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: UFFI test arrays
7 ;;;; Author: Kevin M. Rosenberg
8 ;;;; Date Started: Mar 2002
10 ;;;; $Id: arrays.lisp,v 1.4 2003/05/01 04:59:37 kevin Exp $
12 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; UFFI users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
19 (in-package :uffi-tests)
21 (uffi:def-constant +column-length+ 10)
22 (uffi:def-constant +row-length+ 10)
24 (uffi:def-foreign-type long-ptr '(* :long))
27 (let ((a (uffi:allocate-foreign-object :long +column-length+))
29 (dotimes (i +column-length+)
30 (setf (uffi:deref-array a '(:array :long) i) (* i i)))
31 (dotimes (i +column-length+)
32 (push (uffi:deref-array a '(:array :long) i) results))
33 (uffi:free-foreign-object a)
35 (0 1 4 9 16 25 36 49 64 81))
39 (let ((a (uffi:allocate-foreign-object 'long-ptr +row-length+))
41 (dotimes (r +row-length+)
43 (setf (uffi:deref-array a '(:array (* :long)) r)
44 (uffi:allocate-foreign-object :long +column-length+))
45 (let ((col (uffi:deref-array a '(:array (* :long)) r)))
46 (dotimes (c +column-length+)
48 (setf (uffi:deref-array col '(:array :long) c) (+ (* r +column-length+) c)))))
50 (dotimes (r +row-length+)
52 (let ((col (uffi:deref-array a '(:array (* :long)) r)))
53 (dotimes (c +column-length+)
55 (push (uffi:deref-array col '(:array :long) c) results))))
56 (uffi:free-foreign-object a)
58 (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99))