* Markus Klotzbuecher <[email protected]> [120113 21:01]: > 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);"))
Does that really work? You are allocating this on the stack and that location might be gone after the function returns. You can use malloc there and set a finalizer on the chicken object. I have code for this on my cairo branch, it needs some more testing then I will push this out. HTH, Christian -- Who can (make) the muddy water (clear)? Let it be still, and it will gradually become clear. Who can secure the condition of rest? Let movement go on, and the condition of rest will gradually arise. -- Lao Tse. _______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
