/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
union largest
{
sal_Int64 n; double d; void * p;
uno_Any a;
};
System::Object^ Bridge::call_uno(uno_Interface * pUnoI,
typelib_TypeDescription* member_td,
typelib_TypeDescriptionReference * return_type,
sal_Int32 nParams, typelib_MethodParameter const * pParams,
array<System::Object^>^ args, array<System::Type^>^ argTypes,
System::Object^* ppExc) const
{ // return mem
sal_Int32 return_size = sizeof (largest); if ((0 != return_type) &&
(typelib_TypeClass_STRUCT == return_type->eTypeClass ||
typelib_TypeClass_EXCEPTION == return_type->eTypeClass))
{
TypeDescr return_td( return_type ); if (return_td.get()->nSize > sizeof (largest))
return_size = return_td.get()->nSize;
} //Prepare memory that contains all converted arguments and return value //The memory block contains first pointers to the arguments which are in the same block // For example, 2 arguments, 1 ret. // // | Pointer // | Pointer // | Return value // | Arg 1 // | Arg 2 // // If an argument is larger then union largest, such as some structures, then the pointer // points to an extra block of memory. The same goes for a big return value.
char * mem = (char *)alloca(
(nParams * sizeof (void *)) + return_size + (nParams * sizeof (largest)) ); //array of pointers to args void ** uno_args = (void **)mem; //If an attribute is set, then uno_ret must be null, e.g void setAttribute(int ) void * uno_ret= NULL; if ( !(member_td->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE && nParams == 1))
uno_ret = (mem + (nParams * sizeof (void *)));
largest * uno_args_mem = (largest *)(mem + (nParams * sizeof (void *)) + return_size);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.