serializable: Remove completely
This commit is contained in:
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
|
|
||||||
* Copyright (C) 2008-2010 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION:eek-serializable
|
|
||||||
* @short_description: Interface which provides object serialization
|
|
||||||
* into #GVariant
|
|
||||||
*
|
|
||||||
* The #EekSerializableIface interface defines serialize/deserialize
|
|
||||||
* method.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "eek-serializable.h"
|
|
||||||
|
|
||||||
GType
|
|
||||||
eek_serializable_get_type (void)
|
|
||||||
{
|
|
||||||
static GType iface_type = 0;
|
|
||||||
if (iface_type == 0) {
|
|
||||||
static GTypeInfo info = {
|
|
||||||
.class_size = sizeof (EekSerializableIface)
|
|
||||||
};
|
|
||||||
iface_type = g_type_register_static (G_TYPE_INTERFACE,
|
|
||||||
"EekSerializable",
|
|
||||||
&info, 0);
|
|
||||||
}
|
|
||||||
return iface_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
GVariant *
|
|
||||||
eek_serializable_serialize (EekSerializable *object)
|
|
||||||
{
|
|
||||||
GVariantBuilder builder;
|
|
||||||
|
|
||||||
g_return_val_if_fail (EEK_IS_SERIALIZABLE (object), FALSE);
|
|
||||||
|
|
||||||
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
|
|
||||||
g_variant_builder_add (&builder, "s", g_type_name (G_OBJECT_TYPE (object)));
|
|
||||||
EEK_SERIALIZABLE_GET_IFACE (object)->serialize (object, &builder);
|
|
||||||
|
|
||||||
return g_variant_builder_end (&builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
EekSerializable *
|
|
||||||
eek_serializable_deserialize (GVariant *variant)
|
|
||||||
{
|
|
||||||
gchar *type_name = NULL;
|
|
||||||
GType type;
|
|
||||||
EekSerializable *object;
|
|
||||||
gsize index = 0;
|
|
||||||
|
|
||||||
g_return_val_if_fail (variant != NULL, NULL);
|
|
||||||
|
|
||||||
g_variant_get_child (variant, index++, "&s", &type_name);
|
|
||||||
type = g_type_from_name (type_name);
|
|
||||||
|
|
||||||
g_return_val_if_fail (g_type_is_a (type, EEK_TYPE_SERIALIZABLE), NULL);
|
|
||||||
|
|
||||||
object = g_object_new (type, NULL);
|
|
||||||
|
|
||||||
index = EEK_SERIALIZABLE_GET_IFACE (object)->deserialize (object,
|
|
||||||
variant,
|
|
||||||
index);
|
|
||||||
if (index < 0) {
|
|
||||||
g_object_unref (object);
|
|
||||||
g_return_val_if_reached (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Daiki Ueno <ueno@unixuser.org>
|
|
||||||
* Copyright (C) 2011 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(__EEK_H_INSIDE__) && !defined(EEK_COMPILATION)
|
|
||||||
#error "Only <eek/eek.h> can be included directly."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EEK_SERIALIZABLE_H
|
|
||||||
#define EEK_SERIALIZABLE_H 1
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define EEK_TYPE_SERIALIZABLE (eek_serializable_get_type())
|
|
||||||
#define EEK_SERIALIZABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_SERIALIZABLE, EekSerializable))
|
|
||||||
#define EEK_IS_SERIALIZABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_SERIALIZABLE))
|
|
||||||
#define EEK_SERIALIZABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EEK_TYPE_SERIALIZABLE, EekSerializableIface))
|
|
||||||
|
|
||||||
typedef struct _EekSerializable EekSerializable;
|
|
||||||
typedef struct _EekSerializableIface EekSerializableIface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EekSerializableIface:
|
|
||||||
*
|
|
||||||
* @serialize: virtual function for serializing object into #GVariant
|
|
||||||
* @deserialize: virtual function for deserializing object from #GVariant
|
|
||||||
*/
|
|
||||||
struct _EekSerializableIface
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GTypeInterface parent_iface;
|
|
||||||
|
|
||||||
void (* serialize) (EekSerializable *object,
|
|
||||||
GVariantBuilder *builder);
|
|
||||||
gsize (* deserialize) (EekSerializable *object,
|
|
||||||
GVariant *variant,
|
|
||||||
gsize index);
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
/* padding */
|
|
||||||
gpointer pdummy[24];
|
|
||||||
};
|
|
||||||
|
|
||||||
GType eek_serializable_get_type (void);
|
|
||||||
|
|
||||||
GVariant *eek_serializable_serialize (EekSerializable *object);
|
|
||||||
EekSerializable *eek_serializable_deserialize (GVariant *variant);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
#endif /* EEK_SERIALIZABLE_H */
|
|
||||||
@ -26,7 +26,6 @@
|
|||||||
#include "eek-section.h"
|
#include "eek-section.h"
|
||||||
#include "eek-layout.h"
|
#include "eek-layout.h"
|
||||||
#include "eek-keysym.h"
|
#include "eek-keysym.h"
|
||||||
#include "eek-serializable.h"
|
|
||||||
|
|
||||||
void eek_init (void);
|
void eek_init (void);
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,6 @@ sources = [
|
|||||||
'../eek/eek-layout.c',
|
'../eek/eek-layout.c',
|
||||||
'../eek/eek-renderer.c',
|
'../eek/eek-renderer.c',
|
||||||
'../eek/eek-section.c',
|
'../eek/eek-section.c',
|
||||||
'../eek/eek-serializable.c',
|
|
||||||
'../eek/eek-types.c',
|
'../eek/eek-types.c',
|
||||||
'../eek/eek-xml-layout.c',
|
'../eek/eek-xml-layout.c',
|
||||||
'../eek/layersurface.c',
|
'../eek/layersurface.c',
|
||||||
|
|||||||
Reference in New Issue
Block a user