chiark / gitweb /
Changes required by SBCL
[clg] / glib / genums.lisp
index 4fb3c10e80ce525ca25ddbf9e1495f84604fddbe..44278b3cc64a4ebaf79274f8fae7c6a4939589c9 100644 (file)
@@ -15,7 +15,7 @@
 ;; License along with this library; if not, write to the Free Software
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-;; $Id: genums.lisp,v 1.4 2004-11-06 21:39:58 espen Exp $
+;; $Id: genums.lisp,v 1.7 2005-02-03 22:59:35 espen Exp $
 
 (in-package "GLIB")
 
@@ -118,7 +118,14 @@ (defbinding %enum-class-values () pointer
 (defun query-enum-values (type)
   (%query-enum-or-flags-values #'%enum-class-values '%enum-value type))
 
+(defun enum-int (enum type)
+  (funcall (to-alien-function type) enum))
 
+(defun int-enum (int type)
+  (funcall (from-alien-function type) int))
+
+(defun enum-mapping (type)
+  (rest (type-expand-to 'enum type)))
 
 ;;;;  Generic flags type
 
@@ -149,7 +156,7 @@ (defmethod from-alien-form (int (type (eql 'flags)) &rest args)
   (declare (ignore type))
   `(loop
     for mapping in ',(%map-enum args :int-flags)
-    unless (zerop (logand int (first mapping)))
+    unless (zerop (logand ,int (first mapping)))
     collect (second mapping)))
 
 (defmethod to-alien-function ((type (eql 'flags)) &rest args)
@@ -206,7 +213,8 @@ (defun query-flags-values (type)
 
 ;;;;
 
-(defun expand-enum-type (type-number &optional options)
+(defun expand-enum-type (type-number forward-p options)
+  (declare (ignore forward-p))
   (let* ((super (supertype type-number))
         (type (type-from-number type-number))
         (mappings (getf options :mappings))