TREE-PATH as return type

"Walter C. Pelissero" <[email protected]> Tue, 21 Apr 2009 13:39:56 +0200
Newsgroups gmane.lisp.clg.devel
Message-ID <[email protected]>
There seems to be an inconsistency between the return type for
tree-path arguments and %TREE-PATH-TO-VECTOR.

As I can see from the first line

(defun %tree-path-to-vector (location)
  (unless (null-pointer-p location)
    (let ((indices (%tree-path-get-indices location))
	  (depth (%tree-path-get-depth location)))
      (if (null-pointer-p indices)
	  #()
	(map-c-vector 'vector #'identity indices 'int depth)))))

this function can return NIL when passed a null pointer.
Unfortunately RETURN-TYPE for TREE-PATH returns a '(VECTOR INT *),
which is OK for CMUCL (who is probably ignoring the declaim produced
by DEFBINDING) but makes SBCL angry whenever a GTK function returns a
null pointer.

This patch mends the problem:

*** gtktree.lisp.~1.34.~	2008-05-06 11:00:50.000000000 +0200
--- gtktree.lisp	2009-04-21 13:24:55.000000000 +0200
***************
*** 276,281 ****
--- 276,285 ----
      (declare (ignore type))
      (alien-type 'pointer))
    
+   (define-type-method return-type ((type tree-path))
+     (declare (ignore type))
+     (return-type '(or (vector int *) null)))
+   
    (define-type-method size-of ((type tree-path) &key inlined)
      (assert-not-inlined type inlined)
      (size-of 'pointer))


-- 
walter pelissero
http://www.pelissero.de

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p