first commit
This commit is contained in:
10
inc/hgl/platform/Exit.h
Normal file
10
inc/hgl/platform/Exit.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef HGL_EXIT_INCLUDE
|
||||
#define HGL_EXIT_INCLUDE
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
typedef int (*SignalAppExitFunc)(); //程序退出处理事件函数
|
||||
|
||||
void SetSignalAppExit(SignalAppExitFunc); //设置程序退出处理事件函数
|
||||
}//namespace hgl
|
||||
#endif//HGL_EXIT_INCLUDE
|
36
inc/hgl/platform/ExternalModule.h
Normal file
36
inc/hgl/platform/ExternalModule.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef HGL_EXTERNAL_MODULE_INCLUDE
|
||||
#define HGL_EXTERNAL_MODULE_INCLUDE
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
#include<hgl/platform/FuncLoad.h>
|
||||
#include OS_EXTERNAL_H
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 这个类用于对外部动态库的调用,支持Windows/Linux/BSD/MacOSX<br>
|
||||
* Windows 下动态库扩展名为.DLL<br>
|
||||
* FreeBSD/MacOSX 下动态库扩展名为.dylib<br>
|
||||
* Linux 下动态库扩展名为.so
|
||||
*/
|
||||
class ExternalModule ///外部模块调用类
|
||||
{
|
||||
ExternalModulePointer fp;
|
||||
|
||||
public: //方法
|
||||
|
||||
ExternalModule(); ///<本类构造函数
|
||||
ExternalModule(ExternalModulePointer); ///<本类构造函数
|
||||
virtual ~ExternalModule(); ///<本类析构函数
|
||||
|
||||
bool Load(const os_char *); ///<加载一个外部模块
|
||||
void Clear(); ///<清除当前模块
|
||||
|
||||
void *FindFunc(const char *); ///<查找函数
|
||||
void *GetFunc(const char *); ///<取得函数
|
||||
|
||||
int Get(FuncLoad *); ///<加载函数列表
|
||||
};//class ExternalModule
|
||||
|
||||
ExternalModule *LoadExternalModule(const os_char *); ///<加载一个外部模块
|
||||
}//namespace hgl
|
||||
#endif//HGL_EXTERNAL_MODULE_INCLUDE
|
31
inc/hgl/platform/FuncLoad.h
Normal file
31
inc/hgl/platform/FuncLoad.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef HGL_FUNC_LOAD_INCLUDE
|
||||
#define HGL_FUNC_LOAD_INCLUDE
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 函数加载定义数据结构
|
||||
*/
|
||||
struct FuncLoad
|
||||
{
|
||||
char func_name[64]; ///<函数名称
|
||||
void **func_pointer; ///<函数指针
|
||||
};//struct FuncLoad
|
||||
|
||||
#define HGL_FUNC_LOAD_LIST_BEGIN(name) struct FuncLoad name[]={
|
||||
#define HGL_FUNC_LOAD(name) {#name,(void **)&name},
|
||||
#define HGL_FUNC_LOAD_LIST_END {"",(void **)0}};
|
||||
|
||||
inline void ClearFuncLoadPointer(struct FuncLoad *flp)
|
||||
{
|
||||
if(!flp)return;
|
||||
|
||||
while(flp->func_pointer)
|
||||
{
|
||||
flp->func_pointer=(void **)0;
|
||||
|
||||
++flp;
|
||||
}
|
||||
}
|
||||
}//namespace hgl
|
||||
#endif//HGL_FUNC_LOAD_INCLUDE
|
334
inc/hgl/platform/Platform.h
Normal file
334
inc/hgl/platform/Platform.h
Normal file
@@ -0,0 +1,334 @@
|
||||
#ifndef HGL_PLATFORM_INCLUDE
|
||||
#define HGL_PLATFORM_INCLUDE
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define HGL_LIB_DEBUG_NAME "Debug"
|
||||
#else
|
||||
#define HGL_LIB_DEBUG_NAME "Release"
|
||||
#endif//
|
||||
|
||||
#define HGL_MERGE32(a,b,c,d) (a|b<<8|c<<16|d<<24)
|
||||
|
||||
#define HGL_OS_Windows HGL_MERGE32('W','i','n',' ')
|
||||
#define HGL_OS_macOS HGL_MERGE32('m','a','c',' ')
|
||||
#define HGL_OS_iOS HGL_MERGE32('i','O','S',' ')
|
||||
#define HGL_OS_FreeBSD HGL_MERGE32('F','B','S','D')
|
||||
#define HGL_OS_NetBSD HGL_MERGE32('N','B','S','D')
|
||||
#define HGL_OS_OpenBSD HGL_MERGE32('O','B','S','D')
|
||||
#define HGL_OS_Linux HGL_MERGE32('L','i','n','u')
|
||||
#define HGL_OS_Cygwin HGL_MERGE32('C','y','g','w')
|
||||
#define HGL_OS_PSP2 HGL_MERGE32('P','S','P','2')
|
||||
#define HGL_OS_PS4 HGL_MERGE32('P','S','4',' ')
|
||||
#define HGL_OS_AIX HGL_MERGE32('A','I','X',' ')
|
||||
#define HGL_OS_Android HGL_MERGE32('A','n','d','r')
|
||||
#define HGL_OS_Wasm HGL_MERGE32('W','a','s','m')
|
||||
|
||||
#define HGL_CPU_X86_32 HGL_MERGE32('8','6','3','2')
|
||||
#define HGL_CPU_X86_64 HGL_MERGE32('8','6','6','4')
|
||||
#define HGL_CPU_MIPS HGL_MERGE32('M','I','P','S')
|
||||
#define HGL_CPU_MIPSel HGL_MERGE32('M','I','e','l')
|
||||
#define HGL_CPU_MIPS64 HGL_MERGE32('M','I','6','4')
|
||||
#define HGL_CPU_PowerPC HGL_MERGE32('P','P','C',' ')
|
||||
#define HGL_CPU_PowerPC64 HGL_MERGE32('P','P','6','4')
|
||||
#define HGL_CPU_Cell HGL_MERGE32('C','E','L','L')
|
||||
#define HGL_CPU_ARM7 HGL_MERGE32('A','R','M','7')
|
||||
#define HGL_CPU_ARM64 HGL_MERGE32('A','R','6','4')
|
||||
|
||||
#define HGL_COMPILER_Microsoft HGL_MERGE32('M','S','C',' ')
|
||||
#define HGL_COMPILER_GNU HGL_MERGE32('G','N','U',' ')
|
||||
#define HGL_COMPILER_MinGW32 HGL_MERGE32('M','G','3','2')
|
||||
#define HGL_COMPILER_Intel HGL_MERGE32('I','n','t','e')
|
||||
#define HGL_COMPILER_IBM HGL_MERGE32('I','B','M',' ')
|
||||
#define HGL_COMPILER_DigitalMars HGL_MERGE32('D','i','M','a')
|
||||
#define HGL_COMPILER_LLVM HGL_MERGE32('L','L','V','M')
|
||||
#define HGL_COMPILER_PGI HGL_MERGE32('P','G','I',' ')
|
||||
|
||||
#define HGL_BIG_ENDIAN 'B'
|
||||
#define HGL_LITTLE_ENDIAN 'L'
|
||||
|
||||
#if defined(__amd64__) ||defined(__amd64) || \
|
||||
defined(__x86_64__) ||defined(__x86_64) || \
|
||||
defined(_M_AMD64) ||defined(_M_X64)
|
||||
#define HGL_CPU HGL_CPU_X86_64
|
||||
#define HGL_CPU_NAME OS_TEXT("X86-64Bit")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("x64")
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 8
|
||||
#define HGL_ENDIAN HGL_LITTLE_ENDIAN
|
||||
#elif defined(i386) || defined(__i386__) || defined(__i386) ||defined(_M_IX86)
|
||||
#define HGL_CPU HGL_CPU_X86_32
|
||||
#define HGL_CPU_NAME OS_TEXT("X86-32Bit")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("x86")
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 4
|
||||
#define HGL_ENDIAN HGL_LITTLE_ENDIAN
|
||||
#elif defined(_M_MIPS)||defined(_MIPS_ARCH)||defined(__mips__)||defined(__mips)||defined(mips)||defined(__MIPS__)
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 4
|
||||
#ifdef __MIPSEL__
|
||||
#define HGL_CPU HGL_CPU_MIPSel
|
||||
#define HGL_CPU_NAME OS_TEXT("MIPSel")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("MIPSel")
|
||||
#define HGL_ENDIAN HGL_LITTLE_ENDIAN
|
||||
#else
|
||||
#define HGL_CPU HGL_CPU_MIPS
|
||||
#define HGL_CPU_NAME OS_TEXT("MIPS")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("MIPS")
|
||||
#define HGL_ENDIAN HGL_BIG_ENDIAN
|
||||
#endif//__MIPSEL__
|
||||
#elif defined(__mips64__)||defined(mips64)
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 8
|
||||
#define HGL_CPU HGL_CPU_MIPS64
|
||||
#define HGL_CPU_NAME OS_TEXT("MIPS64")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("MIPS64")
|
||||
#define HGL_ENDIAN HGL_BIG_ENDIAN
|
||||
#elif defined(__powerpc__) || defined(__powerpc) \
|
||||
||defined(__POWERPC__) \
|
||||
|| defined(__ppc__) || defined(__PPC__) || defined(__ppc) \
|
||||
|| defined(_M_PPC) ||defined(_M_MPPC) \
|
||||
|| defined(_ARCH_PPC) || defined(_ARCH_PWR)
|
||||
#ifdef __PPU__
|
||||
#define HGL_CPU HGL_CPU_Cell
|
||||
#define HGL_CPU_NAME OS_TEXT("Cell")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("Cell")
|
||||
#else
|
||||
#ifdef defined(__ppc64__)||defined(__PPC64__)||defined(__powerpc64__) \
|
||||
||defined(_ARCH_PPC64)||defined(__64BIT__)
|
||||
#define HGL_CPU HGL_CPU_PowerPC64
|
||||
#define HGL_CPU_NAME OS_TEXT("PowerPC64")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("PowerPC64")
|
||||
#else
|
||||
#define HGL_CPU HGL_CPU_PowerPC
|
||||
#define HGL_CPU_NAME OS_TEXT("PowerPC")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("PowerPC")
|
||||
#endif//PowerPC64
|
||||
#endif
|
||||
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 8
|
||||
#define HGL_ENDIAN HGL_BIG_ENDIAN
|
||||
#elif defined(__arm__)||defined(__arm) \
|
||||
||defined(_ARM) \
|
||||
||defined(_M_ARM) \
|
||||
||defined(__ARM_ARCH__7__) \
|
||||
||defined(__ARM_ARCH__7A__) \
|
||||
||defined(__ARM_ARCH__7R__) \
|
||||
||defined(__ARM_ARCH__7M__) \
|
||||
||defined(__ARM_ARCH__7S__)
|
||||
#define HGL_CPU HGL_CPU_ARM7
|
||||
#define HGL_CPU_NAME OS_TEXT("ARM7")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("ARM7")
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 4
|
||||
#define HGL_ENDIAN HGL_LITTLE_ENDIAN
|
||||
#elif defined(__aarch64__)
|
||||
#define HGL_CPU HGL_CPU_ARM64
|
||||
#define HGL_CPU_NAME OS_TEXT("ARM64")
|
||||
#define HGL_LIB_CPU_NAME OS_TEXT("ARM64")
|
||||
#define HGL_MIN_MEMORY_ALLOC_BYTES 4
|
||||
#define HGL_ENDIAN HGL_LITTLE_ENDIAN
|
||||
#elif defined(__wasm__)
|
||||
|
||||
#error Not support WebAssembly.please wait update......
|
||||
|
||||
#define HGL_OS HGL_OS_Wasm
|
||||
#define HGL_COMPILER HGL_COMPILER_LLVM
|
||||
#else
|
||||
#error Not support the cpu.
|
||||
#endif
|
||||
|
||||
#if HGL_ENDIAN == HGL_BIG_ENDIAN
|
||||
#define HGL_CPU_ENDIAN OS_TEXT("Big Endian")
|
||||
#else
|
||||
#define HGL_CPU_ENDIAN OS_TEXT("Little Endian")
|
||||
#endif//HGL_ENDIAN == HGL_BIG_ENDIAN
|
||||
|
||||
#if defined(__WIN32__)||defined(_WIN32)||defined(WIN32)||defined(__WINDOWS__)||defined(__WIN64__)||defined(_WIN64)||defined(WIN64)
|
||||
#define HGL_OS HGL_OS_Windows
|
||||
#elif defined(__APPLE__)||defined(__MAC__)||defined(macintosh)||defined(__APPLE_CC__)
|
||||
|
||||
#define HGL_OS_BSD 1
|
||||
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
#define HGL_OS HGL_OS_iOS_Simulator
|
||||
#else
|
||||
#define HGL_OS HGL_OS_iOS
|
||||
#endif//TARGET_IPHONE_SIMULATOR
|
||||
#elif TARGET_OS_MAC
|
||||
#define HGL_OS HGL_OS_macOS
|
||||
#endif//
|
||||
#elif defined(__ANDROID__)
|
||||
#define HGL_OS HGL_OS_Android
|
||||
#elif defined(__FreeBSD)||defined(__FreeBSD__)
|
||||
#define HGL_OS HGL_OS_FreeBSD
|
||||
#define HGL_OS_BSD 1
|
||||
#elif defined(__NetBSD)||defined(__NetBSD__)
|
||||
#define HGL_OS HGL_OS_NetBSD
|
||||
#define HGL_OS_BSD 1
|
||||
#elif defined(__OPENBSD)||defined(__OpenBSD__)
|
||||
#define HGL_OS HGL_OS_OpenBSD
|
||||
#define HGL_OS_BSD 1
|
||||
#elif defined(__linux__)||defined(__LINUX__)||defined(linux)||defined(__linux)
|
||||
#define HGL_OS HGL_OS_Linux
|
||||
#elif defined(__CYGWIN__)
|
||||
#define HGL_OS HGL_OS_Cygwin
|
||||
#elif defined(SN_TARGET_PSP2)||defined(__PSV__)||defined(__psv__)||defined(_PSV)||defined(__PSVita__)||defined(__PSVita)
|
||||
#define HGL_OS HGL_OS_PSP2
|
||||
#elif defined(SN_TARGET_ORBIS)
|
||||
#define HGL_OS HGL_OS_PS4
|
||||
#elif defined(_AIX)||defined(__AIX)||defined(__AIX__)||defined(__aix)||defined(__aix__)
|
||||
#define HGL_OS HGL_OS_AIX
|
||||
#endif//
|
||||
|
||||
#if defined(__clang__)
|
||||
#define HGL_COMPILER HGL_COMPILER_LLVM
|
||||
#elif defined(__INTEL_COMPILER)||defined(__ECL)||defined(__ICL)||defined(__ICC)
|
||||
#define HGL_COMPILER HGL_COMPILER_Intel
|
||||
#elif defined(__IBMC__)||defined(__IBMCPP__)
|
||||
#define HGL_COMPILER HGL_COMPILER_IBM
|
||||
#elif defined(__DMC__)||defined(__SC__)||defined(__ZTC__)
|
||||
#define HGL_COMPILER HGL_COMPILER_DigitalMars
|
||||
#elif defined(_MSC_VER)
|
||||
#define HGL_COMPILER HGL_COMPILER_Microsoft
|
||||
#elif defined(__PGI)
|
||||
#define HGL_COMPILER HGL_COMPILER_PGI
|
||||
#elif defined(__MINGW32__)
|
||||
#define HGL_COMPILER HGL_COMPILER_MinGW32
|
||||
#elif defined(__GNUC__)
|
||||
#define HGL_COMPILER HGL_COMPILER_GNU
|
||||
#else
|
||||
#error Can not support the Compiler.
|
||||
#endif//
|
||||
|
||||
#if defined(SetEventCall)||defined(SafeCallEvent)||defined(CallEvent)||defined(DefEvent)
|
||||
#error SetEventCall,SafeCallEvent,CallEvent,DefEvent 其中之一已经定义
|
||||
#endif//
|
||||
|
||||
#if defined(Property)||defined(PropertyRead)||defined(PropertyWrite)
|
||||
#error Property,PropertyRead,PropertyWrite 其中之一已经定义
|
||||
#endif//
|
||||
|
||||
// #ifndef UNICODE
|
||||
// #define UNICODE //定义使用UNICODE编码
|
||||
// #endif//UNICODE
|
||||
|
||||
#if HGL_OS == HGL_OS_Windows
|
||||
|
||||
#include<hgl/platform/os/MSWindows.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_Microsoft
|
||||
#include<hgl/platform/compiler/Microsoft.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_Intel
|
||||
#include<hgl/platform/compiler/Intel.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_IBM
|
||||
#include<hgl/platform/compiler/IBM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_MINGW32
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif
|
||||
|
||||
#elif HGL_OS == HGL_OS_Cygwin
|
||||
|
||||
#include<hgl/platform/os/Cygwin.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_LLVM
|
||||
#include<hgl/platform/compiler/LLVM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif//GNU
|
||||
|
||||
#elif (HGL_OS == HGL_OS_FreeBSD)||(HGL_OS == HGL_OS_NetBSD)||(HGL_OS == HGL_OS_OpenBSD)
|
||||
|
||||
#include<hgl/platform/os/BSD.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_LLVM
|
||||
#include<hgl/platform/compiler/LLVM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif//GNU
|
||||
|
||||
#elif HGL_OS == HGL_OS_Linux
|
||||
|
||||
#include<hgl/platform/os/Linux.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_CBuilder
|
||||
#include<hgl/platform/compiler/CBuilder.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_Intel
|
||||
#include<hgl/platform/compiler/Intel.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_IBM
|
||||
#include<hgl/platform/compiler/IBM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_Watcom
|
||||
#include<hgl/platform/compiler/Watcom.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_LLVM
|
||||
#include<hgl/platform/compiler/LLVM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif
|
||||
|
||||
#elif HGL_OS == HGL_OS_macOS
|
||||
|
||||
#include<hgl/platform/os/MacOS.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_Intel
|
||||
#include<hgl/platform/compiler/Intel.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_LLVM
|
||||
#include<hgl/platform/compiler/LLVM.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif
|
||||
|
||||
#elif HGL_OS == HGL_OS_iOS
|
||||
|
||||
#include<hgl/platform/os/MacOS.h>
|
||||
#include<hgl/platform/compiler/LLVM.h>
|
||||
|
||||
#elif HGL_OS == HGL_OS_PSP2
|
||||
|
||||
#include<hgl/platform/os/psp2.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif
|
||||
|
||||
#elif HGL_OS == HGL_OS_AIX
|
||||
|
||||
#include<hgl/platform/os/aix.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_IBM
|
||||
#include<hgl/platform/compiler/IBM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_SGI
|
||||
#include<hgl/platform/compiler/SGI.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif
|
||||
|
||||
#elif HGL_OS == HGL_OS_Android
|
||||
|
||||
#include<hgl/platform/os/Android.h>
|
||||
|
||||
#if HGL_COMPILER == HGL_COMPILER_LLVM
|
||||
#include<hgl/platform/compiler/LLVM.h>
|
||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||
#include<hgl/platform/compiler/GNU.h>
|
||||
#else
|
||||
#error Unrecognized compiler
|
||||
#endif//GNU
|
||||
#endif//HGL_OS
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
#define HGL_WINDOW_DIRECTORY_SEPARATOR OS_TEXT('\\')
|
||||
#define HGL_UNIX_DIRECTORY_SPEARATOR OS_TEXT('/')
|
||||
}//namespace hgl
|
||||
|
||||
#endif//HGL_PLATFORM_INCLUDE
|
69
inc/hgl/platform/SystemInfo.h
Normal file
69
inc/hgl/platform/SystemInfo.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef HGL_SYSTEMINFO_INCLUDE
|
||||
#define HGL_SYSTEMINFO_INCLUDE
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
#include<hgl/type/BaseString.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 内存信息结构体
|
||||
*/
|
||||
struct MemInfo ///内存信息结构体
|
||||
{
|
||||
uint64 AvailPhys; ///<有效物理内存
|
||||
uint64 TotalPhys; ///<总共物理内存
|
||||
|
||||
uint64 AvailPageFile; ///<有效页面文件
|
||||
uint64 TotalPageFile; ///<总共页面文件
|
||||
|
||||
uint64 AvailVirtual; ///<有效虚拟内存
|
||||
uint64 TotalVirtual; ///<总计虚拟内存
|
||||
|
||||
public:
|
||||
|
||||
MemInfo();
|
||||
};//struct MemInfo
|
||||
|
||||
/**
|
||||
* 操作系统及引擎相关路径
|
||||
*/
|
||||
struct SystemPath ///操作系统及引擎相关路径
|
||||
{
|
||||
OSString start; ///<当前应用程序起始路径
|
||||
|
||||
OSString os; ///<操作系统路径
|
||||
OSString osfont; ///<操作系统字库路径
|
||||
OSString library; ///<操作系统辅助库路径
|
||||
|
||||
OSString common_data; ///<所有用户共用应用程序数据路径
|
||||
OSString local_data; ///<本地应用程序数据路径
|
||||
|
||||
OSString temp; ///<临时文件路径
|
||||
|
||||
OSString mydata; ///<当前用户应用程序数据保存路径
|
||||
OSString myprogram; ///<“我的程序”路径(Windows下为开始菜单程序路径,Mac下为应用程序路径)
|
||||
OSString mydesktop; ///<“桌面”路径
|
||||
|
||||
OSString desktop; ///<所有用户桌面路径
|
||||
|
||||
OSString engine; ///<引擎所在路径
|
||||
OSString plug_ins; ///<引擎插件路径
|
||||
};//struct SystemPath
|
||||
|
||||
/**
|
||||
* 系统信息
|
||||
*/
|
||||
struct SystemInfo ///系统信息结构
|
||||
{
|
||||
MemInfo mem; ///<内存信息
|
||||
|
||||
u16char os_name[256]; ///<操作系统全名
|
||||
|
||||
SystemPath path; ///<系统相关路径
|
||||
|
||||
public:
|
||||
|
||||
SystemInfo();
|
||||
};//struct SystemInfo
|
||||
}//namespace hgl
|
||||
#endif//HGL_SYSTEMINFO_INCLUDE
|
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
|
86
inc/hgl/platform/os/Android.h
Normal file
86
inc/hgl/platform/os/Android.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef HGL_OS_ANDROID_INCLUDE
|
||||
#define HGL_OS_ANDROID_INCLUDE
|
||||
|
||||
#include<limits.h>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
using u32char =char32_t;
|
||||
using u16char =char16_t;
|
||||
using os_char =char;
|
||||
#define to_oschar to_u8
|
||||
#define OS_TEXT(str) u8##str
|
||||
#define U8_TEXT(str) u8##str
|
||||
#define U16_TEXT(str) u##str
|
||||
|
||||
#define HGL_OS_NAME OS_TEXT("Android")
|
||||
#define HGL_LIB_OS "Android" //库操作系统前缀
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_PLUGIN_FRONTNAME "libCMP." //插件文件名前缀
|
||||
#define HGL_PLUGIN_EXTNAME ".so" //插件文件扩展名
|
||||
#define HGL_PLUGIN_FUNC extern "C" //插件函数定义
|
||||
|
||||
#define HGL_DIRECTORY_SEPARATOR '/' //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_STR OS_TEXT("/") //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_U8STR U8_TEXT("/") //目录分隔符
|
||||
|
||||
#define HGL_LINE_END "\n" //换行符
|
||||
#define HGL_LINE_END_SIZE 1 //换行符长度
|
||||
|
||||
#define HGL_MEM_ALIGN 16 //内存对齐字节数
|
||||
|
||||
#define HGL_MAX_PATH _POSIX_PATH_MAX
|
||||
|
||||
#define HGL_FMT_I64 "%lld"
|
||||
#define HGL_FMT_U64 "%llu"
|
||||
#define HGL_FMT_DOUBLE "%lf"
|
||||
#define HGL_FMT_LONG_DOUBLE "%le"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<malloc.h>
|
||||
#include<stdlib.h>
|
||||
#include<hgl/platform/os/PosixThread.h>
|
||||
|
||||
#define hgl_malloc(size) memalign(HGL_MEM_ALIGN,size) //这个所有版本linux libc都支持
|
||||
//#define hgl_malloc(size) aligned_alloc(HGL_MEM_ALIGN,size) //这个是C11新增,需要libc 2.16
|
||||
#define hgl_realloc(ptr,size) realloc(ptr,size)
|
||||
#define hgl_free free
|
||||
|
||||
template<typename T>
|
||||
inline T *hgl_aligned_malloc(size_t n)
|
||||
{
|
||||
return (T *)memalign(alignof(T),n*sizeof(T));
|
||||
}
|
||||
|
||||
#define OS_EXTERNAL_H <dlfcn.h>
|
||||
typedef void * ExternalModulePointer;
|
||||
#define pi_get dlsym
|
||||
#define pi_close dlclose
|
||||
|
||||
#define iconv_str char *
|
||||
|
||||
#define hgl_stat64 stat
|
||||
#define hgl_open64 open
|
||||
#define hgl_lseek64 lseek
|
||||
#define hgl_tell64(fp) lseek(fp,0,SEEK_CUR)
|
||||
#define hgl_fstat64 fstat
|
||||
#define hgl_lstat64 lstat
|
||||
#define hgl_read64 read
|
||||
#define hgl_write64 write
|
||||
#define hgl_pread64 pread
|
||||
#define hgl_pwrite64 pwrite
|
||||
|
||||
#define struct_stat64 struct stat
|
||||
#define struct_dirent64 struct dirent
|
||||
#define hgl_dirent64 dirent
|
||||
#define hgl_readdir64 readdir
|
||||
|
||||
#define sprintf_s snprintf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//初始化Android支持,以下函数二选一
|
||||
|
||||
#include<jni.h>
|
||||
|
||||
void InitAndroidSupport(JNIEnv *env,jobject obj); //JNI混编模式初始化Android支持
|
||||
|
||||
struct ANativeActivity;
|
||||
void InitAndroidSupport(struct ANativeActivity *app); //NativeActivity模式初始化Android支持
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_OS_ANDROID_INCLUDE
|
83
inc/hgl/platform/os/BSD.h
Normal file
83
inc/hgl/platform/os/BSD.h
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef HGL_OS_BSD_INCLUDE
|
||||
#define HGL_OS_BSD_INCLUDE
|
||||
|
||||
#include<limits.h>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
using u32char =char32_t;
|
||||
using u16char =char16_t;
|
||||
using os_char =char;
|
||||
#define to_oschar to_u8
|
||||
#define OS_TEXT(str) u8##str
|
||||
#define U8_TEXT(str) u8##str
|
||||
#define U16_TEXT(str) u##str
|
||||
|
||||
#if defined(__FreeBSD__)||defined(__FreeBSD)
|
||||
#define HGL_OS_NAME OS_TEXT("FreeBSD")
|
||||
#define HGL_LIB_OS_NAME "FreeBSD"
|
||||
#elif defined(__NetBSD__)||defined(__NetBSD)
|
||||
#define HGL_OS_NAME OS_TEXT("NetBSD")
|
||||
#define HGL_LIB_OS_NAME "NetBSD"
|
||||
#elif defined(__OpenBSD__)||defined(__OPENBSD)
|
||||
#define HGL_OS_NAME OS_TEXT("OpenBSD")
|
||||
#define HGL_LIB_OS_NAME "OpenBSD"
|
||||
#else
|
||||
#define HGL_OS_NAME OS_TEXT("BSD")
|
||||
#define HGL_LIB_OS_NAME "BSD"
|
||||
#endif//
|
||||
|
||||
#define HGL_LIB_OS "BSD" //库操作系统前缀
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_PLUGIN_FRONTNAME "libCMP." //插件文件名前缀
|
||||
#define HGL_PLUGIN_EXTNAME ".so" //插件文件扩展名
|
||||
#define HGL_PLUGIN_FUNC extern "C" //插件函数定义
|
||||
|
||||
#define HGL_DIRECTORY_SEPARATOR '/' //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_STR OS_TEXT("/") //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_U8STR U8_TEXT("/") //目录分隔符
|
||||
|
||||
#define HGL_LINE_END "\n" //换行符
|
||||
#define HGL_LINE_END_SIZE 1 //换行符长度
|
||||
|
||||
#define HGL_MEM_ALIGN 16 //内存对齐字节数
|
||||
|
||||
#define HGL_MAX_PATH _POSIX_PATH_MAX
|
||||
|
||||
#define HGL_FMT_I64 "%lld"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<stdlib.h>
|
||||
#include<hgl/platform/os/PosixThread.h>
|
||||
|
||||
#define hgl_malloc(size) aligned_alloc(HGL_MEM_ALIGN,size) //这个是C11新增,需要libc 2.16
|
||||
#define hgl_realloc realloc
|
||||
#define hgl_free free
|
||||
|
||||
template<typename T>
|
||||
inline T *hgl_aligned_malloc(size_t n)
|
||||
{
|
||||
return (T *)aligned_alloc(alignof(T),n*sizeof(T));
|
||||
}
|
||||
|
||||
#define OS_EXTERNAL_H <dlfcn.h>
|
||||
typedef void * ExternalModulePointer;
|
||||
#define pi_get dlsym
|
||||
#define pi_close dlclose
|
||||
|
||||
typedef pthread_mutex_t hgl_thread_mutex;
|
||||
|
||||
#define hgl_stat64 stat
|
||||
#define hgl_open64 open
|
||||
#define hgl_lseek64 lseek
|
||||
#define hgl_tell64(fp) lseek(fp,0,SEEK_CUR)
|
||||
#define hgl_fstat64 fstat
|
||||
#define hgl_lstat64 lstat
|
||||
#define hgl_read64 read
|
||||
#define hgl_write64 write
|
||||
#define hgl_pread64 pread
|
||||
#define hgl_pwrite64 pwrite
|
||||
|
||||
#define struct_stat64 struct stat
|
||||
#define struct_dirent64 struct dirent
|
||||
#define hgl_dirent64 dirent
|
||||
#define hgl_readdir64 readdir
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_OS_BSD_INCLUDE
|
75
inc/hgl/platform/os/Linux.h
Normal file
75
inc/hgl/platform/os/Linux.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef HGL_OS_LINUX_INCLUDE
|
||||
#define HGL_OS_LINUX_INCLUDE
|
||||
|
||||
#include<limits.h>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
using u32char =char32_t;
|
||||
using u16char =char16_t;
|
||||
using os_char =char;
|
||||
#define to_oschar to_u8
|
||||
#define OS_TEXT(str) u8##str
|
||||
#define U8_TEXT(str) u8##str
|
||||
#define U16_TEXT(str) u##str
|
||||
|
||||
#define HGL_OS_NAME OS_TEXT("Linux")
|
||||
#define HGL_LIB_OS "Linux" //库操作系统前缀
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_PLUGIN_FRONTNAME "libCMP." //插件文件名前缀
|
||||
#define HGL_PLUGIN_EXTNAME ".so" //插件文件扩展名
|
||||
#define HGL_PLUGIN_FUNC extern "C" //插件函数定义
|
||||
|
||||
#define HGL_DIRECTORY_SEPARATOR '/' //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_STR OS_TEXT("/") //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_U8STR U8_TEXT("/") //目录分隔符
|
||||
|
||||
#define HGL_LINE_END "\n" //换行符
|
||||
#define HGL_LINE_END_SIZE 1 //换行符长度
|
||||
|
||||
#define HGL_MEM_ALIGN 16 //内存对齐字节数
|
||||
|
||||
#define HGL_MAX_PATH _POSIX_PATH_MAX
|
||||
|
||||
#define HGL_FMT_I64 "%lld"
|
||||
#define HGL_FMT_U64 "%llu"
|
||||
#define HGL_FMT_DOUBLE "%lf"
|
||||
#define HGL_FMT_LONG_DOUBLE "%le"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<malloc.h>
|
||||
#include<stdlib.h>
|
||||
#include<hgl/platform/os/PosixThread.h>
|
||||
|
||||
//#define hgl_malloc(size) memalign(HGL_MEM_ALIGN,size) //这个所有版本linux libc都支持
|
||||
#define hgl_malloc(size) aligned_alloc(HGL_MEM_ALIGN,size) //这个是C11新增,需要libc 2.16
|
||||
#define hgl_realloc(ptr,size) realloc(ptr,size)
|
||||
#define hgl_free free
|
||||
|
||||
template<typename T>
|
||||
inline T *hgl_aligned_malloc(size_t n)
|
||||
{
|
||||
return (T *)aligned_alloc(alignof(T),n*sizeof(T));
|
||||
}
|
||||
|
||||
#define OS_EXTERNAL_H <dlfcn.h>
|
||||
typedef void * ExternalModulePointer;
|
||||
#define pi_get dlsym
|
||||
#define pi_close dlclose
|
||||
|
||||
#define hgl_stat64 stat64
|
||||
#define hgl_open64 open64
|
||||
#define hgl_lseek64 lseek64
|
||||
#define hgl_tell64(fp) lseek64(fp,0,SEEK_CUR)
|
||||
#define hgl_fstat64 fstat64
|
||||
#define hgl_lstat64 lstat64
|
||||
#define hgl_read64 read
|
||||
#define hgl_write64 write
|
||||
#define hgl_pread64 pread64
|
||||
#define hgl_pwrite64 pwrite64
|
||||
|
||||
#define struct_stat64 struct stat64
|
||||
#define struct_dirent64 struct dirent64
|
||||
#define hgl_dirent64 dirent64
|
||||
#define hgl_readdir64 readdir64
|
||||
|
||||
#define sprintf_s snprintf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_OS_LINUX_INCLUDE
|
80
inc/hgl/platform/os/MSWindows.h
Normal file
80
inc/hgl/platform/os/MSWindows.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef HGL_OS_WIN_INCLUDE
|
||||
#define HGL_OS_WIN_INCLUDE
|
||||
|
||||
#include<malloc.h>
|
||||
#include<winsock2.h> //winsock2必须在Windows.h前面,不然会报错
|
||||
#include<windows.h>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
using u32char =char32_t;
|
||||
using u16char =wchar_t;
|
||||
using os_char =wchar_t;
|
||||
#define to_oschar to_u16
|
||||
#define OS_TEXT(str) L##str
|
||||
#define U8_TEXT(str) u8##str
|
||||
#define U16_TEXT(str) L##str
|
||||
|
||||
#define HGL_OS_NAME OS_TEXT("Windows")
|
||||
|
||||
#if HGL_CPU == HGL_CPU_X86_32
|
||||
#define HGL_LIB_OS "Win32" //库操作系统前缀
|
||||
#elif HGL_CPU == HGL_CPU_X86_64
|
||||
#define HGL_LIB_OS "Win64" //库操作系统前缀
|
||||
#endif//HGL_CPU
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define HGL_PLUGIN_FRONTNAME OS_TEXT("CMP.") //插件文件名前缀
|
||||
#define HGL_PLUGIN_EXTNAME OS_TEXT(".DLL") //插件文件扩展名
|
||||
#define HGL_PLUGIN_FUNC extern "C" __declspec(dllexport) //插件函数定义
|
||||
|
||||
#define HGL_DIRECTORY_SEPARATOR OS_TEXT('\\') //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_STR OS_TEXT("\\") //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_U8STR U8_TEXT("\\")
|
||||
|
||||
#define HGL_LINE_END OS_TEXT("\r\n") //换行符
|
||||
#define HGL_LINE_END_SIZE 2 //换行符长度
|
||||
|
||||
#define HGL_MAX_PATH MAX_PATH
|
||||
|
||||
#define HGL_MEM_ALIGN 16 //内存对齐字节数
|
||||
|
||||
#define HGL_GL_WINDOW_INCLUDE_FILE <hgl/platform/WinOpenGL.h> //指定OpenGL窗口引用头文件
|
||||
#define HGL_GL_WINDOW_CLASS WinGLWindow //指定OpenGL窗口类名称
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#if HGL_COMPILER == HGL_COMPILER_Microsoft
|
||||
#define hgl_malloc(size) _aligned_malloc(size,HGL_MEM_ALIGN)
|
||||
#define hgl_realloc(ptr,size) _aligned_realloc(ptr,size,HGL_MEM_ALIGN)
|
||||
#define hgl_free _aligned_free
|
||||
|
||||
template<typename T>
|
||||
inline T *hgl_aligned_malloc(size_t n)
|
||||
{
|
||||
return (T *)_aligned_malloc(n*sizeof(T),alignof(T));
|
||||
}
|
||||
#else
|
||||
#define hgl_malloc(size) memalign(HGL_MEM_ALIGN,size)
|
||||
#define hgl_realloc(ptr,size) realloc(ptr,size)
|
||||
#define hgl_free free
|
||||
#endif//
|
||||
|
||||
#define OS_EXTERNAL_H <winbase.h>
|
||||
typedef HMODULE ExternalModulePointer;
|
||||
#define pi_get GetProcAddress
|
||||
#define pi_close FreeLibrary
|
||||
|
||||
#define struct_stat64 struct _stat64
|
||||
//#define hgl_stat64 _stat64
|
||||
#define hgl_lseek64 _lseeki64
|
||||
#define hgl_tell64(fp) _telli64(fp)
|
||||
#define hgl_fstat64 _fstati64
|
||||
#define hgl_lstat64 _wstat64
|
||||
#define hgl_read64 _read
|
||||
#define hgl_write64 _write
|
||||
|
||||
using hgl_thread_mutex =CRITICAL_SECTION;
|
||||
using thread_ptr =HANDLE;
|
||||
#define THREAD_FUNC DWORD WINAPI
|
||||
#define HGL_THREAD_DETACH_SELF
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_OS_WIN_INCLUDE
|
78
inc/hgl/platform/os/MacOS.h
Normal file
78
inc/hgl/platform/os/MacOS.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef HGL_OS_MACOS_INCLUDE
|
||||
#define HGL_OS_MACOS_INCLUDE
|
||||
|
||||
#include<dirent.h>
|
||||
//------------------------------------------------------------------
|
||||
using u32char =char32_t;
|
||||
using u16char =char16_t;
|
||||
using os_char =char;
|
||||
#define to_oschar to_u8
|
||||
#define OS_TEXT(str) u8##str
|
||||
#define U8_TEXT(str) u8##str
|
||||
#define U16_TEXT(str) u##str
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#if HGL_OS == HGL_OS_iOS
|
||||
#define HGL_OS_NAME OS_TEXT("iOS")
|
||||
#define HGL_LIB_OS "iOS" //库操作系统前缀
|
||||
#else
|
||||
#define HGL_OS_NAME OS_TEXT("macOS")
|
||||
#define HGL_LIB_OS "mac" //库操作系统前缀
|
||||
#endif//HGL_OS == HGL_OS_iOS
|
||||
|
||||
#define HGL_PLUGIN_FRONTNAME "libCMP." //插件文件名前缀
|
||||
#define HGL_PLUGIN_EXTNAME OS_TEXT(".dylib") //插件文件扩展名
|
||||
#define HGL_PLUGIN_FUNC extern "C" //插件函数定义
|
||||
|
||||
#define HGL_DIRECTORY_SEPARATOR '/' //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_STR OS_TEXT("/") //目录分隔符
|
||||
#define HGL_DIRECTORY_SEPARATOR_U8STR U8_TEXT("/") //目录分隔符
|
||||
|
||||
#define HGL_LINE_END "\n" //换行符
|
||||
#define HGL_LINE_END_SIZE 1 //换行符长度
|
||||
|
||||
#define HGL_MEM_ALIGN 16 //内存对齐字节数
|
||||
|
||||
#define HGL_MAX_PATH __DARWIN_MAXPATHLEN
|
||||
|
||||
#define HGL_FMT_I64 "%lld"
|
||||
#define HGL_FMT_U64 "%llu"
|
||||
#define HGL_FMT_DOUBLE "%lf"
|
||||
#define HGL_FMT_LONG_DOUBLE "%le"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#include<hgl/platform/os/PosixThread.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
#define hgl_malloc(size) malloc(size)
|
||||
#define hgl_realloc(ptr,size) realloc(ptr,size)
|
||||
#define hgl_free free
|
||||
|
||||
template<typename T>
|
||||
inline T *hgl_aligned_malloc(size_t n)
|
||||
{
|
||||
return (T *)hgl_malloc(n*sizeof(T));
|
||||
}
|
||||
|
||||
#define OS_EXTERNAL_H <dlfcn.h>
|
||||
using ExternalModulePointer=void *;
|
||||
#define pi_get dlsym
|
||||
#define pi_close dlclose
|
||||
|
||||
#define hgl_stat64 stat
|
||||
#define hgl_open64 open
|
||||
#define hgl_lseek64 lseek
|
||||
#define hgl_tell64(fp) lseek(fp,0,SEEK_CUR)
|
||||
#define hgl_fstat64 fstat
|
||||
#define hgl_lstat64 lstat
|
||||
#define hgl_read64 read
|
||||
#define hgl_write64 write
|
||||
#define hgl_pread64 pread
|
||||
#define hgl_pwrite64 pwrite
|
||||
|
||||
#define struct_stat64 struct stat
|
||||
#define struct_dirent64 struct dirent
|
||||
#define hgl_dirent64 dirent
|
||||
#define hgl_readdir64 readdir
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#endif//HGL_OS_MACOS_INCLUDE
|
15
inc/hgl/platform/os/PosixThread.h
Normal file
15
inc/hgl/platform/os/PosixThread.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef HGL_POSIX_THREAD_INCLUDE
|
||||
#define HGL_POSIX_THREAD_INCLUDE
|
||||
|
||||
#include<pthread.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
using hgl_thread_mutex =pthread_mutex_t;
|
||||
|
||||
using thread_ptr =pthread_t;
|
||||
using THREAD_FUNC =void *;
|
||||
|
||||
#define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self());
|
||||
}//namespace hgl
|
||||
#endif//HGL_POSIX_THREAD_INCLUDE
|
Reference in New Issue
Block a user