View | Details | Raw Unified | Return to issue 84999
Collapse All | Expand All

(-)inc/bridges/cpp_uno/shared/cppinterfaceproxy.hxx (-1 / +2 lines)
Lines 42-47 Link Here
42
#include "typelib/typedescription.h"
42
#include "typelib/typedescription.h"
43
#include "uno/dispatcher.h"
43
#include "uno/dispatcher.h"
44
#include "uno/environment.h"
44
#include "uno/environment.h"
45
#include "bridges/cpp_uno/shared/vtablefactory.hxx"
45
46
46
namespace com { namespace sun { namespace star { namespace uno {
47
namespace com { namespace sun { namespace star { namespace uno {
47
    class XInterface;
48
    class XInterface;
Lines 102-108 private: Link Here
102
    typelib_InterfaceTypeDescription * pTypeDescr;
103
    typelib_InterfaceTypeDescription * pTypeDescr;
103
    rtl::OUString oid;
104
    rtl::OUString oid;
104
105
105
    void ** vtables[1];
106
    VtableFactory::Slot * vtables[1];
106
107
107
    friend void SAL_CALL freeCppInterfaceProxy(
108
    friend void SAL_CALL freeCppInterfaceProxy(
108
        uno_ExtEnvironment * pEnv, void * pInterface);
109
        uno_ExtEnvironment * pEnv, void * pInterface);
(-)inc/bridges/cpp_uno/shared/vtablefactory.hxx (-8 / +15 lines)
Lines 50-55 namespace bridges { namespace cpp_uno { Link Here
50
 */
50
 */
51
class VtableFactory {
51
class VtableFactory {
52
public:
52
public:
53
    // This structure is not defined in the generic part, but instead has to be
54
    // defined individually for each CPP--UNO bridge:
55
    /** A vtable slot.
56
     */
57
    struct Slot;
58
53
    /** A raw vtable block.
59
    /** A raw vtable block.
54
     */
60
     */
55
    struct Block {
61
    struct Block {
Lines 99-105 public: Link Here
99
    // defined individually for each CPP--UNO bridge:
105
    // defined individually for each CPP--UNO bridge:
100
    /** Given a pointer to a block, turn it into a vtable pointer.
106
    /** Given a pointer to a block, turn it into a vtable pointer.
101
     */
107
     */
102
    static void ** mapBlockToVtable(void * block);
108
    static Slot * mapBlockToVtable(void * block);
103
109
104
private:
110
private:
105
    class GuardedBlocks;
111
    class GuardedBlocks;
Lines 133-143 private: Link Here
133
    /** Initialize a raw vtable block.
139
    /** Initialize a raw vtable block.
134
140
135
        @param block  the start address of the raw vtable block
141
        @param block  the start address of the raw vtable block
136
        @return  a pointer to the first virtual function slot (minus any
142
        @param slotCount  the number of slots
137
        platform-specific ones, like a pointer to a destructor) within the given
143
        @return  a pointer past the last vtable slot
138
        block
139
     */
144
     */
140
    static void ** initializeBlock(void * block);
145
    static Slot * initializeBlock(void * block, sal_Int32 slotCount);
141
146
142
    // This function is not defined in the generic part, but instead has to be
147
    // This function is not defined in the generic part, but instead has to be
143
    // defined individually for each CPP--UNO bridge:
148
    // defined individually for each CPP--UNO bridge:
Lines 145-152 private: Link Here
145
        functions of a given interface type (and generate any necessary code
150
        functions of a given interface type (and generate any necessary code
146
        snippets for them).
151
        snippets for them).
147
152
148
        @param slots  points to the first vtable slot to be filled with the
153
        @param slots  on input, points past the vtable slot to be filled with
149
        first virtual function local to the given type
154
        the last virtual function local to the given type; on output, points to
155
        the vtable slot filled with the first virtual function local to the
156
        given type
150
        @param code  points to the start of the area where code snippets can be
157
        @param code  points to the start of the area where code snippets can be
151
        generated
158
        generated
152
        @param type  the interface type description for which to generate vtable
159
        @param type  the interface type description for which to generate vtable
Lines 162-168 private: Link Here
162
        @return  a pointer to the remaining code snippet area
169
        @return  a pointer to the remaining code snippet area
163
     */
170
     */
164
    static unsigned char * addLocalFunctions(
171
    static unsigned char * addLocalFunctions(
165
        void ** slots, unsigned char * code,
172
        Slot ** slots, unsigned char * code,
166
        typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
173
        typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
167
        sal_Int32 functionCount, sal_Int32 vtableOffset);
174
        sal_Int32 functionCount, sal_Int32 vtableOffset);
168
175
(-)source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx (-14 / +21 lines)
Lines 421-449 unsigned char * codeSnippet( Link Here
421
421
422
}
422
}
423
423
424
void ** bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
424
struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; };
425
{
425
426
    return static_cast< void ** >(block) + 2;
426
bridges::cpp_uno::shared::VtableFactory::Slot *
427
bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) {
428
    return static_cast< Slot * >(block) + 2;
427
}
429
}
428
430
429
sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
431
sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
430
    sal_Int32 slotCount)
432
    sal_Int32 slotCount)
431
{
433
{
432
    return (slotCount + 2) * sizeof (void *) + slotCount * codeSnippetSize;
434
    return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
433
}
435
}
434
436
435
void ** bridges::cpp_uno::shared::VtableFactory::initializeBlock(void * block) {
437
bridges::cpp_uno::shared::VtableFactory::Slot *
436
    void ** slots = mapBlockToVtable(block);
438
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
437
    slots[-2] = 0;
439
    void * block, sal_Int32 slotCount)
438
    slots[-1] = 0;
440
{
439
    return slots;
441
    Slot * slots = mapBlockToVtable(block);
442
    slots[-2].fn = 0;
443
    slots[-1].fn = 0;
444
    return slots + slotCount;
440
}
445
}
441
446
442
unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
447
unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
443
    void ** slots, unsigned char * code,
448
    Slot ** slots, unsigned char * code,
444
    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
449
    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
445
    sal_Int32 /*functionCount*/, sal_Int32 vtableOffset)
450
    sal_Int32 functionCount, sal_Int32 vtableOffset)
446
{
451
{
452
    (*slots) -= functionCount;
453
    Slot * s = *slots;
447
    for (sal_Int32 i = 0; i < type->nMembers; ++i) {
454
    for (sal_Int32 i = 0; i < type->nMembers; ++i) {
448
        typelib_TypeDescription * member = 0;
455
        typelib_TypeDescription * member = 0;
449
        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
456
        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
Lines 451-457 unsigned char * bridges::cpp_uno::shared Link Here
451
        switch (member->eTypeClass) {
458
        switch (member->eTypeClass) {
452
        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
459
        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
453
            // Getter:
460
            // Getter:
454
            *slots++ = code;
461
            (s++)->fn = code;
455
            code = codeSnippet(
462
            code = codeSnippet(
456
                code, functionOffset++, vtableOffset,
463
                code, functionOffset++, vtableOffset,
457
                reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >(
464
                reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >(
Lines 461-467 unsigned char * bridges::cpp_uno::shared Link Here
461
                typelib_InterfaceAttributeTypeDescription * >(
468
                typelib_InterfaceAttributeTypeDescription * >(
462
                    member)->bReadOnly)
469
                    member)->bReadOnly)
463
            {
470
            {
464
                *slots++ = code;
471
                (s++)->fn = code;
465
                code = codeSnippet(
472
                code = codeSnippet(
466
                    code, functionOffset++, vtableOffset,
473
                    code, functionOffset++, vtableOffset,
467
                    typelib_TypeClass_VOID);
474
                    typelib_TypeClass_VOID);
Lines 469-475 unsigned char * bridges::cpp_uno::shared Link Here
469
            break;
476
            break;
470
477
471
        case typelib_TypeClass_INTERFACE_METHOD:
478
        case typelib_TypeClass_INTERFACE_METHOD:
472
            *slots++ = code;
479
            (s++)->fn = code;
473
            code = codeSnippet(
480
            code = codeSnippet(
474
                code, functionOffset++, vtableOffset,
481
                code, functionOffset++, vtableOffset,
475
                reinterpret_cast< typelib_InterfaceMethodTypeDescription * >(
482
                reinterpret_cast< typelib_InterfaceMethodTypeDescription * >(
(-)source/cpp_uno/shared/vtablefactory.cxx (-7 / +5 lines)
Lines 266-286 void VtableFactory::createVtables( Link Here
266
            throw std::bad_alloc();
266
            throw std::bad_alloc();
267
        }
267
        }
268
        try {
268
        try {
269
            void ** slots = initializeBlock(block.start) + slotCount;
269
            Slot * slots = initializeBlock(block.start, slotCount);
270
            unsigned char * codeBegin =
270
            unsigned char * codeBegin =
271
                reinterpret_cast< unsigned char * >(slots);
271
                reinterpret_cast< unsigned char * >(slots);
272
            unsigned char * code = codeBegin;
272
            unsigned char * code = codeBegin;
273
            sal_Int32 vtableOffset = blocks.size() * sizeof (void **);
273
            sal_Int32 vtableOffset = blocks.size() * sizeof (Slot *);
274
            for (typelib_InterfaceTypeDescription const * type2 = type;
274
            for (typelib_InterfaceTypeDescription const * type2 = type;
275
                 type2 != 0; type2 = type2->pBaseTypeDescription)
275
                 type2 != 0; type2 = type2->pBaseTypeDescription)
276
            {
276
            {
277
                sal_Int32 functionCount
278
                    = bridges::cpp_uno::shared::getLocalFunctions(type2);
279
                slots -= functionCount;
280
                code = addLocalFunctions(
277
                code = addLocalFunctions(
281
                    slots, code, type2,
278
                    &slots, code, type2,
282
                    baseOffset.getFunctionOffset(type2->aBase.pTypeName),
279
                    baseOffset.getFunctionOffset(type2->aBase.pTypeName),
283
                    functionCount, vtableOffset);
280
                    bridges::cpp_uno::shared::getLocalFunctions(type2),
281
                    vtableOffset);
284
            }
282
            }
285
            flushCode(codeBegin, code);
283
            flushCode(codeBegin, code);
286
            blocks.push_back(block);
284
            blocks.push_back(block);

Return to issue 84999