From: Gert van Valkenhoef Date: Mon, 7 Nov 2011 22:27:21 +0000 (+0000) Subject: Read folds X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=519462238ad20b1aca242075e3fe8c0d0719b3d4;p=odcread.git Read folds --- diff --git a/Makefile b/Makefile index c933edc..e3f74e5 100644 --- 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 4be4081..5cdbbb4 100644 --- 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::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; diff --git a/reader.cc b/reader.cc index 587c391..21cef1d 100644 --- 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; diff --git a/reader.h b/reader.h index 21178f3..136fb47 100644 --- 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.