Re: interface question



On Sun, 2006-09-24 at 00:48 +0200, Johannes Schmid wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi!
> 
> > In the meantime, I think you can do what Glib::wrap does, by calling the
> > cobject* constructor directly, and being careful about it.
> 
> Can you explain this a bit more, please? Glib::wrap calls
> Glib::wrap_auto which uses some table of virtual functions to do the
> wrapping. I am not sure how I could use this directly.

I guess you could do something hacky like this:

Glib::RefPtr<Anjuta::Shell> wrap_anjuta_shell(AnjutaShell* object)
{
  ObjectBase* pCppObject =
static_cast<ObjectBase*>(g_object_get_qdata(object, Glib::quark_));

  if(pCppObject)
    return dynamic_cast<Anjuta::Shell>(pCppObject)
  else
    return Glib::RefPtr<Anjuta::Shell>( new AnjutaShell(object) );
}

Alternatively, maybe we want to expand the wrap() system so that it
looks at interface types when there is no recognised parent type.

But one thing that bothers me is that the AnjutaApp should at least
derive from GObject, so the wrap() system should at least try to return
a Glib::Object.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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