medit/moo/mooutils/mooclosure.h

83 lines
2.5 KiB
C
Raw Normal View History

2005-06-22 11:20:32 -07:00
/*
2005-11-19 19:59:01 -08:00
* mooclosure.h
2005-06-22 11:20:32 -07:00
*
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
2005-06-22 11:20:32 -07:00
*
* 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 2 of the License, or
* (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
2005-11-19 19:59:01 -08:00
#ifndef __MOO_CLOSURE_H__
#define __MOO_CLOSURE_H__
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
#include <glib-object.h>
2005-06-22 11:20:32 -07:00
G_BEGIN_DECLS
2005-11-19 19:59:01 -08:00
#define MOO_TYPE_CLOSURE (moo_closure_get_type ())
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
typedef struct _MooClosure MooClosure;
typedef struct _MooObjectPtr MooObjectPtr;
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
typedef void (*MooClosureCall) (MooClosure *closure);
typedef void (*MooClosureDestroy) (MooClosure *closure);
2005-06-22 11:20:32 -07:00
struct _MooClosure
{
2005-11-19 19:59:01 -08:00
MooClosureCall call;
MooClosureDestroy destroy;
guint ref_count : 16;
guint valid : 1;
guint floating : 1;
guint in_call : 1;
2005-06-22 11:20:32 -07:00
};
2005-11-19 19:59:01 -08:00
struct _MooObjectPtr
2005-06-22 11:20:32 -07:00
{
2005-11-19 19:59:01 -08:00
GObject *target;
GWeakNotify notify;
gpointer notify_data;
2005-06-22 11:20:32 -07:00
};
2005-11-19 19:59:01 -08:00
GType moo_closure_get_type (void) G_GNUC_CONST;
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
MooClosure *moo_closure_alloc (gsize size,
MooClosureCall call,
MooClosureDestroy destroy);
#define moo_closure_new(Type__,call__,destroy__) \
((Type__*)moo_closure_alloc (sizeof(Type__), call__, destroy__))
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
MooClosure *moo_closure_ref (MooClosure *closure);
void moo_closure_unref (MooClosure *closure);
void moo_closure_sink (MooClosure *closure);
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
void moo_closure_invoke (MooClosure *closure);
void moo_closure_invalidate (MooClosure *closure);
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
#define MOO_OBJECT_PTR_GET(ptr_) ((ptr_) && (ptr_)->target ? (ptr_)->target : NULL)
MooObjectPtr *moo_object_ptr_new (GObject *object,
GWeakNotify notify,
gpointer data);
void moo_object_ptr_die (MooObjectPtr *ptr);
void moo_object_ptr_free (MooObjectPtr *ptr);
MooClosure *moo_closure_new_simple (gpointer object,
const char *signal,
GCallback callback,
GCallback proxy_func);
G_END_DECLS
2005-06-22 11:20:32 -07:00
2005-11-19 19:59:01 -08:00
#endif /* __MOO_CLOSURE_H__ */
/* kate: strip on; indent-width 4; */