summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2017-04-18 20:08:54 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2017-04-18 20:08:54 +0200
commitc2eb712b177f0e6ac31beb1de0288d25532b9f45 (patch)
treedb3d5c57129a12806c7c66458bcdb4edd1dc991f
parentf35efbbd261810c83f675c032092393c04522061 (diff)
downloadglibmm-c2eb712b177f0e6ac31beb1de0288d25532b9f45.tar.gz
gmmproc: New and improved _CONV_*_ENUM m4 macros
* tools/m4/convert_base.m4: In _CONV_ENUM and _CONV_INCLASS_ENUM, add an optional argument, making it possible to define useful conversions when the C name of the enum is not the concatenation of C++ namespace + enum_name or namespace + class_name + enum_name. * tools/m4/convert_gio.m4: Add _CONV_GIO_ENUM, _CONV_GIO_DBUS_ENUM, _CONV_GIO_INCLASS_ENUM and _CONV_GIO_DBUS_INCLASS_ENUM. * tools/m4/convert_glib.m4: In _CONV_GLIB_ENUM and _CONV_GLIB_INCLASS_ENUM, add an optional argument like in convert_base.m4.
-rw-r--r--tools/m4/convert_base.m430
-rw-r--r--tools/m4/convert_gio.m4139
-rw-r--r--tools/m4/convert_glib.m418
3 files changed, 107 insertions, 80 deletions
diff --git a/tools/m4/convert_base.m4 b/tools/m4/convert_base.m4
index c5606339..ce447ccb 100644
--- a/tools/m4/convert_base.m4
+++ b/tools/m4/convert_base.m4
@@ -51,22 +51,28 @@ define(`_EQUAL',`define(EV`'__HASH(`$1'),`$2')')
define(`__ARG3__',`$`'3')
-# _CONV_ENUM(namespace, enum_name)
+# _CONV_ENUM(namespace, enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of namespace+enum_name.
define(`_CONV_ENUM',`dnl
-_CONVERSION(`$1$2', `$2', (($2)(__ARG3__)))
-_CONVERSION(`$1$2', `$1::$2', (($1::$2)(__ARG3__)))
-_CONVERSION(`$2', `$1$2', (($1$2)(__ARG3__)))
-_CONVERSION(`$1::$2', `$1$2', (($1$2)(__ARG3__)))
+pushdef(`C_ENUM_NAME', `m4_ifelse(`$3',,`$1$2',`$3')')
+_CONVERSION(`C_ENUM_NAME', `$2', (($2)(__ARG3__)))
+_CONVERSION(`C_ENUM_NAME', `$1::$2', (($1::$2)(__ARG3__)))
+_CONVERSION(`$2', `C_ENUM_NAME', ((C_ENUM_NAME)(__ARG3__)))
+_CONVERSION(`$1::$2', `C_ENUM_NAME', ((C_ENUM_NAME)(__ARG3__)))
+popdef(`C_ENUM_NAME')
')dnl
-# _CONV_INCLASS_ENUM(namespace, class_name, enum_name)
+# _CONV_INCLASS_ENUM(namespace, class_name, enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of namespace+class_name+enum_name.
define(`_CONV_INCLASS_ENUM',`dnl
-_CONVERSION(`$1$2$3', `$3', (($3)(__ARG3__)))
-_CONVERSION(`$1$2$3', `$2::$3', (($2::$3)(__ARG3__)))
-_CONVERSION(`$1$2$3', `$1::$2::$3', (($1::$2::$3)(__ARG3__)))
-_CONVERSION(`$3', `$1$2$3', (($1$2$3)(__ARG3__)))
-_CONVERSION(`$2::$3', `$1$2$3', (($1$2$3)(__ARG3__)))
-_CONVERSION(`$1::$2::$3', `$1$2$3', (($1$2$3)(__ARG3__)))
+pushdef(`C_ENUM_NAME', `m4_ifelse(`$4',,`$1$2$3',`$4')')
+_CONVERSION(`C_ENUM_NAME', `$3', (($3)(__ARG3__)))
+_CONVERSION(`C_ENUM_NAME', `$2::$3', (($2::$3)(__ARG3__)))
+_CONVERSION(`C_ENUM_NAME', `$1::$2::$3', (($1::$2::$3)(__ARG3__)))
+_CONVERSION(`$3', `C_ENUM_NAME', ((C_ENUM_NAME)(__ARG3__)))
+_CONVERSION(`$2::$3', `C_ENUM_NAME', ((C_ENUM_NAME)(__ARG3__)))
+_CONVERSION(`$1::$2::$3', `C_ENUM_NAME', ((C_ENUM_NAME)(__ARG3__)))
+popdef(`C_ENUM_NAME')
')dnl
# e.g. Glib::RefPtr<Gdk::Something> to GdkSomething*
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index d2b32fa5..5e22f9f9 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -1,59 +1,86 @@
-_CONV_ENUM(G,AppInfoCreateFlags)
-_CONV_ENUM(G,ApplicationFlags)
-_CONV_ENUM(G,AskPasswordFlags)
-_CONV_ENUM(G,BusType)
-_CONV_ENUM(G,ConverterFlags)
-_CONV_ENUM(G,ConverterResult)
-_CONV_ENUM(G,CredentialsType)
-_CONV_ENUM(G,DataStreamByteOrder)
-_CONV_ENUM(G,DataStreamNewlineType)
-_CONV_ENUM(GDBus,CallFlags)
-_CONV_ENUM(GDBus,CapabilityFlags)
-_CONV_ENUM(GDBus, InterfaceSkeletonFlags)
-_CONV_ENUM(GDBus,MessageFlags)
-_CONV_ENUM(GDBus,MessageHeaderField)
-_CONV_ENUM(GDBus,MessageType)
-_CONV_ENUM(GDBus,ProxyFlags)
-_CONV_ENUM(GDBus,SendMessageFlags)
-_CONV_ENUM(GDBus,ServerFlags)
-_CONV_ENUM(G,DriveStartFlags)
-_CONV_ENUM(G,DriveStartFlags)
-_CONV_ENUM(G,DriveStartStopType)
-_CONV_ENUM(G,EmblemOrigin)
-_CONV_ENUM(G,FileAttributeInfoFlags)
-_CONV_ENUM(G,FileAttributeStatus)
-_CONV_ENUM(G,FileAttributeType)
-_CONV_ENUM(G,FileCopyFlags)
-_CONV_ENUM(G,FileCreateFlags)
-_CONV_ENUM(G,FileMonitorEvent)
-_CONV_ENUM(G,FileMonitorFlags)
-_CONV_ENUM(G,FileQueryInfoFlags)
-_CONV_ENUM(G,FileType)
-_CONV_ENUM(G,MountMountFlags)
-_CONV_ENUM(G,MountOperationResult)
-_CONV_ENUM(G,MountUnmountFlags)
-_CONV_ENUM(G,NetworkConnectivity)
-_CONV_ENUM(G,NotificationPriority)
-_CONV_ENUM(G,OutputStreamSpliceFlags)
-_CONV_ENUM(G,PasswordSave)
-_CONV_ENUM(G,ResolverRecordType)
-_CONV_ENUM(G,ResourceFlags)
-_CONV_ENUM(G,ResourceLookupFlags)
-_CONV_ENUM(G,SettingsBindFlags)
-_CONV_ENUM(G,SocketClientEvent)
-_CONV_ENUM(G,SocketFamily)
-_CONV_ENUM(G,SocketMsgFlags)
-_CONV_ENUM(G,SocketProtocol)
-_CONV_ENUM(G,SocketType)
-_CONV_ENUM(G,TlsCertificateFlags)
-_CONV_ENUM(G,TlsCertificateRequestFlags)
-_CONV_ENUM(G,TlsDatabaseVerifyFlags)
-_CONV_ENUM(G,TlsDatabaseLookupFlags)
-_CONV_ENUM(G,TlsInteractionResult)
-_CONV_ENUM(G,TlsPasswordFlags)
-_CONV_ENUM(G,TlsRehandshakeMode)
-_CONV_ENUM(G,UnixSocketAddressType)
-_CONV_ENUM(G,ZlibCompressorFormat)
+dnl
+dnl Gio C names have prefix 'G' or 'GDBus' but C++ namespace Gio ot Gio::DBus
+dnl
+# _CONV_GIO_ENUM(enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of G+enum_name.
+define(`_CONV_GIO_ENUM',`dnl
+_CONV_ENUM(`Gio',`$1',`m4_ifelse(`$2',,`G$1',`$2')')
+')dnl
+
+# _CONV_GIO_DBUS_ENUM(enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of GDBus+enum_name.
+define(`_CONV_GIO_DBUS_ENUM',`dnl
+_CONV_ENUM(`Gio::DBus',`$1',`m4_ifelse(`$2',,`GDBus$1',`$2')')
+')dnl
+
+# _CONV_GIO_INCLASS_ENUM(class_name, enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of G+class_name+enum_name.
+define(`_CONV_GIO_INCLASS_ENUM',`dnl
+_CONV_INCLASS_ENUM(`Gio',`$1',`$2',`m4_ifelse(`$3',,`G$1$2',`$3')')
+')dnl
+
+# _CONV_GIO_DBUS_INCLASS_ENUM(class_name, enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of GDBus+class_name+enum_name.
+define(`_CONV_GIO_DBUS_INCLASS_ENUM',`dnl
+_CONV_INCLASS_ENUM(`Gio::DBus',`$1',`$2',`m4_ifelse(`$3',,`GDBus$1$2',`$3')')
+')dnl
+
+_CONV_GIO_ENUM(AppInfoCreateFlags)
+_CONV_GIO_ENUM(ApplicationFlags)
+_CONV_GIO_ENUM(AskPasswordFlags)
+_CONV_GIO_ENUM(BusType)
+_CONV_GIO_ENUM(ConverterFlags)
+_CONV_GIO_ENUM(ConverterResult)
+_CONV_GIO_ENUM(CredentialsType)
+_CONV_GIO_ENUM(DataStreamByteOrder)
+_CONV_GIO_ENUM(DataStreamNewlineType)
+_CONV_GIO_DBUS_ENUM(CallFlags)
+_CONV_GIO_DBUS_ENUM(CapabilityFlags)
+_CONV_GIO_DBUS_ENUM(InterfaceSkeletonFlags)
+_CONV_GIO_DBUS_ENUM(MessageFlags)
+_CONV_GIO_DBUS_ENUM(MessageHeaderField)
+_CONV_GIO_DBUS_ENUM(MessageType)
+_CONV_GIO_DBUS_ENUM(ProxyFlags)
+_CONV_GIO_DBUS_ENUM(SendMessageFlags)
+_CONV_GIO_DBUS_ENUM(ServerFlags)
+_CONV_GIO_ENUM(DriveStartFlags)
+_CONV_GIO_ENUM(DriveStartFlags)
+_CONV_GIO_ENUM(DriveStartStopType)
+_CONV_GIO_ENUM(EmblemOrigin)
+_CONV_GIO_ENUM(FileAttributeInfoFlags)
+_CONV_GIO_ENUM(FileAttributeStatus)
+_CONV_GIO_ENUM(FileAttributeType)
+_CONV_GIO_ENUM(FileCopyFlags)
+_CONV_GIO_ENUM(FileCreateFlags)
+_CONV_GIO_ENUM(FileMonitorEvent)
+_CONV_GIO_ENUM(FileMonitorFlags)
+_CONV_GIO_ENUM(FileQueryInfoFlags)
+_CONV_GIO_ENUM(FileType)
+_CONV_GIO_ENUM(MountMountFlags)
+_CONV_GIO_ENUM(MountOperationResult)
+_CONV_GIO_ENUM(MountUnmountFlags)
+_CONV_GIO_ENUM(NetworkConnectivity)
+_CONV_GIO_ENUM(NotificationPriority)
+_CONV_GIO_ENUM(OutputStreamSpliceFlags)
+_CONV_GIO_ENUM(PasswordSave)
+_CONV_GIO_ENUM(ResolverRecordType)
+_CONV_GIO_ENUM(ResourceFlags)
+_CONV_GIO_ENUM(ResourceLookupFlags)
+_CONV_GIO_ENUM(SettingsBindFlags)
+_CONV_GIO_ENUM(SocketClientEvent)
+_CONV_GIO_ENUM(SocketFamily)
+_CONV_GIO_ENUM(SocketMsgFlags)
+_CONV_GIO_ENUM(SocketProtocol)
+_CONV_GIO_ENUM(SocketType)
+_CONV_GIO_ENUM(TlsCertificateFlags)
+_CONV_GIO_ENUM(TlsCertificateRequestFlags)
+_CONV_GIO_ENUM(TlsDatabaseVerifyFlags)
+_CONV_GIO_ENUM(TlsDatabaseLookupFlags)
+_CONV_GIO_ENUM(TlsInteractionResult)
+_CONV_GIO_ENUM(TlsPasswordFlags)
+_CONV_GIO_ENUM(TlsRehandshakeMode)
+_CONV_GIO_ENUM(UnixSocketAddressType)
+_CONV_GIO_ENUM(ZlibCompressorFormat)
# Action
_CONVERSION(`GAction*',`Glib::RefPtr<Action>',`Glib::wrap($3)')
diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4
index 22711ab9..79a76dcf 100644
--- a/tools/m4/convert_glib.m4
+++ b/tools/m4/convert_glib.m4
@@ -1,22 +1,16 @@
dnl
dnl Glib C names have prefix 'G' but C++ namespace Glib
dnl
-# _CONV_GLIB_ENUM(enum_name)
+# _CONV_GLIB_ENUM(enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of G+enum_name.
define(`_CONV_GLIB_ENUM',`dnl
-_CONVERSION(`G$1', `$1', (($1)(__ARG3__)))
-_CONVERSION(`G$1', `Glib::$1', ((Glib::$1)(__ARG3__)))
-_CONVERSION(`$1', `G$1', ((G$1)(__ARG3__)))
-_CONVERSION(`Glib::$1', `G$1', ((G$1)(__ARG3__)))
+_CONV_ENUM(`Glib',`$1',`m4_ifelse(`$2',,`G$1',`$2')')
')dnl
-# _CONV_GLIB_INCLASS_ENUM(class_name, enum_name)
+# _CONV_GLIB_INCLASS_ENUM(class_name, enum_name[, C_enum_name])
+# Specify C_enum_name, if it's not the concatenation of G+class_name+enum_name.
define(`_CONV_GLIB_INCLASS_ENUM',`dnl
-_CONVERSION(`G$1$2', `$2', (($2)(__ARG3__)))
-_CONVERSION(`G$1$2', `$1::$2', (($1::$2)(__ARG3__)))
-_CONVERSION(`G$1$2', `Glib::$1::$2', ((Glib::$1::$2)(__ARG3__)))
-_CONVERSION(`$2', `G$1$2', ((G$1$2)(__ARG3__)))
-_CONVERSION(`$1::$2', `G$1$2', ((G$1$2)(__ARG3__)))
-_CONVERSION(`Glib::$1::$2', `G$1$2', ((G$1$2)(__ARG3__)))
+_CONV_INCLASS_ENUM(`Glib',`$1',`$2',`m4_ifelse(`$3',,`G$1$2',`$3')')
')dnl
_EQUAL(gchar,char)