Allow passing a raw pointer for an argument of type class
Sun May 24 23:28:44 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Allow passing a raw pointer for an argument of type class
diff -rN -u old-smoke/src/overload-resolution.lisp new-smoke/src/overload-resolution.lisp
--- old-smoke/src/overload-resolution.lisp 2014-10-01 12:22:41.000000000 +0200
+++ new-smoke/src/overload-resolution.lisp 2014-10-01 12:22:42.000000000 +0200
@@ -386,11 +386,21 @@
:to (find-class 't))))
(defun+using-type conversion-pointer object (object type)
- (when (and (= 0 (type-id type))
+ ;; Not using pointer-p to allow passing a raw pointer for
+ ;; objects on the stack and references
+ ;; (e.g.: for qInstallMsgHandler(QtMsgHandler) )
+ ;;
+ ;; FIXME this breaks passing pointers to references
+ ;; e.g.: calling the function foo(QByteArray& foo)
+ ;; with (foo pointer) assumes pointer to point to a QByteArray,
+ ;; but actually the conversion sequence QByteArray(pointer) should be used.
+ ;; When pointer is a null pointer it fails horribly!.
+ (when (and (or (= 0 (type-id type)) ; voidp
+ (= 13 (type-id type))) ; class
(object.typep 'foreign-pointer))
(make-match 'pointer-conversion 'identity nil
- :from (object.type-of)
- :to (find-class 't))))
+ :from (find-class 't)
+ :to (find-class 't)))) ;; FIXME get the class when applicable
(defun+using-type conversion object (object type)