summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-03-27 19:20:45 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-03-27 19:20:45 +0000
commit8427c62f516831ffef9aa8e2b35748b856bf89ec (patch)
tree5fb3fd892c4577af55579f3dda9b57ee71e58934 /giscanner
parent2faf92a1d87c6cd9b0d3dce20da74dc82a7e82c8 (diff)
downloadgobject-introspection-8427c62f516831ffef9aa8e2b35748b856bf89ec.tar.gz
Add simple pre-processor using subprocess and a PIPE. Change the
2008-03-27 Johan Dahlin <johan@gnome.org> * giscanner/giscannermodule.c: * giscanner/scannerlexer.l: * giscanner/sourcescanner.c: * tools/g-ir-scanner: Add simple pre-processor using subprocess and a PIPE. Change the parse_file apis to accept a file descriptor. svn path=/trunk/; revision=169
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/giscannermodule.c11
-rw-r--r--giscanner/scannerlexer.l10
-rw-r--r--giscanner/sourcescanner.c1
3 files changed, 13 insertions, 9 deletions
diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c
index 4d7bc7d5..c14151e0 100644
--- a/giscanner/giscannermodule.c
+++ b/giscanner/giscannermodule.c
@@ -200,13 +200,14 @@ static PyObject *
pygi_source_scanner_parse_file (PyGISourceScanner *self,
PyObject *args)
{
+ int fd;
char *filename;
FILE *fp;
- if (!PyArg_ParseTuple (args, "s:SourceScanner.__init__", &filename))
+ if (!PyArg_ParseTuple (args, "is:SourceScanner.__init__", &fd, &filename))
return NULL;
- fp = fopen (filename, "r");
+ fp = fdopen (fd, "r");
if (!fp)
{
PyErr_SetFromErrnoWithFilename (PyExc_OSError, filename);
@@ -215,16 +216,14 @@ pygi_source_scanner_parse_file (PyGISourceScanner *self,
self->scanner->filenames =
g_list_append (self->scanner->filenames, g_strdup (filename));
- self->scanner->current_filename = self->scanner->filenames->data;
-
+ self->scanner->current_filename = g_strdup (filename);
+
if (!gi_source_scanner_parse_file (self->scanner, fp))
{
g_print ("Something went wrong..\n");
return NULL;
}
- fclose (fp);
-
Py_INCREF (Py_None);
return Py_None;
}
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index 03455d73..9870efd7 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -384,9 +384,13 @@ process_directive (GISourceScanner *scanner)
if (filename_builder->len > 0) {
char *filename = g_strcompress (filename_builder->str);
- g_free (scanner->current_filename);
- scanner->current_filename = g_realpath(filename);
- g_free(filename);
+ if (g_realpath (filename))
+ {
+ g_free (scanner->current_filename);
+ scanner->current_filename = g_realpath (filename);
+ g_assert (scanner->current_filename);
+ g_free(filename);
+ }
}
g_string_free (filename_builder, TRUE);
diff --git a/giscanner/sourcescanner.c b/giscanner/sourcescanner.c
index 19026913..39507924 100644
--- a/giscanner/sourcescanner.c
+++ b/giscanner/sourcescanner.c
@@ -249,6 +249,7 @@ gi_source_scanner_add_symbol (GISourceScanner *scanner,
gboolean found_filename = FALSE;
GList *l;
+ g_assert (scanner->current_filename);
for (l = scanner->filenames; l != NULL; l = l->next)
{
if (strcmp (l->data, scanner->current_filename) == 0)