mirror of
https://github.com/justinian/j6-uefi-headers.git
synced 2025-12-10 00:24:32 -08:00
81 lines
2.2 KiB
Python
Executable File
81 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
import os
|
|
import os.path
|
|
from jinja2 import Template
|
|
|
|
template = Template('''#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>
|
|
{%- for header in headers %}
|
|
#include <{{ header }}>
|
|
{%- endfor %}
|
|
|
|
namespace uefi {
|
|
namespace protos {
|
|
struct {{ name }};
|
|
|
|
namespace {{ name }}_impl {
|
|
{%- for method in methods %}
|
|
using {{ method.name }} = 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') }});
|
|
{%- endfor %}
|
|
} // namespace {{ name }}_impl
|
|
|
|
struct {{ name }}
|
|
{
|
|
static constexpr uefi::guid guid{ {{ guid }} };
|
|
{% 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 %}
|
|
{{ name }}_impl::{{ method.name }} _{{ method.name }};
|
|
{%- endfor %}
|
|
|
|
public:
|
|
{%- for datum in post_data %}
|
|
{{ datum.type }} {{ datum.name }};
|
|
{%- endfor %}
|
|
};
|
|
|
|
} // namespace protos
|
|
} // namespace uefi
|
|
|
|
#endif // _uefi_protos_{{ name }}_h_
|
|
|
|
''')
|
|
|
|
protos_dir = os.path.join("include", "uefi", "protos")
|
|
os.makedirs(protos_dir, exist_ok=True)
|
|
|
|
import yaml
|
|
protos = yaml.load(open("protos.yaml"))
|
|
for proto in protos:
|
|
with open(os.path.join(protos_dir, proto["name"] + ".h"), 'w') as header:
|
|
header.write(template.render(proto))
|