Skip to content

Commit e6ffc6c

Browse files
Change to use std int for Interop tests (#95040)
* Change to use std int for Interop tests
1 parent ac1ddb9 commit e6ffc6c

File tree

47 files changed

+686
-723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+686
-723
lines changed

src/tests/Common/Platform/platformdefines.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,15 @@ DWORD TP_GetFullPathName(LPWSTR fileName, DWORD nBufferLength, LPWSTR lpBuffer)
331331
#define INTSAFE_E_ARITHMETIC_OVERFLOW ((HRESULT)0x80070216L) // 0x216 = 534 = ERROR_ARITHMETIC_OVERFLOW
332332
#define ULONG_ERROR (0xffffffffUL)
333333
#define WIN32_ALLOC_ALIGN (16 - 1)
334+
335+
#ifndef UInt32x32To64
336+
#define UInt32x32To64(a, b) ((uint64_t)((ULONG)(a)) * (uint64_t)((ULONG)(b)))
337+
#endif // UInt32x32To64
338+
334339
//
335-
// ULONGLONG -> ULONG conversion
340+
// uint64_t -> ULONG conversion
336341
//
337-
HRESULT ULongLongToULong(ULONGLONG ullOperand, ULONG* pulResult)
342+
static HRESULT UInt64ToULong(uint64_t ullOperand, ULONG* pulResult)
338343
{
339344
HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
340345
*pulResult = ULONG_ERROR;
@@ -348,7 +353,7 @@ HRESULT ULongLongToULong(ULONGLONG ullOperand, ULONG* pulResult)
348353
return hr;
349354
}
350355

351-
HRESULT ULongAdd(ULONG ulAugend, ULONG ulAddend,ULONG* pulResult)
356+
static HRESULT ULongAdd(ULONG ulAugend, ULONG ulAddend,ULONG* pulResult)
352357
{
353358
HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
354359
*pulResult = ULONG_ERROR;
@@ -362,14 +367,14 @@ HRESULT ULongAdd(ULONG ulAugend, ULONG ulAddend,ULONG* pulResult)
362367
return hr;
363368
}
364369

365-
HRESULT ULongMult(ULONG ulMultiplicand, ULONG ulMultiplier, ULONG* pulResult)
370+
static HRESULT ULongMult(ULONG ulMultiplicand, ULONG ulMultiplier, ULONG* pulResult)
366371
{
367-
ULONGLONG ull64Result = UInt32x32To64(ulMultiplicand, ulMultiplier);
372+
uint64_t ull64Result = UInt32x32To64(ulMultiplicand, ulMultiplier);
368373

369-
return ULongLongToULong(ull64Result, pulResult);
374+
return UInt64ToULong(ull64Result, pulResult);
370375
}
371376

372-
HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)
377+
static HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)
373378
{
374379
if (result == NULL)
375380
return E_INVALIDARG;

src/tests/Common/Platform/platformdefines.h

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stdlib.h>
99
#include <string.h>
1010
#include <cstdint>
11+
#include <cinttypes>
1112
#include <minipal/utils.h>
1213

1314
#ifndef _PLATFORMDEFINES__H
@@ -50,7 +51,7 @@
5051
#define L(t) L##t
5152
#define W(str) L##str
5253

53-
typedef unsigned error_t;
54+
typedef uint32_t error_t;
5455
typedef HANDLE THREAD_ID;
5556

5657
#define DLL_EXPORT __declspec(dllexport)
@@ -59,44 +60,34 @@ typedef HANDLE THREAD_ID;
5960
#include <pthread.h>
6061

6162
typedef char16_t WCHAR;
62-
typedef unsigned int DWORD;
63+
typedef uint32_t DWORD;
6364

6465
#ifdef OBJC_TESTS
6566
// The Objective-C headers define the BOOL type to be unsigned char or bool.
6667
// As a result, we can't redefine it here. So instead, define WINBOOL to be int-sized.
67-
typedef int WINBOOL;
68+
typedef int32_t WINBOOL;
6869
#else
69-
typedef int BOOL;
70+
typedef int32_t BOOL;
7071
#endif
7172
typedef WCHAR *LPWSTR, *PWSTR;
7273
typedef const WCHAR *LPCWSTR, *PCWSTR;
7374

74-
typedef int HRESULT;
75-
#define LONGLONG long long
76-
#define ULONGLONG unsigned LONGLONG
77-
typedef unsigned int ULONG, *PULONG;
75+
typedef int32_t HRESULT;
76+
77+
typedef int32_t LONG, *PLONG;
78+
typedef uint32_t ULONG, *PULONG;
79+
7880
#define S_OK 0x0
7981
#define SUCCEEDED(_hr) ((HRESULT)(_hr) >= 0)
8082
#define FAILED(_hr) ((HRESULT)(_hr) < 0)
8183

82-
#define CCH_BSTRMAX 0x7FFFFFFF // 4 + (0x7ffffffb + 1 ) * 2 ==> 0xFFFFFFFC
83-
#define CB_BSTRMAX 0xFFFFFFFa // 4 + (0xfffffff6 + 2) ==> 0xFFFFFFFC
84-
8584
#ifdef RC_INVOKED
8685
#define _HRESULT_TYPEDEF_(_sc) _sc
8786
#else // RC_INVOKED
8887
#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc)
8988
#endif // RC_INVOKED
9089
#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)
9190

92-
#ifdef HOST_64BIT
93-
#define __int64 long
94-
#else // HOST_64BIT
95-
#define __int64 long long
96-
#endif // HOST_64BIT
97-
98-
#define UInt32x32To64(a, b) ((unsigned __int64)((ULONG)(a)) * (unsigned __int64)((ULONG)(b)))
99-
10091
#ifndef TRUE
10192
#define TRUE 1
10293
#endif

src/tests/Interop/ArrayMarshalling/SafeArray/RecordNative.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ class BlittableRecordInfo : public IRecordInfo
5151
}
5252

5353
rgBstrNames[0] = TP_SysAllocString(W("a"));
54-
54+
5555
for(size_t i = 1; i < *pcNames; i++)
5656
{
5757
rgBstrNames[i] = nullptr;
5858
}
59-
59+
6060
return S_OK;
6161
}
6262

@@ -234,12 +234,12 @@ class NonBlittableRecordInfo : public IRecordInfo
234234
}
235235

236236
rgBstrNames[0] = TP_SysAllocString(W("b"));
237-
237+
238238
for(size_t i = 1; i < *pcNames; i++)
239239
{
240240
rgBstrNames[i] = nullptr;
241241
}
242-
242+
243243
return S_OK;
244244
}
245245

@@ -368,7 +368,7 @@ class NonBlittableRecordInfo : public IRecordInfo
368368
}
369369

370370
private:
371-
ULONG refCount;
371+
uint32_t refCount;
372372
} s_NonBlittableRecordInfo;
373373

374374
extern "C" DLL_EXPORT SAFEARRAY* STDMETHODCALLTYPE CreateSafeArrayOfRecords(BlittableRecord records[], int numRecords)

src/tests/Interop/COM/ComWrappers/MockReferenceTrackerRuntime/ReferenceTrackerRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ namespace API
3838
STDMETHOD(ReleaseDisconnectedReferenceSources)() = 0;
3939
STDMETHOD(NotifyEndOfReferenceTrackingOnThread)() = 0;
4040
STDMETHOD(GetTrackerTarget)(_In_ IUnknown* obj, _Outptr_ IReferenceTrackerTarget** ppNewReference) = 0;
41-
STDMETHOD(AddMemoryPressure)(_In_ UINT64 bytesAllocated) = 0;
42-
STDMETHOD(RemoveMemoryPressure)(_In_ UINT64 bytesAllocated) = 0;
41+
STDMETHOD(AddMemoryPressure)(_In_ uint64_t bytesAllocated) = 0;
42+
STDMETHOD(RemoveMemoryPressure)(_In_ uint64_t bytesAllocated) = 0;
4343
};
4444

4545
//3cf184b4-7ccb-4dda-8455-7e6ce99a3298

src/tests/Interop/COM/Dynamic/Server/DispatchImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ DispatchImpl::DispatchImpl(GUID guid, void *instance, const wchar_t* tlb)
2323
throw hr;
2424
}
2525

26-
HRESULT DispatchImpl::DoGetTypeInfoCount(UINT* pctinfo)
26+
HRESULT DispatchImpl::DoGetTypeInfoCount(uint32_t* pctinfo)
2727
{
2828
*pctinfo = 1;
2929
return S_OK;
3030
}
3131

32-
HRESULT DispatchImpl::DoGetTypeInfo(UINT iTInfo, ITypeInfo** ppTInfo)
32+
HRESULT DispatchImpl::DoGetTypeInfo(uint32_t iTInfo, ITypeInfo** ppTInfo)
3333
{
3434
if (iTInfo != 0)
3535
return DISP_E_BADINDEX;
@@ -38,12 +38,12 @@ HRESULT DispatchImpl::DoGetTypeInfo(UINT iTInfo, ITypeInfo** ppTInfo)
3838
return _typeInfo->QueryInterface(__uuidof(*ppTInfo), (void**)ppTInfo);
3939
}
4040

41-
HRESULT DispatchImpl::DoGetIDsOfNames(LPOLESTR* rgszNames, UINT cNames, DISPID* rgDispId)
41+
HRESULT DispatchImpl::DoGetIDsOfNames(LPOLESTR* rgszNames, uint32_t cNames, DISPID* rgDispId)
4242
{
4343
return _typeInfo->GetIDsOfNames(rgszNames, cNames, rgDispId);
4444
}
4545

46-
HRESULT DispatchImpl::DoInvoke(DISPID dispIdMember, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
46+
HRESULT DispatchImpl::DoInvoke(DISPID dispIdMember, uint16_t wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, uint32_t* puArgErr)
4747
{
4848
return _typeInfo->Invoke(_instance, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
4949
}

src/tests/Interop/COM/Dynamic/Server/DispatchImpl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class DispatchImpl : public UnknownImpl
2020
DispatchImpl& operator=(DispatchImpl&&) = default;
2121

2222
protected:
23-
HRESULT DoGetTypeInfoCount(UINT* pctinfo);
24-
HRESULT DoGetTypeInfo(UINT iTInfo, ITypeInfo** ppTInfo);
25-
HRESULT DoGetIDsOfNames(LPOLESTR* rgszNames, UINT cNames, DISPID* rgDispId);
26-
HRESULT DoInvoke(DISPID dispIdMember, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
23+
HRESULT DoGetTypeInfoCount(uint32_t* pctinfo);
24+
HRESULT DoGetTypeInfo(uint32_t iTInfo, ITypeInfo** ppTInfo);
25+
HRESULT DoGetIDsOfNames(LPOLESTR* rgszNames, uint32_t cNames, DISPID* rgDispId);
26+
HRESULT DoInvoke(DISPID dispIdMember, uint16_t wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, uint32_t* puArgErr);
2727

2828
private:
2929
ComSmartPtr<ITypeLib> _typeLib;
@@ -33,11 +33,11 @@ class DispatchImpl : public UnknownImpl
3333

3434
// Macro to use for defining dispatch impls
3535
#define DEFINE_DISPATCH() \
36-
STDMETHOD(GetTypeInfoCount)(UINT *pctinfo) \
36+
STDMETHOD(GetTypeInfoCount)(uint32_t *pctinfo) \
3737
{ return DispatchImpl::DoGetTypeInfoCount(pctinfo); } \
38-
STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) \
38+
STDMETHOD(GetTypeInfo)(uint32_t iTInfo, LCID lcid, ITypeInfo **ppTInfo) \
3939
{ return DispatchImpl::DoGetTypeInfo(iTInfo, ppTInfo); } \
40-
STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) \
40+
STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, uint32_t cNames, LCID lcid, DISPID* rgDispId) \
4141
{ return DispatchImpl::DoGetIDsOfNames(rgszNames, cNames, rgDispId); } \
42-
STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) \
42+
STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, uint16_t wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, uint32_t* puArgErr) \
4343
{ return DispatchImpl::DoInvoke(dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); }

src/tests/Interop/COM/Dynamic/Server/EventTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace
1818
HRESULT STDMETHODCALLTYPE FireEventImpl(DISPID dispId, VARIANTARG *arg)
1919
{
2020
HRESULT hr;
21-
for (UINT i = 0; i < _sinks.size(); ++i)
21+
for (uint32_t i = 0; i < _sinks.size(); ++i)
2222
{
2323
IDispatch *handler = _sinks[i];
2424
if (handler == nullptr)
@@ -65,7 +65,7 @@ namespace
6565
if (pUnkSink == nullptr || pdwCookie == nullptr)
6666
return E_POINTER;
6767

68-
for (UINT i = 0; i < _sinks.size(); ++i)
68+
for (uint32_t i = 0; i < _sinks.size(); ++i)
6969
{
7070
if (_sinks[i] != nullptr)
7171
continue;

src/tests/Interop/COM/NativeClients/Dispatch/Client.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@ void Validate_Numeric_In_ReturnByRef()
7979
lcid,
8080
&methodId));
8181

82-
BYTE b1 = 24;
83-
BYTE b2;
84-
SHORT s1 = 53;
85-
SHORT s2;
86-
USHORT us1 = 74;
87-
USHORT us2;
82+
uint8_t b1 = 24;
83+
uint8_t b2;
84+
int16_t s1 = 53;
85+
int16_t s2;
86+
uint16_t us1 = 74;
87+
uint16_t us2;
8888
LONG i1 = 34;
8989
LONG i2;
9090
ULONG ui1 = 854;
9191
ULONG ui2;
92-
LONGLONG l1 = 894;
93-
LONGLONG l2;
94-
ULONGLONG ul1 = 4168;
95-
ULONGLONG ul2;
92+
int64_t l1 = 894;
93+
int64_t l2;
94+
uint64_t ul1 = 4168;
95+
uint64_t ul2;
9696

9797
{
9898
DISPPARAMS params;
@@ -159,7 +159,7 @@ void Validate_Numeric_In_ReturnByRef()
159159
l2 = 0;
160160
ul2 = 0;
161161

162-
THROW_IF_FAILED(dispatchTesting->DoubleNumeric_ReturnByRef(b1, &b2, s1, &s2, us1, &us2, i1, (INT*)&i2, ui1, (UINT*)&ui2, l1, &l2, ul1, &ul2));
162+
THROW_IF_FAILED(dispatchTesting->DoubleNumeric_ReturnByRef(b1, &b2, s1, &s2, us1, &us2, i1, (int32_t*)&i2, ui1, (uint32_t*)&ui2, l1, &l2, ul1, &ul2));
163163

164164
THROW_FAIL_IF_FALSE(b2 == b1 * 2);
165165
THROW_FAIL_IF_FALSE(s2 == s1 * 2);

src/tests/Interop/COM/NativeClients/Events/EventTests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ namespace
104104

105105
public: // IDispatch
106106
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(
107-
/* [out] */ __RPC__out UINT* pctinfo)
107+
/* [out] */ __RPC__out uint32_t* pctinfo)
108108
{
109109
return E_NOTIMPL;
110110
}
111111

112112
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(
113-
/* [in] */ UINT iTInfo,
113+
/* [in] */ uint32_t iTInfo,
114114
/* [in] */ LCID lcid,
115115
/* [out] */ __RPC__deref_out_opt ITypeInfo** ppTInfo)
116116
{
@@ -120,7 +120,7 @@ namespace
120120
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(
121121
/* [in] */ __RPC__in REFIID riid,
122122
/* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR* rgszNames,
123-
/* [range][in] */ __RPC__in_range(0, 16384) UINT cNames,
123+
/* [range][in] */ __RPC__in_range(0, 16384) uint32_t cNames,
124124
/* [in] */ LCID lcid,
125125
/* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID* rgDispId)
126126
{
@@ -135,15 +135,15 @@ namespace
135135
/* [annotation][in] */
136136
_In_ LCID lcid,
137137
/* [annotation][in] */
138-
_In_ WORD wFlags,
138+
_In_ uint16_t wFlags,
139139
/* [annotation][out][in] */
140140
_In_ DISPPARAMS* pDispParams,
141141
/* [annotation][out] */
142142
_Out_opt_ VARIANT* pVarResult,
143143
/* [annotation][out] */
144144
_Out_opt_ EXCEPINFO* pExcepInfo,
145145
/* [annotation][out] */
146-
_Out_opt_ UINT* puArgErr)
146+
_Out_opt_ uint32_t* puArgErr)
147147
{
148148
//
149149
// Note that arguments are received in reverse order for IDispatch::Invoke()

src/tests/Interop/COM/NativeServer/ArrayTesting.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ArrayTesting : public UnknownImpl, public IArrayTesting
3838
switch (type)
3939
{
4040
case VT_UI1:
41-
*r = Mean(*l, static_cast<unsigned char*>(d->pvData));
41+
*r = Mean(*l, static_cast<uint8_t*>(d->pvData));
4242
break;
4343
case VT_I2:
4444
*r = Mean(*l, static_cast<int16_t*>(d->pvData));

0 commit comments

Comments
 (0)