DEADSOFTWARE

Read folds
authorGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Mon, 7 Nov 2011 22:27:21 +0000 (22:27 +0000)
committerGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Mon, 7 Nov 2011 22:27:21 +0000 (22:27 +0000)
Makefile
fold.cc
reader.cc
reader.h

index c933edc1a60e9aae1f39808e273438968abc6abc..e3f74e5ddf148a5018ffd21b9347676e16466af8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
-HEADERS=oberon.h store.h reader.h domain.h alien.h typeregister.h
+HEADERS=oberon.h store.h reader.h domain.h alien.h typeregister.h textmodel.h fold.h
 
-odcread: odcread.o reader.o store.o util.o alien.o typeregister.o textmodel.o
+odcread: odcread.o reader.o store.o util.o alien.o typeregister.o textmodel.o fold.o 
        g++ -o $@ $^
 
 %.o: %.cc $(HEADERS)
diff --git a/fold.cc b/fold.cc
index 4be4081d8b3fd1d479b4c8fad85d7ab35be14138..5cdbbb46ec12e89c40c4d1be530c937f5505e7e8 100644 (file)
--- a/fold.cc
+++ b/fold.cc
@@ -26,7 +26,7 @@ void View::internalize(Reader &reader) {
        reader.readVersion(0, 0);
 }
 
-const std::string Fold::TYPENAME("Folds.Fold^");
+const std::string Fold::TYPENAME("StdFolds.Fold^");
 const TypeProxy<Fold> Fold::PROXY;
 
 Fold::Fold(INTEGER id) : View(id) {}
@@ -44,15 +44,19 @@ const std::string &Fold::getTypeName() const {
 }
 
 void Fold::internalize(Reader &reader) {
-       Store::internalize(reader);
+       View::internalize(reader);
        if (reader.isCancelled()) return;
        reader.readVersion(0, 0);
        if (reader.isCancelled()) return;
-       reader.readSInt(); // FIXME IMPLEMENT
 //             rd.ReadXInt(xint);fold.leftSide := xint = 0;
+       reader.readSInt();
 //             rd.ReadXInt(xint); fold.collapsed := xint = 0;
+       reader.readSInt();
 //             rd.ReadXString(fold.label);
+       SHORTCHAR label[32];
+       reader.readSString(label); // the label
 //             rd.ReadStore(store);
+       reader.readStore(); // the hidden part
 //             IF store # NIL THEN fold.hidden := store(TextModels.Model); Stores.Join(fold.hidden, fold)
 //             ELSE fold.hidden := NIL
 //             END;
index 587c391857cfb84416a953199cf6a0945c311c6e..21cef1dd1882ec8fcdda0033f05821e6f67a538c 100644 (file)
--- a/reader.cc
+++ b/reader.cc
@@ -53,6 +53,20 @@ BYTE Reader::readByte() {
        return out;
 }
 
+SHORTINT Reader::readSInt() {
+       SHORTINT buf;
+       char *bufPtr = (char*)&buf;
+       d_rider.read(bufPtr, 2);
+       if (isLittleEndian()) {
+               return buf;
+       } else {
+               SHORTINT out;
+               char *outPtr = (char *)&out;
+               outPtr[0] = bufPtr[1]; outPtr[1] = bufPtr[0];
+               return out;
+       }
+}
+
 INTEGER Reader::readInt() {
        INTEGER buf;
        char *bufPtr = (char*)&buf;
index 21178f304e2ba32ee0d0ff86d6a74c39c8d2a028..136fb4748cd45f9e0f5595f13e02f1e72b708339 100644 (file)
--- a/reader.h
+++ b/reader.h
@@ -154,7 +154,9 @@ private:
         * PROCEDURE (VAR rd: Reader) ReadSInt (OUT x: SHORTINT)
         * NEW
         * Reads a short integer (-32768..32767).
-        * 
+        */
+       SHORTINT readSInt();
+       /** 
         * PROCEDURE (VAR rd: Reader) ReadXInt (OUT x: INTEGER)
         * NEW
         * Same as ReadSInt, but has an INTEGER-type parameter.