Skip to content

Commit f2a40da

Browse files
committed
Pass around Lisp object instead of foreign addresses
1 parent aa3ced2 commit f2a40da

25 files changed

+78
-63
lines changed

classesdb.lisp-sexp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;;; generated at 2019-05-18T16:24:05.000000Z for IUP 3.27 -*-lisp-*-
1+
;;; generated at 2019-05-23T18:15:44.000000Z for IUP 3.27 -*-lisp-*-
22

33
((:PLATFORM :LINUX :METADATA
44
((:PACKAGE "IUP" :CLASSNAMES
File renamed without changes.
File renamed without changes.

gl/gl-cffi.lisp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(defpackage #:iup-gl-cffi
2-
(:use #:common-lisp))
2+
(:use #:common-lisp)
3+
(:import-from #:tecgraf-base #:ihandle))
34

45
(in-package #:iup-gl-cffi)
56

@@ -13,23 +14,23 @@
1314
(cffi:defcfun (%iup-gl-canvas-open "IupGLCanvasOpen") :void)
1415

1516
(cffi:defcfun (%iup-gl-make-current "IupGLMakeCurrent") :void
16-
(handle iup-cffi::ihandle))
17+
(handle ihandle))
1718

1819
(cffi:defcfun (%iup-gl-is-current "IupGLIsCurrent") :boolean
19-
(handle iup-cffi::ihandle))
20+
(handle ihandle))
2021

2122
(cffi:defcfun (%iup-gl-swap-buffers "IupGLSwapBuffers") :void
22-
(handle iup-cffi::ihandle))
23+
(handle ihandle))
2324

2425
(cffi:defcfun (%iup-gl-palette "IupGLPalette") :void
25-
(handle iup-cffi::ihandle)
26+
(handle ihandle)
2627
(index :int)
2728
(r :float)
2829
(g :float)
2930
(b :float))
3031

3132
(cffi:defcfun (%iup-gl-use-font "IupGLUseFont") :void
32-
(handle iup-cffi::ihandle)
33+
(handle ihandle)
3334
(first :int)
3435
(count :int)
3536
(list-base :int))

glcontrols/glcontrols-cffi.lisp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(defpackage #:iup-glcontrols-cffi
2-
(:use #:common-lisp))
2+
(:use #:common-lisp)
3+
(:import-from #:tecgraf-base #:ihandle))
34

45
(in-package #:iup-glcontrols-cffi)
56

@@ -13,21 +14,21 @@
1314
(cffi:defcfun (%iup-glcontrols-open "IupGLControlsOpen") :int)
1415

1516
(cffi:defcfun (%iup-glcontrols-draw-image "IupGLDrawImage") :void
16-
(handle iup-cffi::ihandle)
17+
(handle ihandle)
1718
(name :string)
1819
(x :int)
1920
(y :int)
2021
(active-p :boolean))
2122

2223
(cffi:defcfun (%iup-glcontrols-draw-text "IupGLDrawText") :void
23-
(handle iup-cffi::ihandle)
24+
(handle ihandle)
2425
(string :string)
2526
(length :int)
2627
(x :int)
2728
(y :int))
2829

2930
(cffi:defcfun (%iup-glcontrols-draw-get-text-size "IupGLDrawGetTextSize") :void
30-
(handle iup-cffi::ihandle)
31+
(handle ihandle)
3132
(string :string)
3233
(length :int)
3334
(x (:pointer :int))

im/im-cffi.lisp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(defpackage #:iup-im-cffi
2-
(:use #:common-lisp))
2+
(:use #:common-lisp)
3+
(:import-from #:tecgraf-base #:ihandle))
34

45
(in-package #:iup-im-cffi)
56

@@ -10,18 +11,18 @@
1011

1112
(cffi:use-foreign-library iup-im)
1213

13-
(cffi:defcfun (%iup-im-load-image "IupLoadImage") iup-cffi::ihandle
14+
(cffi:defcfun (%iup-im-load-image "IupLoadImage") ihandle
1415
(filename :string))
1516

1617
(cffi:defcfun (%iup-im-save-image "IupSaveImage") :int
17-
(handle iup-cffi::ihandle)
18+
(handle ihandle)
1819
(filename :string)
1920
(format :string))
2021

21-
(cffi:defcfun (%iup-im-load-animation "IupLoadAnimation") iup-cffi::ihandle
22+
(cffi:defcfun (%iup-im-load-animation "IupLoadAnimation") ihandle
2223
(filename :string))
2324

24-
(cffi:defcfun (%iup-im-load-animation-frames "IupLoadAnimation") iup-cffi::ihandle
25+
(cffi:defcfun (%iup-im-load-animation-frames "IupLoadAnimation") ihandle
2526
(filename-list :string)
2627
(filename-count :int))
2728

@@ -34,9 +35,9 @@
3435
(handle im-cffi::im-image))
3536

3637
(cffi:defcfun (%iup-im-iup-image-from-im-image "IupImageFromImImage")
37-
iup-cffi::ihandle
38+
ihandle
3839
(handle im-cffi::im-image))
3940

4041
(cffi:defcfun (%iup-im-iup-image-to-im-image "IupImageToImImage")
4142
im-cffi::im-image
42-
(handle iup-cffi::ihandle))
43+
(handle ihandle))

iup-cd-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
:components ((:file "cd-cffi"))
44
:depends-on (#:cd-cffi
55
#:iup-cffi
6+
#:tecgraf-base
67
#:cffi))

iup-cffi.asd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
(defsystem #:iup-cffi
22
:pathname "iup/"
33
:components ((:file "iup-cffi"))
4-
:depends-on (#:cffi
5-
#:pffft))
4+
:depends-on (#:cffi #:tecgraf-base))

iup-classesdb-cffi.asd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(defsystem #:iup-classesdb-cffi
22
:pathname "classesdb/"
33
:components ((:file "classesdb-cffi"))
4-
:depends-on (#:cffi))
4+
:depends-on (#:cffi #:tecgraf-base))

iup-controls-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "controls/"
33
:components ((:file "controls-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-gl-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "gl/"
33
:components ((:file "gl-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-glcontrols-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "glcontrols"
33
:components ((:file "glcontrols-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-im-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
:components ((:file "im-cffi"))
44
:depends-on (#:im-cffi
55
#:iup-cffi
6+
#:tecgraf-base
67
#:cffi))

iup-imglib-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "imglib"
33
:components ((:file "imglib-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-mglplot-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "mglplot"
33
:components ((:file "mglplot-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-olecontrol-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "olecontrol"
33
:components ((:file "olecontrol-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-plot-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
:components ((:file "plot-cffi"))
44
:depends-on (#:iup-cffi
55
#:cd-cffi
6+
#:tecgraf-base
67
#:cffi))

iup-scintilla-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "scintilla"
33
:components ((:file "scintilla-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-tuio-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:pathname "tuio"
33
:components ((:file "tuio-cffi"))
44
:depends-on (#:iup-cffi
5+
#:tecgraf-base
56
#:cffi))

iup-web-cffi.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
:components ((:file "web-cffi"))
44
:depends-on (#:iup-cffi
55
#:cffi
6+
#:tecgraf-base
67
#:serapeum))

iup/callback.lisp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
'callback=
1010
(lambda (callback)
1111
(sxhash (cl:list (callback-name callback)
12-
(callback-handle callback))))
12+
(pffft:pointer (callback-handle callback)))))
1313
(lambda (a b)
1414
(and (eq (callback-name a)
1515
(callback-name b))
16-
(cffi:pointer-eq (callback-handle a)
17-
(callback-handle b))))))
16+
(cffi:pointer-eq (pffft:pointer (callback-handle a))
17+
(pffft:pointer (callback-handle b)))))))
1818

1919
(defvar *registered-callbacks* (genhash:make-generic-hash-table :test 'callback=))
2020

2121
(defun register-callback (name handle action)
22-
(check-type handle cffi:foreign-pointer)
22+
(check-type handle tecgraf-base:ihandle)
2323
(let ((callback (make-callback :name name :handle handle)))
2424
(setf (genhash:hashref callback *registered-callbacks*)
2525
action)))
2626

2727
(defun unregister-callback (name handle)
28-
(check-type handle cffi:foreign-pointer)
28+
(check-type handle tecgraf-base:ihandle)
2929
(genhash:hashrem (make-callback :name name :handle handle) *registered-callbacks*))
3030

3131
(defun find-callback (name handle)
32-
(check-type handle cffi:foreign-pointer)
32+
(check-type handle tecgraf-base:ihandle)
3333
(genhash:hashref (make-callback :name name :handle handle) *registered-callbacks*))

iup/classes.lisp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
(#\V . :pointer) ;*void
1111
(#\C . :pointer) ;*cdCanvas
1212
(#\v . :pointer) ;FIXME Asked about this on mailing list, confirmed it should be "C"
13-
(#\n . :pointer))) ;*Ihandle
13+
(#\n . tecgraf-base:ihandle)))
1414

1515
(defun class-callback-name (classname callback-name package)
1616
(intern (format nil "~:@(~A-~A~)" classname callback-name) package))
@@ -55,7 +55,7 @@
5555
for s = (assoc-value *iup-callback-encoding* c :test #'char=)
5656
for arg = (intern (format nil "ARG~A" i))
5757
collect (cl:list arg s) into arg-list
58-
finally (return (list* '(arg0 :pointer) arg-list))))
58+
finally (return (list* '(arg0 tecgraf-base:ihandle) arg-list))))
5959
(return-and-arg-list (cl:list return-type arg-list))
6060
(callback-name (class-callback-name classname name package)))
6161
`(cffi:defcallback ,callback-name ,@return-and-arg-list

iup/iup-cffi.lisp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(defpackage #:iup-cffi
22
(:use #:common-lisp
3-
#:alexandria))
3+
#:alexandria)
4+
(:import-from #:tecgraf-base #:ihandle))
45

56
(in-package #:iup-cffi)
67

@@ -11,8 +12,6 @@
1112

1213
(cffi:use-foreign-library iup)
1314

14-
(pffft:define-foreign-pointer-wrapper ihandle)
15-
1615
(defmethod print-object ((object ihandle) stream)
1716
(print-unreadable-object (object stream :type t)
1817
(let ((pointer (pffft:pointer object)))
@@ -291,7 +290,7 @@
291290

292291
;; int IupClassMatch(Ihandle* ih, const char* classname);
293292

294-
(cffi:defcfun (%iup-create "IupCreate") iup-cffi::ihandle
293+
(cffi:defcfun (%iup-create "IupCreate") ihandle
295294
(classname :string))
296295

297296
;; /* IupImage utility */

0 commit comments

Comments
 (0)