Skip to content

Commit

Permalink
Remove templates.
Browse files Browse the repository at this point in the history
Signed-off-by: Curtis Black <[email protected]>
  • Loading branch information
curtisblack committed Aug 25, 2023
1 parent 3a0d66c commit 74048bc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 50 deletions.
64 changes: 29 additions & 35 deletions src/include/OSL/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,99 +132,93 @@ template<typename TBuiltinArg> class ArgVariant {
return false;
}

template<typename T> T get() const
{
OSL_DASSERT(false);
return T();
}

template<> inline TBuiltinArg get() const
TBuiltinArg get_builtin() const
{
OSL_DASSERT(is_holding<TBuiltinArg>());
return m_builtin;
}

template<> inline bool get() const
bool get_bool() const
{
OSL_DASSERT(is_holding<bool>());
return OSL_DASSERT(is_holding<bool>());
return m_bool;
}

template<> inline int8_t get() const
int8_t get_int8() const
{
OSL_DASSERT(is_holding<int8_t>());
return OSL_DASSERT(is_holding<int8_t>());
return m_int8;
}

template<> inline int16_t get() const
int16_t get_int16() const
{
OSL_DASSERT(is_holding<int16_t>());
return OSL_DASSERT(is_holding<int16_t>());
return m_int16;
}

template<> inline int32_t get() const
int32_t get_int32() const
{
OSL_DASSERT(is_holding<int32_t>());
return OSL_DASSERT(is_holding<int32_t>());
return m_int32;
}

template<> inline int64_t get() const
int64_t get_int64() const
{
OSL_DASSERT(is_holding<int64_t>());
return OSL_DASSERT(is_holding<int64_t>());
return m_int64;
}

template<> inline uint8_t get() const
uint8_t get_uint8() const
{
OSL_DASSERT(is_holding<uint8_t>());
return OSL_DASSERT(is_holding<uint8_t>());
return m_uint8;
}

template<> inline uint16_t get() const
uint16_t get_uint16() const
{
OSL_DASSERT(is_holding<uint16_t>());
return OSL_DASSERT(is_holding<uint16_t>());
return m_uint16;
}

template<> inline uint32_t get() const
uint32_t get_uint32() const
{
OSL_DASSERT(is_holding<uint32_t>());
return OSL_DASSERT(is_holding<uint32_t>());
return m_uint32;
}

template<> inline uint64_t get() const
uint64_t get_uint64() const
{
OSL_DASSERT(is_holding<uint64_t>());
return OSL_DASSERT(is_holding<uint64_t>());
return m_uint64;
}

template<> inline float get() const
float get_float() const
{
OSL_DASSERT(is_holding<float>());
return OSL_DASSERT(is_holding<float>());
return m_float;
}

template<> inline double get() const
double get_double() const
{
OSL_DASSERT(is_holding<double>());
return OSL_DASSERT(is_holding<double>());
return m_double;
}

template<> inline void* get() const
void* get_ptr() const
{
OSL_DASSERT(is_holding<void*>());
return OSL_DASSERT(is_holding<void*>());
return m_ptr;
}

template<> inline ustring get() const
ustring get_ustring() const
{
OSL_DASSERT(is_holding<ustring>());
return OSL_DASSERT(is_holding<ustring>());
return m_ustring;
}

template<> inline ustringhash get() const
ustringhash get_ustringhash() const
{
OSL_DASSERT(is_holding<ustringhash>());
return OSL_DASSERT(is_holding<ustringhash>());
return m_ustringhash;
}
};
Expand Down
30 changes: 15 additions & 15 deletions src/liboslexec/llvm_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3310,46 +3310,46 @@ append_constant_arg(BackendLLVM& rop, const TArgVariant& arg,
case TArgVariant::Type::Unspecified:
case TArgVariant::Type::Builtin: OSL_DASSERT(false); break;
case TArgVariant::Type::Bool:
args.push_back(rop.ll.constant_bool(arg.get<bool>()));
args.push_back(rop.ll.constant_bool(arg.get_bool()));
break;
case TArgVariant::Type::Int8:
args.push_back(rop.ll.constant8(arg.get<int8_t>()));
args.push_back(rop.ll.constant8(arg.get_int8()));
break;
case TArgVariant::Type::Int16:
args.push_back(rop.ll.constant16(arg.get<int16_t>()));
args.push_back(rop.ll.constant16(arg.get_int16()));
break;
case TArgVariant::Type::Int32:
args.push_back(rop.ll.constant(arg.get<int32_t>()));
args.push_back(rop.ll.constant(arg.get_int32()));
break;
case TArgVariant::Type::Int64:
args.push_back(rop.ll.constanti64(arg.get<int64_t>()));
args.push_back(rop.ll.constanti64(arg.get_int64()));
break;
case TArgVariant::Type::UInt8:
args.push_back(rop.ll.constant8(arg.get<uint8_t>()));
args.push_back(rop.ll.constant8(arg.get_uint8()));
break;
case TArgVariant::Type::UInt16:
args.push_back(rop.ll.constant16(arg.get<uint16_t>()));
args.push_back(rop.ll.constant16(arg.get_uint16()));
break;
case TArgVariant::Type::UInt32:
args.push_back(rop.ll.constant(arg.get<uint32_t>()));
args.push_back(rop.ll.constant(arg.get_uint32()));
break;
case TArgVariant::Type::UInt64:
args.push_back(rop.ll.constant64(arg.get<uint64_t>()));
args.push_back(rop.ll.constant64(arg.get_uint64()));
break;
case TArgVariant::Type::Float:
args.push_back(rop.ll.constant(arg.get<float>()));
args.push_back(rop.ll.constant(arg.get_float()));
break;
case TArgVariant::Type::Double:
args.push_back(rop.ll.constant64(arg.get<double>()));
args.push_back(rop.ll.constant64(arg.get_double()));
break;
case TArgVariant::Type::Pointer:
args.push_back(rop.ll.constant_ptr(arg.get<void*>()));
args.push_back(rop.ll.constant_ptr(arg.get_ptr()));
break;
case TArgVariant::Type::UString:
args.push_back(rop.ll.constant(arg.get<ustring>()));
args.push_back(rop.ll.constant(arg.get_ustring()));
break;
case TArgVariant::Type::UStringHash:
args.push_back(rop.ll.constant(ustring(arg.get<ustringhash>())));
args.push_back(rop.ll.constant(ustring(arg.get_ustringhash())));
break;
}
}
Expand Down Expand Up @@ -3428,7 +3428,7 @@ LLVMGEN(llvm_gen_getattribute)
for (size_t index = 0; index < spec.arg_count(); ++index) {
const auto& arg = spec.arg(index);
if (arg.is_holding<AttributeSpecArg::Type::Builtin>()) {
switch (arg.get<AttributeSpecBuiltinArg>()) {
switch (arg.get_builtin()) {
default: OSL_DASSERT(false); break;
case AttributeSpecBuiltinArg::ShaderGlobalsPointer:
args.push_back(rop.sg_void_ptr());
Expand Down

0 comments on commit 74048bc

Please sign in to comment.