slot-value access for static attributes using the class instead of an object.
Sat Apr 3 21:11:26 CEST 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* slot-value access for static attributes using the class instead of an object.
diff -rN -u old-smoke/src/overload-resolution.lisp new-smoke/src/overload-resolution.lisp
--- old-smoke/src/overload-resolution.lisp 2014-10-30 07:04:57.000000000 +0100
+++ new-smoke/src/overload-resolution.lisp 2014-10-30 07:04:57.000000000 +0100
@@ -554,8 +554,33 @@
(cast object-or-class (get-class method)))
sequence arguments)))
+(defmethod slot-missing (meta-class (class smoke-standard-class) slot-name operation &optional new-value)
+ (let ((method (find-smoke-method class (lisp-to-cxx (string slot-name)))))
+ (if (or (not (valid-p method)) (not (static-p method)))
+ (call-next-method)
+ (ecase operation
+ (setf
+ (handler-case (funcall (fdefinition
+ (intern
+ (concatenate 'string "SET-"
+ (string-upcase
+ (string slot-name)))
+ :cxx))
+ class new-value)
+ (undefined-function ()
+ (error "The C++ attribute ~A of ~A is read only." slot-name class))
+ (no-applicable-cxx-method (condition)
+ (if (null (viable-functions (condition-method condition)
+ (length (condition-arguments condition))
+ (condition-class condition)))
+ (error "The C++ attribute ~A of ~A is read only." slot-name class)
+ (error condition)))))
+ (slot-boundp t)
+ (slot-makunbound (error "Can not unbind the C++ attribute ~A of ~A." slot-name class))
+ (slot-value (s-call method (null-pointer)))))))
+
(defmethod slot-missing ((class smoke-standard-class) object slot-name operation &optional new-value)
- (let ((method (find-smoke-method (class-of object) (lisp-to-cxx (string slot-name)))))
+ (let ((method (find-smoke-method class (lisp-to-cxx (string slot-name)))))
(if (not (valid-p method))
(call-next-method)
(ecase operation