Re: [Vala] Issues will vala and pulse vapi



From: Evan Nemerson <evan coeus-group com>

Sent: Sunday, 22 November 2015, 3:54
Subject: Re: [Vala] Issues will vala and pulse vapi

On Sat, 2015-11-21 at 20:48 -0600, Aaron Paden wrote:
 Right, the code compiles, but the linker fails because of the
 unresolved symbols. I didn't think of this before, but the minimal
 example is pretty simple:

 void main() {
   PulseAudio.SourceInfo info;
 }
If you don't provide a destroy_function CCode annotation but Vala
determines that it is necessary to call one, it will default to
lower_case_cprefix_destroy, which is why it is generating a call to
pulse_audio_source_info_destroy.



Hmm, just found this in the Legacy Bindings documentation (
https://wiki.gnome.org/Projects/Vala/LegacyBindings#Structs ):

"It's important to note that if a struct doesn't have a destroy function specified, Vala will generate one 
given there are any fields in the struct which look like they need to be deallocated, which may or may not 
behave correctly depending on the context. An empty destroy_function will keep the generated code correct and 
prevent Vala from generating a destructor."

So in the VAPI try:
[CCode (cname="pa_sink_info", destroy_function = "", has_type_id=false)]
public struct SinkInfo {
//...
}

If that works then I think we can say the Legacy Bindings
document has some real nuggets in there, it just needs a bit more
re-organisation to make this information more easily found.
At the moment this information is under recognizing Vala
semantics in C code and not the details of memory management.

Al


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