Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
vala
vala
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 701
    • Issues 701
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 39
    • Merge Requests 39
  • Operations
    • Operations
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • GNOME
  • valavala
  • Issues
  • #230

Closed
Open
Opened Sep 11, 2011 by bugzilla-migration@bugzilla-migrationReporter

'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 Jul 17, 2020 by Rico Tzschichholz
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
1.0
Milestone
1.0
Assign milestone
Time tracking
None
Due date
None
Reference: GNOME/vala#230