Removed wxClearVariant() and wxReleaseVariant().

Replaced them with standard VariantInit() and VariantClear() functions
respectively. They appear to be just reimplementations of these.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2010-01-03 18:29:02 +00:00
parent a2fd865b0d
commit 1fbfbfb0bf
2 changed files with 5 additions and 101 deletions

View File

@ -54,8 +54,6 @@
#include "wx/datetime.h"
#endif // wxUSE_DATETIME
extern void wxClearVariant(VARIANTARG *pvarg) ;
extern void wxReleaseVariant(VARIANTARG *pvarg) ;
// static void ShowException(LPOLESTR szMember, HRESULT hr, EXCEPINFO *pexcep, unsigned int uiArgErr);
#if wxUSE_OLE_AUTOMATION
@ -103,7 +101,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
}
VARIANTARG vReturn;
wxClearVariant(& vReturn);
VariantInit(& vReturn);
VARIANTARG* vReturnPtr = & vReturn;
@ -194,7 +192,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
delete[] dispIds;
for (i = 0; i < noArgs; i++)
wxReleaseVariant(& oleArgs[i]) ;
VariantClear(& oleArgs[i]) ;
delete[] oleArgs;
if (FAILED(hr))
@ -208,7 +206,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
SysFreeString(excep.bstrHelpFile);
if (vReturnPtr)
wxReleaseVariant(vReturnPtr);
VariantClear(vReturnPtr);
return false;
}
else
@ -222,7 +220,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
{
vReturn.pdispVal = NULL;
}
wxReleaseVariant(& vReturn);
VariantClear(& vReturn);
}
}
return true;

View File

@ -131,103 +131,9 @@ wxBasicString::~wxBasicString()
#if wxUSE_VARIANT
/*
* wxClearVariant
*
* Zeros a variant structure without regard to current contents
*/
void wxClearVariant(VARIANTARG *pvarg)
{
pvarg->vt = VT_EMPTY;
pvarg->wReserved1 = 0;
pvarg->wReserved2 = 0;
pvarg->wReserved3 = 0;
pvarg->lVal = 0;
}
/*
* wxReleaseVariant
*
* Clears a particular variant structure and releases any external objects
* or memory contained in the variant. Supports the data types listed above.
*/
void wxReleaseVariant(VARIANTARG *pvarg)
{
VARTYPE vt;
VARIANTARG _huge *pvargArray;
LONG lLBound, lUBound, l;
vt = (VARTYPE)(pvarg->vt & 0xfff); // mask off flags
// check if an array. If so, free its contents, then the array itself.
if (V_ISARRAY(pvarg))
{
// variant arrays are all this routine currently knows about. Since a
// variant can contain anything (even other arrays), call ourselves
// recursively.
if (vt == VT_VARIANT)
{
SafeArrayGetLBound(pvarg->parray, 1, &lLBound);
SafeArrayGetUBound(pvarg->parray, 1, &lUBound);
if (lUBound > lLBound)
{
lUBound -= lLBound;
SafeArrayAccessData(pvarg->parray, (void**)&pvargArray);
for (l = 0; l < lUBound; l++)
{
wxReleaseVariant(pvargArray);
pvargArray++;
}
SafeArrayUnaccessData(pvarg->parray);
}
}
else
{
wxLogWarning(wxT("wxReleaseVariant: Array contains non-variant type"));
}
// Free the array itself.
SafeArrayDestroy(pvarg->parray);
}
else
{
switch (vt)
{
case VT_DISPATCH:
if (pvarg->pdispVal)
pvarg->pdispVal->Release();
break;
case VT_BSTR:
SysFreeString(pvarg->bstrVal);
break;
case VT_I2:
case VT_I4:
case VT_BOOL:
case VT_R8:
case VT_ERROR: // to avoid erroring on an error return from Excel
case VT_EMPTY:
case VT_DATE:
// no work for these types
break;
default:
wxLogWarning(wxT("wxReleaseVariant: Unknown type"));
break;
}
}
wxClearVariant(pvarg);
}
WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
{
wxClearVariant(&oleVariant);
VariantInit(&oleVariant);
if (variant.IsNull())
{
oleVariant.vt = VT_NULL;