On Jun 11, 3:58 pm, "Ionut G. Stan" <[email protected]> wrote:
> On Jun 10, 6:41 pm, [email protected] wrote:
>
>
>
> > Hi there,
>
> > I'm looking to add a method to NativeArray/NativeJavaArray (preferably
> > both). Is there some way of doing this?
>
> > Currently, in JavaScript, I could do:
>
> > var a = [ 1, 2, 3, 4, 5, 6 ];
>
> > I can then call the method a.concat(), a.join(), etc. I can't seem to
> > find a way of getting a ScriptableObject of the prototype such that I
> > can then call defineMethod on it.
>
> > Is there any way to do this without having to start modifying the
> > Rhino source code?
>
> > Thanks,
> > Stewart
>
> Are you trying to do something like this?
>
> Array.prototype.getLentgh = function() {
>     return this.length;
>
> };

Almost: I'm trying to do something similar, but in Java. I'd like to
be able to define a Java method that I can call on arrays. My
intention is to be able to do the following:

var a = [1, 2, 3, 4, 5, 6];
b = a.multiply(5);

And then have b = [5, 10, 15, 20, 25, 30];

So that I can implement various vector operations on NativeArray/
NativeJavaArray objects.

Cheers,
Stewart
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to