23 #include <com/sun/star/uno/genfunc.hxx>
26 #include <typelib/typedescription.hxx>
39 extern "C" typelib_TypeClass
cpp_vtable_call(sal_Int64 nOffsetAndIndex,
void ** pCallStack)
41 sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
42 sal_Int32 nVtableOffset = ((nOffsetAndIndex >> 32) & 0xFFFFFFFF);
43 return cpp_mediate(pCallStack, nFunctionIndex, nVtableOffset,
nullptr);
65 sal_Int32 nFunctionIndex,
66 sal_Int32 nVtableOffset )
68 sal_uInt64 nOffsetAndIndex = (
static_cast<sal_uInt64
>(nVtableOffset) << 32 ) |
static_cast<sal_uInt64
>(nFunctionIndex);
69 unsigned char *
p = code;
72 if (param_kind[0] == REGPARAM_INT)
75 *p++ = 0x48; *p++ = 0x89; *p++ = 0x4C; *p++ = 0x24; *p++ = 0x08;
80 *p++ = 0xF2; *p++ = 0x0F; *p++ = 0x11; *p++ = 0x44; *p++ = 0x24; *p++ = 0x08;
82 if ( param_kind[1] == REGPARAM_INT )
85 *p++ = 0x48; *p++ = 0x89; *p++ = 0x54; *p++ = 0x24; *p++ = 0x10;
90 *p++ = 0xF2; *p++ = 0x0F; *p++ = 0x11; *p++ = 0x4C; *p++ = 0x24; *p++ = 0x10;
92 if ( param_kind[2] == REGPARAM_INT )
95 *p++ = 0x4C; *p++ = 0x89; *p++ = 0x44; *p++ = 0x24; *p++ = 0x18;
100 *p++ = 0xF2; *p++ = 0x0F; *p++ = 0x11; *p++ = 0x54; *p++ = 0x24; *p++ = 0x18;
102 if ( param_kind[3] == REGPARAM_INT )
105 *p++ = 0x4C;*p++ = 0x89; *p++ = 0x4C; *p++ = 0x24; *p++ = 0x20;
110 *p++ = 0xF2; *p++ = 0x0F; *p++ = 0x11; *p++ = 0x5C; *p++ = 0x24; *p++ = 0x20;
114 *p++ = 0x48; *p++ = 0xB9;
115 *
reinterpret_cast<sal_uInt64 *
>(
p) = nOffsetAndIndex; p += 8;
118 *p++ = 0x49; *p++ = 0xBB;
122 *p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
135 return static_cast< Slot *
>(block) + 1;
148 sal_Int32, typelib_InterfaceTypeDescription *)
151 sal_Int32 n0,
n1,
n2;
160 Slot * slots = mapBlockToVtable(block);
161 slots[-1].fn = &rtti;
162 return slots + slotCount;
167 unsigned char * code,
168 typelib_InterfaceTypeDescription
const * type,
169 sal_Int32 nFunctionOffset,
170 sal_Int32 functionCount,
171 sal_Int32 nVtableOffset )
173 (*slots) -= functionCount;
176 for (
int member = 0; member < type->nMembers; ++member) {
179 TYPELIB_DANGER_GET( &pTD, type->ppMembers[ member ] );
185 for (
int i = 0;
i < 4; ++
i)
186 param_kind[i] = REGPARAM_INT;
191 if ( pTD->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE )
193 typelib_InterfaceAttributeTypeDescription * pIfaceAttrTD =
194 reinterpret_cast<typelib_InterfaceAttributeTypeDescription *
>( pTD );
199 code =
codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
200 if ( ! pIfaceAttrTD->bReadOnly )
203 TYPELIB_DANGER_GET( &pAttrTD, pIfaceAttrTD->pAttributeTypeRef );
207 if ( pAttrTD->eTypeClass == typelib_TypeClass_FLOAT ||
208 pAttrTD->eTypeClass == typelib_TypeClass_DOUBLE )
209 param_kind[nr++] = REGPARAM_FLT;
211 TYPELIB_DANGER_RELEASE( pAttrTD );
214 code =
codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
217 else if ( pTD->eTypeClass == typelib_TypeClass_INTERFACE_METHOD )
219 typelib_InterfaceMethodTypeDescription * pMethodTD =
220 reinterpret_cast<typelib_InterfaceMethodTypeDescription *
>( pTD );
223 TYPELIB_DANGER_GET( &pReturnTD, pMethodTD->pReturnTypeRef );
232 for (
int param = 0; nr < 4 && param < pMethodTD->nParams; ++param, ++nr)
236 TYPELIB_DANGER_GET( &pParamTD, pMethodTD->pParams[param].pTypeRef );
239 if ( pParamTD->eTypeClass == typelib_TypeClass_FLOAT ||
240 pParamTD->eTypeClass == typelib_TypeClass_DOUBLE )
241 param_kind[nr] = REGPARAM_FLT;
243 TYPELIB_DANGER_RELEASE( pParamTD );
246 code =
codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
248 TYPELIB_DANGER_RELEASE( pReturnTD );
253 TYPELIB_DANGER_RELEASE( pTD );
259 unsigned char const *,
260 unsigned char const *)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
typelib_TypeClass cpp_vtable_call(sal_Int64 nOffsetAndIndex, void **pCallStack)
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT...
static std::size_t getBlockSize(sal_Int32 slotCount)
Calculate the size of a raw vtable block.
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static Slot * initializeBlock(void *block, sal_Int32 slotCount, sal_Int32 vtableNumber, typelib_InterfaceTypeDescription *type)
Initialize a raw vtable block.
typelib_TypeClass __cdecl cpp_mediate(void **pCallStack, const sal_Int32 nFunctionIndex, const sal_Int32 nVtableOffset, sal_Int64 *const pRegisterReturn)
static Slot * mapBlockToVtable(void *block)
Given a pointer to a block, turn it into a vtable pointer.
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...
char privateSnippetExecutor
struct _typelib_TypeDescription typelib_TypeDescription
static unsigned char * codeSnippet(unsigned char *code, RegParamKind param_kind[4], sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset)
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.
int const codeSnippetSize