mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 10:08:56 +01:00 
			
		
		
		
	Move shared *.[ch] files to girepository from tools
2008-08-09 Johan Dahlin <johan@gnome.org> * girepository/Makefile.am: * tools/Makefile.am: * tools/girmodule.c: * tools/girmodule.h: * tools/girnode.c: * tools/girnode.h: * tools/girparser.c: * tools/girparser.h: * tools/girwriter.c: * tools/girwriter.h: Move shared *.[ch] files to girepository from tools svn path=/trunk/; revision=337
This commit is contained in:
		
				
					committed by
					
						
						Johan Dahlin
					
				
			
			
				
	
			
			
			
						parent
						
							e1c3498df8
						
					
				
				
					commit
					282a6c644e
				
			
							
								
								
									
										19
									
								
								Makefile.am
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								Makefile.am
									
									
									
									
									
								
							@@ -1,10 +1,14 @@
 | 
				
			|||||||
## Process this file with automake to produce Makefile.in
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
include $(top_srcdir)/gcov.mak
 | 
					include $(top_srcdir)/gcov.mak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCOVSOURCES = $(libgirepository_la_SOURCES)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INCLUDES = -DGIREPO_DEFAULT_SEARCH_PATH="\"$(libdir)\""
 | 
					INCLUDES = -DGIREPO_DEFAULT_SEARCH_PATH="\"$(libdir)\""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					girepodir = $(includedir)/gobject-introspection-1.0/
 | 
				
			||||||
 | 
					girepo_HEADERS = girepository.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
lib_LTLIBRARIES = libgirepository.la
 | 
					lib_LTLIBRARIES = libgirepository.la
 | 
				
			||||||
 | 
					noinst_LTLIBRARIES = libgirepository-parser.la
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libgirepository_la_SOURCES =			\
 | 
					libgirepository_la_SOURCES =			\
 | 
				
			||||||
	girepository.c				\
 | 
						girepository.c				\
 | 
				
			||||||
@@ -15,7 +19,12 @@ libgirepository_la_SOURCES =			\
 | 
				
			|||||||
libgirepository_la_CPPFLAGS = $(GIREPO_CFLAGS)
 | 
					libgirepository_la_CPPFLAGS = $(GIREPO_CFLAGS)
 | 
				
			||||||
libgirepository_la_LIBADD = $(GIREPO_LIBS)
 | 
					libgirepository_la_LIBADD = $(GIREPO_LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
girepodir = $(includedir)/gobject-introspection-1.0/
 | 
					libgirepository_parser_la_SOURCES =		\
 | 
				
			||||||
girepo_HEADERS = girepository.h
 | 
						girmodule.c				\
 | 
				
			||||||
 | 
						girmodule.h				\
 | 
				
			||||||
 | 
						girnode.c				\
 | 
				
			||||||
 | 
						girnode.h				\
 | 
				
			||||||
 | 
						girparser.c				\
 | 
				
			||||||
 | 
						girparser.h
 | 
				
			||||||
 | 
					libgirepository_parser_la_CFLAGS = $(GIREPO_CFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GCOVSOURCES = $(libgirepository_la_SOURCES)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										215
									
								
								girmodule.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								girmodule.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,215 @@
 | 
				
			|||||||
 | 
					/* GObject introspection: Metadata creation 
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2005 Matthias Clasen
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 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 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.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "girmodule.h"
 | 
				
			||||||
 | 
					#include "girnode.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ALIGN_VALUE(this, boundary) \
 | 
				
			||||||
 | 
					  (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GIrModule *
 | 
				
			||||||
 | 
					g_ir_module_new (const gchar *name, const gchar *shared_library)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrModule *module;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  module = g_new (GIrModule, 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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					g_ir_module_free (GIrModule *module)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GList *e;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_free (module->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (e = module->entries; e; e = e->next)
 | 
				
			||||||
 | 
					    g_ir_node_free ((GIrNode *)e->data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_list_free (module->entries);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_free (module);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GTypelib *
 | 
				
			||||||
 | 
					g_ir_module_build_metadata (GIrModule  *module,
 | 
				
			||||||
 | 
								     GList       *modules)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  guchar *metadata;
 | 
				
			||||||
 | 
					  gsize length;
 | 
				
			||||||
 | 
					  gint i;
 | 
				
			||||||
 | 
					  GList *e;
 | 
				
			||||||
 | 
					  Header *header;
 | 
				
			||||||
 | 
					  DirEntry *entry;
 | 
				
			||||||
 | 
					  guint32 header_size;
 | 
				
			||||||
 | 
					  guint32 dir_size;
 | 
				
			||||||
 | 
					  guint32 n_entries;
 | 
				
			||||||
 | 
					  guint32 n_local_entries;
 | 
				
			||||||
 | 
					  guint32 size, offset, offset2, old_offset;
 | 
				
			||||||
 | 
					  GHashTable *strings;
 | 
				
			||||||
 | 
					  GHashTable *types;
 | 
				
			||||||
 | 
					  guchar *data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  header_size = ALIGN_VALUE (sizeof (Header), 4);
 | 
				
			||||||
 | 
					  n_local_entries = g_list_length (module->entries);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 restart:
 | 
				
			||||||
 | 
					  init_stats ();
 | 
				
			||||||
 | 
					  strings = g_hash_table_new (g_str_hash, g_str_equal);
 | 
				
			||||||
 | 
					  types = g_hash_table_new (g_str_hash, g_str_equal);
 | 
				
			||||||
 | 
					  n_entries = g_list_length (module->entries);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_message ("%d entries (%d local)\n", n_entries, n_local_entries);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  dir_size = n_entries * 12;  
 | 
				
			||||||
 | 
					  size = header_size + dir_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  size += ALIGN_VALUE (strlen (module->name) + 1, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (e = module->entries; e; e = e->next)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      GIrNode *node = e->data;
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      size += g_ir_node_get_full_size (node);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n", 
 | 
				
			||||||
 | 
						  size, header_size, dir_size, size - header_size - dir_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  data = g_malloc0 (size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* fill in header */
 | 
				
			||||||
 | 
					  header = (Header *)data;
 | 
				
			||||||
 | 
					  memcpy (header, G_IR_MAGIC, 16);
 | 
				
			||||||
 | 
					  header->major_version = 1;
 | 
				
			||||||
 | 
					  header->minor_version = 0;
 | 
				
			||||||
 | 
					  header->reserved = 0;
 | 
				
			||||||
 | 
					  header->n_entries = n_entries;
 | 
				
			||||||
 | 
					  header->n_local_entries = n_local_entries;
 | 
				
			||||||
 | 
					  header->n_annotations = 0;
 | 
				
			||||||
 | 
					  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;
 | 
				
			||||||
 | 
					  header->callback_blob_size = 12;
 | 
				
			||||||
 | 
					  header->signal_blob_size = 12;
 | 
				
			||||||
 | 
					  header->vfunc_blob_size = 16;
 | 
				
			||||||
 | 
					  header->arg_blob_size = 12;
 | 
				
			||||||
 | 
					  header->property_blob_size = 12;
 | 
				
			||||||
 | 
					  header->field_blob_size = 12;
 | 
				
			||||||
 | 
					  header->value_blob_size = 12;
 | 
				
			||||||
 | 
					  header->constant_blob_size = 20;
 | 
				
			||||||
 | 
					  header->error_domain_blob_size = 16;
 | 
				
			||||||
 | 
					  header->annotation_blob_size = 12;
 | 
				
			||||||
 | 
					  header->signature_blob_size = 8;
 | 
				
			||||||
 | 
					  header->enum_blob_size = 20;
 | 
				
			||||||
 | 
					  header->struct_blob_size = 20;
 | 
				
			||||||
 | 
					  header->object_blob_size = 32;
 | 
				
			||||||
 | 
					  header->interface_blob_size = 28;
 | 
				
			||||||
 | 
					  header->union_blob_size = 28;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* fill in directory and content */
 | 
				
			||||||
 | 
					  entry = (DirEntry *)&data[header->directory];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  offset2 = header->directory + dir_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (e = module->entries, i = 0; e; e = e->next, i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      GIrNode *node = e->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (strchr (node->name, '.'))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
						  g_error ("Names may not contain '.'");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* we picked up implicit xref nodes, start over */
 | 
				
			||||||
 | 
					      if (i == n_entries)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						  g_message ("Found implicit cross references, starting over");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_hash_table_destroy (strings);
 | 
				
			||||||
 | 
						  g_hash_table_destroy (types);
 | 
				
			||||||
 | 
						  strings = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_free (data);
 | 
				
			||||||
 | 
						  data = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  goto restart;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					      offset = offset2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (node->type == G_IR_NODE_XREF)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						  entry->blob_type = 0;
 | 
				
			||||||
 | 
						  entry->local = FALSE;
 | 
				
			||||||
 | 
						  entry->offset = write_string (((GIrNodeXRef*)node)->namespace, strings, data, &offset2);
 | 
				
			||||||
 | 
						  entry->name = write_string (node->name, strings, data, &offset2);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						  old_offset = offset;
 | 
				
			||||||
 | 
						  offset2 = offset + g_ir_node_get_size (node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  entry->blob_type = node->type;
 | 
				
			||||||
 | 
						  entry->local = TRUE;
 | 
				
			||||||
 | 
						  entry->offset = offset;
 | 
				
			||||||
 | 
						  entry->name = write_string (node->name, strings, data, &offset2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_ir_node_build_metadata (node, module, modules, 
 | 
				
			||||||
 | 
									     strings, types, data, &offset, &offset2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  if (offset2 > old_offset + g_ir_node_get_full_size (node))
 | 
				
			||||||
 | 
						    g_error ("left a hole of %d bytes\n", offset2 - old_offset - g_ir_node_get_full_size (node));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      entry++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  dump_stats ();
 | 
				
			||||||
 | 
					  g_hash_table_destroy (strings);
 | 
				
			||||||
 | 
					  g_hash_table_destroy (types);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  header->annotations = offset2;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  g_message ("reallocating to %d bytes", offset2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  metadata = g_realloc (data, offset2);
 | 
				
			||||||
 | 
					  length = header->size = offset2;
 | 
				
			||||||
 | 
					  return g_typelib_new_from_memory (metadata, length);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										48
									
								
								girmodule.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								girmodule.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					/* GObject introspection: Parsed IDL
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2005 Matthias Clasen
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 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 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.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __G_IR_MODULE_H__
 | 
				
			||||||
 | 
					#define __G_IR_MODULE_H__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <glib.h>
 | 
				
			||||||
 | 
					#include "gtypelib.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					G_BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct _GIrModule GIrModule;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrModule
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  gchar *name;
 | 
				
			||||||
 | 
					  gchar *shared_library;
 | 
				
			||||||
 | 
					  GList *entries;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GIrModule *g_ir_module_new            (const gchar *name,
 | 
				
			||||||
 | 
									       const gchar *module_filename);
 | 
				
			||||||
 | 
					void       g_ir_module_free           (GIrModule  *module);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GTypelib * g_ir_module_build_metadata (GIrModule  *module,
 | 
				
			||||||
 | 
									       GList       *modules);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					G_END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  /* __G_IR_MODULE_H__ */
 | 
				
			||||||
							
								
								
									
										334
									
								
								girnode.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										334
									
								
								girnode.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,334 @@
 | 
				
			|||||||
 | 
					/* GObject introspection: Parsed GIR
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2005 Matthias Clasen
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 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 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.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __G_IR_NODE_H__
 | 
				
			||||||
 | 
					#define __G_IR_NODE_H__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <glib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					G_BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct _GIrNode GIrNode; 
 | 
				
			||||||
 | 
					typedef struct _GIrNodeFunction GIrNodeFunction;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeParam GIrNodeParam;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeType GIrNodeType;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeInterface GIrNodeInterface;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeSignal GIrNodeSignal;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeProperty GIrNodeProperty;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeVFunc GIrNodeVFunc;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeField GIrNodeField;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeValue GIrNodeValue;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeEnum GIrNodeEnum;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeBoxed GIrNodeBoxed;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeStruct GIrNodeStruct;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeConstant GIrNodeConstant;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeErrorDomain GIrNodeErrorDomain;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeXRef GIrNodeXRef;
 | 
				
			||||||
 | 
					typedef struct _GIrNodeUnion GIrNodeUnion;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef enum 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  G_IR_NODE_INVALID      =  0,
 | 
				
			||||||
 | 
					  G_IR_NODE_FUNCTION     =  1,
 | 
				
			||||||
 | 
					  G_IR_NODE_CALLBACK     =  2,
 | 
				
			||||||
 | 
					  G_IR_NODE_STRUCT       =  3,
 | 
				
			||||||
 | 
					  G_IR_NODE_BOXED        =  4,
 | 
				
			||||||
 | 
					  G_IR_NODE_ENUM         =  5,
 | 
				
			||||||
 | 
					  G_IR_NODE_FLAGS        =  6, 
 | 
				
			||||||
 | 
					  G_IR_NODE_OBJECT       =  7,
 | 
				
			||||||
 | 
					  G_IR_NODE_INTERFACE    =  8,
 | 
				
			||||||
 | 
					  G_IR_NODE_CONSTANT     =  9,
 | 
				
			||||||
 | 
					  G_IR_NODE_ERROR_DOMAIN = 10,
 | 
				
			||||||
 | 
					  G_IR_NODE_UNION        = 11,
 | 
				
			||||||
 | 
					  G_IR_NODE_PARAM        = 12,
 | 
				
			||||||
 | 
					  G_IR_NODE_TYPE         = 13,
 | 
				
			||||||
 | 
					  G_IR_NODE_PROPERTY     = 14,
 | 
				
			||||||
 | 
					  G_IR_NODE_SIGNAL       = 15,
 | 
				
			||||||
 | 
					  G_IR_NODE_VALUE        = 16,
 | 
				
			||||||
 | 
					  G_IR_NODE_VFUNC        = 17,
 | 
				
			||||||
 | 
					  G_IR_NODE_FIELD        = 18,
 | 
				
			||||||
 | 
					  G_IR_NODE_XREF         = 19
 | 
				
			||||||
 | 
					} GIrNodeTypeId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNode
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNodeTypeId type;
 | 
				
			||||||
 | 
					  gchar *name;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeXRef
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *namespace;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeFunction
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean is_method;
 | 
				
			||||||
 | 
					  gboolean is_setter;
 | 
				
			||||||
 | 
					  gboolean is_getter;
 | 
				
			||||||
 | 
					  gboolean is_constructor;
 | 
				
			||||||
 | 
					  gboolean wraps_vfunc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *symbol;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  GIrNodeParam *result;
 | 
				
			||||||
 | 
					  GList *parameters;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeType 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean is_pointer;
 | 
				
			||||||
 | 
					  gboolean is_basic;
 | 
				
			||||||
 | 
					  gboolean is_array;
 | 
				
			||||||
 | 
					  gboolean is_glist;
 | 
				
			||||||
 | 
					  gboolean is_gslist;
 | 
				
			||||||
 | 
					  gboolean is_ghashtable;
 | 
				
			||||||
 | 
					  gboolean is_interface;
 | 
				
			||||||
 | 
					  gboolean is_error;
 | 
				
			||||||
 | 
					  gint tag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *unparsed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean zero_terminated;
 | 
				
			||||||
 | 
					  gboolean has_length;
 | 
				
			||||||
 | 
					  gint length;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GIrNodeType *parameter_type1;
 | 
				
			||||||
 | 
					  GIrNodeType *parameter_type2;  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *interface;
 | 
				
			||||||
 | 
					  gchar **errors;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeParam 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean in;
 | 
				
			||||||
 | 
					  gboolean out;
 | 
				
			||||||
 | 
					  gboolean dipper;
 | 
				
			||||||
 | 
					  gboolean optional;
 | 
				
			||||||
 | 
					  gboolean retval;
 | 
				
			||||||
 | 
					  gboolean null_ok;
 | 
				
			||||||
 | 
					  gboolean transfer;
 | 
				
			||||||
 | 
					  gboolean shallow_transfer;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GIrNodeType *type;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeProperty
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *name;
 | 
				
			||||||
 | 
					  gboolean readable;
 | 
				
			||||||
 | 
					  gboolean writable;
 | 
				
			||||||
 | 
					  gboolean construct;
 | 
				
			||||||
 | 
					  gboolean construct_only;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GIrNodeType *type;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeSignal 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean run_first;
 | 
				
			||||||
 | 
					  gboolean run_last;
 | 
				
			||||||
 | 
					  gboolean run_cleanup;
 | 
				
			||||||
 | 
					  gboolean no_recurse;
 | 
				
			||||||
 | 
					  gboolean detailed;
 | 
				
			||||||
 | 
					  gboolean action;
 | 
				
			||||||
 | 
					  gboolean no_hooks;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  gboolean has_class_closure;
 | 
				
			||||||
 | 
					  gboolean true_stops_emit;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  gint class_closure;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GList *parameters;
 | 
				
			||||||
 | 
					  GIrNodeParam *result;    
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeVFunc 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean must_chain_up;
 | 
				
			||||||
 | 
					  gboolean must_be_implemented;
 | 
				
			||||||
 | 
					  gboolean must_not_be_implemented;
 | 
				
			||||||
 | 
					  gboolean is_class_closure;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GList *parameters;
 | 
				
			||||||
 | 
					  GIrNodeParam *result;      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gint offset;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeField
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean readable;
 | 
				
			||||||
 | 
					  gboolean writable;
 | 
				
			||||||
 | 
					  gint bits;
 | 
				
			||||||
 | 
					  gint offset;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GIrNodeType *type;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeInterface
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *gtype_name;
 | 
				
			||||||
 | 
					  gchar *gtype_init;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *parent;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GList *interfaces;
 | 
				
			||||||
 | 
					  GList *prerequisites;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  GList *members;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeValue
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  guint32 value;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeConstant
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  GIrNodeType *type;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  gchar *value;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeEnum
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *gtype_name;
 | 
				
			||||||
 | 
					  gchar *gtype_init;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  GList *values;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeBoxed
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *gtype_name;
 | 
				
			||||||
 | 
					  gchar *gtype_init;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GList *members;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeStruct
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GList *members;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeUnion
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  GList *members;
 | 
				
			||||||
 | 
					  GList *discriminators;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gchar *gtype_name;
 | 
				
			||||||
 | 
					  gchar *gtype_init;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gint discriminator_offset;
 | 
				
			||||||
 | 
					  GIrNodeType *discriminator_type;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _GIrNodeErrorDomain
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIrNode node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gboolean deprecated;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  gchar *name;
 | 
				
			||||||
 | 
					  gchar *getquark;
 | 
				
			||||||
 | 
					  gchar *codes;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GIrNode * g_ir_node_new             (GIrNodeTypeId type);
 | 
				
			||||||
 | 
					void      g_ir_node_free            (GIrNode    *node);
 | 
				
			||||||
 | 
					guint32   g_ir_node_get_size        (GIrNode    *node);
 | 
				
			||||||
 | 
					guint32   g_ir_node_get_full_size   (GIrNode    *node);
 | 
				
			||||||
 | 
					void      g_ir_node_build_metadata  (GIrNode    *node,
 | 
				
			||||||
 | 
									      GIrModule  *module,
 | 
				
			||||||
 | 
									      GList       *modules,
 | 
				
			||||||
 | 
					                                      GHashTable  *strings,
 | 
				
			||||||
 | 
					                                      GHashTable  *types,
 | 
				
			||||||
 | 
									      guchar      *data,
 | 
				
			||||||
 | 
									      guint32     *offset,
 | 
				
			||||||
 | 
					                                      guint32     *offset2);
 | 
				
			||||||
 | 
					int       g_ir_node_cmp             (GIrNode    *node,
 | 
				
			||||||
 | 
									      GIrNode    *other);
 | 
				
			||||||
 | 
					gboolean  g_ir_node_can_have_member (GIrNode    *node);
 | 
				
			||||||
 | 
					void      g_ir_node_add_member      (GIrNode         *node,
 | 
				
			||||||
 | 
									      GIrNodeFunction *member);
 | 
				
			||||||
 | 
					guint32   write_string               (const gchar *str,
 | 
				
			||||||
 | 
									      GHashTable  *strings, 
 | 
				
			||||||
 | 
									      guchar      *data,
 | 
				
			||||||
 | 
									      guint32     *offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const gchar * g_ir_node_param_direction_string (GIrNodeParam * node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					G_END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  /* __G_IR_NODE_H__ */
 | 
				
			||||||
							
								
								
									
										2314
									
								
								girparser.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2314
									
								
								girparser.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										38
									
								
								girparser.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								girparser.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					/* GObject introspection: A parser for the XML GIR format
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2005 Matthias Clasen
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 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 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.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __G_GIR_PARSER_H__
 | 
				
			||||||
 | 
					#define __G_GIR_PARSER_H__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <glib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					G_BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GList *g_ir_parse_string (const gchar  *buffer, 
 | 
				
			||||||
 | 
								  gssize        length,
 | 
				
			||||||
 | 
								  GError      **error);
 | 
				
			||||||
 | 
					GList *g_ir_parse_file   (const gchar  *filename,
 | 
				
			||||||
 | 
								  GError      **error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					G_END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  /* __G_GIR_PARSER_H__ */
 | 
				
			||||||
							
								
								
									
										532
									
								
								girwriter.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										532
									
								
								girwriter.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,532 @@
 | 
				
			|||||||
 | 
					/* 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_IR_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_IR_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_s =
 | 
				
			||||||
 | 
					    g_string_new (g_markup_printf_escaped ("<return-type type=\"%s\"",
 | 
				
			||||||
 | 
								     node->result->type->unparsed));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (node->result->transfer)
 | 
				
			||||||
 | 
					    g_string_append (markup_s, g_markup_printf_escaped (" transfer=\"full\"/>\n"));
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    g_string_append (markup_s, "/>\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_writer_write (writer, markup_s->str);
 | 
				
			||||||
 | 
					  g_string_free (markup_s, TRUE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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;
 | 
				
			||||||
 | 
						  const gchar *direction = g_idl_node_param_direction_string (param);
 | 
				
			||||||
 | 
						  
 | 
				
			||||||
 | 
						  markup_s = g_string_new ("<parameter");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_string_append_printf (markup_s, " name=\"%s\"", param->node.name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_string_append (markup_s,
 | 
				
			||||||
 | 
								   g_markup_printf_escaped (" type=\"%s\"",
 | 
				
			||||||
 | 
											    param->type->unparsed));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  if (param->transfer)
 | 
				
			||||||
 | 
						    g_string_append (markup_s,
 | 
				
			||||||
 | 
								   g_markup_printf_escaped (" transfer=\"full\""));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  if (param->null_ok)
 | 
				
			||||||
 | 
						    g_string_append (markup_s,
 | 
				
			||||||
 | 
								     g_markup_printf_escaped (" null-ok=\"1\""));
 | 
				
			||||||
 | 
						  
 | 
				
			||||||
 | 
						  if (strcmp (direction, "in") != 0)
 | 
				
			||||||
 | 
						    g_string_append (markup_s,
 | 
				
			||||||
 | 
								     g_markup_printf_escaped (" direction=\"%s\"",
 | 
				
			||||||
 | 
											      direction));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_string_append (markup_s, "/>\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  g_writer_write (writer, markup_s->str);
 | 
				
			||||||
 | 
						  g_string_free (markup_s, TRUE);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					      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_IR_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_IR_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_IR_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_IR_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_IR_NODE_OBJECT)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      g_writer_write_unindent (writer, "</object>\n");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else if (node->node.type == G_IR_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;
 | 
				
			||||||
 | 
					  GString *markup_s;
 | 
				
			||||||
 | 
					  char *markup;
 | 
				
			||||||
 | 
					  const char *tag_name = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (node->node.type == G_IR_NODE_ENUM)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      tag_name = "enum";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else if (node->node.type == G_IR_NODE_FLAGS)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      tag_name = "flags";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  markup_s = g_string_new ("<");
 | 
				
			||||||
 | 
					  g_string_append_printf (markup_s,
 | 
				
			||||||
 | 
								  "%s name=\"%s\"",
 | 
				
			||||||
 | 
								  tag_name, node->node.name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (node->gtype_name != NULL)
 | 
				
			||||||
 | 
					    g_string_append_printf (markup_s,
 | 
				
			||||||
 | 
								    g_markup_printf_escaped (" type-name=\"%s\"", node->gtype_name));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (node->gtype_init != NULL)
 | 
				
			||||||
 | 
					    g_string_append_printf (markup_s,
 | 
				
			||||||
 | 
								    g_markup_printf_escaped (" get-type=\"%s\"", node->gtype_init));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (l = node->values; l != NULL; l = l->next)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      node_generate (writer, l->data);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  markup = g_strdup_printf ("</%s>\n", tag_name);
 | 
				
			||||||
 | 
					  g_writer_write_unindent (writer, markup);
 | 
				
			||||||
 | 
					  g_free (markup);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					node_generate (GIdlWriter * writer, GIdlNode * node)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  switch (node->type)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    case G_IR_NODE_FUNCTION:
 | 
				
			||||||
 | 
					    case G_IR_NODE_CALLBACK:
 | 
				
			||||||
 | 
					      function_generate (writer, (GIdlNodeFunction *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_VFUNC:
 | 
				
			||||||
 | 
					      vfunc_generate (writer, (GIdlNodeVFunc *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_OBJECT:
 | 
				
			||||||
 | 
					    case G_IR_NODE_INTERFACE:
 | 
				
			||||||
 | 
					      interface_generate (writer, (GIdlNodeInterface *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_STRUCT:
 | 
				
			||||||
 | 
					      struct_generate (writer, (GIdlNodeStruct *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_UNION:
 | 
				
			||||||
 | 
					      union_generate (writer, (GIdlNodeUnion *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_BOXED:
 | 
				
			||||||
 | 
					      boxed_generate (writer, (GIdlNodeBoxed *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_ENUM:
 | 
				
			||||||
 | 
					    case G_IR_NODE_FLAGS:
 | 
				
			||||||
 | 
					      enum_generate (writer, (GIdlNodeEnum *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_PROPERTY:
 | 
				
			||||||
 | 
					      property_generate (writer, (GIdlNodeProperty *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_FIELD:
 | 
				
			||||||
 | 
					      field_generate (writer, (GIdlNodeField *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_SIGNAL:
 | 
				
			||||||
 | 
					      signal_generate (writer, (GIdlNodeSignal *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_VALUE:
 | 
				
			||||||
 | 
					      value_generate (writer, (GIdlNodeValue *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case G_IR_NODE_CONSTANT:
 | 
				
			||||||
 | 
					      constant_generate (writer, (GIdlNodeConstant *) node);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					      g_assert_not_reached ();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					g_writer_write_module (GIdlWriter * writer, GIdlModule * module)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GList *l;
 | 
				
			||||||
 | 
					  char *markup =
 | 
				
			||||||
 | 
					    g_markup_printf_escaped ("<namespace name=\"%s\">\n", module->name);
 | 
				
			||||||
 | 
					  g_writer_write_indent (writer, markup);
 | 
				
			||||||
 | 
					  g_free (markup);
 | 
				
			||||||
 | 
					  for (l = module->entries; l != NULL; l = l->next)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      node_generate (writer, l->data);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  g_writer_write_unindent (writer, "</namespace>\n");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					g_idl_writer_save_file (GIdlModule *module,
 | 
				
			||||||
 | 
								const gchar *filename)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GIdlWriter *writer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  writer = g_new0 (GIdlWriter, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!filename)
 | 
				
			||||||
 | 
					    writer->output = stdout;
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    writer->output = fopen (filename, "w");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_writer_write (writer, "<?xml version=\"1.0\"?>\n");
 | 
				
			||||||
 | 
					  g_writer_write_indent (writer, "<repository version=\"1.0\""
 | 
				
			||||||
 | 
								 "xmlns=\"http://www.gtk.org/introspection/core/1.0\""
 | 
				
			||||||
 | 
								 "xmlns:c=\"http://www.gtk.org/introspection/c/1.0\""
 | 
				
			||||||
 | 
								 "xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\">");
 | 
				
			||||||
 | 
					  g_writer_write_module (writer, module);
 | 
				
			||||||
 | 
					  g_writer_write_unindent (writer, "</repository>\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (filename)
 | 
				
			||||||
 | 
					    fclose (writer->output);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										26
									
								
								girwriter.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								girwriter.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					/* GObject introspection: IDL writer
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 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 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.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __G_IDL_WRITER_H__
 | 
				
			||||||
 | 
					#define __G_IDL_WRITER_H__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void g_idl_writer_save_file (GIdlModule *module, const gchar *filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  /* __G_IDL_WRITER_H__ */
 | 
				
			||||||
		Reference in New Issue
	
	Block a user