Commit bcc89bcf authored by Wouter's avatar Wouter

Templates work

- Arrays in part reworked (split to header/implementation files)
- More comments in generated code
- Basic start of unions templates (very temporary)
parent 63be2e3c
{% extends "implementation.template" %}
{% block definition %}
{% if class.itemType.type.isAnonymous %}
{% with class.itemType.type as type %}
// -----------------------------------------------------------------------------
// {{ class.itemType.type.fullName }}
// -----------------------------------------------------------------------------
{% include "typedefinition.inc" %}
{% endwith %}
{% endif %}
{% endblock %}
{% if class.itemType.type.isAnonymous %}{# Use inheritance to define subclass #}
/**
* Item class
*/{% with class.itemType.type as type %}{% include "typedeclaration.inc" %}{% endwith %}
{% endif %}
// -----------------------------------------------------------------------------
// ARRAY {{ class.itemType.type.fullName }}
// -----------------------------------------------------------------------------
{% if class.itemType.type.isAnonymous %}
{% with class.itemType.type as type %}
// -----------------------------------------------------------------------------
// {{ class.itemType.type.fullName }}
// -----------------------------------------------------------------------------
{% include "typedefinition.inc" %}
{% endwith %}
{% endif %}
{% load grantleecodegen %}
class {{ class.className }}
{% for base in class.inheritance %}
{% if forloop.first %}:{% else %},{% endif %} virtual {{ base.protectionLevel.key|lower }} {{ base.name }}
{% if forloop.first %}:{% else %},{% endif %} {% if base.isVirtual %}virtual {% endif %}{{ base.protectionLevel.key|lower }} {{ base.name }}
{% endfor %}
{
{% for member in class.members %}
// MEMBER: {{ member.protectionLevel.key }} {{ member.memberKind }} {{ member.name }}
{% endfor %}
{% comment %}
================================================================================
=== QObject bits and pieces
......
......@@ -69,6 +69,9 @@
}
{% for member in class.innerTypes %}
// -------------------------------------------------------------------------
// MEMBER {{ member.innerType.metaType }} {{ class.fullName }}::{{ member.name }}
// -------------------------------------------------------------------------
{% with member.innerType as type %}{% include "typedefinition.inc" %}{% endwith %}
{% endfor %}
......
......@@ -30,4 +30,12 @@
using namespace {{ class.namespaces|join:"::" }};
{% block definition%}{% with class as type %}{% include "typedefinition.inc" %}{% endwith %}{% endblock %}
{% for dep in class.implementationDependencies %}{% spaceless %}
{% ifequal dep.identifier "QObject" %}
#include "{{ class.baseFilename }}.moc"
{% endifequal %}
{% endspaceless %}
{% endfor %}
{% endfilter %}
......@@ -8,8 +8,11 @@
*/
{% filter trim %}
// MEMBER ({{ member.memberKind }}) {{ class.fullName }}::{{ member.name }}
{% switch member.memberKind %}
{% default %}
// SKIPPING {{ class.fullName }}::{{ member.name }} -- unknown kind {{ member.memberKind }}
{% case "Constructor" %}
{% filter indent:0 %}{# Prevent indentation for readability from actual indentation #}
{% if member.isExplicit %}explicit {% endif %}{{ member.name }}({% for param in member.parameters %}{% if not forloop.first %}, {% endif %}{{ param.type.signature }} {{ param.name }}{% if param.defaultValue %} = {{ param.defaultValue }}{% endif %}{% endfor %});
......
{% load grantleecodegen %}
{% switch type.metaType %}
{% case "class" %}{% with type as class %}{% include "classdefinition.inc" %}{% endwith %}
{% case "array" %}{% with type as class %}{# no definition for arrays at this point #}{% endwith %}
{% case "array" %}{% with type as class %}{% include "arraydefinition.inc" %}{% endwith %}
{% case "wrapper" %}{% with type as class %}{% include "wrapperdefinition.inc" %}{% endwith %}
{% case "union" %}{% with type as class %}{% include "uniondefinition.inc" %}{% endwith %}
{% default %}#warning "UNSUPPORTED MetaType {{ type.metaType }}"
{% endswitch %}
{% load grantleecodegen %}
{% for variant in type.variants %}
{% if variant.isAnonymous %}
{% filter indent:4 %}
{% with variant as type %}{% include "typedefinition.inc" %}{% endwith %}
{% endfilter %}
{% endif %}
{% endfor %}
// Default constructor
{{ class.fullName }}::{{ class.className }}()
{% for base in class.inheritance %}
{% if forloop.first %}:{% else %},{% endif %} {{ base.name }}()
{% endfor %}
{
}
{{ class.fullName }} {{ class.fullName }}::fromVariant(const QVariant &value)
{
// TODO
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment