Hi Andreas,
the function cairo_copy_path does return a pointer to a cairo_path_t. So
the return value of your ccall is wrong.
Cheers
Tobi
Am Dienstag, 9. Juni 2015 20:00:39 UTC+2 schrieb Andreas Lobinger:
>
> Hello colleagues,
>
> i'm trying to get further interfacing to libcairo, but i somehow run into
> problems for matching c structures.
>
> My example
> using Cairo
>
> i = CairoImageSurface(100,100,Cairo.FORMAT_RGB24)
> cr = CairoContext(i)
> select_font_face (cr, "Sans", Cairo.FONT_SLANT_NORMAL,
> Cairo.FONT_WEIGHT_BOLD);
> set_font_size (cr, 90.0);
> move_to (cr, 10.0, 135.0);
> text_path (cr, "5");
>
> # typedef struct cairo_path {
> # cairo_status_t status;
> # cairo_path_data_t *data;
> # int num_data;
> # } cairo_path_t;
>
> type Pdata
> status::Cairo.status_t
> data::Ptr{Uint32}
> num_data::Uint32
> end
>
> function pdata_copy_path(ctx::CairoContext)
> ccall((:cairo_copy_path, Cairo._jl_libcairo),
> Pdata, (Ptr{Void},),ctx.ptr)
> end
>
> p = pdata_copy_path(cr);
>
> returns, here:
>
> lobi@orange4:~/juliarepo$ ../julia/julia
> _
> _ _ _(_)_ | A fresh approach to technical computing
> (_) | (_) (_) | Documentation: http://docs.julialang.org
> _ _ _| |_ __ _ | Type "help()" for help.
> | | | | | | |/ _` | |
> | | |_| | | | (_| | | Version 0.3.9 (2015-05-30 11:24 UTC)
> _/ |\__'_|_|_|\__'_| |
> |__/ | x86_64-linux-gnu
>
> julia> include("cairop2.jl")
> Pdata(87413648,Ptr{Uint32} @0x000000000000004f,0x0387dd54)
>
> julia>
>
> which i do not consider correct, as i know the cairo status (first entry
> in Pdata) should be 0, the following pointer to data is the number of
> entries (i have a correctly working c program for the same example).
>
> I spare you the details, but the same code run with a v0.4.0-dev+5208
> segfaults...
>
> How do i get my 3 entries in the path data structure (see cairo.h
> definition in comment inline) correct (and version independent)?
>
> Wishing a happy day,
> Andreas
>
>
>