* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
* for "as" (note that "s" and "v" always exist in the static array).
*
* The trickiest part of GVariantTypeInfo (and in fact, the major reason
* for "as" (note that "s" and "v" always exist in the static array).
*
* The trickiest part of GVariantTypeInfo (and in fact, the major reason
* allow for O(1) lookups of items in tuples. This is described below.
*
* 'container_class' is set to 'a' or 'r' if the GVariantTypeInfo is
* allow for O(1) lookups of items in tuples. This is described below.
*
* 'container_class' is set to 'a' or 'r' if the GVariantTypeInfo is
/* Hard-code the base types in a constant array */
static const GVariantTypeInfo g_variant_type_info_basic_table[24] = {
#define fixed_aligned(x) x, x - 1
/* Hard-code the base types in a constant array */
static const GVariantTypeInfo g_variant_type_info_basic_table[24] = {
#define fixed_aligned(x) x, x - 1
#define unaligned 0, 0
#define aligned(x) 0, x - 1
/* 'b' */ { fixed_aligned(1) }, /* boolean */
#define unaligned 0, 0
#define aligned(x) 0, x - 1
/* 'b' */ { fixed_aligned(1) }, /* boolean */
/* 'g' */ { unaligned }, /* signature string */
/* 'h' */ { fixed_aligned(4) }, /* file handle (int32) */
/* 'i' */ { fixed_aligned(4) }, /* int32 */
/* 'g' */ { unaligned }, /* signature string */
/* 'h' */ { fixed_aligned(4) }, /* file handle (int32) */
/* 'i' */ { fixed_aligned(4) }, /* int32 */
- /* 'j' */ { },
- /* 'k' */ { },
- /* 'l' */ { },
- /* 'm' */ { },
+ /* 'j' */ { not_a_type },
+ /* 'k' */ { not_a_type },
+ /* 'l' */ { not_a_type },
+ /* 'm' */ { not_a_type },
/* 'n' */ { fixed_aligned(2) }, /* int16 */
/* 'o' */ { unaligned }, /* object path string */
/* 'n' */ { fixed_aligned(2) }, /* int16 */
/* 'o' */ { unaligned }, /* object path string */
/* 's' */ { unaligned }, /* string */
/* 't' */ { fixed_aligned(8) }, /* uint64 */
/* 'u' */ { fixed_aligned(4) }, /* uint32 */
/* 'v' */ { aligned(8) }, /* variant */
/* 's' */ { unaligned }, /* string */
/* 't' */ { fixed_aligned(8) }, /* uint64 */
/* 'u' */ { fixed_aligned(4) }, /* uint32 */
/* 'v' */ { aligned(8) }, /* variant */
/* 'x' */ { fixed_aligned(8) }, /* int64 */
/* 'y' */ { fixed_aligned(1) }, /* byte */
#undef fixed_aligned
/* 'x' */ { fixed_aligned(8) }, /* int64 */
/* 'y' */ { fixed_aligned(1) }, /* byte */
#undef fixed_aligned
- * @alignment: the location to store the alignment, or %NULL
- * @fixed_size: the location to store the fixed size, or %NULL
+ * @alignment: (allow-none): the location to store the alignment, or %NULL
+ * @fixed_size: (allow-none): the location to store the fixed size, or %NULL
info->element = g_variant_type_info_get (g_variant_type_element (type));
info->container.info.alignment = info->element->alignment;
info->element = g_variant_type_info_get (g_variant_type_element (type));
info->container.info.alignment = info->element->alignment;
- * @alignment: the location to store the alignment, or %NULL
- * @fixed_size: the location to store the fixed size, or %NULL
+ * @alignment: (allow-none): the location to store the alignment, or %NULL
+ * @fixed_size: (allow-none): the location to store the fixed size, or %NULL
*
* Returns the alignment requires and fixed size (if any) for the
* element type of the array. This call is a convenience wrapper around
*
* Returns the alignment requires and fixed size (if any) for the
* element type of the array. This call is a convenience wrapper around
+
+ if (member->type_info->fixed_size)
+ member->ending_type = G_VARIANT_MEMBER_ENDING_FIXED;
+ else if (item_type == NULL)
+ member->ending_type = G_VARIANT_MEMBER_ENDING_LAST;
+ else
+ member->ending_type = G_VARIANT_MEMBER_ENDING_OFFSET;
* offsets are stored and the last item is fixed-sized too (since
* an offset is never stored for the last item).
*/
* offsets are stored and the last item is fixed-sized too (since
* an offset is never stored for the last item).
*/
/* in that case, the fixed size can be found by finding the
* start of the last item (in the usual way) and adding its
* fixed size.
/* in that case, the fixed size can be found by finding the
* start of the last item (in the usual way) and adding its
* fixed size.
tuple_allocate_members (type, &info->members, &info->n_members);
tuple_generate_table (info);
tuple_allocate_members (type, &info->members, &info->n_members);
tuple_generate_table (info);
- g_static_rec_mutex_lock (&g_variant_type_info_lock);
+ g_rec_mutex_lock (&g_variant_type_info_lock);
+
+ if (g_variant_type_info_table == NULL)
+ g_variant_type_info_table = g_hash_table_new (g_str_hash,
+ g_str_equal);
- g_static_rec_mutex_unlock (&g_variant_type_info_lock);
+ if (g_hash_table_size (g_variant_type_info_table) == 0)
+ {
+ g_hash_table_unref (g_variant_type_info_table);
+ g_variant_type_info_table = NULL;
+ }
+ g_rec_mutex_unlock (&g_variant_type_info_lock);