After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 543073 - Generated para type must be same as vala type
Generated para type must be same as vala type
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.3.x
Other All
: Normal minor
: ---
Assigned To: Jürg Billeter
Vala maintainers
: 542953 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-07-15 10:34 UTC by Daniel Svensson
Modified: 2008-07-17 09:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adds support for changing C-type of parameters. (1.67 KB, patch)
2008-07-15 10:35 UTC, Daniel Svensson
none Details | Review
change generated formal parameter type (1.35 KB, patch)
2008-07-16 08:03 UTC, Daniel Svensson
reviewed Details | Review

Description Daniel Svensson 2008-07-15 10:34:13 UTC
Please describe the problem:
Some cases GTK uses GtkWidget a bit too broad. One of these cases are:

GtkMenuShell.append(GtkWidget child);

Which we want to handle more strict in Vala:
GtkMenuShell.append(GtkMenuItem child);

If you throw anything other than GtkMenuItem or any subclass at it, it will cry, and the documentation also mentions GtkMenuItem.

To come around this problem the .vapi-file now can use the following:

 public void append ([CCode(ctype="GtkWidget*")] Gtk.MenuItem child);

Which will be interpreted the same way as when changing type for fields (see Gtk.ActionEntry.callback for example)

Steps to reproduce:
Call the append method on the MenuShell class. and the C-code will give warnings when passed through gcc.

Actual results:
The C-code will give warnings when compiled by gcc.

Expected results:
No warnings.

Does this happen every time?
Yes.

Other information:
Patch attached.
Comment 1 Daniel Svensson 2008-07-15 10:35:52 UTC
Created attachment 114589 [details] [review]
adds support for changing C-type of parameters.

The patch is based on how fields handle the same kind of functionality.
Comment 2 Jared Moore 2008-07-15 14:11:19 UTC
Note that this is related to bug 542953, but I won't mark dupe since they both have patches.

The way you're handling the attribute looks a bit weird. Why not just something like..

	if (a.has_argument ("ctype")) {
		ctype = a.get_string ("ctype");
	}

	public string? ctype { get; private set; default = null }

The idea is that after attribute processing has happened, you shouldn't need to look at the attribute again after that.

Comment 3 Jared Moore 2008-07-15 14:21:50 UTC
Actually, looking at the commit that Raffaele made for bug 540661, it makes a lot of sense to do CCode attribute handling just in the gobject code. Anyway, this implementation is a bit weird because it stores the value of one attribute into another attribute. I don't see why the second new attribute is necessary. :)



Comment 4 Daniel Svensson 2008-07-15 15:09:28 UTC
Yeah, like I said, I did it the same way as the field version of this functionality because I thought there was some idea behind it. But ok, great, and that other patch was merged so lets close this one.

Maybe the field version of this bug should be changed too then.
Comment 5 Daniel Svensson 2008-07-15 15:17:22 UTC
ops.. didn't see that the resolved bug was kind of unreleated... same thing, but for return value. I could update the patch to be less retarded.
Comment 6 Daniel Svensson 2008-07-16 08:03:02 UTC
Created attachment 114644 [details] [review]
change generated formal parameter type

Patch updated based on comments.
Comment 7 Jürg Billeter 2008-07-17 09:10:22 UTC
*** Bug 542953 has been marked as a duplicate of this bug. ***
Comment 8 Jürg Billeter 2008-07-17 09:40:49 UTC
2008-07-17  Jürg Billeter  <j@bitron.ch>

	* vala/valaformalparameter.vala:
	* vala/valainterfacewriter.vala:
	* gobject/valaccodeinvocationexpressionbinding.vala:

	Support [CCode (type = "Foo")] for parameters,
	based on patch by Daniel Svensson, fixes bug 543073

	* vapigen/valagidlparser.vala:

	Add support for ctype metadata attribute for parameters

	* vapi/packages/gtk+-2.0/:

	Fix gtk_menu_shell_append binding

	* vapi/gtk+-2.0.vapi: regenerated

Fixed in r1710.