]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
handle null pointer for expression_type in get_implicit_cast_expression.
authorMathias Hasselmann <mathias.hasselmann@gmx.de>
Sun, 2 Sep 2007 11:56:20 +0000 (11:56 +0000)
committerMathias Hasselmann <hasselmm@src.gnome.org>
Sun, 2 Sep 2007 11:56:20 +0000 (11:56 +0000)
2007-09-02  Mathias Hasselmann  <mathias.hasselmann@gmx.de>

* 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

ChangeLog
gobject/valacodegenerator.vala
tests/Makefile.am
tests/test-036.exp [new file with mode: 0644]
tests/test-036.vala [new file with mode: 0644]

index 396770bdac02762c7d1ee9d66e7d25ea4a087fb9..06497dfa401e856b4bd9f5716f07be9e44f89bdd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-02  Mathias Hasselmann  <mathias.hasselmann@gmx.de>
+
+       * 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  <mathias.hasselmann@gmx.de>
 
        * vapigen/Makefile.am, vapigen/valavapicheck.vala: adding vapicheck 
index 991c0db05f10b20b163e6ae4df75ae3081caa71a..e035c7744ed16c2277d9804ce1685b769444522a 100644 (file)
@@ -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;
index af64e4e304307b860b811ffd13e84329ad5df334..34ab3143f0aa2f9f245c57af31882d9c8b3f278b 100644 (file)
@@ -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 (file)
index 0000000..d8bb432
--- /dev/null
@@ -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 (file)
index 0000000..471e9cc
--- /dev/null
@@ -0,0 +1,15 @@
+using GLib;
+
+class Maman.Bar : GLib.Object {
+       static void main () {
+               stdout.printf ("testing function pointers:");
+               var table = new HashTable<string, Bar>.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");
+       }
+}