This commit is contained in:
2025-09-27 22:09:23 +03:00
commit 914c0295ac
2468 changed files with 204262 additions and 0 deletions

View File

@@ -0,0 +1,478 @@
dnl $Id$
divert(-1)
dnl
dnl The general convention is
dnl _* are macros
dnl __*__ are variables
dnl
dnl rename several m4 builtins to avoid name clashes
dnl
define(`_PREFIX_BUILTIN_ALIAS', `define(`m4_$1', defn(`$1'))')
define(`_PREFIX_BUILTIN', `_PREFIX_BUILTIN_ALIAS(`$1')`'undefine(`$1')')
_PREFIX_BUILTIN(`builtin')
_PREFIX_BUILTIN(`decr')
_PREFIX_BUILTIN(`errprint')
_PREFIX_BUILTIN(`esyscmd')
_PREFIX_BUILTIN(`eval')
_PREFIX_BUILTIN(`format')
_PREFIX_BUILTIN(`incr')
_PREFIX_BUILTIN(`index')
_PREFIX_BUILTIN(`indir')
_PREFIX_BUILTIN(`len')
_PREFIX_BUILTIN(`maketemp')
_PREFIX_BUILTIN(`syscmd')
_PREFIX_BUILTIN(`substr')
_PREFIX_BUILTIN(`sysval')
_PREFIX_BUILTIN(`mkstemp')
dnl
dnl More alternative names for m4 macros, not undefined (yet!).
dnl
_PREFIX_BUILTIN_ALIAS(`changecom')
_PREFIX_BUILTIN_ALIAS(`changequote')
_PREFIX_BUILTIN_ALIAS(`define')
_PREFIX_BUILTIN_ALIAS(`divert')
_PREFIX_BUILTIN_ALIAS(`divnum')
_PREFIX_BUILTIN_ALIAS(`ifdef')
_PREFIX_BUILTIN_ALIAS(`ifelse')
_PREFIX_BUILTIN_ALIAS(`include')
_PREFIX_BUILTIN_ALIAS(`m4exit')
_PREFIX_BUILTIN_ALIAS(`m4wrap')
_PREFIX_BUILTIN_ALIAS(`patsubst')
_PREFIX_BUILTIN_ALIAS(`popdef')
_PREFIX_BUILTIN_ALIAS(`pushdef')
_PREFIX_BUILTIN_ALIAS(`shift')
_PREFIX_BUILTIN_ALIAS(`undefine')
_PREFIX_BUILTIN_ALIAS(`undivert')
_PREFIX_BUILTIN_ALIAS(`regexp')
_PREFIX_BUILTIN_ALIAS(`translit')
dnl
dnl Type Conversion Macros
dnl
m4_include(convert.m4)
dnl
dnl Initialization macros
dnl
m4_include(initialize.m4)
dnl
dnl ----------------------- Utility Macros -------------------------
dnl
dnl
dnl Add a comma before the arg if any, do nothing otherwise
dnl _COMMA_PREFIX(a) -> ,a
dnl _COMMA_PREFIX() -> `'
dnl
define(`_COMMA_PREFIX', `m4_ifelse(m4_eval(m4_len(`$*') >= 1), 1, `,$*')')dnl
dnl
dnl Add a comma after the arg if any, do nothing otherwise
dnl _COMMA_SUFFIX(a) -> a,
dnl _COMMA_SUFFIX() -> `'
dnl
define(`_COMMA_SUFFIX', `m4_ifelse(m4_eval(m4_len(`$*') >= 1), 1, `$*,')')dnl
dnl
dnl _UPPER(string)
dnl uppercase a string
define(`_UPPER',`m4_translit(`$*',`abcdefghijklmnopqrstuvwxyz',`ABCDEFGHIJKLMNOPQRSTUVWXYZ')')
dnl
dnl _LOWER(string)
dnl lower a string
define(`_LOWER',`m4_translit(`$*',`ABCDEFGHIJKLMNOPQRSTUVWXYZ',`abcdefghijklmnopqrstuvwxyz')')
dnl
dnl _QUOTE(macro)
dnl If a macro generates an output with commas we need to protect it
dnl from being broken down and interpreted
define(`_QUOTE',``$*'')
dnl
dnl _NUM(arglist)
dnl count number of arguments
define(`_NUM',`m4_ifelse(m4_len(`$*'),0,0,`$#')')
dnl
dnl For handling of included macro files.
dnl
dnl _PUSH(section_name)
dnl Uses pushdef() to redefine the __DIV__ macro
dnl so that it diverts output to the section_name,
dnl or discards it (-1) if no section_name is given.
dnl _POP() uses __DIV__ for choosing diversion number.
define(`_PUSH',`pushdef(`__DIV__',divnum)m4_divert(m4_ifelse($1,,-1,__SEC_$1))dnl`'')
dnl _POP(section_name)
dnl Uses popdef() to go back to the previous definition of the __DIV__ macro.
define(`_POP',`m4_divert(__DIV__)popdef(`__DIV__')dnl`'')
dnl _SECTION(section_name):
dnl m4_divert() sends subsequent output to the specified file:
define(`_SECTION',`m4_divert(__SEC_$1)dnl')
dnl _IMPORT(section_name):
define(`_IMPORT',`m4_undivert(__SEC_$1)dnl')
dnl _GET_TYPE_FUNC(GtkWidget) -> gtk_widget_get_type()
dnl The way the macro works is that (in the inner patsubst) it first finds
dnl groups of caps, pre-pending an '_' to the groups . After (in the outer
dnl patsubst), it finds pairs of a caps and a lowercase (like 'Fo' or 'Ba'),
dnl also pre-pending an '_' to the pairs. Finally, it converts all characters
dnl to lowercase (with the translit), removing the first '_' (with substr) and
dnl appending _get_type(). This works with regular types like GtkWidget, but
dnl also multi-cap types like GdkGCFooBar or GdkFOOBar.
define(`_GET_TYPE_FUNC',`dnl
m4_translit(m4_substr(m4_patsubst(m4_patsubst(`$1',`[A-Z][A-Z]+',`_\&'),`[A-Z][a-z]',`_\&'),1),`[A-Z]',`[a-z]')_get_type()`'dnl
')
dnl Define a new diversion
dnl In m4, m4_divert() selects the output file to be used for subsequent text output.
dnl 0 is the normal output. We define extra output files with _NEW_SECTION().
dnl This macro seems to redefine __SEC_COUNT as __SEC_COUNT+1, and also
dnl define __SEC_<the macro argument> as __SEC_COUNT.
dnl So it just sets that section identifier to the next number.
define(`__SEC_COUNT__',0)
define(`_NEW_SECTION',`dnl
define(`__SEC_COUNT__',m4_eval(__SEC_COUNT__+1))dnl
define(`__SEC_$1',__SEC_COUNT__)dnl
')
changequote([,])
define([__BT__],[changequote(,)`changequote(`,')])
define([__FT__],[changequote(,)'changequote(`,')])
changequote(`,')
changecom()
dnl
dnl ----------------------- Main Headers -------------------------
dnl
_NEW_SECTION(SECTION_HEADER_FIRST)dnl Before any generated code
_NEW_SECTION(SECTION_HEADER1) dnl header up to the first namespace
_NEW_SECTION(SECTION_HEADER2) dnl header after the first namespace
_NEW_SECTION(SECTION_HEADER3) dnl header after the first namespace
_NEW_SECTION(SECTION_PHEADER) dnl private header
_NEW_SECTION(SECTION_CC_PRE_INCLUDES) dnl section just before the includes
_NEW_SECTION(SECTION_CC_INCLUDES) dnl section for additional includes
_NEW_SECTION(SECTION_SRC_CUSTOM) dnl user supplied implementation
_NEW_SECTION(SECTION_ANONYMOUS_NAMESPACE) dnl built implementation in anonymous namespace
_NEW_SECTION(SECTION_SRC_GENERATED) dnl built implementation
_NEW_SECTION(SECTION_CLASS1) dnl decl to _CLASS
_NEW_SECTION(SECTION_CLASS2) dnl _CLASS to end of class
_NEW_SECTION(SECTION_CC) dnl section for methods (in current namespace)
_NEW_SECTION(SECTION_CC_IMPLEMENTS_INTERFACES) dnl Calls SomeBaseInterface::add_interface(get_type()).
_NEW_SECTION(SECTION_CC_MOVE_CONSTRUCTOR_INTERFACES) dnl Calls the base constructors
_NEW_SECTION(SECTION_CC_MOVE_ASSIGNMENT_OPERATOR_INTERFACES) dnl Calls the base move assignment operator
dnl Virtual Functions and Default Signal Handlers (Very similar)
_NEW_SECTION(SECTION_H_VFUNCS) dnl Declaration of vfunc hooks.
_NEW_SECTION(SECTION_H_VFUNCS_CPPWRAPPER) dnl Convenience method, using C++ types, that just calls the vfunc.
_NEW_SECTION(SECTION_H_DEFAULT_SIGNAL_HANDLERS) dnl Declaration of default signal handler' hooks.
_NEW_SECTION(SECTION_CC_DEFAULT_SIGNAL_HANDLERS)
_NEW_SECTION(SECTION_CC_VFUNCS)
_NEW_SECTION(SECTION_CC_VFUNCS_CPPWRAPPER) dnl Convenience method, using C++ types, that just calls the vfunc.
_NEW_SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS) dnl private class declaration
_NEW_SECTION(SECTION_PH_VFUNCS) dnl private class declaration
_NEW_SECTION(SECTION_PCC_DEFAULT_SIGNAL_HANDLERS) dnl private class implementation
_NEW_SECTION(SECTION_PCC_VFUNCS) dnl private class implementation
_NEW_SECTION(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS) dnl gtk+ class_init function
_NEW_SECTION(SECTION_PCC_CLASS_INIT_VFUNCS) dnl gtk+ class_init function
dnl Signal Proxies:
dnl _NEW_SECTION(SECTION_H_SIGNALPROXIES) dnl signal member objects
_NEW_SECTION(SECTION_CC_SIGNALPROXIES) dnl signal member objects
dnl Property Proxies:
dnl _NEW_SECTION(SECTION_H_PROPERTYPROXIES)
_NEW_SECTION(SECTION_CC_PROPERTYPROXIES)
dnl Just a hack for some GError wrappers:
_NEW_SECTION(SECTION_H_GERROR_PRIVATE) dnl In the private part of the declaration.
_NEW_SECTION(SECTION_CC_INITIALIZE_CLASS_EXTRA) dnl For instance, to initialize special member data from all constructors. Not commonly used.
dnl _NEW_SECTION(PROXY)
dnl _NEW_SECTION(SECTION_PCC_OBJECT_INIT) dnl gtk+ object_init function
_NEW_SECTION(SECTION_CHECK)
_NEW_SECTION(SECTION_USR)
dnl Used for documenting destructors if desired.
_NEW_SECTION(SECTION_DTOR_DOCUMENTATION)
define(`_CHECK',`dnl
_PUSH(SECTION_CHECK)
$*
_POP()
')
dnl This macro is for including the config header before any code (such as
dnl the #ifndef *_DISABLE_DEPRECATED in deprecated classes) is generated.
define(`_CONFIGINCLUDE',`dnl
_PUSH(SECTION_HEADER_FIRST)
#include <$1>
_POP()
_PUSH()
dnl Define this macro to be tested for later.
define(`__FILENAME_CONFIGINCLUDE__',`$1')
_POP()
')
dnl Start of processing
dnl
dnl _START(filename,module,module_canonical,glibmm_version) .e.g _START(button, gtkmm, gtkmm, 2.38.0)
define(`_START',`dnl
define(`__MODULE__',$2)dnl
define(`__MODULE_CANONICAL__',$3)dnl
define(`__HEADER_GUARD__',`_`'_UPPER(m4_translit(`$3`'_`'$1', `-', `_'))')dnl
define(`__FILE__',$1)dnl
define(`__DEPRECATION_GUARD__',`_UPPER($3)'`_DISABLE_DEPRECATED')dnl
define(`__GLIBMM_VERSION__',$4)dnl
_SECTION(SECTION_HEADER1)
')
dnl Start deprecation of individual methods:
define(`_DEPRECATE_IFDEF_START',`dnl
#ifndef __DEPRECATION_GUARD__'
)
dnl end deprecation of individual methods:
define(`_DEPRECATE_IFDEF_END',`dnl
#endif // __DEPRECATION_GUARD__'
)
dnl begin optional deprecation of whole file
define(`_DEPRECATE_IFDEF_CLASS_START',`dnl
ifdef(`__BOOL_DEPRECATED__',`dnl
_DEPRECATE_IFDEF_START',`dnl
')
')
dnl begin optional deprecation of whole file,
dnl preceded by inclusion of config file
dnl (the config file may define the __DEPRECATION_GUARD__)
define(`_DEPRECATE_IFDEF_CLASS_CONFIG_START',`dnl
ifdef(`__BOOL_DEPRECATED__',`dnl
ifdef(`__FILENAME_CONFIGINCLUDE__',`dnl
#include <__FILENAME_CONFIGINCLUDE__>',`dnl
')
_DEPRECATE_IFDEF_START',`dnl
')
')
dnl end optional deprecation of whole file
define(`_DEPRECATE_IFDEF_CLASS_END',`dnl
ifdef(`__BOOL_DEPRECATED__',`dnl
_DEPRECATE_IFDEF_END',`dnl
')
')
dnl This does all the work of assembling the final output
dnl
dnl _END()
dnl
define(`_END',`dnl
m4_divert(0)dnl
#S 0 dnl Marks the beginning of the header file.
// Generated by gmmproc __GLIBMM_VERSION__ -- DO NOT MODIFY!
#ifndef __HEADER_GUARD__`'_H
#define __HEADER_GUARD__`'_H
_IMPORT(SECTION_HEADER_FIRST)
_DEPRECATE_IFDEF_CLASS_START
m4_ifelse(__MODULE__,glibmm,,`dnl else
#include <glibmm/ustring.h>
#include <sigc++/sigc++.h>
')dnl
_IMPORT(SECTION_HEADER1)
_IMPORT(SECTION_HEADER2)
_IMPORT(SECTION_HEADER3)
_DEPRECATE_IFDEF_CLASS_END
#endif /* __HEADER_GUARD__`'_H */
#S 1 dnl Marks the beginning of the private header file.
// Generated by gmmproc __GLIBMM_VERSION__ -- DO NOT MODIFY!
#ifndef __HEADER_GUARD__`'_P_H
#define __HEADER_GUARD__`'_P_H
_DEPRECATE_IFDEF_CLASS_START
_IMPORT(SECTION_PHEADER)
_DEPRECATE_IFDEF_CLASS_END
#endif /* __HEADER_GUARD__`'_P_H */
#S 2 dnl Marks the beginning of the source file.
// Generated by gmmproc __GLIBMM_VERSION__ -- DO NOT MODIFY!
_IMPORT(SECTION_CC_PRE_INCLUDES)
_DEPRECATE_IFDEF_CLASS_CONFIG_START
#include <glibmm.h>
#include <__MODULE__/__FILE__.h>
#include <__MODULE__/private/__FILE__`'_p.h>
_IMPORT(SECTION_CC_INCLUDES)
_IMPORT(SECTION_SRC_CUSTOM)
namespace
{
_IMPORT(SECTION_ANONYMOUS_NAMESPACE)
} // anonymous namespace
_IMPORT(SECTION_SRC_GENERATED)
_DEPRECATE_IFDEF_CLASS_END
m4_divert(-1)
m4_undivert
')
define(`_NAMESPACE',`dnl
_PUSH()
m4_ifdef(`__NAMESPACE__',`dnl
pushdef(`__NAMESPACE__',__NAMESPACE__`::'$1)
pushdef(`__NAMESPACE_BEGIN__',__NAMESPACE_BEGIN__`
namespace '$1`
{')
pushdef(`__NAMESPACE_END__',`} // namespace '$1`
'__NAMESPACE_END__)
',`dnl else
pushdef(`__NAMESPACE__',$1)
pushdef(`__NAMESPACE_BEGIN__',`namespace '$1`
{')
pushdef(`__NAMESPACE_END__',`} // namespace '$1)
')dnl endif __NAMESPACE__
_POP()
')dnl enddef _NAMESPACE
define(`_END_NAMESPACE',`dnl
_PUSH()
popdef(`__NAMESPACE__')
popdef(`__NAMESPACE_BEGIN__')
popdef(`__NAMESPACE_END__')
_POP()
')dnl enddef _END_NAMESPACE
define(`_INCLUDE_FLAG',`__FLAG_$1_INCLUDE_`'_UPPER(m4_translit(`$2',`/.-',`___'))__')dnl
define(`_PH_INCLUDE',`dnl
m4_ifdef(_INCLUDE_FLAG(PH,`$*'),,`dnl else
define(_INCLUDE_FLAG(PH,`$*'))dnl
_PUSH(SECTION_PHEADER)
#include <$*>
_POP()
')dnl endif
')dnl
define(`_CC_INCLUDE',`dnl
m4_ifdef(_INCLUDE_FLAG(CC,`$*'),,`dnl else
define(_INCLUDE_FLAG(CC,`$*'))dnl
_PUSH(SECTION_CC_INCLUDES)
#include <$*>
_POP()
')dnl endif
')dnl
define(`_PINCLUDE', defn(`_PH_INCLUDE'))
# Put these, for instance, around gtkmmproc macros (_WRAP_SIGNAL)
# to make the #ifndef appear around the generated code in both the .h
# and .cc files.
# e.g. _GTKMMPROC_H_AND_CC(#ifndef _SUN_CC_)
# e.g. _GTKMMPROC_H_AND_CC(#endif //_SUN_CC_)
# _GTKMMPROC_H_AND_CC(code)
define(`_GTKMMPROC_H_AND_CC',`dnl
$1
_PUSH(SECTION_CC)
$1
_POP()
')dnl
# Same thing as _GTKMMPROC_H_AND_CC but for signals (_WRAP_SIGNAL)
define(`_GTKMMPROC_SIGNAL_H_AND_CC',`dnl
$1
_PUSH(SECTION_ANONYMOUS_NAMESPACE)
$1
_POP()
$1
_PUSH(SECTION_H_DEFAULT_SIGNAL_HANDLERS)
$1
_POP()
$1
_PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
$1
_POP()
$1
_PUSH(SECTION_CC_DEFAULT_SIGNAL_HANDLERS)
$1
_POP()
$1
_PUSH(SECTION_PCC_DEFAULT_SIGNAL_HANDLERS)
$1
_POP()
$1
_PUSH(SECTION_CC_SIGNALPROXIES)
$1
_POP()
')dnl
m4_include(class_shared.m4)
m4_include(class_generic.m4)
m4_include(class_gobject.m4)
dnl m4_include(class_gtkobject.m4)
m4_include(class_boxedtype.m4)
m4_include(class_boxedtype_static.m4)
m4_include(class_interface.m4)
m4_include(class_opaque_copyable.m4)
m4_include(class_opaque_refcounted.m4)
m4_include(gerror.m4)
m4_include(signal.m4)
m4_include(vfunc.m4)
m4_include(method.m4)
m4_include(member.m4)
m4_include(compare.m4)
m4_include(ctor.m4)
m4_include(property.m4)
m4_include(enum.m4)
_SECTION(SECTION_HEADER1)

View File

@@ -0,0 +1,246 @@
dnl $Id$
dnl
dnl _CLASS_BOXEDTYPE(Region, GdkRegion, gdk_region_new, gdk_region_copy, gdk_region_destroy)
dnl
define(`_CLASS_BOXEDTYPE',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
define(`__BOXEDTYPE_FUNC_NEW',`$3')
define(`__BOXEDTYPE_FUNC_COPY',`$4')
define(`__BOXEDTYPE_FUNC_FREE',`$5')
define(`_CUSTOM_DEFAULT_CTOR',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_DEFAULT_CTOR__',`$1')
_POP()
')
define(`_CUSTOM_CTOR_CAST',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
_POP()
')
_POP()
_SECTION(SECTION_CLASS2)
') dnl End of _CLASS_BOXEDTYPE.
dnl Some of the Gdk types are unions - e.g. GdkEvent.
define(`_CUSTOM_STRUCT_PROTOTYPE',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_STRUCT_PROTOTYPE__',`$1')
_POP()
')
dnl
dnl _END_CLASS_BOXEDTYPE()
dnl denotes the end of a class
dnl
define(`_END_CLASS_BOXEDTYPE',`
_SECTION(SECTION_HEADER1)
ifdef(`__BOOL_CUSTOM_STRUCT_PROTOTYPE__',`dnl
',`dnl
#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef struct _`'__CNAME__ __CNAME__; }
#endif
')dnl
_SECTION(SECTION_HEADER3)
__NAMESPACE_BEGIN__
/** @relates __NAMESPACE__::__CPPNAME__
* @param lhs The left-hand side
* @param rhs The right-hand side
*/
inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs) noexcept
{ lhs.swap(rhs); }
__NAMESPACE_END__
namespace Glib
{
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
/** A Glib::wrap() method for this object.
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
* @result A C++ instance that wraps this C instance.
*
* @relates __NAMESPACE__::__CPPNAME__
*/
__NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy = false);
')dnl endif __BOOL_NO_WRAP_FUNCTION__
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <>
class Value<__NAMESPACE__::__CPPNAME__> : public Glib::Value_Boxed<__NAMESPACE__::__CPPNAME__>
{};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
} // namespace Glib
_SECTION(SECTION_SRC_GENERATED)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
namespace Glib
{
__NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy)
{
return __NAMESPACE__::__CPPNAME__`'(object, take_copy);
}
} // namespace Glib
')dnl endif
__NAMESPACE_BEGIN__
dnl
dnl The implementation:
dnl
// static
GType __CPPNAME__::get_type()
{
return _GET_TYPE_FUNC(__CNAME__);
}
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
',`dnl else
__CPPNAME__::__CPPNAME__`'()
:
ifelse(__BOXEDTYPE_FUNC_NEW,NONE,`dnl
gobject_ (nullptr) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
',`dnl else
gobject_ (__BOXEDTYPE_FUNC_NEW`'())
')dnl
{}
')dnl endif __BOOL_CUSTOM_DEFAULT_CTOR__
__CPPNAME__::__CPPNAME__`'(const __CPPNAME__& other)
:
gobject_ ((other.gobject_) ? __BOXEDTYPE_FUNC_COPY`'(other.gobject_) : nullptr)
{}
__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& other) noexcept
:
gobject_(other.gobject_)
{
other.gobject_ = nullptr;
}
__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__`'&& other) noexcept
{
__CPPNAME__ temp (other);
swap(temp);
return *this;
}
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else
__CPPNAME__::__CPPNAME__`'(__CNAME__* gobject, bool make_a_copy)
:
// For BoxedType wrappers, make_a_copy is true by default. The static
// BoxedType wrappers must always take a copy, thus make_a_copy = true
// ensures identical behaviour if the default argument is used.
gobject_ ((make_a_copy && gobject) ? __BOXEDTYPE_FUNC_COPY`'(gobject) : gobject)
{}
')dnl
__CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& other)
{
__CPPNAME__ temp (other);
swap(temp);
return *this;
}
__CPPNAME__::~__CPPNAME__`'() noexcept
{
dnl This could be a free or an unref, we do not need to know.
if(gobject_)
__BOXEDTYPE_FUNC_FREE`'(gobject_);
}
void __CPPNAME__::swap(__CPPNAME__& other) noexcept
{
std::swap(gobject_, other.gobject_);
}
__CNAME__* __CPPNAME__::gobj_copy() const
{
return __BOXEDTYPE_FUNC_COPY`'(gobject_);
}
_IMPORT(SECTION_CC)
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl
dnl The actual class, e.g. Pango::FontDescription, declaration:
dnl
_IMPORT(SECTION_CLASS1)
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = __CPPNAME__;
using BaseObjectType = __CNAME__;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
/** Get the GType for this class, for use with the underlying GObject type system.
*/
static GType get_type() G_GNUC_CONST;
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
',`dnl else
__CPPNAME__`'();
')dnl
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else
explicit __CPPNAME__`'(__CNAME__* gobject, bool make_a_copy = true);
')dnl
__CPPNAME__`'(const __CPPNAME__& other);
__CPPNAME__& operator=(const __CPPNAME__& other);
__CPPNAME__`'(__CPPNAME__&& other) noexcept;
__CPPNAME__& operator=(__CPPNAME__&& other) noexcept;
_IMPORT(SECTION_DTOR_DOCUMENTATION)
~__CPPNAME__`'() noexcept;
void swap(__CPPNAME__& other) noexcept;
///Provides access to the underlying C instance.
__CNAME__* gobj() { return gobject_; }
///Provides access to the underlying C instance.
const __CNAME__* gobj() const { return gobject_; }
///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
__CNAME__* gobj_copy() const;
protected:
__CNAME__* gobject_;
private:
_IMPORT(SECTION_CLASS2)
')

View File

@@ -0,0 +1,206 @@
dnl $Id$
dnl
dnl _CLASS_BOXEDTYPE_STATIC(TreeIter, GtkTreeIter)
dnl
define(`_CLASS_BOXEDTYPE_STATIC',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
define(`_CUSTOM_DEFAULT_CTOR',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_DEFAULT_CTOR__',`$1')
_POP()
')
define(`_CUSTOM_CTOR_CAST',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
_POP()
')
_POP()
_SECTION(SECTION_CLASS2)
') dnl End of _CLASS_BOXEDTYPE_STATIC.
dnl TreeIterBase shouldn't have a wrap() method - we'll custom implement them for TreeIter and TreeRow:
define(`_NO_WRAP_FUNCTION',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_NO_WRAP_FUNCTION__',`$1')
_POP()
')
dnl
dnl _END_CLASS_BOXEDTYPE_STATIC()
dnl denotes the end of a class
dnl
define(`_END_CLASS_BOXEDTYPE_STATIC',`
_SECTION(SECTION_HEADER3)
namespace Glib
{
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
/** @relates __NAMESPACE__::__CPPNAME__
* @param object The C instance
* @result A C++ instance that wraps this C instance.
*/
__NAMESPACE__::__CPPNAME__& wrap(__CNAME__* object);
/** @relates __NAMESPACE__::__CPPNAME__
* @param object The C instance
* @result A C++ instance that wraps this C instance.
*/
const __NAMESPACE__::__CPPNAME__& wrap(const __CNAME__* object);
')dnl endif __BOOL_NO_WRAP_FUNCTION__
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <>
class Value<__NAMESPACE__::__CPPNAME__> : public Glib::Value_Boxed<__NAMESPACE__::__CPPNAME__>
{};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
} // namespace Glib
_SECTION(SECTION_CC_INCLUDES)
#include <cstring> // std::memset`'()
_SECTION(SECTION_SRC_GENERATED)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
namespace Glib
{
__NAMESPACE__::__CPPNAME__& wrap(__CNAME__* object)
{
return *reinterpret_cast<__NAMESPACE__::__CPPNAME__*>(object);
}
const __NAMESPACE__::__CPPNAME__& wrap(const __CNAME__* object)
{
return *reinterpret_cast<const __NAMESPACE__::__CPPNAME__*>(object);
}
} // namespace Glib
')dnl endif __BOOL_NO_WRAP_FUNCTION__
__NAMESPACE_BEGIN__
dnl
dnl The implementation:
dnl
__CPPNAME__::__CPPNAME__`'(const __CPPNAME__& other) noexcept
:
gobject_(other.gobject_)
{
}
__CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& other) noexcept
{
gobject_ = other.gobject_;
return *this;
}
__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& other) noexcept
:
gobject_(std::move(other.gobject_))
{
//We could wipe other.gobject_ via memset,
//but that is not really necessary:
//other.gobject_ = nullptr;
}
__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__`'&& other) noexcept
{
gobject_ = std::move(other.gobject_);
return *this;
}
dnl // static
dnl const __CNAME__ __CPPNAME__::gobject_initializer_ = { 0, };
dnl
// static
GType __CPPNAME__::get_type()
{
return _GET_TYPE_FUNC(__CNAME__);
}
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',,`dnl else
__CPPNAME__::__CPPNAME__`'()
{
std::memset`'(&gobject_, 0, sizeof(__CNAME__));
}
')dnl
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else
__CPPNAME__::__CPPNAME__`'(const __CNAME__* gobject)
{
if(gobject)
gobject_ = *gobject;
else
std::memset`'(&gobject_, 0, sizeof(__CNAME__));
}
')dnl
_IMPORT(SECTION_CC)
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl
dnl The actual class, e.g. Gtk::TreeIter, declaration:
dnl
_IMPORT(SECTION_CLASS1)
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = __CPPNAME__;
using BaseObjectType = __CNAME__;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
__CPPNAME__`'(const __CPPNAME__& other) noexcept;
__CPPNAME__& operator=(const __CPPNAME__& other) noexcept;
__CPPNAME__`'(__CPPNAME__&& other) noexcept;
__CPPNAME__& operator=(__CPPNAME__&& other) noexcept;
/** Get the GType for this class, for use with the underlying GObject type system.
*/
static GType get_type() G_GNUC_CONST;
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',,`dnl else
__CPPNAME__`'();
')dnl
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else
explicit __CPPNAME__`'(const __CNAME__* gobject); // always takes a copy
')dnl
///Provides access to the underlying C instance.
__CNAME__* gobj() { return &gobject_; }
///Provides access to the underlying C instance.
const __CNAME__* gobj() const { return &gobject_; }
protected:
__CNAME__ gobject_;
dnl static const __CNAME__ gobject_initializer_;
private:
_IMPORT(SECTION_CLASS2)
')

View File

@@ -0,0 +1,54 @@
dnl $Id$
dnl
dnl _CLASS_GENERIC(LayoutIter, PangoLayoutIter)
dnl
define(`_CLASS_GENERIC',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
_POP()
_SECTION(SECTION_CLASS2)
') dnl End of _CLASS_GENERIC.
dnl
dnl _END_CLASS_GENERIC()
dnl denotes the end of a class
dnl
define(`_END_CLASS_GENERIC',`
_SECTION(SECTION_SRC_GENERATED)
__NAMESPACE_BEGIN__
dnl The implementation:
_IMPORT(SECTION_CC)
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl
dnl The actual class, e.g. Pango::FontDescription, declaration:
dnl
_IMPORT(SECTION_CLASS1)
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = __CPPNAME__;
using BaseObjectType = __CNAME__;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
private:
_IMPORT(SECTION_CLASS2)
')

View File

@@ -0,0 +1,323 @@
dnl $Id$
define(`_CLASS_GOBJECT',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
define(`__CCAST__',`$3')
define(`__BASE__',_LOWER(__CPPNAME__))
define(`__CPPPARENT__',`$4')
define(`__CPARENT__',`$5')
define(`__PCAST__',`($5*)')
dnl Some C types, e.g. GdkWindow or GdkPixmap, are a typedef to their base type,
dnl rather than the real instance type. That is really ugly, yes. We get around
dnl the problem by supporting optional __REAL_* arguments to this macro.
define(`__REAL_CNAME__',ifelse(`$6',,__CNAME__,`$6'))
define(`__REAL_CPARENT__',ifelse(`$7',,__CPARENT__,`$7'))
_POP()
_SECTION(SECTION_CLASS2)
') dnl end of _CLASS_GOBJECT
dnl Widget and Object, and some others, have custom-written destructor implementations:
define(`_CUSTOM_DTOR',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_DTOR__',`$1')
_POP()
')
dnl For classes that need custom code for move operations.
define(`_CUSTOM_MOVE_OPERATIONS', `dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_MOVE_OPERATIONS__',`$1')
_POP()
')
dnl For classes that need custom code in their cast and construct_params
dnl constructor.
define(`_CUSTOM_CTOR_CAST',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
_POP()
')
dnl Gdk::Pixmap_Class::wrap_new() needs a custom implementation, in order
dnl to create a Gdk::Bitmap object if appropriate. See comments there.
define(`_CUSTOM_WRAP_NEW',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_WRAP_NEW__',`1')
_POP()
')
dnl Gnome::Canvas::CanvasAA::CanvasAA() needs access to the
dnl normally-private canvas_class_ member variable. See comments there.
define(`_GMMPROC_PROTECTED_GCLASS',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_PROTECTED_GCLASS__',`1')
_POP()
')
dnl Some of the Gdk types are actually direct typedefs of their base type.
dnl This means that 2 wrap functions would have the same argument.
dnl define(`_NO_WRAP_FUNCTION',`dnl
dnl _PUSH()
dnl Define this macro to be tested for later.
dnl define(`__BOOL_NO_WRAP_FUNCTION__',`$1')
dnl _POP()
dnl ')
dnl In case a class needs to write its own implementation of its Glib::wrap()
dnl function. The function will be declared in the header, but the body is not
dnl generated.
define(`_CUSTOM_WRAP_FUNCTION',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_WRAP_FUNCTION__',`$1')
_POP()
')
dnl Some gobjects actually derive from GInitiallyUnowned, which does some odd reference-counting that is useful to C coders.
dnl We don't want to expose that base class in our API,
dnl but we do want to reverse what it does:
define(`_DERIVES_INITIALLY_UNOWNED',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_DERIVES_INITIALLY_UNOWNED__',`$1')
_POP()
')
dnl
dnl _CREATE_METHOD(args_type_and_name_hpp, args_type_and_name_cpp,args_name_only);
dnl
define(`_CREATE_METHOD',`
static Glib::RefPtr<`'__CPPNAME__`'> create(`'$1`');
_PUSH(SECTION_CC)
Glib::RefPtr<`'__CPPNAME__`'> __CPPNAME__`'::create(`'$2`')
{
return Glib::RefPtr<`'__CPPNAME__`'>( new __CPPNAME__`'(`'$3`') );
}
_POP()
')
dnl
dnl _END_CLASS_GOBJECT()
dnl denotes the end of a class
dnl
define(`_END_CLASS_GOBJECT',`
_SECTION(SECTION_HEADER1)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl
_STRUCT_PROTOTYPE()
')dnl
#ifndef DOXYGEN_SHOULD_SKIP_THIS
__NAMESPACE_BEGIN__ class __CPPNAME__`'_Class; __NAMESPACE_END__
#endif //DOXYGEN_SHOULD_SKIP_THIS
_SECTION(SECTION_HEADER3)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl
namespace Glib
{
/** A Glib::wrap() method for this object.
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
* @result A C++ instance that wraps this C instance.
*
* @relates __NAMESPACE__::__CPPNAME__
*/
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__REAL_CNAME__`'* object, bool take_copy = false);
}
')dnl
dnl
dnl
_SECTION(SECTION_PHEADER)
#include <glibmm/class.h>
__NAMESPACE_BEGIN__
_PH_CLASS_DECLARATION()
__NAMESPACE_END__
_SECTION(SECTION_SRC_GENERATED)
ifdef(`__BOOL_CUSTOM_WRAP_FUNCTION__',`dnl
',`dnl else
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
namespace Glib
{
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__REAL_CNAME__`'* object, bool take_copy)
{
return Glib::RefPtr<__NAMESPACE__::__CPPNAME__>( dynamic_cast<__NAMESPACE__::__CPPNAME__*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
//We use dynamic_cast<> in case of multiple inheritance.
}
} /* namespace Glib */
')dnl endif
')dnl endif
__NAMESPACE_BEGIN__
/* The *_Class implementation: */
_PCC_CLASS_IMPLEMENTATION()
m4_ifdef(`__BOOL_CUSTOM_WRAP_NEW__',,`dnl else
Glib::ObjectBase* __CPPNAME__`'_Class::wrap_new(GObject* object)
{
return new __CPPNAME__`'((__CNAME__*)`'object);
}
')dnl endif
/* The implementation: */
__CNAME__* __CPPNAME__::gobj_copy()
{
reference();
return gobj();
}
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',`dnl
',`dnl
__CPPNAME__::__CPPNAME__`'(const Glib::ConstructParams& construct_params)
:
__CPPPARENT__`'(construct_params)
{
_INITIALLY_UNOWNED_SINK
}
__CPPNAME__::__CPPNAME__`'(__CNAME__* castitem)
:
__CPPPARENT__`'(__PCAST__`'(castitem))
{}
')dnl
ifdef(`__BOOL_CUSTOM_MOVE_OPERATIONS__',`dnl
',`dnl
__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& src) noexcept
: __CPPPARENT__`'(std::move(src))
_IMPORT(SECTION_CC_MOVE_CONSTRUCTOR_INTERFACES)
{}
__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__&& src) noexcept
{
__CPPPARENT__::operator=`'(std::move(src));
_IMPORT(SECTION_CC_MOVE_ASSIGNMENT_OPERATOR_INTERFACES)
return *this;
}
')dnl
ifdef(`__BOOL_CUSTOM_DTOR__',`dnl
',`dnl
__CPPNAME__::~__CPPNAME__`'() noexcept
{}
')dnl
_CC_CLASS_IMPLEMENTATION()
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl The actual class, e.g. Gtk::Widget, declaration:
dnl _IMPORT(SECTION_H_SIGNALPROXIES_CUSTOM)
_IMPORT(SECTION_CLASS1)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
public:
using CppObjectType = __CPPNAME__;
using CppClassType = __CPPNAME__`'_Class;
using BaseObjectType = __CNAME__;
using BaseClassType = __REAL_CNAME__`'Class;
// noncopyable
__CPPNAME__`'(const __CPPNAME__&) = delete;
__CPPNAME__& operator=(const __CPPNAME__&) = delete;
m4_ifdef(`__BOOL_PROTECTED_GCLASS__',
`protected:',`dnl else
private:')dnl endif
friend class __CPPNAME__`'_Class;
static CppClassType `'__BASE__`'_class_;
protected:
explicit __CPPNAME__`'(const Glib::ConstructParams& construct_params);
explicit __CPPNAME__`'(__CNAME__* castitem);
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
public:
ifdef(`__BOOL_CUSTOM_MOVE_OPERATIONS__',`dnl
',`dnl
__CPPNAME__`'(__CPPNAME__&& src) noexcept;
__CPPNAME__& operator=(__CPPNAME__&& src) noexcept;
')dnl
_IMPORT(SECTION_DTOR_DOCUMENTATION)
~__CPPNAME__`'() noexcept override;
/** Get the GType for this class, for use with the underlying GObject type system.
*/
static GType get_type() G_GNUC_CONST;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
static GType get_type(GTypeModule* module) G_GNUC_CONST;
',`')
static GType get_base_type() G_GNUC_CONST;
#endif
///Provides access to the underlying C GObject.
__CNAME__* gobj() { return reinterpret_cast<__CNAME__*>(gobject_); }
///Provides access to the underlying C GObject.
const __CNAME__* gobj() const { return reinterpret_cast<__CNAME__*>(gobject_); }
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
__CNAME__* gobj_copy();
private:
_IMPORT(SECTION_CLASS2)
public:
_H_VFUNCS_AND_SIGNALS()
')

View File

@@ -0,0 +1,311 @@
dnl $Id$
define(`_CLASS_INTERFACE',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
define(`__CCAST__',`$3')
define(`__CCLASS__',`$4') dnl SomethingIface or SomethingClass, both suffixes are used.
define(`__BASE__',_LOWER(__CPPNAME__))
define(`__CPPPARENT__',m4_ifelse($5,`',`Glib::Interface',$5)) #Optional parameter.
define(`__CPARENT__',m4_ifelse($6,`',`GObject',$6)) #Optional parameter.
define(`__PCAST__',`(__CPARENT__`'*)')
define(`__BOOL_IS_INTERFACE__',`1')
dnl For classes that need custom code in their cast constructor.
define(`_CUSTOM_CTOR_CAST',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
_POP()
')
_POP()
_SECTION(SECTION_CLASS2)
') dnl end of _CLASS_INTERFACE
dnl Some of the Gdk types are actually direct typedefs of their base type.
dnl This means that 2 wrap functions would have the same argument.
dnl define(`_NO_WRAP_FUNCTION',`dnl
dnl _PUSH()
dnl Define this macro to be tested for later.
dnl define(`__BOOL_NO_WRAP_FUNCTION__',`$1')
dnl _POP()
dnl ')
dnl
dnl
dnl
define(`_PH_CLASS_DECLARATION_INTERFACE',`dnl
class __CPPNAME__`'_Class : public __CPPPARENT__`'_Class
{
public:
using CppObjectType = __CPPNAME__;
using BaseObjectType = __CNAME__;
using BaseClassType = __CCLASS__;
using CppClassParent = __CPPPARENT__`'_Class;
friend class __CPPNAME__;
const Glib::Interface_Class& init();
static void iface_init_function(void* g_iface, void* iface_data);
static Glib::ObjectBase* wrap_new(GObject*);
protected:
//Callbacks (default signal handlers):
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
//You could prevent the original default signal handlers being called by overriding the *_impl method.
_IMPORT(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
//Callbacks (virtual functions):
_IMPORT(SECTION_PH_VFUNCS)
};
')
dnl
dnl
dnl
define(`_PCC_CLASS_IMPLEMENTATION_INTERFACE',`dnl
const Glib::Interface_Class& __CPPNAME__`'_Class::init()
{
if(!gtype_) // create the GType if necessary
{
// Glib::Interface_Class has to know the interface init function
// in order to add interfaces to implementing types.
class_init_func_ = &__CPPNAME__`'_Class::iface_init_function;
// We can not derive from another interface, and it is not necessary anyway.
gtype_ = _LOWER(__CCAST__)_get_type();
}
return *this;
}
void __CPPNAME__`'_Class::iface_init_function(void* g_iface, void*)
{
const auto klass = static_cast<BaseClassType*>(g_iface);
//This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
//This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
g_assert(klass != nullptr);
_IMPORT(SECTION_PCC_CLASS_INIT_VFUNCS)
_IMPORT(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
}
_IMPORT(SECTION_PCC_VFUNCS)
_IMPORT(SECTION_PCC_DEFAULT_SIGNAL_HANDLERS)
')
dnl
dnl _END_CLASS_INTERFACE()
dnl denotes the end of a class
dnl
define(`_END_CLASS_INTERFACE',`
_SECTION(SECTION_HEADER1)
_STRUCT_PROTOTYPE()
#ifndef DOXYGEN_SHOULD_SKIP_THIS
__NAMESPACE_BEGIN__ class __CPPNAME__`'_Class; __NAMESPACE_END__
#endif // DOXYGEN_SHOULD_SKIP_THIS
_SECTION(SECTION_HEADER3)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl
namespace Glib
{
/** A Glib::wrap() method for this object.
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
* @result A C++ instance that wraps this C instance.
*
* @relates __NAMESPACE__::__CPPNAME__
*/
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__CNAME__`'* object, bool take_copy = false);
} // namespace Glib
')dnl
dnl
dnl
_SECTION(SECTION_PHEADER)
#include <glibmm/private/interface_p.h>
__NAMESPACE_BEGIN__
_PH_CLASS_DECLARATION_INTERFACE()
__NAMESPACE_END__
_SECTION(SECTION_SRC_GENERATED)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
namespace Glib
{
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__CNAME__`'* object, bool take_copy)
{
return Glib::RefPtr<__NAMESPACE__::__CPPNAME__>( dynamic_cast<__NAMESPACE__::__CPPNAME__*> (Glib::wrap_auto_interface<__NAMESPACE__::__CPPNAME__> ((GObject*)(object), take_copy)) );
//We use dynamic_cast<> in case of multiple inheritance.
}
} // namespace Glib
')dnl endif
__NAMESPACE_BEGIN__
/* The *_Class implementation: */
_PCC_CLASS_IMPLEMENTATION_INTERFACE()
Glib::ObjectBase* __CPPNAME__`'_Class::wrap_new(GObject* object)
{
return new __CPPNAME__`'((__CNAME__*)`'(object));
}
/* The implementation: */
__CPPNAME__::__CPPNAME__`'()
:
__CPPPARENT__`'(__BASE__`'_class_.init())
{}
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',`dnl
',`dnl
__CPPNAME__::__CPPNAME__`'(__CNAME__* castitem)
:
__CPPPARENT__`'(__PCAST__`'(castitem))
{}
')dnl
__CPPNAME__::__CPPNAME__`'(const Glib::Interface_Class& interface_class)
: __CPPPARENT__`'(interface_class)
{
}
__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& src) noexcept
: __CPPPARENT__`'(std::move(src))
{}
__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__&& src) noexcept
{
__CPPPARENT__::operator=`'(std::move(src));
return *this;
}
__CPPNAME__::~__CPPNAME__`'() noexcept
{}
// static
void __CPPNAME__`'::add_interface(GType gtype_implementer)
{
__BASE__`'_class_.init().add_interface(gtype_implementer);
}
_CC_CLASS_IMPLEMENTATION()
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl The actual class, e.g. Gtk::Widget, declaration:
dnl _IMPORT(SECTION_H_SIGNALPROXIES_CUSTOM)
_IMPORT(SECTION_CLASS1)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
public:
using CppObjectType = __CPPNAME__;
using CppClassType = __CPPNAME__`'_Class;
using BaseObjectType = __CNAME__;
using BaseClassType = __CCLASS__;
// noncopyable
__CPPNAME__`'(const __CPPNAME__&) = delete;
__CPPNAME__& operator=(const __CPPNAME__&) = delete;
private:
friend class __CPPNAME__`'_Class;
static CppClassType `'__BASE__`'_class_;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
protected:
/**
* You should derive from this class to use it.
*/
__CPPNAME__`'();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/** Called by constructors of derived classes. Provide the result of
* the Class init() function to ensure that it is properly
* initialized.
*
* @param interface_class The Class object for the derived type.
*/
explicit __CPPNAME__`'(const Glib::Interface_Class& interface_class);
public:
// This is public so that C++ wrapper instances can be
// created for C instances of unwrapped types.
// For instance, if an unexpected C type implements the C interface.
explicit __CPPNAME__`'(__CNAME__* castitem);
protected:
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
public:
__CPPNAME__`'(__CPPNAME__&& src) noexcept;
__CPPNAME__& operator=(__CPPNAME__&& src) noexcept;
_IMPORT(SECTION_DTOR_DOCUMENTATION)
~__CPPNAME__`'() noexcept override;
static void add_interface(GType gtype_implementer);
/** Get the GType for this class, for use with the underlying GObject type system.
*/
static GType get_type() G_GNUC_CONST;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
static GType get_base_type() G_GNUC_CONST;
#endif
///Provides access to the underlying C GObject.
__CNAME__* gobj() { return reinterpret_cast<__CNAME__*>(gobject_); }
///Provides access to the underlying C GObject.
const __CNAME__* gobj() const { return reinterpret_cast<__CNAME__*>(gobject_); }
private:
_IMPORT(SECTION_CLASS2)
public:
_H_VFUNCS_AND_SIGNALS()
')

View File

@@ -0,0 +1,233 @@
dnl $Id$
dnl
dnl _CLASS_OPAQUE_COPYABLE(Region, GdkRegion, gdk_region_new, gdk_region_copy, gdk_region_destroy)
dnl
define(`_CLASS_OPAQUE_COPYABLE',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
define(`__OPAQUE_FUNC_NEW',`$3')
define(`__OPAQUE_FUNC_COPY',`$4')
define(`__OPAQUE_FUNC_FREE',`$5')
define(`_CUSTOM_DEFAULT_CTOR',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_DEFAULT_CTOR__',`$1')
_POP()
')
define(`_CUSTOM_CTOR_CAST',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
_POP()
')
_POP()
_SECTION(SECTION_CLASS2)
') dnl End of _CLASS_OPAQUE_COPYABLE.
dnl
dnl _END_CLASS_OPAQUE_COPYABLE()
dnl denotes the end of a class
dnl
define(`_END_CLASS_OPAQUE_COPYABLE',`
_SECTION(SECTION_HEADER3)
__NAMESPACE_BEGIN__
/** @relates __NAMESPACE__::__CPPNAME__
* @param lhs The left-hand side
* @param rhs The right-hand side
*/
inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs) noexcept
{ lhs.swap(rhs); }
__NAMESPACE_END__
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
namespace Glib
{
/** A Glib::wrap() method for this object.
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
* @result A C++ instance that wraps this C instance.
*
* @relates __NAMESPACE__::__CPPNAME__
*/
__NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy = false);
} // namespace Glib
')dnl endif __BOOL_NO_WRAP_FUNCTION__
_SECTION(SECTION_SRC_GENERATED)
ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
',`dnl else
namespace Glib
{
__NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy /* = false */)
{
return __NAMESPACE__::__CPPNAME__`'(object, take_copy);
}
} // namespace Glib
')dnl endif
__NAMESPACE_BEGIN__
dnl
dnl The implementation:
dnl
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
',`dnl else
__CPPNAME__::__CPPNAME__`'()
:
ifelse(__OPAQUE_FUNC_NEW,NONE,`dnl
gobject_ (nullptr) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
',`dnl else
gobject_ (__OPAQUE_FUNC_NEW`'())
')dnl
{}
')dnl endif __BOOL_CUSTOM_DEFAULT_CTOR__
__CPPNAME__::__CPPNAME__`'(const __CPPNAME__& src)
:
gobject_ ((src.gobject_) ? __OPAQUE_FUNC_COPY`'(src.gobject_) : nullptr)
{}
ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else
__CPPNAME__::__CPPNAME__`'(__CNAME__* castitem, bool make_a_copy /* = false */)
{
if(!make_a_copy)
{
// It was given to us by a function which has already made a copy for us to keep.
gobject_ = castitem;
}
else
{
// We are probably getting it via direct access to a struct,
// so we can not just take it - we have to take a copy of it.
if(castitem)
gobject_ = __OPAQUE_FUNC_COPY`'(castitem);
else
gobject_ = nullptr;
}
}
')
ifelse(__OPAQUE_FUNC_COPY,NONE,`dnl
',`dnl else
__CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& src)
{
const auto new_gobject = (src.gobject_) ? __OPAQUE_FUNC_COPY`'(src.gobject_) : nullptr;
if(gobject_)
__OPAQUE_FUNC_FREE`'(gobject_);
gobject_ = new_gobject;
return *this;
}
')dnl
__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& other) noexcept
:
gobject_(other.gobject_)
{
other.gobject_ = nullptr;
}
__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__`'&& other) noexcept
{
__CPPNAME__ temp (other);
swap(temp);
return *this;
}
__CPPNAME__::~__CPPNAME__`'() noexcept
{
if(gobject_)
__OPAQUE_FUNC_FREE`'(gobject_);
}
void __CPPNAME__::swap(__CPPNAME__& other) noexcept
{
std::swap(gobject_, other.gobject_);
}
__CNAME__* __CPPNAME__::gobj_copy() const
{
return __OPAQUE_FUNC_COPY`'(gobject_);
}
_IMPORT(SECTION_CC)
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl
dnl The actual class, e.g. Pango::FontDescription, declaration:
dnl
_IMPORT(SECTION_CLASS1)
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = __CPPNAME__;
using BaseObjectType = __CNAME__;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
',`dnl else
/** Constructs an invalid object.
* E.g. for output arguments to methods. There is not much you can do with
* the object before it has been assigned a valid value.
*/
__CPPNAME__`'();
')dnl
// Use make_a_copy=true when getting it directly from a struct.
explicit __CPPNAME__`'(__CNAME__* castitem, bool make_a_copy = false);
__CPPNAME__`'(const __CPPNAME__& src);
__CPPNAME__& operator=(const __CPPNAME__& src);
__CPPNAME__`'(__CPPNAME__&& other) noexcept;
__CPPNAME__& operator=(__CPPNAME__&& other) noexcept;
_IMPORT(SECTION_DTOR_DOCUMENTATION)
~__CPPNAME__`'() noexcept;
void swap(__CPPNAME__& other) noexcept;
__CNAME__* gobj() { return gobject_; }
const __CNAME__* gobj() const { return gobject_; }
///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
__CNAME__* gobj_copy() const;
protected:
__CNAME__* gobject_;
private:
_IMPORT(SECTION_CLASS2)
')

View File

@@ -0,0 +1,182 @@
dnl $Id$
dnl
dnl _CLASS_OPAQUE_REFCOUNTED(Coverage, PangoCoverage, pango_coverage_new, pango_coverage_ref, pango_coverage_unref)
dnl
define(`_CLASS_OPAQUE_REFCOUNTED',`dnl
_PUSH()
dnl
dnl Define the args for later macros
define(`__CPPNAME__',`$1')
define(`__CNAME__',`$2')
define(`__OPAQUE_FUNC_NEW',`$3')
define(`__OPAQUE_FUNC_REF',`$4')
define(`__OPAQUE_FUNC_UNREF',`$5')
_POP()
_SECTION(SECTION_CLASS2)
')dnl End of _CLASS_OPAQUE_REFCOUNTED.
dnl
dnl _END_CLASS_OPAQUE_REFCOUNTED()
dnl denotes the end of a class
dnl
define(`_END_CLASS_OPAQUE_REFCOUNTED',`
_SECTION(SECTION_HEADER3)
namespace Glib
{
/** A Glib::wrap() method for this object.
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
* @result A C++ instance that wraps this C instance.
*
* @relates __NAMESPACE__::__CPPNAME__
*/
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__CNAME__* object, bool take_copy = false);
} // namespace Glib
_SECTION(SECTION_SRC_GENERATED)
/* Why reinterpret_cast<__CPPNAME__*>(gobject) is needed:
*
* A __CPPNAME__ instance is in fact always a __CNAME__ instance.
* Unfortunately, __CNAME__ cannot be a member of __CPPNAME__,
* because it is an opaque struct. Also, the C interface does not provide
* any hooks to install a destroy notification handler, thus we cannot
* wrap it dynamically either.
*
* The cast works because __CPPNAME__ does not have any member data, and
* it is impossible to derive from it. This is ensured by using final on the
* class and by using = delete on the default constructor.
*/
namespace Glib
{
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__CNAME__* object, bool take_copy)
{
if(take_copy && object)
__OPAQUE_FUNC_REF`'(object);
// See the comment at the top of this file, if you want to know why the cast works.
return Glib::RefPtr<__NAMESPACE__::__CPPNAME__>(reinterpret_cast<__NAMESPACE__::__CPPNAME__*>(object));
}
} // namespace Glib
__NAMESPACE_BEGIN__
dnl
dnl The implementation:
dnl
ifelse(__OPAQUE_FUNC_NEW,NONE,`dnl
',`dnl else
// static
Glib::RefPtr<__CPPNAME__> __CPPNAME__::create()
{
// See the comment at the top of this file, if you want to know why the cast works.
return Glib::RefPtr<__CPPNAME__>(reinterpret_cast<__CPPNAME__*>(__OPAQUE_FUNC_NEW`'()));
}
')dnl endif __OPAQUE_FUNC_NEW
void __CPPNAME__::reference() const
{
// See the comment at the top of this file, if you want to know why the cast works.
__OPAQUE_FUNC_REF`'(reinterpret_cast<__CNAME__*>(const_cast<__CPPNAME__*>(this)));
}
void __CPPNAME__::unreference() const
{
// See the comment at the top of this file, if you want to know why the cast works.
__OPAQUE_FUNC_UNREF`'(reinterpret_cast<__CNAME__*>(const_cast<__CPPNAME__*>(this)));
}
__CNAME__* __CPPNAME__::gobj()
{
// See the comment at the top of this file, if you want to know why the cast works.
return reinterpret_cast<__CNAME__*>(this);
}
const __CNAME__* __CPPNAME__::gobj() const
{
// See the comment at the top of this file, if you want to know why the cast works.
return reinterpret_cast<const __CNAME__*>(this);
}
__CNAME__* __CPPNAME__::gobj_copy() const
{
// See the comment at the top of this file, if you want to know why the cast works.
const auto gobject = reinterpret_cast<__CNAME__*>(const_cast<__CPPNAME__*>(this));
__OPAQUE_FUNC_REF`'(gobject);
return gobject;
}
_IMPORT(SECTION_CC)
__NAMESPACE_END__
dnl
dnl
dnl
dnl
_POP()
dnl
dnl
dnl The actual class, e.g. Pango::FontDescription, declaration:
dnl
_IMPORT(SECTION_CLASS1)
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = __CPPNAME__;
using BaseObjectType = __CNAME__;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
ifelse(__OPAQUE_FUNC_NEW,NONE,`dnl
',`dnl else
static Glib::RefPtr<__CPPNAME__> create();
')dnl endif __OPAQUE_FUNC_NEW
/** Increment the reference count for this object.
* You should never need to do this manually - use the object via a RefPtr instead.
*/
void reference() const;
/** Decrement the reference count for this object.
* You should never need to do this manually - use the object via a RefPtr instead.
*/
void unreference() const;
///Provides access to the underlying C instance.
__CNAME__* gobj();
///Provides access to the underlying C instance.
const __CNAME__* gobj() const;
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
__CNAME__* gobj_copy() const;
__CPPNAME__`'() = delete;
// noncopyable
__CPPNAME__`'(const __CPPNAME__&) = delete;
__CPPNAME__& operator=(const __CPPNAME__&) = delete;
protected:
// Do not derive this. __NAMESPACE__::__CPPNAME__ can neither be constructed nor deleted.
void operator delete(void*, std::size_t);
private:
_IMPORT(SECTION_CLASS2)
')

View File

@@ -0,0 +1,344 @@
dnl $Id$
dnl This is just a hint to generate_wrap_init.pl.
dnl It does not generate any code in the actual .h and .cc file.
m4_define(`_GMMPROC_EXTRA_NAMESPACE',`')
define(`_CLASS_START',`dnl
_PUSH(SECTION_CLASS1)
')
dnl
dnl
dnl
define(`_H_VFUNCS_AND_SIGNALS',`dnl
public:
//C++ methods used to invoke GTK+ virtual functions:
_IMPORT(SECTION_H_VFUNCS_CPPWRAPPER)
protected:
//GTK+ Virtual Functions (override these to change behaviour):
_IMPORT(SECTION_H_VFUNCS)
//Default Signal Handlers::
_IMPORT(SECTION_H_DEFAULT_SIGNAL_HANDLERS)
')
dnl
dnl
dnl
define(`_IMPLEMENTS_INTERFACE_CC',`dnl
_PUSH(SECTION_CC_IMPLEMENTS_INTERFACES)
ifelse(`$2',,,`#ifdef $2'
)dnl
$1`'::add_interface(get_type());
ifelse(`$2',,,`
#endif // $2
')dnl
_POP()
_PUSH(SECTION_CC_MOVE_CONSTRUCTOR_INTERFACES)
ifelse(`$2',,,`#ifdef $2'
)dnl
, $1`'(std::move(src))
ifelse(`$2',,,`
#endif // $2
')dnl
_POP()
_PUSH(SECTION_CC_MOVE_ASSIGNMENT_OPERATOR_INTERFACES)
ifelse(`$2',,,`#ifdef $2'
)dnl
$1`'::operator=(std::move(src));
ifelse(`$2',,,`
#endif // $2
')dnl
_POP()
')
dnl GVolumeMonitor can be broken/impeded by defining a sub-type.
define(`_DO_NOT_DERIVE_GTYPE',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_DO_NOT_DERIVE_GTYPE__',`$1')
_POP()
')
dnl GVolumeMonitor can be broken/impeded by defining a sub-type.
define(`_DYNAMIC_GTYPE_REGISTRATION',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`$1')
_POP()
')
dnl This macro inserts the supplied text as a Doxygen comment block before the
dnl automatically generated declaration of a class' destructor. The inner
dnl m4_ifelse() attempts to remove double quotes before and after the text if
dnl it is a single line. If it is not, it returns the supplied lines, removing
dnl trailing spaces from each of them (with an m4_patsubst()). The following
dnl outer m4_patsubst() prepends possible multiple lines below the first one
dnl with ' * ' by assuming that these lines are preceded by at least one space.
dnl Finally, the outer m4_patsubst() inserts spaces after commas which are
dnl removed by m4 in the processing.
dnl
dnl
dnl
dnl
define(`_DOCUMENT_DTOR',`dnl
_PUSH(SECTION_DTOR_DOCUMENTATION)
m4_ifelse(`$*',,,`dnl
m4_patsubst(`m4_patsubst(`/** m4_ifelse(m4_regexp(`$*',`".*"'),-1,`m4_patsubst(`$*',`\s*$')',`m4_regexp(`$*',`"\s*\(.*\)\(\S\)\s*"',`\1\2')')',`^\s+',` * ')',`,',`, ')
*/
')dnl
_POP()
')
dnl
dnl
dnl
define(`_PH_CLASS_DECLARATION',`dnl
class __CPPNAME__`'_Class : public Glib::Class
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = __CPPNAME__;
using BaseObjectType = __REAL_CNAME__;
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
using CppClassParent = __CPPPARENT__`'_Class;
',`dnl
using BaseClassType = __REAL_CNAME__`'Class;
using CppClassParent = __CPPPARENT__`'_Class;
using BaseClassParent = __REAL_CPARENT__`'Class;
')dnl
friend class __CPPNAME__;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
const Glib::Class& init();
ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
const Glib::Class& init(GTypeModule* module);
',`')
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
',`dnl
static void class_init_function(void* g_class, void* class_data);
')dnl
static Glib::ObjectBase* wrap_new(GObject*);
protected:
//Callbacks (default signal handlers):
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
//You could prevent the original default signal handlers being called by overriding the *_impl method.
_IMPORT(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
//Callbacks (virtual functions):
_IMPORT(SECTION_PH_VFUNCS)
};
')
dnl
dnl
dnl
define(`_PCC_CLASS_IMPLEMENTATION',`dnl
const Glib::Class& __CPPNAME__`'_Class::init()
{
if(!gtype_) // create the GType if necessary
{
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
// Do not derive a GType, or use a derived klass:
gtype_ = CppClassParent::CppObjectType::get_type();
',`dnl
// Glib::Class has to know the class init function to clone custom types.
class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
// This is actually just optimized away, apparently with no harm.
// Make sure that the parent type has been created.
//CppClassParent::CppObjectType::get_type();
// Create the wrapper type, with the same class/instance size as the base type.
register_derived_type(_LOWER(__CCAST__)_get_type());
// Add derived versions of interfaces, if the C type implements any interfaces:
_IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
')
}
return *this;
}
ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
const Glib::Class& __CPPNAME__`'_Class::init(GTypeModule* module)
{
if(!gtype_) // create the GType if necessary
{
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
// Do not derive a GType, or use a derived klass:
gtype_ = CppClassParent::CppObjectType::get_type();
',`dnl
// Glib::Class has to know the class init function to clone custom types.
class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
// This is actually just optimized away, apparently with no harm.
// Make sure that the parent type has been created.
//CppClassParent::CppObjectType::get_type();
// Create the wrapper type, with the same class/instance size as the base type.
register_derived_type(_LOWER(__CCAST__)_get_type(), module);
// Add derived versions of interfaces, if the C type implements any interfaces:
_IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
')
}
return *this;
',`')
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
',`dnl
void __CPPNAME__`'_Class::class_init_function(void* g_class, void* class_data)
{
const auto klass = static_cast<BaseClassType*>(g_class);
CppClassParent::class_init_function(klass, class_data);
_IMPORT(SECTION_PCC_CLASS_INIT_VFUNCS)
_IMPORT(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
}
')dnl
_IMPORT(SECTION_PCC_VFUNCS)
_IMPORT(SECTION_PCC_DEFAULT_SIGNAL_HANDLERS)
')
dnl
dnl
dnl
define(`_CC_CLASS_IMPLEMENTATION',`dnl
__CPPNAME__::CppClassType __CPPNAME__::`'__BASE__`'_class_; // initialize static member
GType __CPPNAME__::get_type()
{
return __BASE__`'_class_.init().get_type();
}
ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
GType __CPPNAME__::get_type(GTypeModule* module)
{
return __BASE__`'_class_.init(module).get_type();
}
'dnl
,`'dnl
)
GType __CPPNAME__::get_base_type()
{
return _LOWER(__CCAST__)_get_type();
}
_IMPORT(SECTION_CC)
dnl _IMPORT(SECTION_CC_SIGNALPROXIES_CUSTOM)
_IMPORT(SECTION_CC_SIGNALPROXIES)
_IMPORT(SECTION_CC_PROPERTYPROXIES)
_IMPORT(SECTION_CC_DEFAULT_SIGNAL_HANDLERS)
_IMPORT(SECTION_CC_VFUNCS)
_IMPORT(SECTION_CC_VFUNCS_CPPWRAPPER)
')
dnl _PARENT_GCLASS_FROM_OBJECT(object_instance_name)
define(`_PARENT_GCLASS_FROM_OBJECT',`dnl
g_type_class_peek_parent`'(G_OBJECT_GET_CLASS`'($1)) // Get the parent class of the object class (The original underlying C class).
')
dnl _IFACE_PARENT_FROM_OBJECT(object_instance_name)
define(`_IFACE_PARENT_FROM_OBJECT',`dnl
g_type_interface_peek_parent`'( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek`'(G_OBJECT_GET_CLASS`'($1), CppObjectType::get_type`'()) // Get the interface.
)dnl
')
dnl Bonobo doesn't use the "typedef struct _somestruct struct" system.
define(`_STRUCT_NOT_HIDDEN',`dnl
_PUSH()
dnl Define this macro to be tested for later.
define(`__BOOL_STRUCT_NOT_HIDDEN__',`$1')
_POP()
')
dnl _STRUCT_PROTOTYPE()
define(`_STRUCT_PROTOTYPE',`dnl
#ifndef DOXYGEN_SHOULD_SKIP_THIS
ifdef(`__BOOL_STRUCT_NOT_HIDDEN__',`dnl
',`dnl
using __CNAME__ = struct _`'__CNAME__;
using __CNAME__`'Class = struct _`'__CNAME__`'Class;
')dnl
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
undefine(`__BOOL_STRUCT_NOT_HIDDEN__')dnl
')
dnl _GTKMMPROC_WIN32_NO_WRAP
dnl Just process it to remove it from the generated file.
dnl generate_wrap_init.pl will look for this in the original .hg file.
dnl
define(`_GTKMMPROC_WIN32_NO_WRAP', dnl
`//This is not available on Win32.
//This source file will not be compiled on Win32,
//and no class defined in it will be registered by wrap_init`'().
')dnl
dnl _GMMPROC_WRAP_CONDITIONALLY(preprocessor_if/ifdef/ifndef_directive_without_#)
dnl Just process it to remove it from the generated file.
dnl generate_wrap_init.pl will look for this in the original .hg file.
dnl
dnl Example calls:
dnl _GMMPROC_WRAP_CONDITIONALLY(ifndef G_OS_WIN32) # Same as _GTKMMPROC_WIN32_NO_WRAP
dnl _GMMPROC_WRAP_CONDITIONALLY(ifdef GDK_WINDOWING_X11)
dnl _GMMPROC_WRAP_CONDITIONALLY(`if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_QUARTZ)')
dnl
define(`_GMMPROC_WRAP_CONDITIONALLY', dnl
`//This is available only #$1.
//Otherwise this source file will not be compiled,
//and no class defined in it will be registered by wrap_init`'().
')dnl
dnl _INCLUDE_IN_WRAP_INIT(file)
dnl Usually used in combination with _GMMPROC_WRAP_CONDITIONALLY.
dnl It does not generate any code in the .h and .cc files.
dnl generate_wrap_init.pl will look for this in the original .hg file.
dnl
define(`_INCLUDE_IN_WRAP_INIT',`')dnl
dnl _IS_DEPRECATED
dnl ifdef-out the whole .h and .cc files.
dnl generate_wrap_init.pl will look for this in the original .hg file.
define(`_IS_DEPRECATED',`dnl
_PUSH()
dnl Define this macro to be tested for later. See base.m4.
define(`__BOOL_DEPRECATED__',`$1')
_POP()
')
dnl _NO_WRAP_INIT_REGISTRATION
dnl Used to tag the classes in a file as one not be registered by the
dnl wrap_init() function (all the classes in the file will not be registered).
dnl This macro does not generate any code in the .h and .cc files.
dnl generate_wrap_init.pl will look for this in the original .hg file.
dnl
define(`_NO_WRAP_INIT_REGISTRATION',`')dnl

View File

@@ -0,0 +1,118 @@
dnl $Id$
define(`__OPERATOR_DECL',`dnl
/** @relates __NAMESPACE__::__CPPNAME__
* @param lhs The left-hand side
* @param rhs The right-hand side
* @result The result
*/
bool operator`'$1`'(const __CPPNAME__& lhs, const __CPPNAME__& rhs);
')
define(`__OPERATOR_IMPL',`dnl
bool operator`'$1`'(const __CPPNAME__& lhs, const __CPPNAME__& rhs)
{'
ifelse`'(`__UNCONST__',`unconst',`dnl
return ($2`'(const_cast<__CNAME__*>(lhs.gobj()), const_cast<__CNAME__*>(rhs.gobj())) $3);
',`dnl else
return ($2`'(lhs.gobj(), rhs.gobj()) $3);
')`dnl endif
}
')
dnl
dnl _WRAP_EQUAL(gdk_region_equal, unconst)
dnl
define(`_WRAP_EQUAL',`dnl
pushdef(`__FUNC_EQUAL__',$1)dnl
pushdef(`__UNCONST__',$2)dnl
_PUSH(SECTION_HEADER3)
__NAMESPACE_BEGIN__
__OPERATOR_DECL(`==')
__OPERATOR_DECL(`!=')
__NAMESPACE_END__
_SECTION(SECTION_CC)
__OPERATOR_IMPL(`==', __FUNC_EQUAL__, `!= 0')
__OPERATOR_IMPL(`!=', __FUNC_EQUAL__, `== 0')
_POP()
popdef(`__UNCONST__')dnl
popdef(`__FUNC_EQUAL__')dnl
')dnl enddef _WRAP_EQUAL
dnl
dnl _WRAP_COMPARE(gtk_tree_path_compare)
dnl
define(`_WRAP_COMPARE',`dnl
pushdef(`__FUNC_COMPARE__',$1)dnl
pushdef(`__UNCONST__',$2)dnl
_PUSH(SECTION_HEADER3)
__NAMESPACE_BEGIN__
__OPERATOR_DECL(`==')
__OPERATOR_DECL(`!=')
__OPERATOR_DECL(`<')
__OPERATOR_DECL(`>')
__OPERATOR_DECL(`<=')
__OPERATOR_DECL(`>=')
__NAMESPACE_END__
_SECTION(SECTION_CC)
__OPERATOR_IMPL(`==', __FUNC_COMPARE__, `== 0')
__OPERATOR_IMPL(`!=', __FUNC_COMPARE__, `!= 0')
__OPERATOR_IMPL(`<', __FUNC_COMPARE__, `< 0')
__OPERATOR_IMPL(`>', __FUNC_COMPARE__, `> 0')
__OPERATOR_IMPL(`<=', __FUNC_COMPARE__, `<= 0')
__OPERATOR_IMPL(`>=', __FUNC_COMPARE__, `>= 0')
_POP()
popdef(`__UNCONST__')dnl
popdef(`__FUNC_COMPARE__')dnl
')dnl enddef _WRAP_COMPARE
dnl
dnl _WRAP_EQUAL_AND_COMPARE(gtk_text_iter_equal, gtk_text_iter_compare)
dnl
define(`_WRAP_EQUAL_AND_COMPARE',`dnl
pushdef(`__FUNC_EQUAL__',$1)dnl
pushdef(`__FUNC_COMPARE__',$2)dnl
pushdef(`__UNCONST__',$3)dnl
_PUSH(SECTION_HEADER3)
__NAMESPACE_BEGIN__
__OPERATOR_DECL(`==')
__OPERATOR_DECL(`!=')
__OPERATOR_DECL(`<')
__OPERATOR_DECL(`>')
__OPERATOR_DECL(`<=')
__OPERATOR_DECL(`>=')
__NAMESPACE_END__
_SECTION(SECTION_CC)
__OPERATOR_IMPL(`==', __FUNC_EQUAL__, `!= 0')
__OPERATOR_IMPL(`!=', __FUNC_EQUAL__, `== 0')
__OPERATOR_IMPL(`<', __FUNC_COMPARE__, `< 0')
__OPERATOR_IMPL(`>', __FUNC_COMPARE__, `> 0')
__OPERATOR_IMPL(`<=', __FUNC_COMPARE__, `<= 0')
__OPERATOR_IMPL(`>=', __FUNC_COMPARE__, `>= 0')
_POP()
popdef(`__UNCONST__')dnl
popdef(`__FUNC_COMPARE__')dnl
popdef(`__FUNC_EQUAL__')dnl
')dnl enddef _WRAP_EQUAL_AND_COMPARE

View File

@@ -0,0 +1,6 @@
dnl $Id$
# Other libraries, such as libgnomeuimm, can provide their own convert.m4 files,
# Maybe choosing to include the same files as this one.
include(convert_glibmm.m4)

View File

@@ -0,0 +1,88 @@
dnl $Id$
#
# Define a hashing for names
#
define(`__HASH',`__`'m4_translit(`$*',`ABCDEFGHIJKLMNOPQRSTUVWXYZ<>[]&*, ',`abcdefghijklmnopqrstuvwxyzVBNMRSC_')`'')
define(`__EQUIV',`m4_ifdef(EV`'__HASH(`$1'),EV`'__HASH(`$1'),`$1')')
dnl __HASH2(firsttype, secondtype)
dnl
dnl Provides a textual combination of the two given types which can be used as
dnl a hash to store and retrieve conversions and initializations. It first
dnl sees if the two types have equivalent types that should be used in their
dnl places (using the __EQUIV macro above). Since the types returned by
dnl __EQUIV may contain commas (because of types such as std::map<>), quote the
dnl call to the macro to avoid the types to be interpreted as more than one
dnl argument to the pushdef() calls. Also quote the expansion of the __E1 and
dnl __E2 macros in the m4_ifelse for the same reason.
define(`__HASH2',`dnl
pushdef(`__E1',`__EQUIV(`$1')')pushdef(`__E2',`__EQUIV(`$2')')dnl
m4_ifelse(_QUOTE(__E1),_QUOTE(__E2),`__EQ',__HASH(__E1)`'__HASH(__E2))`'dnl
popdef(`__E1')popdef(`__E2')`'')
define(`CF__EQ',`$3')
# _CONVERT(fromtype, totype, name, wrap_line)
#
# Print the conversion from 'fromtype' to 'totype'
define(`_CONVERT',`dnl
m4_ifelse(`$2',void,`$3',`dnl
pushdef(`__COV',`CF`'__HASH2(`$1',`$2')')dnl
m4_ifdef(__COV,`m4_indir(__COV,`$1',`$2',`$3')',`
m4_errprint(`No conversion from $1 to $2 defined (line: $4, parameter name: $3)
')
m4_m4exit(1)
')`'dnl
')`'dnl
')
# _CONVERSION(fromtype, totype, conversion)
#
# Functions for populating the tables.
#
define(`_CONVERSION',`
m4_ifelse(`$3',,,`define(CF`'__HASH2(`$1',`$2'),`$3')')
')
define(`_EQUAL',`define(EV`'__HASH(`$1'),`$2')')
/*******************************************************************/
define(`__ARG3__',`$`'3')
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__)))
')dnl
# e.g. Glib::RefPtr<Gdk::Something> to GdkSomething*
define(`__CONVERT_REFPTR_TO_P',`Glib::unwrap($`'3)')
define(`__FR2P',`($`'3).gobj()')
define(`__CFR2P',`const_cast<$`'2>($`'3.gobj())')
define(`__FCR2P',`const_cast<$`'2>(($`'3).gobj())')
define(`__FL2H_SHALLOW',`$`'2($`'3, Glib::OWNERSHIP_SHALLOW)')
# e.g. Glib::RefPtr<const Gdk::Something> to GdkSomething*
#define(`__CONVERT_CONST_REFPTR_TO_P',`const_cast<$`'2>($`'3->gobj())')
define(`__CONVERT_CONST_REFPTR_TO_P',`const_cast<$`'2>(Glib::unwrap($`'3))')
# The Sun Forte compiler doesn't seem to be able to handle these, so we are using the altlernative, __CONVERT_CONST_REFPTR_TO_P_SUN.
# The Sun compiler gives this error, for instance:
#<23> "widget.cc", line 4463: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Window>(const Glib::RefPtr<const Gdk::Window>&)" and
# "Glib::unwrap<const Gdk::Window>(const Glib::RefPtr<const Gdk::Window>&)".
#
define(`__CONVERT_CONST_REFPTR_TO_P_SUN',`const_cast<$`'2>(Glib::unwrap<$1>($`'3))')
#include(convert_gtk.m4)
#include(convert_pango.m4)
#include(convert_gdk.m4)
#include(convert_atk.m4)
include(convert_glib.m4)

View File

@@ -0,0 +1,341 @@
_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)
# Action
_CONVERSION(`GAction*',`Glib::RefPtr<Action>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Action>&',`GAction*',__CONVERT_REFPTR_TO_P)
# ActionGroup
_CONVERSION(`const Glib::RefPtr<ActionGroup>&',`GActionGroup*',__CONVERT_REFPTR_TO_P)
# AppInfo
_CONVERSION(`GAppInfo*',`Glib::RefPtr<AppInfo>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<AppLaunchContext>&',`GAppLaunchContext*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`GAppLaunchContext*',`const Glib::RefPtr<AppLaunchContext>&',Glib::wrap($3))
_CONVERSION(`const Glib::RefPtr<AppInfo>&',`GAppInfo*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`Glib::RefPtr<AppInfo>',`GAppInfo*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`GAppInfo*',`const Glib::RefPtr<AppInfo>&',`Glib::wrap($3)')
_CONVERSION(`const Glib::ListHandle< Glib::RefPtr<Gio::File> >&',`GList*',`$3.data()')
# Application
_CONVERSION(`GApplication*',`Glib::RefPtr<Application>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Application>&',`GApplication*',__CONVERT_CONST_REFPTR_TO_P)
# ApplicationCommandLine
_CONVERSION(`const Glib::RefPtr<ApplicationCommandLine>&',`GApplicationCommandLine*',__CONVERT_CONST_REFPTR_TO_P)
# AsyncResult
_CONVERSION(`Glib::RefPtr<Glib::Object>',`GObject*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<AsyncResult>&',`GAsyncResult*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`Glib::RefPtr<AsyncResult>&',`GAsyncResult*',__CONVERT_REFPTR_TO_P)
#ByteArray
_CONVERSION(`const Glib::RefPtr<Glib::ByteArray>&',`GByteArray*',`Glib::unwrap($3)')
# Cancellable
_CONVERSION(`const Glib::RefPtr<Cancellable>&',`GCancellable*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Gio::Cancellable>&',`GCancellable*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GCancellable*', `Glib::RefPtr<Cancellable>', `Glib::wrap($3)')
_CONVERSION(`GCancellable*', `const Glib::RefPtr<Cancellable>&', `Glib::wrap($3)')
# Converter
_CONVERSION(`const Glib::RefPtr<Converter>&',`GConverter*',`Glib::unwrap($3)')
_CONVERSION(`GConverter*',`Glib::RefPtr<Converter>',`Glib::wrap($3)')
# Credentials
_CONVERSION(`const Glib::RefPtr<Credentials>&',`GCredentials*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::Credentials))
_CONVERSION(`const Glib::RefPtr<const Credentials>&',`GCredentials*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::Credentials))
_CONVERSION(`GCredentials*',`Glib::RefPtr<Credentials>',`Glib::wrap($3)')
_CONVERSION(`GCredentials*',`Glib::RefPtr<const Credentials>',`Glib::wrap($3)')
# DBusConnection
_CONVERSION(`const Glib::RefPtr<Connection>&',`GDBusConnection*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const Connection>&',`GDBusConnection*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GDBusConnection*',`Glib::RefPtr<Connection>',Glib::wrap($3))
_CONVERSION(`GDBusConnection*',`Glib::RefPtr<const Connection>',Glib::wrap($3))
_CONVERSION(`GDBusConnection*',`Glib::RefPtr<DBus::Connection>',Glib::wrap($3))
_CONVERSION(`GDBusConnection*',`Glib::RefPtr<const DBus::Connection>',Glib::wrap($3))
# DBusMessage
_CONVERSION(`const Glib::RefPtr<Message>&',`GDBusMessage*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`GDBusMessage*',`Glib::RefPtr<Message>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<const Message>&',`GDBusMessage*',__CONVERT_CONST_REFPTR_TO_P)
# DBus*Info
_CONVERSION(`GDBusMethodInfo*',`Glib::RefPtr<MethodInfo>',`Glib::wrap($3)')
_CONVERSION(`GDBusSignalInfo*',`Glib::RefPtr<SignalInfo>',`Glib::wrap($3)')
_CONVERSION(`GDBusPropertyInfo*',`Glib::RefPtr<PropertyInfo>',`Glib::wrap($3)')
_CONVERSION(`GDBusNodeInfo*',`Glib::RefPtr<NodeInfo>',`Glib::wrap($3)')
_CONVERSION(`GDBusInterfaceInfo*',`Glib::RefPtr<InterfaceInfo>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<InterfaceInfo>&',`GDBusInterfaceInfo*',`Glib::unwrap($3)')
_CONVERSION(`Glib::RefPtr<InterfaceInfo>',`GDBusInterfaceInfo*',`Glib::unwrap($3)')
_CONVERSION(`GDBusInterfaceInfo*',`const Glib::RefPtr<InterfaceInfo>',`Glib::wrap($3)')
# DBusInterface
_CONVERSION(`GDBusInterface*',`Glib::RefPtr<Gio::DBus::Interface>',`Glib::wrap($3)')
_CONVERSION(`Glib::RefPtr<Gio::DBus::Interface>',`GDBusInterface*',`Glib::unwrap($3)')
_CONVERSION(`const Glib::RefPtr<Gio::DBus::Interface>&',`GDBusInterface*',`Glib::unwrap($3)')
# DBusMethodInvocation
_CONVERSION(`const Glib::RefPtr<MethodInvocation>&',`GDBusMethodInvocation*',`Glib::unwrap($3)')
# DBusObject
_CONVERSION(`GDBusObject*',`Glib::RefPtr<Gio::DBus::Object>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Gio::DBus::Object>&',`GDBusObject*',`Glib::unwrap($3)')
_CONVERSION(`Glib::RefPtr<Gio::DBus::Object>',`GDBusObject*',`Glib::unwrap($3)')
# DBusProxy
_CONVERSION(`GDBusProxy*',`Glib::RefPtr<Gio::DBus::Proxy>',`Glib::wrap($3)')
# DesktopAppInfo
_CONVERSION(`GDesktopAppInfo*', `Glib::RefPtr<DesktopAppInfo>', `Glib::wrap($3)')
# Drive
_CONVERSION(`GDrive*',`Glib::RefPtr<Drive>',`Glib::wrap($3)')
# File
_CONVERSION(`return-char*',`std::string',`Glib::convert_return_gchar_ptr_to_stdstring($3)')
_CONVERSION(`Glib::RefPtr<File>',`GFile*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<File>&',`GFile*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const File>&',`GFile*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::File))
_CONVERSION(`GFile*',`Glib::RefPtr<File>',`Glib::wrap($3)')
_CONVERSION(`GFile*',`Glib::RefPtr<const File>',`Glib::wrap($3)')
# FileAttribute
_CONVERSION(`GFileAttributeValue*',`FileAttributeValue',`Glib::wrap($3)')
_CONVERSION(`const FileAttributeValue&',`const GFileAttributeValue*',`$3.gobj()')
_CONVERSION(`GFileAttributeInfoList*',`Glib::RefPtr<FileAttributeInfoList>',`Glib::wrap($3)')
# FileAttributeMatcher
_CONVERSION(`GFileAttributeMatcher*',`Glib::RefPtr<FileAttributeMatcher>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<const FileAttributeMatcher>&',`GFileAttributeMatcher*',`const_cast<GFileAttributeMatcher*>(Glib::unwrap($3))')
#FileEnumerator
_CONVERSION(`GFileEnumerator*',`Glib::RefPtr<FileEnumerator>',`Glib::wrap($3)')
# FileInfo
_CONVERSION(`GFileInfo*',`Glib::RefPtr<FileInfo>',`Glib::wrap($3)')
_CONVERSION(`Glib::RefPtr<FileInfo>&',`GFileInfo*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<FileInfo>&',`GFileInfo*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`Glib::TimeVal&', `GTimeVal*', static_cast<$2>(&$3))
_CONVERSION(`const Glib::TimeVal&', `GTimeVal*', const_cast<GTimeVal*>(static_cast<const GTimeVal*>(&$3)))
_CONVERSION(`const Glib::RefPtr<FileAttributeMatcher>&',`GFileAttributeMatcher*',__CONVERT_CONST_REFPTR_TO_P)
# FileInputStream
_CONVERSION(`GFileInputStream*',`Glib::RefPtr<FileInputStream>',`Glib::wrap($3)')
# FileMonitor
_CONVERSION(`GFileMonitor*',`Glib::RefPtr<FileMonitor>',`Glib::wrap($3)')
# FileOutputStream
_CONVERSION(`GFileOutputStream*',`Glib::RefPtr<FileOutputStream>',`Glib::wrap($3)')
# FilterInputStream
#_CONVERSION(`GFilterInputStream*',`Glib::RefPtr<FilterInputStream>',`Glib::wrap($3)')
_CONVERSION(`GFileIOStream*',`Glib::RefPtr<FileIOStream>',`Glib::wrap($3)')
# Icon
_CONVERSION(`GIcon*',`Glib::RefPtr<Icon>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Icon>&',`GIcon*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`Glib::RefPtr<Icon>',`GIcon*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`Glib::RefPtr<const Icon>',`GIcon*',__CONVERT_CONST_REFPTR_TO_P)
# Emblem
_CONVERSION(`const Glib::RefPtr<Emblem>&',`GEmblem*',__CONVERT_CONST_REFPTR_TO_P)
# IOStream
_CONVERSION(`GIOStream*',`Glib::RefPtr<Gio::IOStream>',`Glib::wrap($3)')
_CONVERSION(`GIOStream*',`Glib::RefPtr<IOStream>',`Glib::wrap($3)')
_CONVERSION(`GIOStream*',`Glib::RefPtr<const Gio::IOStream>',`Glib::wrap($3)')
_CONVERSION(`GIOStream*',`Glib::RefPtr<const IOStream>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<IOStream>&',`GIOStream*',`Glib::unwrap($3)')
_CONVERSION(`const Glib::RefPtr<const IOStream>&',`GIOStream*',`const_cast<GIOStream*>(Glib::unwrap($3))')
# InetAddress
_CONVERSION(`const Glib::RefPtr<InetAddress>&',`GInetAddress*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const InetAddress>&',`GInetAddress*',`const_cast<GInetAddress*>(Glib::unwrap($3))')
_CONVERSION(`GInetAddress*',`Glib::RefPtr<InetAddress>',`Glib::wrap($3)')
# InputStream
_CONVERSION(`const Glib::RefPtr<InputStream>&',`GInputStream*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Gio::InputStream>&',`GInputStream*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GInputStream*',`Glib::RefPtr<InputStream>',`Glib::wrap($3)')
# MenuAttributeIter
_CONVERSION(`GMenuAttributeIter*',`Glib::RefPtr<MenuAttributeIter>',`Glib::wrap($3)')
# MenuLinkIter
_CONVERSION(`GMenuLinkIter*',`Glib::RefPtr<MenuLinkIter>',`Glib::wrap($3)')
# MenuModel
_CONVERSION(`GMenuModel*',`Glib::RefPtr<MenuModel>',`Glib::wrap($3)')
_CONVERSION(`GMenuModel*',`Glib::RefPtr<const MenuModel>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<MenuModel>&',`GMenuModel*',__CONVERT_CONST_REFPTR_TO_P)
# MenuItem
_CONVERSION(`GMenuItem*',`Glib::RefPtr<MenuItem>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<MenuItem>&',`GMenuItem*',__CONVERT_CONST_REFPTR_TO_P)
# Mount
_CONVERSION(`GMount*',`Glib::RefPtr<Mount>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Mount>&',`GMount*',__CONVERT_CONST_REFPTR_TO_P)
# MountOptions
_CONVERSION(`GPasswordSave',`PasswordSave',`($2)$3')
_CONVERSION(`PasswordSave',`GPasswordSave',`($2)$3')
#MountOperation
#_CONVERSION(`GAskPasswordFlags',`AskPasswordFlags',`($2)$3')
# NetworkMonitor
_CONVERSION(`GNetworkMonitor*',`Glib::RefPtr<NetworkMonitor>',`Glib::wrap($3)')
# Notification
_CONVERSION(`GNotification*',`Glib::RefPtr<Notification>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Notification>&',`GNotification*',__CONVERT_CONST_REFPTR_TO_P)
# OutputStream
_CONVERSION(`GOutputStream*',`Glib::RefPtr<OutputStream>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<OutputStream>&',`GOutputStream*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<ProxyResolver>&',`GProxyResolver*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GProxyResolver*',`Glib::RefPtr<ProxyResolver>',`Glib::wrap($3)')
_CONVERSION(`GProxy*',`Glib::RefPtr<Proxy>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<const ProxyAddress>&',`GProxyAddress*',__CONVERT_CONST_REFPTR_TO_P)
#Resource
_CONVERSION(`GResource*',`Glib::RefPtr<Resource>',`Glib::wrap($3)')
#Settings
_CONVERSION(`GSettings*',`Glib::RefPtr<Settings>',`Glib::wrap($3)')
_CONVERSION(`const Glib::StringArrayHandle&',`const gchar*-const*',`($3).data()')
_CONVERSION(`const Glib::RefPtr<SettingsBackend>&',`GSettingsBackend*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`GSettingsSchemaKey*',`Glib::RefPtr<SettingsSchemaKey>',`Glib::wrap($3)')
_CONVERSION(`GSettingsSchemaKey*',`Glib::RefPtr<const SettingsSchemaKey>',`Glib::wrap($3)')
_CONVERSION(`GSettingsSchema*',`Glib::RefPtr<SettingsSchema>',`Glib::wrap($3)')
_CONVERSION(`GSettingsSchema*',`Glib::RefPtr<const SettingsSchema>',`Glib::wrap($3)')
_CONVERSION(`GSettingsSchemaSource*',`Glib::RefPtr<SettingsSchemaSource>',`Glib::wrap($3)')
#Socket
_CONVERSION(`const Glib::RefPtr<Socket>&',`GSocket*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GSocket*',`Glib::RefPtr<Socket>',`Glib::wrap($3)')
#SocketAddress
_CONVERSION(`GSocketAddress*',`Glib::RefPtr<SocketAddress>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<SocketAddress>&',`GSocketAddress*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`Glib::RefPtr<SocketAddress>&',`GSocketAddress*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GSocketAddressEnumerator*',`Glib::RefPtr<SocketAddressEnumerator>',`Glib::wrap($3)')
#SocketConnectable
_CONVERSION(`const Glib::RefPtr<SocketConnectable>&',`GSocketConnectable*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const SocketConnectable>&', `GSocketConnectable*', `const_cast<GSocketConnectable*>(Glib::unwrap($3))')
_CONVERSION(`GSocketConnectable*',`Glib::RefPtr<SocketConnectable>',`Glib::wrap($3)')
#SocketConnection
_CONVERSION(`GSocketConnection*',`Glib::RefPtr<SocketConnection>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<SocketConnection>&',`GSocketConnection*',__CONVERT_CONST_REFPTR_TO_P)
#SocketControlMessage
_CONVERSION(`GSocketControlMessage*',`Glib::RefPtr<SocketControlMessage>',`Glib::wrap($3)')
#TimeZoneMonitor
_CONVERSION(`GTimeZoneMonitor*',`Glib::RefPtr<TimeZoneMonitor>',`Glib::wrap($3)')
#TlsCertificate
_CONVERSION(`GTlsCertificate*', `Glib::RefPtr<TlsCertificate>', `Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<const TlsCertificate>&', `GTlsCertificate*', `const_cast<GTlsCertificate*>(Glib::unwrap($3))')
_CONVERSION(`const Glib::RefPtr<TlsCertificate>&',`GTlsCertificate*',`Glib::unwrap($3)')
#TlsConnection:
_CONVERSION(`const Glib::RefPtr<TlsConnection>&',`GTlsConnection*',`Glib::unwrap($3)')
#TlsClientConnection:
_CONVERSION(`const Glib::RefPtr<TlsClientConnection>&',`GTlsClientConnection*',__CONVERT_REFPTR_TO_P)
#TlsDatabase
_CONVERSION(`GTlsDatabase*',`Glib::RefPtr<TlsDatabase>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<TlsDatabase>&',`GTlsDatabase*',__CONVERT_REFPTR_TO_P)
#TlsInteraction
_CONVERSION(`const Glib::RefPtr<TlsInteraction>&',`GTlsInteraction*',`Glib::unwrap($3)')
_CONVERSION(`GTlsInteraction*',`Glib::RefPtr<TlsInteraction>',`Glib::wrap($3)')
#TlsPassword
_CONVERSION(`const Glib::RefPtr<TlsPassword>&',`GTlsPassword*',__CONVERT_REFPTR_TO_P)
#UnixFDList
_CONVERSION(`GUnixFDList*',`Glib::RefPtr<UnixFDList>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<UnixFDList>&',`GUnixFDList*',__CONVERT_REFPTR_TO_P)
#Volume
_CONVERSION(`GVolume*',`Glib::RefPtr<Volume>',`Glib::wrap($3)')
# VolumeMonitor
_CONVERSION(`GVolumeMonitor*',`Glib::RefPtr<VolumeMonitor>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Drive>&',`GDrive*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Mount>&',`GMount*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Volume>&',`GVolume*',__CONVERT_CONST_REFPTR_TO_P)
#Vfs
_CONVERSION(`GVfs*', `Glib::RefPtr<Vfs>', `Glib::wrap($3)')

View File

@@ -0,0 +1,180 @@
dnl
dnl Glib C names have prefix 'G' but C++ namespace Glib
dnl
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__)))
')dnl
_EQUAL(gchar,char)
_EQUAL(gchar*,char*)
_EQUAL(gchar**,char**)
_EQUAL(gint**,int**)
_EQUAL(gchar**,char*[])
_EQUAL(const gchar*,const char*)
_EQUAL(const-gchar*,const char*)
_EQUAL(gpointer*,void**)
_EQUAL(gboolean,int)
_EQUAL(gint,int)
_EQUAL(gint*,int*)
_EQUAL(gint&,int&)
_EQUAL(guint,unsigned int)
_EQUAL(guint*,unsigned int*)
_EQUAL(guint&,unsigned int&)
_EQUAL(gdouble,double)
_EQUAL(gdouble*,double*)
_EQUAL(gfloat, float)
_EQUAL(float*,gfloat[])
_EQUAL(const-char*,const-gchar*)
_EQUAL(return-char*,return-gchar*)
_EQUAL(gpointer,void*)
_EQUAL(gconstpointer,const void*)
_EQUAL(GdkAtom,Gdk::Atom)
_EQUAL(GTimeSpan,TimeSpan)
# Basic Types
_CONVERSION(`int',`bool',`$3')
_CONVERSION(`bool',`int',`static_cast<int>($3)')
_CONVERSION(`unsigned int',`bool',`$3')
_CONVERSION(`bool',`unsigned int',`static_cast<unsigned int>($3)')
_CONVERSION(`bool&',`gboolean*',`(($2) &($3))')
_CONVERSION(`int&',`gint*',`&($3)')
_CONVERSION(`gint*',`int&',`*($3)')
_CONVERSION(`guint&',`guint*',`&($3)')
_CONVERSION(`guint64&',`guint64*',`&($3)')
_CONVERSION(`double&',`gdouble*',`&($3)')
_CONVERSION(`float&',`gfloat*',`&($3)')
_CONVERSION(`gchar**',`char**',`$3')
_CONVERSION(`char**',`gchar**',`$3')
_CONVERSION(`gpointer&',`gpointer*',`&($3)')
_CONVERSION(`void*&',`gpointer*',`&($3)')
_CONVERSION(`GError*&',`GError**',`&($3)')
dnl
dnl # These are for fixmegtkconst
_CONVERSION(`const guchar*',`guchar*',`const_cast<guchar*>($3)',`$3')
_CONV_GLIB_ENUM(BindingFlags)
_CONV_GLIB_ENUM(IOCondition)
_CONV_GLIB_ENUM(IOFlags)
_CONV_GLIB_ENUM(IOStatus)
_CONV_GLIB_ENUM(KeyFileFlags)
_CONV_GLIB_ENUM(OptionArg)
_CONV_GLIB_ENUM(RegexCompileFlags)
_CONV_GLIB_ENUM(RegexMatchFlags)
_CONV_GLIB_ENUM(SeekType)
_CONV_GLIB_ENUM(TimeType)
_CONVERSION(`gunichar&',`gunichar*',`&($3)')
_CONVERSION(`gsize&',`gsize*',`&($3)')
# Strings:
define(`__GCHARP_TO_USTRING',`Glib::convert_const_gchar_ptr_to_ustring($`'3)')
define(`__GCHARP_TO_STDSTRING',`Glib::convert_const_gchar_ptr_to_stdstring($`'3)')
_CONVERSION(`const Glib::ustring&',`const char*',`$3.c_str()')
_CONVERSION(`const Glib::ustring&', `const guchar*', `(($2)$3.c_str())')
_CONVERSION(`const std::string&',`const char*',`$3.c_str()')
_CONVERSION(`std::string',`const char*',`$3.c_str()')
_CONVERSION(`const Glib::ustring&',`gchar*',`const_cast<gchar*>($3.c_str())')
_CONVERSION(`gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const-gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const-guchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const char*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
_CONVERSION(`const char*',`std::string',__GCHARP_TO_STDSTRING)
_CONVERSION(`const char*',`const-gchar*',`$3')
_CONVERSION(`const-gchar*',`const char*',`$3')
_CONVERSION(`const char*',`const std::string&',__GCHARP_TO_STDSTRING)
_CONVERSION(`char*',`std::string',__GCHARP_TO_STDSTRING)
_CONVERSION(`std::string', `char*', `g_strdup(($3).c_str())')
_CONVERSION(`const std::string&', `char*', `g_strdup(($3).c_str())')
_CONVERSION(`Glib::ustring', `char*', `g_strdup(($3).c_str())')
_CONVERSION(`return-gchar*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
_CONVERSION(`return-gchar*',`std::string',`Glib::convert_return_gchar_ptr_to_stdstring($3)')
_CONVERSION(`return-char*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
dnl DateTime
_CONVERSION(`GDateTime*',`DateTime',`Glib::wrap($3)')
_CONVERSION(`GDateTime*',`Glib::DateTime',`Glib::wrap($3)')
_CONVERSION(`const DateTime&',`GDateTime*',`const_cast<$2>($3.gobj())')
dnl KeyFile
_CONVERSION(`Glib::KeyFile&',`GKeyFile*',`($3).gobj()')
dnl Object
_CONVERSION(`const Glib::RefPtr<Glib::Object>&',`GObject*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const Glib::Object>&',`GObject*',__CONVERT_CONST_REFPTR_TO_P_SUN(Glib::Object))
_CONVERSION(`GObject*',`Glib::RefPtr<Glib::Object>',`Glib::wrap($3)')
_CONVERSION(`GObject*',`Glib::RefPtr<const Glib::Object>',`Glib::wrap($3)')
_CONVERSION(`GObject*',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap($3)')
_CONVERSION(`GObject*',`Glib::RefPtr<const Glib::ObjectBase>',`Glib::wrap($3)')
dnl OptionGroup
_CONVERSION(`OptionGroup&',`GOptionGroup*',`($3).gobj()')
_CONVERSION(`Glib::OptionGroup&',`GOptionGroup*',`($3).gobj()')
dnl Bytes
_CONVERSION(`GBytes*',`Glib::RefPtr<Glib::Bytes>',`Glib::wrap($3)')
_CONVERSION(`GBytes*',`Glib::RefPtr<const Glib::Bytes>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<const Glib::Bytes>&',`GBytes*',__CONVERT_CONST_REFPTR_TO_P_SUN(Glib::Bytes)))
dnl ByteArray
_CONVERSION(`GByteArray*',`Glib::RefPtr<ByteArray>',`Glib::wrap($3)')
dnl Regex
_CONVERSION(`GRegex*',`Glib::RefPtr<Regex>',`Glib::wrap($3)')
_CONVERSION(`GRegex*',`Glib::RefPtr<const Regex>',`Glib::wrap($3)')
#Source
_CONVERSION(`GSource*',`Glib::RefPtr<Glib::Source>',`Glib::wrap($3)')
dnl TimeVal
_CONVERSION(`const TimeVal&',`const GTimeVal*',`&($3)')
_CONVERSION(`TimeVal&',`GTimeVal*',`&($3)')
dnl TimeZone
_CONVERSION(`GTimeZone*',`TimeZone',`Glib::wrap($3)')
_CONVERSION(`const TimeZone&',`GTimeZone*',`const_cast<$2>($3.gobj())')
dnl ValueBase
_CONVERSION(`Glib::ValueBase&',`GValue*',`($3).gobj()')
_CONVERSION(`const Glib::ValueBase&',`const GValue*',`($3).gobj()')
_CONVERSION(`const Glib::ValueBase&',`GValue*',`const_cast<GValue*>(($3).gobj())')
_CONVERSION(`GValue*', `Glib::ValueBase&', `*reinterpret_cast<Glib::ValueBase*>($3)')
_CONVERSION(`const GValue*', `const Glib::ValueBase&', `*reinterpret_cast<const Glib::ValueBase*>($3)')
#Variant
_CONVERSION(`GVariant*',`Glib::VariantBase',`Glib::wrap($3, false)')
_CONVERSION(`GVariant*',`Glib::VariantContainerBase',`Glib::VariantContainerBase($3, false)')
_CONVERSION(`const VariantBase&',`GVariant*',`const_cast<GVariant*>(($3).gobj())')
_CONVERSION(`const Glib::VariantBase&',`GVariant*',`const_cast<GVariant*>(($3).gobj())')
_CONVERSION(`const Glib::VariantContainerBase&',`GVariant*',`const_cast<GVariant*>(($3).gobj())')
# VariantContainerBase
_CONVERSION(`const VariantContainerBase&',`GVariant*',`const_cast<GVariant*>(($3).gobj())')
#VariantDict
_CONVERSION(`GVariantDict*',`Glib::RefPtr<VariantDict>',`Glib::wrap($3)')
_CONVERSION(`GVariantDict*',`Glib::RefPtr<Glib::VariantDict>',`Glib::wrap($3)')
_CONVERSION(`GVariantDict*',`Glib::RefPtr<const Glib::VariantDict>',`Glib::wrap($3)')
#VariantType
_CONVERSION(`const GVariantType*',`Glib::VariantType',`Glib::wrap(const_cast<GVariantType*>($3), true)')
_CONVERSION(`const VariantType&',`const GVariantType*',`($3).gobj()')
_CONVERSION(`const Glib::VariantType&',`const GVariantType*',`($3).gobj()')
_CONVERSION(`GVariantType*',`VariantType',`Glib::wrap($3)')
dnl Miscellaneous
_CONVERSION(`gint64&',`gint64*',`&($3)')

View File

@@ -0,0 +1,6 @@
dnl $Id$
include(convert_base.m4)
include(convert_glib.m4)
include(convert_gio.m4)

View File

@@ -0,0 +1,71 @@
dnl $Id$
dnl
dnl M4 macros for constructor generation.
dnl
dnl Code to sink a GInitiallyUnowned:
dnl
m4_define(`_INITIALLY_UNOWNED_SINK',`dnl
ifdef(`__BOOL_DERIVES_INITIALLY_UNOWNED__',`dnl
if(gobject_ && g_object_is_floating (gobject_))
g_object_ref_sink(gobject_); //Stops it from being floating.
',`')')
dnl Declares and implements the default constructor
dnl
m4_define(`_CTOR_DEFAULT',`dnl
__CPPNAME__`'();
_PUSH(SECTION_CC)
__CPPNAME__::__CPPNAME__`'()
:
// Mark this class as non-derived to allow C++ vfuncs to be skipped.
Glib::ObjectBase(nullptr),
__CPPPARENT__`'(Glib::ConstructParams(__BASE__`'_class_.init()))
{
_IMPORT(SECTION_CC_INITIALIZE_CLASS_EXTRA)
_INITIALLY_UNOWNED_SINK
}
_POP()')
dnl Constructors with property initializations.
dnl
dnl _CTOR_IMPL(cppname, cname, cppargs, c_varargs)
dnl $1 $2 $3 $4
dnl
m4_define(`_CTOR_IMPL',`dnl
_PUSH(SECTION_CC)
__CPPNAME__::$1`'($3)
:
// Mark this class as non-derived to allow C++ vfuncs to be skipped.
Glib::ObjectBase(nullptr),
__CPPPARENT__`'(Glib::ConstructParams(__BASE__`'_class_.init()m4_ifelse(`$4',,,`, $4, nullptr')))
{
_IMPORT(SECTION_CC_INITIALIZE_CLASS_EXTRA)
_INITIALLY_UNOWNED_SINK
}
_POP()')
m4_define(`_CONSTRUCT',
`// Mark this class as non-derived to allow C++ vfuncs to be skipped.
Glib::ObjectBase(nullptr),
__CPPPARENT__`'(Glib::ConstructParams(__BASE__`'_class_.init()m4_ifelse(`$1',,,`, $@, nullptr')))')
dnl _CONSTRUCT() does not deal with multiple class definitions in one file.
dnl If necessary, _CONSTRUCT_SPECIFIC(BaseClass, Class) must be used instead.
dnl
m4_define(`_CONSTRUCT_SPECIFIC',
`// Mark this class as non-derived to allow C++ vfuncs to be skipped.
Glib::ObjectBase(nullptr),
$1`'(Glib::ConstructParams(_LOWER(`$2')_class_.init()m4_ifelse(`$3',,,`, m4_shift(m4_shift($@)), nullptr')))')
dnl Extra code for initialize_class.
dnl Not commonly used.
dnl
m4_define(`_INITIALIZE_CLASS_EXTRA',`dnl
_PUSH(SECTION_CC_INITIALIZE_CLASS_EXTRA)
$1
_POP()')

View File

@@ -0,0 +1,3 @@
dnl $Id$
divert(-1)

View File

@@ -0,0 +1,105 @@
dnl
dnl _ENUM(cpp_type, c_type, value_suffix, `element_list', `no_gtype', `optional_refdoc_comment', 'deprecated')
dnl $1 $2 $3 $4 $5 $6 $7
dnl
m4_define(`_ENUM',`dnl
_PUSH()
m4_define(`__ENUM_CPPNAME__',`$1')
m4_define(`__ENUM_CNAME__',`$2')
m4_define(`__ENUM_VALUE_BASE__',`Glib::Value_$3<__NAMESPACE__::__ENUM_CPPNAME__>')
_POP()
dnl
dnl // Define a new Doxygen group if this is the first enum in the file.
dnl
m4_ifdef(`__DOCGROUP_'__MODULE_CANONICAL__`_ENUMS__',,`dnl else
m4_define(`__DOCGROUP_'__MODULE_CANONICAL__`_ENUMS__')dnl
/** @addtogroup '__MODULE_CANONICAL__`Enums __MODULE_CANONICAL__ Enums and Flags */
')dnl endif
dnl
dnl
ifelse(`$7',,,`_DEPRECATE_IFDEF_START')`'dnl The expansion of _DEPRECATE_IFDEF_START ends with a newline
/** $6
*
* @ingroup __MODULE_CANONICAL__`'Enums
m4_ifelse($3,Flags,`dnl
* @par Bitwise operators:
* <tt>%__ENUM_CPPNAME__ operator|(__ENUM_CPPNAME__, __ENUM_CPPNAME__)</tt><br>
* <tt>%__ENUM_CPPNAME__ operator&(__ENUM_CPPNAME__, __ENUM_CPPNAME__)</tt><br>
* <tt>%__ENUM_CPPNAME__ operator^(__ENUM_CPPNAME__, __ENUM_CPPNAME__)</tt><br>
* <tt>%__ENUM_CPPNAME__ operator~(__ENUM_CPPNAME__)</tt><br>
* <tt>%__ENUM_CPPNAME__& operator|=(__ENUM_CPPNAME__&, __ENUM_CPPNAME__)</tt><br>
* <tt>%__ENUM_CPPNAME__& operator&=(__ENUM_CPPNAME__&, __ENUM_CPPNAME__)</tt><br>
* <tt>%__ENUM_CPPNAME__& operator^=(__ENUM_CPPNAME__&, __ENUM_CPPNAME__)</tt><br>
')dnl endif
*/
enum __ENUM_CPPNAME__
{
$4
};
m4_ifelse($3,Flags,`dnl
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__ operator|(__ENUM_CPPNAME__ lhs, __ENUM_CPPNAME__ rhs)
{ return static_cast<__ENUM_CPPNAME__>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__ operator&(__ENUM_CPPNAME__ lhs, __ENUM_CPPNAME__ rhs)
{ return static_cast<__ENUM_CPPNAME__>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__ operator^(__ENUM_CPPNAME__ lhs, __ENUM_CPPNAME__ rhs)
{ return static_cast<__ENUM_CPPNAME__>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__ operator~(__ENUM_CPPNAME__ flags)
{ return static_cast<__ENUM_CPPNAME__>(~static_cast<unsigned>(flags)); }
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__& operator|=(__ENUM_CPPNAME__& lhs, __ENUM_CPPNAME__ rhs)
{ return (lhs = static_cast<__ENUM_CPPNAME__>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__& operator&=(__ENUM_CPPNAME__& lhs, __ENUM_CPPNAME__ rhs)
{ return (lhs = static_cast<__ENUM_CPPNAME__>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
/** @ingroup __MODULE_CANONICAL__`'Enums */
inline __ENUM_CPPNAME__& operator^=(__ENUM_CPPNAME__& lhs, __ENUM_CPPNAME__ rhs)
{ return (lhs = static_cast<__ENUM_CPPNAME__>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
')dnl endif Flags
ifelse(`$7',,,`_DEPRECATE_IFDEF_END')`'dnl The expansion of _DEPRECATE_IFDEF_END ends with a newline
m4_ifelse($5,`NO_GTYPE',,`dnl else
__NAMESPACE_END__
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace Glib
{
ifelse(`$7',,,`_DEPRECATE_IFDEF_START')`'dnl
template <>
class Value<__NAMESPACE__::__ENUM_CPPNAME__> : public __ENUM_VALUE_BASE__
{
public:
static GType value_type() G_GNUC_CONST;
};
ifelse(`$7',,,`_DEPRECATE_IFDEF_END')`'dnl
} // namespace Glib
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
__NAMESPACE_BEGIN__
_PUSH(SECTION_SRC_GENERATED)
ifelse(`$7',,,`_DEPRECATE_IFDEF_START')`'dnl
// static
GType Glib::Value<__NAMESPACE__::__ENUM_CPPNAME__>::value_type()
{
return _GET_TYPE_FUNC(__ENUM_CNAME__);
}
ifelse(`$7',,,`_DEPRECATE_IFDEF_END')`'dnl
_POP()
')dnl endif !NO_GTYPE
')dnl enddef _ENUM

View File

@@ -0,0 +1,100 @@
dnl
dnl _GERROR(cpp_type, c_type, domain, `element_list', `no_gtype', `class_docs', `enum_docs', 'deprecated')
dnl $1 $2 $3 $4 $5 $6 $7 $8
dnl
m4_define(`_GERROR',`dnl
_PUSH()
dnl
dnl Define the args for later macros
m4_define(`__CPPNAME__',`$1')
m4_define(`__CNAME__',`$2')
m4_define(`__CQUARK__',`$3')
m4_define(`__VALUE_BASE__',`Glib::Value_Enum<__NAMESPACE__::__CPPNAME__::Code>')
_POP()
ifelse(`$8',,,`_DEPRECATE_IFDEF_START')`'dnl The expansion of _DEPRECATE_IFDEF_START ends with a newline
ifelse(`$6',,,`dnl
/** $6
*/
')dnl
class __CPPNAME__ : public Glib::Error
{
public:
/** $7
*/
enum Code
{
$4
};
__CPPNAME__`'(Code error_code, const Glib::ustring& error_message);
explicit __CPPNAME__`'(GError* gobject);
Code code() const;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
private:
static void throw_func(GError* gobject);
friend void wrap_init(); // uses throw_func()
_IMPORT(SECTION_H_GERROR_PRIVATE)
#endif //DOXYGEN_SHOULD_SKIP_THIS
};
ifelse(`$8',,,`_DEPRECATE_IFDEF_END')`'dnl The expansion of _DEPRECATE_IFDEF_END ends with a newline
m4_ifelse($5,`NO_GTYPE',,`dnl else
__NAMESPACE_END__
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace Glib
{
ifelse(`$8',,,`_DEPRECATE_IFDEF_START')`'dnl
template <>
class Value<__NAMESPACE__::__CPPNAME__::Code> : public __VALUE_BASE__
{
public:
static GType value_type() G_GNUC_CONST;
};
ifelse(`$8',,,`_DEPRECATE_IFDEF_END')`'dnl
} // namespace Glib
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
__NAMESPACE_BEGIN__
')dnl endif !NO_GTYPE
_PUSH(SECTION_SRC_GENERATED)
ifelse(`$8',,,`_DEPRECATE_IFDEF_START')`'dnl
__NAMESPACE__::__CPPNAME__::__CPPNAME__`'(__NAMESPACE__::__CPPNAME__::Code error_code, const Glib::ustring& error_message)
:
Glib::Error (__CQUARK__, error_code, error_message)
{}
__NAMESPACE__::__CPPNAME__::__CPPNAME__`'(GError* gobject)
:
Glib::Error (gobject)
{}
__NAMESPACE__::__CPPNAME__::Code __NAMESPACE__::__CPPNAME__::code() const
{
return static_cast<Code>(Glib::Error::code());
}
void __NAMESPACE__::__CPPNAME__::throw_func(GError* gobject)
{
throw __NAMESPACE__::__CPPNAME__`'(gobject);
}
m4_ifelse($5,`NO_GTYPE',,`dnl else
// static
GType Glib::Value<__NAMESPACE__::__CPPNAME__::Code>::value_type()
{
return _GET_TYPE_FUNC(__CNAME__);
}
')dnl endif !NO_GTYPE
ifelse(`$8',,,`_DEPRECATE_IFDEF_END')`'dnl
_POP()
')dnl enddef _GERROR

View File

@@ -0,0 +1,4 @@
dnl Other libraries, such as libgnomeuimm, can provide their own initialize.m4
dnl files, maybe choosing to include the same files as this one.
include(initialize_glibmm.m4)

View File

@@ -0,0 +1,51 @@
dnl
dnl Macros for keeping track of how to initialize a C++ from a C type.
#
# Define a hashing for names
#
define(`__HASH',`__`'m4_translit(`$*',`ABCDEFGHIJKLMNOPQRSTUVWXYZ<>[]&*, ',`abcdefghijklmnopqrstuvwxyzVBNMRSC_')`'')
define(`__EQUIV',`m4_ifdef(EV`'__HASH(`$1'),EV`'__HASH(`$1'),`$1')')
dnl __HASH2(firsttype, secondtype)
dnl
dnl Provides a textual combination of the two given types which can be used as
dnl a hash to store and retrieve conversions and initializations. It first
dnl sees if the two types have equivalent types that should be used in their
dnl places (using the __EQUIV macro above). Since the types returned by
dnl __EQUIV may contain commas (because of types such as std::map<>), quote the
dnl call to the macro to avoid the types to be interpreted as more than one
dnl argument to the pushdef() calls. Also quote the expansion of the __E1 and
dnl __E2 macros in the m4_ifelse for the same reason.
define(`__HASH2',`dnl
pushdef(`__E1',`__EQUIV(`$1')')pushdef(`__E2',`__EQUIV(`$2')')dnl
m4_ifelse(_QUOTE(__E1),_QUOTE(__E2),`__EQ',__HASH(__E1)`'__HASH(__E2))`'dnl
popdef(`__E1')popdef(`__E2')`'')
define(`IN__EQ',`$3')
# _INITIALIZE(target_type, fromtype, output_param_name, c_return, wrap_line)
#
# Print an initialize statement from ctype to cpptype
define(`_INITIALIZE',`dnl
m4_ifelse(`$1',void,`$4',`dnl
pushdef(`__INI',`IN`'__HASH2(`$1',`$2')')dnl
m4_ifdef(__INI,`m4_indir(__INI,m4_substr(`$1',`0',m4_decr(m4_len(`$1'))),`$2',`$3', $4)',`
m4_errprint(`No initialization for type $1 from type $2 defined (line: $5, output param: $3, c return: $4)
')
m4_m4exit(1)
')`'dnl
')`'dnl
')
# _INITIALIZATION(fromtype, totype, initialization)
#
# Functions for populating initialization tables.
#
define(`_INITIALIZATION',`
m4_ifelse(`$3',,,`define(IN`'__HASH2(`$1',`$2'),m4_patsubst(`$3',`; +',`;
'))')
')
include(initialize_glib.m4)

View File

@@ -0,0 +1,6 @@
dnl
dnl Initializations for giomm C++ types from Gio C types.
dnl
dnl UnixFDList
_INITIALIZATION(`Glib::RefPtr<UnixFDList>&',`GUnixFDList*', `$3 = Glib::wrap($4)')

View File

@@ -0,0 +1,16 @@
dnl
dnl Initialization rules for glibmm C++ types from Glib C types.
dnl
dnl Basic Types
_INITIALIZATION(`bool&',`gboolean',`$3 = static_cast<bool>($4)')
dnl VariantBase
_INITIALIZATION(`Glib::VariantBase&',`GVariant*',`$3 = Glib::wrap($4)')
dnl VariantType
_INITIALIZATION(`Glib::VariantType&',`const GVariantType*',`$3 = Glib::wrap(const_cast<GVariantType*>($4))')
dnl ustring
_INITIALIZATION(`Glib::ustring&',`gchar*',`$3 = Glib::convert_return_gchar_ptr_to_ustring($4)')

View File

@@ -0,0 +1,6 @@
dnl $Id$
include(initialize_base.m4)
include(initialize_glib.m4)
include(initialize_gio.m4)

View File

@@ -0,0 +1,132 @@
dnl
dnl --------------------------- Accessors ----------------------------
dnl
dnl Get:
dnl Creates accessors for simple types:
dnl _MEMBER_GET(cpp_name, c_name, cpp_type, c_type, deprecated (optional))
define(`_MEMBER_GET',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
$3 get_$1() const;
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_PUSH(SECTION_CC)
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
$3 __CPPNAME__::get_$1() const
{
return _CONVERT($4,$3,`gobj()->$2');
}
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')
dnl Creates two accessors for pointer types, one const and one non-const:
define(`_MEMBER_GET_PTR',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
$3 get_$1();
const $3 get_$1() const;
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_PUSH(SECTION_CC)
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
$3 __CPPNAME__::get_$1()
{
return _CONVERT($4,$3,`gobj()->$2');
}
const $3 __CPPNAME__::get_$1() const
{
return _CONVERT($4,const $3,`gobj()->$2');
}
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')
dnl Creates accessors for GObject-derived types that must be ref()ed.
define(`_MEMBER_GET_GOBJECT',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
Glib::RefPtr<$3> get_$1();
Glib::RefPtr<const $3> get_$1() const;
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_PUSH(SECTION_CC)
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
Glib::RefPtr<$3> __CPPNAME__::get_$1()
{
Glib::RefPtr<$3> ref_ptr(_CONVERT($4,Glib::RefPtr<$3>,`gobj()->$2'));
dnl We could use the bool with Glib::wrap(), but we want to share the m4 type-conversion map.
if(ref_ptr)
ref_ptr->reference();
return ref_ptr;
}
Glib::RefPtr<const $3> __CPPNAME__::get_$1() const
{
Glib::RefPtr<const $3> ref_ptr(_CONVERT($4,Glib::RefPtr<const $3>,`gobj()->$2'));
dnl We could use the bool with Glib::wrap(), but we want to share the m4 type-conversion map.
if(ref_ptr)
ref_ptr->reference();
return ref_ptr;
}
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')
dnl Set:
dnl Creates accessors for simple types:
define(`_MEMBER_SET',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
void set_$1(const $3`'& value);
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_PUSH(SECTION_CC)
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
void __CPPNAME__::set_$1(const $3`'& value)
{
gobj()->$2 = _CONVERT($3,$4,`value');
}
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')
dnl Creates accessors for pointer types:
define(`_MEMBER_SET_PTR',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
void set_$1($3 value);
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_PUSH(SECTION_CC)
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
void __CPPNAME__::set_$1($3 value)
{
gobj()->$2 = _CONVERT($3,$4,`value');
}
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')
dnl Creates accessors for GObject-derived types that must be ref()ed.
define(`_MEMBER_SET_GOBJECT',`dnl
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
void set_$1(const Glib::RefPtr<$3>& value);
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_PUSH(SECTION_CC)
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ')dnl
void __CPPNAME__::set_$1(const Glib::RefPtr<$3>& value)
{
Glib::RefPtr<$3> valueOld(_CONVERT($4,Glib::RefPtr<$3>,`gobj()->$2')); //Take possession of the old one, unref-ing it in the destructor.
if(value)
value->reference(); //Ref once for the recipient.
gobj()->$2 = _CONVERT(const Glib::RefPtr<$3>&,$4,`value');
}
ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ')dnl
_POP()')

View File

@@ -0,0 +1,197 @@
dnl
dnl
dnl Code generation sections for making a method.
dnl
dnl
dnl
dnl method
dnl $1 $2 $3 $4 $5 $6 $7 $8
dnl _METHOD(cppname,cname,cpprettype,crettype,arglist,cdeclarations,cargs,cinitializations,
dnl $9 $10 $11 $12 $13 $14 $15
dnl const,refreturn,errthrow,deprecated,constversion,arglist_without_types,ifdef,
dnl $16 $17 $18 $19 $20 $21
dnl out_param,out_param_cpptype,slot_type,slot_name,no_slot_copy,wrap_line)
define(`_METHOD',`dnl
_PUSH(SECTION_CC)
ifelse(`$15',,,`#ifdef $15'
)dnl
ifelse(`$12',,,`_DEPRECATE_IFDEF_START`'dnl The expansion of _DEPRECATE_IFDEF_START ends with a newline
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
')dnl
$3 __CPPNAME__::$1`'($5)ifelse(`$9',1,` const')
{
ifelse(`$13',,dnl
`ifelse(`$10'`$11',,dnl If it is not errthrow or refreturn
dnl If a slot type has been specified insert a slot copy declaration.
`ifelse(`$18',,,dnl
dnl See if the slot should or should not be copied
`ifelse(`$20',,dnl
` // Create a copy of the slot.
auto slot_copy = new $18($19); ',dnl
dnl
` // Use the original slot (not a copy).
auto slot_copy = const_cast<$18*>(&$19);')
')`'dnl
dnl Insert the declarations for C output parameters
ifelse(`$6',,,`$6
')`'dnl
ifelse(`$16',,dnl If no C++ output parameter is specified
`ifelse(`$3',void,dnl If the C function returns voids:
` $2(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7);
dnl Insert the initializations for the C output parameters
ifelse(`$8',,,`$8
')dnl
',dnl If the C function returns non-void:
dnl Store the return if there are C output parameters.
`ifelse(`$6',,` return ',` `$3' retvalue = ')_CONVERT($4,`$3',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)');
dnl Insert the initializations for the C output parameters
ifelse(`$8',,,`$8
')dnl
dnl return the value
ifelse(`$6',,,` return retvalue;
')dnl
')'dnl End if it returns voids.
dnl A C++ output parameter is specified:
,` _INITIALIZE($17,$4,`$16',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)',$21);
dnl
dnl Insert the initializations for the C output parameters
ifelse(`$8',,,`$8
')dnl
')',dnl End if a C++ output parameter is specified.
dnl If is errthrow or refreturn
`ifelse(`$11',,,` GError* gerror = nullptr;
')dnl
dnl If a slot type has been specified insert a slot copy declaration.
ifelse(`$18',,,dnl
dnl See if the slot should or should not be copied
`ifelse(`$20',,dnl
` // Create a copy of the slot.
auto slot_copy = new $18($19); ',dnl
dnl
` // Use the original slot (not a copy).
auto slot_copy = const_cast<$18*>(&$19);')
')`'dnl
dnl Insert the declarations for C output parameters
ifelse(`$6',,,`$6
')`'dnl
ifelse(`$16',,dnl If no C++ output parameter is specified:
` ifelse(`$3',void,,``$3' retvalue = ')_CONVERT($4,`$3',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)');
'dnl
,dnl A C++ output parameter is specified:
` _INITIALIZE($17,$4,`$16',`$2`'(ifelse(`$9',1,const_cast<__CNAME__*>(gobj()),gobj())`'ifelse(`$7',,,`, ')$7)',$21);
'dnl
)dnl
ifelse(`$11',,,`dnl
if(gerror)
::Glib::Error::throw_exception(gerror);
')dnl
ifelse(`$10',,,`dnl
if(ifelse(`$16',,`retvalue',$16))
ifelse(`$16',,`retvalue',$16)->reference(); //The function does not do a ref for us.
')dnl
dnl Insert the initializations for the C output parameters
ifelse(`$8',,,`$8
')`'dnl
ifelse(`$3',void,,` return retvalue;
')dnl
')dnl End errthrow/refreturn
',` return const_cast<__CPPNAME__*>(this)->$1($14);
')dnl
}
ifelse(`$12',,,`G_GNUC_END_IGNORE_DEPRECATIONS
_DEPRECATE_IFDEF_END')`'dnl The expansion of _DEPRECATE_IFDEF_END ends with a newline
ifelse(`$15',,,`#endif // $15
')
_POP()')
dnl
dnl static method
dnl $1 $2 $3 $4 $5 $6 $7
dnl _STATIC_METHOD(cppname,cname,cpprettype,crettype,arglist,cdeclarations,cargs,
dnl $8 $9 $10 $11 $12 $13
dnl cinitializations,refreturn,errthrow,deprecated,ifdef,out_param,
dnl $14 $15 $16 $17 $18
dnl out_param_type,slot_type,slot_name,no_slot_copy,wrap_line)
define(`_STATIC_METHOD',`dnl
_PUSH(SECTION_CC)
ifelse(`$12',,,`#ifdef $12'
)dnl
ifelse(`$11',,,`_DEPRECATE_IFDEF_START`'dnl The expansion of _DEPRECATE_IFDEF_START ends with a newline
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
')dnl
$3 __CPPNAME__::$1($5)
{
ifelse(`$9'`$10',,dnl
dnl If a slot type has been specified insert a slot copy declaration.
ifelse(`$15',,,dnl
dnl See if the slot should or should not be copied
`ifelse(`$17',,dnl
` // Create a copy of the slot.
auto slot_copy = new $15($16); ',dnl
dnl
` // Use the original slot (not a copy).
auto slot_copy = const_cast<$15*>(&$16);')
')`'dnl
dnl Insert declarations for C the output parameters
ifelse(`$6',,,`$6
')`'dnl
`ifelse(`$13',,
dnl If no C++ output parameter is specified.
` ifelse(`$3',void,,dnl
dnl Returns non-void:
dnl Store the return if there are C output parameters
ifelse(`$6',,`return ',``$3' retval = '))_CONVERT($4,`$3',`$2`'($7)');'dnl
dnl A C++ output parameter is specified so initialize it from C return
,` _INITIALIZE($14,$4,`$13',`$2`'($7)',$18);'dnl
)
dnl Insert the initializations for the C output parameters if there are any
ifelse(`$8',,,`$8
')`'dnl
dnl Return the value if it was stored and if the method returns something
ifelse(`$3',void,,`ifelse(`$6',,,` return retval;
')')dnl
',dnl End if a C++ output parameter is specified.
`ifelse(`$10',,,` GError* gerror = nullptr;')
dnl If a slot type has been specified insert a slot copy declaration.
ifelse(`$15',,,dnl
dnl See if the slot should or should not be copied
`ifelse(`$17',,dnl
` // Create a copy of the slot.
auto slot_copy = new $15($16); ',dnl
dnl
` // Use the original slot (not a copy).
auto slot_copy = const_cast<$15*>(&$16);')
')`'dnl
dnl Insert the declarations for the C output parameters
ifelse(`$6',,,`$6
')`'dnl
ifelse(`$13',,dnl If no C++ output parameter is specified:
ifelse(`$3',void,,``$3' retvalue = ')_CONVERT($4,`$3',`$2`'($7)');dnl
dnl A C++ output parameter is specified:
,` _INITIALIZE($14,$4,`$13',`$2`'($7)',$18);'dnl
)dnl
ifelse(`$10',,,`
if(gerror)
::Glib::Error::throw_exception(gerror);
')dnl
dnl Insert the initializations for the C output parameters.
ifelse(`$8',,,`$8
')`'dnl
ifelse(`$9',,,`
if(ifelse(`$13',,`retvalue',$13))
ifelse(`$13',,`retvalue',$13)->reference(); //The function does not do a ref for us
')dnl
ifelse(`$3',void,,` return retvalue;
')dnl
')dnl
}
ifelse(`$11',,,`G_GNUC_END_IGNORE_DEPRECATIONS
_DEPRECATE_IFDEF_END')`'dnl The expansion of _DEPRECATE_IFDEF_END ends with a newline
ifelse(`$12',,,`#endif // $12
')
_POP()')

View File

@@ -0,0 +1,38 @@
dnl
dnl
dnl Code generation sections for properties
dnl
dnl
dnl $1 $2 $3 $4 $5 $6
dnl _PROPERTY_PROXY(name, name_underscored, cpp_type, proxy_suffix, deprecated, docs)
dnl proxy_suffix could be "", "_WriteOnly" or "_ReadOnly"
dnl The method will be const if the propertyproxy is _ReadOnly.
dnl
define(`_PROPERTY_PROXY',`dnl
dnl
dnl Put spaces around the template parameter if necessary.
pushdef(`__PROXY_TYPE__',`dnl
Glib::PropertyProxy$4< _QUOTE($3) >'dnl
)dnl
/** $6
*
* @return A PropertyProxy$4 that allows you to dnl
ifelse($4,_ReadOnly,get,`ifelse($4,_WriteOnly,set,get or set)') the value of the property,
* or receive notification when the value of the property changes.
*/
__PROXY_TYPE__ property_$2`'() ifelse($4,_ReadOnly, const,);
_PUSH(SECTION_CC_PROPERTYPROXIES)
ifelse(`$5',,,`_DEPRECATE_IFDEF_START
')dnl
__PROXY_TYPE__ __CPPNAME__::property_$2`'() ifelse($4,_ReadOnly, const,)
{
return __PROXY_TYPE__`'(this, "$1");
}
ifelse(`$5',,,`_DEPRECATE_IFDEF_END
')dnl
_POP()
popdef(`__PROXY_TYPE__')dnl
')dnl

View File

@@ -0,0 +1,353 @@
#
# --------------------------- Signal Decl----------------------------
#
dnl _SIGNAL_PROXY($1 = c_signal_name,
dnl $2 = c_return_type,
dnl $3 = `<c_arg_types_and_names>',
dnl $4 = cpp_signal_name,
dnl $5 = cpp_return_type,
dnl $6 = `<cpp_arg_types>',
dnl $7 = `<c_args_to_cpp>',
dnl $8 = `custom_c_callback (boolean)',
dnl $9 = `deprecated' (boolean),
dnl $10 = `refdoc_comment',
dnl $11 = ifdef,
dnl $12 = exceptionHandler,
dnl $13 = detail_name,
dnl $14 = two_signal_methods (boolean))
define(`_SIGNAL_PROXY',`
ifelse(`$11',,,`#ifdef $11'
)dnl
ifelse(`$9',,,`_DEPRECATE_IFDEF_START
')dnl
ifelse($13,,`dnl no detail_name
$10
Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > signal_$4`'();
',dnl detail_name
$14,0,`dnl
$10
Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > signal_$4`'(const Glib::ustring& $13 = Glib::ustring());
',`dnl detail_name and two_signal_methods
$10
Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > signal_$4`'();
$10
Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > signal_$4`'(const Glib::ustring& $13);
')dnl end detail_name
ifelse(`$9',,,`_DEPRECATE_IFDEF_END
')dnl
ifelse(`$11',,,`#endif // $11
')dnl
dnl
_PUSH(SECTION_ANONYMOUS_NAMESPACE)
ifelse(`$11',,,`#ifdef $11'
)dnl
ifelse(`$9',,,`_DEPRECATE_IFDEF_START
')dnl
dnl
ifelse($2`'_NUM($3)`'$5`'_NUM($6)`'$8`'_NUM($12),`void0void000',`dnl
dnl
dnl Use predefined callback for SignalProxy0<void>, to reduce code size,
dnl if custom_c_callback or exception_handler is not specified.
static const Glib::SignalProxyInfo __CPPNAME__`'_signal_$4_info =
{
"$1",
(GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
(GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};
',`dnl else
ifelse($8,`1',,`dnl Do not generate the implementation if it should be custom:
static $2 __CPPNAME__`'_signal_$4_callback`'(__CNAME__`'* self, _COMMA_SUFFIX($3)`'void* data)
{
using namespace __NAMESPACE__;
using SlotType = sigc::slot< $5`'_COMMA_PREFIX($6) >;
auto obj = dynamic_cast<__CPPNAME__*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
// Do not try to call a signal on a disassociated wrapper.
if(obj)
{
try
{
if(const auto slot = Glib::SignalProxyNormal::data_to_slot`'(data))
ifelse(`$2',void,`dnl
(*static_cast<SlotType*>(slot))($7);
',`dnl else
return _CONVERT($5,$2,`(*static_cast<SlotType*>(slot))($7)');
')dnl endif
}
catch(...)
{
ifelse($12, `', `dnl
Glib::exception_handlers_invoke`'();
', `dnl
try
{
return _CONVERT($5, $2, `obj->$12`'()');
}
catch(...)
{
Glib::exception_handlers_invoke`'();
}
')dnl
}
}
ifelse($2,void,,`dnl else
using RType = $2;
return RType`'();
')dnl
}
ifelse($2,void,,`dnl else
static $2 __CPPNAME__`'_signal_$4_notify_callback`'(__CNAME__`'* self, _COMMA_SUFFIX($3)`' void* data)
{
using namespace __NAMESPACE__;
using SlotType = sigc::slot< void`'_COMMA_PREFIX($6) >;
auto obj = dynamic_cast<__CPPNAME__*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
// Do not try to call a signal on a disassociated wrapper.
if(obj)
{
try
{
if(const auto slot = Glib::SignalProxyNormal::data_to_slot`'(data))
(*static_cast<SlotType*>(slot))($7);
}
catch(...)
{
ifelse($12, `', `dnl
Glib::exception_handlers_invoke`'();
', `dnl
try
{
return _CONVERT($5, $2, `obj->$12`'()');
}
catch(...)
{
Glib::exception_handlers_invoke`'();
}
')dnl
}
}
using RType = $2;
return RType`'();
}
')dnl endif
')dnl endif
static const Glib::SignalProxyInfo __CPPNAME__`'_signal_$4_info =
{
"$1",
(GCallback) &__CPPNAME__`'_signal_$4_callback,
(GCallback) &__CPPNAME__`'_signal_$4_`'ifelse($2,void,,notify_)`'callback
};
')dnl endif
ifelse(`$9',,,`_DEPRECATE_IFDEF_END
')dnl
ifelse(`$11',,,`#endif // $11
')dnl
_SECTION(SECTION_CC_SIGNALPROXIES)
ifelse(`$11',,,`#ifdef $11'
)dnl
ifelse(`$9',,,`_DEPRECATE_IFDEF_START
')dnl
ifelse($13,,`dnl no detail_name
Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'()
{
return Glib::SignalProxy< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info);
}
',dnl detail_name
$14,0,`dnl
Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'(const Glib::ustring& $13)
{
return Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info, $13);
}
',`dnl detail_name and two_signal_methods
Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'()
{
return Glib::SignalProxy< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info);
}
Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'(const Glib::ustring& $13)
{
return Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info, $13);
}
')dnl end detail_name
ifelse(`$9',,,`_DEPRECATE_IFDEF_END
')dnl
ifelse(`$11',,,`#endif // $11
')dnl
_POP()')
dnl $1 $2 $3 $4 $5 $6
dnl _SIGNAL_PH(gname, crettype, cargs and names, ifdef, deprecated, exceptionHandler)
dnl Create a callback and set it in our derived G*Class.
dnl
define(`_SIGNAL_PH',`dnl
_PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
ifelse(`$4',,,`#ifdef $4'
)dnl
ifelse(`$5',,,`_DEPRECATE_IFDEF_START
')dnl
klass->$1 = `&'$1_callback;
ifelse(`$5',,,`_DEPRECATE_IFDEF_END
')dnl
ifelse(`$4',,,`#endif // $4
')dnl
_SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
ifelse(`$4',,,`#ifdef $4'
)dnl
ifelse(`$5',,,`_DEPRECATE_IFDEF_START
')dnl
static $2 $1_callback`'($3);
ifelse(`$5',,,`_DEPRECATE_IFDEF_END
')dnl
ifelse(`$4',,,`#endif // $4
')dnl
_POP()')
dnl $1 $2 $3 $4 $5 $6
dnl _SIGNAL_PCC(cppname,gname,cpprettype,crettype,`<cargs and names>',`<cnames>',
dnl $7 $8 $9 $10 $11
dnl `<cpparg names>',firstarg,<ifdef>,deprecated,exceptionHandler)
dnl
define(`_SIGNAL_PCC',`dnl
_PUSH(SECTION_PCC_DEFAULT_SIGNAL_HANDLERS)
ifelse(`$9',,,`#ifdef $9'
)dnl
ifelse(`$10',,,`_DEPRECATE_IFDEF_START
')dnl
$4 __CPPNAME__`'_Class::$2_callback`'($5)
{
dnl First, do a simple cast to ObjectBase. We will have to do a dynamic_cast
dnl eventually, but it is not necessary to check whether we need to call
dnl the vfunc.
const auto obj_base = static_cast<Glib::ObjectBase*>(
Glib::ObjectBase::_get_current_wrapper`'((GObject*)$8));
_IMPORT(SECTION_CHECK)
// Non-gtkmmproc-generated custom classes implicitly call the default
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
// generated classes can use this optimisation, which avoids the unnecessary
// parameter conversions if there is no possibility of the virtual function
// being overridden:
if(obj_base && obj_base->is_derived_())
{
dnl We need to do a dynamic cast to get the real object type, to call the
dnl C++ vfunc on it.
const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
if(obj) // This can be NULL during destruction.
{
try // Trap C++ exceptions which would normally be lost because this is a C callback.
{
// Call the virtual member method, which derived classes might override.
ifelse($4,void,`dnl
obj->on_$1`'($7);
return;
',`dnl
return _CONVERT($3,$4,`obj->on_$1`'($7)');
')dnl
}
catch(...)
{
ifelse($11, `', `dnl
Glib::exception_handlers_invoke`'();
', `dnl
try
{
return _CONVERT($3, $4, `obj->$11`'()');
}
catch(...)
{
Glib::exception_handlers_invoke`'();
}
')dnl
}
}
}
const auto base = static_cast<BaseClassType*>(
ifdef(`__BOOL_IS_INTERFACE__',`dnl
_IFACE_PARENT_FROM_OBJECT($8)dnl
',`dnl
_PARENT_GCLASS_FROM_OBJECT($8)dnl
') );
dnl g_assert(base != nullptr);
// Call the original underlying C function:
if(base && base->$2)
ifelse($4,void,,`return ')(*base->$2)`'($6);
ifelse($4,void,,`dnl
using RType = $4;
return RType`'();
')dnl
}
ifelse(`$10',,,`_DEPRECATE_IFDEF_END
')dnl
ifelse(`$9',,,`#endif // $9
')dnl
_POP()')
dnl $1 $2 $3 $4
dnl _SIGNAL_H(signame, rettype, `<cppargs>', <ifdef>)
dnl
define(`_SIGNAL_H',`dnl
_PUSH(SECTION_H_DEFAULT_SIGNAL_HANDLERS)
ifelse(`$4',,,`#ifdef $4'
)dnl
/// This is a default handler for the signal signal_$1`'().
virtual $2 on_$1`'($3);
ifelse(`$4',,,`#endif // $4
')dnl
_POP()')
dnl $1 $2 $3 $4 $5 $6 $7 $8 $9
dnl _SIGNAL_CC(signame,gname,rettype,crettype,`<cppargs>',`<carg_names>', const, refreturn, <ifdef>)
dnl
define(`_SIGNAL_CC',`dnl
_PUSH(SECTION_CC_DEFAULT_SIGNAL_HANDLERS)
ifelse(`$9',,,`#ifdef $9'
)dnl
$3 __NAMESPACE__::__CPPNAME__::on_$1`'($5)
{
const auto base = static_cast<BaseClassType*>(
ifdef(`__BOOL_IS_INTERFACE__',`dnl
_IFACE_PARENT_FROM_OBJECT(gobject_)dnl
',`dnl
_PARENT_GCLASS_FROM_OBJECT(gobject_)dnl
') );
dnl g_assert(base != nullptr);
if(base && base->$2)
ifelse($3,void,`dnl
(*base->$2)`'(gobj`'()`'_COMMA_PREFIX($6));
',`dnl
ifelse($8,refreturn,`dnl Assume Glib::wrap() is correct if refreturn is requested.
return Glib::wrap((*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6)), true);
',`dnl
return _CONVERT($4,$3,`(*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6))');
')dnl
using RType = $3;
return RType`'();
')dnl
}
ifelse(`$9',,,`#endif // $9
')dnl
_POP()')

View File

@@ -0,0 +1,233 @@
dnl
dnl _VFUNC_PH(gtkname, crettype, cargs and names)
dnl Create a callback and set it in our derived G*Class.
dnl
define(`_VFUNC_PH',`dnl
_PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
ifelse(`$4',,,`#ifdef $4'
)dnl
klass->$1 = `&'$1_vfunc_callback;
ifelse(`$4',,,`#endif // $4
')dnl
_SECTION(SECTION_PH_VFUNCS)
ifelse(`$4',,,`#ifdef $4'
)dnl
static $2 $1_vfunc_callback`'($3);
ifelse(`$4',,,`#endif // $4
')dnl
_POP()')
dnl $1 $2 $3 $4
dnl _VFUNC_PCC(cppname,gtkname,cpprettype,crettype,
dnl $5 $6 $7 $8
dnl `<cargs and names>',`<cnames>',`<cpparg names>',firstarg,
dnl $9 $10 $11 $12
dnl refreturn_ctype, keep_return, ifdef, errthrow,
dnl $13 $14 $15 $16 $17
dnl slot_type, c_data_param_name, return_value, err_return_value, exception_handler)
dnl
dnl Note: _get_current_wrapper_inline() could be used throughout for performance instead of _get_current_wrapper(),
dnl and is_derived_() instead of is_derived_(),
dnl but it is not yet clear whether that would be a worthwhile performance optimization.
define(`_VFUNC_PCC',`dnl
_PUSH(SECTION_PCC_VFUNCS)
ifelse(`$11',,,`#ifdef $11'
)dnl
$4 __CPPNAME__`'_Class::$2_vfunc_callback`'($5)
{
ifelse(`$14',,,dnl
` const auto slot = static_cast<$13*>($14);
')dnl
dnl First, do a simple cast to ObjectBase. We will have to do a dynamic_cast
dnl eventually, but it is not necessary to check whether we need to call
dnl the vfunc.
const auto obj_base = static_cast<Glib::ObjectBase*>(
Glib::ObjectBase::_get_current_wrapper`'((GObject*)$8));
_IMPORT(SECTION_CHECK)
// Non-gtkmmproc-generated custom classes implicitly call the default
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
// generated classes can use this optimisation, which avoids the unnecessary
// parameter conversions if there is no possibility of the virtual function
// being overridden:
if(obj_base && obj_base->is_derived_())
{
dnl We need to do a dynamic cast to get the real object type, to call the
dnl C++ vfunc on it.
const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
if(obj) // This can be NULL during destruction.
{
try // Trap C++ exceptions which would normally be lost because this is a C callback.
{
// Call the virtual member method, which derived classes might override.
ifelse($4,void,`dnl
obj->$1`'($7);
return;
',`dnl not void
ifelse($9,refreturn_ctype,`dnl Assume Glib::unwrap_copy() is correct if refreturn_ctype is requested.
return Glib::unwrap_copy`'(`obj->$1'($7));
',`dnl not refreturn_ctype
ifelse($10,keep_return,`dnl
static auto quark_return_value = g_quark_from_static_string("__NAMESPACE__::__CPPNAME__::$1");
auto return_value = static_cast<$3*>(g_object_get_qdata(obj_base->gobj(), quark_return_value));
if (!return_value)
{
return_value = new $3`'();
g_object_set_qdata_full(obj_base->gobj(), quark_return_value, return_value,
&Glib::destroy_notify_delete<$3>);
}
// Keep a copy of the return value. The caller is not expected
// to free the object that the returned pointer points to.
*return_value = obj->$1`'($7);
return _CONVERT($3,$4,`(*return_value)');
',`dnl not keep_return
return _CONVERT($3,$4,`obj->$1`'($7)');
')dnl end keep_return
')dnl end refreturn_ctype
')dnl end void
}
ifelse($17,,,`dnl if (exception_handler)
catch(...)
{
try
{
ifelse($9,refreturn_ctype,`dnl
return Glib::unwrap_copy`'(obj->$17`'());
', `dnl
return _CONVERT($3, $4, `obj->$17`'()');
')dnl
}
')dnl end exception_handler
ifelse($12,errthrow,`dnl
catch(Glib::Error& errormm)
{
errormm.propagate(error);
ifelse($4,void,`dnl
return;
',`dnl
ifelse(`$16', `',`dnl
using RType = $4;
return RType`'();
',`dnl
return _CONVERT($3,$4,`$16');
')dnl
')dnl
}
')dnl end errthrow
catch(...)
{
Glib::exception_handlers_invoke`'();
}
ifelse($17,,,`dnl if (exception_handler)
}
')dnl
}
}
BaseClassType *const base = static_cast<BaseClassType*>(
ifdef(`__BOOL_IS_INTERFACE__',`dnl
_IFACE_PARENT_FROM_OBJECT($8)dnl
',`dnl
_PARENT_GCLASS_FROM_OBJECT($8)dnl
') );
dnl g_assert(base != nullptr);
// Call the original underlying C function:
if(base && base->$2)
ifelse($4,void,,`return ')(*base->$2)`'($6);
ifelse($4,void,,`dnl
ifelse(`$15', `',`dnl
using RType = $4;
return RType`'();
',`dnl
return _CONVERT($3,$4,`$15');
')dnl
')dnl
}
ifelse(`$11',,,`#endif // $11
')dnl
_POP()')
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14
# _VFUNC_CC(vfunc_name, gtkname, cpp_rettype, c_rettype, `<cppargs>', `<carg_names>', is_const, refreturn, $ifdef, $errthrow, $slot_type, $slot_name, $no_slot_copy, $returnValue)
#
define(`_VFUNC_CC',`dnl
_PUSH(SECTION_CC_VFUNCS)
ifelse(`$9',,,`#ifdef $9'
)dnl
$3 __NAMESPACE__::__CPPNAME__::$1`'($5) ifelse($7,1,const,)
{
dnl If a slot type has been specified, insert code to create a copy of it.
ifelse(`$11',,,dnl
dnl See if the slot should or should not be copied
`ifelse(`$13',,dnl
` // Create a copy of the slot.
auto slot_copy = new $11($12); ',dnl
dnl
` // Use the original slot (not a copy).
auto slot_copy = const_cast<$11*>(&$12);')
')dnl
const auto base = static_cast<BaseClassType*>(
ifdef(`__BOOL_IS_INTERFACE__',`dnl
_IFACE_PARENT_FROM_OBJECT(gobject_)dnl
',`dnl
_PARENT_GCLASS_FROM_OBJECT(gobject_)dnl
') );
dnl g_assert(base != nullptr);
if(base && base->$2)
{
ifelse($10,errthrow,`dnl
GError* gerror = nullptr;
')dnl
ifelse($3,void,`dnl
(*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6));
}
',`dnl
ifelse($8,refreturn,`dnl Assume Glib::wrap() is correct if refreturn is requested.
$3 retval(Glib::wrap((*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6)), true));
',`dnl
$3 retval(_CONVERT($4,$3,`(*base->$2)`'(ifelse(`$7',1,const_cast<__CNAME__*>(gobj()),gobj())`'_COMMA_PREFIX($6))'));
')dnl
ifelse($10,errthrow,`dnl
if(gerror)
::Glib::Error::throw_exception(gerror);
')dnl
return retval;
}
ifelse(`$14', `',`dnl
using RType = $3;
return RType`'();
',`dnl
return $14;
')dnl
')dnl
}
ifelse(`$9',,,`#endif // $9
')dnl
_POP()')
# $1 $2 $3 $4 $5
# _VFUNC_H(vfunc_name, rettype, `<cppargs>', is_const, ifndef)
# Only used for custom vfuncs.
#
define(`_VFUNC_H',`dnl
_PUSH(SECTION_H_VFUNCS)
ifelse(`$5',,,`#ifdef $5'
)dnl
ifelse($4,`1',`dnl
virtual $2 $1`'($3) const;
',`dnl
virtual $2 $1`'($3);
')
ifelse(`$5',,,`#endif // $5
')dnl
_POP()')