1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: UFFI Example file to test unions
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Mar 2002
10 ;;;; $Id: union.lisp,v 1.4 2003/04/29 14:08:02 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-union tunion1
28 (defvar *u* (uffi:allocate-foreign-object 'tunion1))
29 (setf (uffi:get-slot-value *u* 'tunion1 'uint)
30 #-(or sparc sparc-v9 powerpc ppc)
31 (+ (* 1 (char-code #\A))
32 (* 256 (char-code #\B))
33 (* 65536 (char-code #\C))
35 #+(or sparc sparc-v9 powerpc ppc)
36 (+ (* 16777216 (char-code #\A))
37 (* 65536 (char-code #\B))
38 (* 256 (char-code #\C))
41 (deftest union.1 (uffi:ensure-char-character
42 (uffi:get-slot-value *u* 'tunion1 'char)) #\A)
44 #-(or sparc sparc-v9 mcl)
45 (deftest union.2 (plusp (uffi:get-slot-value *u* 'tunion1 'uint)) t)
48 ;; (uffi:free-foreign-object u))