Move proto generation template into separate file

This commit is contained in:
Justin C. Miller
2020-05-25 02:28:52 -07:00
parent 9064567e4a
commit 51dce15465
2 changed files with 24 additions and 22 deletions

54
templates/proto.j2 Normal file
View File

@@ -0,0 +1,54 @@
#pragma once
#ifndef _uefi_protos_{{ name }}_h_
#define _uefi_protos_{{ name }}_h_
// This file was auto generated by the j6-uefi-headers project. Please see
// https://github.com/justinian/j6-uefi-headers for more information.
#include <uefi/guid.h>
#include <uefi/types.h>
{%- for header in headers %}
#include <{{ header }}>
{%- endfor %}
namespace uefi {
namespace protos {
struct {{ name }};
struct {{ name }}
{
{% if guid %}static constexpr uefi::guid guid{ {{ guid }} };{% endif %}
{% for method in methods %}
inline uefi::status {{ method.name }}(
{%- for arg in method.args -%}
{% if not loop.first %}, {% endif -%}
{{ arg.type }} {{ arg.name }}
{%- endfor %}) {
return _{{ method.name }}(
{%- if not method.get("skip_this", false) -%}this{%- endif -%}
{%- if not method.get("skip_this", false) and method.args %}, {% endif -%}
{{ method.args|join(', ', attribute='name') }});
}
{% endfor %}
{%- for datum in pre_data %}
{{ datum.type }} {{ datum.name }};
{%- endfor %}
protected:
{%- for method in methods %}
using _{{ method.name }}_def = uefi::status (*)(
{%- if not method.get("skip_this", false) -%}uefi::protos::{{ name }} *{%- endif -%}
{%- if not method.get("skip_this", false) and method.args %}, {% endif -%}
{{ method.args|join(', ', attribute='type') }});
_{{ method.name }}_def _{{ method.name }};
{% endfor %}
public:
{%- for datum in post_data %}
{{ datum.type }} {{ datum.name }};
{%- endfor %}
};
} // namespace protos
} // namespace uefi
#endif // _uefi_protos_{{ name }}_h_