30 #ifndef PXR_BASE_TF_STATIC_TOKENS_H
31 #define PXR_BASE_TF_STATIC_TOKENS_H
85 #include <hboost/preprocessor/seq/enum.hpp>
86 #include <hboost/preprocessor/seq/filter.hpp>
87 #include <hboost/preprocessor/seq/for_each.hpp>
95 #define _TF_DECLARE_PUBLIC_TOKENS3(key, eiapi, seq) \
96 _TF_DECLARE_TOKENS3(key, seq, eiapi) \
97 extern eiapi TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
98 #define _TF_DECLARE_PUBLIC_TOKENS2(key, seq) \
99 _TF_DECLARE_TOKENS2(key, seq) \
100 extern TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
101 #define _TF_DECLARE_PUBLIC_TOKENS(N) _TF_DECLARE_PUBLIC_TOKENS##N
102 #define _TF_DECLARE_PUBLIC_TOKENS_EVAL(N) _TF_DECLARE_PUBLIC_TOKENS(N)
103 #define _TF_DECLARE_PUBLIC_TOKENS_EXPAND(x) x
108 #define TF_DECLARE_PUBLIC_TOKENS(...) _TF_DECLARE_PUBLIC_TOKENS_EXPAND( _TF_DECLARE_PUBLIC_TOKENS_EVAL(_TF_DECLARE_PUBLIC_TOKENS_EXPAND( TF_PP_VARIADIC_SIZE(__VA_ARGS__) ))(__VA_ARGS__) )
113 #define TF_DEFINE_PUBLIC_TOKENS(key, seq) \
114 _TF_DEFINE_TOKENS(key) \
115 TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
119 #define TF_DEFINE_PRIVATE_TOKENS(key, seq) \
121 struct _TF_TOKENS_STRUCT_NAME_PRIVATE(key) { \
122 _TF_TOKENS_STRUCT_NAME_PRIVATE(key)() = default; \
123 _TF_TOKENS_DECLARE_MEMBERS(seq) \
126 static TfStaticData<_TF_TOKENS_STRUCT_NAME_PRIVATE(key)> key
135 #define _TF_TOKENS_STRUCT_NAME_PRIVATE(key) \
136 TF_PP_CAT(key, _PrivateStaticTokenType)
142 #define _TF_TOKENS_STRUCT_NAME(key) \
143 TF_PP_CAT(key, _StaticTokenType)
151 #define _TF_TOKENS_DECLARE_MEMBER(unused, elem) \
152 TfToken _TF_PP_IFF(TF_PP_IS_TUPLE(elem), \
153 TF_PP_TUPLE_ELEM(0, elem), elem){ \
154 _TF_PP_IFF(TF_PP_IS_TUPLE(elem), \
155 TF_PP_TUPLE_ELEM(1, elem), TF_PP_STRINGIZE(elem)), \
157 #define _TF_TOKENS_DECLARE_TOKEN_MEMBERS(seq) \
158 TF_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_MEMBER, ~, seq)
160 #define _TF_TOKENS_FORWARD_ARRAY(elem) TF_PP_TUPLE_ELEM(0, elem),
161 #define _TF_TOKENS_DECLARE_ARRAY_MEMBER_IMPL(identifier, ...) \
162 TfToken identifier[TF_PP_VARIADIC_SIZE(__VA_ARGS__)] = { \
163 TF_PP_FOR_EACH(_TF_TOKENS_FORWARD_ARRAY, __VA_ARGS__)};
164 #define _TF_TOKENS_DECLARE_ARRAY_MEMBER(r, data, elem) \
165 _TF_TOKENS_DECLARE_ARRAY_MEMBER_IMPL( \
166 TF_PP_TUPLE_ELEM(0, elem), \
167 HBOOST_PP_SEQ_ENUM(TF_PP_EAT_PARENS(TF_PP_TUPLE_ELEM(1, elem))))
168 #define _TF_TOKENS_DECLARE_ARRAY_MEMBERS(seq) \
169 HBOOST_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_ARRAY_MEMBER, ~, seq)
171 #define _TF_TOKENS_FORWARD_TOKEN(unused, elem) TF_PP_TUPLE_ELEM(0, elem),
172 #define _TF_TOKENS_DECLARE_ALL_TOKENS(seq) \
173 std::vector<TfToken> allTokens = \
174 {TF_PP_SEQ_FOR_EACH(_TF_TOKENS_FORWARD_TOKEN, ~, seq)};
178 #define _TF_TOKENS_DECLARE_MEMBERS(seq) \
179 _TF_TOKENS_DECLARE_TOKEN_MEMBERS( \
180 HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_NOT_ARRAY, ~, seq) \
181 _TF_TOKENS_EXPAND_ARRAY_ELEMENTS(seq) \
183 _TF_TOKENS_DECLARE_ARRAY_MEMBERS( \
184 HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_ARRAY, ~, seq)) \
185 _TF_TOKENS_DECLARE_ALL_TOKENS( \
186 HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_NOT_ARRAY, ~, seq) \
187 _TF_TOKENS_EXPAND_ARRAY_ELEMENTS(seq) \
193 #define _TF_TOKENS_EXPAND_ARRAY_ELEMENTS(seq) \
194 HBOOST_PP_SEQ_FOR_EACH(_TF_TOKENS_APPEND_ARRAY_ELEMENTS, \
196 HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_ARRAY, ~, seq)) \
200 #define _TF_DECLARE_TOKENS3(key, seq, eiapi) \
201 struct _TF_TOKENS_STRUCT_NAME(key) { \
202 eiapi _TF_TOKENS_STRUCT_NAME(key)(); \
203 eiapi ~_TF_TOKENS_STRUCT_NAME(key)(); \
204 _TF_TOKENS_DECLARE_MEMBERS(seq) \
207 #define _TF_DECLARE_TOKENS2(key, seq) \
208 struct _TF_TOKENS_STRUCT_NAME(key) { \
209 _TF_TOKENS_STRUCT_NAME(key)(); \
210 ~_TF_TOKENS_STRUCT_NAME(key)(); \
211 _TF_TOKENS_DECLARE_MEMBERS(seq) \
220 #define _TF_TOKENS_IS_ARRAY(s, data, elem) \
221 _TF_PP_IFF(TF_PP_IS_TUPLE(elem), \
222 TF_PP_IS_TUPLE(TF_PP_TUPLE_ELEM(1, elem)), 0)
224 #define _TF_TOKENS_IS_NOT_ARRAY(s, data, elem) \
225 _TF_PP_IFF(_TF_TOKENS_IS_ARRAY(s, data, elem), 0, 1)
229 #define _TF_TOKENS_APPEND_ARRAY_ELEMENTS(r, data, elem) \
230 TF_PP_TUPLE_ELEM(0, TF_PP_TUPLE_ELEM(1, elem))
237 #define _TF_DEFINE_TOKENS(key) \
238 _TF_TOKENS_STRUCT_NAME(key)::~_TF_TOKENS_STRUCT_NAME(key)() = default; \
239 _TF_TOKENS_STRUCT_NAME(key)::_TF_TOKENS_STRUCT_NAME(key)() = default; \
243 #endif // PXR_BASE_TF_STATIC_TOKENS_H
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE