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

Contents of /redefines.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (show annotations)
Sun Jul 29 15:15:41 2012 UTC (20 months, 3 weeks ago) by rklochkov
File size: 1001 byte(s)
Fixed memory leaks
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 ;; make type string with :free for uniformity
17 (define-foreign-type cffi-string (freeable)
18 ()
19 (:actual-type :pointer)
20 (:simple-parser pstring))
21
22 (defmethod translate-to-foreign ((value string) (type cffi-string))
23 (values (foreign-string-alloc value) value))
24
25 (defmethod translate-to-foreign (value (type cffi-string))
26 (values (foreign-string-alloc (string value)) value))
27
28 (defmethod free-ptr ((type cffi-string) ptr)
29 (foreign-string-free ptr))
30
31 (defmethod translate-from-foreign (ptr (type cffi-string))
32 (foreign-string-to-lisp ptr))
33

  ViewVC Help
Powered by ViewVC 1.1.5