I have a situation where I need to pass 'rm:RMmatrix3D to a function,
and then a couple lines down pass (rm:RMmatrix *) to a macro; removing
the quote.
(defmacro new-pointer (type &optional (value nil))
(let ((pointer (gensym)))
`(let ((,pointer (ct:malloc (ct:sizeof ,type))))
(if ,value
(setf (ct:cref (,type *) ,pointer 0) ,value))
,pointer)))
Here, ct:sizeof requires 'rm:RMmatrix3D, whereas ct:cref requires
(rm:RMmatrix3D *)
I can't not quote the value passed to 'type' as new-pointer must also
handle e.g. :single-float. Which is never quoted.
Any pointers ?
-Luke
In article <···················@twister.socal.rr.com>,
Luke J Crook <······@NO-SPAM.hd-plus.com> wrote:
> I have a situation where I need to pass 'rm:RMmatrix3D to a function,
> and then a couple lines down pass (rm:RMmatrix *) to a macro; removing
> the quote.
>
> (defmacro new-pointer (type &optional (value nil))
> (let ((pointer (gensym)))
> `(let ((,pointer (ct:malloc (ct:sizeof ,type))))
> (if ,value
> (setf (ct:cref (,type *) ,pointer 0) ,value))
> ,pointer)))
>
> Here, ct:sizeof requires 'rm:RMmatrix3D, whereas ct:cref requires
> (rm:RMmatrix3D *)
>
> I can't not quote the value passed to 'type' as new-pointer must also
> handle e.g. :single-float. Which is never quoted.
>
> Any pointers ?
(ct:sizeof ',type)
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Barry Margolin wrote:
> In article <···················@twister.socal.rr.com>,
> Luke J Crook <······@NO-SPAM.hd-plus.com> wrote:
>
>
>>I have a situation where I need to pass 'rm:RMmatrix3D to a function,
>>and then a couple lines down pass (rm:RMmatrix *) to a macro; removing
>>the quote.
>
> (ct:sizeof ',type)
>
That's it thanks.
Just pass everything into the macro unquoted and perform the quoting as
required.
Going back, I see that I can quote e.g. :single-float, :double in
(ct:sizeof ':double) and it still works as expected. This is actually
better as (ct:sizeof '((:double 4) 4)) must be quoted to create an array
of [4][4] floats.
-Luke