summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 68f5d58)
raw | patch | inline | side by side (parent: 68f5d58)
author | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Wed, 16 Nov 2011 20:00:43 +0000 (20:00 +0000) | ||
committer | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Wed, 16 Nov 2011 20:00:43 +0000 (20:00 +0000) |
fold/Make.inc | patch | blob | history | |
fold/accept.cc | [new file with mode: 0644] | patch | blob |
fold/fold.cc | patch | blob | history | |
fold/fold.h | patch | blob | history | |
fold/internalize.cc | [new file with mode: 0644] | patch | blob |
fold/toString.cc | [new file with mode: 0644] | patch | blob |
fold/view.cc | [new file with mode: 0644] | patch | blob |
diff --git a/fold/Make.inc b/fold/Make.inc
index 8b7c74e9cd8423575362a69a8969611f2716a756..302066155aa9f2a8318db20aa26102b0841342d6 100644 (file)
--- a/fold/Make.inc
+++ b/fold/Make.inc
-SRCS += fold/fold.cc
+SRCS += $(wildcard fold/*.cc)
diff --git a/fold/accept.cc b/fold/accept.cc
--- /dev/null
+++ b/fold/accept.cc
@@ -0,0 +1,14 @@
+#include "fold/module.ih"
+
+namespace odc {
+
+void Fold::accept(Visitor &visitor) const {
+ if (d_hidden == 0) { // right part
+ visitor.foldRight();
+ } else { // left part
+ visitor.foldLeft(d_collapsed);
+ d_hidden->accept(visitor);
+ }
+}
+
+} // namespace odc
diff --git a/fold/fold.cc b/fold/fold.cc
index 9a0195f941ea010f7d9eb40c78beaeaf9909eaec..62421f322bc5054f9094630d794ac00990e4b9cf 100644 (file)
--- a/fold/fold.cc
+++ b/fold/fold.cc
namespace odc {
-const std::string View::TYPENAME("Views.View^");
-const TypeProxy<View, Store> View::PROXY;
-
-View::View(INTEGER id) : Store(id) {}
-
-const std::string &View::getTypeName() const {
- return TYPENAME;
-}
-
-void View::internalize(Reader &reader) {
- Store::internalize(reader);
- if (reader.isCancelled()) return;
- reader.readVersion(0, 0);
-}
-
const std::string Fold::TYPENAME("StdFolds.Fold^");
const TypeProxy<Fold, View> Fold::PROXY;
Fold::Fold(INTEGER id) : View(id) {}
-const std::string &Fold::getTypeName() const {
- return TYPENAME;
-}
-
-void Fold::internalize(Reader &reader) {
- View::internalize(reader);
- if (reader.isCancelled()) return;
- reader.readVersion(0, 0);
- if (reader.isCancelled()) return;
-// rd.ReadXInt(xint);fold.leftSide := xint = 0;
- reader.readSInt();
-// rd.ReadXInt(xint); fold.collapsed := xint = 0;
- SHORTINT c = reader.readSInt();
- d_collapsed = (c == 0);
-// rd.ReadXString(fold.label);
- d_label = new SHORTCHAR[32];
- reader.readSString(d_label); // the label
-// rd.ReadStore(store);
- d_hidden = reader.readStore(); // the hidden part
-// IF store # NIL THEN fold.hidden := store(TextModels.Model); Stores.Join(fold.hidden, fold)
-// ELSE fold.hidden := NIL
-// END;
-// fold.leftSide := store # NIL
-}
-
-std::string Fold::toString() {
- if (d_hidden == 0) {
- return std::string("Fold(right)");
+Fold::~Fold() {
+ if (d_hidden != 0) {
+ delete d_hidden;
}
- return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string(" }");
+ delete d_label;
}
-void Fold::accept(Visitor &visitor) const {
- if (d_hidden == 0) { // right part
- visitor.foldRight();
- } else { // left part
- visitor.foldLeft(d_collapsed);
- d_hidden->accept(visitor);
- }
+const std::string &Fold::getTypeName() const {
+ return TYPENAME;
}
} // namespace odc
diff --git a/fold/fold.h b/fold/fold.h
index 3725b47093cbd96287c162b49471f24b3ffde6ac..628caca2ecc790e32112f1ed53c050933383d94b 100644 (file)
--- a/fold/fold.h
+++ b/fold/fold.h
virtual const std::string &getTypeName() const;
Fold(INTEGER id);
+ ~Fold();
/**
* Calls super and reads the version and checks that its in the allowed range.
* Then reads the state of the Fold, including the hidden part.
diff --git a/fold/internalize.cc b/fold/internalize.cc
--- /dev/null
+++ b/fold/internalize.cc
@@ -0,0 +1,27 @@
+#include "fold/module.ih"
+
+namespace odc {
+
+void Fold::internalize(Reader &reader) {
+ View::internalize(reader);
+ if (reader.isCancelled()) return;
+ reader.readVersion(0, 0);
+ if (reader.isCancelled()) return;
+
+ // indicates left/right side, but this is also determined by the presense
+ // of a hidden part (so this field unused by BlackBox)
+ reader.readSInt();
+
+ // whether the view is collapsed
+ SHORTINT c = reader.readSInt();
+ d_collapsed = (c == 0);
+
+ // label of the fold (not sure of its use)
+ d_label = new SHORTCHAR[32];
+ reader.readSString(d_label);
+
+ // the hidden part (NULL indicates this is a right side)
+ d_hidden = reader.readStore();
+}
+
+} // namespace odc
diff --git a/fold/toString.cc b/fold/toString.cc
--- /dev/null
+++ b/fold/toString.cc
@@ -0,0 +1,12 @@
+#include "fold/module.ih"
+
+namespace odc {
+
+std::string Fold::toString() {
+ if (d_hidden == 0) {
+ return std::string("Fold(right)");
+ }
+ return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string(" }");
+}
+
+} // namespace odc
diff --git a/fold/view.cc b/fold/view.cc
--- /dev/null
+++ b/fold/view.cc
@@ -0,0 +1,20 @@
+#include "fold/module.ih"
+
+namespace odc {
+
+const std::string View::TYPENAME("Views.View^");
+const TypeProxy<View, Store> View::PROXY;
+
+View::View(INTEGER id) : Store(id) {}
+
+const std::string &View::getTypeName() const {
+ return TYPENAME;
+}
+
+void View::internalize(Reader &reader) {
+ Store::internalize(reader);
+ if (reader.isCancelled()) return;
+ reader.readVersion(0, 0);
+}
+
+} // namespace odc