From 2224e41fd7416ebd00820e07ad23a7d6d419a70b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 11 Sep 2016 19:10:59 -0700 Subject: 3331 --- 018type_abbreviations.cc | 49 +++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to '018type_abbreviations.cc') diff --git a/018type_abbreviations.cc b/018type_abbreviations.cc index 99491d79..d3e84050 100644 --- a/018type_abbreviations.cc +++ b/018type_abbreviations.cc @@ -1,4 +1,4 @@ -//: For convenience, make some common types shorter. +//: For convenience, allow Mu types to be abbreviated. :(scenarios transform) :(scenario type_abbreviations) @@ -8,30 +8,10 @@ def main [ ] +transform: product type after expanding abbreviations: "number" -//:: Allow type abbreviations to be defined in mu code. - :(before "End Globals") map Type_abbreviations, Type_abbreviations_snapshot; -:(before "End save_snapshots") -Type_abbreviations_snapshot = Type_abbreviations; -:(before "End restore_snapshots") -restore_type_abbreviations(); -:(before "End One-time Setup") -atexit(clear_type_abbreviations); -:(code) -void restore_type_abbreviations() { - for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { - if (!contains_key(Type_abbreviations_snapshot, p->first)) - delete p->second; - } - Type_abbreviations.clear(); - Type_abbreviations = Type_abbreviations_snapshot; -} -void clear_type_abbreviations() { - for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) - delete p->second; - Type_abbreviations.clear(); -} + +//:: Defining type abbreviations. :(before "End Command Handlers") else if (command == "type") { @@ -117,6 +97,29 @@ def main [ ] +transform: product type after expanding abbreviations: ("address" "number") +//: cleaning up type abbreviations between tests and before exiting + +:(before "End save_snapshots") +Type_abbreviations_snapshot = Type_abbreviations; +:(before "End restore_snapshots") +restore_type_abbreviations(); +:(before "End One-time Setup") +atexit(clear_type_abbreviations); +:(code) +void restore_type_abbreviations() { + for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { + if (!contains_key(Type_abbreviations_snapshot, p->first)) + delete p->second; + } + Type_abbreviations.clear(); + Type_abbreviations = Type_abbreviations_snapshot; +} +void clear_type_abbreviations() { + for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) + delete p->second; + Type_abbreviations.clear(); +} + //:: A few default abbreviations. :(before "End Mu Types Initialization") -- cgit 1.4.1-2-gfad0