1 /********************************************************************\
2 * This program is free software; you can redistribute it and/or *
3 * modify it under the terms of the GNU General Public License as *
4 * published by the Free Software Foundation; either version 2 of *
5 * the License, or (at your option) any later version. *
6 * *
7 * This program is distributed in the hope that it will be useful, *
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10 * GNU General Public License for more details. *
11 * *
12 * You should have received a copy of the GNU General Public License*
13 * along with this program; if not, contact: *
14 * *
15 * Free Software Foundation Voice: +1-617-542-5942 *
16 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17 * Boston, MA 02110-1301, USA gnu@gnu.org *
18 * *
19 \********************************************************************/
20
21 %module unittest_support
22 %{
23 #include <config.h>
24 #include "unittest-support.h"
25 %}
26
27 #if defined(SWIGGUILE)
28 %{
29 #include "guile-mappings.h"
30
31 SCM scm_init_unittest_support_module (void);
32 %}
33 #endif
34
35 #if defined(SWIGPYTHON)
36 %{
37 /* avoid no previous prototype warning/error */
38 PyObject* SWIG_init (void);
39 %}
40 #endif
41
42 %import "base-typemaps.i"
43
44 typedef struct
45 {
46 GLogLevelFlags log_level;
47 gchar *log_domain;
48 gchar *msg;
49 } TestErrorStruct;
50
51 typedef enum {
52 /* log flags */
53 G_LOG_FLAG_RECURSION = 1 << 0,
54 G_LOG_FLAG_FATAL = 1 << 1,
55
56 /* GLib log levels */
57 G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
58 G_LOG_LEVEL_CRITICAL = 1 << 3,
59 G_LOG_LEVEL_WARNING = 1 << 4,
60 G_LOG_LEVEL_MESSAGE = 1 << 5,
61 G_LOG_LEVEL_INFO = 1 << 6,
62 G_LOG_LEVEL_DEBUG = 1 << 7,
63
64 G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
65 } GLogLevelFlags;
66
67 typedef gboolean (*GLogFunc) (const gchar *log_domain,
68 GLogLevelFlags log_level,
69 const gchar *message,
70 gpointer user_data);
71
72 void test_add_error (TestErrorStruct *error);
73 void test_clear_error_list (void);
74 guint test_set_checked_handler (const char *domain, GLogLevelFlags level,
75 gpointer data);
76 guint test_set_list_handler (const char *domain, GLogLevelFlags level,
77 gpointer data);
78 guint test_set_null_handler (const char *domain, GLogLevelFlags level,
79 gpointer data);
80
81 %{
82
83 static guint
test_set_checked_handler(const char * domain,GLogLevelFlags level,gpointer data)84 test_set_checked_handler (const char *domain, GLogLevelFlags level,
85 gpointer data)
86 {
87 return g_log_set_handler (domain, level,
88 (GLogFunc)test_checked_handler, data);
89 }
90 static guint
test_set_list_handler(const char * domain,GLogLevelFlags level,gpointer data)91 test_set_list_handler (const char *domain, GLogLevelFlags level,
92 gpointer data)
93 {
94 return g_log_set_handler (domain, level,
95 (GLogFunc)test_list_handler, data);
96 }
97 static guint
test_set_null_handler(const char * domain,GLogLevelFlags level,gpointer data)98 test_set_null_handler (const char *domain, GLogLevelFlags level,
99 gpointer data)
100 {
101 return g_log_set_handler (domain, level,
102 (GLogFunc)test_null_handler, data);
103 }
104 %}
105 void g_log_remove_handler (const char *log_domain, guint handler);
106
107