On Tue, Aug 23, 2011 at 10:43 AM, Evan Nemerson <[email protected]> wrote: > On Mon, 2011-08-22 at 08:36 -0700, bsquared wrote: >> I ran into a couple of issues regarding structs. >> >> 1. When using a struct from a pkg, as opposed to one of my creation, >> an error is raised in the c code when attempting to access the >> "built-in" to_string() method for an element. >> >> Context.State state = ctx.get_state(); >> print (state.to_string()); >> >> /.../Source/vala/pulse-device-chooser/src/main.t c:160:47: error: >> ‘PA_CONTEXT_TYPE_STATE’ undeclared (first use in this function) > > Looks like a missing CCode annotation in the VAPI. Depending on whether > Context.State has a GType > > [CCode (type_id = "pa_context_state_get_type ()")] > > or > > [CCode (has_type_id = false)] > >> >> 2. What is the correct method to copy a struct? Attempting to copy >> struct by assignment to variable, or Memory.copy causes "undefined >> reference to `pulse_audio_sink_info_copy'" errors in c code. > > There is no generic way to copy a struct. It depends on the library. > There may even be no way to copy, in which case you would likely need to > make judicious use of the "unowned" keyword. > >> where i & si are type PulseAudio.SinkInfo >> >> context.get_sink_info_by_index (index, (context, i, eol) => { >> Memory.copy(&i, &si, sizeof(SinkInfo)); >> si = i; >> }); >> >> >> >> 3. Attempting to box struct from pkg in an ArrayList causes an error >> in c code similar to question 1. >> Gee.ArrayList<SinkInfo?> sink_info = new Gee.ArrayList<SinkInfo?>(); >> >> main.c:643:31: error: ‘PULSE_AUDIO_TYPE_SINK_INFO’ undeclared (first >> use in this function) > > The solution is the same as above... either specify the correct type id > or set has_type_id = false for SinkInfo. > >
Thanks. This bug was reported on freedesktop. I added your comment there. https://bugs.freedesktop.org/show_bug.cgi?id=40290 -- Regards, -Brian _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
