Write memory starting at offset from the array with element type cls.
(long offset, Object value, Class<?> cls)
| 900 | |
| 901 | /** Write memory starting at offset from the array with element type cls. */ |
| 902 | private void writeArray(long offset, Object value, Class<?> cls) { |
| 903 | if (cls == byte.class) { |
| 904 | byte[] buf = (byte[])value; |
| 905 | write(offset, buf, 0, buf.length); |
| 906 | } else if (cls == short.class) { |
| 907 | short[] buf = (short[])value; |
| 908 | write(offset, buf, 0, buf.length); |
| 909 | } else if (cls == char.class) { |
| 910 | char[] buf = (char[])value; |
| 911 | write(offset, buf, 0, buf.length); |
| 912 | } else if (cls == int.class) { |
| 913 | int[] buf = (int[])value; |
| 914 | write(offset, buf, 0, buf.length); |
| 915 | } else if (cls == long.class) { |
| 916 | long[] buf = (long[])value; |
| 917 | write(offset, buf, 0, buf.length); |
| 918 | } else if (cls == float.class) { |
| 919 | float[] buf = (float[])value; |
| 920 | write(offset, buf, 0, buf.length); |
| 921 | } else if (cls == double.class) { |
| 922 | double[] buf = (double[])value; |
| 923 | write(offset, buf, 0, buf.length); |
| 924 | } else if (Pointer.class.isAssignableFrom(cls)) { |
| 925 | Pointer[] buf = (Pointer[])value; |
| 926 | write(offset, buf, 0, buf.length); |
| 927 | } else if (Structure.class.isAssignableFrom(cls)) { |
| 928 | Structure[] sbuf = (Structure[])value; |
| 929 | if (Structure.ByReference.class.isAssignableFrom(cls)) { |
| 930 | Pointer[] buf = new Pointer[sbuf.length]; |
| 931 | for (int i=0;i < sbuf.length;i++) { |
| 932 | if (sbuf[i] == null) { |
| 933 | buf[i] = null; |
| 934 | } else { |
| 935 | buf[i] = sbuf[i].getPointer(); |
| 936 | sbuf[i].write(); |
| 937 | } |
| 938 | } |
| 939 | write(offset, buf, 0, buf.length); |
| 940 | } else { |
| 941 | Structure first = sbuf[0]; |
| 942 | if (first == null) { |
| 943 | first = Structure.newInstance((Class<Structure>) cls, share(offset)); |
| 944 | sbuf[0] = first; |
| 945 | } else { |
| 946 | first.useMemory(this, (int)offset, true); |
| 947 | } |
| 948 | first.write(); |
| 949 | Structure[] tmp = first.toArray(sbuf.length); |
| 950 | for (int i=1;i < sbuf.length;i++) { |
| 951 | if (sbuf[i] == null) { |
| 952 | sbuf[i] = tmp[i]; |
| 953 | } else { |
| 954 | sbuf[i].useMemory(this, (int)(offset + i * sbuf[i].size()), true); |
| 955 | } |
| 956 | sbuf[i].write(); |
| 957 | } |
| 958 | } |
| 959 | } else if (NativeMapped.class.isAssignableFrom(cls)) { |
no test coverage detected