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 ;;;; This file, part of UFFI, is Copyright (c) 2002-2010 by Kevin M. Rosenberg
12 ;;;; *************************************************************************
14 (in-package #:uffi-tests)
16 (uffi:def-union tunion1
23 (defvar *u* (uffi:allocate-foreign-object 'tunion1))
24 (setf (uffi:get-slot-value *u* 'tunion1 'uint)
25 #-(or sparc sparc-v9 powerpc ppc)
26 (+ (* 1 (char-code #\A))
27 (* 256 (char-code #\B))
28 (* 65536 (char-code #\C))
30 #+(or sparc sparc-v9 powerpc ppc)
31 (+ (* 16777216 (char-code #\A))
32 (* 65536 (char-code #\B))
33 (* 256 (char-code #\C))
37 (uffi:ensure-char-character
38 (uffi:get-slot-value *u* 'tunion1 'char))
42 (uffi:ensure-char-integer
43 (uffi:get-slot-value *u* 'tunion1 'char))
46 #-(or sparc sparc-v9 openmcl digitool)
47 (deftest :union.3 (plusp (uffi:get-slot-value *u* 'tunion1 'uint)) t)
55 (uffi:def-foreign-type foo-u-ptr (* foo-u))
57 ;; tests that compilation worked
60 (with-foreign-object (p 'foo-u)
67 (uffi:def-foreign-type foo-union (:union foo-u))