Providing JavaScript specific implementations of Hashtable and Vector. Those should likely be faster for the JavaScript VM than interpreting bytecode. This is the way to get the best of JavaScript and yet provide reasonably well working implementation in Java.
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package org.apidesign.javap;
7 import org.apidesign.bck2brwsr.core.JavaScriptBody;
8 import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
10 /** A JavaScript ready replacement for java.util.Vector
12 * @author Jaroslav Tulach <jtulach@netbeans.org>
14 @JavaScriptPrototype(prototype = "new Array" )
24 void add(Object objectType) {
25 addElement(objectType);
27 @JavaScriptBody(args = { "self", "obj" }, body =
30 void addElement(Object obj) {
36 @JavaScriptBody(args = { "self" }, body =
40 return arr == null ? 0 : arr.length;
43 @JavaScriptBody(args = { "self", "newArr" }, body =
44 "for (var i = 0; i < self.length; i++) {\n"
45 + " newArr[i] = self[i];\n"
47 void copyInto(Object[] newArr) {
51 int min = Math.min(newArr.length, arr.length);
52 for (int i = 0; i < min; i++) {
57 @JavaScriptBody(args = { "self", "index" }, body =
60 Object elementAt(int index) {
64 private void setSize(int len) {
65 Object[] newArr = new Object[len];
70 @JavaScriptBody(args = { "self", "val", "index" }, body =
73 void setElementAt(Object val, int index) {