hand wrapping cluttermm functions



Hi,
How do I return a RefPtr to the object when hand- wrapping a function? I'm pretty certain this is the wrong way to do it.

Alternatively, are there any hand-wrapped functions that return a RefPtr (to the object being called from) in other libraries so I can see how it's been done?

I also can't figure out how to convert a C++ enum to a C enum, although does it matter in this context? ( it's being passed in as a guint, so presumably it should correlate?)

code(a modified cluttermm/clutter/src/animator.hg):


template <class ValueType>
Glib::RefPtr<Animator> Animator::set_key(const Glib::RefPtr<Glib::Object>& object,
                                const Glib::ustring& property_name,
                                guint mode,
                                double progress,
                                const ValueType& value)
{
  ClutterAnimator* animator_ptr = this->gobj();

  Glib::Value<ValueType> property_value;
  property_value.init(Glib::Value<ValueType>::value_type());
  property_value.set(value);

  std::string prop_name = property_name;

  clutter_animator_set_key(animator_ptr,
                        object->gobj(),
                        prop_name.c_str(),
                        mode,
                        progress,
                        property_value.gobj() );

//returning a RefPtr. Can't seem to just call wrap() therefore copied the function. Glib::RefPtr<Clutter::Animator> wrapper = Glib::RefPtr<Clutter::Animator> (dynamic_cast<Clutter::Animator*> (Glib::wrap_auto ((GObject*)(animator_ptr), false)) );

  return wrapper;
}

Ian


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]