/[cffi-objects]/pfunction.lisp
ViewVC logotype

Contents of /pfunction.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Thu Feb 9 15:53:55 2012 UTC (2 years, 2 months ago) by rklochkov
File size: 766 byte(s)
Initial release
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; object.lisp --- CFFI type PFUNCTION
4 ;;;
5 ;;; Copyright (C) 2007, Roman Klochkov <kalimehtar@mail.ru>
6 ;;;
7
8 (in-package :cffi-objects)
9
10 (define-foreign-type pfunction ()
11 ()
12 (:actual-type :pointer)
13 (:simple-parser pfunction)
14 (:documentation "Takes a foreign pointer, keyword or a string.
15 Keyword or a string = name of C function, substituting #\- to #\_"))
16
17 (defmethod translate-to-foreign (value (type pfunction))
18 (labels ((to-ptr (str)
19 (declare (type string str))
20 (foreign-symbol-pointer (substitute #\_ #\- str))))
21 (etypecase value
22 (string (to-ptr value))
23 (keyword (to-ptr (string-downcase value)))
24 (foreign-pointer value)
25 (null (null-pointer)))))

  ViewVC Help
Powered by ViewVC 1.1.5