[Pkg-javascript-commits] [pdf.js] 285/414: Removes core/stream circular dependency on core/parser.
David Prévot
taffit at moszumanska.debian.org
Tue Jun 28 17:12:31 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 6038c236b24b7d60181ee4a3df0ec43de5ba2900
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Tue Mar 22 14:06:01 2016 -0500
Removes core/stream circular dependency on core/parser.
---
src/core/parser.js | 3 ---
src/core/stream.js | 42 ++++++++++++++++++------------------------
2 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/src/core/parser.js b/src/core/parser.js
index 9395aa3..a895d26 100644
--- a/src/core/parser.js
+++ b/src/core/parser.js
@@ -1116,7 +1116,4 @@ exports.Lexer = Lexer;
exports.Linearization = Linearization;
exports.Parser = Parser;
exports.isEOF = isEOF;
-
-// TODO refactor to remove dependency on stream.js
-coreStream._setCoreParser(exports);
}));
diff --git a/src/core/stream.js b/src/core/stream.js
index fceff08..d3f70ba 100644
--- a/src/core/stream.js
+++ b/src/core/stream.js
@@ -43,10 +43,6 @@ var Jbig2Image = coreJbig2.Jbig2Image;
var JpegImage = coreJpg.JpegImage;
var JpxImage = coreJpx.JpxImage;
-var coreParser; // see _setCoreParser below
-var EOF; // = coreParser.EOF;
-var Lexer; // = coreParser.Lexer;
-
var coreColorSpace; // see _setCoreColorSpace below
var ColorSpace; // = coreColorSpace.ColorSpace;
@@ -1168,6 +1164,11 @@ var DecryptStream = (function DecryptStreamClosure() {
})();
var Ascii85Stream = (function Ascii85StreamClosure() {
+ // Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
+ function isSpace(ch) {
+ return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A);
+ }
+
function Ascii85Stream(str, maybeLength) {
this.str = str;
this.dict = str.dict;
@@ -1191,7 +1192,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
var str = this.str;
var c = str.getByte();
- while (Lexer.isSpace(c)) {
+ while (isSpace(c)) {
c = str.getByte();
}
@@ -1215,7 +1216,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
input[0] = c;
for (i = 1; i < 5; ++i) {
c = str.getByte();
- while (Lexer.isSpace(c)) {
+ while (isSpace(c)) {
c = str.getByte();
}
@@ -1362,6 +1363,7 @@ var RunLengthStream = (function RunLengthStreamClosure() {
var CCITTFaxStream = (function CCITTFaxStreamClosure() {
var ccittEOL = -2;
+ var ccittEOF = -1;
var twoDimPass = 0;
var twoDimHoriz = 1;
var twoDimVert0 = 2;
@@ -2044,7 +2046,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
}
}
break;
- case EOF:
+ case ccittEOF:
this.addPixels(columns, 0);
this.eof = true;
break;
@@ -2085,7 +2087,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
} else {
code1 = this.lookBits(12);
if (this.eoline) {
- while (code1 !== EOF && code1 !== 1) {
+ while (code1 !== ccittEOF && code1 !== 1) {
this.eatBits(1);
code1 = this.lookBits(12);
}
@@ -2098,7 +2100,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
if (code1 === 1) {
this.eatBits(12);
gotEOL = true;
- } else if (code1 === EOF) {
+ } else if (code1 === ccittEOF) {
this.eof = true;
}
}
@@ -2134,7 +2136,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
} else if (this.err && this.eoline) {
while (true) {
code1 = this.lookBits(13);
- if (code1 === EOF) {
+ if (code1 === ccittEOF) {
this.eof = true;
return null;
}
@@ -2214,7 +2216,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
var limitValue = limit || 0;
for (var i = start; i <= end; ++i) {
var code = this.lookBits(i);
- if (code === EOF) {
+ if (code === ccittEOF) {
return [true, 1, false];
}
if (i < end) {
@@ -2250,7 +2252,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
}
}
info('Bad two dim code');
- return EOF;
+ return ccittEOF;
};
CCITTFaxStream.prototype.getWhiteCode =
@@ -2260,7 +2262,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
var p;
if (this.eoblock) {
code = this.lookBits(12);
- if (code === EOF) {
+ if (code === ccittEOF) {
return 1;
}
@@ -2296,7 +2298,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
var code, p;
if (this.eoblock) {
code = this.lookBits(13);
- if (code === EOF) {
+ if (code === ccittEOF) {
return 1;
}
if ((code >> 7) === 0) {
@@ -2337,12 +2339,12 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
while (this.inputBits < n) {
if ((c = this.str.getByte()) === -1) {
if (this.inputBits === 0) {
- return EOF;
+ return ccittEOF;
}
return ((this.inputBuf << (n - this.inputBits)) &
(0xFFFF >> (16 - n)));
}
- this.inputBuf = (this.inputBuf << 8) + c;
+ this.inputBuf = (this.inputBuf << 8) | c;
this.inputBits += 8;
}
return (this.inputBuf >> (this.inputBits - n)) & (0xFFFF >> (16 - n));
@@ -2498,14 +2500,6 @@ var NullStream = (function NullStreamClosure() {
return NullStream;
})();
-// TODO refactor to remove dependency on parser.js
-function _setCoreParser(coreParser_) {
- coreParser = coreParser_;
- EOF = coreParser_.EOF;
- Lexer = coreParser_.Lexer;
-}
-exports._setCoreParser = _setCoreParser;
-
// TODO refactor to remove dependency on colorspace.js
function _setCoreColorSpace(coreColorSpace_) {
coreColorSpace = coreColorSpace_;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list