[Vala] Questions about structs: printing, copying, ArrayList<StructType?>



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.c:160:47: error:
‘PA_CONTEXT_TYPE_STATE’ undeclared (first use in this function)

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.

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)

-- 
Regards,
-Brian



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