chiark / gitweb /
Work around for broken def-type-method
authorespen <espen>
Sun, 19 Feb 2006 22:25:31 +0000 (22:25 +0000)
committerespen <espen>
Sun, 19 Feb 2006 22:25:31 +0000 (22:25 +0000)
glib/ffi.lisp
glib/genums.lisp
glib/gtype.lisp

index 630181c3ca6f2e6bf89aa1b518b895fa65c58500..7b0c130ef47f9e3660810748073e365eb3a0266c 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: ffi.lisp,v 1.24 2006/02/19 19:17:45 espen Exp $
+;; $Id: ffi.lisp,v 1.25 2006/02/19 22:25:31 espen Exp $
 
 (in-package "GLIB")
 
@@ -274,7 +274,7 @@     (defgeneric ,name (,@args type &rest args)
       ,@(when documentation `((:documentation ,documentation))))
     (defmethod ,name (,@args (type symbol) &rest args)
       (let ((class (find-class type nil)))
-       (if class 
+       (if (typep class 'standard-class)
            (apply #',name ,@args class args)
          (multiple-value-bind (super-type expanded-p)
              (type-expand-1 (cons type args))
@@ -365,8 +365,11 @@ (defmethod cleanup-function ((type t) &rest args)
   (declare (ignore type args))
   #'identity)
 
+;; This does not really work as def-type-method is badly broken and
+;; needs a redesign, so we need to add a lots of redundant methods
 (defmethod callback-from-alien-form (form (type t) &rest args)
-  (apply #'copy-from-alien-form form type args))
+;  (apply #'copy-from-alien-form form type args))
+  (apply #'from-alien-form form type args))
 
 (defmethod callback-cleanup-form (form (type t) &rest args)
   (declare (ignore form type args))
@@ -625,6 +628,9 @@ (defmethod to-alien-function ((type (eql 'string)) &rest args)
       (let ((utf8 (%deport-utf8-string string)))
        (copy-memory (vector-sap utf8) (length utf8)))))
 
+(defmethod callback-from-alien-form (form (type (eql 'string)) &rest args)
+  (apply #'copy-from-alien-form form type args))
+
 (defmethod from-alien-form (string (type (eql 'string)) &rest args)
   (declare (ignore type args))
   `(let ((string ,string))
@@ -655,6 +661,9 @@ (defmethod cleanup-function ((type (eql 'string)) &rest args)
       (unless (null-pointer-p string)
        (deallocate-memory string))))
 
+(defmethod callback-from-alien-form (form (type (eql 'string)) &rest args)
+  (apply #'copy-from-alien-form form type args))
+
 (defmethod copy-from-alien-form (string (type (eql 'string)) &rest args)
   (declare (ignore type args))
   `(let ((string ,string))
@@ -777,6 +786,9 @@ (defmethod to-alien-function ((type (eql 'boolean)) &rest args)
   #'(lambda (boolean)
       (if boolean 1 0)))
 
+(defmethod callback-from-alien-form (form (type (eql 'boolean)) &rest args)
+  (apply #'from-alien-form form type args))
+
 (defmethod from-alien-form (boolean (type (eql 'boolean)) &rest args)
   (declare (ignore type args))
   `(not (zerop ,boolean)))
index 14bff9a4f276ee06d9a510f8debd2a0d62efb683..6624332573c4cf01d0f5ac41a54476cee20d6058 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: genums.lisp,v 1.17 2006/02/06 18:12:19 espen Exp $
+;; $Id: genums.lisp,v 1.18 2006/02/19 22:25:31 espen Exp $
 
 (in-package "GLIB")
   
@@ -57,6 +57,9 @@ (defmethod to-alien-form (form (type (eql 'enum)) &rest args)
     (t (error 'type-error :datum ,form :expected-type '(enum ,@args)))))
 
 
+(defmethod callback-from-alien-form (form (type (eql 'enum)) &rest args)
+  (apply #'from-alien-form form type args))
+
 (defmethod from-alien-form (form (type (eql 'enum)) &rest args)
   (declare (ignore type))
   `(case ,form
@@ -173,6 +176,9 @@ (defmethod to-alien-form (flags (type (eql 'flags)) &rest args)
               (t (error 'type-error :datum ,flags 
                   :expected-type '(,type ,@args)))))))
 
+(defmethod callback-from-alien-form (form (type (eql 'flags)) &rest args)
+  (apply #'from-alien-form form type args))
+
 (defmethod from-alien-form (value (type (eql 'flags)) &rest args)
   (declare (ignore type))
   `(loop
index 9be8ecc1cc8d127bd09614893787fa09b9625592..c83c4951ba65565762ff1e8b045dc113facb7827 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: gtype.lisp,v 1.45 2006/02/19 19:27:32 espen Exp $
+;; $Id: gtype.lisp,v 1.46 2006/02/19 22:25:31 espen Exp $
 
 (in-package "GLIB")
 
@@ -376,8 +376,9 @@ (defmethod invalidate-instance ((instance ginstance))
   ;; A ginstance should never be invalidated since it is ref counted
   nil)
 
-(defmethod callback-from-alien-form (form (type t) &rest args)
-  (apply #'from-alien-form form type args))
+(defmethod callback-from-alien-form (form (class ginstance-class) &rest args)
+  (declare (ignore args))
+  (from-alien-form form class))
 
 (defmethod copy-from-alien-form (location (class ginstance-class) &rest args)
   (declare (ignore location class args))