[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kio/misc/kpac
From: Peter Kelly <pmk () post ! com>
Date: 2003-04-26 0:27:09
[Download RAW message or body]
CVS commit by pmk:
Changed Script::evaluate() to invoke call() on the FindProxyForURL
function object instead of using Interpreter::evaluate(). This is because
Interpreter::evaluate() no longer supports the use of "return" in the main
program body, in accordance with the ECMA spec.
M +19 -8 script.cpp 1.5
--- kdelibs/kio/misc/kpac/script.cpp #1.4:1.5
@@ -434,12 +434,23 @@ namespace KPAC
QString Script::evaluate( const KURL& url )
{
- QString code =
- "return FindProxyForURL('" + url.url() + "','" + url.host() + "');";
+ ExecState *exec = m_interpreter.globalExec();
+ Value findFunc = m_interpreter.globalObject().get( exec, "FindProxyForURL" );
+ Object findObj = Object::dynamicCast( findFunc );
+ if (!findObj.isValid() || !findObj.implementsCall())
+ throw Error( "No such function FindProxyForURL" );
- ExecState* exec = m_interpreter.globalExec();
- Completion result = m_interpreter.evaluate( code );
- if ( result.complType() == Throw )
- throw Error( result.value().toString( exec ).qstring() );
- return result.value().toString( exec ).qstring();
+ Object thisObj;
+ List args;
+ args.append(String(url.url()));
+ args.append(String(url.host()));
+ Value retval = findObj.call( exec, thisObj, args );
+
+ if ( exec->hadException() ) {
+ Value ex = exec->exception();
+ exec->clearException();
+ throw Error( ex.toString( exec ).qstring() );
+ }
+
+ return retval.toString( exec ).qstring();
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic