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
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))
39 (uffi:ensure-char-character
40 (uffi:get-slot-value *u* 'tunion1 'char))
44 (uffi:ensure-char-integer
45 (uffi:get-slot-value *u* 'tunion1 'char))
48 #-(or sparc sparc-v9 mcl)
49 (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
59 (with-foreign-object (p 'foo-u)
65 (uffi:def-foreign-type foo-union (:union foo-u))