brintos

brintos / linux-shallow public Read only

0
0
Text · 733 B · f2339ca Raw
21 lines · python
1#!/usr/bin/env python32# ex: set filetype=python:3 4"""Generate code to handle XDR constants"""5 6from generators import SourceGenerator, create_jinja2_environment7from xdr_ast import _XdrConstant8 9class XdrConstantGenerator(SourceGenerator):10    """Generate source code for XDR constants"""11 12    def __init__(self, language: str, peer: str):13        """Initialize an instance of this class"""14        self.environment = create_jinja2_environment(language, "constants")15        self.peer = peer16 17    def emit_definition(self, node: _XdrConstant) -> None:18        """Emit one definition for a constant"""19        template = self.environment.get_template("definition.j2")20        print(template.render(name=node.name, value=node.value))21