Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_openvms_alpha.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /* Implement shared vtbl methods. */
00039 
00040 #include "xptcprivate.h"
00041 
00042 extern "C" {
00043 
00044 nsresult
00045 PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint64* args)
00046 {
00047     const PRUint8 PARAM_BUFFER_COUNT = 16;
00048     const PRUint8 NUM_ARG_REGS = 6-1;        // -1 for "this" pointer
00049 
00050     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00051     nsXPTCMiniVariant* dispatchParams = NULL;
00052     nsIInterfaceInfo* iface_info = NULL;
00053     const nsXPTMethodInfo* info;
00054     PRUint8 paramCount;
00055     PRUint8 i;
00056     nsresult result = NS_ERROR_FAILURE;
00057 
00058     NS_ASSERTION(self,"no self");
00059 
00060     self->GetInterfaceInfo(&iface_info);
00061     NS_ASSERTION(iface_info,"no interface info");
00062 
00063     iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00064     NS_ASSERTION(info,"no interface info");
00065 
00066     paramCount = info->GetParamCount();
00067 
00068     // setup variant array pointer
00069     if(paramCount > PARAM_BUFFER_COUNT)
00070         dispatchParams = new nsXPTCMiniVariant[paramCount];
00071     else
00072         dispatchParams = paramBuffer;
00073     NS_ASSERTION(dispatchParams,"no place for params");
00074 
00075     // args[0] to args[NUM_ARG_REGS] hold floating point register values
00076     PRUint64* ap = args + NUM_ARG_REGS;
00077     for(i = 0; i < paramCount; i++, ap++)
00078     {
00079         const nsXPTParamInfo& param = info->GetParam(i);
00080         const nsXPTType& type = param.GetType();
00081         nsXPTCMiniVariant* dp = &dispatchParams[i];
00082 
00083         if(param.IsOut() || !type.IsArithmetic())
00084         {
00085             dp->val.p = (void*) *ap;
00086             continue;
00087         }
00088         // else
00089         switch(type)
00090         {
00091         case nsXPTType::T_I8     : dp->val.i8  = (PRInt8)    *ap; break;
00092         case nsXPTType::T_I16    : dp->val.i16 = (PRInt16)   *ap; break;
00093         case nsXPTType::T_I32    : dp->val.i32 = (PRInt32)   *ap; break;
00094         case nsXPTType::T_I64    : dp->val.i64 = (PRInt64)   *ap; break;
00095         case nsXPTType::T_U8     : dp->val.u8  = (PRUint8)   *ap; break;
00096         case nsXPTType::T_U16    : dp->val.u16 = (PRUint16)  *ap; break;
00097         case nsXPTType::T_U32    : dp->val.u32 = (PRUint32)  *ap; break;
00098         case nsXPTType::T_U64    : dp->val.u64 = (PRUint64)  *ap; break;
00099         case nsXPTType::T_FLOAT  :
00100             if(i < NUM_ARG_REGS)
00101             {
00102                 // floats passed via registers are stored as doubles
00103                 // in the first NUM_ARG_REGS entries in args
00104                 dp->val.u64 = (PRUint64) args[i];
00105                 dp->val.f = (float) dp->val.d;    // convert double to float
00106             }
00107             else
00108                 dp->val.u32 = (PRUint32) *ap;
00109             break;
00110         case nsXPTType::T_DOUBLE :
00111             // doubles passed via registers are also stored
00112             // in the first NUM_ARG_REGS entries in args
00113             dp->val.u64 = (i < NUM_ARG_REGS) ? args[i] : *ap;
00114             break;
00115         case nsXPTType::T_BOOL   : dp->val.b   = (PRBool)    *ap; break;
00116         case nsXPTType::T_CHAR   : dp->val.c   = (char)      *ap; break;
00117         case nsXPTType::T_WCHAR  : dp->val.wc  = (PRUnichar) *ap; break;
00118         default:
00119             NS_ASSERTION(0, "bad type");
00120             break;
00121         }
00122     }
00123 
00124     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00125 
00126     NS_RELEASE(iface_info);
00127 
00128     if(dispatchParams != paramBuffer)
00129         delete [] dispatchParams;
00130 
00131     return result;
00132 }
00133 
00134 }
00135 
00136 #define STUB_ENTRY(n)  /* This is in the ASM file */
00137 
00138 #define SENTINEL_ENTRY(n) \
00139 nsresult nsXPTCStubBase::Sentinel##n() \
00140 { \
00141     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00142     return NS_ERROR_NOT_IMPLEMENTED; \
00143 }
00144 
00145 #include "xptcstubsdef.inc"
00146 
00147