Skip to content

Commit 90477c9

Browse files
committed
cleanup: Switch some deprecated TypeDesc names to modern ones (#1806)
Signed-off-by: Larry Gritz <[email protected]>
1 parent 10ec529 commit 90477c9

30 files changed

+333
-417
lines changed

src/include/OSL/batched_texture.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ template<int WidthT> class BatchedTextureOutputs {
219219
void* errormessage, Mask<WidthT> mask)
220220
: m_result(result)
221221
, m_resultHasDerivs(resultHasDerivs)
222-
, m_resultType((chans == 1) ? TypeDesc::TypeFloat : TypeDesc::TypeColor)
222+
, m_resultType((chans == 1) ? TypeFloat : TypeColor)
223223
, m_alpha(alpha)
224224
, m_alphaHasDerivs(alphaHasDerivs)
225225
, m_errormessage(errormessage)
@@ -240,15 +240,13 @@ template<int WidthT> class BatchedTextureOutputs {
240240
// The return value maybe invalid or be Masked<float, WidthT>
241241
OSL_FORCEINLINE MaskedData<WidthT> alpha()
242242
{
243-
return MaskedData<WidthT>(TypeDesc::TypeFloat, m_alphaHasDerivs, m_mask,
244-
m_alpha);
243+
return MaskedData<WidthT>(TypeFloat, m_alphaHasDerivs, m_mask, m_alpha);
245244
}
246245

247246
// The return value maybe invalid or be Masked<ustring, WidthT>
248247
OSL_FORCEINLINE MaskedData<WidthT> errormessage()
249248
{
250-
return MaskedData<WidthT>(TypeDesc::TypeString, false, m_mask,
251-
m_errormessage);
249+
return MaskedData<WidthT>(TypeString, false, m_mask, m_errormessage);
252250
}
253251

254252
private:

src/include/OSL/genclosure.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ struct ClosureParam {
2424
#define fieldsize(st, fld) sizeof(((st *)0)->fld)
2525

2626
#define CLOSURE_INT_PARAM(st, fld) \
27-
{ TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
27+
{ TypeInt, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
2828
#define CLOSURE_FLOAT_PARAM(st, fld) \
29-
{ TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
29+
{ TypeFloat, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
3030
#define CLOSURE_COLOR_PARAM(st, fld) \
31-
{ TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
31+
{ TypeColor, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
3232
#define CLOSURE_VECTOR_PARAM(st, fld) \
33-
{ TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
33+
{ TypeVector, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
3434
#define CLOSURE_STRING_PARAM(st, fld) \
35-
{ TypeDesc::TypeString, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
35+
{ TypeString, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
3636
#define CLOSURE_CLOSURE_PARAM(st, fld) \
3737
{ TypeDesc::PTR, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
3838

@@ -49,15 +49,15 @@ struct ClosureParam {
4949

5050
// NOTE: this keyword args have to be always at the end of the list
5151
#define CLOSURE_INT_KEYPARAM(st, fld, key) \
52-
{ TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
52+
{ TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
5353
#define CLOSURE_FLOAT_KEYPARAM(st, fld, key) \
54-
{ TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
54+
{ TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
5555
#define CLOSURE_COLOR_KEYPARAM(st, fld, key) \
56-
{ TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
56+
{ TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
5757
#define CLOSURE_VECTOR_KEYPARAM(st, fld, key) \
58-
{ TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
58+
{ TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
5959
#define CLOSURE_STRING_KEYPARAM(st, fld, key) \
60-
{ TypeDesc::TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
60+
{ TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
6161

6262
#define CLOSURE_FINISH_PARAM(st) { TypeDesc(), sizeof(st), nullptr, alignof(st) }
6363

src/include/OSL/oslexec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ class OSLEXECPUBLIC ShadingSystem {
576576
// float blur = 0.001;
577577
// ss->Parameter (*group, "blur", blur);
578578
// Vec3 colorfilter (0.5f, 0.5f, 1.0f);
579-
// ss->Parameter (*group, "colorfilter", TypeDesc::TypeColor,
579+
// ss->Parameter (*group, "colorfilter", TypeColor,
580580
// &colorfilter);
581581
// ss->Shader ("surface", "texmap", "texturelayer");
582582
// /* Second layer - generate the BSDF closure: */

src/include/osl_pvt.h

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -244,46 +244,25 @@ class TypeSpec {
244244
// m_simple is always UNKNOWN for structures.
245245

246246
/// Is it a simple scalar int?
247-
bool is_int() const
248-
{
249-
return m_simple == TypeDesc::TypeInt && !is_closure();
250-
}
247+
bool is_int() const { return m_simple == TypeInt && !is_closure(); }
251248

252249
/// Is it a simple scalar float?
253-
bool is_float() const
254-
{
255-
return m_simple == TypeDesc::TypeFloat && !is_closure();
256-
}
250+
bool is_float() const { return m_simple == TypeFloat && !is_closure(); }
257251

258252
/// Is it a color?
259-
bool is_color() const
260-
{
261-
return m_simple == TypeDesc::TypeColor && !is_closure();
262-
}
253+
bool is_color() const { return m_simple == TypeColor && !is_closure(); }
263254

264255
/// Is it a point?
265-
bool is_point() const
266-
{
267-
return m_simple == TypeDesc::TypePoint && !is_closure();
268-
}
256+
bool is_point() const { return m_simple == TypePoint && !is_closure(); }
269257

270258
/// Is it a vector?
271-
bool is_vector() const
272-
{
273-
return m_simple == TypeDesc::TypeVector && !is_closure();
274-
}
259+
bool is_vector() const { return m_simple == TypeVector && !is_closure(); }
275260

276261
/// Is it a normal?
277-
bool is_normal() const
278-
{
279-
return m_simple == TypeDesc::TypeNormal && !is_closure();
280-
}
262+
bool is_normal() const { return m_simple == TypeNormal && !is_closure(); }
281263

282264
/// Is it a simple string?
283-
bool is_string() const
284-
{
285-
return m_simple == TypeDesc::TypeString && !is_closure();
286-
}
265+
bool is_string() const { return m_simple == TypeString && !is_closure(); }
287266

288267
/// Is it a string or an array of strings?
289268
///
@@ -357,26 +336,21 @@ class TypeSpec {
357336
bool is_vectriple() const
358337
{
359338
return !is_closure()
360-
&& (m_simple == TypeDesc::TypePoint
361-
|| m_simple == TypeDesc::TypeVector
362-
|| m_simple == TypeDesc::TypeNormal);
339+
&& (m_simple == TypePoint || m_simple == TypeVector
340+
|| m_simple == TypeNormal);
363341
}
364342

365343
/// Is it based on a vector-like triple (point, vector, or normal)?
366344
/// (It's ok for it to be an array or closure.)
367345
bool is_vectriple_based() const
368346
{
369347
auto elem = m_simple.elementtype();
370-
return (elem == TypeDesc::TypePoint || elem == TypeDesc::TypeVector
371-
|| elem == TypeDesc::TypeNormal);
348+
return (elem == TypePoint || elem == TypeVector || elem == TypeNormal);
372349
}
373350

374351
/// Is it a simple matrix (but not an array or closure)?
375352
///
376-
bool is_matrix() const
377-
{
378-
return m_simple == TypeDesc::TypeMatrix && !is_closure();
379-
}
353+
bool is_matrix() const { return m_simple == TypeMatrix && !is_closure(); }
380354

381355
/// Is it a color closure?
382356
///

src/liboslcomp/ast.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,19 +1032,19 @@ class ASTliteral final : public ASTNode {
10321032
ASTliteral(OSLCompilerImpl* comp, int i)
10331033
: ASTNode(literal_node, comp), m_i(i)
10341034
{
1035-
m_typespec = TypeDesc::TypeInt;
1035+
m_typespec = TypeInt;
10361036
}
10371037

10381038
ASTliteral(OSLCompilerImpl* comp, float f)
10391039
: ASTNode(literal_node, comp), m_f(f)
10401040
{
1041-
m_typespec = TypeDesc::TypeFloat;
1041+
m_typespec = TypeFloat;
10421042
}
10431043

10441044
ASTliteral(OSLCompilerImpl* comp, ustring s)
10451045
: ASTNode(literal_node, comp), m_s(s)
10461046
{
1047-
m_typespec = TypeDesc::TypeString;
1047+
m_typespec = TypeString;
10481048
}
10491049

10501050
const char* nodetypename() const { return "literal"; }

src/liboslcomp/codegen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ ASTNode::codegen_int(Symbol*, bool boolify, bool invert)
354354
if (!type.is_int() || boolify || invert) {
355355
// If they're not using an int as the condition, then it's an
356356
// implied comparison to zero.
357-
Symbol* tempvar = m_compiler->make_temporary(TypeDesc::TypeInt);
357+
Symbol* tempvar = m_compiler->make_temporary(TypeInt);
358358
Symbol* zerovar = NULL;
359359
if (type.is_closure())
360360
zerovar = m_compiler->make_constant((int)0);
@@ -1543,7 +1543,7 @@ ASTbinary_expression::codegen(Symbol* dest)
15431543
if (m_op == Mul || m_op == Div) {
15441544
// Need to coerce the weight into a color.
15451545
// N.B. The typecheck always reorders c=k*c into c=c*k.
1546-
rsym = coerce(rsym, TypeDesc::TypeColor, true);
1546+
rsym = coerce(rsym, TypeColor, true);
15471547
}
15481548
emitcode(opword(), dest, lsym, rsym);
15491549
return dest;

src/liboslcomp/oslcomp.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -632,20 +632,15 @@ struct GlobalTable {
632632
void
633633
OSLCompilerImpl::initialize_globals()
634634
{
635-
static GlobalTable globals[]
636-
= { { "P", TypeDesc::TypePoint, false },
637-
{ "I", TypeDesc::TypeVector, false },
638-
{ "N", TypeDesc::TypeNormal, false },
639-
{ "Ng", TypeDesc::TypeNormal },
640-
{ "u", TypeDesc::TypeFloat },
641-
{ "v", TypeDesc::TypeFloat },
642-
{ "dPdu", TypeDesc::TypeVector },
643-
{ "dPdv", TypeDesc::TypeVector },
644-
{ "Ps", TypeDesc::TypePoint },
645-
{ "Ci", TypeSpec(TypeDesc::TypeColor, true), false },
646-
{ "time", TypeDesc::TypeFloat },
647-
{ "dtime", TypeDesc::TypeFloat },
648-
{ "dPdtime", TypeDesc::TypeVector } };
635+
static GlobalTable globals[] = {
636+
{ "P", TypePoint, false }, { "I", TypeVector, false },
637+
{ "N", TypeNormal, false }, { "Ng", TypeNormal },
638+
{ "u", TypeFloat }, { "v", TypeFloat },
639+
{ "dPdu", TypeVector }, { "dPdv", TypeVector },
640+
{ "Ps", TypePoint }, { "Ci", TypeSpec(TypeColor, true), false },
641+
{ "time", TypeFloat }, { "dtime", TypeFloat },
642+
{ "dPdtime", TypeVector }
643+
};
649644

650645
for (auto& g : globals) {
651646
Symbol* s = new Symbol(ustring(g.name), g.type, SymTypeGlobal);
@@ -706,7 +701,7 @@ OSLCompilerImpl::write_oso_const_value(const ConstantSymbol* sym) const
706701
else if (elemtype == TypeDesc::FLOAT)
707702
for (int i = 0; i < nelements; ++i)
708703
osofmt("{:.9g}{}", sym->floatval(i), nelements > 1 ? " " : "");
709-
else if (equivalent(elemtype, TypeDesc::TypeVector))
704+
else if (equivalent(elemtype, TypeVector))
710705
for (int i = 0; i < nelements; ++i) {
711706
Vec3 v = sym->get_vec3(i);
712707
osofmt("{:.9g} {:.9g} {:.9g}{}", v.x, v.y, v.z,

src/liboslcomp/oslgram.y

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,14 +1110,14 @@ inline TypeDesc
11101110
OSL::pvt::osllextype (int lex)
11111111
{
11121112
switch (lex) {
1113-
case COLORTYPE : return TypeDesc::TypeColor;
1114-
case FLOATTYPE : return TypeDesc::TypeFloat;
1115-
case INTTYPE : return TypeDesc::TypeInt;
1116-
case MATRIXTYPE : return TypeDesc::TypeMatrix;
1117-
case NORMALTYPE : return TypeDesc::TypeNormal;
1118-
case POINTTYPE : return TypeDesc::TypePoint;
1119-
case STRINGTYPE : return TypeDesc::TypeString;
1120-
case VECTORTYPE : return TypeDesc::TypeVector;
1113+
case COLORTYPE : return TypeColor;
1114+
case FLOATTYPE : return TypeFloat;
1115+
case INTTYPE : return TypeInt;
1116+
case MATRIXTYPE : return TypeMatrix;
1117+
case NORMALTYPE : return TypeNormal;
1118+
case POINTTYPE : return TypePoint;
1119+
case STRINGTYPE : return TypeString;
1120+
case VECTORTYPE : return TypeVector;
11211121
case VOIDTYPE : return TypeDesc::NONE;
11221122
default: return TypeDesc::UNKNOWN;
11231123
}

src/liboslcomp/symtab.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,17 @@ class FunctionSymbol final : public Symbol {
114114
/// the parent class to properly free it upon destruction.
115115
class ConstantSymbol final : public Symbol {
116116
public:
117-
ConstantSymbol(ustring n, ustring val)
118-
: Symbol(n, TypeDesc::TypeString, SymTypeConst)
117+
ConstantSymbol(ustring n, ustring val) : Symbol(n, TypeString, SymTypeConst)
119118
{
120119
m_val.s = val.c_str();
121120
set_dataptr(SymArena::Absolute, &m_val.s);
122121
}
123-
ConstantSymbol(ustring n, int val)
124-
: Symbol(n, TypeDesc::TypeInt, SymTypeConst)
122+
ConstantSymbol(ustring n, int val) : Symbol(n, TypeInt, SymTypeConst)
125123
{
126124
m_val.i = val;
127125
set_dataptr(SymArena::Absolute, &m_val.i);
128126
}
129-
ConstantSymbol(ustring n, float val)
130-
: Symbol(n, TypeDesc::TypeFloat, SymTypeConst)
127+
ConstantSymbol(ustring n, float val) : Symbol(n, TypeFloat, SymTypeConst)
131128
{
132129
m_val.f = val;
133130
set_dataptr(SymArena::Absolute, &m_val.f);
@@ -148,7 +145,7 @@ class ConstantSymbol final : public Symbol {
148145
set_dataptr(SymArena::Absolute, &m_val.i);
149146
else if (type == TypeDesc::STRING)
150147
set_dataptr(SymArena::Absolute, &m_val.s);
151-
else if (equivalent(type, TypeDesc::TypeVector))
148+
else if (equivalent(type, TypeVector))
152149
set_dataptr(SymArena::Absolute, &m_val.v);
153150
else {
154151
OSL_DASSERT(arena() == SymArena::Unknown);

0 commit comments

Comments
 (0)