return PyString_FromString (self->symbol->const_string);
}
+static PyObject *
+symbol_get_source_filename (PyGISourceSymbol *self,
+ void *context)
+{
+ if (!self->symbol->source_filename)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return PyString_FromString (self->symbol->source_filename);
+}
+
static const PyGetSetDef _PyGISourceSymbol_getsets[] = {
/* int ref_count; */
{ "type", (getter)symbol_get_type, 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_string", (getter)symbol_get_const_string, NULL, NULL},
+ { "const_string", (getter)symbol_get_const_string, NULL, NULL},
+ { "source_filename", (getter)symbol_get_source_filename, NULL, NULL},
{ 0 }
};
if (symbol->base_type)
ctype_free (symbol->base_type);
g_free (symbol->const_string);
+ g_free (symbol->source_filename);
g_slice_free (GISourceSymbol, symbol);
}
}
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)
{
gboolean const_int_set;
int const_int;
char *const_string;
+ char *source_filename;
};
struct _GISourceType
if self._symbol.base_type is not None:
return SourceType(self._scanner, self._symbol.base_type)
+ @property
+ def source_filename(self):
+ return self._symbol.source_filename
+
class SourceScanner(object):
return return_
def _create_const(self, symbol):
+ # Don't create constants for non-public things
+ # http://bugzilla.gnome.org/show_bug.cgi?id=572790
+ if not symbol.source_filename.endswith('.h'):
+ return None
name = self.remove_prefix(symbol.ident)
if symbol.const_string is None:
type_name = 'int'
</return-value>
</method>
</record>
+ <constant name="DEFINE_SHOULD_BE_EXPOSED" value="should be exposed">
+ <type name="utf8"/>
+ </constant>
<enumeration name="EnumFullname" c:type="FooEnumFullname">
<member name="one" value="1" c:identifier="FOO_ENUM_FULLNAME_ONE"/>
<member name="two" value="2" c:identifier="FOO_ENUM_FULLNAME_TWO"/>
</return-value>
</method>
</record>
+ <constant name="DEFINE_SHOULD_BE_EXPOSED" value="should be exposed">
+ <type name="utf8"/>
+ </constant>
<enumeration name="EnumFullname">
<member name="one" value="1"/>
<member name="two" value="2"/>
-#define FOO_SUCCESS_INT 0x1138
-
#include "foo.h"
/* A hidden type not exposed publicly, similar to GUPNP's XML wrapper
foo_buffer_some_method (FooBuffer *buffer)
{
}
+
+#define FOO_DEFINE_SHOULD_NOT_BE_EXPOSED "should not be exposed"
#include <glib-object.h>
#include "utility.h"
+#define FOO_SUCCESS_INT 0x1138
+
+#define FOO_DEFINE_SHOULD_BE_EXPOSED "should be exposed"
+
#define FOO_TYPE_INTERFACE (foo_interface_get_type ())
#define FOO_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_INTERFACE, FooInterface))
#define FOO_IS_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_INTERFACE))
arg.endswith('.h')):
if not os.path.exists(arg):
_error('%s: no such a file or directory' % (arg, ))
- filenames.append(arg)
+ # Make absolute, because we do comparisons inside scannerparser.c
+ # against the absolute path that cpp will give us
+ filenames.append(os.path.abspath(arg))
cachestore = CacheStore()
transformer = Transformer(cachestore,