Commit 2d651f7b authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Use macro to simplify class VulkanFunctionPointers

Bug: None
Change-Id: Id4ef48633b81f575ff0fb863bbc34fdd929be880
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2075048Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744783}
parent 70ab0a94
......@@ -291,13 +291,7 @@ def WriteFunctionDeclarations(file, functions):
WriteFunctions(file, functions, template)
def WriteTemplateMethods(file, functions):
template = Template('''
template <typename ... Types>
NO_SANITIZE("cfi-icall")
auto ${name}Fn(Types ... args) -> decltype(${name}Fn_(args...)) {
return ${name}Fn_(args...);
}
''')
template = Template(' DEFINE_METHOD(${name})\n')
WriteFunctions(file, functions, template)
def WriteMacros(file, functions):
......@@ -402,6 +396,14 @@ class VulkanFunctionPointers {
file.write("""
public:
#define DEFINE_METHOD(name) \
template <typename... Types> \
NO_SANITIZE("cfi-icall") \
auto name ## Fn(Types... args) \
-> decltype(name ## Fn_(args...)) { \
return name ## Fn_(args...); \
}
// Unassociated functions
""")
WriteTemplateMethods(file, [{'functions': [ 'vkGetInstanceProcAddr' ,
......@@ -423,6 +425,7 @@ class VulkanFunctionPointers {
WriteTemplateMethods(file, VULKAN_DEVICE_FUNCTIONS)
file.write("""\
#undef DEFINE_METHOD
};
} // namespace gpu
......@@ -450,8 +453,7 @@ class VulkanFunctionPointers {
file.write("""\
#endif // GPU_VULKAN_VULKAN_FUNCTION_POINTERS_H_
""")
#endif // GPU_VULKAN_VULKAN_FUNCTION_POINTERS_H_""")
def WriteFunctionPointerInitialization(file, proc_addr_function, parent,
functions):
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment