Hi Everyone,

I'm writing a c wrapper for a small part of the VTK (vtk.org) library and would 
like to see if it is possible to generate c pointers with multiple tags.

VTK uses inheritance extensively so it is possible to write functions in C that 
take different objects as parameters as long as they inherit from the same base 
class.

Racket has cpointer-push-tag! enabling a C pointer to have multiple tags and 
this allows calling any ffi function to take any argument as long as it has the 
right tag.

I'd like to know if it is possible to add multiple tags when the pointer is 
defined.

I have tried modifying the c->scheme function in define-cpointer-type as

(define-cpointer-type _vtkActor #f #f
  (lambda (ptr)
    (if ptr
        (begin
          (register-finalizer ptr (lambda (ptr)
            (log-debug (format "Releasing ~s\n" ptr)
                  (vtkActor_Delete ptr))))

          (map (lambda (t) (cpointer-push-tag! ptr t)) 
                '(vtkObject vtkProp vtkProp3D vtkActor)

          ptr))
        (error '_name "got a NULL pointer"))))

but the created #<cpointer:vtkActor>s do not have any of the other tags.

thanks in advance,
carlos.





-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to