-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapTokens.cpp
58 lines (50 loc) · 1.82 KB
/
wrapTokens.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Copyright 2016 Pixar
//
// Licensed under the terms set forth in the LICENSE.txt file available at
// https://openusd.org/license.
//
// GENERATED FILE. DO NOT EDIT.
#include <boost/python/class.hpp>
#include "./tokens.h"
PXR_NAMESPACE_USING_DIRECTIVE
namespace {
// Helper to return a static token as a string. We wrap tokens as Python
// strings and for some reason simply wrapping the token using def_readonly
// bypasses to-Python conversion, leading to the error that there's no
// Python type for the C++ TfToken type. So we wrap this functor instead.
class _WrapStaticToken {
public:
_WrapStaticToken(const TfToken* token) : _token(token) { }
std::string operator()() const
{
return _token->GetString();
}
private:
const TfToken* _token;
};
template <typename T>
void
_AddToken(T& cls, const char* name, const TfToken& token)
{
cls.add_static_property(name,
boost::python::make_function(
_WrapStaticToken(&token),
boost::python::return_value_policy<
boost::python::return_by_value>(),
boost::mpl::vector1<std::string>()));
}
} // anonymous
void wrapUsdGrassTokens()
{
boost::python::class_<UsdGrassTokensType, boost::noncopyable>
cls("Tokens", boost::python::no_init);
_AddToken(cls, "color", UsdGrassTokens->color);
_AddToken(cls, "extent", UsdGrassTokens->extent);
_AddToken(cls, "height", UsdGrassTokens->height);
_AddToken(cls, "heightPos", UsdGrassTokens->heightPos);
_AddToken(cls, "horizontalStretch", UsdGrassTokens->horizontalStretch);
_AddToken(cls, "radius", UsdGrassTokens->radius);
_AddToken(cls, "thinning", UsdGrassTokens->thinning);
_AddToken(cls, "Grass", UsdGrassTokens->Grass);
}