LibreOffice Module bridges (master)  1
gcc3_linux_ia64/cpp2uno.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include <com/sun/star/uno/genfunc.hxx>
22 #include <sal/log.hxx>
23 #include <uno/data.h>
24 #include <typelib/typedescription.hxx>
25 
26 #include "bridge.hxx"
27 #include "cppinterfaceproxy.hxx"
28 #include "types.hxx"
29 #include "vtablefactory.hxx"
30 
31 #include "share.hxx"
32 #include <stdio.h>
33 
34 extern "C" { extern void (*privateSnippetExecutor)(); }
35 
36 using namespace ::com::sun::star::uno;
37 
38 namespace
39 {
40 
41 static typelib_TypeClass cpp2uno_call(
43  const typelib_TypeDescription * pMemberTypeDescr,
44  typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
45  sal_Int32 nParams, typelib_MethodParameter * pParams, long r8,
46  void ** gpreg, void ** fpreg, void ** ovrflw,
47  sal_Int64 * pRegisterReturn /* space for register return */ )
48 {
49 #if OSL_DEBUG_LEVEL > 2
50  fprintf(stderr, "as far as cpp2uno_call\n");
51 #endif
52 
53  int ng = 0; //number of gpr registers used
54  int nf = 0; //number of fpr registers used
55 
56  // gpreg: [ret *], this, [gpr params]
57  // fpreg: [fpr params]
58  // ovrflw: [gpr or fpr params (properly aligned)]
59 
60  // return
61  typelib_TypeDescription * pReturnTypeDescr = 0;
62  if (pReturnTypeRef)
63  TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
64 
65  void * pUnoReturn = 0;
66  void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
67 
68  if (pReturnTypeDescr)
69  {
70  if ( ia64::return_in_hidden_param( pReturnTypeRef ) ) // complex return via ptr passed as hidden parameter reg (pCppReturn)
71  {
72  pCppReturn = *(void **)gpreg;
73  gpreg++;
74  ng++;
75 
76  pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
77  ? alloca( pReturnTypeDescr->nSize )
78  : pCppReturn); // direct way
79  }
80  else if ( ia64::return_via_r8_buffer( pReturnTypeRef ) ) // complex return via ptr passed in r8
81  {
82  pCppReturn = (void *)r8;
83 
84  pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
85  ? alloca( pReturnTypeDescr->nSize )
86  : pCppReturn); // direct way
87  }
88 
89  else
90  pUnoReturn = pRegisterReturn; // direct way for simple types
91  }
92  // pop this
93  gpreg++;
94  ng++;
95 
96  // stack space
97  static_assert(sizeof(void *) == sizeof(sal_Int64), "### unexpected size!");
98  // parameters
99  void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
100  void ** pCppArgs = pUnoArgs + nParams;
101  // indices of values this have to be converted (interface conversion cpp<=>uno)
102  sal_Int32 * pTempIndices = (sal_Int32 *)(pUnoArgs + (2 * nParams));
103  // type descriptions for reconversions
104  typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
105 
106  sal_Int32 nTempIndices = 0;
107  bool bOverflowUsed = false;
108  for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
109  {
110  const typelib_MethodParameter & rParam = pParams[nPos];
111  typelib_TypeDescription * pParamTypeDescr = 0;
112  TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
113 
114 #if OSL_DEBUG_LEVEL > 2
115  fprintf(stderr, "arg %d of %d\n", nPos, nParams);
116 #endif
117 
118  //I think it is impossible to get UNO to pass structs as parameters by copy
119  if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
120  {
121 #if OSL_DEBUG_LEVEL > 2
122  fprintf(stderr, "simple\n");
123 #endif
124 
125  switch (pParamTypeDescr->eTypeClass)
126  {
127  case typelib_TypeClass_FLOAT:
128  if (nf < ia64::MAX_SSE_REGS && ng < ia64::MAX_GPR_REGS)
129  {
130  float tmp = (float) (*((double *)fpreg));
131  (*((float *) fpreg)) = tmp;
132  pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
133  nf++;
134  gpreg++;
135  ng++;
136  }
137  else
138  {
139  pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
140  bOverflowUsed = true;
141  }
142  if (bOverflowUsed) ovrflw++;
143  break;
144  case typelib_TypeClass_DOUBLE:
145  if (nf < ia64::MAX_SSE_REGS && ng < ia64::MAX_GPR_REGS)
146  {
147  pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
148  nf++;
149  gpreg++;
150  ng++;
151  }
152  else
153  {
154  pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
155  bOverflowUsed = true;
156  }
157  if (bOverflowUsed) ovrflw++;
158  break;
159  case typelib_TypeClass_BYTE:
160  case typelib_TypeClass_BOOLEAN:
161  case typelib_TypeClass_CHAR:
162  case typelib_TypeClass_SHORT:
163  case typelib_TypeClass_UNSIGNED_SHORT:
164  case typelib_TypeClass_ENUM:
165  case typelib_TypeClass_LONG:
166  case typelib_TypeClass_UNSIGNED_LONG:
167  default:
168  if (ng < ia64::MAX_GPR_REGS)
169  {
170  pCppArgs[nPos] = pUnoArgs[nPos] = gpreg++;
171  ng++;
172  }
173  else
174  {
175  pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
176  bOverflowUsed = true;
177  }
178  if (bOverflowUsed) ovrflw++;
179  break;
180  }
181 
182  // no longer needed
183  TYPELIB_DANGER_RELEASE( pParamTypeDescr );
184  }
185  else // ptr to complex value | ref
186  {
187 #if OSL_DEBUG_LEVEL > 2
188  fprintf(stderr, "complex, ng is %d\n", ng);
189 #endif
190  void *pCppStack; //temporary stack pointer
191 
192  if (ng < ia64::MAX_GPR_REGS)
193  {
194  pCppArgs[nPos] = pCppStack = *gpreg++;
195  ng++;
196  }
197  else
198  {
199  pCppArgs[nPos] = pCppStack = *ovrflw;
200  bOverflowUsed = true;
201  }
202  if (bOverflowUsed) ovrflw++;
203 
204  if (! rParam.bIn) // is pure out
205  {
206  // uno out is unconstructed mem!
207  pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
208  pTempIndices[nTempIndices] = nPos;
209  // will be released at reconversion
210  ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
211  }
212  // is in/inout
213  else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
214  {
215  uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
216  pCppStack, pParamTypeDescr,
217  pThis->getBridge()->getCpp2Uno() );
218  pTempIndices[nTempIndices] = nPos; // has to be reconverted
219  // will be released at reconversion
220  ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
221  }
222  else // direct way
223  {
224  pUnoArgs[nPos] = pCppStack;
225  // no longer needed
226  TYPELIB_DANGER_RELEASE( pParamTypeDescr );
227  }
228  }
229  }
230 
231 #if OSL_DEBUG_LEVEL > 2
232  fprintf(stderr, "end of params\n");
233 #endif
234 
235  // ExceptionHolder
236  uno_Any aUnoExc; // Any will be constructed by callee
237  uno_Any * pUnoExc = &aUnoExc;
238 
239  // invoke uno dispatch call
240  (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
241 
242  // in case an exception occurred...
243  if (pUnoExc)
244  {
245  // destruct temporary in/inout params
246  for ( ; nTempIndices--; )
247  {
248  sal_Int32 nIndex = pTempIndices[nTempIndices];
249 
250  if (pParams[nIndex].bIn) // is in/inout => was constructed
251  uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 );
252  TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
253  }
254  if (pReturnTypeDescr)
255  TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
256 
258  // has to destruct the any
259  // is here for dummy
260  return typelib_TypeClass_VOID;
261  }
262  else // else no exception occurred...
263  {
264  // temporary params
265  for ( ; nTempIndices--; )
266  {
267  sal_Int32 nIndex = pTempIndices[nTempIndices];
268  typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
269 
270  if (pParams[nIndex].bOut) // inout/out
271  {
272  // convert and assign
273  uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
274  uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
275  pThis->getBridge()->getUno2Cpp() );
276  }
277  // destroy temp uno param
278  uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
279 
280  TYPELIB_DANGER_RELEASE( pParamTypeDescr );
281  }
282  // return
283  if (pCppReturn) // has complex return
284  {
285  if (pUnoReturn != pCppReturn) // needs reconversion
286  {
287  uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
288  pThis->getBridge()->getUno2Cpp() );
289  // destroy temp uno return
290  uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
291  }
292  // complex return ptr is set to return reg
293  *(void **)pRegisterReturn = pCppReturn;
294  }
295  if (pReturnTypeDescr)
296  {
297  typelib_TypeClass eRet = ia64::return_via_r8_buffer(pReturnTypeRef) ? typelib_TypeClass_VOID : (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
298  TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
299  return eRet;
300  }
301  else
302  return typelib_TypeClass_VOID;
303  }
304 }
305 
306 
307 static typelib_TypeClass cpp_mediate(
308  sal_uInt64 nOffsetAndIndex,
309  void ** gpreg, void ** fpreg, long sp, long r8,
310  sal_Int64 * pRegisterReturn /* space for register return */ )
311 {
312  static_assert(sizeof(sal_Int64)==sizeof(void *), "### unexpected!");
313 
314  sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
315  sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
316 
317  void ** ovrflw = (void**)(sp);
318 
319  // gpreg: [ret *], this, [other gpr params]
320  // fpreg: [fpr params]
321  // ovrflw: [gpr or fpr params (properly aligned)]
322 
323  void * pThis;
324  if (nFunctionIndex & 0x80000000 )
325  {
326  nFunctionIndex &= 0x7fffffff;
327  pThis = gpreg[1];
328 #if OSL_DEBUG_LEVEL > 2
329  fprintf(stderr, "pThis is gpreg[1]\n");
330 #endif
331  }
332  else
333  {
334  pThis = gpreg[0];
335 #if OSL_DEBUG_LEVEL > 2
336  fprintf(stderr, "pThis is gpreg[0]\n");
337 #endif
338  }
339 
340 #if OSL_DEBUG_LEVEL > 2
341  fprintf(stderr, "pThis is %p\n", pThis);
342 #endif
343 
344  pThis = static_cast< char * >(pThis) - nVtableOffset;
345 
346 #if OSL_DEBUG_LEVEL > 2
347  fprintf(stderr, "pThis is now %p\n", pThis);
348 #endif
349 
352  pThis);
353 
354  typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
355 
356 #if OSL_DEBUG_LEVEL > 2
357  fprintf(stderr, "indexes are %d %d\n", nFunctionIndex, pTypeDescr->nMapFunctionIndexToMemberIndex);
358 #endif
359 
360  if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
361  {
362  SAL_WARN(
363  "bridges",
364  "illegal " << OUString::unacquired(&pTypeDescr->aBase.pTypeName)
365  << " vtable index " << nFunctionIndex << "/"
366  << pTypeDescr->nMapFunctionIndexToMemberIndex);
367  throw RuntimeException(
368  ("illegal " + OUString::unacquired(&pTypeDescr->aBase.pTypeName)
369  + " vtable index " + OUString::number(nFunctionIndex) + "/"
370  + OUString::number(pTypeDescr->nMapFunctionIndexToMemberIndex)),
371  (XInterface *)pThis);
372  }
373 
374  // determine called method
375  sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
376  assert(nMemberPos < pTypeDescr->nAllMembers);
377 
378 #if OSL_DEBUG_LEVEL > 2
379  fprintf(stderr, "members are %d %d\n", nMemberPos, pTypeDescr->nAllMembers);
380 #endif
381 
382  TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
383 
384  typelib_TypeClass eRet;
385  switch (aMemberDescr.get()->eTypeClass)
386  {
387  case typelib_TypeClass_INTERFACE_ATTRIBUTE:
388  {
389  if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
390  {
391  // is GET method
392  eRet = cpp2uno_call(
393  pCppI, aMemberDescr.get(),
394  ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
395  0, 0, // no params
396  r8, gpreg, fpreg, ovrflw, pRegisterReturn );
397  }
398  else
399  {
400  // is SET method
401  typelib_MethodParameter aParam;
402  aParam.pTypeRef =
403  ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
404  aParam.bIn = sal_True;
405  aParam.bOut = sal_False;
406 
407  eRet = cpp2uno_call(
408  pCppI, aMemberDescr.get(),
409  0, // indicates void return
410  1, &aParam,
411  r8, gpreg, fpreg, ovrflw, pRegisterReturn );
412  }
413  break;
414  }
415  case typelib_TypeClass_INTERFACE_METHOD:
416  {
417  // is METHOD
418  switch (nFunctionIndex)
419  {
420  case 1: // acquire()
421  pCppI->acquireProxy(); // non virtual call!
422  eRet = typelib_TypeClass_VOID;
423  break;
424  case 2: // release()
425  pCppI->releaseProxy(); // non virtual call!
426  eRet = typelib_TypeClass_VOID;
427  break;
428  case 0: // queryInterface() opt
429  {
430  typelib_TypeDescription * pTD = 0;
431  TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
432  if (pTD)
433  {
434  XInterface * pInterface = 0;
435  (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
436  pCppI->getBridge()->getCppEnv(),
437  (void **)&pInterface, pCppI->getOid().pData,
438  (typelib_InterfaceTypeDescription *)pTD );
439 
440  if (pInterface)
441  {
442  ::uno_any_construct(
443  reinterpret_cast< uno_Any * >( gpreg[0] ),
444  &pInterface, pTD, cpp_acquire );
445  pInterface->release();
446  TYPELIB_DANGER_RELEASE( pTD );
447  *(void **)pRegisterReturn = gpreg[0];
448  eRet = typelib_TypeClass_ANY;
449  break;
450  }
451  TYPELIB_DANGER_RELEASE( pTD );
452  }
453  } // else perform queryInterface()
454  default:
455  eRet = cpp2uno_call(
456  pCppI, aMemberDescr.get(),
457  ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
458  ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
459  ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
460  r8, gpreg, fpreg, ovrflw, pRegisterReturn );
461  }
462  break;
463  }
464  default:
465  {
466 #if OSL_DEBUG_LEVEL > 2
467  fprintf(stderr, "screwed\n");
468 #endif
469 
470  throw RuntimeException( "no member description found!", (XInterface *)pThis );
471  }
472  }
473 
474 #if OSL_DEBUG_LEVEL > 2
475  fprintf(stderr, "end of cpp_mediate\n");
476 #endif
477  return eRet;
478 }
479 }
480 
482  long in0, long in1, long in2, long in3, long in4, long in5, long in6, long in7,
483  long firstonstack
484  )
485 {
486  register long r15 asm("r15");
487  long r8 = r15;
488 
489  register long r14 asm("r14");
490  long nOffsetAndIndex = r14;
491 
492  long sp = (long)&firstonstack;
493 
494  sal_uInt64 gpreg[ia64::MAX_GPR_REGS];
495  gpreg[0] = in0;
496  gpreg[1] = in1;
497  gpreg[2] = in2;
498  gpreg[3] = in3;
499  gpreg[4] = in4;
500  gpreg[5] = in5;
501  gpreg[6] = in6;
502  gpreg[7] = in7;
503 
504  double fpreg[ia64::MAX_SSE_REGS];
505  register double f8 asm("f8"); fpreg[0] = f8;
506  register double f9 asm("f9"); fpreg[1] = f9;
507  register double f10 asm("f10"); fpreg[2] = f10;
508  register double f11 asm("f11"); fpreg[3] = f11;
509  register double f12 asm("f12"); fpreg[4] = f12;
510  register double f13 asm("f13"); fpreg[5] = f13;
511  register double f14 asm("f14"); fpreg[6] = f14;
512  register double f15 asm("f15"); fpreg[7] = f15;
513 
514 #if OSL_DEBUG_LEVEL > 2
515  fprintf(stderr, "cpp_vtable_call called with %lx\n", nOffsetAndIndex);
516  fprintf(stderr, "adump is %lx %lx %lx %lx %lx %lx %lx %lx\n", in0, in1, in2, in3, in4, in5, in6, in7);
517  fprintf(stderr, "bdump is %f %f %f %f %f %f %f %f\n", f8, f9, f10, f11, f12, f13, f14, f15);
518 #endif
519 
520  volatile long nRegReturn[4] = { 0 };
521 
522  typelib_TypeClass aType =
523  cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, r8, (sal_Int64*)&nRegReturn[0]);
524 
525  ia64::RegReturn ret;
526  switch( aType )
527  {
528  case typelib_TypeClass_VOID:
529  break;
530  case typelib_TypeClass_BOOLEAN:
531  case typelib_TypeClass_BYTE:
532  case typelib_TypeClass_CHAR:
533  case typelib_TypeClass_UNSIGNED_SHORT:
534  case typelib_TypeClass_SHORT:
535  case typelib_TypeClass_ENUM:
536  case typelib_TypeClass_UNSIGNED_LONG:
537  case typelib_TypeClass_LONG:
538  case typelib_TypeClass_UNSIGNED_HYPER:
539  case typelib_TypeClass_HYPER:
540  ret.r8 = nRegReturn[0];
541  break;
542  case typelib_TypeClass_FLOAT:
543  asm volatile("ldfs f8=%0" : : "m"((*((float*)&nRegReturn))) : "f8");
544  break;
545  case typelib_TypeClass_DOUBLE:
546  asm volatile("ldfd f8=%0" : : "m"((*((double*)&nRegReturn))) : "f8");
547  break;
548  case typelib_TypeClass_STRUCT:
549  case typelib_TypeClass_EXCEPTION:
550  {
551  ret.r8 = nRegReturn[0];
552  ret.r9 = nRegReturn[1];
553  ret.r10 = nRegReturn[2];
554  ret.r11 = nRegReturn[3];
555  break;
556  }
557  default:
558  break;
559  }
560  return ret;
561 }
562 
563 namespace
564 {
565 const int codeSnippetSize = 40;
566 
567 bridges::cpp_uno::shared::VtableFactory::Slot codeSnippet( unsigned char * code, sal_PtrDiff writetoexecdiff, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
568  bool bHasHiddenParam )
569 {
570 #if OSL_DEBUG_LEVEL > 2
571  fprintf(stderr, "size is %d\n", codeSnippetSize);
572  fprintf(stderr,"in codeSnippet functionIndex is %x\n", nFunctionIndex);
573  fprintf(stderr,"in codeSnippet vtableOffset is %x\n", nVtableOffset);
574 #endif
575 
576  sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex );
577 
578  if ( bHasHiddenParam )
579  nOffsetAndIndex |= 0x80000000;
580 
581  long *raw = (long *)code;
582 
584 
585  raw[0] = (long)&privateSnippetExecutor;
586  raw[1] = (long)&raw[2];
587  raw[2] = nOffsetAndIndex;
588  raw[3] = destination->gp_value;
589 
590  return *(bridges::cpp_uno::shared::VtableFactory::Slot*)(code+writetoexecdiff);
591 }
592 }
593 
594 void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const *, unsigned char const *)
595 {
596 }
597 
599 {
600  return static_cast< Slot * >(block) + 2;
601 }
602 
603 
605  sal_Int32 slotCount)
606 {
607  return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
608 }
609 
610 bridges::cpp_uno::shared::VtableFactory::Slot* bridges::cpp_uno::shared::VtableFactory::initializeBlock(void * block, sal_Int32 slotCount, sal_Int32, typelib_InterfaceTypeDescription *)
611 {
612  Slot * slots = mapBlockToVtable(block);
613  Slot foo = {0,0};
614  slots[-2] = foo;
615  slots[-1] = foo;
616  return slots + slotCount;
617 }
618 
620  Slot ** in_slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
621  typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
622  sal_Int32 functionCount, sal_Int32 vtableOffset)
623 {
624  (*in_slots) -= functionCount;
625  Slot * slots = *in_slots;
626 #if OSL_DEBUG_LEVEL > 2
627  fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
628  fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
629 #endif
630 
631  for (sal_Int32 i = 0; i < type->nMembers; ++i) {
632  typelib_TypeDescription * member = 0;
633  TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
634  assert(member != 0);
635  switch (member->eTypeClass) {
636  case typelib_TypeClass_INTERFACE_ATTRIBUTE:
637  // Getter:
638  *slots++ = codeSnippet(
639  code, writetoexecdiff, functionOffset++, vtableOffset,
641  reinterpret_cast<
642  typelib_InterfaceAttributeTypeDescription * >(
643  member)->pAttributeTypeRef));
644  code += codeSnippetSize;
645 
646 
647  // Setter:
648  if (!reinterpret_cast<
649  typelib_InterfaceAttributeTypeDescription * >(
650  member)->bReadOnly)
651  {
652  *slots++ = codeSnippet(code, writetoexecdiff, functionOffset++, vtableOffset, false);
653  code += codeSnippetSize;
654  }
655  break;
656 
657  case typelib_TypeClass_INTERFACE_METHOD:
658  *slots++ = codeSnippet(
659  code, writetoexecdiff, functionOffset++, vtableOffset,
661  reinterpret_cast<
662  typelib_InterfaceMethodTypeDescription * >(
663  member)->pReturnTypeRef));
664  code += codeSnippetSize;
665  break;
666 
667  default:
668  assert(false);
669  break;
670  }
671  TYPELIB_DANGER_RELEASE(member);
672  }
673  return code;
674 }
675 
676 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void(* privateSnippetExecutor)()
sal_Int32 nIndex
void SAL_CALL uno_destructData(void *pValue, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
Does function that returns this type use a hidden parameter, or registers?
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT...
Definition: types.cxx:28
static std::size_t getBlockSize(sal_Int32 slotCount)
Calculate the size of a raw vtable block.
const int codeSnippetSize
bool relatesToInterfaceType(typelib_TypeDescription const *type)
Determines whether a type relates to an interface type (is itself an interface type, or might contain entities of interface type).
Definition: types.cxx:41
bool return_via_r8_buffer(typelib_TypeDescriptionReference *pTypeRef)
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.
struct _uno_Any uno_Any
Definition: msvc/except.hxx:31
uno_Mapping * getUno2Cpp()
Definition: bridge.hxx:73
uno_ExtEnvironment * getCppEnv()
Definition: bridge.hxx:69
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...
typelib_InterfaceTypeDescription * getTypeDescr()
A cpp proxy wrapping a uno interface.
int i
#define sal_True
void SAL_CALL uno_copyAndConvertData(void *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_Mapping *mapping) SAL_THROW_EXTERN_C()
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:52
uno_Mapping * getCpp2Uno()
Definition: bridge.hxx:72
void raiseException(uno_Any *pUnoExc, uno_Mapping *pUno2Cpp)
static int cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy *pThis, const typelib_TypeDescription *pMemberTypeDescr, typelib_TypeDescriptionReference *pReturnTypeRef, sal_Int32 nParams, typelib_MethodParameter *pParams, void **gpreg, void **fpreg, void **ovrflw, sal_uInt64 *pRegisterReturn)
static unsigned char * codeSnippet(unsigned char *code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, bool bHasHiddenParam)
#define sal_False
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.
#define SAL_WARN(area, stream)
static CppInterfaceProxy * castInterfaceToProxy(void *pInterface)
ia64::RegReturn cpp_vtable_call(long in0, long in1, long in2, long in3, long in4, long in5, long in6, long in7, long firstonstack)
sal_uInt16 nPos
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo