emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java
branchemul
changeset 568 6bcb6b98155d
parent 560 53fafe384803
child 595 784aaf9ee179
     1.1 --- a/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java	Wed Jan 23 22:55:28 2013 +0100
     1.2 +++ b/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java	Wed Jan 23 23:26:59 2013 +0100
     1.3 @@ -17,6 +17,8 @@
     1.4   */
     1.5  package org.apidesign.bck2brwsr.emul.lang;
     1.6  
     1.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
     1.8 +
     1.9  /**
    1.10   *
    1.11   * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.12 @@ -25,40 +27,16 @@
    1.13      private System() {
    1.14      }
    1.15  
    1.16 -    public static void arraycopy(char[] value, int srcBegin, char[] dst, int dstBegin, int count) {
    1.17 -        if (srcBegin < dstBegin) {
    1.18 -            while (count-- > 0) {
    1.19 -                dst[dstBegin + count] = value[srcBegin + count];
    1.20 -            }
    1.21 -        } else {
    1.22 -            while (count-- > 0) {
    1.23 -                dst[dstBegin++] = value[srcBegin++];
    1.24 -            }
    1.25 -        }
    1.26 -    }
    1.27 -    
    1.28 -    public static void arraycopy(byte[] value, int srcBegin, byte[] dst, int dstBegin, int count) {
    1.29 -        if (srcBegin < dstBegin) {
    1.30 -            while (count-- > 0) {
    1.31 -                dst[dstBegin + count] = value[srcBegin + count];
    1.32 -            }
    1.33 -        } else {
    1.34 -            while (count-- > 0) {
    1.35 -                dst[dstBegin++] = value[srcBegin++];
    1.36 -            }
    1.37 -        }
    1.38 -    }
    1.39 -
    1.40 -    public static void arraycopy(Object[] value, int srcBegin, Object[] dst, int dstBegin, int count) {
    1.41 -        if (srcBegin < dstBegin) {
    1.42 -            while (count-- > 0) {
    1.43 -                dst[dstBegin + count] = value[srcBegin + count];
    1.44 -            }
    1.45 -        } else {
    1.46 -            while (count-- > 0) {
    1.47 -                dst[dstBegin++] = value[srcBegin++];
    1.48 -            }
    1.49 -        }
    1.50 -    }
    1.51 -    
    1.52 +    @JavaScriptBody(args = { "value", "srcBegin", "dst", "dstBegin", "count" }, body = 
    1.53 +        "if (srcBegin < dstBegin) {\n" +
    1.54 +        "    while (count-- > 0) {\n" +
    1.55 +        "        dst[dstBegin + count] = value[srcBegin + count];\n" +
    1.56 +        "    }\n" +
    1.57 +        "} else {\n" +
    1.58 +        "    while (count-- > 0) {\n" +
    1.59 +        "        dst[dstBegin++] = value[srcBegin++];\n" +
    1.60 +        "    }\n" +
    1.61 +        "}"
    1.62 +    )
    1.63 +    public static native void arraycopy(Object value, int srcBegin, Object dst, int dstBegin, int count);
    1.64  }