[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    Debugging smartwrappers
From:       Stefan Westerfeld <stefan () space ! twc ! de>
Date:       2000-03-19 19:49:47
[Download RAW message or body]

   Hi!

I've spent a bit of time in making smartwrappers nicer. One ugly bug was,
that on having

interface Base {
	void base();
}

interface Derived : Base {
	void derived();
};

this code

	Derived d;
	d.base();

would crash. That happened, since the different (inherited) smartwrappers
involved would have different _var's, which resulted in one being assigned
upon creation, but not the other. The same happened for all other assignments
such as creation from reference or assignment of a (Derived_base *).

The smartwrappers now also no longer use _var's internally, but _base classes
and do reference counting themselves. This is better because in the upper
case, having _vars would result in referencing the object twice and
dereferencing it twice (as you have one _var per smartwrapper).

I am still a bit suspicious of the next change I made: on demand creation.
This allows you to do the following

StereoEffect effect = /* something that returns an effect here */;

without having the effect created and shortly after that destroyed. However

Synth_PLAY p;
p.start();

will make the on demand creation kick in in the second line, so that no
difference to the former behaviour is visible. What do you think?

However, all that reference counting results in having many operations non-
const, although they ought to be const (such as assignment operators and such).
If anybody knows a brilliant solution, let me know.

With these changes, smartwrappers have a chance again to become universal
usable, that means, they maybe could replace all CORBA _var, _copy(),
_release(), _create(), _base* etc. stuff in the code.

I am sorry if my position towards what shall become the MCOP api in the
future currently looks a bit like one day like this, the other day like that.

However, how this is done best is a non-trivial thing to decide.

The arguments currently look like:

  pro "only smartwrappers"

- smartwrappers are easier to use
- they are - now - probably usable everywhere where CORBA syntax is usable
- they might avoid stupid mistakes you otherwise run into

  contra "only smartwrappers"

- smartwrappers increase code size & compile time
- their on-demand-creation semantics is a bit strange

I would be glad if anybody could proof-read my smart wrapper changes.

   Cu... Stefan
-- 
  -* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany
     KDE Developer, project infos at http://space.twc.de/~stefan/kde *-

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic