+(define-type-method alien-type ((class proxy))
+ (declare (ignore class))
+ (alien-type 'pointer))
+
+(define-type-method size-of ((class proxy))
+ (declare (ignore class))
+ (size-of 'pointer))
+
+(define-type-method from-alien-form ((type proxy) location)
+ (let ((class (type-expand type)))
+ `(ensure-proxy-instance ',class ,location)))
+
+(define-type-method from-alien-function ((type proxy))
+ (let ((class (type-expand type)))
+ #'(lambda (location)
+ (ensure-proxy-instance class location))))
+
+(define-type-method to-alien-form ((type proxy) instance)
+ (declare (ignore type))
+ `(foreign-location ,instance))
+
+(define-type-method to-alien-function ((type proxy))
+ (declare (ignore type))
+ #'foreign-location)
+
+(define-type-method copy-from-alien-form ((type proxy) location)
+ (let ((class (type-expand type)))
+ `(ensure-proxy-instance ',class (reference-foreign ',class ,location))))
+
+(define-type-method copy-from-alien-function ((type proxy))
+ (let ((class (type-expand type)))
+ #'(lambda (location)
+ (ensure-proxy-instance class (reference-foreign class location)))))
+
+(define-type-method copy-to-alien-form ((type proxy) instance)
+ (let ((class (type-expand type)))
+ `(reference-foreign ',class (foreign-location ,instance))))
+
+(define-type-method copy-to-alien-function ((type proxy))
+ (let ((class (type-expand type)))
+ #'(lambda (instance)
+ (reference-foreign class (foreign-location instance)))))
+
+(define-type-method writer-function ((type proxy))
+ (let ((class (type-expand type)))
+ #'(lambda (instance location &optional (offset 0))
+ (assert (null-pointer-p (sap-ref-sap location offset)))
+ (setf
+ (sap-ref-sap location offset)
+ (reference-foreign class (foreign-location instance))))))
+
+(define-type-method reader-function ((type proxy))
+ (let ((class (type-expand type)))
+ #'(lambda (location &optional (offset 0) weak-p)
+ (declare (ignore weak-p))
+ (let ((instance (sap-ref-sap location offset)))
+ (unless (null-pointer-p instance)
+ (ensure-proxy-instance class (reference-foreign class instance)))))))
+
+(define-type-method destroy-function ((type proxy))
+ (let ((class (type-expand type)))
+ #'(lambda (location &optional (offset 0))
+ (unreference-foreign class (sap-ref-sap location offset)))))
+
+(define-type-method unbound-value ((type proxy))
+ (declare (ignore type))
+ nil)