Commit 2549f2b7 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

update from gobject-introspection SVN, fixes bug 505920

2008-01-11  Juerg Billeter  <j@bitron.ch>

	* gobject-introspection/: update from gobject-introspection SVN,
	  fixes bug 505920

	* vapigen/vala-gen-introspect/vala-gen-introspect.in: fix to work
	  with updated gobject-introspection

svn path=/trunk/; revision=829
parent 93b91d12
2008-01-11 Jürg Billeter <j@bitron.ch>
* gobject-introspection/: update from gobject-introspection SVN,
fixes bug 505920
* vapigen/vala-gen-introspect/vala-gen-introspect.in: fix to work
with updated gobject-introspection
2008-01-10 Jürg Billeter <j@bitron.ch>
* vapi/packages/gnome-desktop-2.0/: update to gnome-desktop 2.21.4
......
......@@ -15,24 +15,29 @@ libgidl_la_SOURCES = \
gidlnode.h \
gidlparser.c \
gidlparser.h \
girepository.h \
gmetadata.c \
gmetadata.h \
$(NULL)
libgidl_la_LIBADD = \
$(GLIB_LIBS) \
$(GMODULE_LIBS) \
$(NULL)
pkglibexecdir = $(libdir)/vala
pkglibexec_PROGRAMS = gen-introspect
BUILT_SOURCES = cparser.h
BUILT_SOURCES = scannerparser.h
AM_YFLAGS = -d
gen_introspect_SOURCES = \
clexer.l \
cparser.y \
gen-introspect.c \
gen-introspect.h \
gidlwriter.c \
gidlwriter.h \
scanner.c \
scanner.h \
scannerlexer.l \
scannerparser.y \
$(NULL)
gen_introspect_LDADD = \
......
This diff is collapsed.
/* GObject introspection: gen-introspect
*
* Copyright (C) 2007 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
#ifndef __GEN_INTROSPECT_H__
#define __GEN_INTROSPECT_H__
#include <glib.h>
#include "gidlmodule.h"
G_BEGIN_DECLS
typedef struct _GIGenerator GIGenerator;
typedef struct _CSymbol CSymbol;
typedef struct _CType CType;
struct _GIGenerator {
const char *namespace;
char *lower_case_namespace;
/* specified files to be parsed */
GList *filenames;
GList *libraries;
/* source reference of current lexer position */
char *current_filename;
GList *symbol_list;
GHashTable *typedef_table;
GHashTable *struct_or_union_or_enum_table;
gboolean macro_scan;
GIdlModule *module;
GList *get_type_symbols;
GHashTable *type_map;
GHashTable *type_by_lower_case_prefix;
int indent;
};
GIGenerator *g_igenerator_new (void);
void g_igenerator_parse (GIGenerator *igenerator, FILE *f);
void g_igenerator_add_symbol (GIGenerator *igenerator, CSymbol *symbol);
gboolean g_igenerator_is_typedef (GIGenerator *igenerator, const char *name);
void g_igenerator_generate (GIGenerator *igenerator);
GIGenerator *the_igenerator;
typedef enum {
CSYMBOL_TYPE_INVALID,
CSYMBOL_TYPE_CONST,
CSYMBOL_TYPE_OBJECT,
CSYMBOL_TYPE_FUNCTION,
CSYMBOL_TYPE_STRUCT,
CSYMBOL_TYPE_UNION,
CSYMBOL_TYPE_ENUM,
CSYMBOL_TYPE_TYPEDEF
} CSymbolType;
struct _CSymbol {
CSymbolType type;
int id;
char *ident;
CType *base_type;
gboolean const_int_set;
int const_int;
char *const_string;
};
CSymbol *csymbol_new (CSymbolType type);
gboolean csymbol_get_const_boolean (CSymbol *symbol);
typedef enum {
CTYPE_INVALID,
CTYPE_VOID,
CTYPE_BASIC_TYPE,
CTYPE_TYPEDEF,
CTYPE_STRUCT,
CTYPE_UNION,
CTYPE_ENUM,
CTYPE_POINTER,
CTYPE_ARRAY,
CTYPE_FUNCTION
} CTypeType;
typedef enum {
STORAGE_CLASS_NONE = 0,
STORAGE_CLASS_TYPEDEF = 1 << 1,
STORAGE_CLASS_EXTERN = 1 << 2,
STORAGE_CLASS_STATIC = 1 << 3,
STORAGE_CLASS_AUTO = 1 << 4,
STORAGE_CLASS_REGISTER = 1 << 5
} StorageClassSpecifier;
typedef enum {
TYPE_QUALIFIER_NONE = 0,
TYPE_QUALIFIER_CONST = 1 << 1,
TYPE_QUALIFIER_RESTRICT = 1 << 2,
TYPE_QUALIFIER_VOLATILE = 1 << 3
} TypeQualifier;
typedef enum {
FUNCTION_NONE = 0,
FUNCTION_INLINE = 1 << 1
} FunctionSpecifier;
typedef enum {
UNARY_ADDRESS_OF,
UNARY_POINTER_INDIRECTION,
UNARY_PLUS,
UNARY_MINUS,
UNARY_BITWISE_COMPLEMENT,
UNARY_LOGICAL_NEGATION
} UnaryOperator;
struct _CType {
CTypeType type;
StorageClassSpecifier storage_class_specifier;
TypeQualifier type_qualifier;
FunctionSpecifier function_specifier;
char *name;
CType *base_type;
GList *child_list;
};
CType *ctype_new (CTypeType type);
CType *ctype_copy (CType *type);
CType *cbasic_type_new (const char *name);
CType *ctypedef_new (const char *name);
CType *cstruct_new (const char *name);
CType *cunion_new (const char *name);
CType *cenum_new (const char *name);
CType *cpointer_new (CType *base_type);
CType *carray_new (void);
CType *cfunction_new (void);
G_END_DECLS
#endif
......@@ -23,20 +23,23 @@
#include "gidlmodule.h"
#include "gidlnode.h"
#include "gmetadata.h"
#define ALIGN_VALUE(this, boundary) \
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
GIdlModule *
g_idl_module_new (const gchar *name)
g_idl_module_new (const gchar *name, const gchar *shared_library)
{
GIdlModule *module;
module = g_new (GIdlModule, 1);
module->name = g_strdup (name);
if (shared_library)
module->shared_library = g_strdup (shared_library);
else
module->shared_library = NULL;
module->entries = NULL;
return module;
......@@ -57,12 +60,12 @@ g_idl_module_free (GIdlModule *module)
g_free (module);
}
void
GMetadata *
g_idl_module_build_metadata (GIdlModule *module,
GList *modules,
guchar **metadata,
gsize *length)
GList *modules)
{
guchar *metadata;
gsize length;
gint i;
GList *e;
Header *header;
......@@ -116,6 +119,9 @@ g_idl_module_build_metadata (GIdlModule *module,
header->annotations = 0; /* filled in later */
header->size = 0; /* filled in later */
header->namespace = write_string (module->name, strings, data, &header_size);
header->shared_library = (module->shared_library?
write_string (module->shared_library, strings, data, &header_size)
: 0);
header->directory = ALIGN_VALUE (header_size, 4);
header->entry_blob_size = 12;
header->function_blob_size = 16;
......@@ -202,7 +208,8 @@ g_idl_module_build_metadata (GIdlModule *module,
g_message ("reallocating to %d bytes", offset2);
*metadata = g_realloc (data, offset2);
*length = header->size = offset2;
metadata = g_realloc (data, offset2);
length = header->size = offset2;
return g_metadata_new_from_memory (metadata, length);
}
......@@ -22,6 +22,7 @@
#define __G_IDL_MODULE_H__
#include <glib.h>
#include "gmetadata.h"
G_BEGIN_DECLS
......@@ -31,16 +32,16 @@ typedef struct _GIdlModule GIdlModule;
struct _GIdlModule
{
gchar *name;
gchar *shared_library;
GList *entries;
};
GIdlModule *g_idl_module_new (const gchar *name);
GIdlModule *g_idl_module_new (const gchar *name,
const gchar *module_filename);
void g_idl_module_free (GIdlModule *module);
void g_idl_module_build_metadata (GIdlModule *module,
GList *modules,
guchar **metadata,
gsize *length);
GMetadata * g_idl_module_build_metadata (GIdlModule *module,
GList *modules);
G_END_DECLS
......
......@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include "gidlmodule.h"
......@@ -92,6 +93,11 @@ parse_type_internal (gchar *str, gchar **rest)
{ "void", TYPE_TAG_VOID, 0 },
{ "gpointer", TYPE_TAG_VOID, 1 },
{ "gboolean", TYPE_TAG_BOOLEAN, 0 },
#if 0
{ "char", TYPE_TAG_INT8, 0 },
{ "gchar", TYPE_TAG_INT8, 0 },
{ "guchar", TYPE_TAG_UINT8, 0 },
#endif
{ "int8_t", TYPE_TAG_INT8, 0 },
{ "int8", TYPE_TAG_INT8, 0 },
{ "gint8", TYPE_TAG_INT8, 0 },
......@@ -1724,15 +1730,16 @@ start_element_handler (GMarkupParseContext *context,
case 'n':
if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_ROOT)
{
const gchar *name;
const gchar *name, *shared_library;
name = find_attribute ("name", attribute_names, attribute_values);
shared_library = find_attribute ("shared-library", attribute_names, attribute_values);
if (name == NULL)
MISSING_ATTRIBUTE (error, element_name, "name");
else
{
ctx->current_module = g_idl_module_new (name);
ctx->current_module = g_idl_module_new (name, shared_library);
ctx->modules = g_list_append (ctx->modules, ctx->current_module);
ctx->state = STATE_NAMESPACE;
......@@ -1863,7 +1870,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_NAMESPACE:
if (strcmp (element_name, "namespace") == 0)
{
{
ctx->current_module = NULL;
ctx->state = STATE_ROOT;
}
......
/* GObject introspection: gen-introspect
*
* Copyright (C) 2007 Jürg Billeter
* Copyright (C) 2007 Johan Dahlin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
#include <stdio.h>
#include <glib.h>
#include "scanner.h"
#include "gidlnode.h"
typedef struct {
int indent;
FILE *output;
} GIdlWriter;
static void node_generate (GIdlWriter * writer, GIdlNode * node);
static void
g_writer_write_inline (GIdlWriter * writer, const char *s)
{
fprintf (writer->output, "%s", s);
}
static void
g_writer_write (GIdlWriter * writer, const char *s)
{
int i;
for (i = 0; i < writer->indent; i++)
{
fprintf (writer->output, "\t");
}
g_writer_write_inline (writer, s);
}
static void
g_writer_write_indent (GIdlWriter * writer, const char *s)
{
g_writer_write (writer, s);
writer->indent++;
}
static void
g_writer_write_unindent (GIdlWriter * writer, const char *s)
{
writer->indent--;
g_writer_write (writer, s);
}
static void
field_generate (GIdlWriter * writer, GIdlNodeField * node)
{
char *markup =
g_markup_printf_escaped ("<field name=\"%s\" type=\"%s\"/>\n",
node->node.name, node->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
}
static void
value_generate (GIdlWriter * writer, GIdlNodeValue * node)
{
char *markup =
g_markup_printf_escaped ("<member name=\"%s\" value=\"%d\"/>\n",
node->node.name, node->value);
g_writer_write (writer, markup);
g_free (markup);
}
static void
constant_generate (GIdlWriter * writer, GIdlNodeConstant * node)
{
char *markup =
g_markup_printf_escaped
("<constant name=\"%s\" type=\"%s\" value=\"%s\"/>\n", node->node.name,
node->type->unparsed, node->value);
g_writer_write (writer, markup);
g_free (markup);
}
static void
property_generate (GIdlWriter * writer, GIdlNodeProperty * node)
{
char *markup =
g_markup_printf_escaped ("<property name=\"%s\" "
"type=\"%s\" "
"readable=\"%s\" "
"writable=\"%s\" "
"construct=\"%s\" "
"construct-only=\"%s\"/>\n",
node->node.name,
node->type->unparsed,
node->readable ? "1" : "0",
node->writable ? "1" : "0",
node->construct ? "1" : "0",
node->construct_only ? "1" : "0");
g_writer_write (writer, markup);
g_free (markup);
}
static void
function_generate (GIdlWriter * writer, GIdlNodeFunction * node)
{
const char *tag_name;
GString *markup_s;
gchar *markup;
if (node->node.type == G_IDL_NODE_CALLBACK)
tag_name = "callback";
else if (node->is_constructor)
tag_name = "constructor";
else if (node->is_method)
tag_name = "method";
else
tag_name = "function";
markup_s = g_string_new ("<");
g_string_append_printf (markup_s,
"%s name=\"%s\"",
tag_name, node->node.name);
if (node->node.type != G_IDL_NODE_CALLBACK)
g_string_append_printf (markup_s,
g_markup_printf_escaped (" symbol=\"%s\"", node->symbol));
if (node->deprecated)
g_string_append_printf (markup_s, " deprecated=\"1\"");
g_string_append (markup_s, ">\n");
g_writer_write_indent (writer, markup_s->str);
g_string_free (markup_s, TRUE);
markup =
g_markup_printf_escaped ("<return-type type=\"%s\"/>\n",
node->result->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
if (node->parameters != NULL)
{
GList *l;
g_writer_write_indent (writer, "<parameters>\n");
for (l = node->parameters; l != NULL; l = l->next)
{
GIdlNodeParam *param = l->data;
markup =
g_markup_printf_escaped ("<parameter name=\"%s\" type=\"%s\"/>\n",
param->node.name, param->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
}
g_writer_write_unindent (writer, "</parameters>\n");
}
markup = g_strdup_printf ("</%s>\n", tag_name);
g_writer_write_unindent (writer, markup);
g_free (markup);
}
static void
vfunc_generate (GIdlWriter * writer, GIdlNodeVFunc * node)
{
char *markup =
g_markup_printf_escaped ("<vfunc name=\"%s\">\n", node->node.name);
g_writer_write_indent (writer, markup);
g_free (markup);
markup =
g_markup_printf_escaped ("<return-type type=\"%s\"/>\n",
node->result->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
if (node->parameters != NULL)
{
GList *l;
g_writer_write_indent (writer, "<parameters>\n");
for (l = node->parameters; l != NULL; l = l->next)
{
GIdlNodeParam *param = l->data;
markup =
g_markup_printf_escaped ("<parameter name=\"%s\" type=\"%s\"/>\n",
param->node.name, param->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
}
g_writer_write_unindent (writer, "</parameters>\n");
}
g_writer_write_unindent (writer, "</vfunc>\n");
}
static void
signal_generate (GIdlWriter * writer, GIdlNodeSignal * node)
{
char *markup;
const char *when = "LAST";
if (node->run_first)
{
when = "FIRST";
}
else if (node->run_cleanup)
{
when = "CLEANUP";
}
markup =
g_markup_printf_escaped ("<signal name=\"%s\" when=\"%s\">\n",
node->node.name, when);
g_writer_write_indent (writer, markup);
g_free (markup);
markup =
g_markup_printf_escaped ("<return-type type=\"%s\"/>\n",
node->result->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
if (node->parameters != NULL)
{
GList *l;
g_writer_write_indent (writer, "<parameters>\n");
for (l = node->parameters; l != NULL; l = l->next)
{
GIdlNodeParam *param = l->data;
markup =
g_markup_printf_escaped ("<parameter name=\"%s\" type=\"%s\"/>\n",
param->node.name, param->type->unparsed);
g_writer_write (writer, markup);
g_free (markup);
}
g_writer_write_unindent (writer, "</parameters>\n");
}
g_writer_write_unindent (writer, "</signal>\n");
}
static void
interface_generate (GIdlWriter * writer, GIdlNodeInterface * node)
{
GList *l;
char *markup;
if (node->node.type == G_IDL_NODE_OBJECT)
{
markup =
g_markup_printf_escaped ("<object name=\"%s\" "
"parent=\"%s\" "
"type-name=\"%s\" "
"get-type=\"%s\">\n",
node->node.name,
node->parent,
node->gtype_name,
node->gtype_init);
}
else if (node->node.type == G_IDL_NODE_INTERFACE)
{
markup =
g_markup_printf_escaped
("<interface name=\"%s\" type-name=\"%s\" get-type=\"%s\">\n",
node->node.name, node->gtype_name, node->gtype_init);
}
g_writer_write_indent (writer, markup);
g_free (markup);
if (node->node.type == G_IDL_NODE_OBJECT && node->interfaces != NULL)
{
GList *l;
g_writer_write_indent (writer, "<implements>\n");
for (l = node->interfaces; l != NULL; l = l->next)
{
markup =
g_markup_printf_escaped ("<interface name=\"%s\"/>\n",
(char *) l->data);
g_writer_write (writer, markup);
g_free (markup);
}
g_writer_write_unindent (writer, "</implements>\n");
}
else if (node->node.type == G_IDL_NODE_INTERFACE
&& node->prerequisites != NULL)
{
GList *l;
g_writer_write_indent (writer, "<requires>\n");
for (l = node->prerequisites; l != NULL; l = l->next)
{
markup =
g_markup_printf_escaped ("<interface name=\"%s\"/>\n",
(char *) l->data);
g_writer_write (writer, markup);
g_free (markup);
}
g_writer_write_unindent (writer, "</requires>\n");
}
for (l = node->members; l != NULL; l = l->next)
{
node_generate (writer, l->data);
}
if (node->node.type == G_IDL_NODE_OBJECT)
{
g_writer_write_unindent (writer, "</object>\n");
}
else if (node->node.type == G_IDL_NODE_INTERFACE)
{
g_writer_write_unindent (writer, "</interface>\n");
}
}
static void
struct_generate (GIdlWriter * writer, GIdlNodeStruct * node)
{
GList *l;
char *markup =
g_markup_printf_escaped ("<struct name=\"%s\">\n", node->node.name);
g_writer_write_indent (writer, markup);
g_free (markup);
for (l = node->members; l != NULL; l = l->next)
{
node_generate (writer, l->data);
}
g_writer_write_unindent (writer, "</struct>\n");
}
static void
union_generate (GIdlWriter * writer, GIdlNodeUnion * node)
{
GList *l;
char *markup =
g_markup_printf_escaped ("<union name=\"%s\">\n", node->node.name);
g_writer_write_indent (writer, markup);
g_free (markup);
for (l = node->members; l != NULL; l = l->next)
{
node_generate (writer, l->data);
}
g_writer_write_unindent (writer, "</union>\n");
}
static void
boxed_generate (GIdlWriter * writer, GIdlNodeBoxed * node)
{
GList *l;
char *markup =
g_markup_printf_escaped
("<boxed name=\"%s\" type-name=\"%s\" get-type=\"%s\">\n",
node->node.name, node->gtype_name, node->gtype_init);
g_writer_write_indent (writer, markup);
g_free (markup);
for (l = node->members; l != NULL; l = l->next)
{
node_generate (writer, l->data);
}
g_writer_write_unindent (writer, "</boxed>\n");
}
static void
enum_generate (GIdlWriter * writer, GIdlNodeEnum * node)
{
GList *l;
char *markup;
const char *tag_name = NULL;
if (node->node.type == G_IDL_NODE_ENUM)
{
tag_name = "enum";
}