On Wed, Oct 24, 2007 at 02:17:45PM -0400, Richard Heck wrote:
> I think the following would work, and we would need to go roughly this 
> way, anyway, since InsetCommandParams can live without an inset to which 
> they're attached. Namely: Pass the buffer when the ICP is created. Then 
> we will again have a problem about insets transferred across buffers, 
> but I suppose that could be solved in the cut and paste code. It looks 
> to me as if this happens for InsetTabular already in CutAndPaste.cpp, 
> lines 216ff. So if we did something like:
>    case BIBTEX_CODE:
>    case BIBITEM_CODE:
>    etc.etc.
>       InsetCommand * it = static_cast<InsetCommand *>(lit->inset);
>       it->buffer(&buffer);
>       break;
> would that be enough? Note: it->buffer() would be responsible for 
> updating the buffer reference in the associated ICP.
> 
> Also, these casts confuse me sometimes. (I take it I'm not the only 
> one.) If buffer() were virtual---it wouldn't be in this case, but the 
> question is general---we'd still get dynamic binding, or no? I.e., if it 
> is really an InsetBibitem, then InsetBibitem::buffer() gets called, or no?

Right.

Just think about how it is implemented. An object with vritual functions
usually has an extra pointer pointing to the table of virtual functions
of the object's "real" class. A static cast does not change anything in
a single-inheritance hierarchy, so the same poiter to the same vtable
will be used in the end.

Andre'

Reply via email to