You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Rice Yeh <ri...@gmail.com> on 2007/01/11 10:36:48 UTC

call a function not in global object in

Hi,
  Does anyone know whether the function mentioned in
http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works now?

Rice

Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 13, 2007, at 11:58 PM, Rice Yeh wrote:

> Then, should I report this problem to JIRA. Or there is other concern 
> not to include this function in trunk?

I'll do it, 'cause I can supply my "svn diff" as a patch... :-)

—ml—


Re: call a function not in global object in

Posted by Rice Yeh <ri...@gmail.com>.
Then, should I report this problem to JIRA. Or there is other concern not to
include this function in trunk?

Regards,
Rice

On 1/14/07, Mark Lundquist <ml...@wrinkledog.com> wrote:
>
>
> On Jan 13, 2007, at 8:02 PM, Rice Yeh wrote:
>
> > It is sured that this function is not in trunk.
>
> Bah, you are right, sorry, my bad... so I guess it is in BRANCH_2_1_X
> but not in trunk yet.  It turns out that I had this file checked out in
> trunk and was looking at my own checked-out version.
>
> —ml—
>
>

Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 13, 2007, at 8:02 PM, Rice Yeh wrote:

> It is sured that this function is not in trunk.

Bah, you are right, sorry, my bad... so I guess it is in BRANCH_2_1_X 
but not in trunk yet.  It turns out that I had this file checked out in 
trunk and was looking at my own checked-out version.

—ml—


Re: call a function not in global object in

Posted by Rice Yeh <ri...@gmail.com>.
And have a check at
https://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
.

It is sured that this function is not in trunk.

Rice

On 1/14/07, Rice Yeh <ri...@gmail.com> wrote:
>
> I am sure my code is from trunk. It is at version revision 494774. Please
> have a look at
> https://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
> .
> Is the code you add in it?
>
> Rice
>
> On 1/14/07, Mark Lundquist <ml...@wrinkledog.com> wrote:
> >
> >
> > On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:
> >
> > > The fun is not gotten by the code at line 591 in
> > > FOM_JavaScriptInterpreter.java
> > > Object fun = ScriptableObject.getProperty(thrScope, funName);
> >
> > hold on, I did not read the above very carefully the first time,
> > sorry... :-/
> >
> > > By studying the source code, I do not think "call a function not in
> > > global object in <map:call >" is supported in trunk
> >
> > OK, the code you excerpted above is not from trunk HEAD (or
> > BRANCH_2_1_X HEAD either.  What version are you looking at there,
> > anyway?  The current versions have my change, which looks like this:
> >
> >                      // Resolve function name
> >                      //
> >                      Object fun;
> >                      try {
> >                          fun = context.compileString (funName, null, 1,
> > null)
> >                                           .exec (context, thrScope);
> >                      } catch (EcmaError ee) {
> >                         throw new ResourceNotFoundException (
> >                              "Function \"javascript:" + funName + "()\"
> > not found"
> >                          );
> >                      }
> >
> > HTH,
> > —ml—
> >
> >
> >
>

Re: call a function not in global object in

Posted by Rice Yeh <ri...@gmail.com>.
I am sure my code is from trunk. It is at version revision 494774. Please
have a look at
https://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
.
Is the code you add in it?

Rice

On 1/14/07, Mark Lundquist <ml...@wrinkledog.com> wrote:
>
>
> On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:
>
> > The fun is not gotten by the code at line 591 in
> > FOM_JavaScriptInterpreter.java
> > Object fun = ScriptableObject.getProperty(thrScope, funName);
>
> hold on, I did not read the above very carefully the first time,
> sorry... :-/
>
> > By studying the source code, I do not think "call a function not in
> > global object in <map:call >" is supported in trunk
>
> OK, the code you excerpted above is not from trunk HEAD (or
> BRANCH_2_1_X HEAD either.  What version are you looking at there,
> anyway?  The current versions have my change, which looks like this:
>
>                      // Resolve function name
>                      //
>                      Object fun;
>                      try {
>                          fun = context.compileString (funName, null, 1,
> null)
>                                           .exec (context, thrScope);
>                      } catch (EcmaError ee) {
>                         throw new ResourceNotFoundException (
>                              "Function \"javascript:" + funName + "()\"
> not found"
>                          );
>                      }
>
> HTH,
> —ml—
>
>
>

Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:

> The fun is not gotten by the code at line 591 in 
> FOM_JavaScriptInterpreter.java
>        Object fun = ScriptableObject.getProperty(thrScope, funName);

hold on, I did not read the above very carefully the first time, 
sorry... :-/

> By studying the source code, I do not think "call a function not in 
> global object in <map:call >" is supported in trunk

OK, the code you excerpted above is not from trunk HEAD (or 
BRANCH_2_1_X HEAD either.  What version are you looking at there, 
anyway?  The current versions have my change, which looks like this:

                     // Resolve function name
                     //
                     Object fun;
                     try {
                         fun = context.compileString (funName, null, 1, 
null)
                                          .exec (context, thrScope);
                     } catch (EcmaError ee) {
                        throw new ResourceNotFoundException (
                             "Function \"javascript:" + funName + "()\" 
not found"
                         );
                     }

HTH,
—ml—


Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:

> By studying the source code, I do not think "call a function not in 
> global object in <map:call >" is supported in trunk because function 
> is still gotten in thrScope. Am I right?

I don't think so.  What scope do you think it should compile in?

—ml—


Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 13, 2007, at 1:41 PM, Mark Lundquist wrote:

>
> I just tested like this:
> 	[...snip..]
> and it worked fine...

Note, actually I tested in 2.1.11(dev), not trunk, because that was 
more convenient ATM... but it's the exact same code in 
FOM_JavascriptInterpreter.

cheers,
—ml—


Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
I just tested like this:

	var flowTest =
		{
			foo: {}
		}

	flowTest.foo.bar =
		function() {
			print ("Hello from flowTest()");
		};

...and like this...

	<map:call function="flowTest.foo.bar" />

and it worked fine...

???
—ml—


Re: call a function not in global object in

Posted by Rice Yeh <ri...@gmail.com>.
The fun is not gotten by the code at line 591 in
FOM_JavaScriptInterpreter.java
       Object fun = ScriptableObject.getProperty(thrScope, funName);

, so ResourceNotFoundException is thrown at its following code.
                    if (fun == Scriptable.NOT_FOUND) {
                        throw new ResourceNotFoundException("Function
\"javascript:" + funName + "()\" not found");
                    }

By studying the source code, I do not think *"call a function not in global
object in <map:call >" *is supported in trunk because function is still
gotten in thrScope. Am I right?
*
Rice
*


On 1/13/07, Mark Lundquist <ml...@wrinkledog.com> wrote:
>
>
> On Jan 13, 2007, at 2:21 AM, Rice Yeh wrote:
>
> > Do you have an example about how to pass the namespace object? I use
> > it like the following:
> >
> > <map:call function="xs.party.use">
> > <map:parameter name="flowpath" value="{0}"/>
> > </map:call>
> >
> > , but it does not work.
>
> That should work if there is a function xs.party.use() at the global
> scope.  E.g., something like:
>
>         var xs = {};
>         .
>         .
>         .
>         xs.party = {};
>         .
>         .
>         .
>         xs.party.use =
>                 function() {
>                         .
>                         .
>                 };
>
> What do you mean by "it does not work"?
>
> cheers,
> —ml—
>
>

Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 13, 2007, at 2:21 AM, Rice Yeh wrote:

>   Do you have an example about how to pass the namespace object? I use 
> it like the following:
>
>                 <map:call function="xs.party.use">
>                     <map:parameter name="flowpath" value="{0}"/>
>                 </map:call>
>
> , but it does not work.

That should work if there is a function xs.party.use() at the global 
scope.  E.g., something like:

	var xs = {};
	.
	.
	.
	xs.party = {};
	.
	.
	.
	xs.party.use =
		function() {
			.
			.
		};

What do you mean by "it does not work"?

cheers,
—ml—


Re: call a function not in global object in

Posted by Rice Yeh <ri...@gmail.com>.
Hi,
  Do you have an example about how to pass the namespace object? I use it
like the following:

                <map:call function="xs.party.use">
                    <map:parameter name="flowpath" value="{0}"/>
                </map:call>

, but it does not work.

Regards,
Rice




On 1/11/07, Mark Lundquist <ml...@wrinkledog.com> wrote:
>
>
> On Jan 11, 2007, at 6:08 AM, Mark Lundquist wrote:
>
> >
> > On Jan 11, 2007, at 1:36 AM, Rice Yeh wrote:
> >
> >> Does anyone know whether the function mentioned in
> >> http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works
> >> now?
> >
> > phooey... I forgot to submit this patch to JIRA :-(.  Doing it now...
>
> Never mind! :-)
>
> I never submitted it to JIRA because I didn't need to.  Jeremy Quinn
> asked for this feature, and that reminded me how it was something I had
> wanted also, so I made a patch and emailed it so he could try it out
> —I think I didn't JIRA it at first because I wasn't sure if the
> committers would think it was the right way to implement it (not that I
> think there's anything wrong with it :-).
>
> Anyway, it turns out that Jeremy committed this along with some of his
> other changes.  So this made it into the 2.1.10 release, and it's also
> in trunk.
>
> —ml—
>
>

Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 11, 2007, at 6:08 AM, Mark Lundquist wrote:

>
> On Jan 11, 2007, at 1:36 AM, Rice Yeh wrote:
>
>>   Does anyone know whether the function mentioned in 
>> http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works 
>> now?
>
> phooey... I forgot to submit this patch to JIRA :-(.  Doing it now...

Never mind! :-)

I never submitted it to JIRA because I didn't need to.  Jeremy Quinn 
asked for this feature, and that reminded me how it was something I had 
wanted also, so I made a patch and emailed it so he could try it out 
— I think I didn't JIRA it at first because I wasn't sure if the 
committers would think it was the right way to implement it (not that I 
think there's anything wrong with it :-).

Anyway, it turns out that Jeremy committed this along with some of his 
other changes.  So this made it into the 2.1.10 release, and it's also 
in trunk.

—ml—


Re: call a function not in global object in

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 11, 2007, at 1:36 AM, Rice Yeh wrote:

>   Does anyone know whether the function mentioned in 
> http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works 
> now?

phooey... I forgot to submit this patch to JIRA :-(.  Doing it now...

—ml—