[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: Re: JS return values
From: Harri Porten <harri () trolltech ! com>
Date: 2001-02-28 21:10:21
[Download RAW message or body]
David Faure wrote:
>
> ecma/kjs_window.cpp :
> 655 return Completion(Normal, result);
>
> kjs/function.cpp :
> 128 else if (comp.complType() == ReturnValue)
> 129 return comp.value();
> 130 else
> 131 return Undefined();
>
> This obviously makes any window function return Undefined :(
That's what I wrote about in that ununderstandable answer to your bug
report recently :}
> So I can easily fix my "blah=window.open" problem this way :
>
> Index: kjs_window.cpp
> ===================================================================
> RCS file: /home/kde/kdelibs/khtml/ecma/kjs_window.cpp,v
> retrieving revision 1.99
> diff -u -p -r1.99 kjs_window.cpp
> --- kjs_window.cpp 2001/02/23 01:50:49 1.99
> +++ kjs_window.cpp 2001/02/28 20:43:28
> @@ -532,7 +532,7 @@ Completion WindowFunc::tryExecute(const
> if (uargs.frameName == "_blank")
> uargs.frameName = QString::null;
> emit static_cast<KHTMLPart*>(newPart)->browserExtension()->openURLRequest(url,uargs);
> - result = win;
> + return Completion( ReturnValue, win );
Yes.
> } else
> result = Undefined();
> }
>
> Harri, what's the more generic solution ?
> Should we do like the above in every Window function that should return a value,
> or should we simply fix line 655 to s/Normal/ReturnValue/, given that if the value
Yes. And I'm very sorry if you wasted any time debugging this. I had the
fix on my disk and must have forgotten to commit it :( I even fixed the
kpac code .... It's checked in now.
> is undefined, kjs/function is going to return Undefined anyway ?
There are other parts in the code that differentiate between the two so
I would prefer to keep it this way.
> There has to be a reason for Normal vs ReturnValue but I'm probably missing it :-)
"Normal" would be like "void" and no exception thrown. "ReturnValue" is
used when the JS code said "return xyz;" or we want to emulate that like
above.
Sorry for the mess. I had done local checks before I checked in my
recent libkjs fix. Now I understand why I couldn't explain the posting
(from Malte?) about getElementById() I read today. Good that I resisted
touching that part of the code until after the 2.1 release.
Harri.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic