Skip to content

Commit

Permalink
Even more stubby
Browse files Browse the repository at this point in the history
Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz committed Jul 22, 2023
1 parent 5f76c2c commit 496d369
Showing 1 changed file with 23 additions and 50 deletions.
73 changes: 23 additions & 50 deletions src/liboslexec/opstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,77 +164,50 @@ osl_format(const char* format_str, ...)



OSL_SHADEOP int
osl_split(const char* str, ustring* results, const char* sep, int maxsplit,
int resultslen)
{
maxsplit = OIIO::clamp(maxsplit, 0, resultslen);
std::vector<std::string> splits;
Strutil::split(USTR(str).string(), splits, USTR(sep).string(), maxsplit);
int n = std::min(maxsplit, (int)splits.size());
for (int i = 0; i < n; ++i)
results[i] = ustring(splits[i]);
return n;
}



////////
// The osl_printf, osl_error, osl_warning, and osl_fprintf are deprecated but
// the stubs are needed for now to prevent breaking OptiX-based renderers who
// aren't quite ready to refactor around the journaling print family of
// functions. They eventually can be removed when we're happy that all the
// compliant renderers have adapted.

OSL_SHADEOP void
osl_printf(ShaderGlobals* sg, const char* format_str, ...)
{
va_list args;
va_start(args, format_str);
#if 0
// Make super sure we know we are executing LLVM-generated code!
std::string newfmt = std::string("llvm: ") + format_str;
format_str = newfmt.c_str();
#endif
std::string s = Strutil::vsprintf(format_str, args);
va_end(args);
sg->context->messagefmt("{}", s);
}


OSL_SHADEOP void
osl_error(ShaderGlobals* sg, const char* format_str, ...)
{
va_list args;
va_start(args, format_str);
std::string s = Strutil::vsprintf(format_str, args);
va_end(args);
sg->context->errorfmt("{}", s);
}


OSL_SHADEOP void
osl_warning(ShaderGlobals* sg, const char* format_str, ...)
{
if (sg->context->allow_warnings()) {
va_list args;
va_start(args, format_str);
std::string s = Strutil::vsprintf(format_str, args);
va_end(args);
sg->context->warningfmt("{}", s);
}
}



OSL_SHADEOP void
osl_fprintf(ShaderGlobals* /*sg*/, const char* filename, const char* format_str,
...)
{
va_list args;
va_start(args, format_str);
std::string s = Strutil::vsprintf(format_str, args);
va_end(args);

static OIIO::mutex fprintf_mutex;
OIIO::lock_guard lock(fprintf_mutex);
FILE* file = OIIO::Filesystem::fopen(filename, "a");
fputs(s.c_str(), file);
fclose(file);
}



OSL_SHADEOP int
osl_split(const char* str, ustring* results, const char* sep, int maxsplit,
int resultslen)
{
maxsplit = OIIO::clamp(maxsplit, 0, resultslen);
std::vector<std::string> splits;
Strutil::split(USTR(str).string(), splits, USTR(sep).string(), maxsplit);
int n = std::min(maxsplit, (int)splits.size());
for (int i = 0; i < n; ++i)
results[i] = ustring(splits[i]);
return n;
}
////////


} // end namespace pvt
Expand Down

0 comments on commit 496d369

Please sign in to comment.