Fix wxAny for VC6 by removing 'wxAny& operator=(const wxVariant &variant)' for it. This will break some cases of implicit wxVariant->wxAny conversion (for VC6).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64022 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -772,7 +772,18 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_VARIANT
|
#if wxUSE_VARIANT && (!defined(__VISUALC__) || __VISUALC__ >= 1300)
|
||||||
|
//
|
||||||
|
// Adding this operator for VC6 breaks wxAny, and also
|
||||||
|
// some cases of implicit conversion from wxVariant to wxAny.
|
||||||
|
//
|
||||||
|
// e.g. wxAny any = variant; // should work
|
||||||
|
//
|
||||||
|
// wxAny any;
|
||||||
|
// any = 16;
|
||||||
|
// any = variant; // probably doesn't work - uses template
|
||||||
|
// // assignment, most likely
|
||||||
|
//
|
||||||
wxAny& operator=(const wxVariant &variant)
|
wxAny& operator=(const wxVariant &variant)
|
||||||
{
|
{
|
||||||
AssignVariant(variant);
|
AssignVariant(variant);
|
||||||
|
@@ -201,7 +201,13 @@ bool wxConvertAnyToVariant(const wxAny& any, wxVariant* variant)
|
|||||||
{
|
{
|
||||||
// Check if wxAny wrapped wxVariantData*
|
// Check if wxAny wrapped wxVariantData*
|
||||||
if ( !any.GetAs(&data) )
|
if ( !any.GetAs(&data) )
|
||||||
|
{
|
||||||
|
// Ok, one last chance: while unlikely, it is possible that the
|
||||||
|
// wxAny actually contains wxVariant.
|
||||||
|
if ( wxANY_CHECK_TYPE(any, wxVariant) )
|
||||||
|
*variant = wxANY_AS(any, wxVariant);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Wrapper's GetValue() does not increase reference
|
// Wrapper's GetValue() does not increase reference
|
||||||
// count, se have to do it before the data gets passed
|
// count, se have to do it before the data gets passed
|
||||||
|
@@ -225,11 +225,10 @@ wxVariant::wxVariant(const wxAny& any)
|
|||||||
|
|
||||||
wxAny wxVariant::GetAny() const
|
wxAny wxVariant::GetAny() const
|
||||||
{
|
{
|
||||||
wxAny any;
|
|
||||||
|
|
||||||
if ( IsNull() )
|
if ( IsNull() )
|
||||||
return any;
|
return wxAny();
|
||||||
|
|
||||||
|
wxAny any;
|
||||||
wxVariantData* data = GetData();
|
wxVariantData* data = GetData();
|
||||||
|
|
||||||
if ( data->GetAsAny(&any) )
|
if ( data->GetAsAny(&any) )
|
||||||
|
@@ -482,13 +482,16 @@ void wxAnyTestCase::wxVariantConversions()
|
|||||||
CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
|
CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
|
||||||
CPPUNIT_ASSERT(variant.GetLong() == 1000);
|
CPPUNIT_ASSERT(variant.GetLong() == 1000);
|
||||||
|
|
||||||
any = vString;
|
// FIXME-VC6: for VC6, any = variant needs to be any = wxAny(variant).
|
||||||
|
// Note that 'wxAny any = variant' does work, probably because
|
||||||
|
// ctor is used in that case instead of assignment operator.
|
||||||
|
any = wxAny(vString);
|
||||||
CPPUNIT_ASSERT(any == "ABC");
|
CPPUNIT_ASSERT(any == "ABC");
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
CPPUNIT_ASSERT(variant.GetString() == "ABC");
|
CPPUNIT_ASSERT(variant.GetString() == "ABC");
|
||||||
|
|
||||||
any = vDouble;
|
any = wxAny(vDouble);
|
||||||
double d = wxANY_AS(any, double);
|
double d = wxANY_AS(any, double);
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(d, TEST_FLOAT_CONST, FEQ_DELTA);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(d, TEST_FLOAT_CONST, FEQ_DELTA);
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
@@ -497,27 +500,27 @@ void wxAnyTestCase::wxVariantConversions()
|
|||||||
TEST_FLOAT_CONST,
|
TEST_FLOAT_CONST,
|
||||||
FEQ_DELTA);
|
FEQ_DELTA);
|
||||||
|
|
||||||
any = vBool;
|
any = wxAny(vBool);
|
||||||
CPPUNIT_ASSERT(wxANY_AS(any, bool) == true);
|
CPPUNIT_ASSERT(wxANY_AS(any, bool) == true);
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
CPPUNIT_ASSERT(variant.GetBool() == true);
|
CPPUNIT_ASSERT(variant.GetBool() == true);
|
||||||
|
|
||||||
any = vChar;
|
any = wxAny(vChar);
|
||||||
//CPPUNIT_ASSERT(wxANY_AS(any, wxUniChar) == 'A');
|
//CPPUNIT_ASSERT(wxANY_AS(any, wxUniChar) == 'A');
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
CPPUNIT_ASSERT(variant.GetChar() == 'A');
|
CPPUNIT_ASSERT(variant.GetChar() == 'A');
|
||||||
|
|
||||||
#ifdef wxLongLong_t
|
#ifdef wxLongLong_t
|
||||||
any = vLongLong;
|
any = wxAny(vLongLong);
|
||||||
CPPUNIT_ASSERT(any == wxLL(0xFFFFFFFFFF));
|
CPPUNIT_ASSERT(any == wxLL(0xFFFFFFFFFF));
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
CPPUNIT_ASSERT(variant.GetLongLong() == wxLongLong(wxLL(0xFFFFFFFFFF)));
|
CPPUNIT_ASSERT(variant.GetLongLong() == wxLongLong(wxLL(0xFFFFFFFFFF)));
|
||||||
CPPUNIT_ASSERT(variant.GetType() == "longlong");
|
CPPUNIT_ASSERT(variant.GetType() == "longlong");
|
||||||
|
|
||||||
any = vULongLong;
|
any = wxAny(vULongLong);
|
||||||
CPPUNIT_ASSERT(any == wxLL(123456));
|
CPPUNIT_ASSERT(any == wxLL(123456));
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
@@ -526,7 +529,7 @@ void wxAnyTestCase::wxVariantConversions()
|
|||||||
|
|
||||||
// Cannot test equality for the rest, just test that they convert
|
// Cannot test equality for the rest, just test that they convert
|
||||||
// back correctly.
|
// back correctly.
|
||||||
any = vArrayString;
|
any = wxAny(vArrayString);
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
wxArrayString arrstr2 = variant.GetArrayString();
|
wxArrayString arrstr2 = variant.GetArrayString();
|
||||||
@@ -534,18 +537,18 @@ void wxAnyTestCase::wxVariantConversions()
|
|||||||
|
|
||||||
any = m_testDateTime;
|
any = m_testDateTime;
|
||||||
CPPUNIT_ASSERT(wxANY_AS(any, wxDateTime) == m_testDateTime);
|
CPPUNIT_ASSERT(wxANY_AS(any, wxDateTime) == m_testDateTime);
|
||||||
any = vDateTime;
|
any = wxAny(vDateTime);
|
||||||
CPPUNIT_ASSERT(wxANY_AS(any, wxDateTime) == m_testDateTime);
|
CPPUNIT_ASSERT(wxANY_AS(any, wxDateTime) == m_testDateTime);
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
CPPUNIT_ASSERT(variant == m_testDateTime);
|
CPPUNIT_ASSERT(variant == m_testDateTime);
|
||||||
|
|
||||||
any = vVoidPtr;
|
any = wxAny(vVoidPtr);
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
CPPUNIT_ASSERT(variant.GetVoidPtr() == dummyVoidPointer);
|
CPPUNIT_ASSERT(variant.GetVoidPtr() == dummyVoidPointer);
|
||||||
|
|
||||||
any = vList;
|
any = wxAny(vList);
|
||||||
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxAnyList));
|
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxAnyList));
|
||||||
wxAnyList anyList = wxANY_AS(any, wxAnyList);
|
wxAnyList anyList = wxANY_AS(any, wxAnyList);
|
||||||
CPPUNIT_ASSERT(anyList.GetCount() == 2);
|
CPPUNIT_ASSERT(anyList.GetCount() == 2);
|
||||||
@@ -558,7 +561,7 @@ void wxAnyTestCase::wxVariantConversions()
|
|||||||
CPPUNIT_ASSERT(variant[0].GetLong() == 15);
|
CPPUNIT_ASSERT(variant[0].GetLong() == 15);
|
||||||
CPPUNIT_ASSERT(variant[1].GetString() == "abc");
|
CPPUNIT_ASSERT(variant[1].GetString() == "abc");
|
||||||
|
|
||||||
any = vCustomType;
|
any = wxAny(vCustomType);
|
||||||
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxVariantData*));
|
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxVariantData*));
|
||||||
res = any.GetAs(&variant);
|
res = any.GetAs(&variant);
|
||||||
CPPUNIT_ASSERT(res);
|
CPPUNIT_ASSERT(res);
|
||||||
|
Reference in New Issue
Block a user