Skip to content

Commit

Permalink
Preparing for more Python generation
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Aug 12, 2024
1 parent d2554d8 commit eeead9f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ifgen/generation/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def cpp_namespace(
data = f"{self.name}::{data}"
return data if not prefix else prefix + data

@property
def is_python(self) -> bool:
"""Determine if this task's language is set to Python."""
return self.language is Language.PYTHON

@property
def stream_implementation(self) -> bool:
"""
Expand Down
3 changes: 3 additions & 0 deletions ifgen/struct/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def enforce_expected_size(
def create_struct(task: GenerateTask) -> None:
"""Create a header file based on a struct definition."""

if task.is_python:
return

with task.boilerplate(
includes=struct_includes(task), json=task.instance.get("json", False)
) as writer:
Expand Down
3 changes: 3 additions & 0 deletions ifgen/struct/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
def create_struct_source(task: GenerateTask) -> None:
"""Create a header file based on a struct definition."""

if task.is_python:
return

if task.instance["stream"] or task.instance["codec"]:
with task.source_boilerplate([]) as writer:
struct_methods(task, writer, False)
Expand Down
3 changes: 3 additions & 0 deletions ifgen/struct/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def unit_test_body(task: GenerateTask, writer: IndentedFileWriter) -> None:
def create_struct_test(task: GenerateTask) -> None:
"""Create a unit test for the enum string-conversion methods."""

if task.is_python:
return

if task.instance["unit_test"]:
with unit_test_boilerplate(task, main=False) as writer:
unit_test_basic_method(task, writer)
Expand Down

0 comments on commit eeead9f

Please sign in to comment.