Add wx headers and ext
This commit is contained in:
parent
6390dcef6a
commit
66d3c7b811
1531 changed files with 295895 additions and 0 deletions
60
wxheaders/wx/meta/convertible.h
Normal file
60
wxheaders/wx/meta/convertible.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/convertible.h
|
||||
// Purpose: Test if types are convertible
|
||||
// Author: Arne Steinarson
|
||||
// Created: 2008-01-10
|
||||
// Copyright: (c) 2008 Arne Steinarson
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_CONVERTIBLE_H_
|
||||
#define _WX_META_CONVERTIBLE_H_
|
||||
|
||||
//
|
||||
// Introduce an extra class to make this header compilable with g++3.2
|
||||
//
|
||||
template <class D, class B>
|
||||
struct wxConvertibleTo_SizeHelper
|
||||
{
|
||||
static char Match(B* pb);
|
||||
static int Match(...);
|
||||
};
|
||||
|
||||
// Helper to decide if an object of type D is convertible to type B (the test
|
||||
// succeeds in particular when D derives from B)
|
||||
template <class D, class B>
|
||||
struct wxConvertibleTo
|
||||
{
|
||||
enum
|
||||
{
|
||||
value =
|
||||
sizeof(wxConvertibleTo_SizeHelper<D,B>::Match(static_cast<D*>(NULL)))
|
||||
==
|
||||
sizeof(char)
|
||||
};
|
||||
};
|
||||
|
||||
// This is similar to wxConvertibleTo, except that when using a C++11 compiler,
|
||||
// the case of D deriving from B non-publicly will be detected and the correct
|
||||
// value (false) will be deduced instead of getting a compile-time error as
|
||||
// with wxConvertibleTo. For pre-C++11 compilers there is no difference between
|
||||
// this helper and wxConvertibleTo.
|
||||
template <class D, class B>
|
||||
struct wxIsPubliclyDerived
|
||||
{
|
||||
enum
|
||||
{
|
||||
#if __cplusplus >= 201103 || (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
// If C++11 is available we use this, as on most compilers it's a
|
||||
// built-in and will be evaluated at compile-time.
|
||||
value = std::is_base_of<B, D>::value && std::is_convertible<D*, B*>::value
|
||||
#else
|
||||
// When not using C++11, we fall back to wxConvertibleTo, which fails
|
||||
// at compile-time if D doesn't publicly derive from B.
|
||||
value = wxConvertibleTo<D, B>::value
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
#endif // _WX_META_CONVERTIBLE_H_
|
||||
|
||||
56
wxheaders/wx/meta/if.h
Normal file
56
wxheaders/wx/meta/if.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/if.h
|
||||
// Purpose: declares wxIf<> metaprogramming construct
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2008-01-22
|
||||
// Copyright: (c) 2008 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_IF_H_
|
||||
#define _WX_META_IF_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
namespace wxPrivate
|
||||
{
|
||||
|
||||
template <bool Cond>
|
||||
struct wxIfImpl;
|
||||
|
||||
// specialization for true:
|
||||
template <>
|
||||
struct wxIfImpl<true>
|
||||
{
|
||||
template<typename TTrue, typename TFalse> struct Result
|
||||
{
|
||||
typedef TTrue value;
|
||||
};
|
||||
};
|
||||
|
||||
// specialization for false:
|
||||
template<>
|
||||
struct wxIfImpl<false>
|
||||
{
|
||||
template<typename TTrue, typename TFalse> struct Result
|
||||
{
|
||||
typedef TFalse value;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace wxPrivate
|
||||
|
||||
// wxIf<> template defines nested type "value" which is the same as
|
||||
// TTrue if the condition Cond (boolean compile-time constant) was met and
|
||||
// TFalse if it wasn't.
|
||||
//
|
||||
// See wxVector<T> in vector.h for usage example
|
||||
template<bool Cond, typename TTrue, typename TFalse>
|
||||
struct wxIf
|
||||
{
|
||||
typedef typename wxPrivate::wxIfImpl<Cond>
|
||||
::template Result<TTrue, TFalse>::value
|
||||
value;
|
||||
};
|
||||
|
||||
#endif // _WX_META_IF_H_
|
||||
102
wxheaders/wx/meta/implicitconversion.h
Normal file
102
wxheaders/wx/meta/implicitconversion.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/implicitconversion.h
|
||||
// Purpose: Determine resulting type from implicit conversion
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2010-10-22
|
||||
// Copyright: (c) 2010 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_IMPLICITCONVERSION_H_
|
||||
#define _WX_META_IMPLICITCONVERSION_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/meta/if.h"
|
||||
|
||||
// C++ hierarchy of data types is:
|
||||
//
|
||||
// Long double (highest)
|
||||
// Double
|
||||
// Float
|
||||
// Unsigned long int
|
||||
// Long int
|
||||
// Unsigned int
|
||||
// Int (lowest)
|
||||
//
|
||||
// Types lower in the hierarchy are converted into ones higher up if both are
|
||||
// involved e.g. in arithmetic expressions.
|
||||
|
||||
namespace wxPrivate
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct TypeHierarchy
|
||||
{
|
||||
// consider unknown types (e.g. objects, pointers) to be of highest
|
||||
// level, always convert to them if they occur
|
||||
static const int level = 9999;
|
||||
};
|
||||
|
||||
#define WX_TYPE_HIERARCHY_LEVEL(level_num, type) \
|
||||
template<> struct TypeHierarchy<type> \
|
||||
{ \
|
||||
static const int level = level_num; \
|
||||
}
|
||||
|
||||
WX_TYPE_HIERARCHY_LEVEL( 1, char);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 2, unsigned char);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 3, short);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 4, unsigned short);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 5, int);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 6, unsigned int);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 7, long);
|
||||
WX_TYPE_HIERARCHY_LEVEL( 8, unsigned long);
|
||||
#ifdef wxLongLong_t
|
||||
WX_TYPE_HIERARCHY_LEVEL( 9, wxLongLong_t);
|
||||
WX_TYPE_HIERARCHY_LEVEL(10, wxULongLong_t);
|
||||
#endif
|
||||
WX_TYPE_HIERARCHY_LEVEL(11, float);
|
||||
WX_TYPE_HIERARCHY_LEVEL(12, double);
|
||||
WX_TYPE_HIERARCHY_LEVEL(13, long double);
|
||||
|
||||
#if wxWCHAR_T_IS_REAL_TYPE
|
||||
#if SIZEOF_WCHAR_T == SIZEOF_SHORT
|
||||
template<> struct TypeHierarchy<wchar_t> : public TypeHierarchy<short> {};
|
||||
#elif SIZEOF_WCHAR_T == SIZEOF_INT
|
||||
template<> struct TypeHierarchy<wchar_t> : public TypeHierarchy<int> {};
|
||||
#elif SIZEOF_WCHAR_T == SIZEOF_LONG
|
||||
template<> struct TypeHierarchy<wchar_t> : public TypeHierarchy<long> {};
|
||||
#else
|
||||
#error "weird wchar_t size, please update this code"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef WX_TYPE_HIERARCHY_LEVEL
|
||||
|
||||
} // namespace wxPrivate
|
||||
|
||||
// Helper to determine resulting type of implicit conversion in
|
||||
// an expression with two arithmetic types.
|
||||
template<typename T1, typename T2>
|
||||
struct wxImplicitConversionType
|
||||
{
|
||||
typedef typename wxIf
|
||||
<
|
||||
// if T2 is "higher" type, convert to it
|
||||
(int)(wxPrivate::TypeHierarchy<T1>::level) < (int)(wxPrivate::TypeHierarchy<T2>::level),
|
||||
T2,
|
||||
// otherwise use T1
|
||||
T1
|
||||
>::value
|
||||
value;
|
||||
};
|
||||
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
struct wxImplicitConversionType3 : public wxImplicitConversionType<
|
||||
T1,
|
||||
typename wxImplicitConversionType<T2,T3>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // _WX_META_IMPLICITCONVERSION_H_
|
||||
16
wxheaders/wx/meta/int2type.h
Normal file
16
wxheaders/wx/meta/int2type.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/int2type.h
|
||||
// Purpose: Generate a unique type from a constant integer
|
||||
// Author: Arne Steinarson
|
||||
// Created: 2008-01-10
|
||||
// Copyright: (c) 2008 Arne Steinarson
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_INT2TYPE_H_
|
||||
#define _WX_META_INT2TYPE_H_
|
||||
|
||||
template <int N>
|
||||
struct wxInt2Type { enum { value=N }; };
|
||||
|
||||
#endif // _WX_META_INT2TYPE_H_
|
||||
44
wxheaders/wx/meta/movable.h
Normal file
44
wxheaders/wx/meta/movable.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/movable.h
|
||||
// Purpose: Test if a type is movable using memmove() etc.
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2008-01-21
|
||||
// Copyright: (c) 2008 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_MOVABLE_H_
|
||||
#define _WX_META_MOVABLE_H_
|
||||
|
||||
#include "wx/meta/pod.h"
|
||||
#include "wx/string.h" // for wxIsMovable<wxString> specialization
|
||||
|
||||
// Helper to decide if an object of type T is "movable", i.e. if it can be
|
||||
// copied to another memory location using memmove() or realloc() C functions.
|
||||
// C++ only guarantees that POD types (including primitive types) are
|
||||
// movable.
|
||||
template<typename T>
|
||||
struct wxIsMovable
|
||||
{
|
||||
static const bool value = wxIsPod<T>::value;
|
||||
};
|
||||
|
||||
// Macro to add wxIsMovable<T> specialization for given type that marks it
|
||||
// as movable:
|
||||
#define WX_DECLARE_TYPE_MOVABLE(type) \
|
||||
template<> struct wxIsMovable<type> \
|
||||
{ \
|
||||
static const bool value = true; \
|
||||
};
|
||||
|
||||
// Our implementation of wxString is written in such way that it's safe to move
|
||||
// it around (unless position cache is used which unfortunately breaks this).
|
||||
// OTOH, we don't know anything about std::string.
|
||||
// (NB: we don't put this into string.h and choose to include wx/string.h from
|
||||
// here instead so that rarely-used wxIsMovable<T> code isn't included by
|
||||
// everything)
|
||||
#if !wxUSE_STD_STRING && !wxUSE_STRING_POS_CACHE
|
||||
WX_DECLARE_TYPE_MOVABLE(wxString)
|
||||
#endif
|
||||
|
||||
#endif // _WX_META_MOVABLE_H_
|
||||
69
wxheaders/wx/meta/pod.h
Normal file
69
wxheaders/wx/meta/pod.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/pod.h
|
||||
// Purpose: Test if a type is POD
|
||||
// Author: Vaclav Slavik, Jaakko Salli
|
||||
// Created: 2010-06-14
|
||||
// Copyright: (c) wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_POD_H_
|
||||
#define _WX_META_POD_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
//
|
||||
// TODO: Use TR1 is_pod<> implementation where available. VC9 SP1 has it
|
||||
// in tr1 namespace, VC10 has it in std namespace. GCC 4.2 has it in
|
||||
// <tr1/type_traits>, while GCC 4.3 and later have it in <type_traits>.
|
||||
//
|
||||
|
||||
// Helper to decide if an object of type T is POD (Plain Old Data)
|
||||
template<typename T>
|
||||
struct wxIsPod
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
// Macro to add wxIsPod<T> specialization for given type that marks it
|
||||
// as Plain Old Data:
|
||||
#define WX_DECLARE_TYPE_POD(type) \
|
||||
template<> struct wxIsPod<type> \
|
||||
{ \
|
||||
static const bool value = true; \
|
||||
};
|
||||
|
||||
WX_DECLARE_TYPE_POD(bool)
|
||||
WX_DECLARE_TYPE_POD(unsigned char)
|
||||
WX_DECLARE_TYPE_POD(signed char)
|
||||
WX_DECLARE_TYPE_POD(unsigned int)
|
||||
WX_DECLARE_TYPE_POD(signed int)
|
||||
WX_DECLARE_TYPE_POD(unsigned short int)
|
||||
WX_DECLARE_TYPE_POD(signed short int)
|
||||
WX_DECLARE_TYPE_POD(signed long int)
|
||||
WX_DECLARE_TYPE_POD(unsigned long int)
|
||||
WX_DECLARE_TYPE_POD(float)
|
||||
WX_DECLARE_TYPE_POD(double)
|
||||
WX_DECLARE_TYPE_POD(long double)
|
||||
#if wxWCHAR_T_IS_REAL_TYPE
|
||||
WX_DECLARE_TYPE_POD(wchar_t)
|
||||
#endif
|
||||
#ifdef wxLongLong_t
|
||||
WX_DECLARE_TYPE_POD(wxLongLong_t)
|
||||
WX_DECLARE_TYPE_POD(wxULongLong_t)
|
||||
#endif
|
||||
|
||||
// pointers are Plain Old Data:
|
||||
template<typename T>
|
||||
struct wxIsPod<T*>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct wxIsPod<const T*>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#endif // _WX_META_POD_H_
|
||||
33
wxheaders/wx/meta/removeref.h
Normal file
33
wxheaders/wx/meta/removeref.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/meta/removeref.h
|
||||
// Purpose: Allows to remove a reference from a type.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2012-10-21
|
||||
// Copyright: (c) 2012 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_META_REMOVEREF_H_
|
||||
#define _WX_META_REMOVEREF_H_
|
||||
|
||||
// wxRemoveRef<> is similar to C++11 std::remove_reference<> but works with all
|
||||
// compilers (but, to compensate for this, doesn't work with rvalue references).
|
||||
|
||||
template <typename T>
|
||||
struct wxRemoveRef
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct wxRemoveRef<T&>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// Define this for compatibility with the previous versions in which
|
||||
// wxRemoveRef() wasn't always defined as we supported MSVC6 for which it
|
||||
// couldn't be implemented.
|
||||
#define wxHAS_REMOVEREF
|
||||
|
||||
#endif // _WX_META_REMOVEREF_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue