chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] how to create a cairo_matrix_t (defined by define-foreig


From: Markus Klotzbuecher
Subject: [Chicken-users] how to create a cairo_matrix_t (defined by define-foreign-type) ?
Date: Fri, 13 Jan 2012 21:01:09 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Dear All,

For my small visualization project I need the functions
cairo-get-matrix and cairo-set-matrix. The cairo_matrix_t type is
defined in cairo.sdl as shown below:

(define-foreign-type cairo_matrix_t (c-pointer "cairo_matrix_t")
  values
  (cut tag-pointer <> 'cairo-matrix))

cairo-get-matrix expects a cairo_matrix_t pointer as shown below, but
I couldn't figure out how to create such a type. Is it correct that
define-foreign-type registers the type with CHICKEN's type system, but
does not create a constructor?

(define cairo-get-matrix
  (foreign-lambda void "cairo_get_matrix" cairo_t cairo_matrix_t))

For now I worked around it by using the code below. Is this correct
chickenwise? Is there a better solution?

(define cairo-get-matrix
  (foreign-lambda* cairo_matrix_t ((cairo_t ct))
                   "cairo_matrix_t cmt;
                    cairo_get_matrix(ct, &cmt);
                    C_return(&cmt);"))


Thanks in advance!
Markus



reply via email to

[Prev in Thread] Current Thread [Next in Thread]