LibreOffice Module bridges (master) 1
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
bridges::cpp_uno::shared::VtableFactory Class Reference

Hand out vtable structures for interface type descriptions. More...

#include <vtablefactory.hxx>

Classes

class  BaseOffset
 
struct  Block
 A raw vtable block. More...
 
class  GuardedBlocks
 
struct  Slot
 
struct  Vtables
 The vtable structure corresponding to an interface type. More...
 

Public Member Functions

 VtableFactory ()
 
 ~VtableFactory ()
 
const VtablesgetVtables (typelib_InterfaceTypeDescription *type)
 Given an interface type description, return its corresponding vtable structure. More...
 

Static Public Member Functions

static SlotmapBlockToVtable (void *block)
 Given a pointer to a block, turn it into a vtable pointer. More...
 

Private Types

typedef std::unordered_map< OUString, VtablesMap
 

Private Member Functions

 VtableFactory (VtableFactory const &)=delete
 
VtableFactoryoperator= (const VtableFactory &)=delete
 
bool createBlock (Block &block, sal_Int32 slotCount) const
 
void freeBlock (Block const &block) const
 
sal_Int32 createVtables (GuardedBlocks &blocks, BaseOffset const &baseOffset, typelib_InterfaceTypeDescription *type, sal_Int32 vtableNumber, typelib_InterfaceTypeDescription *mostDerived, bool includePrimary) const
 

Static Private Member Functions

static std::size_t getBlockSize (sal_Int32 slotCount)
 Calculate the size of a raw vtable block. More...
 
static SlotinitializeBlock (void *block, sal_Int32 slotCount, sal_Int32 vtableNumber, typelib_InterfaceTypeDescription *type)
 Initialize a raw vtable block. More...
 
static unsigned char * addLocalFunctions (Slot **slots, unsigned char *code, sal_PtrDiff writetoexecdiff, typelib_InterfaceTypeDescription const *type, sal_Int32 functionOffset, sal_Int32 functionCount, sal_Int32 vtableOffset)
 Fill the vtable slots corresponding to all local (i.e., not inherited) functions of a given interface type (and generate any necessary code snippets for them). More...
 
static void flushCode (unsigned char const *begin, unsigned char const *end)
 Flush all the generated code snippets of a vtable, on platforms that require it. More...
 

Private Attributes

std::mutex m_mutex
 
Map m_map
 
rtl_arena_type * m_arena
 

Friends

class GuardedBlocks
 

Detailed Description

Hand out vtable structures for interface type descriptions.

Definition at line 42 of file vtablefactory.hxx.

Member Typedef Documentation

◆ Map

typedef std::unordered_map< OUString, Vtables > bridges::cpp_uno::shared::VtableFactory::Map
private

Definition at line 211 of file vtablefactory.hxx.

Constructor & Destructor Documentation

◆ VtableFactory() [1/2]

VtableFactory::VtableFactory ( )

Definition at line 203 of file vtablefactory.cxx.

References m_arena.

◆ ~VtableFactory()

VtableFactory::~VtableFactory ( )

Definition at line 214 of file vtablefactory.cxx.

References freeBlock(), m_arena, m_map, and m_mutex.

◆ VtableFactory() [2/2]

bridges::cpp_uno::shared::VtableFactory::VtableFactory ( VtableFactory const &  )
privatedelete

Member Function Documentation

◆ addLocalFunctions()

unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions ( Slot **  slots,
unsigned char *  code,
sal_PtrDiff  writetoexecdiff,
typelib_InterfaceTypeDescription const *  type,
sal_Int32  functionOffset,
sal_Int32  functionCount,
sal_Int32  vtableOffset 
)
staticprivate

Fill the vtable slots corresponding to all local (i.e., not inherited) functions of a given interface type (and generate any necessary code snippets for them).

Parameters
slotson input, points past the vtable slot to be filled with the last virtual function local to the given type; on output, points to the vtable slot filled with the first virtual function local to the given type
codepoints to the start of the area where code snippets can be generated
writetoexecdiffwhen the same code area is mapped twice, once for writing for code-generation, and once for code-execution, then this records the offset from a writable address to its executable address
typethe interface type description for which to generate vtable slots
functionOffsetthe function offset of the first vtable slot (typically coded into the code snippet for that vtable slot)
functionCountthe number of vtable slots to fill (the number of local functions of the given type, passed in so that it doesn't need to be recomputed)
vtableOffsetthe offset of this vtable (needed to adjust the this pointer, typically coded into the code snippets for all the filled vtable slots)
Returns
a pointer to the remaining code snippet area

Definition at line 496 of file gcc3_ios/cpp2uno.cxx.

References code, codeSnippet(), i, and type.

Referenced by createVtables().

◆ createBlock()

bool VtableFactory::createBlock ( Block block,
sal_Int32  slotCount 
) const
private

◆ createVtables()

sal_Int32 VtableFactory::createVtables ( GuardedBlocks blocks,
BaseOffset const &  baseOffset,
typelib_InterfaceTypeDescription *  type,
sal_Int32  vtableNumber,
typelib_InterfaceTypeDescription *  mostDerived,
bool  includePrimary 
) const
private

◆ flushCode()

void bridges::cpp_uno::shared::VtableFactory::flushCode ( unsigned char const *  begin,
unsigned char const *  end 
)
staticprivate

Flush all the generated code snippets of a vtable, on platforms that require it.

Parameters
beginpoints to the start of the code snippet area
endpoints behind the end of the code snippet area

Definition at line 544 of file gcc3_ios/cpp2uno.cxx.

Referenced by createVtables().

◆ freeBlock()

void VtableFactory::freeBlock ( Block const &  block) const
private

◆ getBlockSize()

std::size_t bridges::cpp_uno::shared::VtableFactory::getBlockSize ( sal_Int32  slotCount)
staticprivate

Calculate the size of a raw vtable block.

Parameters
slotCountthe number of virtual function slots the returned vtable block shall support (if there are any platform-specific slots, like an RTTI pointer, or a pointer to a destructor, they are not covered by slotCount)
Returns
the size of the raw vtable block, in bytes

Definition at line 473 of file gcc3_ios/cpp2uno.cxx.

Referenced by createBlock().

◆ getVtables()

const VtableFactory::Vtables & VtableFactory::getVtables ( typelib_InterfaceTypeDescription *  type)

◆ initializeBlock()

bridges::cpp_uno::shared::VtableFactory::Slot * bridges::cpp_uno::shared::VtableFactory::initializeBlock ( void *  block,
sal_Int32  slotCount,
sal_Int32  vtableNumber,
typelib_InterfaceTypeDescription *  type 
)
staticprivate

Initialize a raw vtable block.

Parameters
blockthe start address of the raw vtable block
slotCountthe number of slots
vtableNumberzero-based count across all the most derived type's vtables (for vtable's "offset to top" slot)
typenon-null most derived type (for vtable's "typeinfo pointer" slot)
Returns
a pointer past the last vtable slot

Definition at line 486 of file gcc3_ios/cpp2uno.cxx.

References bridges::cpp_uno::shared::VtableFactory::Slot::fn.

Referenced by createVtables().

◆ mapBlockToVtable()

bridges::cpp_uno::shared::VtableFactory::Slot * bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable ( void *  block)
static

Given a pointer to a block, turn it into a vtable pointer.

Definition at line 468 of file gcc3_ios/cpp2uno.cxx.

Referenced by bridges::cpp_uno::shared::CppInterfaceProxy::create().

◆ operator=()

VtableFactory & bridges::cpp_uno::shared::VtableFactory::operator= ( const VtableFactory )
privatedelete

Friends And Related Function Documentation

◆ GuardedBlocks

friend class GuardedBlocks
friend

Definition at line 120 of file vtablefactory.hxx.

Member Data Documentation

◆ m_arena

rtl_arena_type* bridges::cpp_uno::shared::VtableFactory::m_arena
private

Definition at line 216 of file vtablefactory.hxx.

Referenced by createBlock(), freeBlock(), VtableFactory(), and ~VtableFactory().

◆ m_map

Map bridges::cpp_uno::shared::VtableFactory::m_map
private

Definition at line 214 of file vtablefactory.hxx.

Referenced by getVtables(), and ~VtableFactory().

◆ m_mutex

std::mutex bridges::cpp_uno::shared::VtableFactory::m_mutex
private

Definition at line 213 of file vtablefactory.hxx.

Referenced by getVtables(), and ~VtableFactory().


The documentation for this class was generated from the following files: