#include <string.h>
#include <glib-object.h>

/**********************************************************************/
#define BADGER_TYPE_DOMESTIC           (badger_domestic_get_type())
#define BADGER_DOMESTIC(obj)           (G_TYPE_CHECK_INSTANCE_CAST((obj), BADGER_TYPE_DOMESTIC, BadgerDomestic))
#define BADGER_IS_DOMESTIC(obj)        (G_TYPE_CHECK_INSTANCE_TYPE((obj), BADGER_TYPE_DOMESTIC))
#define BADGER_DOMESTIC_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), BADGER_TYPE_DOMESTIC, BadgerDomesticIface))

typedef struct _BadgerDomesticIface BadgerDomesticIface;
typedef struct _BadgerDomestic      BadgerDomestic;        /* dummy */

struct _BadgerDomesticIface {
    /*< private >*/
    GTypeInterface parent_class;

    /*< public >*/
    void (*bite)(BadgerDomestic *badger);
};

GType       badger_domestic_get_type           (void) G_GNUC_CONST;

/**********************************************************************/
static void badger_domestic_base_init(gpointer g_class);

GType
badger_domestic_get_type(void)
{
    static GType badger_domestic_type = 0;

    if (!badger_domestic_type) {
        static const GTypeInfo badger_domestic_info = {
            sizeof(BadgerDomesticIface),
            (GBaseInitFunc)badger_domestic_base_init,
            NULL,
            NULL,
            NULL,
            NULL,
            0,
            0,
            NULL,
            NULL,
        };

        badger_domestic_type = g_type_register_static(G_TYPE_INTERFACE,
                                                      "BadgerDomestic",
                                                      &badger_domestic_info,
                                                      0);
        g_type_interface_add_prerequisite(badger_domestic_type, G_TYPE_OBJECT);
    }

    return badger_domestic_type;
}

static void
badger_domestic_base_init(G_GNUC_UNUSED gpointer g_class)
{
    static gboolean initialized = FALSE;

    if (initialized)
        return;

    g_object_interface_install_property
        (g_class,  /* FIXME: Is this right? */
         g_param_spec_boolean("whatever", "Whatever", "Bloody whatever",
                              TRUE, G_PARAM_READWRITE));

    initialized = TRUE;
}

/**********************************************************************/
int
main(int argc, char *argv[])
{
    GType type;

    if (glib_major_version == 2 && glib_minor_version < 3) {
        g_printerr("Too old GLib.\n");
        return 1;
    }

    g_type_init();
    if (argc == 2 && !strcmp(argv[1], "ensure"))
        g_type_class_ref(G_TYPE_OBJECT);

    type = (gulong)BADGER_TYPE_DOMESTIC;
    g_printerr("BadgerDomestic type: %lu\n", type);
    g_type_default_interface_ref(type);

    return 0;
}

