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

libspirv.cpp: adds c++ api for spvBinaryParse #5109

Merged
merged 2 commits into from
Feb 14, 2023

Conversation

Keenuts
Copy link
Contributor

@Keenuts Keenuts commented Feb 13, 2023

This commit adds a C++ wrapper above the current spvBinaryParse function. I tried to match it 1:1, except for 2 things:

  • std::function<>& are used. No more function pointers, allowing context capture.
  • spv_result_t replaced with a boolean, to match other C++ apis.

Callbacks still return a spv_result_t because the underlying implem relies on that. The convertion from spv_result_t to boolean is only done at the boundary.

This commit adds a C++ wrapper above the current spvBinaryParse
function. I tried to match it 1:1, except for 2 things:
 - std::function<>& are used. No more function pointers, allowing
   context capture.
 - spv_result_t replaced with a boolean, to match other C++ apis.

Callbacks still return a spv_result_t because the underlying implem
relies on that. The convertion from spv_result_t to boolean is only done
at the boundary.

Signed-off-by: Nathan Gauër <brioche@google.com>
@Keenuts Keenuts marked this pull request as ready for review February 13, 2023 18:25
@Keenuts Keenuts requested a review from s-perron February 14, 2023 14:31
s-perron
s-perron previously approved these changes Feb 14, 2023
Copy link
Collaborator

@s-perron s-perron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great thanks. Just a few minor nits, and then it is good to merge.

include/spirv-tools/libspirv.hpp Outdated Show resolved Hide resolved
include/spirv-tools/libspirv.hpp Outdated Show resolved Hide resolved
@s-perron s-perron merged commit b84c86f into KhronosGroup:main Feb 14, 2023
@Keenuts Keenuts deleted the cxx-parsing branch February 14, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants