1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/uno/genfunc.hxx>
21 #include "com/sun/star/uno/RuntimeException.hpp"
26 #include "unointerfaceproxy.hxx"
27 #include "vtables.hxx"
31 #include "callvirtualmethod.hxx"
33 void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
34 void * pAdjustedThisPtr
,
35 sal_Int32 nVtableIndex
,
36 void * pRegisterReturn
,
37 typelib_TypeClass eReturnType
,
38 sal_Int32
* pStackLongs
,
39 sal_Int32 nStackLongs
)
41 // parameter list is mixed list of * and values
42 // reference parameters are pointers
44 assert(pStackLongs
&& pAdjustedThisPtr
);
45 static_assert((sizeof(void *) == 4) && (sizeof(sal_Int32
) == 4), "### unexpected size of int!");
46 assert(nStackLongs
&& pStackLongs
&& "### no stack in callVirtualMethod !");
49 if (! pAdjustedThisPtr
) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
51 long edx
, eax
; // for register returns
55 // preserve potential 128bit stack alignment
56 "and $0xfffffff0, %%esp\n\t"
58 "lea -4(,%%eax,4), %%eax\n\t"
61 "add %%eax, %%esp\n\t"
64 "mov %%eax, %%edx\n\t"
75 "mov 0(%%edx), %%edx\n\t"
78 "add %%eax, %%edx\n\t"
79 "mov 0(%%edx), %%edx\n\t"
81 // save return registers
86 : "=m"(eax
), "=m"(edx
), "=m"(stackptr
)
87 : "m"(nStackLongs
), "m"(pStackLongs
), "m"(pAdjustedThisPtr
), "m"(nVtableIndex
)
88 : "eax", "ecx", "edx" );
91 case typelib_TypeClass_HYPER
:
92 case typelib_TypeClass_UNSIGNED_HYPER
:
93 ((long*)pRegisterReturn
)[1] = edx
;
94 case typelib_TypeClass_LONG
:
95 case typelib_TypeClass_UNSIGNED_LONG
:
96 case typelib_TypeClass_CHAR
:
97 case typelib_TypeClass_ENUM
:
98 ((long*)pRegisterReturn
)[0] = eax
;
100 case typelib_TypeClass_SHORT
:
101 case typelib_TypeClass_UNSIGNED_SHORT
:
102 *(unsigned short*)pRegisterReturn
= eax
;
104 case typelib_TypeClass_BOOLEAN
:
105 case typelib_TypeClass_BYTE
:
106 *(unsigned char*)pRegisterReturn
= eax
;
108 case typelib_TypeClass_FLOAT
:
109 asm ( "fstps %0" : : "m"(*(char *)pRegisterReturn
) );
111 case typelib_TypeClass_DOUBLE
:
112 asm ( "fstpl %0\n\t" : : "m"(*(char *)pRegisterReturn
) );
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */