r1588: Added array allocation to allocate-foreign-objects
[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.2 2002/03/18 22:47:57 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 (defun test-array-2d ()
24   "Tests 2d array"
25   (let ((a (uffi:allocate-foreign-object :long +column-length+)))
26     (dotimes (i +column-length+)
27       (setf (uffi:deref-array a '(:array :long) i) (* i i)))
28     (dotimes (i +column-length+)
29       (format t "~&~D => ~D" i (uffi:deref-array a '(:array :long) i)))
30     (uffi:free-foreign-object a))
31   (values))
32
33 #+test-uffi
34 (test-array-2d)
35
36