I have this conditional from a cond statement I need to satisfy
((listp (first args))
(c-arr-to-vector-point (first args)))
The (first args) will be this but it should be able to have an infinite number
of (point i j) in it.
(foreign-alloc :pointer :initial-contents (LIST (POINT 1 2) (POINT 3 4)))
The thing is that the output of (point i j) is a metaobject e.g. #<CV-POINT {10038888E3}> . That is how I have my
return for point defined. When I need to use foreign-alloc to define an array of point I have to do it like this...
(foreign-alloc :pointer :initial-contents (LIST (c-pointer (POINT 1 2)) (c-pointer (POINT 3 4))))
...because my defclass is this:
(defclass std-vector-point ()
((c-pointer :reader c-pointer :initarg :c-pointer)))
Here is my function I need to change so a when it is run I can just enter (LIST (POINT 1 2) (POINT 3 4)) for the (first args) in the above mentioned conditional block and have the %c-arr-to-vector-point function be satisfied, because it accepts a list of pointers as its input. But I need help because I don't want the user to see the c-pointer at all let alone have to wrap each (point i j) like
this (c-pointer (point i j)) that is too much typing. How would I do this without it making my function any slower.
(defun vector-point (&rest args)
(cond
((fourth args)
(error "odd number of args to VECTOR-POINT"))
((null (first args))
(%vector-point))
((listp (first args))
(%c-arr-to-vector-point (foreign-alloc :pointer :initial-contents (first args))))
((eq :size (second args))
(%vector-point-size (first args)))
((and (eq (type-of (first args)) 'std-vector-point) (second args) (not (third
args)))
(mem-aref (c-pointer
(%vector-point-to-c-array (first args))) :pointer (second args)))
((and (eq (type-of (first args)) 'std-vector-point) (second args) (third args))
(mem-aref (c-pointer
(mem-aref (c-pointer
(%vector-point-to-c-array (first args))) :pointer (second args)))
:int (third args)))
((not (eq (type-of (first args)) 'std-vector-point))
(error "The value ~a is not of type (STD-VECTOR-POINT)." (first args)))))