[SYMBOL_LINES] Support for line numbers on Symbols
[gnome.gobject-introspection] / giscanner / sourcescanner.c
index 1a2508d..14e3a3b 100644 (file)
 #include <string.h>
 
 GISourceSymbol *
-gi_source_symbol_new (GISourceSymbolType type)
+gi_source_symbol_new (GISourceSymbolType type, int line)
 {
   GISourceSymbol *s = g_slice_new0 (GISourceSymbol);
   s->ref_count = 1;
   s->type = type;
+  s->line = line;
   return s;
 }
 
@@ -60,6 +61,7 @@ gi_source_symbol_unref (GISourceSymbol * symbol)
       if (symbol->base_type)
         ctype_free (symbol->base_type);
       g_free (symbol->const_string);
+      g_free (symbol->source_filename);
       g_slice_free (GISourceSymbol, symbol);
     }
 }
@@ -245,6 +247,11 @@ gi_source_scanner_add_symbol (GISourceScanner  *scanner,
   if (found_filename || scanner->macro_scan)
     scanner->symbols = g_slist_prepend (scanner->symbols,
                                        gi_source_symbol_ref (symbol));
+  /* TODO: Refcounted string here or some other optimization */
+  if (found_filename && symbol->source_filename == NULL)
+    {
+      symbol->source_filename = g_strdup (scanner->current_filename);
+    }
 
   switch (symbol->type)
     {