projects
/
uffi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r8251: fix compilation on SunOS
[uffi.git]
/
src
/
functions.lisp
diff --git
a/src/functions.lisp
b/src/functions.lisp
index 03b8d59f72bece9e317bd5ac19a94bda89dba1de..7f0939d5afe2dd20fdcf7d7264096483a39e51fb 100644
(file)
--- a/
src/functions.lisp
+++ b/
src/functions.lisp
@@
-2,12
+2,12
@@
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
-;;;; Name: function.
cl
-;;;; Purpose: UFFI source to C function defintions
+;;;; Name: function.
lisp
+;;;; Purpose: UFFI source to C function defin
i
tions
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id
: functions.lisp,v 1.1 2002/09/30 10:02:36 kevin Exp
$
+;;;; $Id$
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
@@
-16,47
+16,45
@@
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :uffi)
+(in-package #:uffi)
(defun process-function-args (args)
(if (null args)
(defun process-function-args (args)
(if (null args)
- #+
lispworks
nil
+ #+
(or lispworks cmu sbcl scl cormanlisp (and mcl (not openmcl)))
nil
#+allegro '(:void)
#+allegro '(:void)
- #+cmu nil
- #+(and mcl (not openmcl)) nil
- #+mcl (values nil nil)
+ #+openmcl (values nil nil)
;; args not null
;; args not null
- #+(or lispworks allegro cmu
(and mcl (not openmcl))
)
+ #+(or lispworks allegro cmu
sbcl scl (and mcl (not openmcl)) cormanlisp
)
(let (processed)
(dolist (arg args)
(push (process-one-function-arg arg) processed))
(nreverse processed))
#+openmcl
(let ((processed nil)
(let (processed)
(dolist (arg args)
(push (process-one-function-arg arg) processed))
(nreverse processed))
#+openmcl
(let ((processed nil)
- (params nil)
- name type)
+ (params nil))
(dolist (arg args)
(dolist (arg args)
- (
setf
name (car arg))
-
(setf type (convert-from-uffi-type (cadr arg) :routine
))
- ;;(when (and (listp type) (eq (car type) :address))
- ;;(setf type :address))
- (push name params)
- (push type processed)
-
(push name processed
))
+ (
let ((
name (car arg))
+
(type (convert-from-uffi-type (cadr arg) :routine)
))
+
;;(when (and (listp type) (eq (car type) :address))
+
;;(setf type :address))
+
(push name params)
+
(push type processed)
+
(push name processed)
))
(values (nreverse params) (nreverse processed)))
))
(defun process-one-function-arg (arg)
(let ((name (car arg))
(type (convert-from-uffi-type (cadr arg) :routine)))
(values (nreverse params) (nreverse processed)))
))
(defun process-one-function-arg (arg)
(let ((name (car arg))
(type (convert-from-uffi-type (cadr arg) :routine)))
- #+
cmu
+ #+
(or cmu sbcl scl)
(list name type :in)
#+(or allegro lispworks (and mcl (not openmcl)))
(if (and (listp type) (listp (car type)))
(append (list name) type)
(list name type))
(list name type :in)
#+(or allegro lispworks (and mcl (not openmcl)))
(if (and (listp type) (listp (car type)))
(append (list name) type)
(list name type))
+ #+openmcl
+ (declare (ignore name type))
))
))
@@
-68,40
+66,54
@@
;; name is either a string representing foreign name, or a list
;; of foreign-name as a string and lisp name as a symbol
(defmacro def-function (names args &key module returning)
;; name is either a string representing foreign name, or a list
;; of foreign-name as a string and lisp name as a symbol
(defmacro def-function (names args &key module returning)
- #+(or cmu
allegro mcl
) (declare (ignore module))
+ #+(or cmu
sbcl scl allegro mcl cormanlisp
) (declare (ignore module))
(let* ((result-type (convert-from-uffi-type returning :return))
(function-args (process-function-args args))
(foreign-name (if (atom names) names (car names)))
(lisp-name (if (atom names) (make-lisp-name names) (cadr names))))
(let* ((result-type (convert-from-uffi-type returning :return))
(function-args (process-function-args args))
(foreign-name (if (atom names) names (car names)))
(lisp-name (if (atom names) (make-lisp-name names) (cadr names))))
-
+
+ ;; todo: calling-convention :stdcall for cormanlisp
#+allegro
`(ff:def-foreign-call (,lisp-name ,foreign-name)
,function-args
:returning ,(allegro-convert-return-type result-type)
:call-direct t
:strings-convert nil)
#+allegro
`(ff:def-foreign-call (,lisp-name ,foreign-name)
,function-args
:returning ,(allegro-convert-return-type result-type)
:call-direct t
:strings-convert nil)
- #+
cmu
+ #+
(or cmu scl)
`(alien:def-alien-routine (,foreign-name ,lisp-name)
,result-type
,@function-args)
`(alien:def-alien-routine (,foreign-name ,lisp-name)
,result-type
,@function-args)
+ #+sbcl
+ `(sb-alien:define-alien-routine (,foreign-name ,lisp-name)
+ ,result-type
+ ,@function-args)
#+lispworks
`(fli:define-foreign-function (,lisp-name ,foreign-name :source)
,function-args
,@(if module (list :module module) (values))
:result-type ,result-type
#+lispworks
`(fli:define-foreign-function (,lisp-name ,foreign-name :source)
,function-args
,@(if module (list :module module) (values))
:result-type ,result-type
+ :language :ansi-c
:calling-convention :cdecl)
#+(and mcl (not openmcl))
`(eval-when (:compile-toplevel :load-toplevel :execute)
(ccl:define-entry-point (,lisp-name ,foreign-name)
,function-args
,result-type))
:calling-convention :cdecl)
#+(and mcl (not openmcl))
`(eval-when (:compile-toplevel :load-toplevel :execute)
(ccl:define-entry-point (,lisp-name ,foreign-name)
,function-args
,result-type))
+ #+openmcl
+ (declare (ignore function-args))
#+(and openmcl darwinppc-target)
(setf foreign-name (concatenate 'string "_" foreign-name))
#+openmcl
(multiple-value-bind (params args) (process-function-args args)
`(defun ,lisp-name ,params
(ccl::external-call ,foreign-name ,@args ,result-type)))
#+(and openmcl darwinppc-target)
(setf foreign-name (concatenate 'string "_" foreign-name))
#+openmcl
(multiple-value-bind (params args) (process-function-args args)
`(defun ,lisp-name ,params
(ccl::external-call ,foreign-name ,@args ,result-type)))
+ #+cormanlisp
+ `(ct:defun-dll ,lisp-name (,function-args)
+ :return-type ,result-type
+ ,@(if module (list :library-name module) (values))
+ :entry-name ,foreign-name
+ :linkage-type ,calling-convention) ; we need :pascal
))
))