Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / glibmm2 / tools / m4 / convert_glib.m4
1 dnl 
2 dnl Glib C names have prefix 'G' but C++ namespace Glib
3 dnl 
4 define(`_CONV_GLIB_ENUM',`dnl
5 _CONVERSION(`G$1', `$1', (($1)(__ARG3__)))
6 _CONVERSION(`G$1', `Glib::$1', ((Glib::$1)(__ARG3__)))
7 _CONVERSION(`$1', `G$1', ((G$1)(__ARG3__)))
8 _CONVERSION(`Glib::$1', `G$1', ((G$1)(__ARG3__)))
9 ')dnl
10
11 _EQUAL(gchar,char)
12 _EQUAL(gchar*,char*)
13 _EQUAL(gchar**,char**)
14 _EQUAL(gint**,int**)
15 _EQUAL(gchar**,char*[])
16 _EQUAL(const gchar*,const char*)
17 _EQUAL(const-gchar*,const char*)
18 _EQUAL(gpointer*,void**)
19
20 _CONV_GLIB_ENUM(IOStatus)
21 _CONV_GLIB_ENUM(IOFlags)
22 _CONV_GLIB_ENUM(IOCondition)
23 _CONV_GLIB_ENUM(SeekType)
24 _CONV_GLIB_ENUM(OptionArg)
25 _CONV_GLIB_ENUM(KeyFileFlags)
26 _CONV_GLIB_ENUM(RegexCompileFlags)
27 _CONV_GLIB_ENUM(RegexMatchFlags)
28
29
30 _CONVERSION(`gunichar&',`gunichar*',`&($3)')
31 _CONVERSION(`gsize&',`gsize*',`&($3)')
32
33
34 # Strings:
35 define(`__GCHARP_TO_USTRING',`Glib::convert_const_gchar_ptr_to_ustring($`'3)')
36 define(`__GCHARP_TO_STDSTRING',`Glib::convert_const_gchar_ptr_to_stdstring($`'3)')
37
38 _CONVERSION(`const Glib::ustring&',`const char*',`$3.c_str()')
39 _CONVERSION(`const Glib::ustring&', `const guchar*', `(($2)$3.c_str())')
40 _CONVERSION(`const std::string&',`const char*',`$3.c_str()')
41 _CONVERSION(`std::string',`const char*',`$3.c_str()')
42 _CONVERSION(`const Glib::ustring&',`gchar*',`const_cast<gchar*>($3.c_str())')
43 _CONVERSION(`gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
44 _CONVERSION(`const-gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
45 _CONVERSION(`const-guchar*',`Glib::ustring',__GCHARP_TO_USTRING)
46 _CONVERSION(`const gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
47 _CONVERSION(`const char*',`Glib::ustring',__GCHARP_TO_USTRING)
48 _CONVERSION(`const char*',`std::string',__GCHARP_TO_STDSTRING)
49 _CONVERSION(`const char*',`const-gchar*',`$3')
50 _CONVERSION(`const-gchar*',`const char*',`$3')
51 _CONVERSION(`const char*',`const std::string&',__GCHARP_TO_STDSTRING)
52 _CONVERSION(`char*',`std::string',__GCHARP_TO_STDSTRING)
53 _CONVERSION(`std::string', `char*', `g_strdup(($3).c_str())')
54 _CONVERSION(`const std::string&', `char*', `g_strdup(($3).c_str())')
55 _CONVERSION(`Glib::ustring', `char*', `g_strdup(($3).c_str())')
56
57 _CONVERSION(`return-gchar*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
58 _CONVERSION(`return-gchar*',`std::string',`Glib::convert_return_gchar_ptr_to_stdstring($3)')
59 _CONVERSION(`return-char*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
60
61 _CONVERSION(`const Glib::RefPtr<Glib::Object>&',`GObject*',__CONVERT_REFPTR_TO_P)
62 _CONVERSION(`const Glib::RefPtr<const Glib::Object>&',`GObject*',__CONVERT_CONST_REFPTR_TO_P_SUN(Glib::Object))
63 _CONVERSION(`GObject*',`Glib::RefPtr<Glib::Object>',`Glib::wrap($3)')
64 _CONVERSION(`GObject*',`Glib::RefPtr<const Glib::Object>',`Glib::wrap($3)')
65
66 _CONVERSION(`GRegex*',`Glib::RefPtr<Regex>',`Glib::wrap($3)')
67 _CONVERSION(`GRegex*',`Glib::RefPtr<const Regex>',`Glib::wrap($3)')
68
69 _CONVERSION(`Glib::ValueBase&',`GValue*',`($3).gobj()')
70 _CONVERSION(`const Glib::ValueBase&',`const GValue*',`($3).gobj()')
71 _CONVERSION(`const Glib::ValueBase&',`GValue*',`const_cast<GValue*>(($3).gobj())')
72 _CONVERSION(`GValue*', `Glib::ValueBase&', `*reinterpret_cast<Glib::ValueBase*>($3)')
73 _CONVERSION(`const GValue*', `const Glib::ValueBase&', `*reinterpret_cast<const Glib::ValueBase*>($3)')
74
75 _CONVERSION(`OptionGroup&',`GOptionGroup*',`($3).gobj()')
76 #_CONVERSION(`GOptionGroup*',`OptionGroup',`Glib::wrap(($3), true /* take_copy */)')
77