mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
[girepository] Move GIFieldInfo out of ginfo.ch
This commit is contained in:
parent
bbc69cefaa
commit
8d2ae7fa90
@ -5,6 +5,7 @@ girepo_HEADERS = \
|
||||
gicallableinfo.h \
|
||||
gienuminfo.h \
|
||||
gierrordomaininfo.h \
|
||||
gifieldinfo.h \
|
||||
gifunctioninfo.h \
|
||||
girepository.h \
|
||||
girffi.h \
|
||||
@ -23,6 +24,7 @@ libgirepository_1_0_la_SOURCES = \
|
||||
gicallableinfo.c \
|
||||
gienuminfo.c \
|
||||
gierrordomaininfo.c \
|
||||
gifieldinfo.c \
|
||||
gifunctioninfo.c \
|
||||
ginfo.c \
|
||||
ginvoke.c \
|
||||
|
98
gifieldinfo.c
Normal file
98
gifieldinfo.c
Normal file
@ -0,0 +1,98 @@
|
||||
/* GObject introspection: Field implementation
|
||||
*
|
||||
* Copyright (C) 2005 Matthias Clasen
|
||||
* Copyright (C) 2008,2009 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.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <girepository.h>
|
||||
#include "girepository-private.h"
|
||||
#include "gitypelib-internal.h"
|
||||
|
||||
/**
|
||||
* SECTION:gifieldinfo
|
||||
* @Short_description: Struct representing a struct or union field
|
||||
* @Title: GIFieldInfo
|
||||
*
|
||||
* A GIFieldInfo struct represents a field of a struct (see #GIStructInfo),
|
||||
* union (see #GIUnionInfo) or an object (see #GIObjectInfo). The GIFieldInfo
|
||||
* is fetched by calling g_struct_info_get_field(), g_union_info_get_field()
|
||||
* or g_object_info_get_value().
|
||||
* A field has a size, type and a struct offset asssociated and a set of flags,
|
||||
* which is currently #GI_FIELD_IS_READABLE or #GI_FIELD_IS_WRITABLE.
|
||||
*/
|
||||
|
||||
GIFieldInfoFlags
|
||||
g_field_info_get_flags (GIFieldInfo *info)
|
||||
{
|
||||
GIFieldInfoFlags flags;
|
||||
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
flags = 0;
|
||||
|
||||
if (blob->readable)
|
||||
flags = flags | GI_FIELD_IS_READABLE;
|
||||
|
||||
if (blob->writable)
|
||||
flags = flags | GI_FIELD_IS_WRITABLE;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
gint
|
||||
g_field_info_get_size (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
return blob->bits;
|
||||
}
|
||||
|
||||
gint
|
||||
g_field_info_get_offset (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
return blob->struct_offset;
|
||||
}
|
||||
|
||||
GITypeInfo *
|
||||
g_field_info_get_type (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
Header *header = (Header *)rinfo->typelib->data;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
GIRealInfo *type_info;
|
||||
|
||||
if (blob->has_embedded_type)
|
||||
{
|
||||
type_info = (GIRealInfo *) g_info_new (GI_INFO_TYPE_TYPE,
|
||||
(GIBaseInfo*)info, rinfo->typelib,
|
||||
rinfo->offset + header->field_blob_size);
|
||||
type_info->type_is_embedded = TRUE;
|
||||
}
|
||||
else
|
||||
return _g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (FieldBlob, type));
|
||||
|
||||
return (GIBaseInfo*)type_info;
|
||||
}
|
||||
|
52
gifieldinfo.h
Normal file
52
gifieldinfo.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* GObject introspection: Field and Field values
|
||||
*
|
||||
* Copyright (C) 2005 Matthias Clasen
|
||||
* Copyright (C) 2008,2009 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 __GIFIELDINFO_H__
|
||||
#define __GIFIELDINFO_H__
|
||||
|
||||
#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION)
|
||||
#error "Only <girepository.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gitypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GI_IS_FIELD_INFO(info) \
|
||||
(g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FIELD)
|
||||
|
||||
GIFieldInfoFlags g_field_info_get_flags (GIFieldInfo *info);
|
||||
gint g_field_info_get_size (GIFieldInfo *info);
|
||||
gint g_field_info_get_offset (GIFieldInfo *info);
|
||||
GITypeInfo * g_field_info_get_type (GIFieldInfo *info);
|
||||
|
||||
gboolean g_field_info_get_field (GIFieldInfo *field_info,
|
||||
gpointer mem,
|
||||
GArgument *value);
|
||||
gboolean g_field_info_set_field (GIFieldInfo *field_info,
|
||||
gpointer mem,
|
||||
const GArgument *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GIFIELDINFO_H__ */
|
||||
|
73
ginfo.c
73
ginfo.c
@ -28,79 +28,6 @@
|
||||
#include "gitypelib-internal.h"
|
||||
#include "girepository-private.h"
|
||||
|
||||
/* GIFieldInfo functions */
|
||||
|
||||
/**
|
||||
* SECTION:gifieldinfo
|
||||
* @Short_description: Struct representing a struct or union field
|
||||
* @Title: GIFieldInfo
|
||||
*
|
||||
* A GIFieldInfo struct represents a field of a struct (see #GIStructInfo),
|
||||
* union (see #GIUnionInfo) or an object (see #GIObjectInfo). The GIFieldInfo
|
||||
* is fetched by calling g_struct_info_get_field(), g_union_info_get_field()
|
||||
* or g_object_info_get_value().
|
||||
* A field has a size, type and a struct offset asssociated and a set of flags,
|
||||
* which is currently #GI_FIELD_IS_READABLE or #GI_FIELD_IS_WRITABLE.
|
||||
*/
|
||||
|
||||
GIFieldInfoFlags
|
||||
g_field_info_get_flags (GIFieldInfo *info)
|
||||
{
|
||||
GIFieldInfoFlags flags;
|
||||
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
flags = 0;
|
||||
|
||||
if (blob->readable)
|
||||
flags = flags | GI_FIELD_IS_READABLE;
|
||||
|
||||
if (blob->writable)
|
||||
flags = flags | GI_FIELD_IS_WRITABLE;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
gint
|
||||
g_field_info_get_size (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
return blob->bits;
|
||||
}
|
||||
|
||||
gint
|
||||
g_field_info_get_offset (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
return blob->struct_offset;
|
||||
}
|
||||
|
||||
GITypeInfo *
|
||||
g_field_info_get_type (GIFieldInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
Header *header = (Header *)rinfo->typelib->data;
|
||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
GIRealInfo *type_info;
|
||||
|
||||
if (blob->has_embedded_type)
|
||||
{
|
||||
type_info = (GIRealInfo *) g_info_new (GI_INFO_TYPE_TYPE,
|
||||
(GIBaseInfo*)info, rinfo->typelib,
|
||||
rinfo->offset + header->field_blob_size);
|
||||
type_info->type_is_embedded = TRUE;
|
||||
}
|
||||
else
|
||||
return _g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (FieldBlob, type));
|
||||
|
||||
return (GIBaseInfo*)type_info;
|
||||
}
|
||||
|
||||
/* GIRegisteredTypeInfo functions */
|
||||
const gchar *
|
||||
g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <gicallableinfo.h>
|
||||
#include <gienuminfo.h>
|
||||
#include <gierrordomaininfo.h>
|
||||
#include <gifieldinfo.h>
|
||||
#include <gifunctioninfo.h>
|
||||
#include <gitypeinfo.h>
|
||||
#include <gitypelib.h>
|
||||
@ -150,24 +151,6 @@ void gi_cclosure_marshal_generic (GClosure *closure,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
|
||||
/* GIFieldInfo */
|
||||
|
||||
#define GI_IS_FIELD_INFO(info) \
|
||||
(g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FIELD)
|
||||
|
||||
GIFieldInfoFlags g_field_info_get_flags (GIFieldInfo *info);
|
||||
gint g_field_info_get_size (GIFieldInfo *info);
|
||||
gint g_field_info_get_offset (GIFieldInfo *info);
|
||||
GITypeInfo * g_field_info_get_type (GIFieldInfo *info);
|
||||
|
||||
gboolean g_field_info_get_field (GIFieldInfo *field_info,
|
||||
gpointer mem,
|
||||
GArgument *value);
|
||||
gboolean g_field_info_set_field (GIFieldInfo *field_info,
|
||||
gpointer mem,
|
||||
const GArgument *value);
|
||||
|
||||
/* GIUnionInfo */
|
||||
|
||||
#define GI_IS_UNION_INFO(info) \
|
||||
|
Loading…
Reference in New Issue
Block a user