Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timespec fixes #17

Merged
merged 2 commits into from
Mar 27, 2019
Merged
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
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ CHECK_FUNCTION_EXISTS(secure_getenv HAVE_SECURE_GETENV)
CHECK_FUNCTION_EXISTS(__secure_getenv HAVE___SECURE_GETENV)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/common_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/common_cmake_config.h)

add_definitions(-DXR_USE_TIMESPEC)

# Set up the OpenXR version variables, used by several targets in this project.
set(MAJOR "0")
set(MINOR "0")
Expand Down
22 changes: 22 additions & 0 deletions src/scripts/api_dump_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,28 @@ def outputSingleEntry(self, indent, allow_deref, member_param, base_type, descri
write_string += self.writeIndent(indent)
write_string += 'contents.push_back(std::make_tuple("%s", %s' % (full_type, description)
write_string += ', oss_%s.str()));\n' % int_short_param_name
elif base_type == 'timespec':
# Unbeknownst to XR, this is actually a struct.
write_string += self.writeIndent(indent)
write_string += 'std::ostringstream oss_%s;\n' % int_short_param_name
write_string += self.writeIndent(indent)
deref = '' + '*' * pointer_count

# Write whole seconds
write_string += 'oss_%s << (' % int_short_param_name
write_string += deref
write_string += '%s).tv_sec << ".";\n' % full_name

# Write nanoseconds as a decimal
write_string += self.writeIndent(indent)
write_string += "oss_%s << std::setw(9) << std::setfill('0') << (" % int_short_param_name
write_string += deref
write_string += '%s).tv_nsec << "s";\n' % full_name

write_string += self.writeIndent(indent)
write_string += 'contents.push_back(std::make_tuple("%s", %s' % (
full_type, description)
write_string += ', oss_%s.str()));\n' % int_short_param_name
else:
if base_type == 'XrResult':
write_string += self.writeIndent(indent)
Expand Down