'unowned' is not propagated to .vapi for non-nullable structs
Submitted by Sam Thursfield
Link to original bug (#658720)
Description
In the following code, the 'unowned' flag for the return type of get_struct_1() is not written correctly to the .vapi file:
unowned-values.vala
public struct S {
int foo;
}
S s;
public unowned S get_struct_1 () {
return s;
}
public unowned S? get_struct_2 () {
return s;
}
unowned-values.vapi
/* unowned-values.vapi generated by valac 0.13.4.8-6faa4, do not modify. */
[CCode (cheader_filename = "unowned-values.h")]
public struct S {
public int foo;
}
[CCode (cheader_filename = "unowned-values.h")]
public static S get_struct_1 ();
[CCode (cheader_filename = "unowned-values.h")]
public static unowned S? get_struct_2 ();
unowned-values.c
/* unowned-values.c generated by valac 0.13.4.8-6faa4, the Vala compiler
* generated from unowned-values.vala, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <string.h>
#define TYPE_S (s_get_type ())
typedef struct _S S;
struct _S {
gint foo;
};
extern S s;
S s = {0};
GType s_get_type (void) G_GNUC_CONST;
S* s_dup (const S* self);
void s_free (S* self);
void get_struct_1 (S* result);
S* get_struct_2 (void);
S* s_dup (const S* self) {
S* dup;
dup = g_new0 (S, 1);
memcpy (dup, self, sizeof (S));
return dup;
}
void s_free (S* self) {
g_free (self);
}
GType s_get_type (void) {
static volatile gsize s_type_id__volatile = 0;
if (g_once_init_enter (&s_type_id__volatile)) {
GType s_type_id;
s_type_id = g_boxed_type_register_static ("S", (GBoxedCopyFunc) s_dup, (GBoxedFreeFunc) s_free);
g_once_init_leave (&s_type_id__volatile, s_type_id);
}
return s_type_id__volatile;
}
void get_struct_1 (S* result) {
S _tmp0_;
_tmp0_ = s;
*result = _tmp0_;
return;
}
S* get_struct_2 (void) {
S* result = NULL;
S _tmp0_;
_tmp0_ = s;
result = &_tmp0_;
return result;
}
Edited by Rico Tzschichholz