+(defmethod reference-foreign ((class (eql (find-class 'stock-item))) location)
+ (%stock-item-copy location))
+
+(defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location)
+ (%stock-item-free location))
+
+(defbinding stock-add (stock-item) nil
+ (stock-item stock-item)
+ (1 unsigned-int))
+
+(defbinding stock-list-ids () (gslist string))
+
+(defbinding %stock-lookup () boolean
+ (stock-id string)
+ (location pointer))
+
+(defun stock-lookup (stock-id)
+ (let ((location
+ (allocate-memory (proxy-instance-size (find-class 'stock-item)))))
+ (unwind-protect
+ (when (%stock-lookup stock-id location)
+ (ensure-proxy-instance 'stock-item (%stock-item-copy location)))
+ (deallocate-memory location))))