From 7c830da0428844a4b8cc4c65734fe1c989f3bb2d Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Tue, 9 May 2006 19:23:39 +0000 Subject: [PATCH] Use __applyConstructor__ to allow for an arbitrary number of parameters to be passed to native constructors. bug 331429, r=brendan git-svn-id: svn://10.0.0.236/trunk@196234 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/narcissus/jsexec.js | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/mozilla/js/narcissus/jsexec.js b/mozilla/js/narcissus/jsexec.js index 39bb2336949..44193eca21e 100644 --- a/mozilla/js/narcissus/jsexec.js +++ b/mozilla/js/narcissus/jsexec.js @@ -906,25 +906,8 @@ if (!('__call__' in Fp)) { }, true, true, true); Fp.__defineProperty__('__construct__', function (a, x) { - switch (a.length) { - case 0: - return new this(); - case 1: - return new this(a[0]); - case 2: - return new this(a[0], a[1]); - case 3: - return new this(a[0], a[1], a[2]); - case 4: - return new this(a[0], a[1], a[2], a[3]); - case 5: - return new this(a[0], a[1], a[2], a[3], a[4]); - case 6: - return new this(a[0], a[1], a[2], a[3], a[4], a[5]); - case 7: - return new this(a[0], a[1], a[2], a[3], a[4], a[5], a[6]); - } - throw "PANIC: too many arguments to constructor"; + a = Array.prototype.splice.call(a, 0, a.length); + return this.__applyConstructor__(a); }, true, true, true); // Since we use native functions such as Date along with host ones such