Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] issue #84 #95

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/function.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@
:type-desc (desc-of-type (gir-type-of ret-data)))
out-args-desc)
(iter (for arg-data :in args-data)
(with-slots (name type direction for-array-length-p)
(with-slots (name type direction for-array-length-p) ; ???
arg-data
(unless for-array-length-p
(let ((arg-desc (make-instance 'variable-desc :name name
Expand Down
5 changes: 4 additions & 1 deletion src/object.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
(function-cache :reader function-cache-of)
(method-cache :reader method-cache-of)))

(defun object-class-name (obj-cls)
(info-get-name (info-of obj-cls)))

(defmethod print-object ((obj-cls object-class) s)
(format s "#O<~a>" (info-get-name (info-of obj-cls))))
(format s "#O<~a>" (object-class-name obj-cls)))

(defmethod shared-initialize :after ((object-class object-class) slot-names
&key info)
Expand Down
1 change: 1 addition & 0 deletions src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
#:arguments-desc-of
#:returns-desc-of
#:object-class
#:object-class-name
#:gir-class-of
#:parent-of
#:list-fields-desc
Expand Down
13 changes: 10 additions & 3 deletions src/signal.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@
(declare (ignore data))
(destroy-trampoline closure))

(defun make-closure (func)
(defun make-closure (func signal-desc)
(let* ((g-closure-size (cffi:foreign-type-size '(:struct g-closure)))
(closure-ptr (g-closure-new-simple
g-closure-size (cffi:null-pointer)))) ;; sizeof(GClosure) = 16
(make-trampoline func closure-ptr)
(flet ((cb (&rest args)
(format t "DESC ~A" signal-desc)
(apply func args)))
(make-trampoline #'cb closure-ptr))
(g-closure-set-marshal closure-ptr (cffi:callback marshal))
(g-closure-add-finalize-notifier closure-ptr
(cffi:null-pointer)
Expand All @@ -75,7 +78,11 @@
(let* ((object-ptr (if (typep g-object 'object-instance)
(this-of g-object)
g-object))
(gir-class (when (typep g-object 'object-instance)
(gir-class-of g-object)))
(str-signal (string-downcase signal))
(signal-desc (when gir-class
(get-signal-desc gir-class signal)))
(c-handler (cond
((and (symbolp c-handler) (fboundp c-handler))
(symbol-function c-handler))
Expand All @@ -86,7 +93,7 @@
(typecase c-handler
(function (g-signal-connect-closure
object-ptr str-signal
(make-closure c-handler)
(make-closure c-handler signal-desc)
after))
(t (g-signal-connect-data object-ptr
str-signal
Expand Down
16 changes: 15 additions & 1 deletion test/gir-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
(test (object-constructor :depends-on (and function enum))
"Test the object constructor"
(is (eql 'gir::object-instance
(let ((flags (nget *gio* "ApplicationFlags" :flags_none)))
(let ((flags (nget *gio* "ApplicationFlags" :handles-open)))
(setf *app* (invoke (*gio* "Application" 'new)
*app-id1* flags))
(type-of *app*)))))
Expand Down Expand Up @@ -181,6 +181,20 @@
time-val))
'gir::struct-instance)))

(test (object-signal :depends-on object-constructor)
"Test signal parameters mapping"
(is (equal '()
(let* ((icon1 (gir:invoke (*gio* "ThemedIcon" 'new) "open"))
(icon2 (gir:invoke (*gio* "ThemedIcon" 'new) "document-new"))
(store (gir:invoke (*gio* "ListStore" 'new)
(gir:invoke (icon1 'get-type))))
(calls nil))
(gir:connect store 'items-changed (lambda (&rest args)
(push args calls)))
(gir:invoke (store 'append) icon1)
(gir:invoke (store 'append) icon2)
calls))))

(in-suite gir)

(test (array :depends-on object-method)
Expand Down