[SYMBOL_LINES] Support for line numbers on Symbols
[gnome.gobject-introspection] / giscanner / giscannermodule.c
index 7d63784..2d2e073 100644 (file)
@@ -22,8 +22,9 @@
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
-#include "sourcescanner.h"
 #include <Python.h>
+#include "sourcescanner.h"
+#include "grealpath.h"
 
 #ifdef _WIN32
 #include <fcntl.h>
@@ -110,6 +111,13 @@ symbol_get_type (PyGISourceSymbol *self,
   return PyInt_FromLong (self->symbol->type);
 }
 
+static PyObject *
+symbol_get_line (PyGISourceSymbol *self,
+                void             *context)
+{
+  return PyInt_FromLong (self->symbol->line);
+}
+
 static PyObject *
 symbol_get_ident (PyGISourceSymbol *self,
                  void            *context)
@@ -135,9 +143,26 @@ static PyObject *
 symbol_get_const_int (PyGISourceSymbol *self,
                      void             *context)
 {
+  if (!self->symbol->const_int_set)
+    {
+      Py_INCREF(Py_None);
+      return Py_None;
+    }
   return PyInt_FromLong (self->symbol->const_int);
 }
 
+static PyObject *
+symbol_get_const_double (PyGISourceSymbol *self,
+                         void             *context)
+{
+  if (!self->symbol->const_double_set)
+    {
+      Py_INCREF(Py_None);
+      return Py_None;
+    }
+  return PyFloat_FromDouble (self->symbol->const_double);
+}
+
 static PyObject *
 symbol_get_const_string (PyGISourceSymbol *self,
                         void             *context)
@@ -171,9 +196,12 @@ static const PyGetSetDef _PyGISourceSymbol_getsets[] = {
   { "ident", (getter)symbol_get_ident, NULL, NULL},
   { "base_type", (getter)symbol_get_base_type, NULL, NULL},
   /* gboolean const_int_set; */
-  { "const_int", (getter)symbol_get_const_int, NULL, NULL},  
+  { "const_int", (getter)symbol_get_const_int, NULL, NULL},
+  /* gboolean const_double_set; */
+  { "const_double", (getter)symbol_get_const_double, NULL, NULL},
   { "const_string", (getter)symbol_get_const_string, NULL, NULL},
   { "source_filename", (getter)symbol_get_source_filename, NULL, NULL},
+  { "line", (getter)symbol_get_line, NULL, NULL},
   { 0 }
 };
 
@@ -316,7 +344,7 @@ pygi_source_scanner_append_filename (PyGISourceScanner *self,
     return NULL;
 
   self->scanner->filenames = g_list_append (self->scanner->filenames,
-                                           g_strdup (filename));
+                                           g_realpath (filename));
   
   Py_INCREF (Py_None);
   return Py_None;