How to get eval() caller this from inside bsh ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get eval() caller this from inside bsh ?

Sergio Oliveira-3
Hi List,
 
I am calling eval to execute a beanshell script.
 
I would like to be able to do something like this inside my script:
 
this.addSomething();
 
or simply:
 
addSomething();
 
where "this" would be the java object from where eval() was called.
 
I can do i.set("yourThis", this);
 
but then on every method I need to append:
 
yourThis.addSomething();
 
Is it possible to do this or I am dreaming ?
 
Sergio
Reply | Threaded
Open this post in threaded view
|

Re: How to get eval() caller this from inside bsh ?

Alexey Zinger
I believe you're dreaming because "this" is a special variable in BSH referring
to the namespace object you're in.  I suppose you could follow a naming
convention and register the caller under "caller" or "_this" or some such and
then use your own caller handle in your scripts.

--- Sergio Oliveira <[hidden email]> wrote:

> Hi List,
>
> I am calling eval to execute a beanshell script.
>
> I would like to be able to do something like this inside my script:
>
> this.addSomething();
>
> or simply:
>
> addSomething();
>
> where "this" would be the java object from where eval() was called.
>
> I can do i.set("yourThis", this);
>
> but then on every method I need to append:
>
> yourThis.addSomething();
>
> Is it possible to do this or I am dreaming ?
>
> Sergio
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: How to get eval() caller this from inside bsh ?

Patric Bechtel
In reply to this post by Sergio Oliveira-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Sergio?

I think importObject(Object o) is the one you're searching for.
I normally do a

namespace.setVariable("bla",apiobject);
interpreter.eval("importObject(bla)");

hope that helps...

Sergio Oliveira schrieb am 09.03.2006 10:05:

> Hi List,
>  
> I am calling eval to execute a beanshell script.
>  
> I would like to be able to do something like this inside my script:
>  
> this.addSomething();
>  
> or simply:
>  
> addSomething();
>  
> where "this" would be the java object from where eval() was called.
>  
> I can do i.set("yourThis", this);
>  
> but then on every method I need to append:
>  
> yourThis.addSomething();
>  
> Is it possible to do this or I am dreaming ?
>  
> Sergio

- --
Mit freundlichen Gruessen / Regards
Patric Bechtel, IPCON Informationssysteme OHG
Kontakt: http://www.ipcon.de/kontakt.php
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: GnuPT 2.5.2

iD8DBQFED5sFfGgGu8y7ypARAvcGAKCpXQeZglLTiKQ0LLkWsJR32VP/ZgCg9shz
cJTgXnG6DXS5sqJxeBBl+Xs=
=Hs0G
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users