Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused tf/preprocessorUtils.h dependency #2535

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pxr/base/tf/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "pxr/base/arch/defines.h"
#include "pxr/base/arch/demangle.h"
#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/preprocessorUtilsLite.h"
#include "pxr/base/tf/safeTypeCompare.h"
#include "pxr/base/tf/api.h"
Expand Down
75 changes: 0 additions & 75 deletions pxr/base/tf/preprocessorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,81 +109,6 @@ ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
_TF_NUM_ARGS_REP, _TF))
#endif


/// Return the arguments as is except if the first argument starts with a
/// matched parenthesis then remove those parentheses.
/// \ingroup group_tf_Preprocessor
/// \hideinitializer
//
// If the arguments satisfy _TF_PP_EAT_PARENS_IS_PARENS() then we expand to
// _TF_PP_EAT_PARENS_EXPAND1, otherwise to _TF_PP_EAT_PARENS_EXPAND. The
// former eats the parentheses while the latter passes the arguments
// unchanged.
//
// We add the ~ after the first __VA_ARGS__ in case there are zero
// arguments. MSVC will complain about insufficient arguments otherwise.
// The ~ will be discarded in any case.
#define TF_PP_EAT_PARENS(...) \
_TF_PP_EAT_PARENS_IFF(_TF_PP_EAT_PARENS_IS_PARENS(__VA_ARGS__ ~),\
_TF_PP_EAT_PARENS_EXPAND1,_TF_PP_EAT_PARENS_EXPAND)(__VA_ARGS__)

/// Expand the arguments and make the result a string.
// We can't use
// BOOST_PP_STRINGIZE because on MSVC passing no arguments will report "not
// enough actual parameters" and yield nothing. We want no warnings and an
// empty string. We do that by passing an unused first argument to the inner
// macro (we need an inner macro to cause expansion). This causes MSVC to
// yield "" for an empty __VA_ARGS__ list.
#define TF_PP_EAT_PARENS_STR(...) _TF_PP_EAT_PARENS_STR2(~, __VA_ARGS__)
#define _TF_PP_EAT_PARENS_STR2(x, ...) #__VA_ARGS__

// Expands to the second argument if c is 1 and the third argument if c is
// 0. No other values of c are allowed. We can't use BOOST_PP_IFF() because
// it won't expand during stringizing under MSVC.
#define _TF_PP_EAT_PARENS_IFF(c, t, f) \
BOOST_PP_CAT(_TF_PP_EAT_PARENS_IFF_, c)(t, f)
#define _TF_PP_EAT_PARENS_IFF_0(t, f) f
#define _TF_PP_EAT_PARENS_IFF_1(t, f) t

// Force expansion of the arguments.
#define _TF_PP_EAT_PARENS_EXPAND(...) __VA_ARGS__

// Similar to expand except it will eat the first matching pair of
// parentheses. For example, _TF_PP_EAT_PARENS_EXPAND1((x)(y)) yields x(y).
// The outer _TF_PP_EAT_PARENS_EXPAND() is needed for MSVC, which otherwise
// would stringizing to "_TF_PP_EAT_PARENS_EXPAND " plus the literal
// substitution of the arguments.
#define _TF_PP_EAT_PARENS_EXPAND1(...) \
_TF_PP_EAT_PARENS_EXPAND(_TF_PP_EAT_PARENS_EXPAND __VA_ARGS__)

// This works around a MSVC bug. When a macro expands to FOO(__VA_ARGS__,bar),
// MSVC will separate the arguments of __VA_ARGS__ even if they're inside
// matching parentheses. So, for example, if __VA_ARGS__ is (x,y) then we'll
// expand to FOO(x,y,bar) instead of FOO((x,y),bar). This macro works around
// that. Use: _TF_PP_EAT_PARENS_CALL(FOO,(__VA_ARGS__,bar)).
//
// We need the _TF_PP_EAT_PARENS_EXPAND() here otherwise stringizing will
// stringize the literal replacements, not the result of the expansion of x y.
// If FOO(x,y) expands to x+y then we'd get "FOO ((x,y),bar)" without
// _TF_PP_EAT_PARENS_EXPAND() instead of the correct "(x,y)+bar".
#define _TF_PP_EAT_PARENS_CALL(x, y) _TF_PP_EAT_PARENS_EXPAND(x y)

// Expands to 1 if x starts with a matched parenthesis, otherwise expands to
// 0. "_TF_PP_EAT_PARENS_IS_PARENS2 x" eats the parentheses if they exist and
// expands to "x, 1,", otherwise it expands to _TF_PP_EAT_PARENS_IS_PARENS2
// and the literal expansion of x. This result goes to
// _TF_PP_EAT_PARENS_IS_PARENS_CHECK_N() which extracts the 1 expanded from
// _TF_PP_EAT_PARENS_IS_PARENS2 or a 0 passed as a final argument. In either
// case the desired result is the second argument to
// _TF_PP_EAT_PARENS_IS_PARENS_CHECK_N.
#define _TF_PP_EAT_PARENS_IS_PARENS(x) \
_TF_PP_EAT_PARENS_IS_PARENS_CHECK(_TF_PP_EAT_PARENS_IS_PARENS2 x)
#define _TF_PP_EAT_PARENS_IS_PARENS_CHECK(...) \
_TF_PP_EAT_PARENS_CALL(_TF_PP_EAT_PARENS_IS_PARENS_CHECK_N,(__VA_ARGS__,0,))
#define _TF_PP_EAT_PARENS_IS_PARENS_CHECK_N(x, n, ...) n
#define _TF_PP_EAT_PARENS_IS_PARENS_TRUE(x) x, 1,
#define _TF_PP_EAT_PARENS_IS_PARENS2(...) _TF_PP_EAT_PARENS_IS_PARENS_TRUE(~)

/// Exapnds to 1 if the argument is a tuple, and 0 otherwise.
/// \ingroup group_tf_Preprocessor
/// \hideinitializer
Expand Down
74 changes: 74 additions & 0 deletions pxr/base/tf/preprocessorUtilsLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,78 @@

#endif

/// Return the arguments as is except if the first argument starts with a
/// matched parenthesis then remove those parentheses.
/// \ingroup group_tf_Preprocessor
/// \hideinitializer
//
// If the arguments satisfy _TF_PP_EAT_PARENS_IS_PARENS() then we expand to
// _TF_PP_EAT_PARENS_EXPAND1, otherwise to _TF_PP_EAT_PARENS_EXPAND. The
// former eats the parentheses while the latter passes the arguments
// unchanged.
//
// We add the ~ after the first __VA_ARGS__ in case there are zero
// arguments. MSVC will complain about insufficient arguments otherwise.
// The ~ will be discarded in any case.
#define TF_PP_EAT_PARENS(...) \
_TF_PP_EAT_PARENS_IFF(_TF_PP_EAT_PARENS_IS_PARENS(__VA_ARGS__ ~),\
_TF_PP_EAT_PARENS_EXPAND1,_TF_PP_EAT_PARENS_EXPAND)(__VA_ARGS__)

/// Expand the arguments and make the result a string.
// We can't use
// BOOST_PP_STRINGIZE because on MSVC passing no arguments will report "not
// enough actual parameters" and yield nothing. We want no warnings and an
// empty string. We do that by passing an unused first argument to the inner
// macro (we need an inner macro to cause expansion). This causes MSVC to
// yield "" for an empty __VA_ARGS__ list.
#define TF_PP_EAT_PARENS_STR(...) _TF_PP_EAT_PARENS_STR2(~, __VA_ARGS__)
#define _TF_PP_EAT_PARENS_STR2(x, ...) #__VA_ARGS__

// Expands to the second argument if c is 1 and the third argument if c is
// 0. No other values of c are allowed. We can't use BOOST_PP_IFF() because
// it won't expand during stringizing under MSVC.
#define _TF_PP_EAT_PARENS_IFF(c, t, f) \
TF_PP_CAT(_TF_PP_EAT_PARENS_IFF_, c)(t, f)
#define _TF_PP_EAT_PARENS_IFF_0(t, f) f
#define _TF_PP_EAT_PARENS_IFF_1(t, f) t

// Force expansion of the arguments.
#define _TF_PP_EAT_PARENS_EXPAND(...) __VA_ARGS__

// Similar to expand except it will eat the first matching pair of
// parentheses. For example, _TF_PP_EAT_PARENS_EXPAND1((x)(y)) yields x(y).
// The outer _TF_PP_EAT_PARENS_EXPAND() is needed for MSVC, which otherwise
// would stringizing to "_TF_PP_EAT_PARENS_EXPAND " plus the literal
// substitution of the arguments.
#define _TF_PP_EAT_PARENS_EXPAND1(...) \
_TF_PP_EAT_PARENS_EXPAND(_TF_PP_EAT_PARENS_EXPAND __VA_ARGS__)

// This works around a MSVC bug. When a macro expands to FOO(__VA_ARGS__,bar),
// MSVC will separate the arguments of __VA_ARGS__ even if they're inside
// matching parentheses. So, for example, if __VA_ARGS__ is (x,y) then we'll
// expand to FOO(x,y,bar) instead of FOO((x,y),bar). This macro works around
// that. Use: _TF_PP_EAT_PARENS_CALL(FOO,(__VA_ARGS__,bar)).
//
// We need the _TF_PP_EAT_PARENS_EXPAND() here otherwise stringizing will
// stringize the literal replacements, not the result of the expansion of x y.
// If FOO(x,y) expands to x+y then we'd get "FOO ((x,y),bar)" without
// _TF_PP_EAT_PARENS_EXPAND() instead of the correct "(x,y)+bar".
#define _TF_PP_EAT_PARENS_CALL(x, y) _TF_PP_EAT_PARENS_EXPAND(x y)

// Expands to 1 if x starts with a matched parenthesis, otherwise expands to
// 0. "_TF_PP_EAT_PARENS_IS_PARENS2 x" eats the parentheses if they exist and
// expands to "x, 1,", otherwise it expands to _TF_PP_EAT_PARENS_IS_PARENS2
// and the literal expansion of x. This result goes to
// _TF_PP_EAT_PARENS_IS_PARENS_CHECK_N() which extracts the 1 expanded from
// _TF_PP_EAT_PARENS_IS_PARENS2 or a 0 passed as a final argument. In either
// case the desired result is the second argument to
// _TF_PP_EAT_PARENS_IS_PARENS_CHECK_N.
#define _TF_PP_EAT_PARENS_IS_PARENS(x) \
_TF_PP_EAT_PARENS_IS_PARENS_CHECK(_TF_PP_EAT_PARENS_IS_PARENS2 x)
#define _TF_PP_EAT_PARENS_IS_PARENS_CHECK(...) \
_TF_PP_EAT_PARENS_CALL(_TF_PP_EAT_PARENS_IS_PARENS_CHECK_N,(__VA_ARGS__,0,))
#define _TF_PP_EAT_PARENS_IS_PARENS_CHECK_N(x, n, ...) n
#define _TF_PP_EAT_PARENS_IS_PARENS_TRUE(x) x, 1,
#define _TF_PP_EAT_PARENS_IS_PARENS2(...) _TF_PP_EAT_PARENS_IS_PARENS_TRUE(~)

#endif // PXR_BASE_TF_PREPROCESSOR_UTILS_LITE_H
1 change: 0 additions & 1 deletion pxr/base/tf/scopeDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "pxr/pxr.h"

#include "pxr/base/tf/callContext.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/stringUtils.h"
#include "pxr/base/tf/api.h"

Expand Down
1 change: 0 additions & 1 deletion pxr/base/tf/staticData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "pxr/pxr.h"
#include "pxr/base/arch/hints.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/preprocessorUtilsLite.h"

#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion pxr/base/tf/testenv/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "pxr/base/tf/functionTraits.h"
#include "pxr/base/tf/meta.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/preprocessorUtilsLite.h"

#include <string>
#include <tuple>
Expand Down
2 changes: 1 addition & 1 deletion pxr/base/vt/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "pxr/pxr.h"
#include "pxr/base/vt/api.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/preprocessorUtilsLite.h"

#include <boost/type_traits/has_trivial_assign.hpp>

Expand Down
1 change: 0 additions & 1 deletion pxr/usd/sdf/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#include "pxr/base/gf/vec4h.h"
#include "pxr/base/gf/vec4i.h"
#include "pxr/base/tf/enum.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/staticTokens.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
Expand Down