[Vala] modify simpletype with methods in vapi
- From: pancake <pancake youterm com>
- To: vala-list gnome org
- Subject: [Vala] modify simpletype with methods in vapi
- Date: Sat, 29 May 2010 02:38:51 +0200
I've tried to do this without success:
31 [SimpleType]
32 [CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN",
marshaller_type_name = "BOOLEAN", get _value_function = "g_value_get_boolean", set_value_function =
"g_value_set_boolean", default_value = "FALSE", type_signatu re = "b")]
33 [BooleanType]
34 public struct bool {
35 public string to_string () {
36 if (this) {
37 return "true";
38 } else {
39 return "false";
40 }
41 }
42 public bool toggle() {
43 this = !this;
44 return this;
45 }
46 }
This is part of glib-2.0.vapi, with my 'toggle' method.
I thought this should be a valid expression, but it results into:
581 static gboolean bool_toggle (gboolean self) {
583 gboolean result = FALSE;
585 self = !self;
587 result = self;
589 return result;
591 }
Which is obviously not modifying the value, unless I do an assignment like:
bool foo = false;
foo.toggle (); // does nothing
foo = foo.toogle () //works
I was expecting both ways to work. what's the way to add this method to bool?
should this change be added in main glib.vapi ?
--pancake
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]