#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; };
最终,宏变成了两个函数的定义