1 ;;;; -*- Mode: ANSI-Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: UFFI -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: UFFI source to C function defintions
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Feb 2002
10 ;;;; $Id: functions.cl,v 1.1 2002/04/04 05:01:45 desoi 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 (defun process-function-args (args)
30 (push (process-one-function-arg arg) processed))
31 (nreverse processed))))
33 (defun process-one-function-arg (arg)
34 (let ((name (car arg))
35 (type (convert-from-uffi-type (cadr arg) :routine)))
36 (if (and (listp type) (listp (car type)))
37 (append (list name) type)
41 (defun allegro-convert-return-type (type)
42 (if (and (listp type) (not (listp (car type))))
46 ;; name is either a string representing foreign name, or a list
47 ;; of foreign-name as a string and lisp name as a symbol
50 (defmacro def-function (names args &key module returning)
51 (declare (ignore module))
53 (let* ((result-type (convert-from-uffi-type returning :return))
54 (function-args (process-function-args args))
55 (foreign-name (if (atom names) names (car names)))
56 (lisp-name (if (atom names) (make-lisp-name names) (cadr names))))
57 `(eval-when (:compile-toplevel :load-toplevel :execute)
58 (ccl:define-entry-point (,lisp-name ,foreign-name)
63 (defun make-lisp-name (name)
64 (let ((converted (substitute #\- #\_ name)))
66 #+case-sensitive converted
67 #-case-sensitive (string-upcase converted))))