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.5 2003/08/13 18:53:42 kevin Exp $
12 ;;;; This file, part of UFFI, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
14 ;;;; *************************************************************************
16 (in-package #:uffi-tests)
18 (uffi:def-union tunion1
25 (defvar *u* (uffi:allocate-foreign-object 'tunion1))
26 (setf (uffi:get-slot-value *u* 'tunion1 'uint)
27 #-(or sparc sparc-v9 powerpc ppc)
28 (+ (* 1 (char-code #\A))
29 (* 256 (char-code #\B))
30 (* 65536 (char-code #\C))
32 #+(or sparc sparc-v9 powerpc ppc)
33 (+ (* 16777216 (char-code #\A))
34 (* 65536 (char-code #\B))
35 (* 256 (char-code #\C))
38 (deftest union.1 (uffi:ensure-char-character
39 (uffi:get-slot-value *u* 'tunion1 'char)) #\A)
41 #-(or sparc sparc-v9 mcl)
42 (deftest union.2 (plusp (uffi:get-slot-value *u* 'tunion1 'uint)) t)
45 ;; (uffi:free-foreign-object u))