From: Mathias Hasselmann Date: Sun, 2 Sep 2007 11:56:20 +0000 (+0000) Subject: handle null pointer for expression_type in get_implicit_cast_expression. X-Git-Tag: VALA_0_1_4~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bea6f3243daa80cce34503c52b46cd46395ddb04;p=thirdparty%2Fvala.git handle null pointer for expression_type in get_implicit_cast_expression. 2007-09-02 Mathias Hasselmann * gobject/valacodegenerator.vala, tests/Makefile.am: handle null pointer for expression_type in get_implicit_cast_expression. needed for instance to pass function pointers to HashTable.full * tests/test-036.exp, tests/test-036.vala: test for usability of HashTable.full svn path=/trunk/; revision=574 --- diff --git a/ChangeLog b/ChangeLog index 396770bda..06497dfa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-02 Mathias Hasselmann + + * gobject/valacodegenerator.vala, tests/Makefile.am: handle null + pointer for expression_type in get_implicit_cast_expression. + needed for instance to pass function pointers to HashTable.full + * tests/test-036.exp, tests/test-036.vala: test for usability + of HashTable.full + 2007-09-02 Mathias Hasselmann * vapigen/Makefile.am, vapigen/valavapicheck.vala: adding vapicheck diff --git a/gobject/valacodegenerator.vala b/gobject/valacodegenerator.vala index 991c0db05..e035c7744 100644 --- a/gobject/valacodegenerator.vala +++ b/gobject/valacodegenerator.vala @@ -2641,7 +2641,11 @@ public class Vala.CodeGenerator : CodeVisitor { return result; } - private CCodeExpression! get_implicit_cast_expression (CCodeExpression! cexpr, TypeReference! expression_type, TypeReference! target_type) { + private CCodeExpression! get_implicit_cast_expression (CCodeExpression! cexpr, TypeReference expression_type, TypeReference! target_type) { + if (null == expression_type) { + return cexpr; + } + if (expression_type.data_type == target_type.data_type) { // same type, no cast required return cexpr; diff --git a/tests/Makefile.am b/tests/Makefile.am index af64e4e30..34ab3143f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -69,6 +69,7 @@ TESTS = \ test-033.vala \ test-034.vala \ test-035.vala \ + test-036.vala \ $(NULL) EXTRA_DIST = \ @@ -110,6 +111,7 @@ EXTRA_DIST = \ test-033.exp \ test-034.exp \ test-035.exp \ + test-036.exp \ \ testenchant.stamp \ testenchant.vala \ diff --git a/tests/test-036.exp b/tests/test-036.exp new file mode 100644 index 000000000..d8bb432ff --- /dev/null +++ b/tests/test-036.exp @@ -0,0 +1 @@ +testing function pointers: 1 2 3 diff --git a/tests/test-036.vala b/tests/test-036.vala new file mode 100644 index 000000000..471e9cccd --- /dev/null +++ b/tests/test-036.vala @@ -0,0 +1,15 @@ +using GLib; + +class Maman.Bar : GLib.Object { + static void main () { + stdout.printf ("testing function pointers:"); + var table = new HashTable.full (str_hash, str_equal, g_free, Object.unref); + stdout.printf (" 1"); + + table.insert ("foo", new Bar ()); + stdout.printf (" 2"); + + var bar = table.lookup ("foo"); + stdout.printf (" 3\n"); + } +}