Using Javascript HTML5 typed arrays from Java using the ScriptManager (Rhino), how?
Asked Answered
A

1

7

I've been porting and application I developed in client Javascript to my server (for a multiplayer game purposes). I am executing some parts using the ScriptEngine because I want to use the same code in the client and the server without having to recode everything twice.

At the beginning it worked fine but then I stumbled uppon the problem of the new typed arrays from HTML5 (Float32Array, Uint8Array...). These arrays are not supported by ScriptEngine (Rhino), and I need them for performance reasons so I cant reimplement them in javascript using non-typed arrays.

I thought to reimplement them using Java and importing the package, but there is no way to reimplement [] operators in Java nor extend the basic arrays (AFAIK).

So at the end Im doing a hack and putting some rules for the developer.

Does anyone knows a solution or a way to reimplement the typed arrays in Java and export them to Javascript?.

Thanks

Albaugh answered 27/7, 2011 at 17:19 Comment(0)
P
-3

If i am not mistaken, This might help you

http://json.org/java/

Penstemon answered 27/7, 2011 at 17:26 Comment(3)
I don't think that JSON has anything at all to do with the question being asked.Clarita
I was not referring to json, It has class that can convert java collections/array to java script array json.org/javadoc/org/json/JSONStringer.htmlPenstemon
but that is not what I need. I need a native low-level support for typed-arrays inside the Javascript engine of Java. Thanks anyway.Albaugh

© 2022 - 2024 — McMap. All rights reserved.