1 /*-
2  * Copyright (c) 2006-2007 Benedikt Meurer <benny@xfce.org>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TERMINAL_PRIVATE_H
19 #define TERMINAL_PRIVATE_H
20 
21 #include <glib-object.h>
22 #include <vte/vte.h>
23 
24 #define PCRE2_CODE_UNIT_WIDTH 0
25 #include <pcre2.h>
26 
27 G_BEGIN_DECLS
28 
29 /* returns true if string contains text */
30 #define IS_STRING(string) ((string) != NULL && *(string) != '\0')
31 
32 /* macro for some debugging */
33 #define PRINT_TIME(desc) \
34   G_BEGIN_DECLS { \
35     GTimeVal gtv; \
36     g_get_current_time (&gtv); \
37     g_print ("%ld.%ld: %s\n", gtv.tv_sec, gtv.tv_usec, desc); \
38   } G_END_DECLS
39 
40 /* support macros for debugging */
41 #ifdef G_ENABLE_DEBUG
42 #define terminal_assert(expr)                  g_assert (expr)
43 #define terminal_assert_not_reached()          g_assert_not_reached ()
44 #define terminal_return_if_fail(expr)          g_return_if_fail (expr)
45 #define terminal_return_val_if_fail(expr, val) g_return_val_if_fail (expr, (val))
46 #else
47 #define terminal_assert(expr)                  G_STMT_START{ (void)0; }G_STMT_END
48 #define terminal_assert_not_reached()          G_STMT_START{ (void)0; }G_STMT_END
49 #define terminal_return_if_fail(expr)          G_STMT_START{ (void)0; }G_STMT_END
50 #define terminal_return_val_if_fail(expr, val) G_STMT_START{ (void)0; }G_STMT_END
51 #endif
52 
53 /* avoid trivial g_value_get_*() function calls */
54 #ifdef G_ENABLE_DEBUG
55 #define g_value_get_boolean(v)  (((const GValue *) (v))->data[0].v_int)
56 #define g_value_get_char(v)     (((const GValue *) (v))->data[0].v_int)
57 #define g_value_get_uchar(v)    (((const GValue *) (v))->data[0].v_uint)
58 #define g_value_get_int(v)      (((const GValue *) (v))->data[0].v_int)
59 #define g_value_get_uint(v)     (((const GValue *) (v))->data[0].v_uint)
60 #define g_value_get_long(v)     (((const GValue *) (v))->data[0].v_long)
61 #define g_value_get_ulong(v)    (((const GValue *) (v))->data[0].v_ulong)
62 #define g_value_get_int64(v)    (((const GValue *) (v))->data[0].v_int64)
63 #define g_value_get_uint64(v)   (((const GValue *) (v))->data[0].v_uint64)
64 #define g_value_get_enum(v)     (((const GValue *) (v))->data[0].v_long)
65 #define g_value_get_flags(v)    (((const GValue *) (v))->data[0].v_ulong)
66 #define g_value_get_float(v)    (((const GValue *) (v))->data[0].v_float)
67 #define g_value_get_double(v)   (((const GValue *) (v))->data[0].v_double)
68 #define g_value_get_string(v)   (((const GValue *) (v))->data[0].v_pointer)
69 #define g_value_get_param(v)    (((const GValue *) (v))->data[0].v_pointer)
70 #define g_value_get_boxed(v)    (((const GValue *) (v))->data[0].v_pointer)
71 #define g_value_get_pointer(v)  (((const GValue *) (v))->data[0].v_pointer)
72 #define g_value_get_object(v)   (((const GValue *) (v))->data[0].v_pointer)
73 #endif
74 
75 #define I_(string) (g_intern_static_string ((string)))
76 
77 G_END_DECLS
78 
79 #endif /* !TERMINAL_PRIVATE_H */
80