diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2019-09-05 13:43:40 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2019-09-06 13:29:47 +0300 |
commit | 333980ae914f2930a7d239ac883a3c132d7b35bf (patch) | |
tree | 29dac6b9d5c93330fb77330ea4fe685ed143f098 /tests-other | |
parent | 5af8a04b6ce38427f5f1a12f38bae33339d84a2b (diff) |
Refactor into stronger types in public API.
Some fallout where internal functions are using stronger types.
Overkill to move everything over to strong types right now, but perhaps
move over to it slowly over time.
Diffstat (limited to 'tests-other')
-rw-r--r-- | tests-other/typed_id_test.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests-other/typed_id_test.cpp b/tests-other/typed_id_test.cpp new file mode 100644 index 00000000..e8ecb16c --- /dev/null +++ b/tests-other/typed_id_test.cpp @@ -0,0 +1,49 @@ +#include "spirv_common.hpp" + +using namespace SPIRV_CROSS_NAMESPACE; + +int main() +{ + // Construct from uint32_t. + VariableID var_id = 10; + TypeID type_id = 20; + ConstantID constant_id = 30; + + // Assign from uint32_t. + var_id = 100; + type_id = 40; + constant_id = 60; + + // Construct generic ID. + ID generic_var_id = var_id; + ID generic_type_id = type_id; + ID generic_constant_id = constant_id; + + // Assign generic id. + generic_var_id = var_id; + generic_type_id = type_id; + generic_constant_id = constant_id; + + // Assign generic ID to typed ID + var_id = generic_var_id; + type_id = generic_type_id; + constant_id = generic_constant_id; + + // Implicit conversion to uint32_t. + uint32_t a; + a = var_id; + a = type_id; + a = constant_id; + a = generic_var_id; + a = generic_type_id; + a = generic_constant_id; + + // Copy assignment. + var_id = VariableID(10); + type_id = TypeID(10); + constant_id = ConstantID(10); + + // These operations are blocked, assign or construction from mismatched types. + //var_id = type_id; + //var_id = TypeID(100); +}
\ No newline at end of file |