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 396770b..06497df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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 
        as tool to verify Vala bindings. currently only .metadata files are
        checked for unresolved symbols.
index 991c0db..e035c77 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 af64e4e..34ab314 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");
+       }
+}