Skip to content

Commit 01be067

Browse files
committed
Make static TfToken macros usable outside of PXR_NS
1 parent 434dfd5 commit 01be067

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

pxr/base/tf/pyStaticTokens.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ PXR_NAMESPACE_OPEN_SCOPE
2828
///
2929
/// \hideinitializer
3030
#define TF_PY_WRAP_PUBLIC_TOKENS(name, key, seq) \
31-
pxr_boost::python::class_< \
32-
_TF_TOKENS_STRUCT_NAME(key), pxr_boost::python::noncopyable>( \
33-
name, pxr_boost::python::no_init) \
31+
PXR_NS::pxr_boost::python::class_< \
32+
_TF_TOKENS_STRUCT_NAME(key), \
33+
PXR_NS::pxr_boost::python::noncopyable>( \
34+
name, PXR_NS::pxr_boost::python::no_init) \
3435
_TF_PY_TOKENS_WRAP_SEQ(key, seq)
3536

3637
/// Macro to wrap static tokens defined with \c TF_DEFINE_PUBLIC_TOKENS to
@@ -43,7 +44,7 @@ PXR_NAMESPACE_OPEN_SCOPE
4344

4445
// Private macros to add a single data member.
4546
#define _TF_PY_TOKENS_WRAP_ATTR_MEMBER(r, key, name) \
46-
pxr_boost::python::scope().attr( \
47+
PXR_NS::pxr_boost::python::scope().attr( \
4748
TF_PP_STRINGIZE(name)) = key->name.GetString();
4849

4950
// We wrap tokens as Python strings, but simply wrapping the token using

pxr/base/tf/staticTokens.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ PXR_NAMESPACE_OPEN_SCOPE
6868

6969
#define _TF_DECLARE_PUBLIC_TOKENS3(key, eiapi, seq) \
7070
_TF_DECLARE_TOKENS3(key, seq, eiapi) \
71-
extern eiapi TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
71+
extern eiapi PXR_NS::TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
7272
#define _TF_DECLARE_PUBLIC_TOKENS2(key, seq) \
7373
_TF_DECLARE_TOKENS2(key, seq) \
74-
extern TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
74+
extern PXR_NS::TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
7575
#define _TF_DECLARE_PUBLIC_TOKENS(N) _TF_DECLARE_PUBLIC_TOKENS##N
7676
#define _TF_DECLARE_PUBLIC_TOKENS_EVAL(N) _TF_DECLARE_PUBLIC_TOKENS(N)
7777
#define _TF_DECLARE_PUBLIC_TOKENS_EXPAND(x) x
@@ -92,7 +92,7 @@ PXR_NAMESPACE_OPEN_SCOPE
9292
/// \hideinitializer
9393
#define TF_DEFINE_PUBLIC_TOKENS(key, seq) \
9494
_TF_DEFINE_TOKENS(key) \
95-
TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
95+
PXR_NS::TfStaticData<_TF_TOKENS_STRUCT_NAME(key)> key
9696

9797
/// Macro to define private tokens.
9898
/// \hideinitializer
@@ -103,7 +103,7 @@ PXR_NAMESPACE_OPEN_SCOPE
103103
_TF_TOKENS_DECLARE_MEMBERS(seq) \
104104
}; \
105105
} \
106-
static TfStaticData<_TF_TOKENS_STRUCT_NAME_PRIVATE(key)> key
106+
static PXR_NS::TfStaticData<_TF_TOKENS_STRUCT_NAME_PRIVATE(key)> key
107107

108108
///////////////////////////////////////////////////////////////////////////////
109109
// Private Macros
@@ -129,17 +129,17 @@ PXR_NAMESPACE_OPEN_SCOPE
129129
// be a tuple on the form (name, value) or just a name.
130130
//
131131
#define _TF_TOKENS_DECLARE_MEMBER(unused, elem) \
132-
TfToken _TF_PP_IFF(TF_PP_IS_TUPLE(elem), \
132+
PXR_NS::TfToken _TF_PP_IFF(TF_PP_IS_TUPLE(elem), \
133133
TF_PP_TUPLE_ELEM(0, elem), elem){ \
134134
_TF_PP_IFF(TF_PP_IS_TUPLE(elem), \
135135
TF_PP_TUPLE_ELEM(1, elem), TF_PP_STRINGIZE(elem)), \
136-
TfToken::Immortal};
136+
PXR_NS::TfToken::Immortal};
137137
#define _TF_TOKENS_DECLARE_TOKEN_MEMBERS(seq) \
138138
TF_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_MEMBER, ~, seq)
139139

140140
#define _TF_TOKENS_FORWARD_TOKEN(unused, elem) TF_PP_TUPLE_ELEM(0, elem),
141141
#define _TF_TOKENS_DECLARE_ALL_TOKENS(seq) \
142-
std::vector<TfToken> allTokens = \
142+
std::vector<PXR_NS::TfToken> allTokens = \
143143
{TF_PP_SEQ_FOR_EACH(_TF_TOKENS_FORWARD_TOKEN, ~, seq)};
144144

145145
// Private macro used to declare the list of members as TfTokens

pxr/base/tf/wrapTestPyStaticTokens.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@
1010

1111
#include "pxr/base/tf/pyStaticTokens.h"
1212

13-
PXR_NAMESPACE_OPEN_SCOPE
14-
1513
#define TF_TEST_TOKENS \
1614
(orange) \
1715
((pear, "d'Anjou"))
1816

1917
TF_DECLARE_PUBLIC_TOKENS(tfTestStaticTokens, TF_API, TF_TEST_TOKENS);
2018
TF_DEFINE_PUBLIC_TOKENS(tfTestStaticTokens, TF_TEST_TOKENS);
2119

22-
PXR_NAMESPACE_CLOSE_SCOPE
23-
24-
PXR_NAMESPACE_USING_DIRECTIVE
25-
2620
namespace {
2721
struct _DummyScope {
2822
};
@@ -34,9 +28,10 @@ wrapTf_TestPyStaticTokens()
3428
TF_PY_WRAP_PUBLIC_TOKENS("_testStaticTokens",
3529
tfTestStaticTokens, TF_TEST_TOKENS);
3630

37-
pxr_boost::python::class_<_DummyScope, pxr_boost::python::noncopyable>
38-
cls("_TestStaticTokens", pxr_boost::python::no_init);
39-
pxr_boost::python::scope testScope = cls;
31+
PXR_NS::pxr_boost::python::class_<
32+
_DummyScope, PXR_NS::pxr_boost::python::noncopyable>
33+
cls("_TestStaticTokens", PXR_NS::pxr_boost::python::no_init);
34+
PXR_NS::pxr_boost::python::scope testScope = cls;
4035

4136
TF_PY_WRAP_PUBLIC_TOKENS_IN_CURRENT_SCOPE(
4237
tfTestStaticTokens, TF_TEST_TOKENS);

0 commit comments

Comments
 (0)