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): ...@@ -291,13 +291,7 @@ def WriteFunctionDeclarations(file, functions):
WriteFunctions(file, functions, template) WriteFunctions(file, functions, template)
def WriteTemplateMethods(file, functions): def WriteTemplateMethods(file, functions):
template = Template(''' template = Template(' DEFINE_METHOD(${name})\n')
template <typename ... Types>
NO_SANITIZE("cfi-icall")
auto ${name}Fn(Types ... args) -> decltype(${name}Fn_(args...)) {
return ${name}Fn_(args...);
}
''')
WriteFunctions(file, functions, template) WriteFunctions(file, functions, template)
def WriteMacros(file, functions): def WriteMacros(file, functions):
...@@ -402,6 +396,14 @@ class VulkanFunctionPointers { ...@@ -402,6 +396,14 @@ class VulkanFunctionPointers {
file.write(""" file.write("""
public: 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 // Unassociated functions
""") """)
WriteTemplateMethods(file, [{'functions': [ 'vkGetInstanceProcAddr' , WriteTemplateMethods(file, [{'functions': [ 'vkGetInstanceProcAddr' ,
...@@ -423,6 +425,7 @@ class VulkanFunctionPointers { ...@@ -423,6 +425,7 @@ class VulkanFunctionPointers {
WriteTemplateMethods(file, VULKAN_DEVICE_FUNCTIONS) WriteTemplateMethods(file, VULKAN_DEVICE_FUNCTIONS)
file.write("""\ file.write("""\
#undef DEFINE_METHOD
}; };
} // namespace gpu } // namespace gpu
...@@ -450,8 +453,7 @@ class VulkanFunctionPointers { ...@@ -450,8 +453,7 @@ class VulkanFunctionPointers {
file.write("""\ file.write("""\
#endif // GPU_VULKAN_VULKAN_FUNCTION_POINTERS_H_ #endif // GPU_VULKAN_VULKAN_FUNCTION_POINTERS_H_""")
""")
def WriteFunctionPointerInitialization(file, proc_addr_function, parent, def WriteFunctionPointerInitialization(file, proc_addr_function, parent,
functions): 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