#define SET_ACCESSOR( x, y ) inline void Set##y( x t ) { DXUTLock l; m_state.m_##y = t; };
#define GET_ACCESSOR( x, y ) inline x Get##y() { DXUTLock l; return m_state.m_##y; };
#define GET_SET_ACCESSOR( x, y ) SET_ACCESSOR( x, y ) GET_ACCESSOR( x, y )
GET_SET_ACCESSOR( IDirect3D9*, D3D );
最終被替換成什麼了呢???
1:
SET_ACCESSOR( IDirect3D9*, D3D ) GET_ACCESSOR( IDirect3D9*, D3D )
進一步,替換:
2:
inline void Set##D3D( IDirect3D9*, t ) { DXUTLock l; m_state.m_##D3D = t; };
inline x Get##D3D() { DXUTLock l; return m_state.m_##D3D; };
3:去掉##,
inline void SetD3D( IDirect3D9* t ) { DXUTLock l; m_state.m_D3D = t; };
inline IDirect3D9* GetD3D() { DXUTLock l; return m_state.m_D3D; };
最終,宏變成了兩個函數的定義