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 521688 - Array of delegates doesn't work
Array of delegates doesn't work
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Delegates
0.3.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
: 523749 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-03-10 22:59 UTC by Mikael Hermansson
Modified: 2009-10-07 14:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
full example code compile (842 bytes, application/octet-stream)
2008-03-10 23:04 UTC, Mikael Hermansson
Details

Description Mikael Hermansson 2008-03-10 22:59:02 UTC
Please describe the problem:
There is problem creating correct C code when using Callbacks in a "array"
like this:

public   delegate void cbCommand();
public struct ServerCallbackData
{
	public int replyID;
	public cbCommand cbc;
	ServerCallbackData( int id,  cbCommand _cbc) 
	{ replyID=id; cbc = _cbc; }
}

public class ServerCommands : Object {
	ServerCallbackData[] commands;
	string parameter;
	construct {    	commands=new ServerCallbackData[]
									{
											new ServerCallbackData(1 , on_default),
											new ServerCallbackData(2, on_user)
										};
	}

....

C code failys to compile

I will give an full example as attachment below

Steps to reproduce:


Actual results:
test.c:33: error: request for member ‘cbc_target’ in something not a structure or union beloW:


	(*self).cbc = (_tmp0 = _cbc, self.cbc_target = _cbc_target, _tmp0);


Expected results:
should be:

	(*self).cbc = (_tmp0 = _cbc, (*self).cbc_target = _cbc_target, _tmp0);


Does this happen every time?
using NON static callbacks in arrays

Other information:
works when making class callback members static but imho it should work when nonstatic to :-)
Comment 1 Mikael Hermansson 2008-03-10 23:04:37 UTC
Created attachment 107024 [details]
full example code compile

full example code compile with:

valac --save-temps --pkg glib-2.0 test.vala -o testapp
Comment 2 Jürg Billeter 2008-03-14 15:19:49 UTC
Confirming, instance delegates in arrays are not supported at the moment.
Comment 3 Jürg Billeter 2008-10-09 18:28:50 UTC
*** Bug 523749 has been marked as a duplicate of this bug. ***
Comment 4 Michael 'Mickey' Lauer 2009-10-07 14:03:48 UTC
Thanks for your report. This problem has been fixed meanwhile and is working in Vala 0.7.7.