Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Base - Type.h
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if !defined(TGS_COMMON_BASE_TYPE_H)
#define TGS_COMMON_BASE_TYPE_H
#pragma once

#include "TgS COMMON/TgS Common - Base - Constants.h"
#include "TgS COMMON/TgS Common - Base - Type - Platform.h"


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Types                                                                                                                                                          */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- Standard Types -------------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_PREFIX( TgUINT08 );
TgTYPE_PREFIX( TgUINT16 );
TgTYPE_PREFIX( TgUINT32 );
TgTYPE_PREFIX( TgUINT64 );
TgTYPE_PREFIX( TgSINT08 );
TgTYPE_PREFIX( TgSINT16 );
TgTYPE_PREFIX( TgSINT32 );
TgTYPE_PREFIX( TgSINT64 );
TgTYPE_PREFIX( TgFLOAT32 );
TgTYPE_PREFIX( TgFLOAT64 );
TgTYPE_PREFIX( TgBOOL );
TgTYPE_PREFIX( TgANSICHAR );
TgTYPE_PREFIX( TgWIDECHAR );

typedef void                                TgVOID;
typedef TgVOID*                             P_TgVOID;
typedef TgVOID *const                       PC_TgVOID;
typedef TgVOID * __restrict                 PU_TgVOID;
typedef TgVOID *const __restrict            PCU_TgVOID;
typedef const TgVOID *                      CP_TgVOID;
typedef const TgVOID *const                 CPC_TgVOID;
typedef const TgVOID * __restrict           CPU_TgVOID;
typedef const TgVOID * const __restrict     CPCU_TgVOID;
typedef TgVOID**                            PP_TgVOID;

#if defined(TgCOMPILE_WIDE_CHAR)
    TgTYPE_DECLARE( TgWIDECHAR,                 TgCHAR );
#else
    TgTYPE_DECLARE( TgANSICHAR,                 TgCHAR );
#endif

enum { KTgBYTE_PER_CHAR                     = sizeof(TgCHAR) / sizeof(TgUINT08) };

#if TgCOMPILE_64BIT_POINTER
TgTYPE_DECLARE( TgUINT64,                   TgUINTXX );
#elif TgCOMPILE_32BIT_POINTER
TgTYPE_DECLARE( TgUINT32,                   TgUINTXX );
#else
    #error Unsupported pointer size
#endif


/* ---- Commonly Used Types --------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_DECLARE( TgUINT32,                   TgFILE );
TgTYPE_DECLARE( TgSINT32,                   TgRESULT );

TgTYPE_DECLARE( size_t,                     TgSIZE );
TgTYPE_DECLARE( intptr_t,                   TgSINTPTR );
TgTYPE_DECLARE( uintptr_t,                  TgUINTPTR );
TgTYPE_DECLARE( ptrdiff_t,                  TgPTRDIFF );
TgTYPE_DECLARE( time_t,                     TgTIME );


/* ---- Alias Union ----------------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_UNION(TgSCALAR_ALIAS_UNION,)
{
    TgUINT08                                    m_ui08;
    TgUINT16                                    m_ui16;
    TgUINT32                                    m_ui32;
    TgUINT64                                    m_ui64;
    TgSINT08                                    m_i08;
    TgSINT16                                    m_i16;
    TgSINT32                                    m_i32;
    TgSINT64                                    m_i64;
    TgFLOAT32                                   m_f32;
    TgFLOAT64                                   m_f64;
    TgBOOL                                      m_b;
    TgANSICHAR                                  m_ac;
    TgWIDECHAR                                  m_uc;
    TgUINTPTR                                   m_uiPTR;
    TgSINTPTR                                   m_iPTR;
};

TgTYPE_UNION(TgSCALAR_P_ALIAS_UNION,)
{
    P_TgUINT08                                  m_pui08;
    P_TgUINT16                                  m_pui16;
    P_TgUINT32                                  m_pui32;
    P_TgUINT64                                  m_pui64;
    P_TgSINT08                                  m_pi08;
    P_TgSINT16                                  m_pi16;
    P_TgSINT32                                  m_pi32;
    P_TgSINT64                                  m_pi64;
    P_TgFLOAT32                                 m_pf32;
    P_TgFLOAT64                                 m_pf64;
    P_TgBOOL                                    m_pb;
    P_TgANSICHAR                                m_pac;
    P_TgWIDECHAR                                m_puc;
    P_TgVOID                                    m_p;
    P_TgUINTPTR                                 m_puiPTR;
    P_TgSINTPTR                                 m_piPTR;
    TgUINTPTR                                   m_uiPTR;
    TgSINTPTR                                   m_iPTR;
};

TgTYPE_UNION( TgCOLOUR32, )
{
    TgUINT32                                    m_uiColour;
    struct { TgUINT08                           uiRed,uiGreen,uiBlue,uiAlpha; } m;
};


/* ---- Bitfields ------------------------------------------------------------------------------------------------------------------------------------------------------- */

TgINLINE TgVOID                             tgBF_Set_Flag_U08( PCU_TgUINT08, C_TgUINT32, C_TgBOOL );
TgINLINE TgVOID                             tgBF_Toggle_Flag_U08( PCU_TgUINT08, C_TgUINT32 );
TgINLINE TgBOOL                             tgBF_Query_Flag_U08( CPCU_TgUINT08, C_TgUINT32 );
TgINLINE TgVOID                             tgBF_Reset_U08( PCU_TgUINT08 );

TgINLINE TgVOID                             tgBF_Set_Flag_U16( PCU_TgUINT16, C_TgUINT32, C_TgBOOL );
TgINLINE TgVOID                             tgBF_Toggle_Flag_U16( PCU_TgUINT16, C_TgUINT32 );
TgINLINE TgBOOL                             tgBF_Query_Flag_U16( CPCU_TgUINT16, C_TgUINT32 );
TgINLINE TgVOID                             tgBF_Reset_U16( PCU_TgUINT16 );

TgINLINE TgVOID                             tgBF_Set_Flag_U32( PCU_TgUINT32, C_TgUINT32, C_TgBOOL );
TgINLINE TgVOID                             tgBF_Toggle_Flag_U32( PCU_TgUINT32, C_TgUINT32 );
TgINLINE TgBOOL                             tgBF_Query_Flag_U32( CPCU_TgUINT32, C_TgUINT32 );
TgINLINE TgVOID                             tgBF_Reset_U32( PCU_TgUINT32 );

TgINLINE TgVOID                             tgBF_Set_Flag_U64( PCU_TgUINT64, C_TgUINT32, C_TgBOOL );
TgINLINE TgVOID                             tgBF_Toggle_Flag_U64( PCU_TgUINT64, C_TgUINT32 );
TgINLINE TgBOOL                             tgBF_Query_Flag_U64( CPCU_TgUINT64, C_TgUINT32 );
TgINLINE TgVOID                             tgBF_Reset_U64( PCU_TgUINT64 );

TgINLINE TgVOID                             tgBF_Set_Flag_UXX( PCU_TgUINTXX, C_TgUINT32, C_TgBOOL );
TgINLINE TgVOID                             tgBF_Toggle_Flag_UXX( PCU_TgUINTXX, C_TgUINT32 );
TgINLINE TgBOOL                             tgBF_Query_Flag_UXX( CPCU_TgUINTXX, C_TgUINT32 );
TgINLINE TgVOID                             tgBF_Reset_UXX( PCU_TgUINTXX );


/* ---- TgS Functions --------------------------------------------------------------------------------------------------------------------------------------------------- */

typedef TgUINT32( *TgPLATFORM_THREAD_FCN )( C_TgUINTPTR );
TgTYPE_PREFIX( TgPLATFORM_THREAD_FCN );

typedef TgVOID( *TgFCN_MEM_FREE )( PC_TgVOID );
TgTYPE_PREFIX( TgFCN_MEM_FREE );


/* ====================================================================================================================================================================== */
#endif