Browse Source

cleanup code a bit, avoid tabs, use java mode

Andreas Gal 14 years ago
parent
commit
4c74c34924
  1. 61
      pdf.js

61
pdf.js

@ -1,4 +1,24 @@
var EOF = -1; /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
var HashMap = (function() {
function constructor() {
}
constructor.prototype = {
get: function(key) {
return this["$" + key];
},
set: function(key, value) {
this["$" + key] = value;
},
contains: function(key) {
return ("$" + key) in this;
}
};
return constructor;
})();
var Obj = (function() { var Obj = (function() {
function constructor(type, value) { function constructor(type, value) {
@ -43,26 +63,9 @@ var Obj = (function() {
return constructor; return constructor;
})(); })();
var HashMap = (function() {
function constructor() {
}
constructor.prototype = {
get: function(key) {
return this["$" + key];
},
set: function(key, value) {
this["$" + key] = value;
},
contains: function(key) {
return ("$" + key) in this;
}
};
return constructor;
})();
var Lexer = (function() { var Lexer = (function() {
const EOF = -1;
function constructor(bytes) { function constructor(bytes) {
this.bytes = bytes; this.bytes = bytes;
this.pos = 0; this.pos = 0;
@ -236,7 +239,6 @@ var Lexer = (function() {
break; break;
} }
break; break;
default: default:
str += ch; str += ch;
break; break;
@ -407,8 +409,7 @@ var Parser = (function() {
if (this.inlineImg == 2) if (this.inlineImg == 2)
this.refill(); this.refill();
// array if (this.buf1.isCmd("[")) { // array
if (this.buf1.isCmd("[")) {
var obj = new Obj(Obj.Array, []); var obj = new Obj(Obj.Array, []);
while (!this.buf1.isCmd("]") && !this.buf1.isEOF()) while (!this.buf1.isCmd("]") && !this.buf1.isEOF())
obj.value.push(this.getObj()); obj.value.push(this.getObj());
@ -416,9 +417,7 @@ var Parser = (function() {
this.error("End of file inside array"); this.error("End of file inside array");
this.shift(); this.shift();
return obj; return obj;
} else if (this.buf1.isCmd("<<")) { // dictionary or stream
// dictionary or stream
} else if (this.buf1.isCmd("<<")) {
this.shift(); this.shift();
var obj = new Obj(Obj.Dict, new HashMap()); var obj = new Obj(Obj.Dict, new HashMap());
while (!this.buf1.isCmd(">>") && !this.buf1.isEOF()) { while (!this.buf1.isCmd(">>") && !this.buf1.isEOF()) {
@ -435,6 +434,7 @@ var Parser = (function() {
} }
if (this.buf1.isEOF()) if (this.buf1.isEOF())
error("End of file inside dictionary"); error("End of file inside dictionary");
// stream objects are not allowed inside content streams or // stream objects are not allowed inside content streams or
// object streams // object streams
if (this.allowStreams && this.buf2.isCmd("stream")) { if (this.allowStreams && this.buf2.isCmd("stream")) {
@ -444,8 +444,7 @@ var Parser = (function() {
} }
return obj; return obj;
// indirect reference or integer } else if (this.buf1.isInt()) { // indirect reference or integer
} else if (this.buf1.isInt()) {
var num = this.buf1.value; var num = this.buf1.value;
this.shift(); this.shift();
if (this.buf1.isInt() && this.buf2.isCmd("R")) { if (this.buf1.isInt() && this.buf2.isCmd("R")) {
@ -455,9 +454,7 @@ var Parser = (function() {
return obj; return obj;
} }
return new Obj(Obj.Int, num); return new Obj(Obj.Int, num);
} else if (this.buf1.isString()) { // string
// string
} else if (this.buf1.isString()) {
var obj = this.decrypt(this.buf1); var obj = this.decrypt(this.buf1);
this.shift(); this.shift();
return obj; return obj;
@ -595,5 +592,3 @@ function checkHeader(arrayBuffer) {
function setup(arrayBuffer, ownerPassword, userPassword) { function setup(arrayBuffer, ownerPassword, userPassword) {
var ub = checkHeader(arrayBuffer); var ub = checkHeader(arrayBuffer);
} }
})
Loading…
Cancel
Save