Sat Feb 20 21:56:27 CET 2010 Tobias Rautenkranz * Allow passing integers as enum arguments. diff -rN -u old-smoke/src/overload-resolution.lisp new-smoke/src/overload-resolution.lisp --- old-smoke/src/overload-resolution.lisp 2014-10-30 08:05:55.000000000 +0100 +++ new-smoke/src/overload-resolution.lisp 2014-10-30 08:05:55.000000000 +0100 @@ -369,7 +369,7 @@ (defun coerce-c-string (string) (make-auto-pointer (foreign-string-alloc string))) -(defun coerce-enum (enum) +(defun coerce-from-enum (enum) (cxx-support:value enum)) (defun coerce-double-float (number) @@ -378,6 +378,11 @@ (defun coerce-single-float (number) (float number 0f0)) +(defun coerce-to-enum (number) + ;; we can skip the enum type because it is not checked at this + ;; point. + (make-instance 'enum :value number)) + ;; FIXME incomplete (defun+using-type promotion object (object type) (declare (smoke-type type)) @@ -386,13 +391,15 @@ (object.typep 'string)) (make-match 'promotion 'coerce-c-string))) (6 (when (object.typep 'enum) - (make-match 'promotion 'coerce-enum))) + (make-match 'promotion 'coerce-from-enum))) (7 (when (object.typep 'enum) - (make-match 'promotion 'coerce-enum))) + (make-match 'promotion 'coerce-from-enum))) (10 (when (object.typep 'real) (make-match 'promotion 'coerce-single-float))) (11 (when (object.typep 'real) - (make-match 'promotion 'coerce-double-float))))) + (make-match 'promotion 'coerce-double-float))) + (12 (when (object.typep '(integer 0)) + (make-match 'promotion 'coerce-to-enum))))) (declaim (inline coerce-to-class)) (defun coerce-cast (object to-class)