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

Contents of /redefines.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Sun Aug 12 17:36:30 2012 UTC (20 months ago) by rklochkov
File size: 1206 byte(s)
Changed API for freeable to be consistent with CFFI: 
changed :FREE to :FREE-FROM-FOREIGN and :FREE-TO-FOREIGN as in :STRING

Synced with last version of CFFI


1 rklochkov 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 rklochkov 7 (define-foreign-type cffi-keyword (freeable)
17 rklochkov 6 ()
18     (:simple-parser cffi-keyword)
19 rklochkov 8 (:actual-type :pointer))
20 rklochkov 6
21     (defmethod translate-to-foreign ((value symbol) (type cffi-keyword))
22 rklochkov 8 (foreign-string-alloc (string-downcase value)))
23 rklochkov 6
24     (defmethod translate-to-foreign ((value string) (type cffi-keyword))
25 rklochkov 8 (foreign-string-alloc value))
26 rklochkov 6
27 rklochkov 8 (defmethod free-ptr ((type cffi-keyword) ptr)
28     (foreign-string-free ptr))
29    
30 rklochkov 7 (define-foreign-type cffi-pathname (freeable)
31 rklochkov 6 ()
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