Support modular smoke & cleanup.
src/libsmoke/smoke.lisp
Sun Jan 10 09:49:36 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Support modular smoke & cleanup.
--- old-smoke/src/libsmoke/smoke.lisp 1970-01-01 01:00:00.000000000 +0100
+++ new-smoke/src/libsmoke/smoke.lisp 2014-10-30 08:09:21.000000000 +0100
@@ -0,0 +1,81 @@
+(in-package #:smoke)
+
+;; Load the qt smoke binding to prevent undefined aliens.
+(eval-when (:load-toplevel :compile-toplevel :execute)
+ (define-foreign-library libsmokeqt
+ (:unix "libsmokeqtcore.so.3")
+ (t (:default "libsmokeqt")))
+ (define-foreign-library libclsmoke
+ (:unix "libclsmoke.so")
+ (t (:default "libclsmoke")))
+ (define-foreign-library libclsmokeutil
+ (:unix "libclsmokeutil.so")
+ (t (:default "libclsmokeutil")))
+ (use-foreign-library libsmokeqt)
+ (use-foreign-library libclsmoke))
+
+
+(eval-when (:load-toplevel :compile-toplevel :execute)
+ (use-foreign-library libclsmokeutil)
+ (defcfun (smoke-sizeof-bool "cl_smoke_sizeof_bool") :int)
+ (defun cffi-bool-type ()
+ "Returns a cffi unsigned int type with the same size as a C++ bool."
+ (load-foreign-library 'libclsmokeutil)
+ (intern (format nil "UINT~A" (* 8 (smoke-sizeof-bool)))
+ (find-package :keyword)))
+
+ (defmacro defcxxbool ()
+ `(defctype cxx-bool (:boolean ,(cffi-bool-type)))))
+
+(defcxxbool)
+
+;(close-foreign-library 'libclsmokeutil)
+
+(defctype smoke-binding :pointer
+ "A Smoke binding")
+
+(defctype smoke-index :short
+ "An index")
+
+(deftype smoke-index (&optional (lower -32768) (upper 32767))
+ "Smoke index."
+ `(integer ,lower ,upper))
+
+(defcfun (smoke-init "cl_smoke_init") smoke-binding
+ (smoke :pointer)
+ (destruct :pointer)
+ (dispatch :pointer))
+
+(defcfun (smoke-destruct "cl_smoke_destruct") :void
+ (smoke smoke-binding))
+
+;; Smoke::ModuleIndex is a POD-struct.
+;; Thus we can treat it as a C struct.
+(defcstruct smoke-module-index
+ (smoke :pointer)
+ (index smoke-index))
+
+(declaim (inline smoke-get-smoke))
+(defcfun (smoke-get-smoke "cl_smoke_get_smoke") :pointer
+ (smoke-binding smoke-binding))
+
+(defcfun (smoke-get-module-name "cl_smoke_get_module_name") :string
+ (smoke :pointer))
+
+(defcenum cl-smoke-array
+ :classes
+ :methods
+ :method-maps
+ :method-names
+ :types
+ :inheritance-list
+ :argument-list
+ :ambiguous-method-list)
+
+(defcfun cl-smoke-array :pointer
+ (smoke :pointer)
+ (array cl-smoke-array))
+
+(defcfun cl-smoke-array-size smoke-index
+ (smoke :pointer)
+ (array cl-smoke-array))