// Generated by gmmproc 2.86.0 -- DO NOT MODIFY!


#include <glibmm.h>

#include <gtkmm/expression.h>
#include <gtkmm/private/expression_p.h>


/* Copyright (C) 2020 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/expression.h>
#include <utility> // std::swap()

namespace Gtk
{

namespace Expression_Private
{
extern "C"
{
// A function with external linkage and C linkage does not get a mangled name.
// Even though gtkmm_Expression_watch_callback() is declared in a named namespace,
// the linker does not see the namespace name.
// Therefore the function name shall have a prefix, hopefully unique.
void gtkmm_Expression_watch_callback(gpointer data)
{
  auto slot = static_cast<ExpressionBase::SlotNotify*>(data);
  (*slot)();
}

void gtkmm_Expression_watch_callback_destroy(gpointer data)
{
  delete static_cast<ExpressionBase::SlotNotify*>(data);
}

void gtkmm_Expression_closure_callback_func()
{}

void gtkmm_Expression_closure_marshal(GClosure* closure,
                     GValue* return_value,
                     guint n_param_values,
                     const GValue* param_values,
                     gpointer invocation_hint,
                     gpointer user_data)
{
  auto marshal_data = static_cast<ExpressionClosureData*>(closure->data);
  std::swap(marshal_data->data, closure->data);
  (*marshal_data->func)(closure, return_value, n_param_values, param_values,
    invocation_hint, user_data);
  std::swap(marshal_data->data, closure->data);
}

void gtkmm_Expression_closure_destroy(gpointer data, GClosure* closure)
{
  auto marshal_data = static_cast<ExpressionClosureData*>(closure->data);
  // Delete the Invoker.
  std::swap(marshal_data->data, closure->data);
  (*marshal_data->destroy_func)(data, closure);
  std::swap(marshal_data->data, closure->data);
  // Delete the ExpressionClosureData.
  delete marshal_data;
}
} // extern "C"

void watch_callback(gpointer data)
{
  auto slot = static_cast<sigc::slot<void()>*>(data);
  (*slot)();
}

void closure_callback_func()
{}

} // namespace Expression_Private

} // namespace Gtk

namespace
{
} // anonymous namespace


/* Why reinterpret_cast<ExpressionBase*>(gobject) is needed:
 *
 * A ExpressionBase instance is in fact always a GtkExpression instance.
 * Unfortunately, GtkExpression cannot be a member of ExpressionBase,
 * 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 ExpressionBase 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<Gtk::ExpressionBase> wrap(GtkExpression* object, bool take_copy)
{
  if(take_copy && object)
    gtk_expression_ref(object);

  // See the comment at the top of this file, if you want to know why the cast works.
  return Glib::make_refptr_for_instance<Gtk::ExpressionBase>(reinterpret_cast<Gtk::ExpressionBase*>(object));
}

} // namespace Glib


namespace Gtk
{

void ExpressionBase::reference() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  gtk_expression_ref(reinterpret_cast<GtkExpression*>(const_cast<ExpressionBase*>(this)));
}

void ExpressionBase::unreference() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  gtk_expression_unref(reinterpret_cast<GtkExpression*>(const_cast<ExpressionBase*>(this)));
}

GtkExpression* ExpressionBase::gobj()
{
  // See the comment at the top of this file, if you want to know why the cast works.
  return reinterpret_cast<GtkExpression*>(this);
}

const GtkExpression* ExpressionBase::gobj() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  return reinterpret_cast<const GtkExpression*>(this);
}

GtkExpression* ExpressionBase::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<GtkExpression*>(const_cast<ExpressionBase*>(this));
  gtk_expression_ref(gobject);
  return gobject;
}


GType ExpressionBase::get_value_type() const
{
  return gtk_expression_get_value_type(const_cast<GtkExpression*>(gobj()));
}

bool ExpressionBase::is_static() const
{
  return gtk_expression_is_static(const_cast<GtkExpression*>(gobj()));
}


} // namespace Gtk


