tools/spec: avoid c-style casts

This commit is contained in:
Danny Robson 2019-03-11 10:43:11 +11:00
parent 222b662995
commit 80c13529bd

View File

@ -866,7 +866,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
implementations = {
'vkCreateInstance': """
auto res = std::make_unique<indirect<VkInstance,cruft::vk::load::instance_table>> ();
auto ptr = (decltype(vkCreateInstance)*) (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "vkCreateInstance"));
auto ptr = reinterpret_cast<decltype(vkCreateInstance)*> (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "vkCreateInstance"));
auto err = (*ptr) (pCreateInfo, pAllocator, &res->handle);
if (err != VK_SUCCESS)
return err;
@ -879,7 +879,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
MAP_INSTANCE_COMMANDS(GET)
#undef GET
*pInstance = (VkInstance)res.release ();
*pInstance = reinterpret_cast<VkInstance> (res.release ());
return err;
""",
@ -935,8 +935,8 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
MAP_INSTANCE_COMMANDS(GET)
#undef GET
std::clog << "physical_device[" << i << "]; wrapped: " << wrapped.get() << ", native: " << (void*)wrapped->handle << '\\n';
pPhysicalDevices[i] = (VkPhysicalDevice)wrapped.release ();
std::clog << "physical_device[" << i << "]; wrapped: " << wrapped.get() << ", native: " << reinterpret_cast<void const*> (wrapped->handle) << '\\n';
pPhysicalDevices[i] = reinterpret_cast<VkPhysicalDevice> (wrapped.release ());
}
return err;
@ -963,7 +963,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
if obj.is_instance(reg) and obj.params[0].type not in ['VkInstance', 'VkPhysicalDevice']:
forwarding = f"""
auto ptr= cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "{obj.name}");
return ((decltype({obj.name})*) (ptr)) ({', '.join (i.name for i in obj.params)});
return (reinterpret_cast<decltype({obj.name})*> (ptr)) ({', '.join (i.name for i in obj.params)});
"""
else:
forwarding = f"""
@ -971,7 +971,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
std::is_same_v<{obj.params[0].type}, VkPhysicalDevice>) {{
if ({obj.params[0].name} == VK_NULL_HANDLE) {{
auto ptr= cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "{obj.name}");
return ((decltype({obj.name})*) (ptr)) ({', '.join (i.name for i in obj.params)});
return (reinterpret_cast<decltype({obj.name})*> (ptr)) ({', '.join (i.name for i in obj.params)});
}}
}}
@ -1022,7 +1022,7 @@ def write_trace(dst: TextIO, q: List[Type], reg: Registry):
#define FWD(NAME) \\
if (!strcmp(#NAME,pName)) { \\
if (fn (nullptr, #NAME)) \\
return (PFN_vkVoidFunction)NAME; \\
return reinterpret_cast<PFN_vkVoidFunction> (NAME); \\
else \\
return nullptr;\\
}