1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 * GObject introspection: Property implementation
4 * Copyright (C) 2005 Matthias Clasen
5 * Copyright (C) 2008,2009 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 #include <girepository.h>
26 #include "girepository-private.h"
27 #include "gitypelib-internal.h"
30 * SECTION:gipropertyinfo
31 * @Short_description: Struct representing a property
32 * @Title: GIPropertyInfo
34 * GIPropertyInfo represents a property. A property belongs to
35 * either a #GIObjectInfo or a #GIInterfaceInfo.
37 * <refsect1 id="gi-gipropertyinfo.struct-hierarchy" role="struct_hierarchy">
38 * <title role="struct_hierarchy.title">Struct hierarchy</title>
40 * <link linkend="gi-GIBaseInfo">GIBaseInfo</link>
47 * g_property_info_get_flags:
48 * @info: a #GIPropertyInfo
50 * Obtain the flags for this property info. See #GParamFags for
51 * more information about possible flag values.
56 g_property_info_get_flags (GIPropertyInfo *info)
59 GIRealInfo *rinfo = (GIRealInfo *)info;
62 g_return_val_if_fail (info != NULL, 0);
63 g_return_val_if_fail (GI_IS_PROPERTY_INFO (info), 0);
65 blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];
70 flags = flags | G_PARAM_READABLE;
73 flags = flags | G_PARAM_WRITABLE;
76 flags = flags | G_PARAM_CONSTRUCT;
78 if (blob->construct_only)
79 flags = flags | G_PARAM_CONSTRUCT_ONLY;
85 * g_property_info_get_type:
86 * @info: a #GIPropertyInfo
88 * Obtain the type information for the property @info.
90 * Returns: (transfer full): the #GITypeInfo, free it with
91 * g_base_info_unref() when done.
94 g_property_info_get_type (GIPropertyInfo *info)
96 GIRealInfo *rinfo = (GIRealInfo *)info;
98 g_return_val_if_fail (info != NULL, NULL);
99 g_return_val_if_fail (GI_IS_PROPERTY_INFO (info), NULL);
101 return _g_type_info_new ((GIBaseInfo*)info,
103 rinfo->offset + G_STRUCT_OFFSET (PropertyBlob, type));
107 * g_property_info_get_ownership_transfer:
108 * @info: a #GIPropertyInfo
110 * Obtain the ownership transfer for this property. See #GITransfer for more
111 * information about transfer values.
113 * Returns: the transfer
116 g_property_info_get_ownership_transfer (GIPropertyInfo *info)
118 GIRealInfo *rinfo = (GIRealInfo *)info;
121 g_return_val_if_fail (info != NULL, -1);
122 g_return_val_if_fail (GI_IS_PROPERTY_INFO (info), -1);
124 blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];
126 if (blob->transfer_ownership)
127 return GI_TRANSFER_EVERYTHING;
128 else if (blob->transfer_container_ownership)
129 return GI_TRANSFER_CONTAINER;
131 return GI_TRANSFER_NOTHING;