was missing in xti merge
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66588 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: src/common/xti.cpp
|
// Name: src/common/xti.cpp
|
||||||
// Purpose: runtime metadata information (extended class info
|
// Purpose: runtime metadata information (extended class info)
|
||||||
// Author: Stefan Csomor
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 27/07/03
|
// Created: 27/07/03
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Enum Support
|
// wxEnumData
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxEnumData::wxEnumData( wxEnumMemberData* data )
|
wxEnumData::wxEnumData( wxEnumMemberData* data )
|
||||||
@@ -102,6 +102,7 @@ const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) const
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Type Information
|
// Type Information
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// value streaming
|
// value streaming
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -114,13 +115,13 @@ const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) const
|
|||||||
template<> void wxStringReadValue(const wxString &s, bool &data )
|
template<> void wxStringReadValue(const wxString &s, bool &data )
|
||||||
{
|
{
|
||||||
int intdata;
|
int intdata;
|
||||||
wxSscanf(s, wxT("%d"), &intdata ) ;
|
wxSscanf(s, _T("%d"), &intdata );
|
||||||
data = (bool)intdata ;
|
data = (bool)(intdata != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const bool &data )
|
template<> void wxStringWriteValue(wxString &s, const bool &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%d"), data ) ;
|
s = wxString::Format(_T("%d"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// char
|
// char
|
||||||
@@ -128,13 +129,13 @@ template<> void wxStringWriteValue(wxString &s , const bool &data )
|
|||||||
template<> void wxStringReadValue(const wxString &s, char &data )
|
template<> void wxStringReadValue(const wxString &s, char &data )
|
||||||
{
|
{
|
||||||
int intdata;
|
int intdata;
|
||||||
wxSscanf(s, wxT("%d"), &intdata ) ;
|
wxSscanf(s, _T("%d"), &intdata );
|
||||||
data = char(intdata);
|
data = char(intdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const char &data )
|
template<> void wxStringWriteValue(wxString &s, const char &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%d"), data ) ;
|
s = wxString::Format(_T("%d"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsigned char
|
// unsigned char
|
||||||
@@ -142,85 +143,85 @@ template<> void wxStringWriteValue(wxString &s , const char &data )
|
|||||||
template<> void wxStringReadValue(const wxString &s, unsigned char &data )
|
template<> void wxStringReadValue(const wxString &s, unsigned char &data )
|
||||||
{
|
{
|
||||||
int intdata;
|
int intdata;
|
||||||
wxSscanf(s, wxT("%d"), &intdata ) ;
|
wxSscanf(s, _T("%d"), &intdata );
|
||||||
data = (unsigned char)(intdata);
|
data = (unsigned char)(intdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const unsigned char &data )
|
template<> void wxStringWriteValue(wxString &s, const unsigned char &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%d"), data ) ;
|
s = wxString::Format(_T("%d"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// int
|
// int
|
||||||
|
|
||||||
template<> void wxStringReadValue(const wxString &s, int &data )
|
template<> void wxStringReadValue(const wxString &s, int &data )
|
||||||
{
|
{
|
||||||
wxSscanf(s, wxT("%d"), &data ) ;
|
wxSscanf(s, _T("%d"), &data );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const int &data )
|
template<> void wxStringWriteValue(wxString &s, const int &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%d"), data ) ;
|
s = wxString::Format(_T("%d"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsigned int
|
// unsigned int
|
||||||
|
|
||||||
template<> void wxStringReadValue(const wxString &s, unsigned int &data )
|
template<> void wxStringReadValue(const wxString &s, unsigned int &data )
|
||||||
{
|
{
|
||||||
wxSscanf(s, wxT("%d"), &data ) ;
|
wxSscanf(s, _T("%d"), &data );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const unsigned int &data )
|
template<> void wxStringWriteValue(wxString &s, const unsigned int &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%d"), data ) ;
|
s = wxString::Format(_T("%d"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// long
|
// long
|
||||||
|
|
||||||
template<> void wxStringReadValue(const wxString &s, long &data )
|
template<> void wxStringReadValue(const wxString &s, long &data )
|
||||||
{
|
{
|
||||||
wxSscanf(s, wxT("%ld"), &data ) ;
|
wxSscanf(s, _T("%ld"), &data );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const long &data )
|
template<> void wxStringWriteValue(wxString &s, const long &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%ld"), data ) ;
|
s = wxString::Format(_T("%ld"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsigned long
|
// unsigned long
|
||||||
|
|
||||||
template<> void wxStringReadValue(const wxString &s, unsigned long &data )
|
template<> void wxStringReadValue(const wxString &s, unsigned long &data )
|
||||||
{
|
{
|
||||||
wxSscanf(s, wxT("%ld"), &data ) ;
|
wxSscanf(s, _T("%ld"), &data );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const unsigned long &data )
|
template<> void wxStringWriteValue(wxString &s, const unsigned long &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%ld"), data ) ;
|
s = wxString::Format(_T("%ld"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// float
|
// float
|
||||||
|
|
||||||
template<> void wxStringReadValue(const wxString &s, float &data )
|
template<> void wxStringReadValue(const wxString &s, float &data )
|
||||||
{
|
{
|
||||||
wxSscanf(s, wxT("%f"), &data ) ;
|
wxSscanf(s, _T("%f"), &data );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const float &data )
|
template<> void wxStringWriteValue(wxString &s, const float &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%f"), data ) ;
|
s = wxString::Format(_T("%f"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// double
|
// double
|
||||||
|
|
||||||
template<> void wxStringReadValue(const wxString &s, double &data )
|
template<> void wxStringReadValue(const wxString &s, double &data )
|
||||||
{
|
{
|
||||||
wxSscanf(s, wxT("%lf"), &data ) ;
|
wxSscanf(s, _T("%lf"), &data );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void wxStringWriteValue(wxString &s, const double &data )
|
template<> void wxStringWriteValue(wxString &s, const double &data )
|
||||||
{
|
{
|
||||||
s = wxString::Format(wxT("%lf"), data ) ;
|
s = wxString::Format(_T("%lf"), data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// wxString
|
// wxString
|
||||||
@@ -235,17 +236,23 @@ template<> void wxStringWriteValue(wxString &s , const wxString &data )
|
|||||||
s = data;
|
s = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
//
|
//
|
||||||
|
|
||||||
#if wxUSE_FUNC_TEMPLATE_POINTER
|
#if wxUSE_FUNC_TEMPLATE_POINTER
|
||||||
#define wxBUILTIN_TYPE_INFO( element, type ) \
|
#define wxBUILTIN_TYPE_INFO( element, type ) \
|
||||||
wxBuiltInTypeInfo s_typeInfo##type(element , &wxToStringConverter<type> , &wxFromStringConverter<type> , typeid(type).name()) ;
|
wxBuiltInTypeInfo \
|
||||||
|
s_typeInfo##type(element, &wxToStringConverter<type>, \
|
||||||
|
&wxFromStringConverter<type>, typeid(type).name());
|
||||||
#else
|
#else
|
||||||
#define wxBUILTIN_TYPE_INFO( element, type ) \
|
#define wxBUILTIN_TYPE_INFO( element, type ) \
|
||||||
void _toString##element( const wxxVariant& data , wxString &result ) { wxToStringConverter<type>(data, result); } \
|
void _toString##element( const wxVariantBase& data, wxString &result ) \
|
||||||
void _fromString##element( const wxString& data , wxxVariant &result ) { wxFromStringConverter<type>(data, result); } \
|
{ wxToStringConverter<type, data, result); } \
|
||||||
wxBuiltInTypeInfo s_typeInfo##type(element , &_toString##element , &_fromString##element , typeid(type).name()) ;
|
void _fromString##element( const wxString& data, wxVariantBase &result ) \
|
||||||
|
{ wxFromStringConverter<type, data, result); } \
|
||||||
|
wxBuiltInTypeInfo s_typeInfo##type(element, &_toString##element, \
|
||||||
|
&_fromString##element, typeid(type).name());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned char unsigned_char;
|
typedef unsigned char unsigned_char;
|
||||||
@@ -277,7 +284,8 @@ wxILLEGAL_TYPE_SPECIALIZATION( wxString * )
|
|||||||
|
|
||||||
wxCOLLECTION_TYPE_INFO( wxString, wxArrayString );
|
wxCOLLECTION_TYPE_INFO( wxString, wxArrayString );
|
||||||
|
|
||||||
template<> void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value)
|
template<> void wxCollectionToVariantArray( wxArrayString const &theArray,
|
||||||
|
wxVariantBaseArray &value)
|
||||||
{
|
{
|
||||||
wxArrayCollectionToVariantArray( theArray, value );
|
wxArrayCollectionToVariantArray( theArray, value );
|
||||||
}
|
}
|
||||||
@@ -287,27 +295,61 @@ wxTypeInfoMap *wxTypeInfo::ms_typeTable = NULL ;
|
|||||||
wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName)
|
wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName)
|
||||||
{
|
{
|
||||||
wxTypeInfoMap::iterator iter = ms_typeTable->find(typeName);
|
wxTypeInfoMap::iterator iter = ms_typeTable->find(typeName);
|
||||||
wxASSERT_MSG( iter != ms_typeTable->end() , wxT("lookup for a non-existent type-info") ) ;
|
|
||||||
|
//wxASSERT_MSG( iter != ms_typeTable->end(),
|
||||||
|
// wxT("lookup for a non-existent type-info") );
|
||||||
|
// FM 3/6/2007 - disabled because otherwise
|
||||||
|
// wxPropertyInfo::GetCollectionElementTypeInfo
|
||||||
|
// may easily crash
|
||||||
|
if (iter == ms_typeTable->end())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return (wxTypeInfo *)iter->second;
|
return (wxTypeInfo *)iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *name) :
|
wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind, wxClassInfo* classInfo,
|
||||||
|
wxVariant2StringFnc to,
|
||||||
|
wxString2VariantFnc from,
|
||||||
|
const char *name) :
|
||||||
wxTypeInfo( kind, to, from, name)
|
wxTypeInfo( kind, to, from, name)
|
||||||
{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;}
|
{
|
||||||
|
wxASSERT_MSG( kind == wxT_OBJECT_PTR ||
|
||||||
|
kind == wxT_OBJECT,
|
||||||
|
wxT("Illegal Kind for Enum Type")); m_classInfo = classInfo;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const wxString &name) :
|
wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind, wxClassInfo* classInfo,
|
||||||
|
wxVariant2StringFnc to,
|
||||||
|
wxString2VariantFnc from,
|
||||||
|
const wxString &name) :
|
||||||
wxTypeInfo( kind, to, from, name)
|
wxTypeInfo( kind, to, from, name)
|
||||||
{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;}
|
{
|
||||||
|
wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT,
|
||||||
|
wxT("Illegal Kind for Enum Type")); m_classInfo = classInfo;
|
||||||
|
}
|
||||||
|
|
||||||
wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
|
wxEventSourceTypeInfo::wxEventSourceTypeInfo( int eventType, wxClassInfo* eventClass,
|
||||||
|
wxVariant2StringFnc to,
|
||||||
|
wxString2VariantFnc from ) :
|
||||||
wxTypeInfo ( wxT_DELEGATE, to, from, wxEmptyString )
|
wxTypeInfo ( wxT_DELEGATE, to, from, wxEmptyString )
|
||||||
{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = -1 ;}
|
{
|
||||||
|
m_eventClass = eventClass;
|
||||||
|
m_eventType = eventType;
|
||||||
|
m_lastEventType = -1;
|
||||||
|
}
|
||||||
|
|
||||||
wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , int lastEventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
|
wxEventSourceTypeInfo::wxEventSourceTypeInfo( int eventType, int lastEventType,
|
||||||
|
wxClassInfo* eventClass,
|
||||||
|
wxVariant2StringFnc to,
|
||||||
|
wxString2VariantFnc from ) :
|
||||||
wxTypeInfo ( wxT_DELEGATE, to, from, wxEmptyString )
|
wxTypeInfo ( wxT_DELEGATE, to, from, wxEmptyString )
|
||||||
{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = lastEventType; }
|
{
|
||||||
|
m_eventClass = eventClass;
|
||||||
|
m_eventType = eventType;
|
||||||
|
m_lastEventType = lastEventType;
|
||||||
|
}
|
||||||
|
|
||||||
void wxTypeInfo::Register()
|
void wxTypeInfo::Register()
|
||||||
{
|
{
|
||||||
@@ -338,10 +380,25 @@ void wxSetStringToArray( const wxString &s , wxArrayString &array )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxClassInfo
|
// wxPropertyInfo
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxPropertyInfo::~wxPropertyInfo()
|
void wxPropertyInfo::Insert(wxPropertyInfo* &iter)
|
||||||
|
{
|
||||||
|
m_next = NULL;
|
||||||
|
if ( iter == NULL )
|
||||||
|
iter = this;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxPropertyInfo* i = iter;
|
||||||
|
while( i->m_next )
|
||||||
|
i = i->m_next;
|
||||||
|
|
||||||
|
i->m_next = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPropertyInfo::Remove()
|
||||||
{
|
{
|
||||||
if ( this == m_itsClass->m_firstProperty )
|
if ( this == m_itsClass->m_firstProperty )
|
||||||
{
|
{
|
||||||
@@ -363,7 +420,26 @@ wxPropertyInfo::~wxPropertyInfo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxHandlerInfo::~wxHandlerInfo()
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxHandlerInfo
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxHandlerInfo::Insert(wxHandlerInfo* &iter)
|
||||||
|
{
|
||||||
|
m_next = NULL;
|
||||||
|
if ( iter == NULL )
|
||||||
|
iter = this;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxHandlerInfo* i = iter;
|
||||||
|
while( i->m_next )
|
||||||
|
i = i->m_next;
|
||||||
|
|
||||||
|
i->m_next = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHandlerInfo::Remove()
|
||||||
{
|
{
|
||||||
if ( this == m_itsClass->m_firstHandler )
|
if ( this == m_itsClass->m_firstHandler )
|
||||||
{
|
{
|
||||||
@@ -385,6 +461,54 @@ wxHandlerInfo::~wxHandlerInfo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxClassInfo
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxClassInfo::Create(wxObject *object, int ParamCount, wxVariantBase *Params) const
|
||||||
|
{
|
||||||
|
if ( ParamCount != m_constructorPropertiesCount )
|
||||||
|
{
|
||||||
|
// FIXME: shouldn't we just return false and let the caller handle it?
|
||||||
|
wxLogError( _("Illegal Parameter Count for Create Method") );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_constructor->Create( object, Params );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObject *wxClassInfo::ConstructObject(int ParamCount, wxVariantBase *Params) const
|
||||||
|
{
|
||||||
|
if ( ParamCount != m_constructorPropertiesCount )
|
||||||
|
{
|
||||||
|
// FIXME: shouldn't we just return NULL and let the caller handle this case?
|
||||||
|
wxLogError( _("Illegal Parameter Count for ConstructObject Method") );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObject *object = NULL;
|
||||||
|
if (!m_constructor->Create( object, Params ))
|
||||||
|
return NULL;
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClassInfo::IsKindOf(const wxClassInfo *info) const
|
||||||
|
{
|
||||||
|
if ( info != 0 )
|
||||||
|
{
|
||||||
|
if ( info == this )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for ( int i = 0; m_parents[i]; ++ i )
|
||||||
|
{
|
||||||
|
if ( m_parents[i]->IsKindOf( info ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const wxPropertyAccessor *wxClassInfo::FindAccessor(const wxChar *PropertyName) const
|
const wxPropertyAccessor *wxClassInfo::FindAccessor(const wxChar *PropertyName) const
|
||||||
{
|
{
|
||||||
const wxPropertyInfo* info = FindPropertyInfo( PropertyName );
|
const wxPropertyInfo* info = FindPropertyInfo( PropertyName );
|
||||||
@@ -470,7 +594,8 @@ wxObjectStreamingCallback wxClassInfo::GetStreamingCallback() const
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxWriter *streamer , wxPersister *persister , wxxVariantArray &metadata) const
|
bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxObjectWriter *streamer,
|
||||||
|
wxObjectReaderCallback *persister, wxVariantBaseArray &metadata) const
|
||||||
{
|
{
|
||||||
wxObjectStreamingCallback sb = GetStreamingCallback();
|
wxObjectStreamingCallback sb = GetStreamingCallback();
|
||||||
if ( sb )
|
if ( sb )
|
||||||
@@ -479,7 +604,8 @@ bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxWriter *streamer , w
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxxVariant &value) const
|
void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName,
|
||||||
|
const wxVariantBase &value) const
|
||||||
{
|
{
|
||||||
const wxPropertyAccessor *accessor;
|
const wxPropertyAccessor *accessor;
|
||||||
|
|
||||||
@@ -488,29 +614,31 @@ void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, cons
|
|||||||
accessor->SetProperty( object, value );
|
accessor->SetProperty( object, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxxVariant wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
|
wxVariantBase wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
|
||||||
{
|
{
|
||||||
const wxPropertyAccessor *accessor;
|
const wxPropertyAccessor *accessor;
|
||||||
|
|
||||||
accessor = FindAccessor(propertyName);
|
accessor = FindAccessor(propertyName);
|
||||||
wxASSERT(accessor->HasGetter());
|
wxASSERT(accessor->HasGetter());
|
||||||
wxxVariant result ;
|
wxVariantBase result;
|
||||||
accessor->GetProperty(object,result);
|
accessor->GetProperty(object,result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxxVariantArray wxClassInfo::GetPropertyCollection(wxObject *object, const wxChar *propertyName) const
|
wxVariantBaseArray wxClassInfo::GetPropertyCollection(wxObject *object,
|
||||||
|
const wxChar *propertyName) const
|
||||||
{
|
{
|
||||||
const wxPropertyAccessor *accessor;
|
const wxPropertyAccessor *accessor;
|
||||||
|
|
||||||
accessor = FindAccessor(propertyName);
|
accessor = FindAccessor(propertyName);
|
||||||
wxASSERT(accessor->HasGetter());
|
wxASSERT(accessor->HasGetter());
|
||||||
wxxVariantArray result ;
|
wxVariantBaseArray result;
|
||||||
accessor->GetPropertyCollection(object,result);
|
accessor->GetPropertyCollection(object,result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const
|
void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName,
|
||||||
|
const wxVariantBase& value) const
|
||||||
{
|
{
|
||||||
const wxPropertyAccessor *accessor;
|
const wxPropertyAccessor *accessor;
|
||||||
|
|
||||||
@@ -540,23 +668,11 @@ void wxClassInfo::GetProperties( wxPropertyInfoMap &infomap ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
VARIANT TO OBJECT
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxObject* wxxVariant::GetAsObject()
|
|
||||||
{
|
|
||||||
const wxClassTypeInfo *ti = dynamic_cast<const wxClassTypeInfo*>( m_data->GetTypeInfo() ) ;
|
|
||||||
if ( ti )
|
|
||||||
return ti->GetClassInfo()->VariantToInstance(*this) ;
|
|
||||||
else
|
|
||||||
return NULL ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDynamicObject support
|
// wxDynamicObject support
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
|
||||||
// Dynamic Objects are objects that have a real superclass instance and carry their
|
// Dynamic Objects are objects that have a real superclass instance and carry their
|
||||||
// own attributes in a hash map. Like this it is possible to create the objects and
|
// own attributes in a hash map. Like this it is possible to create the objects and
|
||||||
// stream them, as if their class information was already available from compiled data
|
// stream them, as if their class information was already available from compiled data
|
||||||
@@ -566,9 +682,9 @@ struct wxDynamicObject::wxDynamicObjectInternal
|
|||||||
wxDynamicObjectInternal() {}
|
wxDynamicObjectInternal() {}
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
map<wstring,wxxVariant> m_properties ;
|
map<wstring,wxVariantBase> m_properties;
|
||||||
#else
|
#else
|
||||||
map<string,wxxVariant> m_properties ;
|
map<string,wxVariantBase> m_properties;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -589,43 +705,52 @@ wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicCl
|
|||||||
|
|
||||||
wxDynamicObject::~wxDynamicObject()
|
wxDynamicObject::~wxDynamicObject()
|
||||||
{
|
{
|
||||||
dynamic_cast<const wxDynamicClassInfo*>(m_classInfo)->m_data->m_dynamicObjects.remove( this ) ;
|
wx_dynamic_cast(const wxDynamicClassInfo*, m_classInfo)->
|
||||||
|
m_data->m_dynamicObjects.remove( this );
|
||||||
delete m_data;
|
delete m_data;
|
||||||
delete m_superClassInstance;
|
delete m_superClassInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value)
|
void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxVariantBase &value)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
|
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),
|
||||||
|
wxT("Accessing Unknown Property in a Dynamic Object") );
|
||||||
m_data->m_properties[propertyName] = value;
|
m_data->m_properties[propertyName] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const
|
wxVariantBase wxDynamicObject::GetProperty (const wxChar *propertyName) const
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
|
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),
|
||||||
|
wxT("Accessing Unknown Property in a Dynamic Object") );
|
||||||
return m_data->m_properties[propertyName];
|
return m_data->m_properties[propertyName];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDynamicObject::RemoveProperty( const wxChar *propertyName )
|
void wxDynamicObject::RemoveProperty( const wxChar *propertyName )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Removing Unknown Property in a Dynamic Object") ) ;
|
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),
|
||||||
|
wxT("Removing Unknown Property in a Dynamic Object") );
|
||||||
m_data->m_properties.erase( propertyName );
|
m_data->m_properties.erase( propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName )
|
void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName,
|
||||||
|
const wxChar *newPropertyName )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName),wxT("Renaming Unknown Property in a Dynamic Object") ) ;
|
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName),
|
||||||
wxxVariant value = m_data->m_properties[oldPropertyName] ;
|
wxT("Renaming Unknown Property in a Dynamic Object") );
|
||||||
|
|
||||||
|
wxVariantBase value = m_data->m_properties[oldPropertyName];
|
||||||
m_data->m_properties.erase( oldPropertyName );
|
m_data->m_properties.erase( oldPropertyName );
|
||||||
m_data->m_properties[newPropertyName] = value;
|
m_data->m_properties[newPropertyName] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDynamiClassInfo
|
// wxDynamicClassInfo
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxDynamicClassInfo::wxDynamicClassInfo( const wxChar *unitName, const wxChar *className , const wxClassInfo* superClass ) :
|
wxDynamicClassInfo::wxDynamicClassInfo( const wxChar *unitName,
|
||||||
|
const wxChar *className,
|
||||||
|
const wxClassInfo* superClass ) :
|
||||||
wxClassInfo( unitName, className, new const wxClassInfo*[2])
|
wxClassInfo( unitName, className, new const wxClassInfo*[2])
|
||||||
{
|
{
|
||||||
GetParents()[0] = superClass;
|
GetParents()[0] = superClass;
|
||||||
@@ -647,11 +772,14 @@ wxObject *wxDynamicClassInfo::AllocateObject() const
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxxVariant *params) const
|
bool wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxVariantBase *params) const
|
||||||
{
|
{
|
||||||
wxDynamicObject *dynobj = dynamic_cast< wxDynamicObject *>( object ) ;
|
wxDynamicObject *dynobj = wx_dynamic_cast( wxDynamicObject *, object );
|
||||||
wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::Create on an object other than wxDynamicObject") ) ;
|
wxASSERT_MSG( dynobj,
|
||||||
GetParents()[0]->Create( dynobj->GetSuperClassInstance() , paramCount , params ) ;
|
wxT("cannot call wxDynamicClassInfo::Create on ")
|
||||||
|
wxT("an object other than wxDynamicObject") );
|
||||||
|
|
||||||
|
return GetParents()[0]->Create( dynobj->GetSuperClassInstance(), paramCount, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
// get number of parameters for constructor
|
// get number of parameters for constructor
|
||||||
@@ -666,9 +794,9 @@ const wxChar* wxDynamicClassInfo::GetCreateParamName(int i) const
|
|||||||
return GetParents()[0]->GetCreateParamName( i );
|
return GetParents()[0]->GetCreateParamName( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxxVariant &value) const
|
void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxVariantBase &value) const
|
||||||
{
|
{
|
||||||
wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
|
wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object);
|
||||||
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
||||||
if ( FindPropertyInfoInThisClass(propertyName) )
|
if ( FindPropertyInfoInThisClass(propertyName) )
|
||||||
dynobj->SetProperty( propertyName, value );
|
dynobj->SetProperty( propertyName, value );
|
||||||
@@ -676,9 +804,9 @@ void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyNam
|
|||||||
GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance(), propertyName, value );
|
GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance(), propertyName, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxxVariant wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
|
wxVariantBase wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
|
||||||
{
|
{
|
||||||
wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
|
wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object);
|
||||||
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
||||||
if ( FindPropertyInfoInThisClass(propertyName) )
|
if ( FindPropertyInfoInThisClass(propertyName) )
|
||||||
return dynobj->GetProperty( propertyName );
|
return dynobj->GetProperty( propertyName );
|
||||||
@@ -688,7 +816,7 @@ wxxVariant wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *prope
|
|||||||
|
|
||||||
void wxDynamicClassInfo::AddProperty( const wxChar *propertyName, const wxTypeInfo* typeInfo )
|
void wxDynamicClassInfo::AddProperty( const wxChar *propertyName, const wxTypeInfo* typeInfo )
|
||||||
{
|
{
|
||||||
new wxPropertyInfo( m_firstProperty , this , propertyName , typeInfo->GetTypeName() , new wxGenericPropertyAccessor( propertyName ) , wxxVariant() ) ;
|
new wxPropertyInfo( m_firstProperty, this, propertyName, typeInfo->GetTypeName(), new wxGenericPropertyAccessor( propertyName ), wxVariantBase() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDynamicClassInfo::AddHandler( const wxChar *handlerName, wxObjectEventFunction address, const wxClassInfo* eventClassInfo )
|
void wxDynamicClassInfo::AddHandler( const wxChar *handlerName, wxObjectEventFunction address, const wxClassInfo* eventClassInfo )
|
||||||
@@ -716,7 +844,7 @@ void wxDynamicClassInfo::RenameProperty( const wxChar *oldPropertyName , const w
|
|||||||
wxPropertyInfo* pi = FindPropertyInfoInThisClass(oldPropertyName);
|
wxPropertyInfo* pi = FindPropertyInfoInThisClass(oldPropertyName);
|
||||||
wxASSERT_MSG( pi,wxT("not existing property") );
|
wxASSERT_MSG( pi,wxT("not existing property") );
|
||||||
pi->m_name = newPropertyName;
|
pi->m_name = newPropertyName;
|
||||||
dynamic_cast<wxGenericPropertyAccessor*>(pi->GetAccessor())->RenameProperty( oldPropertyName , newPropertyName ) ;
|
wx_dynamic_cast(wxGenericPropertyAccessor*, pi->GetAccessor())->RenameProperty( oldPropertyName, newPropertyName );
|
||||||
for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin(); iter != m_data->m_dynamicObjects.end(); ++iter )
|
for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin(); iter != m_data->m_dynamicObjects.end(); ++iter )
|
||||||
(*iter)->RenameProperty( oldPropertyName, newPropertyName );
|
(*iter)->RenameProperty( oldPropertyName, newPropertyName );
|
||||||
}
|
}
|
||||||
@@ -750,16 +878,17 @@ wxGenericPropertyAccessor::~wxGenericPropertyAccessor()
|
|||||||
{
|
{
|
||||||
delete m_data;
|
delete m_data;
|
||||||
}
|
}
|
||||||
void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxxVariant &value) const
|
|
||||||
|
void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxVariantBase &value) const
|
||||||
{
|
{
|
||||||
wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
|
wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object);
|
||||||
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
||||||
dynobj->SetProperty(m_propertyName, value );
|
dynobj->SetProperty(m_propertyName, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxxVariant& value) const
|
void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxVariantBase& value) const
|
||||||
{
|
{
|
||||||
const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject * >( object ) ;
|
const wxDynamicObject* dynobj = wx_dynamic_cast( const wxDynamicObject * , object );
|
||||||
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
|
||||||
value = dynobj->GetProperty( m_propertyName );
|
value = dynobj->GetProperty( m_propertyName );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user