cleanup code a bit, avoid tabs, use java mode

This commit is contained in:
Andreas Gal 2011-05-02 15:06:11 -07:00
parent 4570f6a444
commit 4c74c34924

61
pdf.js
View File

@ -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() {
function constructor(type, value) {
@ -43,26 +63,9 @@ var Obj = (function() {
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() {
const EOF = -1;
function constructor(bytes) {
this.bytes = bytes;
this.pos = 0;
@ -236,7 +239,6 @@ var Lexer = (function() {
break;
}
break;
default:
str += ch;
break;
@ -407,8 +409,7 @@ var Parser = (function() {
if (this.inlineImg == 2)
this.refill();
// array
if (this.buf1.isCmd("[")) {
if (this.buf1.isCmd("[")) { // array
var obj = new Obj(Obj.Array, []);
while (!this.buf1.isCmd("]") && !this.buf1.isEOF())
obj.value.push(this.getObj());
@ -416,9 +417,7 @@ var Parser = (function() {
this.error("End of file inside array");
this.shift();
return obj;
// dictionary or stream
} else if (this.buf1.isCmd("<<")) {
} else if (this.buf1.isCmd("<<")) { // dictionary or stream
this.shift();
var obj = new Obj(Obj.Dict, new HashMap());
while (!this.buf1.isCmd(">>") && !this.buf1.isEOF()) {
@ -435,6 +434,7 @@ var Parser = (function() {
}
if (this.buf1.isEOF())
error("End of file inside dictionary");
// stream objects are not allowed inside content streams or
// object streams
if (this.allowStreams && this.buf2.isCmd("stream")) {
@ -444,8 +444,7 @@ var Parser = (function() {
}
return obj;
// indirect reference or integer
} else if (this.buf1.isInt()) {
} else if (this.buf1.isInt()) { // indirect reference or integer
var num = this.buf1.value;
this.shift();
if (this.buf1.isInt() && this.buf2.isCmd("R")) {
@ -455,9 +454,7 @@ var Parser = (function() {
return obj;
}
return new Obj(Obj.Int, num);
// string
} else if (this.buf1.isString()) {
} else if (this.buf1.isString()) { // string
var obj = this.decrypt(this.buf1);
this.shift();
return obj;
@ -595,5 +592,3 @@ function checkHeader(arrayBuffer) {
function setup(arrayBuffer, ownerPassword, userPassword) {
var ub = checkHeader(arrayBuffer);
}
})