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

Contents of /package.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (hide annotations)
Sat Dec 22 19:24:45 2012 UTC (15 months, 3 weeks ago) by rklochkov
File size: 3424 byte(s)
Fixed array. Removed redefinition of cffi:mem-ref
1 rklochkov 13 ;;;;<title> CFFI-Objects</title>
2     ;;;;<author>Roman Klochkov, monk@slavsoft.surgut.ru</author>
3     ;;;;<date>2012</date>
4 rklochkov 1
5 rklochkov 13 ;;;; Package definition for cffi-objects,
6     ;;;; that is a CFFI add-on, supporting GLib/GObject/GDK/GTK and similar objects
7    
8     ;;;<insert name="introduction"/>
9    
10     ;;;[ [[* Package definition *]]
11    
12 rklochkov 1 (in-package #:cl-user)
13    
14 rklochkov 13 #|<doc>
15     We unexport all symbols before [[defpackage]], because
16     CFFI-objects will be a drop-in replacemant for CFFI and I don't
17     want to export by hand all symbols exported by CFFI.
18     |#
19    
20 rklochkov 1 (eval-when (:compile-toplevel :load-toplevel)
21     (let ((p (find-package "CFFI-OBJECTS")))
22     (when p
23     (do-external-symbols (v p)
24     (unexport (list v) p)))))
25    
26     (defpackage #:cffi-objects
27     (:use #:common-lisp #:cffi)
28     (:export
29 rklochkov 13 #:freeable-base
30     ;; slots
31     #:free-from-foreign
32     #:free-to-foreign
33     ;; freeable-base API
34     #:free-sent-if-needed
35     #:free-returned-if-needed
36     #:free-ptr
37     #:free-sent-ptr
38     #:free-returned-ptr
39    
40     #:freeable
41     #:freeable-out
42     #:copy-from-foreign
43    
44 rklochkov 1 #:gconstructor
45    
46     #:object
47 rklochkov 3 #:free-after
48 rklochkov 2 #:find-object
49 rklochkov 1 #:object-by-id
50 rklochkov 7 #:initialize
51 rklochkov 1 #:*objects*
52     #:*objects-ids*
53 rklochkov 2 #:object-class
54     #:volatile
55 rklochkov 1 ;; slots
56     #:pointer
57     ;; methods
58     #:free
59    
60 rklochkov 2
61     #:*array-length*
62 rklochkov 1 ;; types
63     #:pstring
64     #:pfunction
65     #:cffi-object
66 rklochkov 2 #:cffi-array
67     #:cffi-null-array
68     #:carray
69     #:null-array
70     #:string-array
71 rklochkov 1
72 rklochkov 6 #:cffi-keyword
73     #:cffi-pathname
74 rklochkov 7 #:cffi-string
75 rklochkov 6
76 rklochkov 1 #:struct
77     ; #:cffi-struct
78     #:new-struct
79     #:free-struct
80    
81    
82     #:defcstruct-accessors
83     #:defcstruct*
84     #:defbitaccessors
85    
86     #:with-foreign-out
87     #:with-foreign-outs
88     #:with-foreign-outs-list
89    
90     #:pair
91     #:setf-init
92     #:init-slots
93     #:save-setter
94     #:remove-setter
95     #:clear-setters))
96    
97 rklochkov 13 ;;;<doc> Now simply reexport all CFFI symbols.
98 rklochkov 1 (eval-when (:compile-toplevel :load-toplevel)
99     (let ((cffi (find-package "CFFI"))
100     (cffi-objects (find-package "CFFI-OBJECTS")))
101     (do-external-symbols (v cffi)
102 rklochkov 13 (export (list v) cffi-objects))))
103    
104     ;;; <define name="introduction">
105     #|<doc>
106     [[* Introduction *]]
107    
108     This document describes CFFI-objects: library, that extends CFFI to support
109     structures, objects and reference parameters.
110    
111     Other alternatives are Virgil and FSBV/cffi-libffi. Virgil tend to marshall all
112     data back and forth. There are no support for structures as pointers.
113     FSBV is obsoleted by cffi-libffi. Libffi I dislike, because it gives another
114     layer of indirection (so make it slower) without new features (no bit fields
115     in structures).
116    
117     So I made my own library. It gives the opportunity for programmer to
118     say which structures should be return values and how to save every
119     particular structure -- as pointer or as a lisp value.
120    
121     Example:
122     \begin{alltt}
123     (defcstruct* foo (bar :int) (baz :int))
124     (defvar foo-as-ptr (make-instance 'foo :new-struct t))
125     (defvar foo-as-value (make-instance 'foo))
126    
127     (defcfun foo-maker (struct foo))
128     (defcfun proceed-foo :void (param (struct foo :out t)))
129     (defcfun print-foo :void (param (struct foo)))
130     \end{alltt}
131    
132     Here you can use either [[foo-as-ptr]] or [[foo-as-value]] in all functions.
133     [[Foo-as-ptr]] is faster, because it shouldn't convert values from Lisp to C
134     and back, but if foreign pointer is not considered stable (may be freed
135     by another c-function) or you don't want to control, when you need
136     to free foreign pointer, you should use [[foo-as-value]].
137    
138     \include{redefines}
139     |#
140     ;;; </define>
141    
142    
143    

  ViewVC Help
Powered by ViewVC 1.1.5