/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
staticbool recursivelyFindType(typelib_TypeDescriptionReference const* demandedType,
typelib_InterfaceTypeDescription const* type, sal_IntPtr* offset)
{ // This code assumes that the vtables of a multiple-inheritance class (the // offset amount by which to adjust the this pointer) follow one another in // the object layout, and that they contain slots for the inherited classes // in a specific order. In theory, that need not hold for any given // platform; in practice, it seems to work well on all supported platforms:
next: for (sal_Int32 i = 0; i < type->nBaseTypes; ++i)
{ if (i > 0)
{
*offset += sizeof(void*);
}
typelib_InterfaceTypeDescription const* base = type->ppBaseTypes[i]; // ignore XInterface: if (base->nBaseTypes > 0)
{ if (td_equals(reinterpret_cast<typelib_TypeDescriptionReference const*>(base),
demandedType))
{ returntrue;
} // Profiling showed that it is important to speed up the common case // of only one base: if (type->nBaseTypes == 1)
{
type = base; goto next;
} if (recursivelyFindType(demandedType, base, offset))
{ returntrue;
}
}
} returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.