E3 Fixes.

git-svn-id: svn://10.0.0.236/trunk@142908 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
2003-05-25 23:46:54 +00:00
parent b5d4fb496a
commit 24428a6e21
10 changed files with 229 additions and 85 deletions

View File

@@ -125,15 +125,26 @@ namespace MetaData {
return STRING_TO_JS2VAL(meta->engine->Function_StringAtom);
}
static js2val Function_call(JS2Metadata *meta, const js2val thisValue, js2val * /*argv*/, uint32 /*argc*/)
static js2val Function_call(JS2Metadata *meta, const js2val thisValue, js2val *argv, uint32 argc)
{
if (!JS2VAL_IS_OBJECT(thisValue)
|| (JS2VAL_TO_OBJECT(thisValue)->kind != SimpleInstanceKind)
|| ((checked_cast<SimpleInstance *>(JS2VAL_TO_OBJECT(thisValue)))->type != meta->functionClass))
meta->reportError(Exception::typeError, "Function.call called on something other than a function thing", meta->engine->errorPos());
// FunctionInstance *fnInst = checked_cast<FunctionInstance *>(JS2VAL_TO_OBJECT(thisValue));
return STRING_TO_JS2VAL(meta->engine->Function_StringAtom);
}
FunctionInstance *fnInst = checked_cast<FunctionInstance *>(JS2VAL_TO_OBJECT(thisValue));
js2val callThis = argv[0];
DEFINE_ROOTKEEPER(rk0, callThis);
if (JS2VAL_IS_NULL(argv[0]) || JS2VAL_IS_UNDEFINED(argv[0]))
callThis = OBJECT_TO_JS2VAL(meta->glob);
else
callThis = meta->toObject(callThis);
if (argc > 1)
return meta->invokeFunction(fnInst, callThis, &argv[1], argc - 1, NULL);
else
return meta->invokeFunction(fnInst, callThis, NULL, 0, NULL);
}
static js2val Function_apply(JS2Metadata *meta, const js2val thisValue, js2val *argv, uint32 argc)
{
@@ -143,28 +154,28 @@ namespace MetaData {
meta->reportError(Exception::typeError, "Function.apply called on something other than a function thing", meta->engine->errorPos());
FunctionInstance *fnInst = checked_cast<FunctionInstance *>(JS2VAL_TO_OBJECT(thisValue));
js2val callThis = argv[0];
DEFINE_ROOTKEEPER(rk0, callThis);
if (JS2VAL_IS_NULL(argv[0]) || JS2VAL_IS_UNDEFINED(argv[0]))
callThis = OBJECT_TO_JS2VAL(meta->glob);
else
callThis = meta->toObject(callThis);
js2val *argArray = NULL;
uint32 length = 0;
if ((argc > 1) && !JS2VAL_IS_NULL(argv[1]) && !JS2VAL_IS_UNDEFINED(argv[1])) {
if (!JS2VAL_IS_OBJECT(argv[1])
|| (JS2VAL_TO_OBJECT(argv[1])->kind != SimpleInstanceKind)
|| ((checked_cast<SimpleInstance *>(JS2VAL_TO_OBJECT(argv[1])))->type != meta->arrayClass))
meta->reportError(Exception::typeError, "Function.apply passed a non-array argument list", meta->engine->errorPos());
ArrayInstance *arrInst = checked_cast<ArrayInstance *>(JS2VAL_TO_OBJECT(argv[1]));
uint32 length = getLength(meta, arrInst);
argArray = new js2val[length];
js2val *argArray = new js2val[length];
DEFINE_ARRAYROOTKEEPER(rk, argArray, length);
for (uint32 i = 0; i < length; i++)
meta->arrayClass->ReadPublic(meta, &argv[1], meta->engine->numberToString(i), RunPhase, &argArray[i]);
return meta->invokeFunction(fnInst, callThis, argArray, length, NULL);
}
else
return meta->invokeFunction(fnInst, callThis, NULL, 0, NULL);
return meta->invokeFunction(fnInst, callThis, argArray, 0, NULL);
}
void initFunctionObject(JS2Metadata *meta)