Use strcmp, fix constructor & destrucor calling for classes witn namespace (phonon::MediaPlayer) and add :arg0 to :arg2 initargs
src/smoke.lisp
Thu Jul 23 00:26:05 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Use strcmp, fix constructor & destrucor calling for classes witn namespace (phonon::MediaPlayer) and add :arg0 to :arg2 initargs
--- old-smoke/src/smoke.lisp 2014-10-30 08:12:46.000000000 +0100
+++ new-smoke/src/smoke.lisp 2014-10-30 08:12:46.000000000 +0100
@@ -80,11 +80,10 @@
"Destructs the object at POINTER of type CLASS.
Calls the destructor and frees the memory."
(declare (optimize (speed 3)))
- (let ((method-name (concatenate 'string "~" (name class))))
+ (let ((method-name (concatenate 'string "~" (constructor-name class))))
(s-call
(make-smoke-method-from-name class method-name)
- pointer))
- (setf pointer (null-pointer)))
+ pointer)))
(defun delete-object (object)
(let ((method-name (concatenate 'string "~" (name (class-of object)))))
@@ -144,35 +143,39 @@
(declare (optimize (speed 3)))
(format nil "~@[~A~%~]C++ name: ~A" (call-next-method) (name class)))
-;; No eql T since all-methods is to slow to be used in conjunction with
-;; mb:document
-(defmethod documentation ((gf smoke-gf) (doc-type (eql 'cxx-function)))
+(defmethod documentation ((gf smoke-gf) (doc-type (eql 't)))
(declare (optimize (speed 3)))
(let ((methods (all-methods (name gf))))
(format nil "~@[~A~%~]~{~T~A~%~}"
(call-next-method)
(sort (mapcar #'method-declaration methods) #'string<=))))
+
+(declaim (inline cstring=))
+(defun cstring= (string1 string2)
+ "Returns T when the C strings STRING1 and STRING2 are equal
+ and NIL otherwise."
+ (zerop (strcmp string1 string2)))
+
(defun all-methods (name)
"Returns a list of all methods named NAME."
;;FIXME speed this up, needed by (mb:document :smoke).
- (declare (string name)
- (optimize (speed 3)))
+ (declare (optimize (speed 3)))
+ (with-foreign-string (name name)
(let ((methods))
(maphash
- #'(lambda (address value)
- (declare (ignore value))
- (let ((smoke (make-pointer address)))
- (map-methods #'(lambda (method)
- (when (and (string= name (name method))
- (not (enum-p method)))
- (push (make-instance 'smoke-method
- :id (smoke-method-id method)
- :smoke (smoke method))
- methods)))
- smoke)))
- *smoke-id-class-map*)
- methods))
+ #'(lambda (address module)
+ (declare (ignore address))
+ (map-methods #'(lambda (method)
+ (when (and (cstring= name (smoke-method-name method))
+ (not (enum-p method)))
+ (push (make-smoke-method
+ :id (smoke-method-id method)
+ :smoke (smoke-method-smoke method))
+ methods)))
+ module))
+ *smoke-modules*)
+ methods)))
(defun fgrep-methods (smoke str)
(map-methods #'(lambda (method)
@@ -187,18 +190,13 @@
"Define a Smoke module."
(let ((smoke-module (intern "*SMOKE-MODULE*")))
`(progn
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (define-foreign-library ,library
- (:unix ,(format nil "~(~A~).so.2" library))
- (t (:default ,(format nil "~(~A~)" library)))))
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ (define-foreign-library ,library
+ (:unix ,(format nil "~(~A~).so.2" library))
+ (t (:default ,(format nil "~(~A~)" library)))))
(eval-startup (:compile-toplevel :execute)
- (load-foreign-library ',library))
+ (load-foreign-library ',library))
(eval-startup (:compile-toplevel :execute)
-; (eval-when (:compile-toplevel :load-toplevel :execute)
-; (define-foreign-library ,library
-; (:unix ,(format nil "~(~A~).so.2" library))
-; (t (:default ,(format nil "~(~A~)" library))))
-; (load-foreign-library ',library))
(defcvar (,variable ,variable-name
:read-only t
:library ,library) :pointer)