1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: UFFI source to handle objects and pointers
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Feb 2002
10 ;;;; $Id: objects.cl,v 1.5 2002/03/14 21:03:12 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 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
22 (defmacro allocate-foreign-object (type)
24 `(alien:make-alien ,(convert-from-uffi-type type :allocation))
26 `(fli:allocate-foreign-object :type ',(convert-from-uffi-type type :allocate))
28 `(ff:allocate-fobject ',(convert-from-uffi-type type :allocate) :c)
31 (defmacro free-foreign-object (obj)
33 `(alien:free-alien ,obj)
35 `(fli:free-foreign-object ,obj)
37 `(ff:free-fobject ,obj)
40 (defmacro null-pointer-p (obj)
41 #+lispworks `(fli:null-pointer-p ,obj)
42 #+allegro `(zerop ,obj)
43 #+cmu `(alien:null-alien ,obj)
47 (defmacro make-null-pointer (type)
48 #+(or allegro cmu) (declare (ignore type))
50 #+cmu `(system:int-sap 0)
52 #+lispworks `(fli:make-pointer :address 0 :type ,type)
55 (defmacro deref-pointer (ptr type)
56 "Returns a object pointed"
57 #+(or lispworks cmu) (declare (ignore type))
58 #+cmu `(alien:deref ,ptr)
59 #+lispworks `(fli:dereference ,ptr)
60 #+allegro `(ff:fslot-value-typed ,type :c ,ptr)
63 (defmacro pointer-address (obj)
65 `(system:sap-int (alien:alien-sap ,obj))
67 `(fli:pointer-address ,obj)