first commit
This commit is contained in:
21
inc/hgl/platform/compiler/DataTypeGNU.h
Normal file
21
inc/hgl/platform/compiler/DataTypeGNU.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef HGL_DATATYPE_GNU_INCLUDE
|
||||
#define HGL_DATATYPE_GNU_INCLUDE
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
using int8 = signed char; ///<有符号 8位整型
|
||||
using uint8 =unsigned char; ///<无符号 8位整型
|
||||
using int16 = signed short; ///<有符号16位整型
|
||||
using uint16 =unsigned short; ///<无符号16位整型
|
||||
using int32 = signed int; ///<有符号32位整型
|
||||
using uint32 =unsigned int; ///<无符号32位整型
|
||||
|
||||
//64位系统下long/long long都是64位,32位系列下只有long long是64位
|
||||
|
||||
using int64 = signed long long; ///<有符号64位整型
|
||||
using uint64 =unsigned long long; ///<无符号64位整型
|
||||
|
||||
using float32 =float;
|
||||
using float64 =double;
|
||||
}//namespace hgl
|
||||
#endif//HGL_DATATYPE_GNU_INCLUDE
|
29
inc/hgl/platform/compiler/DataTypeTiny.h
Normal file
29
inc/hgl/platform/compiler/DataTypeTiny.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef HGL_DATA_TYPE_TINY_INCLUDE
|
||||
#define HGL_DATA_TYPE_TINY_INCLUDE
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
using i8=int8;
|
||||
using i16=int16;
|
||||
using i32=int32;
|
||||
using i64=int64;
|
||||
|
||||
using u8=uint8;
|
||||
using u16=uint16;
|
||||
using u32=uint32;
|
||||
using u64=uint64;
|
||||
|
||||
using f32=float;
|
||||
using f64=double;
|
||||
|
||||
#define enum_int(name) enum name:int
|
||||
#define enum_uint(name) enum name:uint
|
||||
|
||||
using void_pointer=void *;
|
||||
|
||||
using uchar = unsigned char; ///< 无符号字符型
|
||||
using ushort = unsigned short; ///< 无符号短整型
|
||||
using uint = unsigned int; ///< 无符号整型
|
||||
using ulong = unsigned long; ///< 无符号长整型
|
||||
}//namespace hgl
|
||||
#endif//HGL_DATA_TYPE_TINY_INCLUDE
|
17
inc/hgl/platform/compiler/DataTypeWin.h
Normal file
17
inc/hgl/platform/compiler/DataTypeWin.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef HGL_DATATYPE_WINDOWS_INCLUDE
|
||||
#define HGL_DATATYPE_WINDOWS_INCLUDE
|
||||
namespace hgl
|
||||
{
|
||||
using int8 = signed __int8 ; ///<有符号 8位整型
|
||||
using uint8 =unsigned __int8 ; ///<无符号 8位整型
|
||||
using int16 = signed __int16; ///<有符号16位整型
|
||||
using uint16 =unsigned __int16; ///<无符号16位整型
|
||||
using int32 = signed __int32; ///<有符号32位整型
|
||||
using uint32 =unsigned __int32; ///<无符号32位整型
|
||||
using int64 = signed __int64; ///<有符号64位整型
|
||||
using uint64 =unsigned __int64; ///<无符号64位整型
|
||||
|
||||
using float32 =float;
|
||||
using float64 =double;
|
||||
}//namespace hgl
|
||||
#endif//HGL_DATATYPE_WINDOWS_INCLUDE
|
250
inc/hgl/platform/compiler/EventFunc.h
Normal file
250
inc/hgl/platform/compiler/EventFunc.h
Normal file
@@ -0,0 +1,250 @@
|
||||
#ifndef HGL_EVENT_FUNC_INCLUDE
|
||||
#define HGL_EVENT_FUNC_INCLUDE
|
||||
|
||||
#include<hgl/type/_Object.h>
|
||||
#include<string.h>
|
||||
namespace hgl
|
||||
{
|
||||
#ifdef __BORLANDC__
|
||||
|
||||
#define SetEventCall(event_obj,obj_this,class_name,event_func) event_obj=obj_this->class_name::event_func
|
||||
#define SafeCallEvent(event_obj,intro) {if(event_obj)event_obj intro;}
|
||||
#define CallEvent(event_obj,intro) event_obj intro
|
||||
#define DefEvent(result,name,intro) result (__closure *name)intro
|
||||
|
||||
#else
|
||||
|
||||
template <typename RT,typename Func> struct EventFunc
|
||||
{
|
||||
typedef EventFunc<RT,Func> SelfClass;
|
||||
|
||||
union
|
||||
{
|
||||
void *vp_this;
|
||||
_Object *this_pointer;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
void *vp_func;
|
||||
Func func_pointer;
|
||||
ObjectMemberFunc omf;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
EventFunc()
|
||||
{
|
||||
ClearFunc();
|
||||
}
|
||||
|
||||
EventFunc(void *t,void *f)
|
||||
{
|
||||
ClearFunc();
|
||||
|
||||
vp_this=t;
|
||||
vp_func=f;
|
||||
}
|
||||
|
||||
void ClearFunc()
|
||||
{
|
||||
memset(this,0,sizeof(SelfClass));
|
||||
}
|
||||
|
||||
bool operator !()const
|
||||
{
|
||||
if(!vp_func)return(true);
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
void operator = (void *v)
|
||||
{
|
||||
if(v==0)
|
||||
memset(this,0,sizeof(SelfClass)); //omf可能不止一个指针的长度,所以必须这样清
|
||||
}
|
||||
|
||||
void operator = (const SelfClass &ef)
|
||||
{
|
||||
memcpy(this,&ef,sizeof(SelfClass));
|
||||
}
|
||||
|
||||
bool operator == (void *v)
|
||||
{
|
||||
return(vp_func==v);
|
||||
}
|
||||
|
||||
bool operator != (void *v)
|
||||
{
|
||||
return(vp_func!=v);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
RT operator()(ARGS...args)
|
||||
{
|
||||
return (this_pointer->*(func_pointer))(args...);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
RT operator()(ARGS...args)const
|
||||
{
|
||||
return (this_pointer->*(func_pointer))(args...);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
RT ThisCall(void *tp,ARGS...args)
|
||||
{
|
||||
return (((_Object *)tp)->*(func_pointer))(args...);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
RT ThisCall(void *tp,ARGS...args)const
|
||||
{
|
||||
return (((_Object *)tp)->*(func_pointer))(args...);
|
||||
}
|
||||
};//template<typename RT,typename Func> struct EventFunc
|
||||
|
||||
template<typename Func> struct EventFunc<void,Func>
|
||||
{
|
||||
typedef EventFunc<void,Func> SelfClass;
|
||||
|
||||
union
|
||||
{
|
||||
void *vp_this;
|
||||
_Object *this_pointer;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
void *vp_func;
|
||||
Func func_pointer;
|
||||
ObjectMemberFunc omf;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
EventFunc()
|
||||
{
|
||||
memset(this,0,sizeof(SelfClass));
|
||||
}
|
||||
|
||||
EventFunc(void *t,void *f)
|
||||
{
|
||||
memset(this,0,sizeof(SelfClass));
|
||||
|
||||
vp_this=t;
|
||||
vp_func=f;
|
||||
}
|
||||
|
||||
bool operator !()const
|
||||
{
|
||||
if(!vp_func)return(true);
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
void operator = (void *v)
|
||||
{
|
||||
if(v==0)
|
||||
memset(this,0,sizeof(SelfClass)); //omf可能不止一个指针的长度,所以必须这样清
|
||||
}
|
||||
|
||||
void operator = (const SelfClass &ef)
|
||||
{
|
||||
memcpy(this,&ef,sizeof(SelfClass));
|
||||
}
|
||||
|
||||
bool operator == (void *v)
|
||||
{
|
||||
return(vp_func==v);
|
||||
}
|
||||
|
||||
bool operator != (void *v)
|
||||
{
|
||||
return(vp_func!=v);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
void operator()(ARGS...args)
|
||||
{
|
||||
(this_pointer->*(func_pointer))(args...);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
void operator()(ARGS...args)const
|
||||
{
|
||||
(this_pointer->*(func_pointer))(args...);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
void ThisCall(void *tp,ARGS...args)
|
||||
{
|
||||
(((_Object *)tp)->*(func_pointer))(args...);
|
||||
}
|
||||
|
||||
template<typename ...ARGS>
|
||||
void ThisCall(void *tp,ARGS...args)const
|
||||
{
|
||||
(((_Object *)tp)->*(func_pointer))(args...);
|
||||
}
|
||||
};//template<void,typename Func> struct EventFunc
|
||||
|
||||
#define SetEventCall(event_obj,obj_this,class_name,event_func) { \
|
||||
event_obj.vp_this=obj_this; \
|
||||
event_obj.vp_func=GetMemberFuncPointer(class_name,event_func); \
|
||||
}
|
||||
|
||||
#define SetEventThis(event_obj,obj_this) event_obj.vp_this=obj_this;
|
||||
|
||||
// #define CallEvent(event_obj,intro) ((event_obj.this_pointer->*(event_obj.func_pointer))intro)
|
||||
|
||||
#define SafeCallEvent(event_obj,intro) {if(event_obj.vp_func)event_obj intro;}
|
||||
|
||||
#define DefEvent(result,name,intro) EventFunc<result,result (_Object:: *)intro> name;
|
||||
|
||||
#endif//__BORLANDC__
|
||||
|
||||
/*
|
||||
|
||||
使用方法:
|
||||
|
||||
class Example
|
||||
{
|
||||
//原Borland/CodeGear方式
|
||||
void (__closure *OnClick)(Object *);
|
||||
|
||||
//现通用方式
|
||||
DefEvent(void,OnClick,(Object *));
|
||||
};
|
||||
|
||||
void Test::ClickProc(Object *);
|
||||
|
||||
void Test::func()
|
||||
{
|
||||
Example *exp;
|
||||
|
||||
{
|
||||
//原Borland/CodeGear方式
|
||||
exp->OnClick=this->ClickProc;
|
||||
或
|
||||
exp->OnClick=ClickProc;
|
||||
|
||||
//现通用方式
|
||||
SetEventCall(exp->OnClick,this,Test,ClickProc);
|
||||
}
|
||||
|
||||
{
|
||||
//原Borland/CodeGear方式
|
||||
exp->OnClick(nullptr);
|
||||
|
||||
//现通用方式
|
||||
CallEvent(exp->OnClick,(nullptr));
|
||||
|
||||
//C++11方式
|
||||
exp->OnClick(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}//namespace hgl
|
||||
#endif//HGL_EVENT_FUNC_INCLUDE
|
85
inc/hgl/platform/compiler/GNU.h
Normal file
85
inc/hgl/platform/compiler/GNU.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef HGL_COMPILER_GNU_INCLUDE
|
||||
#define HGL_COMPILER_GNU_INCLUDE
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_COMPILER_NAME OS_TEXT("GNU C/C++")
|
||||
#define HGL_LIB_COMPILER_NAME OS_TEXT("GCC")
|
||||
|
||||
#if (__GNUC__<4)||(__GNUC__==4&&__GNUC_MINOR__<8)
|
||||
#error Please upgrade your compiler or development tools to GNU C/C++ 4.8 or later
|
||||
#else
|
||||
|
||||
#if __GNUC__ == 4
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("4")
|
||||
#elif __GNUC__ == 5
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("5")
|
||||
#elif __GNUC__ == 6
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("6")
|
||||
#elif __GNUC__ == 7
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("7")
|
||||
#elif __GNUC__ == 8
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("8")
|
||||
#elif __GNUC__ == 9
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("9")
|
||||
#elif __GNUC__ == 10
|
||||
#define HGL_LIB_COMPILER_MAIOR_VER OS_TEXT("10")
|
||||
#endif//__GNUC__
|
||||
|
||||
#if __GNUC_MINOR__ == 0
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("0")
|
||||
#elif __GNUC_MINOR__ == 1
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("1")
|
||||
#elif __GNUC_MINOR__ == 2
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("2")
|
||||
#elif __GNUC_MINOR__ == 3
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("3")
|
||||
#elif __GNUC_MINOR__ == 4
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("4")
|
||||
#elif __GNUC_MINOR__ == 5
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("5")
|
||||
#elif __GNUC_MINOR__ == 6
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("6")
|
||||
#elif __GNUC_MINOR__ == 7
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("7")
|
||||
#elif __GNUC_MINOR__ == 8
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("8")
|
||||
#elif __GNUC_MINOR__ == 9
|
||||
#define HGL_LIB_COMPILER_MINOR_VER OS_TEXT("9")
|
||||
#endif//
|
||||
|
||||
#if __GNUC_PATCHLEVEL__ == 0
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("0")
|
||||
#elif __GNUC_PATCHLEVEL__ == 1
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("1")
|
||||
#elif __GNUC_PATCHLEVEL__ == 2
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("2")
|
||||
#elif __GNUC_PATCHLEVEL__ == 3
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("3")
|
||||
#elif __GNUC_PATCHLEVEL__ == 4
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("4")
|
||||
#elif __GNUC_PATCHLEVEL__ == 5
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("5")
|
||||
#elif __GNUC_PATCHLEVEL__ == 6
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("6")
|
||||
#elif __GNUC_PATCHLEVEL__ == 7
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("7")
|
||||
#elif __GNUC_PATCHLEVEL__ == 8
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("8")
|
||||
#elif __GNUC_PATCHLEVEL__ == 9
|
||||
#define HGL_LIB_COMPILER_PATCH_LEVEL OS_TEXT("9")
|
||||
#endif//
|
||||
|
||||
#define HGL_LIB_COMPILER_VERSION HGL_LIB_COMPILER_MAIOR_VER OS_TEXT(".") HGL_LIB_COMPILER_MINOR_VER OS_TEXT(".") HGL_LIB_COMPILER_PATCH_LEVEL
|
||||
|
||||
#endif//__GNUC__
|
||||
|
||||
#define HGL_THREAD_LOCAL_STORAGE __thread //线程本地储存
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_"
|
||||
|
||||
#define HGL_LIB_END ".a"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<hgl/platform/compiler/DataTypeGNU.h>
|
||||
#include<hgl/platform/compiler/DataTypeTiny.h>
|
||||
#include<hgl/platform/compiler/Property.h>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_COMPILER_GNU_INCLUDE
|
43
inc/hgl/platform/compiler/Intel.h
Normal file
43
inc/hgl/platform/compiler/Intel.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef HGL_COMPILER_INTEL_INCLUDE
|
||||
#define HGL_COMPILER_INTEL_INCLUDE
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_COMPILER_NAME u"Intel C/C++"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#if __INTEL_COMPILER < 1200
|
||||
#error Please upgrade your compiler To Intel C/C++ 12.1 or later.
|
||||
#else
|
||||
#if __INTEL_COMPILER >=1200 && __INTEL_COMPILER < 1300
|
||||
#define HGL_LIB_COMPILER_NAME "IntelCPP12"
|
||||
#else
|
||||
#define HGL_LIB_COMPILER_NAME "IntelCPP_UnknownVersion"
|
||||
#endif//__INTEL_COMPILER
|
||||
|
||||
#define enum_uint(name) enum name:unsigned int
|
||||
#endif//__INTEL_COMPILER
|
||||
|
||||
#define vsnwprintf _vsnwprintf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<hgl/platform/compiler/DataTypeGNU.h>
|
||||
#include<hgl/platform/compiler/DataTypeTiny.h>
|
||||
#include<hgl/platform/compiler/Property.h>
|
||||
|
||||
#if HGL_OS == HGL_OS_Windows
|
||||
#define HGL_THREAD __declspec(thread)
|
||||
#else
|
||||
#define HGL_THREAD __thread
|
||||
#endif//HGL_OS == HGL_OS_Windows
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#ifdef _DLL
|
||||
#define HGL_LIB_CRT "Dynamic"
|
||||
#else
|
||||
#define HGL_LIB_CRT "Static"
|
||||
#endif//_DLL
|
||||
|
||||
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_" HGL_LIB_CRT "_"
|
||||
|
||||
#if HGL_OS == HGL_OS_Windows
|
||||
#define HGL_LIB_END ".LIB"
|
||||
#elif
|
||||
#define HGL_LIB_END ".a"
|
||||
#endif//HGL_OS == HGL_OS_Windows
|
||||
#endif//HGL_COMPILER_INTEL_INCLUDE
|
25
inc/hgl/platform/compiler/LLVM.h
Normal file
25
inc/hgl/platform/compiler/LLVM.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef HGL_COMPILER_LLVM_CLANG_INCLUDE
|
||||
#define HGL_COMPILER_LLVM_CLANG_INCLUDE
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_COMPILER_NAME OS_TEXT("LLVM Clang")
|
||||
#define HGL_LIB_COMPILER_NAME OS_TEXT("LLVM")
|
||||
|
||||
#if (__clang_major__<3)||(__clang_major__==3&&__clang_minor__<7)
|
||||
#error Please upgrade your compiler or development tools to LLVM Clang 3.7 or later
|
||||
#else
|
||||
|
||||
#define HGL_LIB_COMPILER_VERSION __clang_version__
|
||||
|
||||
#endif//__clang__
|
||||
|
||||
#define HGL_THREAD_LOCAL_STORAGE __thread //线程本地储存
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_"
|
||||
|
||||
#define HGL_LIB_END ".a"
|
||||
|
||||
#include<hgl/platform/compiler/DataTypeGNU.h>
|
||||
#include<hgl/platform/compiler/DataTypeTiny.h>
|
||||
#include<hgl/platform/compiler/Property.h>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_COMPILER_LLVM_CLANG_INCLUDE
|
61
inc/hgl/platform/compiler/Microsoft.h
Normal file
61
inc/hgl/platform/compiler/Microsoft.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef HGL_COMPILER_MICROSOFT_INCLUDE
|
||||
#define HGL_COMPILER_MICROSOFT_INCLUDE
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_COMPILER_NAME OS_TEXT("Microsoft C/C++")
|
||||
#define HGL_LIB_COMPILER_NAME OS_TEXT("MSC")
|
||||
|
||||
#if _MSC_VER < 1900 //Visual C++ 2015(19)
|
||||
#error Please upgrade your compiler or development tools to Microsoft C/C++ 19.0 (Visual C++ 2015) or later.
|
||||
#else
|
||||
#if _MSC_VER >= 1910
|
||||
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19.1") //Visual C++ 2017
|
||||
#elif _MSC_VER == 1900
|
||||
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19") //Visual C++ 2015
|
||||
#else
|
||||
#define HGL_LIB_COMPILER_VERSION OS_TEXT("Unknow")
|
||||
#endif//_MSC_VER
|
||||
#endif//_MSC_VER
|
||||
|
||||
#define HGL_THREAD_LOCAL_STORAGE __declspec(thread) //线程本地储存
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_FMT_I64 "%I64d"
|
||||
#define HGL_FMT_U64 "%I64u"
|
||||
//参考文档最后查阅支持版本为VC2013,网址:http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define _USE_MATH_DEFINES // 使用数学常数定义
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#pragma warning(disable:4819) // ansi -> unicode
|
||||
#pragma warning(disable:4311) // 模板警告
|
||||
#pragma warning(disable:4800) // -> bool 性能损失警告
|
||||
#pragma warning(disable:4244) // -> int 精度丢失警告
|
||||
#pragma warning(disable:4804) // 不安全的类型比较
|
||||
#pragma warning(disable:4805) // 不安全的类型比较
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif//
|
||||
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif//
|
||||
|
||||
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
|
||||
#define _CRT_NON_CONFORMING_SWPRINTFS
|
||||
#endif//
|
||||
|
||||
#ifdef _DLL
|
||||
#define HGL_LIB_CRT "Dynamic"
|
||||
#else
|
||||
#define HGL_LIB_CRT "Static"
|
||||
#endif//_DLL
|
||||
|
||||
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_" HGL_LIB_CRT "_"
|
||||
|
||||
#define HGL_LIB_END ".LIB"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<hgl/platform/compiler/DataTypeWin.h>
|
||||
#include<hgl/platform/compiler/DataTypeTiny.h>
|
||||
#include<hgl/platform/compiler/Property.h>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_COMPILER_MICROSOFT_INCLUDE
|
||||
|
97
inc/hgl/platform/compiler/Property.h
Normal file
97
inc/hgl/platform/compiler/Property.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef HGL_PROPERTY_INCLUDE
|
||||
#define HGL_PROPERTY_INCLUDE
|
||||
|
||||
#include<hgl/platform/compiler/EventFunc.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 只读属性
|
||||
*/
|
||||
template<typename T> class PropertyRead
|
||||
{
|
||||
public:
|
||||
|
||||
DefEvent(T,Get,() const);
|
||||
};//template<typename T> class PropertyRead
|
||||
|
||||
/**
|
||||
* 属性
|
||||
*/
|
||||
template<typename T> class Property
|
||||
{
|
||||
public:
|
||||
|
||||
DefEvent(T,Get,() const);
|
||||
DefEvent(void,Set,(T));
|
||||
|
||||
public:
|
||||
|
||||
Property()
|
||||
{
|
||||
Get=0;
|
||||
Set=0;
|
||||
}
|
||||
|
||||
virtual ~Property() {}
|
||||
|
||||
operator T() const{return Get();}
|
||||
void operator = (T v){Set(v);}
|
||||
void operator = (const Property<T> &v){Set(v.operator T());}
|
||||
|
||||
T operator !(){ return !(operator T());}
|
||||
T operator ~(){ return ~(operator T());}
|
||||
|
||||
T operator ++ () { T v=operator T(); Set(++v); return v; } ///<前置++
|
||||
T operator -- () { T v=operator T(); Set(--v); return v; } ///<前置--
|
||||
|
||||
T operator ++ (int) { T r,v; v=operator T(); r=v; Set(++v); return r; } ///<后置++
|
||||
T operator -- (int) { T r,v; v=operator T(); r=v; Set(--v); return r; } ///<后置--
|
||||
|
||||
void operator += (T v) { if(v){Set(operator T() + v);} }
|
||||
void operator -= (T v) { if(v){Set(operator T() - v);} }
|
||||
void operator *= (T v) { Set(operator T() * v); }
|
||||
void operator /= (T v) { Set(operator T() / v); }
|
||||
void operator %= (T v) { Set(operator T() % v); }
|
||||
|
||||
void operator &= (T v) { Set(operator T() & v); }
|
||||
void operator |= (T v) { Set(operator T() | v); }
|
||||
|
||||
void operator >>= (int n) { Set((operator T())>>n);}
|
||||
void operator <<= (int n) { Set((operator T())<<n);}
|
||||
|
||||
T operator >> (int n) { return (operator T())>>n;}
|
||||
T operator << (int n) { return (operator T())<<n;}
|
||||
|
||||
bool operator == (const T &v){return(operator T()==v);}
|
||||
bool operator != (const T &v){return(operator T()!=v);}
|
||||
};//class Property
|
||||
|
||||
template<typename T> class PropertyObject:public Property<T *>
|
||||
{
|
||||
public:
|
||||
|
||||
T *operator ->()const{return Property<T *>::Get();}
|
||||
void operator =(void *pointer){Property<T *>::Set((T *)pointer);}
|
||||
};//class PropertyObject
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define cmSetPropertyRead(name,tp,get) {name.Get=tp->get;}
|
||||
#define cmSetPropertyWrite(name,tp,set) {name.Set=tp->set;}
|
||||
#else
|
||||
#define cmSetPropertyRead(name,tp,get) { \
|
||||
name.Get.vp_this=tp; \
|
||||
name.Get.omf=ObjectMemberFunc(&get); \
|
||||
}
|
||||
|
||||
#define cmSetPropertyWrite(name,tp,set) { \
|
||||
name.Set.vp_this=tp; \
|
||||
name.Set.omf=ObjectMemberFunc(&set); \
|
||||
}
|
||||
#endif//
|
||||
|
||||
#define cmSetProperty(name,tp,get,set) { \
|
||||
cmSetPropertyRead(name,tp,get); \
|
||||
cmSetPropertyWrite(name,tp,set); \
|
||||
}
|
||||
}//namespace hgl
|
||||
#endif//HGL_PROPERTY_INCLUDE
|
Reference in New Issue
Block a user