]> git.parisson.com Git - pdf.js.git/commitdiff
isNum and operator argument type checking
authorChris Jones <jones.chris.g@gmail.com>
Wed, 4 May 2011 21:58:51 +0000 (16:58 -0500)
committerChris Jones <jones.chris.g@gmail.com>
Wed, 4 May 2011 21:58:51 +0000 (16:58 -0500)
pdf.js

diff --git a/pdf.js b/pdf.js
index 253974de028d8e79d971de2b5faa241c39df1b75..3d48bbf0d993b097b8410f03f1b20f1e66ba9f22 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -82,6 +82,9 @@ var Obj = (function() {
             });
     }
 
+    constructor.prototype.isNum = function(value) {
+        return this.isInt(value) || this.isReal(value);
+    }
     constructor.prototype.lookup = function(key) {
         function lookup(key) {
             if (!(this.value.contains(key)))
@@ -718,13 +721,18 @@ var Interpreter = (function() {
             var cmd = CMD_TABLE[cmdName];
             if (!cmd) {
                 this.error("Unknown command '"+ cmdName +"'");
-            } else if (!this.typeCheck(cmd, args)) {
+            } else if (!this.typeCheck(cmd.params, args)) {
                 this.error("Wrong arguments for command '"+ cmdName +"'");
             }
 
             return cmd.fn;
         },
-        typeCheck: function(cmd, args) {
+        typeCheck: function(params, args) {
+            if (params.length != args.length)
+                return false;
+            for (var i = 0; i < params.length; ++i)
+                if (!args[i]["is"+ params[i]]())
+                    return false;
             return true;
         },
         error: function(what) {