Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/include/OSL/oslquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ class OSLQUERYPUBLIC OSLQuery {
Parameter(Parameter&& src);
const Parameter& operator=(const Parameter&);
const Parameter& operator=(Parameter&&);

/// Return the type as a string ("float", "color[7]", etc.)
std::string type_name() const;
/// Set the type as a string
void type_name(const std::string& typestring);
};

/// OSLQuery methods
Expand Down
16 changes: 16 additions & 0 deletions src/liboslquery/oslquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,22 @@ OSLQuery::Parameter::operator=(Parameter&& src)



std::string
OSLQuery::Parameter::type_name() const
{
return type.c_str();
}



void
OSLQuery::Parameter::type_name(const std::string& typestring)
{
type = TypeDesc(typestring);
}



OSLQuery::OSLQuery() {}


Expand Down
7 changes: 4 additions & 3 deletions src/liboslquery/py_osl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ declare_oslqueryparam(py::module& m)
return PY_STR(p.name.string());
})
.def_readwrite("type", &Parameter::type)
.def_property(
"type_name",
[](const Parameter& p) { return PY_STR(p.type_name()); },
[](Parameter& p, const std::string& t) { p.type_name(t); })
.def_readwrite("isoutput", &Parameter::isoutput)
.def_readwrite("varlenarray", &Parameter::varlenarray)
.def_readwrite("isstruct", &Parameter::isstruct)
Expand Down Expand Up @@ -171,9 +175,6 @@ declare_oslquery(py::module& m)

PYBIND11_MODULE(oslquery, m)
{
// Force an OIIO module load so we have TypeDesc, among other things.
py::module oiio = py::module::import("OpenImageIO");

// Global (OSL scope) functions and symbols
m.attr("osl_version") = OSL_VERSION;
m.attr("VERSION") = OSL_VERSION;
Expand Down
4 changes: 2 additions & 2 deletions testsuite/python-oslquery/src/test_oslquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def printparam(p, indent=" ") :
# as tuples.
print (indent, "{}{} {} = {}".format(
"output " if p.isoutput else "",
p.type, p.name,
"'{}'".format(p.value) if p.type == "string" else p.value))
p.type_name, p.name,
"'{}'".format(p.value) if p.type_name == "string" else p.value))
if p.spacename :
print (indent, " space:", p.spacename)
# Metadata are themselves another tuple of Parameter objects hanging off
Expand Down
Loading