Skip to content

Commit d54e1a3

Browse files
committed
Change enums to namespace for tab-completion
1 parent c21e82d commit d54e1a3

File tree

3 files changed

+358
-326
lines changed

3 files changed

+358
-326
lines changed

js/scripts/templates/py_enums.mustache

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@ This file auto-generated with {{ generatorScriptName }}
33
Date: {{ now }}
44
"""
55

6+
class EnumNamespace:
7+
"""A collection of enum values.
8+
9+
This collection can be used as specification to traitlets.Enum
10+
as it supports the `in` operator, and also supports tab completion
11+
as the values are attributes.
12+
"""
13+
def __init__(self, **kwargs):
14+
self.__dict__.update(kwargs)
15+
16+
def __contains__(self, key):
17+
return key in self.__dict__
18+
19+
def __repr__(self):
20+
return str(list(filter(lambda e: not e.startswith('_'), dir(self))))
21+
622
{{#each categories as |category|}}
723

8-
{{ category.key }} = [
24+
{{ category.key }} = EnumNamespace(
925
{{#each category.enums as |enumKey|}}
10-
'{{ enumKey }}',
26+
{{ enumKey }}='{{ enumKey }}',
27+
{{/each}}
28+
)
1129
{{/each}}
12-
]
13-
{{/each}}

js/src/_base/enums.js

Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,204 +1,204 @@
11
//
22
// This file auto-generated with generate-enums.js
3-
// Date: Fri Jun 02 2017 16:44:47 GMT+0200 (W. Europe Daylight Time)
3+
// Date: Wed Nov 15 2017 17:14:48 GMT+0100 (W. Europe Standard Time)
44
//
55

66

77
var Equations = {
8-
100: "AddEquation",
9-
101: "SubtractEquation",
10-
102: "ReverseSubtractEquation",
11-
103: "MinEquation",
12-
104: "MaxEquation",
8+
100: 'AddEquation',
9+
101: 'SubtractEquation',
10+
102: 'ReverseSubtractEquation',
11+
103: 'MinEquation',
12+
104: 'MaxEquation',
1313
};
1414

1515
var BlendFactors = {
16-
200: "ZeroFactor",
17-
201: "OneFactor",
18-
202: "SrcColorFactor",
19-
203: "OneMinusSrcColorFactor",
20-
204: "SrcAlphaFactor",
21-
205: "OneMinusSrcAlphaFactor",
22-
206: "DstAlphaFactor",
23-
207: "OneMinusDstAlphaFactor",
24-
208: "DstColorFactor",
25-
209: "OneMinusDstColorFactor",
26-
210: "SrcAlphaSaturateFactor",
16+
200: 'ZeroFactor',
17+
201: 'OneFactor',
18+
202: 'SrcColorFactor',
19+
203: 'OneMinusSrcColorFactor',
20+
204: 'SrcAlphaFactor',
21+
205: 'OneMinusSrcAlphaFactor',
22+
206: 'DstAlphaFactor',
23+
207: 'OneMinusDstAlphaFactor',
24+
208: 'DstColorFactor',
25+
209: 'OneMinusDstColorFactor',
26+
210: 'SrcAlphaSaturateFactor',
2727
};
2828

2929
var Side = {
30-
0: "FrontSide",
31-
1: "BackSide",
32-
2: "DoubleSide",
30+
0: 'FrontSide',
31+
1: 'BackSide',
32+
2: 'DoubleSide',
3333
};
3434

3535
var Shading = {
36-
1: "FlatShading",
37-
2: "SmoothShading",
36+
1: 'FlatShading',
37+
2: 'SmoothShading',
3838
};
3939

4040
var Colors = {
41-
0: "NoColors",
42-
1: "FaceColors",
43-
2: "VertexColors",
41+
0: 'NoColors',
42+
1: 'FaceColors',
43+
2: 'VertexColors',
4444
};
4545

4646
var BlendingMode = {
47-
0: "NoBlending",
48-
1: "NormalBlending",
49-
2: "AdditiveBlending",
50-
3: "SubtractiveBlending",
51-
4: "MultiplyBlending",
52-
5: "CustomBlending",
47+
0: 'NoBlending',
48+
1: 'NormalBlending',
49+
2: 'AdditiveBlending',
50+
3: 'SubtractiveBlending',
51+
4: 'MultiplyBlending',
52+
5: 'CustomBlending',
5353
};
5454

5555
var DepthMode = {
56-
0: "NeverDepth",
57-
1: "AlwaysDepth",
58-
2: "LessDepth",
59-
3: "LessEqualDepth",
60-
4: "EqualDepth",
61-
5: "GreaterEqualDepth",
62-
6: "GreaterDepth",
63-
7: "NotEqualDepth",
56+
0: 'NeverDepth',
57+
1: 'AlwaysDepth',
58+
2: 'LessDepth',
59+
3: 'LessEqualDepth',
60+
4: 'EqualDepth',
61+
5: 'GreaterEqualDepth',
62+
6: 'GreaterDepth',
63+
7: 'NotEqualDepth',
6464
};
6565

6666
var Operations = {
67-
0: "MultiplyOperation",
68-
1: "MixOperation",
69-
2: "AddOperation",
67+
0: 'MultiplyOperation',
68+
1: 'MixOperation',
69+
2: 'AddOperation',
7070
};
7171

7272
var MappingModes = {
73-
300: "UVMapping",
74-
301: "CubeReflectionMapping",
75-
302: "CubeRefractionMapping",
76-
303: "EquirectangularReflectionMapping",
77-
304: "EquirectangularRefractionMapping",
78-
305: "SphericalReflectionMapping",
79-
306: "CubeUVReflectionMapping",
80-
307: "CubeUVRefractionMapping",
73+
300: 'UVMapping',
74+
301: 'CubeReflectionMapping',
75+
302: 'CubeRefractionMapping',
76+
303: 'EquirectangularReflectionMapping',
77+
304: 'EquirectangularRefractionMapping',
78+
305: 'SphericalReflectionMapping',
79+
306: 'CubeUVReflectionMapping',
80+
307: 'CubeUVRefractionMapping',
8181
};
8282

8383
var WrappingModes = {
84-
1000: "RepeatWrapping",
85-
1001: "ClampToEdgeWrapping",
86-
1002: "MirroredRepeatWrapping",
84+
1000: 'RepeatWrapping',
85+
1001: 'ClampToEdgeWrapping',
86+
1002: 'MirroredRepeatWrapping',
8787
};
8888

8989
var Filters = {
90-
1003: "NearestFilter",
91-
1004: "NearestMipMapNearestFilter",
92-
1005: "NearestMipMapLinearFilter",
93-
1006: "LinearFilter",
94-
1007: "LinearMipMapNearestFilter",
95-
1008: "LinearMipMapLinearFilter",
90+
1003: 'NearestFilter',
91+
1004: 'NearestMipMapNearestFilter',
92+
1005: 'NearestMipMapLinearFilter',
93+
1006: 'LinearFilter',
94+
1007: 'LinearMipMapNearestFilter',
95+
1008: 'LinearMipMapLinearFilter',
9696
};
9797

9898
var DataTypes = {
99-
1009: "UnsignedByteType",
100-
1010: "ByteType",
101-
1011: "ShortType",
102-
1012: "UnsignedShortType",
103-
1013: "IntType",
104-
1014: "UnsignedIntType",
105-
1015: "FloatType",
106-
1016: "HalfFloatType",
99+
1009: 'UnsignedByteType',
100+
1010: 'ByteType',
101+
1011: 'ShortType',
102+
1012: 'UnsignedShortType',
103+
1013: 'IntType',
104+
1014: 'UnsignedIntType',
105+
1015: 'FloatType',
106+
1016: 'HalfFloatType',
107107
};
108108

109109
var PixelTypes = {
110-
1017: "UnsignedShort4444Type",
111-
1018: "UnsignedShort5551Type",
112-
1019: "UnsignedShort565Type",
113-
1020: "UnsignedInt248Type",
110+
1017: 'UnsignedShort4444Type',
111+
1018: 'UnsignedShort5551Type',
112+
1019: 'UnsignedShort565Type',
113+
1020: 'UnsignedInt248Type',
114114
};
115115

116116
var PixelFormats = {
117-
1021: "AlphaFormat",
118-
1022: "RGBFormat",
119-
1023: "RGBAFormat",
120-
1024: "LuminanceFormat",
121-
1025: "LuminanceAlphaFormat",
122-
1026: "DepthFormat",
123-
1027: "DepthStencilFormat",
117+
1021: 'AlphaFormat',
118+
1022: 'RGBFormat',
119+
1023: 'RGBAFormat',
120+
1024: 'LuminanceFormat',
121+
1025: 'LuminanceAlphaFormat',
122+
1026: 'DepthFormat',
123+
1027: 'DepthStencilFormat',
124124
};
125125

126126
var DepthFormats = {
127-
1026: "DepthFormat",
128-
1027: "DepthStencilFormat",
127+
1026: 'DepthFormat',
128+
1027: 'DepthStencilFormat',
129129
};
130130

131131
var CompressedTextureFormats = {
132-
2001: "RGB_S3TC_DXT1_Format",
133-
2002: "RGBA_S3TC_DXT1_Format",
134-
2003: "RGBA_S3TC_DXT3_Format",
135-
2004: "RGBA_S3TC_DXT5_Format",
136-
2100: "RGB_PVRTC_4BPPV1_Format",
137-
2101: "RGB_PVRTC_2BPPV1_Format",
138-
2102: "RGBA_PVRTC_4BPPV1_Format",
139-
2103: "RGBA_PVRTC_2BPPV1_Format",
140-
2151: "RGB_ETC1_Format",
132+
2001: 'RGB_S3TC_DXT1_Format',
133+
2002: 'RGBA_S3TC_DXT1_Format',
134+
2003: 'RGBA_S3TC_DXT3_Format',
135+
2004: 'RGBA_S3TC_DXT5_Format',
136+
2100: 'RGB_PVRTC_4BPPV1_Format',
137+
2101: 'RGB_PVRTC_2BPPV1_Format',
138+
2102: 'RGBA_PVRTC_4BPPV1_Format',
139+
2103: 'RGBA_PVRTC_2BPPV1_Format',
140+
2151: 'RGB_ETC1_Format',
141141
};
142142

143143
var TextureEncodings = {
144-
3000: "LinearEncoding",
145-
3001: "sRGBEncoding",
146-
3002: "RGBEEncoding",
147-
3003: "LogLuvEncoding",
148-
3004: "RGBM7Encoding",
149-
3005: "RGBM16Encoding",
150-
3006: "RGBDEncoding",
151-
3007: "GammaEncoding",
144+
3000: 'LinearEncoding',
145+
3001: 'sRGBEncoding',
146+
3002: 'RGBEEncoding',
147+
3003: 'LogLuvEncoding',
148+
3004: 'RGBM7Encoding',
149+
3005: 'RGBM16Encoding',
150+
3006: 'RGBDEncoding',
151+
3007: 'GammaEncoding',
152152
};
153153

154154
var CullFaceModes = {
155-
0: "CullFaceNone",
156-
1: "CullFaceBack",
157-
2: "CullFaceFront",
158-
3: "CullFaceFrontBack",
155+
0: 'CullFaceNone',
156+
1: 'CullFaceBack',
157+
2: 'CullFaceFront',
158+
3: 'CullFaceFrontBack',
159159
};
160160

161161
var FrontFaceDirection = {
162-
0: "FrontFaceDirectionCW",
163-
1: "FrontFaceDirectionCCW",
162+
0: 'FrontFaceDirectionCW',
163+
1: 'FrontFaceDirectionCCW',
164164
};
165165

166166
var ShadowTypes = {
167-
0: "BasicShadowMap",
168-
1: "PCFShadowMap",
169-
2: "PCFSoftShadowMap",
167+
0: 'BasicShadowMap',
168+
1: 'PCFShadowMap',
169+
2: 'PCFSoftShadowMap',
170170
};
171171

172172
var ToneMappings = {
173-
0: "NoToneMapping",
174-
1: "LinearToneMapping",
175-
2: "ReinhardToneMapping",
176-
3: "Uncharted2ToneMapping",
177-
4: "CineonToneMapping",
173+
0: 'NoToneMapping',
174+
1: 'LinearToneMapping',
175+
2: 'ReinhardToneMapping',
176+
3: 'Uncharted2ToneMapping',
177+
4: 'CineonToneMapping',
178178
};
179179

180180
var LoopModes = {
181-
2200: "LoopOnce",
182-
2201: "LoopRepeat",
183-
2202: "LoopPingPong",
181+
2200: 'LoopOnce',
182+
2201: 'LoopRepeat',
183+
2202: 'LoopPingPong',
184184
};
185185

186186
var InterpolationModes = {
187-
2300: "InterpolateDiscrete",
188-
2301: "InterpolateLinear",
189-
2302: "InterpolateSmooth",
187+
2300: 'InterpolateDiscrete',
188+
2301: 'InterpolateLinear',
189+
2302: 'InterpolateSmooth',
190190
};
191191

192192
var EndingModes = {
193-
2400: "ZeroCurvatureEnding",
194-
2401: "ZeroSlopeEnding",
195-
2402: "WrapAroundEnding",
193+
2400: 'ZeroCurvatureEnding',
194+
2401: 'ZeroSlopeEnding',
195+
2402: 'WrapAroundEnding',
196196
};
197197

198198
var DrawModes = {
199-
0: "TrianglesDrawMode",
200-
1: "TriangleStripDrawMode",
201-
2: "TriangleFanDrawMode",
199+
0: 'TrianglesDrawMode',
200+
1: 'TriangleStripDrawMode',
201+
2: 'TriangleFanDrawMode',
202202
};
203203

204204
module.exports = {

0 commit comments

Comments
 (0)