1 /* gdict-private.h - Private definitions for Gdict
2  *
3  * Copyright (C) 2005  Emmanuele Bassi <ebassi@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __GDICT_PRIVATE_H__
20 #define __GDICT_PRIVATE_H__
21 
22 #ifndef GDICT_ENABLE_INTERNALS
23 #error "You are trying to access Gdict's internals outside Gdict.  The API of these internal functions is not fixed."
24 #endif
25 
26 #include <glib-object.h>
27 
28 #include "gdict-context.h"
29 
30 G_BEGIN_DECLS
31 
32 /* boilerplate code, similar to G_DEFINE_TYPE in spirit, used to define
33  * our boxed types and their ref/unref functions; you still have to
34  * implement your own ref/unref functions!
35  */
36 #define GDICT_DEFINE_BOXED_TYPE(TypeName,type_name)	\
37 \
38 static gpointer type_name##_intern_ref (gpointer self) \
39 { \
40   return type_name##_ref ((TypeName *) self); \
41 } \
42 static void type_name##_intern_unref (gpointer self) \
43 { \
44   type_name##_unref ((TypeName *) self); \
45 } \
46 \
47 GType \
48 type_name##_get_type (void) \
49 { \
50   static GType gdict_define_boxed_type = 0; \
51   if (G_UNLIKELY (gdict_define_boxed_type == 0)) \
52     gdict_define_boxed_type = g_boxed_type_register_static (#TypeName, (GBoxedCopyFunc) type_name##_intern_ref, (GBoxedFreeFunc) type_name##_intern_unref); \
53   return gdict_define_boxed_type; \
54 }
55 
56 /* Never, _ever_ access the members of these structures, unless you
57  * know what you are doing.
58  */
59 
60 struct _GdictDatabase
61 {
62   gchar *name;
63   gchar *full_name;
64 
65   guint ref_count;
66 };
67 
68 struct _GdictStrategy
69 {
70   gchar *name;
71   gchar *description;
72 
73   guint ref_count;
74 };
75 
76 struct _GdictMatch
77 {
78   gchar *database;
79   gchar *word;
80 
81   guint ref_count;
82 };
83 
84 struct _GdictDefinition
85 {
86   gint total;
87 
88   gchar *word;
89   gchar *database_name;
90   gchar *database_full;
91   gchar *definition;
92 
93   guint ref_count;
94 };
95 
96 /* constructors for these objects are private, as the world outside do
97  * not know what they hold, and accessor functions are getters only
98  */
99 GdictDatabase *   _gdict_database_new   (const gchar *name);
100 GdictStrategy *   _gdict_strategy_new   (const gchar *name);
101 GdictMatch *      _gdict_match_new      (const gchar *word);
102 GdictDefinition * _gdict_definition_new (gint         total);
103 
104 G_END_DECLS
105 
106 #endif /* __GDICT_PRIVATE_H__ */
107