[gobject-introspection] scanner: Abort if we would be generating an empty namespace



commit ef84d840a7822c20f30fe7a93526713acfabd57a
Author: Colin Walters <walters verbum org>
Date:   Wed Sep 29 13:55:29 2010 -0400

    scanner: Abort if we would be generating an empty namespace
    
    Kind of silly we weren't doing this before; an empty namespace
    is always going to be unintentional.
    
    The "oops I forgot to include .h" files actually happened with
    Clutter, but it wasn't caught since the build didn't obviously
    fail.

 giscanner/maintransformer.py |    6 ++++++
 tests/warn/unresolved-type.h |    4 ++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index e45ff79..89f7ff6 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -47,6 +47,12 @@ class MainTransformer(object):
     # Public API
 
     def transform(self):
+        contents = list(self._namespace.itervalues())
+        if len(contents) == 0:
+            message.fatal("""Namespace is empty; likely causes are:
+* Not including .h files to be scanned
+* Broken --identifier-prefix
+""")
         ## WORKAROUND ##
         # Dirty hack for now...maybe eventually we'll support the "typedef GSList FooSet"
         # pattern.
diff --git a/tests/warn/unresolved-type.h b/tests/warn/unresolved-type.h
index a31db5e..d20182c 100644
--- a/tests/warn/unresolved-type.h
+++ b/tests/warn/unresolved-type.h
@@ -17,3 +17,7 @@ typedef enum {
 } TestMyEnum2;
 
 // EXPECT:17: Warning: Test: symbol='TestMyEnum2': Unknown namespace for symbol 'MY_ENUM_A'
+
+/* Stub function here so namespace isn't empty */
+void test_foo (void);
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]