~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to sigscheme/src/global.h

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2007-04-21 03:46:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070421034609-gpcurkutp8vaysqj
Tags: 1:1.4.1-3
* Switch to dh_gtkmodules for the gtk 2.10 transition (Closes:
  #419318)
  - debian/control: Add ${misc:Depends} and remove libgtk2.0-bin on
    uim-gtk2.0.
  - debian/uim-gtk2.0.post{inst,rm}: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
 *  Filename : global.h
 
3
 *  About    : Global object handlings
 
4
 *
 
5
 *  Copyright (C) 2006 YAMAMOTO Kengo <yamaken AT bp.iij4u.or.jp>
 
6
 *  Copyright (c) 2007 SigScheme Project <uim AT freedesktop.org>
 
7
 *
 
8
 *  All rights reserved.
 
9
 *
 
10
 *  Redistribution and use in source and binary forms, with or without
 
11
 *  modification, are permitted provided that the following conditions
 
12
 *  are met:
 
13
 *
 
14
 *  1. Redistributions of source code must retain the above copyright
 
15
 *     notice, this list of conditions and the following disclaimer.
 
16
 *  2. Redistributions in binary form must reproduce the above copyright
 
17
 *     notice, this list of conditions and the following disclaimer in the
 
18
 *     documentation and/or other materials provided with the distribution.
 
19
 *  3. Neither the name of authors nor the names of its contributors
 
20
 *     may be used to endorse or promote products derived from this software
 
21
 *     without specific prior written permission.
 
22
 *
 
23
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
 
24
 *  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
25
 *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
26
 *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
 
27
 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
28
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
29
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 
30
 *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
31
 *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
32
 *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
33
 *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
34
===========================================================================*/
 
35
 
 
36
/* FIXME: SCM_WRITABLE_STATICLESS_PLATFORM is not available yet */
 
37
 
 
38
#ifndef __SCM_GLOBAL_H
 
39
#define __SCM_GLOBAL_H
 
40
 
 
41
#include <sigscheme/config.h>
 
42
 
 
43
#if (defined(__SYMBIAN32__) && !defined(EKA2))
 
44
#include <string.h>
 
45
#include <stdlib.h>
 
46
#include <e32std.h>
 
47
#elif BREW_MAJ_VER  /* FIXME: inappropriate detection method */
 
48
#include "AEEStdLib.h"
 
49
#else
 
50
#include <string.h>
 
51
#endif
 
52
 
 
53
#ifdef __cplusplus
 
54
extern "C" {
 
55
#endif
 
56
 
 
57
/*=======================================
 
58
  Macro Definitions
 
59
=======================================*/
 
60
/* Consumes sizeof(void *) per struct to suppress the extra semicolon warnings
 
61
 * by default. Disable SCM_USE_WARNING_SUPPRESSOR to minimize memory
 
62
 * consumption. */
 
63
#if SCM_USE_WARNING_SUPPRESSOR
 
64
#define SCM_GLOBAL_STRUCT_WARNING_SUPPRESSOR void *dummy
 
65
#else
 
66
#define SCM_GLOBAL_STRUCT_WARNING_SUPPRESSOR
 
67
#endif
 
68
 
 
69
#if SCM_USE_AGGREGATED_GLOBAL_VARS
 
70
#define SCM_AGGREGATED_GLOBAL_VARS_BEGIN                                     \
 
71
    /* dummy statement to prevent static prefix */                           \
 
72
    struct scm_g_dummy_aggregated_begin { int dummy; };                      \
 
73
    struct scm_g_aggregated {                                                \
 
74
        SCM_GLOBAL_STRUCT_WARNING_SUPPRESSOR
 
75
#define SCM_AGGREGATED_GLOBAL_VARS(_name)                                    \
 
76
        struct scm_g_##_name _name
 
77
#define SCM_AGGREGATED_GLOBAL_VARS_END                                       \
 
78
    }
 
79
 
 
80
#if (defined(__SYMBIAN32__) && !defined(EKA2))
 
81
/*** EXPERIMENTAL AND NOT TESTED ***/
 
82
 
 
83
#define SCM_DECLARE_AGGREGATED_GLOBAL_VARS() extern int scm_g_dummy
 
84
#define SCM_DEFINE_AGGREGATED_GLOBAL_VARS()  extern int scm_g_dummy
 
85
 
 
86
#define SCM_AGGREGATED_GLOBAL_VARS_INIT() (scm_aggregated_global_vars_init())
 
87
#define SCM_AGGREGATED_GLOBAL_VARS_FIN()  (scm_aggregated_global_vars_fin())
 
88
#define SCM_AGGREGATED_GLOBAL_VARS_INSTANCE()                                \
 
89
    ((struct scm_g_aggregated *)Dll::Tls())
 
90
 
 
91
#elif BREW_MAJ_VER  /* FIXME: inappropriate detection method */
 
92
/*** EXPERIMENTAL AND NOT TESTED ***/
 
93
 
 
94
#define SCM_DECLARE_AGGREGATED_GLOBAL_VARS() extern int scm_g_dummy
 
95
#define SCM_DEFINE_AGGREGATED_GLOBAL_VARS()  extern int scm_g_dummy
 
96
 
 
97
#define SCM_AGGREGATED_GLOBAL_VARS_INIT() (scm_aggregated_global_vars_init())
 
98
#define SCM_AGGREGATED_GLOBAL_VARS_FIN()  SCM_EMPTY_EXPR
 
99
#define SCM_AGGREGATED_GLOBAL_VARS_INSTANCE()                                \
 
100
    (&((SCM_BREW_USER_APPLET_T *)GETAPPINSTANCE())->m_scm_g_aggregated_instance)
 
101
 
 
102
#elif SCM_HAVE_WRITABLE_GLOBAL_VARS
 
103
#define SCM_DECLARE_AGGREGATED_GLOBAL_VARS()                                 \
 
104
    SCM_EXTERN(struct scm_g_aggregated scm_g_aggregated_instance)
 
105
#define SCM_DEFINE_AGGREGATED_GLOBAL_VARS()                                  \
 
106
    /* dummy statement to prevent static prefix */                           \
 
107
    struct scm_g_dummy_aggregated_define { int dummy; };                     \
 
108
    SCM_EXPORT struct scm_g_aggregated scm_g_aggregated_instance
 
109
 
 
110
#define SCM_AGGREGATED_GLOBAL_VARS_INIT() (scm_aggregated_global_vars_init())
 
111
#define SCM_AGGREGATED_GLOBAL_VARS_FIN()  SCM_EMPTY_EXPR
 
112
#define SCM_AGGREGATED_GLOBAL_VARS_INSTANCE() (scm_g_aggregated_instance)
 
113
#else
 
114
#error "This platform is not supported yet"
 
115
#endif
 
116
 
 
117
#define SCM_DEFINE_STATIC_VARS(_namespace)                                   \
 
118
    static struct scm_g_##_namespace *scm_g_instance_##_namespace(void)
 
119
 
 
120
#define SCM_GLOBAL_VARS_INIT(_namespace)   SCM_EMPTY_EXPR
 
121
#define SCM_GLOBAL_VARS_FIN(_namespace)    SCM_EMPTY_EXPR
 
122
 
 
123
#define SCM_GLOBAL_VARS_INSTANCE(_namespace) (*scm_g_instance_##_namespace())
 
124
 
 
125
#define SCM_DEFINE_GLOBAL_VARS_INSTANCE_ACCESSOR(_namespace)                 \
 
126
    SCM_EXPORT struct scm_g_##_namespace *                                   \
 
127
    scm_g_instance_##_namespace(void)                                        \
 
128
    {                                                                        \
 
129
        return &SCM_AGGREGATED_GLOBAL_VARS_INSTANCE()._namespace;            \
 
130
    }                                                                        \
 
131
    extern int scm_g_dummy_##_namespace
 
132
 
 
133
#else /* SCM_USE_AGGREGATED_GLOBAL_VARS */
 
134
 
 
135
#define SCM_DECLARE_AGGREGATED_GLOBAL_VARS()                                 \
 
136
    extern int scm_g_dummy
 
137
#define SCM_DEFINE_AGGREGATED_GLOBAL_VARS()                                  \
 
138
    extern int scm_g_dummy
 
139
 
 
140
#define SCM_AGGREGATED_GLOBAL_VARS_INIT() SCM_EMPTY_EXPR
 
141
#define SCM_AGGREGATED_GLOBAL_VARS_FIN()  SCM_EMPTY_EXPR
 
142
 
 
143
#define SCM_DEFINE_STATIC_VARS(_namespace)                                   \
 
144
    static struct scm_g_##_namespace scm_g_instance_##_namespace
 
145
#define SCM_GLOBAL_VARS_INIT(_namespace)                                     \
 
146
    (memset(&scm_g_instance_##_namespace, 0,                                 \
 
147
            sizeof(scm_g_instance_##_namespace)))
 
148
#define SCM_GLOBAL_VARS_FIN(_namespace) SCM_EMPTY_EXPR
 
149
 
 
150
#define SCM_GLOBAL_VARS_INSTANCE(_namespace)                                 \
 
151
    (scm_g_instance_##_namespace)
 
152
#endif /* SCM_USE_AGGREGATED_GLOBAL_VARS */
 
153
 
 
154
#define SCM_GLOBAL_VARS_BEGIN(_namespace)                                    \
 
155
    struct scm_g_##_namespace {                                              \
 
156
    SCM_GLOBAL_STRUCT_WARNING_SUPPRESSOR
 
157
#define SCM_GLOBAL_VARS_END(_namespace)                                      \
 
158
    }
 
159
 
 
160
#define SCM_GLOBAL_VAR(_namespace, _var_name)                                \
 
161
    (SCM_GLOBAL_VARS_INSTANCE(_namespace)._var_name)
 
162
 
 
163
#if SCM_USE_AGGREGATED_GLOBAL_VARS
 
164
#define SCM_DECLARE_EXPORTED_VARS(_namespace)                                \
 
165
    SCM_EXPORT struct scm_g_##_namespace *scm_g_instance_##_namespace(void)
 
166
#define SCM_DEFINE_EXPORTED_VARS(_namespace)                                 \
 
167
    extern int scm_g_dummy_##_namespace
 
168
#if !SCM_COMBINED_SOURCE
 
169
#error "(SCM_USE_AGGREGATED_GLOBAL_VARS && !SCM_COMBINED_SOURCE) is not supported"
 
170
#endif /* SCM_COMBINED_SOURCE */
 
171
#else /* SCM_USE_AGGREGATED_GLOBAL_VARS */
 
172
#if SCM_COMBINED_SOURCE
 
173
/* define at declaration in the header file */
 
174
#define SCM_DECLARE_EXPORTED_VARS(_namespace)                                \
 
175
    SCM_DEFINE_STATIC_VARS(_namespace)
 
176
#define SCM_DEFINE_EXPORTED_VARS(_namespace)                                 \
 
177
    /* dummy statement to prevent static prefix */                           \
 
178
    struct scm_g_dummy_##_namespace { int dummy; }
 
179
#else /* SCM_COMBINED_SOURCE */
 
180
#define SCM_DECLARE_EXPORTED_VARS(_namespace)                                \
 
181
    SCM_EXTERN(struct scm_g_##_namespace scm_g_instance_##_namespace)
 
182
#define SCM_DEFINE_EXPORTED_VARS(_namespace)                                 \
 
183
    /* dummy statement to prevent static prefix */                           \
 
184
    struct scm_g_dummy_##_namespace { int dummy; };                          \
 
185
    SCM_EXPORT struct scm_g_##_namespace scm_g_instance_##_namespace
 
186
#endif /* SCM_COMBINED_SOURCE */
 
187
#endif /* SCM_USE_AGGREGATED_GLOBAL_VARS */
 
188
 
 
189
#if (SCM_COMBINED_SOURCE && !SCM_EXPORT_API)
 
190
#define SCM_EXTERN(_decl) extern int scm_g_dummy
 
191
#define SCM_EXPORT static
 
192
 
 
193
/* FIXME: reflect SCM_COMBINED_SOURCE */
 
194
#elif defined(__SYMBIAN32__)
 
195
#define SCM_EXTERN(_decl) extern _decl
 
196
#if SCM_COMPILING_LIBSSCM
 
197
#define SCM_EXPORT EXPORT_C
 
198
#else /* SCM_COMPILING_LIBSSCM */
 
199
#define SCM_EXPORT IMPORT_C
 
200
#endif /* SCM_COMPILING_LIBSSCM */
 
201
 
 
202
#elif BREW_MAJ_VER  /* FIXME: inappropriate detection method */
 
203
#define SCM_EXTERN(_decl) extern _decl
 
204
#define SCM_EXPORT extern  /* respect coding style of BREW */
 
205
 
 
206
/* FIXME: reflect SCM_COMBINED_SOURCE */
 
207
#elif (defined(_WIN32) || defined(_WIN64))
 
208
#define SCM_EXTERN(_decl) extern _decl
 
209
#if SCM_COMPILING_LIBSSCM
 
210
#define SCM_EXPORT __declspec(dllexport)
 
211
#else /* SCM_COMPILING_LIBSSCM */
 
212
#define SCM_EXPORT __declspec(dllimport)
 
213
#endif /* SCM_COMPILING_LIBSSCM */
 
214
 
 
215
#else
 
216
#define SCM_EXTERN(_decl) extern _decl
 
217
#define SCM_EXPORT
 
218
#endif
 
219
 
 
220
/*=======================================
 
221
  Type Definitions
 
222
=======================================*/
 
223
 
 
224
/*=======================================
 
225
  Variable Declarations
 
226
=======================================*/
 
227
 
 
228
/*=======================================
 
229
  Function Declarations
 
230
=======================================*/
 
231
#if SCM_USE_AGGREGATED_GLOBAL_VARS
 
232
SCM_EXPORT void scm_aggregated_global_vars_init(void);
 
233
#if (defined(__SYMBIAN32__) && !defined(EKA2))
 
234
SCM_EXPORT void scm_aggregated_global_vars_fin(void);
 
235
#endif /* (defined(__SYMBIAN32__) && !defined(EKA2)) */
 
236
#endif /* SCM_USE_AGGREGATED_GLOBAL_VARS */
 
237
 
 
238
 
 
239
#ifdef __cplusplus
 
240
}
 
241
#endif
 
242
 
 
243
#endif /* __SCM_GLOBAL_H */