- (:metaclass proxy-class)))
-
-(defmethod initialize-proxy ((boxed boxed) &rest initargs
- &key location weak-ref)
- (declare (ignore initargs))
- (setf
- (slot-value boxed 'location)
- (if weak-ref
- (%boxed-copy (find-type-number (class-of boxed)) location)
- location))
- (call-next-method))
-
-(defmethod instance-finalizer ((boxed boxed))
- (let ((location (proxy-location boxed))
- (type-number (find-type-number (class-of boxed))))
- (declare (type system-area-pointer location))
- #'(lambda ()
- (%boxed-free type-number location)
- (remove-cached-instance location))))
-
-
-(deftype-method translate-to-alien boxed (type-spec boxed &optional weak-ref)
- (if weak-ref
- `(proxy-location ,boxed)
- `(let ((boxed ,boxed))
- (%boxed-copy
- (find-type-number type-spec)
- (proxy-location boxed)))))
-
-(deftype-method unreference-alien boxed (type-spec c-struct)
- `(%boxed-free ,(find-type-number type-spec) ,c-struct))
-
-
-(defbinding %boxed-copy () pointer
- (type type-number)
+ (:metaclass proxy-class)
+ (:copy %boxed-copy)
+ (:free %boxed-free)))
+
+(defbinding %boxed-copy (type location) pointer
+ ((find-type-number type) type-number)