#include <glib.h>
#include <glib-object.h>
-#include "girepository.h"
#include "gtypelib.h"
+#include "ginfo.h"
struct _GIBaseInfo
{
gint type;
gint ref_count;
+ GIRepository *repository;
GIBaseInfo *container;
GTypelib *typelib;
/* info creation */
GIBaseInfo *
-g_info_new (GIInfoType type,
- GIBaseInfo *container,
- GTypelib *typelib,
- guint32 offset)
+g_info_new_full (GIInfoType type,
+ GIRepository *repository,
+ GIBaseInfo *container,
+ GTypelib *typelib,
+ guint32 offset)
{
GIBaseInfo *info;
+ g_return_val_if_fail (container != NULL || repository != NULL, NULL);
+
info = g_new0 (GIBaseInfo, 1);
info->ref_count = 1;
if (container)
info->container = g_base_info_ref (container);
+ info->repository = g_object_ref (repository);
+
return info;
}
+GIBaseInfo *
+g_info_new (GIInfoType type,
+ GIBaseInfo *container,
+ GTypelib *typelib,
+ guint32 offset)
+{
+ return g_info_new_full (type, container->repository, container, typelib, offset);
+}
+
static GIBaseInfo *
-g_info_from_entry (GTypelib *typelib,
+g_info_from_entry (GIRepository *repository,
+ GTypelib *typelib,
guint16 index)
{
GIBaseInfo *result;
DirEntry *entry = g_typelib_get_dir_entry (typelib, index);
-
+
if (entry->local)
- result = g_info_new (entry->blob_type, NULL, typelib, entry->offset);
- else
+ result = g_info_new_full (entry->blob_type, repository, NULL, typelib, entry->offset);
+ else
{
const gchar *namespace = g_typelib_get_string (typelib, entry->offset);
const gchar *name = g_typelib_get_string (typelib, entry->name);
-
- GIRepository *repository = g_irepository_get_default ();
-
+
result = g_irepository_find_by_name (repository, namespace, name);
if (result == NULL)
{
GIUnresolvedInfo *unresolved;
unresolved = g_new0 (GIUnresolvedInfo, 1);
-
+
unresolved->type = GI_INFO_TYPE_UNRESOLVED;
unresolved->ref_count = 1;
unresolved->container = NULL;
unresolved->name = name;
unresolved->namespace = namespace;
-
+
return (GIBaseInfo*)unresolved;
}
return result;
if (info->container)
g_base_info_unref (info->container);
+ g_object_unref (info->repository);
+
g_free (info);
}
}
InterfaceTypeBlob *blob = (InterfaceTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_INTERFACE)
- return g_info_from_entry (base->typelib, blob->interface);
+ return g_info_from_entry (base->repository, base->typelib, blob->interface);
}
return NULL;
ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_ERROR)
- return (GIErrorDomainInfo *) g_info_from_entry (base->typelib,
+ return (GIErrorDomainInfo *) g_info_from_entry (base->repository,
+ base->typelib,
blob->domains[n]);
}
GIBaseInfo *base = (GIBaseInfo *)info;
ErrorDomainBlob *blob = (ErrorDomainBlob *)&base->typelib->data[base->offset];
- return (GIInterfaceInfo *) g_info_from_entry (base->typelib, blob->error_codes);
+ return (GIInterfaceInfo *) g_info_from_entry (base->repository,
+ base->typelib, blob->error_codes);
}
ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
if (blob->parent)
- return (GIObjectInfo *) g_info_from_entry (base->typelib, blob->parent);
+ return (GIObjectInfo *) g_info_from_entry (base->repository,
+ base->typelib, blob->parent);
else
return NULL;
}
GIBaseInfo *base = (GIBaseInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
- return (GIInterfaceInfo *) g_info_from_entry (base->typelib, blob->interfaces[n]);
+ return (GIInterfaceInfo *) g_info_from_entry (base->repository,
+ base->typelib, blob->interfaces[n]);
}
gint
GIBaseInfo *base = (GIBaseInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
- return g_info_from_entry (base->typelib, blob->prerequisites[n]);
+ return g_info_from_entry (base->repository,
+ base->typelib, blob->prerequisites[n]);
}
--- /dev/null
+/* GObject introspection: Typelib info functions
+ *
+ * Copyright (C) 2008 Red Hat, Inc
+ *
+ * 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 __GIRINFO_H__
+#define __GIRINFO_H__
+
+#include "girepository.h"
+
+G_BEGIN_DECLS
+
+GITypeInfo *
+g_type_info_new (GIBaseInfo *container,
+ GTypelib *typelib,
+ guint32 offset);
+
+GIBaseInfo *
+g_info_new_full (GIInfoType type,
+ GIRepository *repository,
+ GIBaseInfo *container,
+ GTypelib *typelib,
+ guint32 offset);
+
+G_END_DECLS
+
+#endif
#include <gmodule.h>
#include "girepository.h"
#include "gtypelib.h"
+#include "ginfo.h"
#include "config.h"
else
key = build_typelib_key (namespace, source);
+ g_printerr ("loaded: %s\n", key);
g_hash_table_insert (repository->priv->typelibs, key, (void *)typelib);
}
typedef struct
{
+ GIRepository *repo;
gint index;
const gchar *name;
const gchar *type;
if (index != 0)
{
entry = g_typelib_get_dir_entry (typelib, index);
- iface_data->iface = g_info_new (entry->blob_type, NULL,
- typelib, entry->offset);
+ iface_data->iface = g_info_new_full (entry->blob_type,
+ iface_data->repo,
+ NULL, typelib, entry->offset);
}
}
repository = get_repository (repository);
+ data.repo = repository;
data.name = NULL;
data.type = NULL;
data.index = index + 1;
repository = get_repository (repository);
+ data.repo = repository;
data.name = NULL;
data.type = g_type_name (type);
data.index = -1;
repository = get_repository (repository);
+ data.repo = repository;
data.name = name;
data.type = NULL;
data.index = -1;