Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2017-12-20 14:16:50 -0500
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-09-11 09:30:51 -0400
commit90f70df8cf397a7dda47ceeab2411e9dc43720a4 (patch)
tree04d695250cfb7c7f1eef0ee96aa0c0431e299dce
parent228404248a01c86fb980c9894c6141de5be7f111 (diff)
downloadtame-90f70df8cf397a7dda47ceeab2411e9dc43720a4.tar.gz
tame-90f70df8cf397a7dda47ceeab2411e9dc43720a4.tar.bz2
tame-90f70df8cf397a7dda47ceeab2411e9dc43720a4.zip
Add alias and extern packages
Long-needed abstractions. * alias.xml: New package. * extern.xml: New package.
-rw-r--r--core/alias.xml83
-rw-r--r--core/extern.xml80
2 files changed, 163 insertions, 0 deletions
diff --git a/core/alias.xml b/core/alias.xml
new file mode 100644
index 0000000..a180589
--- /dev/null
+++ b/core/alias.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<!--
+ Copyright (C) 2017 LoVullo Associates, Inc.
+
+ This file is part of tame-core.
+
+ tame-core is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+<package xmlns="http://www.lovullo.com/rater"
+ xmlns:c="http://www.lovullo.com/calc"
+ core="true"
+ desc="Aliasing Values">
+
+ These alias templates allow giving a new name to existing values.
+ They are most useful for avoiding too many template-generated variables.
+
+ <template name="_classify-alias_"
+ desc="Alias classification">
+ <param name="@as@" desc="Classification alias name" />
+ <param name="@from@" desc="Source classification" />
+
+ <param name="@desc@" desc="Classification alias description">
+ <text>Alias for </text>
+ <param-value name="@from@" />
+ </param>
+
+ <param name="@yields@" desc="Classification alias yield">
+ <text></text>
+ </param>
+
+ <param name="@__src_yields@" desc="Source classification yield">
+ <param-class-to-yields name="@from@" />
+ </param>
+
+
+ <classify as="@as@" desc="@desc@" yields="@yields@">
+ <match on="@__src_yields@" />
+ </classify>
+ </template>
+
+
+ <template name="_rate-alias_"
+ desc="Alias calculation">
+ <param name="@yields@" desc="Alias name" />
+ <param name="@from@" desc="Source name" />
+
+
+ <rate yields="@yields@">
+ <c:value-of name="@from@" />
+ </rate>
+ </template>
+
+
+ <template name="_rate-each-alias_"
+ desc="Alias generator">
+ <param name="@generates@" desc="Generator alias name" />
+ <param name="@from@" desc="Source generator" />
+
+ <param name="@yields@" desc="Yield alias name">
+ <text>_</text>
+ <param-value name="@generates@" />
+ </param>
+
+
+ <rate yields="@yields@">
+ <c:sum of="@from@" desc="Alias iterator"
+ generates="@generates@" index="k">
+ <c:value-of name="@from@" index="k" />
+ </c:sum>
+ </rate>
+ </template>
+</package>
diff --git a/core/extern.xml b/core/extern.xml
new file mode 100644
index 0000000..b7062ac
--- /dev/null
+++ b/core/extern.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!--
+ Copyright (C) 2017 LoVullo Associates, Inc.
+
+ This file is part of tame-core.
+
+ tame-core is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+<package xmlns="http://www.lovullo.com/rater"
+ xmlns:c="http://www.lovullo.com/calc"
+ core="true"
+ desc="Extern Definition">
+
+ Externs are symbols that are expected to be defined by package importers
+ before linking.
+ Rather than explicitly declaring extern symbols,
+ these templates provide more human-readable abstractions.
+
+
+ Note that when defining extern classifications with
+ \ref{_classify-extern_},
+ if specifying a yield,
+ the dimensionality is~$1$ unless otherwise provided.
+
+ <template name="_classify-extern_"
+ desc="Define extern for classification">
+ <param name="@as@" desc="Extern classification name" />
+
+ <param name="@yields@" desc="Extern classification yield">
+ <text></text>
+ </param>
+
+ <!-- default assumption is a vector -->
+ <param name="@dim@" desc="Extern classification yield dimensions">
+ <text>1</text>
+ </param>
+
+ <extern name=":class:{@as@}" type="class" dim="0"
+ yields="@yields@" />
+
+ <if name="@yields@">
+ <extern name="@yields@" type="cgen" dim="@dim@"
+ parent=":class:{@as@}" />
+ </if>
+ </template>
+
+
+ <template name="_rate-each-extern_"
+ desc="Define extern for rate-each">
+ <param name="@generates@" desc="Extern generator name" />
+ <param name="@yields@" desc="Extern yield name" />
+
+ <if name="@generates@">
+ <extern name="@generates@" type="gen" dtype="float" dim="1" />
+ </if>
+
+ <if name="@yields@">
+ <extern name="@yields@" type="rate" dtype="float" dim="0" />
+ </if>
+ </template>
+
+
+ <template name="_rate-extern_"
+ desc="Define extern for rate">
+ <param name="@yields@" desc="Extern yield name" />
+
+ <extern name="@yields@" type="rate" dtype="float" dim="0" />
+ </template>
+</package>