Example #1
0
# Template for main module.
_TEMPLATE_MAIN = "decoder.txt"

# Template for a decoder module.
_TEMPLATE_DECODER_MODULE = 'decoder_module.txt'

# Template for a decoder function.
_TEMPLATE_DECODER_FUNCTION = "decoder_function.txt"

# Template for a decoding xml utilities.
_TEMPLATE_DECODER_XML_UTILS = "decoder_xml_utils.txt"

# Loaded templates.
_TEMPLATES = gu.load_templates(_LANG, (
    _TEMPLATE_MAIN,
    _TEMPLATE_DECODER_MODULE,
    _TEMPLATE_DECODER_FUNCTION,
    _TEMPLATE_DECODER_XML_UTILS,
))



class DecoderGenerator(Generator):
    """Generates code to support decoding.

    """
    def is_required(self, ctx):
        """Predicate determing whether code generation is required.

        :param GeneratorContext ctx: Generation context information.

        """
_TEMPLATE_CLASS_ABSTRACT = "typeset_class_abstract.txt"

# Template for a class print string.
_TEMPLATE_CLASS_PSTR = "typeset_class_pstr.txt"

# Template for an enumeration.
_TEMPLATE_ENUM = "typeset_enum.txt"

# Template for a computed class property.
_TEMPLATE_CLASS_COMPUTED_PROPERTY = "typeset_class_computed_property.txt"

# Loaded templates.
_TEMPLATES = gu.load_templates(_LANG, (
    _TEMPLATE_TYPESET,
    _TEMPLATE_CLASS_CONCRETE,
    _TEMPLATE_CLASS_ABSTRACT,
    _TEMPLATE_CLASS_PSTR,
    _TEMPLATE_ENUM,
    _TEMPLATE_CLASS_COMPUTED_PROPERTY
))


class PackageTypeSetGenerator(Generator):
    """Generates code to represent an ontology as a set of types.

    """
    def on_package_parse(self, ctx):
        """Event handler for the package parse event.

        :param GeneratorContext ctx: Generation context information.

        """