[Vala] Foreach with lambda: C error
- From: Marco Trevisan (Treviño) <mail 3v1n0 net>
- To: vala-list gnome org
- Subject: [Vala] Foreach with lambda: C error
- Date: Tue, 19 Oct 2010 19:32:34 +0200
I'm trying to use a lambda function as a foreach body for an HashTable:
public void print_hashmap(GLib.HashTable<string,GLib.Value?> map) {
// ....
map.foreach((k, v) => {
string key = (string)k;
Value val = (Value)v;
print(@"Foreach k: $key => %s\n",val.strdup_contents());
});
}
It seems correct and Vala converts it to C, but when compiling my code I
get this error:
test.c: In function ‘_lambda0_’:
test.c:275: error: conversion to non-scalar type requested
My lambda0 function is defined like this in C:
static void _lambda0_ (void* k, void* v, TestClass* self) {
char* key;
GValue _tmp0_ = {0};
GValue val;
char* _tmp1_;
char* _tmp2_;
key = g_strdup ((const char*) k);
// BUGGY LINE BELOW!!!!
val = G_IS_VALUE (&((GValue) v)) ? (g_value_init (&_tmp0_, G_VALUE_TYPE
(&((GValue) v))), g_value_copy (&((GValue) v), &_tmp0_), _tmp0_) :
((GValue) v);
g_print (_tmp1_ = g_strconcat ("Foreach k: ", string_to_string (key), "
=> %s\n", NULL), _tmp2_ = g_strdup_value_contents (&val));
_g_free0 (_tmp2_);
_g_free0 (_tmp1_);
G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
_g_free0 (key);
}
Bug? :)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]