From a5d95894a4fb196c5139f94872560cfda6f3184e Mon Sep 17 00:00:00 2001 From: Not Zed Date: Fri, 14 Jan 2005 09:50:12 +0000 Subject: [PATCH] reverted rodrigo's change. We never build ESexp as a GObject anymore (it 2005-01-14 Not Zed * libedataserver/e-sexp.c: reverted rodrigo's change. We never build ESexp as a GObject anymore (it is used by camel). --- ChangeLog | 5 +++++ libedataserver/e-sexp.c | 38 ++++++++++++++++++++++++++++++++++++-- libedataserver/e-sexp.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6919b5..81df1b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-01-14 Not Zed + + * libedataserver/e-sexp.c: reverted rodrigo's change. We never + build ESexp as a GObject anymore (it is used by camel). + 2005-01-12 Rodrigo Moya * libedataserver/e-categories.[ch] (e_categories_exist): new function. diff --git a/libedataserver/e-sexp.c b/libedataserver/e-sexp.c index 420aab8..724859f 100644 --- a/libedataserver/e-sexp.c +++ b/libedataserver/e-sexp.c @@ -105,7 +105,9 @@ static struct _ESExpTerm * parse_value(ESExp *f); static void parse_dump_term(struct _ESExpTerm *t, int depth); +#ifdef E_SEXP_IS_G_OBJECT static GObjectClass *parent_class; +#endif static GScannerConfig scanner_config = { @@ -1030,6 +1032,7 @@ parse_list(ESExp *f, int gotbrace) static void e_sexp_finalise(void *); +#ifdef E_SEXP_IS_G_OBJECT static void e_sexp_class_init (ESExpClass *klass) { @@ -1037,8 +1040,9 @@ e_sexp_class_init (ESExpClass *klass) object_class->finalize = e_sexp_finalise; - parent_class = g_type_class_peek_parent (klass); + parent_class = g_type_class_ref (g_object_get_type ()); } +#endif /* 'builtin' functions */ static struct { @@ -1086,7 +1090,9 @@ e_sexp_finalise(void *o) g_scanner_scope_foreach_symbol(s->scanner, 0, free_symbol, 0); g_scanner_destroy(s->scanner); +#ifdef E_SEXP_IS_G_OBJECT G_OBJECT_CLASS (parent_class)->finalize (o); +#endif } static void @@ -1107,8 +1113,12 @@ e_sexp_init (ESExp *s) } } +#ifndef E_SEXP_IS_G_OBJECT + s->refcount = 1; +#endif } +#ifdef E_SEXP_IS_G_OBJECT GType e_sexp_get_type (void) { @@ -1132,15 +1142,39 @@ e_sexp_get_type (void) return type; } +#endif ESExp * e_sexp_new (void) { - ESExp *f = (ESExp *) g_object_new (E_TYPE_SEXP, NULL); +#ifdef E_SEXP_IS_G_OBJECT + ESExp *f = (ESexp *) g_object_new (E_TYPE_SEXP, NULL); +#else + ESExp *f = g_malloc0 (sizeof (ESExp)); + e_sexp_init (f); +#endif return f; } +#ifndef E_SEXP_IS_G_OBJECT +void +e_sexp_ref (ESExp *f) +{ + f->refcount++; +} + +void +e_sexp_unref (ESExp *f) +{ + f->refcount--; + if (f->refcount == 0) { + e_sexp_finalise(f); + g_free(f); + } +} +#endif + void e_sexp_add_function(ESExp *f, int scope, char *name, ESExpFunc *func, void *data) { diff --git a/libedataserver/e-sexp.h b/libedataserver/e-sexp.h index 7e2129b..b472d37 100644 --- a/libedataserver/e-sexp.h +++ b/libedataserver/e-sexp.h @@ -8,16 +8,29 @@ #include #include +/* Don't define E_SEXP_IS_G_OBJECT as this object is now used by camel */ + +#ifdef E_SEXP_IS_G_OBJECT #include +#endif G_BEGIN_DECLS +#ifdef E_SEXP_IS_G_OBJECT #define E_TYPE_SEXP (e_sexp_get_type ()) #define E_SEXP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SEXP, ESExp)) #define E_SEXP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SEXP, ESExpClass)) #define IS_E_SEXP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SEXP)) #define IS_E_SEXP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SEXP)) #define E_SEXP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_SEXP, ESExpClass)) +#else +#define E_TYPE_SEXP (0) +#define E_SEXP(obj) ((struct _ESExp *) (obj)) +#define E_SEXP_CLASS(klass) ((struct _ESExpClass *) (klass)) +#define IS_E_SEXP(obj) (1) +#define IS_E_SEXP_CLASS(obj) (1) +#define E_SEXP_GET_CLASS(obj) (NULL) +#endif typedef struct _ESExp ESExp; typedef struct _ESExpClass ESExpClass; @@ -93,7 +106,11 @@ struct _ESExpTerm { struct _ESExp { +#ifdef E_SEXP_IS_G_OBJECT GObject parent_object; +#else + int refcount; +#endif GScanner *scanner; /* for parsing text version */ ESExpTerm *tree; /* root of expression tree */ @@ -108,13 +125,24 @@ struct _ESExp { }; struct _ESExpClass { +#ifdef E_SEXP_IS_G_OBJECT GObjectClass parent_class; +#else + int dummy; +#endif }; +#ifdef E_SEXP_IS_G_OBJECT GType e_sexp_get_type (void); +#endif ESExp *e_sexp_new (void); +#ifdef E_SEXP_IS_G_OBJECT #define e_sexp_ref(f) g_object_ref (f) #define e_sexp_unref(f) g_object_unref (f) +#else +void e_sexp_ref (ESExp *f); +void e_sexp_unref (ESExp *f); +#endif void e_sexp_add_function (ESExp *f, int scope, char *name, ESExpFunc *func, void *data); void e_sexp_add_ifunction (ESExp *f, int scope, char *name, ESExpIFunc *func, void *data); void e_sexp_add_variable (ESExp *f, int scope, char *name, ESExpTerm *value); -- 2.7.4