#:g-idle-add-full
#:g-idle-add
#:g-timeout-add-full
- #:g-source-remove)
+ #:g-source-remove
+ #:at-finalize
+ #:with-g-error
+ #:with-catching-to-g-error
+ #:g-error-condition
+ #:g-error-condition-domain
+ #:g-error-condition-code
+ #:g-error-condition-message
+ #:g-spawn-flags)
(:documentation
"Cl-gtk2-glib is wrapper for @a[http://library.gnome.org/devel/glib/]{GLib}."))
(defun register-initializer (key fn)
(unless (gethash key *initializers-table*)
(setf (gethash key *initializers-table*) t
- *initializers* (nconc *initializers* (list fn))))))
+ *initializers* (nconc *initializers* (list fn)))))
+ (defvar *finalizers-table* (make-hash-table :test 'equalp))
+ (defvar *finalizers* nil)
+ (defun register-finalizer (key fn)
+ (unless (gethash key *finalizers-table*)
+ (setf (gethash key *finalizers-table*) t
+ *finalizers* (nconc *finalizers* (list fn))))))
(defun run-initializers ()
(iter (for fn in *initializers*)
(funcall fn)))
+(defun run-finalizers ()
+ (iter (for fn in *finalizers*)
+ (funcall fn)))
+
+#+sbcl
+(pushnew 'run-initializers sb-ext:*init-hooks*)
+#+openmcl
+(pushnew 'run-initializers ccl:*restore-lisp-functions*)
+
+#+sbcl
+(pushnew 'run-finalizers sb-ext:*save-hooks*)
+#+openmcl
+(pushnew 'run-finalizers ccl:*save-exit-functions*)
+
(defmacro at-init ((&rest keys) &body body)
"
@arg[keys]{list of expression}
`(progn (register-initializer (list ,@keys ',body) (lambda () ,@body))
,@body))
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (define-foreign-library glib
- (:unix (:or "libglib-2.0.so.0" "libglib-2.0.so"))
- (:win32 "libglib-2.0-0.dll")
- (t (:default "libglib-2.0"))))
-
-(use-foreign-library glib)
+(defmacro at-finalize ((&rest keys) &body body)
+ `(register-finalizer (list ,@keys ',body) (lambda () ,@body)))
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (define-foreign-library gthread
- (:unix (:or "libgthread-2.0.so.0" "libgthread-2.0.so"))
- (:win32 "libgthread-2.0-0.dll")
- (t "libgthread-2.0")))
-
-(use-foreign-library gthread)
+(at-init ()
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ (define-foreign-library glib
+ (:unix (:or "libglib-2.0.so.0" "libglib-2.0.so"))
+ (:windows "libglib-2.0-0.dll")
+ (t (:default "libglib-2.0"))))
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ (define-foreign-library gthread
+ (:unix (:or "libgthread-2.0.so.0" "libgthread-2.0.so"))
+ (:windows "libgthread-2.0-0.dll")
+ (t "libgthread-2.0")))
+
+ (use-foreign-library glib)
+ (use-foreign-library gthread))
;;
;; Glib Fundamentals
(str (:string :free-to-foreign t)))
;omitted all GLib Utilites
-;TODO: omitted Date and Time Functions
+(defbitfield g-spawn-flags
+ :leave-descriptors-open :do-not-reap-child :search-path :stdout-to-dev-null :stderr-to-dev-null
+ :child-inherits-stdin :file-and-argv-zero)
+
+;TODO: omitted Date and Time Functions