Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/extension/make_interface_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def run(target, source, env):
kind = type["kind"]

check_type(kind, type, valid_data_types)
if type["name"] in BASE_TYPES:
raise Exception(f"Type '{type['name']}' shadows a built-in type")
check_duplicate(type["name"], valid_data_types, "type")
valid_data_types[type["name"]] = type

if "deprecated" in type:
Expand Down Expand Up @@ -111,6 +114,7 @@ def run(target, source, env):
["name", "arguments", "since", "description"],
["return_value", "see", "legacy_type_name", "deprecated"],
)
check_duplicate(interface["name"], valid_interfaces, "interface function")
valid_interfaces[interface["name"]] = interface
if "deprecated" in interface:
check_allowed_keys(interface["deprecated"], ["since"], ["message", "replace_with"])
Expand Down Expand Up @@ -158,6 +162,13 @@ def check_formatting(buffer, data, filename):
raise Exception(f"Formatting issues in {filename}")


# Note: most symbols (enum values, struct members, argument names) already cause a compile error if duplicated.
# However, some C/C++ compilers allow duplicate typedefs if they're identical -> check those in Python.
def check_duplicate(name, defined, what):
if name in defined:
raise Exception(f"Found duplicate {what} '{name}'")


def check_allowed_keys(data, required, optional=[]):
keys = data.keys()
allowed = required + optional
Expand Down