preproc/domain: Eliminate duplicate domain generation

I have long forgotten about this system.  It converts typedefs into a more
generic domain, but the way in which it does so causes duplicate domains,
for two reasons:

  - Both `preproc:mkdomain` and the caller (`preproc:expand`) recurse into
    unions and generate domains; and
  - Each `preproc:expand` pass generates domains.

So, for example, if there are two `preproc:expand` passes on a union, then
the outer typedef (union) will have domains generated twice (once for each
pass), and the inner typedefs will have domains generated four times (for
each expansion pass, and twice for each pass).

This resolves the issue before the next commit makes further changes to move
this into a generated header file.
main
Mike Gerwitz 2023-09-28 10:12:40 -04:00
parent 4e7d202d2d
commit 3d8c4d1ed0
2 changed files with 9 additions and 6 deletions

View File

@ -54,7 +54,6 @@
"
mode="preproc:mkdomain" priority="5">
<!-- generate all contained domains -->
<variable name="subdomains">
<variable name="union-types" select="
lv:union/lv:typedef" />
@ -80,7 +79,7 @@
<with-param name="subdomains" select="$subdomains" />
</call-template>
<copy-of select="$subdomains" />
<sequence select="$subdomains" />
</template>

View File

@ -85,9 +85,13 @@
<!--
Domain data are extracted from typedefs
Eventually, the typedefs will be converted into templates and removed entirely.
We must be sure that we (a) have not yet processed this typedef and (b)
that we do not handle nested typedefs (within unions), since that is done
for us by `preproc:mkdomain`.
-->
<template match="lv:typedef"
<template match="lv:typedef[
not( preceding-sibling::lv:domain/@name = @name )
and not( ancestor::lv:union ) ]"
mode="preproc:expand" priority="5">
<apply-templates select="." mode="preproc:mkdomain" />