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

Contents of /redefines.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (show annotations)
Fri Aug 24 19:26:53 2012 UTC (19 months, 3 weeks ago) by rklochkov
File size: 1213 byte(s)
Fixed FREE-PTR generic. First param is a symbol
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; redefines.lisp --- fix :double, alternate string
4 ;;;
5 ;;; Copyright (C) 2012, Roman Klochkov <monk@slavsoft.surgut.ru>
6 ;;;
7
8 (in-package #:cffi-objects)
9
10 (defmethod expand-to-foreign-dyn :around
11 (value var body (type cffi::foreign-built-in-type))
12 (if (eq (cffi::type-keyword type) :double)
13 `(let ((,var (coerce ,value 'double-float))) ,@body)
14 `(let ((,var ,value)) ,@body)))
15
16 (define-foreign-type cffi-keyword (freeable)
17 ()
18 (:simple-parser cffi-keyword)
19 (:actual-type :pointer))
20
21 (defmethod translate-to-foreign ((value symbol) (type cffi-keyword))
22 (foreign-string-alloc (string-downcase value)))
23
24 (defmethod translate-to-foreign ((value string) (type cffi-keyword))
25 (foreign-string-alloc value))
26
27 (defmethod free-ptr ((type (eql 'cffi-keyword)) ptr)
28 (foreign-string-free ptr))
29
30 (define-foreign-type cffi-pathname (freeable)
31 ()
32 (:simple-parser cffi-pathname)
33 (:actual-type :string))
34
35 (defmethod translate-to-foreign ((value pathname) (type cffi-pathname))
36 (convert-to-foreign (namestring value) :string))
37
38 (defmethod translate-to-foreign ((value string) (type cffi-pathname))
39 (convert-to-foreign value :string))
40
41
42

  ViewVC Help
Powered by ViewVC 1.1.5