Changeset 17504


Ignore:
Timestamp:
Oct 3, 2001, 9:22:00 PM (24 years ago)
Author:
sandervl
Message:

wine update

Location:
tags/trunk/src/oleaut32
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/oleaut32/dispatch.c

    r17271 r17504  
    88 * TODO: Type coercion is implemented in variant.c but not called yet.
    99 */
    10 #ifdef __WIN32OS2__
    11 #define HAVE_FLOAT_H
    12 #define WINE_LARGE_INTEGER
    13 #include "oleaut32.h"
    14 #endif
     10
     11#include "config.h"
    1512
    1613#include <stdlib.h>
     
    1815#include <stdio.h>
    1916#include <ctype.h>
     17
     18#include "windef.h"
     19#include "ole.h"
     20#include "oleauto.h"
    2021#include "winerror.h"
    2122#include "winreg.h"         /* for HKEY_LOCAL_MACHINE */
    2223#include "winnls.h"         /* for PRIMARYLANGID */
    23 #include "ole.h"
    24 #include "heap.h"
     24
    2525#include "wine/obj_oleaut.h"
     26
    2627#include "debugtools.h"
    2728
     
    3132
    3233/******************************************************************************
    33  *         DispInvoke    (OLEAUT32.30)
     34 *              DispInvoke (OLEAUT32.30)
    3435 *
    3536 *
     
    4344 *              S_OK on success.
    4445 */
    45 HRESULT WINAPI
    46 DispInvoke(VOID*            _this,          /* object instance */
    47            ITypeInfo*       ptinfo,         /* object's type info */
    48            DISPID           dispidMember,   /* member id */
    49            USHORT           wFlags,         /* kind of method call */
    50            DISPPARAMS*      pparams,        /* array of arguments */
    51            VARIANT*         pvarResult,     /* result of method call */
    52            EXCEPINFO*       pexcepinfo,     /* information about exception */
    53            UINT*            puArgErr        /* index of bad argument(if any) */
    54           )
     46HRESULT WINAPI DispInvoke(
     47        VOID       *_this,        /* [in] object instance */
     48        ITypeInfo  *ptinfo,       /* [in] object's type info */
     49        DISPID      dispidMember, /* [in] member id */
     50        USHORT      wFlags,       /* [in] kind of method call */
     51        DISPPARAMS *pparams,      /* [in] array of arguments */
     52        VARIANT    *pvarResult,   /* [out] result of method call */
     53        EXCEPINFO  *pexcepinfo,   /* [out] information about exception */
     54        UINT       *puArgErr)     /* [out] index of bad argument(if any) */
    5555{
    5656    HRESULT hr = E_FAIL;
     
    7474
    7575/******************************************************************************
    76  *         DispGetIDsOfNames (OLEAUT32.29)
     76 *              DispGetIDsOfNames (OLEAUT32.29)
    7777 *
    7878 * Convert a set of names to dispids, based on information
     
    8686 *              S_OK on success.
    8787 */
    88 HRESULT WINAPI
    89 DispGetIDsOfNames(ITypeInfo* ptinfo,
    90                   OLECHAR**  rgszNames,
    91                   UINT       cNames,
    92                   DISPID*    rgdispid)
     88HRESULT WINAPI DispGetIDsOfNames(
     89        ITypeInfo  *ptinfo,    /* [in] */
     90        OLECHAR   **rgszNames, /* [in] */
     91        UINT        cNames,    /* [in] */
     92        DISPID     *rgdispid)  /* [out] */
    9393{
    9494    HRESULT hr = E_FAIL;
     
    103103
    104104/******************************************************************************
    105  *         DispGetParam    (OLEAUT32.30)
     105 *              DispGetParam (OLEAUT32.28)
    106106 *
    107107 * Retrive a parameter from a DISPPARAMS structures and coerce it to
     
    115115 *              S_OK on success.
    116116 */
    117 HRESULT WINAPI DispGetParam(DISPPARAMS* pdispparams, UINT position,
    118             VARTYPE vtTarg, VARIANT* pvarResult, UINT* puArgErr)
     117HRESULT WINAPI DispGetParam(
     118        DISPPARAMS *pdispparams, /* [in] */
     119        UINT        position,    /* [in] */
     120        VARTYPE     vtTarg,      /* [in] */
     121        VARIANT    *pvarResult,  /* [out] */
     122        UINT       *puArgErr)    /* [out] */
    119123{
    120     HRESULT hr = E_FAIL;
     124    /* position is counted backwards */
     125    UINT pos;
     126    HRESULT hr;
    121127
    122     /**
    123      * TODO : Call VariantChangeTypeEx with LCID 0 (system)
    124      */
     128    TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
     129          position, pdispparams->cArgs, pdispparams->cNamedArgs);
     130    if (position < pdispparams->cArgs) {
     131      /* positional arg? */
     132      pos = pdispparams->cArgs - position - 1;
     133    } else {
     134      /* FIXME: is this how to handle named args? */
     135      for (pos=0; pos<pdispparams->cNamedArgs; pos++)
     136        if (pdispparams->rgdispidNamedArgs[pos] == position) break;
    125137
    126     FIXME("Coercion of arguments not implemented\n");
    127     return (hr);
     138      if (pos==pdispparams->cNamedArgs)
     139        return DISP_E_PARAMNOTFOUND;
     140    }
     141    hr = VariantChangeType(pvarResult,
     142                           &pdispparams->rgvarg[pos],
     143                           0, vtTarg);
     144    if (hr == DISP_E_TYPEMISMATCH) *puArgErr = pos;
     145    return hr;
    128146}
  • TabularUnified tags/trunk/src/oleaut32/oleaut.c

    r17271 r17504  
    33 *
    44 */
     5#ifdef __WIN32OS2__
     6#define HAVE_FLOAT_H
     7#define WINE_LARGE_INTEGER
     8#include "oleaut32.h"
     9#endif
     10
    511#include <string.h>
    612
     
    1218
    1319#include "ole2.h"
    14 #include "heap.h"
     20#include "olectl.h"
     21#include "wine/obj_oleaut.h"
     22#include "wine/obj_olefont.h"
    1523#include "debugtools.h"
    1624
     
    139147}
    140148
    141 #ifndef __WIN32OS2__
    142149/***********************************************************************
    143150 *              DllRegisterServer
     
    155162    return S_OK;
    156163}
    157 #endif //__WIN32OS2__
     164
     165
     166extern void _get_STDFONT_CF(LPVOID);
     167
     168/***********************************************************************
     169 *              DllGetClassObject (OLEAUT32.1)
     170 */
     171HRESULT WINAPI OLEAUT32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
     172{
     173    *ppv = NULL;
     174    if (IsEqualGUID(rclsid,&CLSID_StdFont)) {
     175        if (IsEqualGUID(iid,&IID_IClassFactory)) {
     176            _get_STDFONT_CF(ppv);
     177            IClassFactory_AddRef((IClassFactory*)*ppv);
     178            return S_OK;
     179        }
     180    }
     181    FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
     182    return CLASS_E_CLASSNOTAVAILABLE;
     183}
     184
     185/***********************************************************************
     186 *              DllCanUnloadNow (OLEAUT32.410)
     187 */
     188HRESULT WINAPI OLEAUT32_DllCanUnloadNow() {
     189    FIXME("(), stub!\n");
     190    return S_FALSE;
     191}
  • TabularUnified tags/trunk/src/oleaut32/oleaut32.def

    r17135 r17504  
    1 ;/* $Id: oleaut32.def,v 1.7 2001-08-23 18:11:20 sandervl Exp $ */
     1;/* $Id: oleaut32.def,v 1.8 2001-10-03 19:21:59 sandervl Exp $ */
    22LIBRARY OLAUTOS2 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - OleAut32'
     
    55
    66EXPORTS
    7 DllGetClassObject = _DllGetClassObject@12  @1
     7DllGetClassObject = _OLEAUT32_DllGetClassObject@12  @1
    88SysAllocString = _SysAllocString@4  @2
    99SysReAllocString = _SysReAllocString@8  @3
     
    254254LPSAFEARRAY_Marshal = _LPSAFEARRAY_Marshal@0  @296
    255255LPSAFEARRAY_Unmarshal = _LPSAFEARRAY_Unmarshal@0  @297
    256 DllRegisterServer = _DllRegisterServer@0  @320
    257 DllUnregisterServer = _DllUnregisterServer@0  @321
     256DllRegisterServer = _OLEAUT32_DllRegisterServer@0  @320
     257DllUnregisterServer = _OLEAUT32_DllUnregisterServer@0  @321
    258258VarDateFromUdate = _VarDateFromUdate@12  @330
    259259VarUdateFromDate = _VarUdateFromDate@16  @331
     
    279279UserMSG_free_inst = _UserMSG_free_inst@0  @398
    280280UserMSG_free_local = _UserMSG_free_local@0  @399
    281 DllCanUnloadNow = _DllCanUnloadNow@0  @410
     281DllCanUnloadNow = _OLEAUT32_DllCanUnloadNow@0  @410
    282282SafeArrayCreateVector = _SafeArrayCreateVector@12  @411
    283283SafeArrayCopyData = _SafeArrayCopyData@8  @412
  • TabularUnified tags/trunk/src/oleaut32/oleaut32.h

    r16033 r17504  
    1 /* $Id: oleaut32.h,v 1.10 2001-04-04 09:02:15 sandervl Exp $ */
     1/* $Id: oleaut32.h,v 1.11 2001-10-03 19:21:59 sandervl Exp $ */
    22/*
    33 * Win32 OLE stubs for OS/2
     
    5959void OpenPrivateLogFileTypelib();
    6060
     61#define snprintf wsnprintfA
    6162#endif
  • TabularUnified tags/trunk/src/oleaut32/safearray.c

    r17271 r17504  
    88 */
    99
    10 #ifdef __WIN32OS2__
    11 #define HAVE_FLOAT_H
    12 #define WINE_LARGE_INTEGER
    13 #include "oleaut32.h"
    14 #endif
    1510#include <stdio.h>
    1611#include <string.h>
     
    2419DEFAULT_DEBUG_CHANNEL(ole);
    2520
     21#define SYSDUPSTRING(str) SysAllocStringLen((str), SysStringLen(str))
     22
    2623/* Localy used methods */
    2724static INT 
     
    5956{
    6057  /* this is taken from wtypes.h.  Only [S]es are supported by the SafeArray */
    61 VARTYPE_NOT_SUPPORTED,  /* VT_EMPTY    [V]   [P]    nothing                     */
    62 VARTYPE_NOT_SUPPORTED,  /* VT_NULL     [V]   [P]    SQL style Nul       */
    63 2,                          /* VT_I2       [V][T][P][S] 2 byte signed int */
    64 4,                          /* VT_I4       [V][T][P][S] 4 byte signed int */
    65 4,                          /* VT_R4       [V][T][P][S] 4 byte real     */
    66 8,                          /* VT_R8       [V][T][P][S] 8 byte real     */
     58VARTYPE_NOT_SUPPORTED,  /* VT_EMPTY    [V]   [P]    nothing                     */
     59VARTYPE_NOT_SUPPORTED,  /* VT_NULL     [V]   [P]    SQL style Nul       */
     602,                      /* VT_I2       [V][T][P][S] 2 byte signed int */
     614,                      /* VT_I4       [V][T][P][S] 4 byte signed int */
     624,                      /* VT_R4       [V][T][P][S] 4 byte real */
     638,                      /* VT_R8       [V][T][P][S] 8 byte real */
    67648,                      /* VT_CY       [V][T][P][S] currency */
    68 8,                          /* VT_DATE     [V][T][P][S] date */
    69 4,                          /* VT_BSTR     [V][T][P][S] OLE Automation string*/
    70 4,                          /* VT_DISPATCH [V][T][P][S] IDispatch *     */
     658,                      /* VT_DATE     [V][T][P][S] date */
     66sizeof(BSTR),           /* VT_BSTR     [V][T][P][S] OLE Automation string*/
     67sizeof(LPDISPATCH),     /* VT_DISPATCH [V][T][P][S] IDispatch * */
    71684,                      /* VT_ERROR    [V][T]   [S] SCODE       */
    72 4,                          /* VT_BOOL     [V][T][P][S] True=-1, False=0*/
    73 24,                     /* VT_VARIANT  [V][T][P][S] VARIANT *   */
    74 4,                          /* VT_UNKNOWN  [V][T]   [S] IUnknown * */
    75 16,                         /* VT_DECIMAL  [V][T]   [S] 16 byte fixed point     */
     694,                      /* VT_BOOL     [V][T][P][S] True=-1, False=0*/
     70sizeof(VARIANT),        /* VT_VARIANT  [V][T][P][S] VARIANT *   */
     71sizeof(LPUNKNOWN),      /* VT_UNKNOWN  [V][T]   [S] IUnknown * */
     72sizeof(DECIMAL),        /* VT_DECIMAL  [V][T]   [S] 16 byte fixed point */
    7673VARTYPE_NOT_SUPPORTED,                         /* no VARTYPE here..... */
    7774VARTYPE_NOT_SUPPORTED,  /* VT_I1          [T]       signed char */
    78 1,                          /* VT_UI1      [V][T][P][S] unsigned char                   */
     751,                      /* VT_UI1      [V][T][P][S] unsigned char                       */
    7976VARTYPE_NOT_SUPPORTED,  /* VT_UI2         [T][P]    unsigned short      */
    8077VARTYPE_NOT_SUPPORTED,  /* VT_UI4         [T][P]    unsigned short      */
     
    109106
    110107/*************************************************************************
    111  *              SafeArrayAllocDescriptor
     108 *              SafeArrayAllocDescriptor (OLEAUT32.36)
    112109 * Allocate the appropriate amount of memory for the SafeArray descriptor
    113110 */
     
    134131
    135132/*************************************************************************
    136  *              SafeArrayAllocData
     133 *              SafeArrayAllocData (OLEAUT32.37)
    137134 * Allocate the appropriate amount of data for the SafeArray data
    138135 */
     
    141138{
    142139  ULONG  ulWholeArraySize;   /* to store the size of the whole thing */
    143 
    144   dprintf(("SafeArrayAllocData %x", psa));
    145140
    146141  if(! validArg(psa))
     
    161156
    162157/*************************************************************************
    163  *              SafeArrayCreate
     158 *              SafeArrayCreate (OLEAUT32.15)
    164159 * Create a SafeArray object by encapsulating AllocDescriptor and AllocData
    165160 */
     
    172167  HRESULT   hRes;
    173168  USHORT    cDim;
    174 
    175   dprintf(("SafeArrayCreate %x %d %x", vt, cDims, rgsabound));
    176169
    177170  /* Validate supported VARTYPE */
     
    208201
    209202/*************************************************************************
    210  *              SafeArrayDestroyDescriptor
     203 *              SafeArrayDestroyDescriptor (OLEAUT32.38)
    211204 * Frees the memory associated with the descriptor.
    212205 */
     
    214207  SAFEARRAY *psa)
    215208{
    216   dprintf(("SafeArrayDestroyDescriptor %x", psa));
    217 
    218209  /* Check for lockness before to free... */
    219210  if(psa->cLocks > 0)
     
    229220
    230221/*************************************************************************
    231  *              SafeArrayLock
     222 *              SafeArrayLock (OLEAUT32.21)
    232223 * Increment the lock counter
    233224 *
     
    239230  SAFEARRAY *psa)
    240231{
    241   dprintf(("SafeArrayLock %x", psa));
    242 
    243232  if(! validArg(psa))     
    244233    return E_INVALIDARG;
     
    250239
    251240/*************************************************************************
    252  *              SafeArrayUnlock
     241 *              SafeArrayUnlock (OLEAUT32.22)
    253242 * Decrement the lock counter
    254243 */
     
    256245  SAFEARRAY *psa)
    257246{
    258   dprintf(("SafeArrayUnlock %x", psa));
    259 
    260247  if(! validArg(psa))
    261248    return E_INVALIDARG;
     
    269256
    270257/*************************************************************************
    271  *              SafeArrayPutElement
     258 *              SafeArrayPutElement (OLEAUT32.26)
    272259 * Set the data at the given coordinate
    273260 */
     
    280267                                         the desired one... */
    281268  PVOID elementStorageAddress = NULL; /* Adress to store the data */
    282   BSTR  pbstrReAllocStr     = NULL; /* BSTR reallocated */
    283 
    284   dprintf(("SafeArrayPutElement %x %x %x", psa, rgIndices, pv));
    285269
    286270  /* Validate the index given */
     
    300284    if(isPointer(psa->fFeatures)) { /* increment ref count for this pointer */
    301285
    302       *((VOID**)elementStorageAddress) = *(VOID**)pv;
     286      *((PVOID*)elementStorageAddress) = *(PVOID*)pv;
    303287      IUnknown_AddRef( *(IUnknown**)pv);
    304288
     
    306290
    307291      if(psa->fFeatures == FADF_BSTR) { /* Create a new object */
    308 
    309         if((pbstrReAllocStr = SysAllocString( (OLECHAR*)pv )) == NULL) {
     292        BSTR pbstrReAllocStr = NULL;
     293        if(pv &&
     294           ((pbstrReAllocStr = SYSDUPSTRING( (OLECHAR*)pv )) == NULL)) {
    310295          SafeArrayUnlock(psa); 
    311296          return E_OUTOFMEMORY;
    312297        } else
    313298          *((BSTR*)elementStorageAddress) = pbstrReAllocStr;
    314 
    315       } else /* dupplicate the memory */
     299      }
     300      else if(psa->fFeatures == FADF_VARIANT) {
     301        HRESULT hr = VariantCopy(elementStorageAddress, pv);
     302        if (FAILED(hr)) {
     303          SafeArrayUnlock(psa);
     304          return hr;
     305        }
     306      }
     307      else /* duplicate the memory */
    316308        memcpy(elementStorageAddress, pv, SafeArrayGetElemsize(psa) );
    317309    }
     
    328320
    329321/*************************************************************************
    330  *              SafeArrayGetElement
     322 *              SafeArrayGetElement (OLEAUT32.25)
    331323 * Return the data element corresponding the the given coordinate
    332324 */
     
    339331                                         the desired one... */
    340332  PVOID elementStorageAddress = NULL; /* Adress to store the data */
    341   BSTR  pbstrReturnedStr    = NULL; /* BSTR reallocated */
    342 
    343   dprintf(("SafeArrayGetElement %x %x %x", psa, rgIndices, pv));
    344333
    345334  if(! validArg(psa))
     
    358347 
    359348    if( psa->fFeatures == FADF_BSTR) {           /* reallocate the obj */
    360       if( (pbstrReturnedStr =
    361           SysAllocString( *(OLECHAR**)elementStorageAddress )) == NULL) {
     349      BSTR pbstrStoredStr = *(OLECHAR**)elementStorageAddress;
     350      BSTR pbstrReturnedStr = NULL;
     351      if( pbstrStoredStr &&
     352          ((pbstrReturnedStr = SYSDUPSTRING( pbstrStoredStr )) == NULL) ) {
    362353        SafeArrayUnlock(psa);
    363354        return E_OUTOFMEMORY;
    364355      } else
    365356        *((BSTR*)pv) = pbstrReturnedStr;
    366        
    367     } else if( isPointer(psa->fFeatures) )       /* simply copy the pointer */
    368        pv = *((PVOID*)elementStorageAddress);
     357    }
     358    else if( psa->fFeatures == FADF_VARIANT) {
     359      HRESULT hr = VariantCopy(pv, elementStorageAddress);
     360      if (FAILED(hr)) {
     361        SafeArrayUnlock(psa);
     362        return hr;
     363      }
     364    }
     365    else if( isPointer(psa->fFeatures) )         /* simply copy the pointer */
     366      *(PVOID*)pv = *((PVOID*)elementStorageAddress);
    369367    else                                         /* copy the bytes */
    370       memcpy(pv, elementStorageAddress, SafeArrayGetElemsize(psa) );
     368      memcpy(pv, elementStorageAddress, psa->cbElements );
    371369
    372370  } else {
     
    379377
    380378/*************************************************************************
    381  *              SafeArrayGetUBound
     379 *              SafeArrayGetUBound (OLEAUT32.19)
    382380 * return the UP bound for a given array dimension
    383381 */
     
    387385  LONG      *plUbound)
    388386{
    389 
    390   dprintf(("SafeArrayGetUBound %x %x %x", psa, nDim, plUbound));
    391 
    392387  if(! validArg(psa))   
    393388    return E_INVALIDARG;
     
    396391    return DISP_E_BADINDEX;
    397392
     393  if(0 == nDim)
     394    return DISP_E_BADINDEX;
     395
    398396  *plUbound = psa->rgsabound[nDim-1].lLbound +
    399397              psa->rgsabound[nDim-1].cElements - 1;
     
    403401
    404402/*************************************************************************
    405  *              SafeArrayGetLBound
     403 *              SafeArrayGetLBound (OLEAUT32.20)
    406404 * Return the LO bound for a given array dimension
    407405 */
     
    417415    return DISP_E_BADINDEX;
    418416
     417  if(0 == nDim)
     418    return DISP_E_BADINDEX;
     419 
    419420  *plLbound = psa->rgsabound[nDim-1].lLbound;
    420421  return S_OK;
     
    422423
    423424/*************************************************************************
    424  *              SafeArrayGetDim
     425 *              SafeArrayGetDim (OLEAUT32.17)
    425426 * returns the number of dimension in the array
    426427 */
     
    439440
    440441/*************************************************************************
    441  *              SafeArrayGetElemsize
     442 *              SafeArrayGetElemsize (OLEAUT32.18)
    442443 * Return the size of the element in the array
    443444 */
     
    456457
    457458/*************************************************************************
    458  *              SafeArrayAccessData
     459 *              SafeArrayAccessData (OLEAUT32.23)
    459460 * increment the access count and return the data
    460461 */
     
    484485
    485486/*************************************************************************
    486  *              SafeArrayUnaccessData
     487 *              SafeArrayUnaccessData (OLEAUT32.24)
    487488 * Decrement the access count
    488489 */
     
    497498
    498499/************************************************************************
    499  *              SafeArrayPtrOfIndex
     500 *              SafeArrayPtrOfIndex (OLEAUT32.148)
    500501 * Return a pointer to the element at rgIndices
    501502 */
     
    523524
    524525/************************************************************************
    525  *              SafeArrayDestroyData
     526 *              SafeArrayDestroyData (OLEAUT32.39)
    526527 * Frees the memory data bloc
    527528 */
     
    532533  ULONG    ulWholeArraySize; /* count spot in array  */
    533534  ULONG    ulDataIter;       /* to iterate the data space */
    534   IUnknown *punk;
    535   BSTR   bstr;
    536535
    537536  if(! validArg(psa))
     
    544543
    545544  if(isPointer(psa->fFeatures)) {           /* release the pointers */
     545    IUnknown *punk;
    546546
    547547    for(ulDataIter=0; ulDataIter < ulWholeArraySize; ulDataIter++) {
     
    552552    }
    553553
    554   } else if(psa->fFeatures & FADF_BSTR) {  /* deallocate the obj */
     554  }
     555  else if(psa->fFeatures & FADF_BSTR) {  /* deallocate the obj */
     556    BSTR bstr;
    555557
    556558    for(ulDataIter=0; ulDataIter < ulWholeArraySize; ulDataIter++) {
     
    559561      if( bstr != NULL)
    560562        SysFreeString( bstr );
     563    }
     564  }
     565  else if(psa->fFeatures & FADF_VARIANT) {  /* deallocate the obj */
     566
     567    for(ulDataIter=0; ulDataIter < ulWholeArraySize; ulDataIter++) {
     568      VariantClear((VARIANT*)((char *) psa->pvData+(ulDataIter*(psa->cbElements))));
    561569    }
    562570  }
     
    578586
    579587/************************************************************************
    580  *              SafeArrayCopyData
     588 *              SafeArrayCopyData (OLEAUT32.412)
    581589 * Copy the psaSource's data block into psaTarget if dimension and size
    582590 * permits it.
     
    616624    }
    617625
    618   } else if( (*psaTarget)->fFeatures & FADF_BSTR) {  /* the target contain BSTR
     626  }
     627  else if( (*psaTarget)->fFeatures & FADF_BSTR) {    /* the target contain BSTR
    619628                                                        that must be freed */
    620629    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
     
    626635    }
    627636  }
     637  else if( (*psaTarget)->fFeatures & FADF_VARIANT) {
     638
     639    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
     640      VariantClear((VARIANT*)((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements)));
     641    }
     642  }
    628643
    629644  return duplicateData(psaSource, psaTarget);
     
    631646
    632647/************************************************************************
    633  *              SafeArrayDestroy
     648 *              SafeArrayDestroy (OLEAUT32.16)
    634649 * Deallocates all memory reserved for the SafeArray
    635650 */
     
    653668
    654669/************************************************************************
    655  *              SafeArrayCopy
     670 *              SafeArrayCopy (OLEAUT32.27)
    656671 * Make a dupplicate of a SafeArray
    657672 */
     
    706721
    707722/************************************************************************
    708  *              SafeArrayCreateVector
     723 *              SafeArrayCreateVector (OLEAUT32.411)
    709724 * Creates a one dimension safearray where the data is next to the
    710725 * SAFEARRAY structure.
     
    743758
    744759/************************************************************************
    745  *              SafeArrayRedim
     760 *              SafeArrayRedim (OLEAUT32.40)
    746761 * Changes the caracteristics of the last dimension of the SafeArray
    747762 */
     
    808823  /* Check whether the size of the chunk makes sense... That's the only thing
    809824     I can think of now... */
     825
    810826  psaSize = HeapSize(GetProcessHeap(), 0, psa);
    811827  if (psaSize == -1)
     
    838854  if(lDelta < 0) {                    /* array needs to be shorthen  */
    839855    if( isPointer(psa->fFeatures))    /* ptr that need to be released */
    840             for(;lDelta < 0; lDelta++) {
     856      for(;lDelta < 0; lDelta++) {
    841857              punk = *(IUnknown**)
    842858          ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements));
     
    847863
    848864    else if(psa->fFeatures & FADF_BSTR)  /* BSTR that need to be freed */
    849             for(;lDelta < 0; lDelta++) {
     865      for(;lDelta < 0; lDelta++) {
    850866        bstr = *(BSTR*)
    851867          ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements));
     
    853869        if( bstr != NULL )
    854870          SysFreeString( bstr );
     871      }
     872    else if(psa->fFeatures & FADF_VARIANT)
     873      for(;lDelta < 0; lDelta++) {
     874        VariantClear((VARIANT*)((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements)));
    855875      }
    856876  }
     
    894914{
    895915  switch(vt) {
     916    case VT_BSTR:      return FADF_BSTR;
    896917    case VT_UNKNOWN:   return FADF_UNKNOWN;
    897918    case VT_DISPATCH:  return FADF_DISPATCH;
    898     case VT_BSTR:      return FADF_BSTR;
     919    case VT_VARIANT:   return FADF_VARIANT;
    899920  }
    900921  return 0;
     
    973994
    974995  for(; iter<psa->cDims; iter++) {
    975     if((hRes = SafeArrayGetLBound(psa, iter, &lLBound)) != S_OK)
     996    if((hRes = SafeArrayGetLBound(psa, (iter+1), &lLBound)) != S_OK)
    976997      return FALSE;
    977     if((hRes = SafeArrayGetUBound(psa, iter, &lUBound)) != S_OK)
     998    if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
    978999      return FALSE;
    9791000 
     
    10141035  ULONG    ulWholeArraySize; /* size of the thing */
    10151036  LONG     lDelta;
    1016   IUnknown *punk;
    1017   BSTR   pbstrReAllocStr = NULL; /* BSTR reallocated */
    10181037
    10191038  ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
     
    10231042  if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment
    10241043                                        object's reference count */
     1044    IUnknown *punk;
    10251045
    10261046    for(lDelta=0; lDelta < ulWholeArraySize; lDelta++) {
     
    10351055      ulWholeArraySize*psa->cbElements);
    10361056
    1037   } else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate
    1038                                                the BSTR in the new array */
     1057  }
     1058  else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate
     1059                                             the BSTR in the new array */
     1060    BSTR   pbstrReAllocStr = NULL;
    10391061
    10401062    for(lDelta=0; lDelta < ulWholeArraySize; lDelta++) {
    1041       if(( pbstrReAllocStr = SysAllocString(
     1063      if(( pbstrReAllocStr = SYSDUPSTRING(
    10421064            *(BSTR*)((char *) psa->pvData+(lDelta * psa->cbElements)))) == NULL) {
    10431065
     
    10501072    }
    10511073
    1052   } else { /* Simply copy the source array data into target array */
     1074  }
     1075  else if( psa->fFeatures & FADF_VARIANT ) {
     1076
     1077    for(lDelta=0; lDelta < ulWholeArraySize; lDelta++) {
     1078      VariantCopy((VARIANT*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements)),
     1079                  (VARIANT*)((char *) psa->pvData+(lDelta * psa->cbElements)));
     1080    }
     1081
     1082  }
     1083  else { /* Simply copy the source array data into target array */
    10531084
    10541085    memcpy((*ppsaOut)->pvData, psa->pvData,
     
    10631094
    10641095/************************************************************************
    1065  *              SafeArrayGetVarType
     1096 *              SafeArrayGetVarType (OLEAUT32.77)
    10661097 * Returns the VARTYPE stored in the given safearray
    10671098 */
     
    10781109  {
    10791110    /* VT tag @ negative offset 4 in the array descriptor */
    1080     FIXME("Returning VT_BSTR instead of VT_...");
     1111    FIXME("Returning VT_BSTR instead of VT_...\n");
    10811112    vt = VT_BSTR;
    10821113  }
     
    10851116    vt = VT_RECORD;
    10861117  }
     1118  else if (psa->fFeatures & FADF_BSTR)
     1119  {
     1120    vt = VT_BSTR;
     1121  }
     1122  else if (psa->fFeatures & FADF_UNKNOWN)
     1123  {
     1124    vt = VT_UNKNOWN;
     1125  }
    10871126  else if (psa->fFeatures & FADF_DISPATCH)
    10881127  {
    10891128    vt = VT_DISPATCH;
    10901129  }
    1091   else if (psa->fFeatures & FADF_UNKNOWN)
     1130  else if (psa->fFeatures & FADF_VARIANT)
    10921131  {
    1093     vt = VT_UNKNOWN;
     1132    vt = VT_VARIANT;
    10941133  }
    10951134
     
    10991138    hr = S_OK;
    11001139  }
    1101  
    1102   TRACE("HRESULT = %08lx", hr);
     1140
     1141  TRACE("HRESULT = %08lx\n", hr);
    11031142  return hr;
    11041143}
  • TabularUnified tags/trunk/src/oleaut32/stubs.cpp

    r17135 r17504  
    1 /* $Id: stubs.cpp,v 1.11 2001-08-23 18:11:21 sandervl Exp $ */
     1/* $Id: stubs.cpp,v 1.12 2001-10-03 19:21:59 sandervl Exp $ */
    22/*
    33 * Win32 COM/OLE stubs for OS/2
     
    1212
    1313#include "oleaut32.h"
    14 
    15 //*****************************************************************************
    16 //*****************************************************************************
    17 HRESULT WIN32API DllCanUnloadNow()
    18 {
    19     dprintf(("OLEAUT32: DllCanUnloadNow - stub"));
    20     return S_OK;
    21 }
    22 
    23 //*****************************************************************************
    24 //*****************************************************************************
    25 HRESULT WIN32API DllRegisterServer(void )
    26 {
    27     dprintf(("OLEAUT32: DllRegisterServer - stub"));
    28     return S_OK;
    29 }
    30 
    31 //*****************************************************************************
    32 //*****************************************************************************
    33 HRESULT WIN32API DllUnregisterServer(void )
    34 {
    35     dprintf(("OLEAUT32: DllUnregisterServer - stub"));
    36     return S_OK;
    37 }
    38 
    39 //*****************************************************************************
    40 //*****************************************************************************
    41 HRESULT WIN32API DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv)
    42 {
    43     dprintf(("OLEAUT32: DllGetClassObject - stub"));
    44     return S_OK;
    45 }
    46 
    4714
    4815//*****************************************************************************
  • TabularUnified tags/trunk/src/oleaut32/typelib.c

    r17271 r17504  
    5555#include "winreg.h"         /* for HKEY_LOCAL_MACHINE */
    5656
     57#include "wine/unicode.h"
    5758#include "wine/obj_base.h"
    5859#include "heap.h"
    5960#include "ole2disp.h"
    6061#include "typelib.h"
    61 
    6262#include "debugtools.h"
     63#include "ntddk.h"
    6364
    6465DEFAULT_DEBUG_CHANNEL(ole);
     
    251252}
    252253#endif
    253 
    254254/******************************************************************************
    255255 *              LoadTypeLib     [OLEAUT32.161]
     
    263263 *    Failure: Status
    264264 */
    265 int TLB_ReadTypeLib(PCHAR file, ITypeLib2 **ppTypelib);
     265int TLB_ReadTypeLib(LPCWSTR file, INT index, ITypeLib2 **ppTypelib);
    266266
    267267HRESULT WINAPI LoadTypeLib(
     
    286286    ITypeLib **pptLib) /* [out] Pointer to pointer to loaded type library */
    287287{
    288     LPSTR p=NULL;
    289     WCHAR szPath[MAX_PATH+1];
     288    WCHAR szPath[MAX_PATH+1], szFileCopy[MAX_PATH+1];
     289    const WCHAR *pFile, *pIndexStr;
    290290    HRESULT res;
     291    INT index = 1;
    291292    TRACE("(%s,%d,%p)\n",debugstr_w(szFile), regkind, pptLib);
    292293   
    293     if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath,NULL))
    294       res = TYPE_E_CANTLOADLIBRARY;
    295     else {
    296       p=HEAP_strdupWtoA(GetProcessHeap(),0,szPath);
    297       res= TLB_ReadTypeLib(p, (ITypeLib2**)pptLib);
    298     }
     294    pFile = szFile;
     295    if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath,
     296                    NULL)) {
     297
     298        /* Look for a trailing '\\' followed by an index */
     299        pIndexStr = strrchrW(szFile, '\\');
     300        if(pIndexStr && pIndexStr != szFile && *++pIndexStr != '\0') {
     301            index = wcstol(pIndexStr, NULL, 10);
     302            memcpy(szFileCopy, szFile,
     303                   (pIndexStr - szFile - 1) * sizeof(WCHAR));
     304            szFileCopy[pIndexStr - szFile - 1] = '\0';
     305            pFile = szFileCopy;
     306            if(!SearchPathW(NULL,szFileCopy,NULL,sizeof(szPath)/sizeof(WCHAR),
     307                            szPath,NULL))
     308                return TYPE_E_CANTLOADLIBRARY;
     309        } else
     310            return TYPE_E_CANTLOADLIBRARY;
     311    }
     312
     313    TRACE("File %s index %d\n", debugstr_w(pFile), index);
     314
     315    res = TLB_ReadTypeLib(pFile, index, (ITypeLib2**)pptLib);
     316
    299317    if (SUCCEEDED(res))
    300318        switch(regkind)
     
    318336        }
    319337
    320     if(p) HeapFree(GetProcessHeap(),0,p);
    321338    TRACE(" returns %08lx\n",res);
    322339    return res;
     
    372389    CHAR keyName[120];
    373390    HKEY key, subKey;
     391    UINT types, tidx;
     392    TYPEKIND kind;
     393    static const char *PSOA = "{00020424-0000-0000-C000-000000000046}";
    374394
    375395    if (ptlib == NULL || szFullPath == NULL)
     
    381401    StringFromGUID2(&attr->guid, guid, 80);
    382402    guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
    383 #ifdef __WIN32OS2__
    384     sprintf(keyName, "TypeLib\\%s\\%x.%x",
    385             guidA, attr->wMajorVerNum, attr->wMinorVerNum);
    386 #else
    387403    snprintf(keyName, sizeof(keyName), "TypeLib\\%s\\%x.%x",
    388404        guidA, attr->wMajorVerNum, attr->wMinorVerNum);
    389 #endif
    390405    HeapFree(GetProcessHeap(), 0, guidA);
    391406
     
    425440            CHAR buf[20];
    426441            /* FIXME: is %u correct? */
    427 #ifdef __WIN32OS2__
    428             sprintf(buf, "%u", attr->wLibFlags);
    429 #else
    430442            snprintf(buf, sizeof(buf), "%u", attr->wLibFlags);
    431 #endif
    432443            if (RegSetValueExA(subKey, NULL, 0, REG_SZ,
    433444                buf, lstrlenA(buf) + 1) != ERROR_SUCCESS)
     
    439450        res = E_FAIL;
    440451
     452    /* register OLE Automation-compatible interfaces for this typelib */
     453    types = ITypeLib_GetTypeInfoCount(ptlib);
     454    for (tidx=0; tidx<types; tidx++) {
     455        if (SUCCEEDED(ITypeLib_GetTypeInfoType(ptlib, tidx, &kind))) {
     456            LPOLESTR name = NULL;
     457            ITypeInfo *tinfo = NULL;
     458            BOOL stop = FALSE;
     459            ITypeLib_GetDocumentation(ptlib, tidx, &name, NULL, NULL, NULL);
     460            switch (kind) {
     461            case TKIND_INTERFACE:
     462                TRACE_(typelib)("%d: interface %s\n", tidx, debugstr_w(name));
     463                ITypeLib_GetTypeInfo(ptlib, tidx, &tinfo);
     464                break;
     465            case TKIND_DISPATCH:
     466                TRACE_(typelib)("%d: dispinterface %s\n", tidx, debugstr_w(name));
     467                /* ITypeLib_GetTypeInfo(ptlib, tidx, &tinfo); */
     468                break;
     469            case TKIND_COCLASS:
     470                TRACE_(typelib)("%d: coclass %s\n", tidx, debugstr_w(name));
     471                /* coclasses should probably not be registered? */
     472                break;
     473            default:
     474                TRACE_(typelib)("%d: %s\n", tidx, debugstr_w(name));
     475                break;
     476            }
     477            if (tinfo) {
     478                TYPEATTR *tattr = NULL;
     479                ITypeInfo_GetTypeAttr(tinfo, &tattr);
     480                if (tattr) {
     481                    TRACE_(typelib)("guid=%s, flags=%04x\n",
     482                                    debugstr_guid(&tattr->guid),
     483                                    tattr->wTypeFlags);
     484                    if (tattr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION) {
     485                        /* register interface<->typelib coupling */
     486                        StringFromGUID2(&tattr->guid, guid, 80);
     487                        guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
     488                        snprintf(keyName, sizeof(keyName), "Interface\\%s", guidA);
     489                        HeapFree(GetProcessHeap(), 0, guidA);
     490
     491                        if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyName, 0, NULL, 0,
     492                                            KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
     493                            if (name)
     494                                RegSetValueExW(key, NULL, 0, REG_SZ,
     495                                               (BYTE *)name, lstrlenW(name) * sizeof(OLECHAR));
     496
     497                            if (RegCreateKeyExA(key, "ProxyStubClsid", 0, NULL, 0,
     498                                KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS) {
     499                                RegSetValueExA(subKey, NULL, 0, REG_SZ,
     500                                               PSOA, strlen(PSOA));
     501                                RegCloseKey(subKey);
     502                            }
     503                            if (RegCreateKeyExA(key, "ProxyStubClsid32", 0, NULL, 0,
     504                                KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS) {
     505                                RegSetValueExA(subKey, NULL, 0, REG_SZ,
     506                                               PSOA, strlen(PSOA));
     507                                RegCloseKey(subKey);
     508                            }
     509
     510                            if (RegCreateKeyExA(key, "TypeLib", 0, NULL, 0,
     511                                KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS) {
     512                                CHAR ver[32];
     513                                StringFromGUID2(&attr->guid, guid, 80);
     514                                snprintf(ver, sizeof(ver), "%x.%x",
     515                                         attr->wMajorVerNum, attr->wMinorVerNum);
     516                                RegSetValueExW(subKey, NULL, 0, REG_SZ,
     517                                               (BYTE *)guid, lstrlenW(guid) * sizeof(OLECHAR));
     518                                RegSetValueExA(subKey, "Version", 0, REG_SZ,
     519                                               ver, lstrlenA(ver));
     520                                RegCloseKey(subKey);
     521                            }
     522                            RegCloseKey(key);
     523                        }
     524                    }
     525                    ITypeInfo_ReleaseTypeAttr(tinfo, tattr);
     526                }
     527                ITypeInfo_Release(tinfo);
     528            }
     529            SysFreeString(name);
     530            if (stop) break;
     531        }
     532    }
     533
    441534    ITypeLib_ReleaseTLibAttr(ptlib, attr);
     535
    442536    return res;
    443537}
     
    464558}
    465559
    466 #ifndef __WIN32OS2__
     560#ifdef __WIN32OS2__
    467561/****************************************************************************
    468562 *      OaBuildVersion                          (TYPELIB.15)
     
    17611855#define MSFT_SIGNATURE 0x5446534D /* "MSFT" */
    17621856#define SLTG_SIGNATURE 0x47544c53 /* "SLTG" */
    1763 int TLB_ReadTypeLib(LPSTR pszFileName, ITypeLib2 **ppTypeLib)
    1764 {
    1765     int ret = E_FAIL;
     1857int TLB_ReadTypeLib(LPCWSTR pszFileName, INT index, ITypeLib2 **ppTypeLib)
     1858{
     1859    int ret = TYPE_E_CANTLOADLIBRARY;
    17661860    DWORD dwSignature = 0;
    17671861    HFILE hFile;
    1768     int nStrLen = strlen(pszFileName);
    1769     int i;
    1770 
    1771     PCHAR pszTypeLibIndex = NULL;
    1772     PCHAR pszDllName      = NULL;
    1773 
    1774     TRACE_(typelib)("%s\n", pszFileName);
     1862
     1863    TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index);
    17751864
    17761865    *ppTypeLib = NULL;
    17771866
    1778     /* is it a DLL? */
    1779         for (i=0 ; i < nStrLen ; ++i)
    1780         {
    1781             pszFileName[i] = tolower(pszFileName[i]);
    1782         }
    1783     pszTypeLibIndex = strstr(pszFileName, ".dll");
    1784 
    1785     /* find if there's a back-slash after .DLL (good sign of the presence of a typelib index) */
    1786     if (pszTypeLibIndex)
    1787     {
    1788       pszTypeLibIndex = strstr(pszTypeLibIndex, "\\");
    1789     }
    1790 
    1791     /* is there any thing after trailing back-slash  ? */
    1792     if (pszTypeLibIndex && pszTypeLibIndex < pszFileName + nStrLen)
    1793     {
    1794       /* yes -> it's an index! store DLL name, without the trailing back-slash */
    1795       size_t nMemToAlloc = pszTypeLibIndex - pszFileName;
    1796      
    1797       pszDllName = HeapAlloc(GetProcessHeap(),
    1798                           HEAP_ZERO_MEMORY,
    1799                           nMemToAlloc + 1);
    1800                          
    1801       strncpy(pszDllName, pszFileName, nMemToAlloc);
    1802      
    1803       /* move index string pointer pass the backslash */
    1804       while (*pszTypeLibIndex == '\\')
    1805         ++pszTypeLibIndex;
    1806     }
    1807     else
    1808     {
    1809       /* No index, reset variable to 1 */
    1810       pszDllName = HeapAlloc(GetProcessHeap(),
    1811                           HEAP_ZERO_MEMORY,
    1812                           nStrLen + 1);
    1813                          
    1814       strncpy(pszDllName, pszFileName, nStrLen);
    1815      
    1816       pszTypeLibIndex = "1\0";
    1817     }
    1818 
    1819     TRACE_(typelib)("File name without index %s\n", pszDllName);
    1820     TRACE_(typelib)("Index of typelib %s\n",        pszTypeLibIndex);
    1821 
    1822 
    18231867    /* check the signature of the file */
    1824     hFile = CreateFileA( pszDllName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
     1868    hFile = CreateFileW( pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
    18251869    if (INVALID_HANDLE_VALUE != hFile)
    18261870    {
     
    18561900    {
    18571901      /* find the typelibrary resource*/
    1858       HINSTANCE hinstDLL = LoadLibraryExA(pszDllName, 0, DONT_RESOLVE_DLL_REFERENCES|
     1902      HINSTANCE hinstDLL = LoadLibraryExW(pszFileName, 0, DONT_RESOLVE_DLL_REFERENCES|
    18591903                                          LOAD_LIBRARY_AS_DATAFILE|LOAD_WITH_ALTERED_SEARCH_PATH);
    18601904      if (hinstDLL)
    18611905      {
    1862         HRSRC hrsrc = FindResourceA(hinstDLL, MAKEINTRESOURCEA(atoi(pszTypeLibIndex)), "TYPELIB");
     1906        HRSRC hrsrc = FindResourceA(hinstDLL, MAKEINTRESOURCEA(index),
     1907          "TYPELIB");
    18631908        if (hrsrc)
    18641909        {
     
    18951940    }
    18961941
    1897     HeapFree(GetProcessHeap(), 0, pszDllName);
    1898 
    18991942    if(*ppTypeLib)
    19001943      ret = S_OK;
    19011944    else
    1902       ERR("Loading of typelib %s failed with error 0x%08lx\n", pszFileName, GetLastError());
     1945      ERR("Loading of typelib %s failed with error 0x%08lx\n",
     1946          debugstr_w(pszFileName), GetLastError());
    19031947
    19041948    return ret;
     
    24862530        for(param = 0; param < (*ppFuncDesc)->funcdesc.cParams; param++) {
    24872531            char *paramName = pNameTable + *pArg;
    2488             /* right, if the arg type follows then paramName points to the 2nd
    2489                letter of the name (or there is no name), else if the next
    2490                WORD is an offset to the arg type then paramName points to the
    2491                first letter. Before the name there always seems to be the byte
    2492                0xff or 0x00, so let's take one char off paramName and see what
    2493                we're pointing at.  Got that? */
    2494 
    2495             if(*pArg == 0xffff) /* If we don't have a name the type seems to
    2496                                    always follow.  FIXME is this correct? */
    2497               paramName = NULL;
     2532            BOOL HaveOffs;
     2533            /* If arg type follows then paramName points to the 2nd
     2534               letter of the name, else the next WORD is an offset to
     2535               the arg type and paramName points to the first letter.
     2536               So let's take one char off paramName and see if we're
     2537               pointing at an alpha-numeric char.  However if *pArg is
     2538               0xffff or 0xfffe then the param has no name, the former
     2539               meaning that the next WORD is the type, the latter
     2540               meaning the the next WORD is an offset to the type. */
     2541
     2542            HaveOffs = FALSE;
     2543            if(*pArg == 0xffff)
     2544                paramName = NULL;
     2545            else if(*pArg == 0xfffe) {
     2546                paramName = NULL;
     2547                HaveOffs = TRUE;
     2548            }
     2549            else if(!isalnum(*(paramName-1)))
     2550                HaveOffs = TRUE;
    24982551
    24992552            pArg++;
    25002553
    2501             if(paramName &&
    2502                (*(paramName-1) == '\xff' ||
    2503                 *(paramName-1) == '\x00')) { /* the next word is an offset to
    2504                                               the type */
     2554            if(HaveOffs) { /* the next word is an offset to type */
    25052555                pType = (WORD*)(pFirstItem + *pArg);
    25062556                SLTG_DoType(pType, pFirstItem,
     
    26012651      if(pItem->magic != SLTG_ENUMITEM_MAGIC) {
    26022652          FIXME("enumitem magic = %04x\n", pItem->magic);
    2603           return;
     2653          return NULL;
    26042654      }
    26052655      *ppVarDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
  • TabularUnified tags/trunk/src/oleaut32/variant.c

    r17271 r17504  
    4848DEFAULT_DEBUG_CHANNEL(ole);
    4949
     50#define SYSDUPSTRING(str) SysAllocStringLen((str), SysStringLen(str))
     51
    5052#ifndef FLT_MAX
    5153# ifdef MAXFLOAT
     
    9092 * 400 then it is a leap year.
    9193 */
    92 /* According to postgeSQL date parsing functions there is
     94/* According to postgreSQL date parsing functions there is
    9395 * a leap year when this expression is true.
    9496 * (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
     
    104106 */
    105107static const double DAYS_IN_ONE_YEAR = 365.2425;
     108
    106109
    107110/******************************************************************************
     
    235238static BOOL TmToDATE( struct tm* pTm, DATE *pDateOut )
    236239{
    237         if( (pTm->tm_year - 1900) >= 0 )
    238         {
    239                 int leapYear = 0;
    240                
    241                 /* Start at 1. This is the way DATE is defined.
    242                  * January 1, 1900 at Midnight is 1.00.
    243                  * January 1, 1900 at 6AM is 1.25.
    244                  * and so on.
    245                  */
    246                 *pDateOut = 1;
    247 
    248                 /* Add the number of days corresponding to
    249                  * tm_year.
    250                  */
    251                 *pDateOut += (pTm->tm_year - 1900) * 365;
    252 
    253                 /* Add the leap days in the previous years between now and 1900.
    254                  * Note a leap year is one that is a multiple of 4
    255                  * but not of a 100.  Except if it is a multiple of
    256                  * 400 then it is a leap year.
    257                  */
    258                 *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
    259                 *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
    260                 *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
    261 
    262                 /* Set the leap year flag if the
    263                  * current year specified by tm_year is a
    264                  * leap year. This will be used to add a day
    265                  * to the day count.
    266                  */
    267                 if( isleap( pTm->tm_year ) )
    268                         leapYear = 1;
    269                
    270                 /* Add the number of days corresponding to
    271                  * the month.
    272                  */
    273                 switch( pTm->tm_mon )
    274                 {
    275                 case 2:
    276                         *pDateOut += 31;
    277                         break;
    278                 case 3:
    279                         *pDateOut += ( 59 + leapYear );
    280                         break;
    281                 case 4:
    282                         *pDateOut += ( 90 + leapYear );
    283                         break;
    284                 case 5:
    285                         *pDateOut += ( 120 + leapYear );
    286                         break;
    287                 case 6:
    288                         *pDateOut += ( 151 + leapYear );
    289                         break;
    290                 case 7:
    291                         *pDateOut += ( 181 + leapYear );
    292                         break;
    293                 case 8:
    294                         *pDateOut += ( 212 + leapYear );
    295                         break;
    296                 case 9:
    297                         *pDateOut += ( 243 + leapYear );
    298                         break;
    299                 case 10:
    300                         *pDateOut += ( 273 + leapYear );
    301                         break;
    302                 case 11:
    303                         *pDateOut += ( 304 + leapYear );
    304                         break;
    305                 case 12:
    306                         *pDateOut += ( 334 + leapYear );
    307                         break;
    308                 }
    309                 /* Add the number of days in this month.
    310                  */
    311                 *pDateOut += pTm->tm_mday;
    312        
    313                 /* Add the number of seconds, minutes, and hours
    314                  * to the DATE. Note these are the fracionnal part
    315                  * of the DATE so seconds / number of seconds in a day.
    316                  */
    317                 *pDateOut += pTm->tm_hour / 24.0;
    318                 *pDateOut += pTm->tm_min / 1440.0;
    319                 *pDateOut += pTm->tm_sec / 86400.0;
    320                 return TRUE;
    321         }
    322         return FALSE;
     240    int leapYear = 0;
     241
     242    if( (pTm->tm_year - 1900) < 0 ) return FALSE;
     243
     244    /* Start at 1. This is the way DATE is defined.
     245     * January 1, 1900 at Midnight is 1.00.
     246     * January 1, 1900 at 6AM is 1.25.
     247     * and so on.
     248     */
     249    *pDateOut = 1;
     250
     251    /* Add the number of days corresponding to
     252     * tm_year.
     253     */
     254    *pDateOut += (pTm->tm_year - 1900) * 365;
     255
     256    /* Add the leap days in the previous years between now and 1900.
     257     * Note a leap year is one that is a multiple of 4
     258     * but not of a 100.  Except if it is a multiple of
     259     * 400 then it is a leap year.
     260     */
     261    *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
     262    *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
     263    *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
     264
     265    /* Set the leap year flag if the
     266     * current year specified by tm_year is a
     267     * leap year. This will be used to add a day
     268     * to the day count.
     269     */
     270    if( isleap( pTm->tm_year ) )
     271        leapYear = 1;
     272
     273    /* Add the number of days corresponding to
     274     * the month.
     275     */
     276    switch( pTm->tm_mon )
     277    {
     278    case 2:
     279        *pDateOut += 31;
     280        break;
     281    case 3:
     282        *pDateOut += ( 59 + leapYear );
     283        break;
     284    case 4:
     285        *pDateOut += ( 90 + leapYear );
     286        break;
     287    case 5:
     288        *pDateOut += ( 120 + leapYear );
     289        break;
     290    case 6:
     291        *pDateOut += ( 151 + leapYear );
     292        break;
     293    case 7:
     294        *pDateOut += ( 181 + leapYear );
     295        break;
     296    case 8:
     297        *pDateOut += ( 212 + leapYear );
     298        break;
     299    case 9:
     300        *pDateOut += ( 243 + leapYear );
     301        break;
     302    case 10:
     303        *pDateOut += ( 273 + leapYear );
     304        break;
     305    case 11:
     306        *pDateOut += ( 304 + leapYear );
     307        break;
     308    case 12:
     309        *pDateOut += ( 334 + leapYear );
     310        break;
     311    }
     312    /* Add the number of days in this month.
     313     */
     314    *pDateOut += pTm->tm_mday;
     315
     316    /* Add the number of seconds, minutes, and hours
     317     * to the DATE. Note these are the fracionnal part
     318     * of the DATE so seconds / number of seconds in a day.
     319     */
     320    *pDateOut += pTm->tm_hour / 24.0;
     321    *pDateOut += pTm->tm_min / 1440.0;
     322    *pDateOut += pTm->tm_sec / 86400.0;
     323    return TRUE;
    323324}
    324325
     
    339340static BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
    340341{
    341         /* Do not process dates smaller than January 1, 1900.
    342          * Which corresponds to 2.0 in the windows DATE format.
    343          */
    344         if( dateIn >= 2.0 )
    345         {
    346                 double decimalPart = 0.0;
    347                 double wholePart = 0.0;
    348 
    349                 memset(pTm,0,sizeof(*pTm));
    350        
    351                 /* Because of the nature of DATE format which
    352                  * associates 2.0 to January 1, 1900. We will
    353                  * remove 1.0 from the whole part of the DATE
    354                  * so that in the following code 1.0
    355                  * will correspond to January 1, 1900.
    356                  * This simplifies the processing of the DATE value.
    357                  */
    358                 dateIn -= 1.0;
    359 
    360                 wholePart = (double) floor( dateIn );
    361                 decimalPart = fmod( dateIn, wholePart );
    362 
    363                 if( !(dwFlags & VAR_TIMEVALUEONLY) )
    364                 {
    365                         int nDay = 0;
    366                         int leapYear = 0;
    367                         double yearsSince1900 = 0;
    368                         /* Start at 1900, this is where the DATE time 0.0 starts.
    369                          */
    370                         pTm->tm_year = 1900;
    371                         /* find in what year the day in the "wholePart" falls into.
    372                          * add the value to the year field.
    373                          */
    374                         yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
    375                         pTm->tm_year += yearsSince1900;
    376                         /* determine if this is a leap year.
    377                          */
    378                         if( isleap( pTm->tm_year ) )
    379                         {
    380                                 leapYear = 1;
    381                                 wholePart++;
    382                         }
    383 
    384                         /* find what day of that year the "wholePart" corresponds to.
    385                          * Note: nDay is in [1-366] format
    386                          */
    387                         nDay = (int) ( wholePart - floor( yearsSince1900 * DAYS_IN_ONE_YEAR ) );
    388                         /* Set the tm_yday value.
    389                          * Note: The day must be converted from [1-366] to [0-365]
    390                          */
    391                         /*pTm->tm_yday = nDay - 1;*/
    392                         /* find which month this day corresponds to.
    393                          */
    394                         if( nDay <= 31 )
    395                         {
    396                                 pTm->tm_mday = nDay;
    397                                 pTm->tm_mon = 0;
    398                         }
    399                         else if( nDay <= ( 59 + leapYear ) )
    400                         {
    401                                 pTm->tm_mday = nDay - 31;
    402                                 pTm->tm_mon = 1;
    403                         }
    404                         else if( nDay <= ( 90 + leapYear ) )
    405                         {
    406                                 pTm->tm_mday = nDay - ( 59 + leapYear );
    407                                 pTm->tm_mon = 2;
    408                         }
    409                         else if( nDay <= ( 120 + leapYear ) )
    410                         {
    411                                 pTm->tm_mday = nDay - ( 90 + leapYear );
    412                                 pTm->tm_mon = 3;
    413                         }
    414                         else if( nDay <= ( 151 + leapYear ) )
    415                         {
    416                                 pTm->tm_mday = nDay - ( 120 + leapYear );
    417                                 pTm->tm_mon = 4;
    418                         }
    419                         else if( nDay <= ( 181 + leapYear ) )
    420                         {
    421                                 pTm->tm_mday = nDay - ( 151 + leapYear );
    422                                 pTm->tm_mon = 5;
    423                         }
    424                         else if( nDay <= ( 212 + leapYear ) )
    425                         {
    426                                 pTm->tm_mday = nDay - ( 181 + leapYear );
    427                                 pTm->tm_mon = 6;
    428                         }
    429                         else if( nDay <= ( 243 + leapYear ) )
    430                         {
    431                                 pTm->tm_mday = nDay - ( 212 + leapYear );
    432                                 pTm->tm_mon = 7;
    433                         }
    434                         else if( nDay <= ( 273 + leapYear ) )
    435                         {
    436                                 pTm->tm_mday = nDay - ( 243 + leapYear );
    437                                 pTm->tm_mon = 8;
    438                         }
    439                         else if( nDay <= ( 304 + leapYear ) )
    440                         {
    441                                 pTm->tm_mday = nDay - ( 273 + leapYear );
    442                                 pTm->tm_mon = 9;
    443                         }
    444                         else if( nDay <= ( 334 + leapYear ) )
    445                         {
    446                                 pTm->tm_mday = nDay - ( 304 + leapYear );
    447                                 pTm->tm_mon = 10;
    448                         }
    449                         else if( nDay <= ( 365 + leapYear ) )
    450                         {
    451                                 pTm->tm_mday = nDay - ( 334 + leapYear );
    452                                 pTm->tm_mon = 11;
    453                         }
    454                 }
    455                 if( !(dwFlags & VAR_DATEVALUEONLY) )
    456                 {
    457                         /* find the number of seconds in this day.
    458                          * fractional part times, hours, minutes, seconds.
    459                          */
    460                         pTm->tm_hour = (int) ( decimalPart * 24 );
    461                         pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 );
    462                         pTm->tm_sec = (int) ( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 );
    463                 }
    464                 return TRUE;
    465         }
    466         return FALSE;
     342    double decimalPart = 0.0;
     343    double wholePart = 0.0;
     344
     345    /* Do not process dates smaller than January 1, 1900.
     346     * Which corresponds to 2.0 in the windows DATE format.
     347     */
     348    if( dateIn < 2.0 ) return FALSE;
     349
     350    memset(pTm,0,sizeof(*pTm));
     351
     352    /* Because of the nature of DATE format which
     353     * associates 2.0 to January 1, 1900. We will
     354     * remove 1.0 from the whole part of the DATE
     355     * so that in the following code 1.0
     356     * will correspond to January 1, 1900.
     357     * This simplifies the processing of the DATE value.
     358     */
     359    dateIn -= 1.0;
     360
     361    wholePart = (double) floor( dateIn );
     362    decimalPart = fmod( dateIn, wholePart );
     363
     364    if( !(dwFlags & VAR_TIMEVALUEONLY) )
     365    {
     366        int nDay = 0;
     367        int leapYear = 0;
     368        double yearsSince1900 = 0;
     369        /* Start at 1900, this is where the DATE time 0.0 starts.
     370         */
     371        pTm->tm_year = 1900;
     372        /* find in what year the day in the "wholePart" falls into.
     373         * add the value to the year field.
     374         */
     375        yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
     376        pTm->tm_year += yearsSince1900;
     377        /* determine if this is a leap year.
     378         */
     379        if( isleap( pTm->tm_year ) )
     380        {
     381            leapYear = 1;
     382            wholePart++;
     383        }
     384
     385        /* find what day of that year the "wholePart" corresponds to.
     386         * Note: nDay is in [1-366] format
     387         */
     388        nDay = (int) ( wholePart - floor( yearsSince1900 * DAYS_IN_ONE_YEAR ) );
     389        /* Set the tm_yday value.
     390         * Note: The day must be converted from [1-366] to [0-365]
     391         */
     392        /*pTm->tm_yday = nDay - 1;*/
     393        /* find which month this day corresponds to.
     394         */
     395        if( nDay <= 31 )
     396        {
     397            pTm->tm_mday = nDay;
     398            pTm->tm_mon = 0;
     399        }
     400        else if( nDay <= ( 59 + leapYear ) )
     401        {
     402            pTm->tm_mday = nDay - 31;
     403            pTm->tm_mon = 1;
     404        }
     405        else if( nDay <= ( 90 + leapYear ) )
     406        {
     407            pTm->tm_mday = nDay - ( 59 + leapYear );
     408            pTm->tm_mon = 2;
     409        }
     410        else if( nDay <= ( 120 + leapYear ) )
     411        {
     412            pTm->tm_mday = nDay - ( 90 + leapYear );
     413            pTm->tm_mon = 3;
     414        }
     415        else if( nDay <= ( 151 + leapYear ) )
     416        {
     417            pTm->tm_mday = nDay - ( 120 + leapYear );
     418            pTm->tm_mon = 4;
     419        }
     420        else if( nDay <= ( 181 + leapYear ) )
     421        {
     422            pTm->tm_mday = nDay - ( 151 + leapYear );
     423            pTm->tm_mon = 5;
     424        }
     425        else if( nDay <= ( 212 + leapYear ) )
     426        {
     427            pTm->tm_mday = nDay - ( 181 + leapYear );
     428            pTm->tm_mon = 6;
     429        }
     430        else if( nDay <= ( 243 + leapYear ) )
     431        {
     432            pTm->tm_mday = nDay - ( 212 + leapYear );
     433            pTm->tm_mon = 7;
     434        }
     435        else if( nDay <= ( 273 + leapYear ) )
     436        {
     437            pTm->tm_mday = nDay - ( 243 + leapYear );
     438            pTm->tm_mon = 8;
     439        }
     440        else if( nDay <= ( 304 + leapYear ) )
     441        {
     442            pTm->tm_mday = nDay - ( 273 + leapYear );
     443            pTm->tm_mon = 9;
     444        }
     445        else if( nDay <= ( 334 + leapYear ) )
     446        {
     447            pTm->tm_mday = nDay - ( 304 + leapYear );
     448            pTm->tm_mon = 10;
     449        }
     450        else if( nDay <= ( 365 + leapYear ) )
     451        {
     452            pTm->tm_mday = nDay - ( 334 + leapYear );
     453            pTm->tm_mon = 11;
     454        }
     455    }
     456    if( !(dwFlags & VAR_DATEVALUEONLY) )
     457    {
     458        /* find the number of seconds in this day.
     459         * fractional part times, hours, minutes, seconds.
     460         */
     461        pTm->tm_hour = (int) ( decimalPart * 24 );
     462        pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 );
     463        pTm->tm_sec = (int) ( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 );
     464    }
     465    return TRUE;
    467466}
    468467
     
    615614        LPSTR pNewString = NULL;
    616615        LPSTR strToken = NULL;
    617 
    618616
    619617        /* Check if we have a valid argument
     
    16801678 *              VariantInit     [OLEAUT32.8]
    16811679 *
    1682  * Initializes the Variant.  Unlike VariantClear it does not interpret the current
    1683  * contents of the Variant.
     1680 * Initializes the Variant.  Unlike VariantClear it does not interpret
     1681 * the current contents of the Variant.
    16841682 */
    16851683void WINAPI VariantInit(VARIANTARG* pvarg)
    16861684{
    1687   TRACE("(%p),stub\n",pvarg);
     1685  TRACE("(%p)\n",pvarg);
    16881686
    16891687  memset(pvarg, 0, sizeof (VARIANTARG));
     
    17641762  HRESULT res = S_OK;
    17651763
    1766   TRACE("(%p, %p)\n", pvargDest, pvargSrc);
     1764  TRACE("(%p, %p), vt=%d\n", pvargDest, pvargSrc, V_VT(pvargSrc));
    17671765
    17681766  res = ValidateVariantType( V_VT(pvargSrc) );
     
    17971795        {
    17981796          /* In the case of by value we need to
    1799            * copy the actuall value. In the case of
     1797           * copy the actual value. In the case of
    18001798           * VT_BSTR a copy of the string is made,
    1801            * if VT_DISPATCH or VT_IUNKNOWN AddReff is
     1799           * if VT_DISPATCH or VT_IUNKNOWN AddRef is
    18021800           * called to increment the object's reference count.
    18031801           */
     
    18051803          {
    18061804            case( VT_BSTR ):
    1807               V_UNION(pvargDest,bstrVal) = SysAllocString( V_UNION(pvargSrc,bstrVal) );
     1805              V_UNION(pvargDest,bstrVal) = SYSDUPSTRING( V_UNION(pvargSrc,bstrVal) );
    18081806              break;
    18091807            case( VT_DISPATCH ):
     
    18941892          {
    18951893            case( VT_BSTR ):
    1896               V_UNION(pvargDest,bstrVal) = SysAllocString( *(V_UNION(pvargSrc,pbstrVal)) );
     1894              V_UNION(pvargDest,bstrVal) = SYSDUPSTRING( *(V_UNION(pvargSrc,pbstrVal)) );
    18971895              break;
    18981896            case( VT_DISPATCH ):
     
    19861984        VariantInit( &varg );
    19871985       
    1988         TRACE("(%p, %p, %ld, %u, %u),stub\n", pvargDest, pvargSrc, lcid, wFlags, vt);
     1986        TRACE("(%p, %p, %ld, %u, %u) vt=%d\n", pvargDest, pvargSrc, lcid, wFlags, vt, V_VT(pvargSrc));
    19891987
    19901988        /* validate our source argument.
     
    32513249 */
    32523250HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut) {
    3253                                 /* FIXME */
     3251        FIXME("([cyIn], %08lx, %08lx, %p), stub.\n", lcid, dwFlags, pbstrOut);
    32543252        return E_NOTIMPL;
    32553253}
     
    33163314        TRACE("( %d, %ld, %ld, %p ), stub\n", boolIn, lcid, dwFlags, pbstrOut );
    33173315
    3318         if( boolIn == VARIANT_FALSE )
    3319         {
    3320                 sprintf( pBuffer, "False" );
    3321         }
    3322         else
    3323         {
    3324                 sprintf( pBuffer, "True" );
    3325         }
     3316        sprintf( pBuffer, (boolIn == VARIANT_FALSE) ? "False" : "True" );
    33263317
    33273318        *pbstrOut = StringDupAtoBstr( pBuffer );
     
    33923383        TRACE("( %d, %p ), stub\n", sIn, pboolOut );
    33933384
    3394         if( sIn == 0 )
    3395         {
    3396                 *pboolOut = VARIANT_FALSE;
    3397         }
    3398         else
    3399         {
    3400                 *pboolOut = VARIANT_TRUE;
    3401         }
     3385        *pboolOut = (sIn) ? VARIANT_TRUE : VARIANT_FALSE;
    34023386
    34033387        return S_OK;
     
    34113395        TRACE("( %ld, %p ), stub\n", lIn, pboolOut );
    34123396
    3413         if( lIn == 0 )
    3414         {
    3415                 *pboolOut = VARIANT_FALSE;
    3416         }
    3417         else
    3418         {
    3419                 *pboolOut = VARIANT_TRUE;
    3420         }
     3397        *pboolOut = (lIn) ? VARIANT_TRUE : VARIANT_FALSE;
    34213398
    34223399        return S_OK;
     
    34303407        TRACE("( %f, %p ), stub\n", fltIn, pboolOut );
    34313408
    3432         if( fltIn == 0.0 )
    3433         {
    3434                 *pboolOut = VARIANT_FALSE;
    3435         }
    3436         else
    3437         {
    3438                 *pboolOut = VARIANT_TRUE;
    3439         }
     3409        *pboolOut = (fltIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
    34403410
    34413411        return S_OK;
     
    34493419        TRACE("( %f, %p ), stub\n", dblIn, pboolOut );
    34503420
    3451         if( dblIn == 0.0 )
    3452         {
    3453                 *pboolOut = VARIANT_FALSE;
    3454         }
    3455         else
    3456         {
    3457                 *pboolOut = VARIANT_TRUE;
    3458         }
     3421        *pboolOut = (dblIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
    34593422
    34603423        return S_OK;
     
    34683431        TRACE("( %f, %p ), stub\n", dateIn, pboolOut );
    34693432
    3470         if( dateIn == 0.0 )
    3471         {
    3472                 *pboolOut = VARIANT_FALSE;
    3473         }
    3474         else
    3475         {
    3476                 *pboolOut = VARIANT_TRUE;
    3477         }
     3433        *pboolOut = (dateIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
    34783434
    34793435        return S_OK;
     
    35173473                                ret = DISP_E_TYPEMISMATCH;
    35183474                        }
    3519                         else if( dValue == 0.0 )
    3520                         {
    3521                                 *pboolOut = VARIANT_FALSE;
    3522                         }
    35233475                        else
    3524                         {
    3525                                 *pboolOut = VARIANT_TRUE;
    3526                         }
     3476                                *pboolOut = (dValue == 0.0) ?
     3477                                                VARIANT_FALSE : VARIANT_TRUE;
    35273478                }
    35283479        }
     
    35403491        TRACE("( %c, %p ), stub\n", cIn, pboolOut );
    35413492
    3542         if( cIn == 0 )
    3543         {
    3544                 *pboolOut = VARIANT_FALSE;
    3545         }
    3546         else
    3547         {
    3548                 *pboolOut = VARIANT_TRUE;
    3549         }
     3493        *pboolOut = (cIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
    35503494
    35513495        return S_OK;
     
    35593503        TRACE("( %d, %p ), stub\n", uiIn, pboolOut );
    35603504
    3561         if( uiIn == 0 )
    3562         {
    3563                 *pboolOut = VARIANT_FALSE;
    3564         }
    3565         else
    3566         {
    3567                 *pboolOut = VARIANT_TRUE;
    3568         }
     3505        *pboolOut = (uiIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
    35693506
    35703507        return S_OK;
     
    35783515        TRACE("( %ld, %p ), stub\n", ulIn, pboolOut );
    35793516
    3580         if( ulIn == 0 )
    3581         {
    3582                 *pboolOut = VARIANT_FALSE;
    3583         }
    3584         else
    3585         {
    3586                 *pboolOut = VARIANT_TRUE;
    3587         }
     3517        *pboolOut = (ulIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
    35883518
    35893519        return S_OK;
     
    41114041        TRACE("( %f, %p ), stub\n", dblIn, pulOut );
    41124042
    4113     dblIn = round( dblIn );
     4043        dblIn = round( dblIn );
    41144044        if( dblIn < UI4_MIN || dblIn > UI4_MAX )
    41154045        {
    41164046                return DISP_E_OVERFLOW;
    4117     }
     4047        }
    41184048
    41194049        *pulOut = (ULONG) dblIn;
     
    41294059        TRACE("( %f, %p ), stub\n", dateIn, pulOut );
    41304060
    4131     dateIn = round( dateIn );
    4132     if( dateIn < UI4_MIN || dateIn > UI4_MAX )
     4061        dateIn = round( dateIn );
     4062        if( dateIn < UI4_MIN || dateIn > UI4_MAX )
    41334063        {
    41344064                return DISP_E_OVERFLOW;
     
    41954125 */
    41964126HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY* pcyOut) {
    4197    pcyOut->s.Hi = 0;
    4198    pcyOut->s.Lo = ((ULONG)bIn) * 10000;
    4199    
    4200    return S_OK;
     4127    pcyOut->s.Hi = 0;
     4128    pcyOut->s.Lo = ((ULONG)bIn) * 10000;
     4129
     4130    return S_OK;
    42014131}
    42024132
     
    42064136 */
    42074137HRESULT WINAPI VarCyFromI2(short sIn, CY* pcyOut) {
    4208    if (sIn < 0) pcyOut->s.Hi = -1;
    4209    else pcyOut->s.Hi = 0;
    4210    pcyOut->s.Lo = ((ULONG)sIn) * 10000;
    4211    
    4212    return S_OK;
     4138    if (sIn < 0) pcyOut->s.Hi = -1;
     4139    else pcyOut->s.Hi = 0;
     4140    pcyOut->s.Lo = ((ULONG)sIn) * 10000;
     4141
     4142    return S_OK;
    42134143}
    42144144
     
    42694199 */
    42704200HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pcyOut) {
    4271                                 /* FIXME */
    4272                 return E_NOTIMPL;
     4201        FIXME("(%p, %08lx, %08lx, %p), stub.\n", strIn, lcid, dwFlags, pcyOut);
     4202        return E_NOTIMPL;
    42734203}
    42744204
     
    44144344
    44154345/**********************************************************************
    4416  *              VariantTimeToDosDateTime [OLEAUT32.??]
     4346 *              VariantTimeToDosDateTime [OLEAUT32.13]
    44174347 * Convert variant representation of time to the date and time representation
    44184348 * stored in dos.
     
    44404370
    44414371
     4372/***********************************************************************
     4373 *              SystemTimeToVariantTime [OLEAUT32.184]
     4374 */
    44424375HRESULT WINAPI SystemTimeToVariantTime( LPSYSTEMTIME  lpSystemTime, double *pvtime )
    44434376{
     
    44884421}
    44894422
     4423/***********************************************************************
     4424 *              VariantTimeToSystemTime [OLEAUT32.185]
     4425 */
    44904426HRESULT WINAPI VariantTimeToSystemTime( double vtime, LPSYSTEMTIME  lpSystemTime )
    44914427{
     
    46034539}
    46044540
     4541/***********************************************************************
     4542 *              VarUdateFromDate [OLEAUT32.331]
     4543 */
    46054544HRESULT WINAPI VarUdateFromDate( DATE datein, ULONG dwFlags, UDATE *pudateout)
    46064545{
     
    46354574}
    46364575
     4576/***********************************************************************
     4577 *              VarDateFromUdate [OLEAUT32.330]
     4578 */
    46374579HRESULT WINAPI VarDateFromUdate(UDATE *pudateout,
    46384580                                ULONG dwFlags, DATE *datein)
Note: See TracChangeset for help on using the changeset viewer.