9e344db55f2882182e20e89d0aea01b9a6c2cdd0
[uffi.git] / tests / array-2d.cl
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          array-2d.cl
6 ;;;; Purpose:       UFFI Example file use 2-dimensional arrays
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Mar 2002
9 ;;;;
10 ;;;; $Id: array-2d.cl,v 1.1 2002/03/18 02:27:32 kevin Exp $
11 ;;;;
12 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
13 ;;;;
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 ;;;; *************************************************************************
18
19 (in-package :cl-user)
20
21 (uffi:def-constant +column-length+ 10)
22
23 (uffi:def-array long-array (:long 10))
24
25 (defun test-array-2d ()
26   "Tests 2d array"
27   (let ((a (uffi:allocate-foreign-object long-array)))
28     (dotimes (i +column-length+)
29       (setf (uffi:deref-array a :long i) (* i i)))
30     (dotimes (i +column-length+)
31       (format "~&~D => ~D" i (uffi:deref-array a 'long-array i)))
32     (uffi:free-foreign-object a)))
33
34 #+test-uffi
35 (test-array-2d)
36
37