end();
23 |
24 | }
25 |
26 | public Line.EffectiveAddress EA();
27 |
28 | public long sizeof();
29 |
30 | public Point start();
31 |
32 | public Point end();
33 |
34 | @Override
35 | public String toString();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/Point.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"x:jint:4","y:jint:4"})
16 | public interface Point extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer x();
21 |
22 | public IntPointer y();
23 |
24 | }
25 |
26 | public Point.EffectiveAddress EA();
27 |
28 | public long sizeof();
29 |
30 | public int x();
31 |
32 | public int y();
33 |
34 | public void x(int val);
35 |
36 | public void y(int val);
37 |
38 | @Override
39 | public String toString();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/MyPrimBooleanArray1DCharSeq.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.BooleanArray1D;
11 | /**
12 | * User defined layout
13 | */
14 | public interface MyPrimBooleanArray1DCharSeq extends BooleanArray1D, CharSequence {
15 |
16 |
17 | @Override
18 | public default char charAt(int index) {
19 | if(at(index)) {
20 | return 'T';
21 | } else {
22 | return 'F';
23 | }
24 | }
25 |
26 | @Override
27 | public default int length() {
28 | return (int)getLength();
29 | }
30 |
31 | @Override
32 | public default CharSequence subSequence(int start, int end) {
33 | return (CharSequence)this.range(start, (end - start));
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/myline/Point.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.myline;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"x:jint:4","y:jint:4"})
16 | public interface Point extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer x();
21 |
22 | public IntPointer y();
23 |
24 | }
25 |
26 | public Point.EffectiveAddress EA();
27 |
28 | public long sizeof();
29 |
30 | public int x();
31 |
32 | public int y();
33 |
34 | public void x(int val);
35 |
36 | public void y(int val);
37 |
38 | @Override
39 | public String toString();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/myline/TestMyLine.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.myline;
9 |
10 | import com.ibm.layout.Layout;
11 | import com.ibm.layout.Location;
12 | import com.user.types.MyLine;
13 |
14 | public class TestMyLine {
15 |
16 | public static void main(String[] args) {
17 | System.out.println("== testMyLine ==");
18 | MyLine line = Layout.getLayout(MyLine.class);
19 | Location loc = new Location(new byte[(int) (line.sizeof())]);
20 | line.bindLocation(loc);
21 | System.out.println("line: " + line);
22 | System.out.println(" length: " + line.length());
23 | line.st(10, 11);
24 | line.en(20, 21);
25 | System.out.println("line: " + line);
26 | System.out.println(" length: " + line.length());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/ArrayElement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"item1:jint:4","item2:jint:4"})
16 | public interface ArrayElement extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer item1();
21 |
22 | public IntPointer item2();
23 |
24 | }
25 |
26 | public ArrayElement.EffectiveAddress EA();
27 |
28 | public long sizeof();
29 |
30 | public int item1();
31 |
32 | public int item2();
33 |
34 | public void item1(int val);
35 |
36 | public void item2(int val);
37 |
38 | @Override
39 | public String toString();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/LayoutDesc.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | import java.lang.annotation.Documented;
11 | import java.lang.annotation.ElementType;
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.RetentionPolicy;
14 | import java.lang.annotation.Target;
15 |
16 | /**
17 | * Describes the data layout.
18 | *
19 | * e.g.
20 | *
21 | * struct Point {
22 | * jint x;
23 | * jint y;
24 | * }
25 | *
26 | *
27 | * corresponds to
28 | *
29 | *
30 | * {@code @LayoutDesc}({ "x:jint:+0:4", "y:jint:+4:4" })
31 | *
32 | */
33 | @Retention(RetentionPolicy.RUNTIME)
34 | @Target(ElementType.TYPE)
35 | @Documented
36 | public @interface LayoutDesc {
37 | String[] value();
38 | }
39 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/M3.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.Pointer;
11 | import com.ibm.layout.Array2D;
12 | import com.ibm.layout.Layout;
13 | import com.ibm.layout.LayoutDesc;
14 |
15 | /* Generated by LD2J */
16 | @LayoutDesc({"m:Int[2][2]:16","n:Int[2][2]:16","p:Int[2][2]:16"})
17 | public interface M3 extends Layout {
18 |
19 | interface EffectiveAddress {
20 |
21 | public Pointer m();
22 |
23 | public Pointer n();
24 |
25 | public Pointer p();
26 |
27 | }
28 |
29 | public M3.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public Array2D m();
34 |
35 | public Array2D n();
36 |
37 | public Array2D p();
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/IntM3.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.IntArray2D;
12 | import com.ibm.layout.Layout;
13 | import com.ibm.layout.LayoutDesc;
14 |
15 | /* Generated by LD2J */
16 | @LayoutDesc({"m:jint[2][2]:16","n:jint[2][2]:16","p:jint[2][2]:16"})
17 | public interface IntM3 extends Layout {
18 |
19 | interface EffectiveAddress {
20 |
21 | public IntPointer m();
22 |
23 | public IntPointer n();
24 |
25 | public IntPointer p();
26 |
27 | }
28 |
29 | public IntM3.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public IntArray2D m();
34 |
35 | public IntArray2D n();
36 |
37 | public IntArray2D p();
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/variablelengtharray/ArrayElement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.variablelengtharray;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"item1:jint:4","item2:jint:4"})
16 | public interface ArrayElement extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer item1();
21 |
22 | public IntPointer item2();
23 |
24 | }
25 |
26 | public ArrayElement.EffectiveAddress EA();
27 |
28 | public long sizeof();
29 |
30 | public int item1();
31 |
32 | public int item2();
33 |
34 | public void item1(int val);
35 |
36 | public void item2(int val);
37 |
38 | @Override
39 | public String toString();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/CPEntry.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.javaclassfile;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.user.examples.javaclassfile.CPEntryPayload;
12 | import com.ibm.layout.Pointer;
13 | import com.ibm.layout.Layout;
14 | import com.ibm.layout.LayoutDesc;
15 |
16 | /* Generated by LD2J */
17 | @LayoutDesc({">tag:jbyte:1",">info:Byte[tag]:0"})
18 | public interface CPEntry extends Layout {
19 |
20 | interface EffectiveAddress {
21 |
22 | public BytePointer tag();
23 |
24 | public Pointer info();
25 |
26 | }
27 |
28 | public CPEntry.EffectiveAddress EA();
29 |
30 | public long sizeof();
31 |
32 | public byte tag();
33 |
34 | public CPEntryPayload info();
35 |
36 | @Override
37 | public String toString();
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/Point3D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"x:jint:4","y:jint:4","z:jint:4"})
16 | public interface Point3D extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer x();
21 |
22 | public IntPointer y();
23 |
24 | public IntPointer z();
25 |
26 | }
27 |
28 | public Point3D.EffectiveAddress EA();
29 |
30 | public long sizeof();
31 |
32 | public int x();
33 |
34 | public int y();
35 |
36 | public int z();
37 |
38 | public void x(int val);
39 |
40 | public void y(int val);
41 |
42 | public void z(int val);
43 |
44 | @Override
45 | public String toString();
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/AllPoints.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.Pointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"a:Point:8","b:Point3D:12","c:Point4D:16","d:Point5D:20"})
16 | public interface AllPoints extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public Pointer a();
21 |
22 | public Pointer b();
23 |
24 | public Pointer c();
25 |
26 | public Pointer d();
27 |
28 | }
29 |
30 | public AllPoints.EffectiveAddress EA();
31 |
32 | public long sizeof();
33 |
34 | public Point a();
35 |
36 | public Point3D b();
37 |
38 | public Point4D c();
39 |
40 | public Point5D d();
41 |
42 | @Override
43 | public String toString();
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VLS2.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"a:jbyte:1","b:Byte[a]:0"})
19 | public interface VLS2 extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public BytePointer a();
24 |
25 | public Pointer b();
26 |
27 | }
28 |
29 | public VLS2.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public byte a();
34 |
35 | public VLArray b();
36 |
37 | public void bindLocation(Location loc, byte repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VLSLong2.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.LongPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"a:jlong:8","b:Long[a]:0"})
19 | public interface VLSLong2 extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public LongPointer a();
24 |
25 | public Pointer b();
26 |
27 | }
28 |
29 | public VLSLong2.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public long a();
34 |
35 | public VLArray b();
36 |
37 | public void bindLocation(Location loc, long repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.ibm.layout.bin/jni_src/com_ibm_layout_UnsafeHelper.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | #include "jni.h"
9 | #include "com_ibm_layout_UnsafeHelper.h"
10 |
11 | jobject JNICALL
12 | Java_com_ibm_layout_UnsafeHelper_bufferFromAddressImpl(JNIEnv *env, jclass receiver, jlong addr, jlong size)
13 | {
14 | /* If an error occurs here, an exception will be set */
15 | return (*env)->NewDirectByteBuffer(env, (void *)addr, size);
16 | }
17 |
18 | jlong JNICALL
19 | Java_com_ibm_layout_UnsafeHelper_getDBBAddress(JNIEnv *env, jclass receiver, jobject buffer)
20 | {
21 | /* Get the data pointer */
22 | return (jlong) (*env)->GetDirectBufferAddress(env, buffer);
23 | }
24 |
25 | jlong JNICALL
26 | Java_com_ibm_layout_UnsafeHelper_getDBBLength(JNIEnv *env, jclass receiver, jobject buffer)
27 | {
28 | /* Get the data pointer */
29 | return (*env)->GetDirectBufferCapacity(env, buffer);
30 | }
31 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/jni_src/com_ibm_layout_UnsafeHelper.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | #include "jni.h"
9 | #include "com_ibm_layout_UnsafeHelper.h"
10 |
11 | jobject JNICALL
12 | Java_com_ibm_layout_UnsafeHelper_bufferFromAddressImpl(JNIEnv *env, jclass receiver, jlong addr, jlong size)
13 | {
14 | /* If an error occurs here, an exception will be set */
15 | return (*env)->NewDirectByteBuffer(env, (void *)addr, size);
16 | }
17 |
18 | jlong JNICALL
19 | Java_com_ibm_layout_UnsafeHelper_getDBBAddress(JNIEnv *env, jclass receiver, jobject buffer)
20 | {
21 | /* Get the data pointer */
22 | return (jlong) (*env)->GetDirectBufferAddress(env, buffer);
23 | }
24 |
25 | jlong JNICALL
26 | Java_com_ibm_layout_UnsafeHelper_getDBBLength(JNIEnv *env, jclass receiver, jobject buffer)
27 | {
28 | /* Get the data pointer */
29 | return (*env)->GetDirectBufferCapacity(env, buffer);
30 | }
31 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/VLArray.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | public interface VLArray extends LayoutType {
11 |
12 | /**
13 | * Get the number of elements in VLA.
14 | * @return the number of array elements
15 | */
16 | public long getVLALength();
17 |
18 | /**
19 | * Get an array element
20 | * @param index the element index
21 | * @return a layout targeting the array element
22 | */
23 | public abstract T at(long index);
24 |
25 | /**
26 | * Set an array element
27 | * @param index the element index
28 | * @param value new value of the array element
29 | */
30 | public abstract void put(long index, T value);
31 |
32 | /**
33 | * Get the size of the array
34 | * @return the data size in bytes
35 | */
36 | public long sizeof();
37 |
38 | @Override
39 | public String toString();
40 | }
41 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/Point4D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"x:jint:4","y:jint:4","z:jint:4","o:jint:4"})
16 | public interface Point4D extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer x();
21 |
22 | public IntPointer y();
23 |
24 | public IntPointer z();
25 |
26 | public IntPointer o();
27 |
28 | }
29 |
30 | public Point4D.EffectiveAddress EA();
31 |
32 | public long sizeof();
33 |
34 | public int x();
35 |
36 | public int y();
37 |
38 | public int z();
39 |
40 | public int o();
41 |
42 | public void x(int val);
43 |
44 | public void y(int val);
45 |
46 | public void z(int val);
47 |
48 | public void o(int val);
49 |
50 | @Override
51 | public String toString();
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VLS3.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"c:jbyte:1","d:VLS2[c]:0","e:jbyte:1"})
19 | public interface VLS3 extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public BytePointer c();
24 |
25 | public Pointer d();
26 |
27 | public BytePointer e();
28 |
29 | }
30 |
31 | public VLS3.EffectiveAddress EA();
32 |
33 | public long sizeof();
34 |
35 | public byte c();
36 |
37 | public VLArray d();
38 |
39 | public byte e();
40 |
41 | public void bindLocation(Location loc, byte repeatCountInitializer);
42 |
43 | public void e(byte val);
44 |
45 | @Override
46 | public String toString();
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VLSLong3.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.LongPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"c:jlong:8","d:VLSLong2[c]:0","e:jlong:8"})
19 | public interface VLSLong3 extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public LongPointer c();
24 |
25 | public Pointer d();
26 |
27 | public LongPointer e();
28 |
29 | }
30 |
31 | public VLSLong3.EffectiveAddress EA();
32 |
33 | public long sizeof();
34 |
35 | public long c();
36 |
37 | public VLArray d();
38 |
39 | public long e();
40 |
41 | public void bindLocation(Location loc, long repeatCountInitializer);
42 |
43 | public void e(long val);
44 |
45 | @Override
46 | public String toString();
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/ArrayCases.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.Pointer;
11 | import com.ibm.layout.Array1D;
12 | import com.ibm.layout.Array2D;
13 | import com.ibm.layout.Layout;
14 | import com.ibm.layout.LayoutDesc;
15 |
16 | /* Generated by LD2J */
17 | @LayoutDesc({"array1:Byte[10]:10","array2:Int[5][5]:100","array3:Double[3]:24","array4:Byte[2][3]:6"})
18 | public interface ArrayCases extends Layout {
19 |
20 | interface EffectiveAddress {
21 |
22 | public Pointer array1();
23 |
24 | public Pointer array2();
25 |
26 | public Pointer array3();
27 |
28 | public Pointer array4();
29 |
30 | }
31 |
32 | public ArrayCases.EffectiveAddress EA();
33 |
34 | public long sizeof();
35 |
36 | public Array1D array1();
37 |
38 | public Array2D array2();
39 |
40 | public Array1D array3();
41 |
42 | public Array2D array4();
43 |
44 | @Override
45 | public String toString();
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/variablelengtharray/VariableLengthArray.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.variablelengtharray;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"lengthOfArray:jint:4","elements:ArrayElement[lengthOfArray]:0"})
19 | public interface VariableLengthArray extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public IntPointer lengthOfArray();
24 |
25 | public Pointer elements();
26 |
27 | }
28 |
29 | public VariableLengthArray.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public int lengthOfArray();
34 |
35 | public VLArray elements();
36 |
37 | public void bindLocation(Location loc, int repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VariableLengthArrayWithIntRepeatCount.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"lengthOfArray:jint:1","elements:ArrayElement[lengthOfArray]:0"})
19 | public interface VariableLengthArrayWithIntRepeatCount extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public IntPointer lengthOfArray();
24 |
25 | public Pointer elements();
26 |
27 | }
28 |
29 | public VariableLengthArrayWithIntRepeatCount.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public int lengthOfArray();
34 |
35 | public VLArray elements();
36 |
37 | public void bindLocation(Location loc, int repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VariableLengthArrayWithByteRepeatCount.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"lengthOfArray:jbyte:1","elements:ArrayElement[lengthOfArray]:0"})
19 | public interface VariableLengthArrayWithByteRepeatCount extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public BytePointer lengthOfArray();
24 |
25 | public Pointer elements();
26 |
27 | }
28 |
29 | public VariableLengthArrayWithByteRepeatCount.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public byte lengthOfArray();
34 |
35 | public VLArray elements();
36 |
37 | public void bindLocation(Location loc, byte repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VariableLengthArrayWithCharRepeatCount.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.CharPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"lengthOfArray:jchar:1","elements:ArrayElement[lengthOfArray]:0"})
19 | public interface VariableLengthArrayWithCharRepeatCount extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public CharPointer lengthOfArray();
24 |
25 | public Pointer elements();
26 |
27 | }
28 |
29 | public VariableLengthArrayWithCharRepeatCount.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public char lengthOfArray();
34 |
35 | public VLArray elements();
36 |
37 | public void bindLocation(Location loc, char repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VariableLengthArrayWithLongRepeatCount.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.LongPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"lengthOfArray:jlong:1","elements:ArrayElement[lengthOfArray]:0"})
19 | public interface VariableLengthArrayWithLongRepeatCount extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public LongPointer lengthOfArray();
24 |
25 | public Pointer elements();
26 |
27 | }
28 |
29 | public VariableLengthArrayWithLongRepeatCount.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public long lengthOfArray();
34 |
35 | public VLArray elements();
36 |
37 | public void bindLocation(Location loc, long repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/Point5D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutDesc;
13 |
14 | /* Generated by LD2J */
15 | @LayoutDesc({"x:jint:4","y:jint:4","z:jint:4","o:jint:4","p:jint:4"})
16 | public interface Point5D extends Layout {
17 |
18 | interface EffectiveAddress {
19 |
20 | public IntPointer x();
21 |
22 | public IntPointer y();
23 |
24 | public IntPointer z();
25 |
26 | public IntPointer o();
27 |
28 | public IntPointer p();
29 |
30 | }
31 |
32 | public Point5D.EffectiveAddress EA();
33 |
34 | public long sizeof();
35 |
36 | public int x();
37 |
38 | public int y();
39 |
40 | public int z();
41 |
42 | public int o();
43 |
44 | public int p();
45 |
46 | public void x(int val);
47 |
48 | public void y(int val);
49 |
50 | public void z(int val);
51 |
52 | public void o(int val);
53 |
54 | public void p(int val);
55 |
56 | @Override
57 | public String toString();
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VariableLengthArrayWithShortRepeatCount.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.ShortPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"lengthOfArray:jshort:1","elements:ArrayElement[lengthOfArray]:0"})
19 | public interface VariableLengthArrayWithShortRepeatCount extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public ShortPointer lengthOfArray();
24 |
25 | public Pointer elements();
26 |
27 | }
28 |
29 | public VariableLengthArrayWithShortRepeatCount.EffectiveAddress EA();
30 |
31 | public long sizeof();
32 |
33 | public short lengthOfArray();
34 |
35 | public VLArray elements();
36 |
37 | public void bindLocation(Location loc, short repeatCountInitializer);
38 |
39 | @Override
40 | public String toString();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/LD:
--------------------------------------------------------------------------------
1 | ">Byte",
2 | "val:jbyte:1";
3 |
4 | ">Short",
5 | "val:jshort:2";
6 |
7 | ">Int",
8 | "val:jint:4";
9 |
10 | ">Long",
11 | "val:jlong:8";
12 |
13 | ">Float",
14 | "val:jfloat:4";
15 |
16 | ">Double",
17 | "val:jdouble:8";
18 |
19 | ">CONSTANTUtf8Info",
20 | "tag:jbyte:1",
21 | "length:jshort:2",
22 | "bytes:Byte[length]:0";
23 |
24 | ">CPEntry",
25 | "tag:jbyte:1",
26 | "info:Byte[CPEntryPayload tag]:0";
27 |
28 | ">Attributes",
29 | "attrNameIndex:jshort:2",
30 | "attrLength:jint:4",
31 | "info:Byte[attrLength]:0";
32 |
33 | ">Fields",
34 | "accessFlags:jshort:2",
35 | "nameIndex:jshort:2",
36 | "descriptorIndex:jshort:2",
37 | "attributesCount:jshort:2",
38 | "attributeInfo:Attributes[attributesCount]:0";
39 |
40 | ">Methods",
41 | "accessFlags:jshort:2",
42 | "nameIndex:jshort:2",
43 | "descriptorIndex:jshort:2",
44 | "attributesCount:jshort:2",
45 | "attributeInfo:Attributes[attributesCount]:0";
46 |
47 | ">JavaClassFileFormat",
48 | "magic:jint:4",
49 | "minor:jshort:2",
50 | "major:jshort:2",
51 | "cpCount:jshort:2",
52 | "cp:CPEntry[ConstantPool cpCount]:0",
53 | "accessFlags:jshort:2",
54 | "thisClass:jshort:2",
55 | "superClass:jshort:2",
56 | "interfaceCount:jshort:2",
57 | "interfaces:Short[interfaceCount]:0",
58 | "fieldsCount:jshort:2",
59 | "fieldInfo:Fields[fieldsCount]:0",
60 | "methodsCount:jshort:2",
61 | "methodInfo:Methods[methodsCount]:0",
62 | "attributesCount:jshort:2",
63 | "attributeInfo:Attributes[attributesCount]:0";
64 |
65 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/Record0.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.IntPointer ;
11 | import com.ibm.layout.BytePointer ;
12 | import com.ibm.layout.Pointer;
13 | import com.ibm.layout.Array1D;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"col0:jint:4","col1:Byte[23]:23","col2:jbyte:1","col3:Byte[23]:23"})
19 | public interface Record0 extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public IntPointer col0();
24 |
25 | public Pointer col1();
26 |
27 | public BytePointer col2();
28 |
29 | public Pointer col3();
30 |
31 | }
32 |
33 | public Record0.EffectiveAddress EA();
34 |
35 | public long sizeof();
36 |
37 | public int col0();
38 |
39 | public Array1D col1();
40 |
41 | public byte col2();
42 |
43 | public Array1D col3();
44 |
45 | public void col0(int val);
46 |
47 | public void col2(byte val);
48 |
49 | @Override
50 | public String toString();
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/vlawithoperation/VlaWithOperation.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.vlawithoperation;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.user.examples.vlawithoperation.SubOne;
12 | import com.user.examples.vlawithoperation.AddOne;
13 | import com.ibm.layout.Pointer;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({"a:jbyte:1","b:Byte[a]:0","c:jbyte:1","d:Byte[c]:0"})
19 | public interface VlaWithOperation extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public BytePointer a();
24 |
25 | public Pointer b();
26 |
27 | public BytePointer c();
28 |
29 | public Pointer d();
30 |
31 | }
32 |
33 | public VlaWithOperation.EffectiveAddress EA();
34 |
35 | public long sizeof();
36 |
37 | public byte a();
38 |
39 | public SubOne b();
40 |
41 | public byte c();
42 |
43 | public AddOne d();
44 |
45 | public void a(byte val);
46 |
47 | @Override
48 | public String toString();
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/CONSTANTUtf8Info.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.javaclassfile;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.ibm.layout.ShortPointer ;
12 | import com.ibm.layout.Pointer;
13 | import com.ibm.layout.Location;
14 | import com.ibm.layout.VLArray;
15 | import com.ibm.layout.Layout;
16 | import com.ibm.layout.LayoutDesc;
17 |
18 | /* Generated by LD2J */
19 | @LayoutDesc({">tag:jbyte:1",">length:jshort:2",">bytes:Byte[length]:0"})
20 | public interface CONSTANTUtf8Info extends Layout {
21 |
22 | interface EffectiveAddress {
23 |
24 | public BytePointer tag();
25 |
26 | public ShortPointer length();
27 |
28 | public Pointer bytes();
29 |
30 | }
31 |
32 | public CONSTANTUtf8Info.EffectiveAddress EA();
33 |
34 | public long sizeof();
35 |
36 | public byte tag();
37 |
38 | public short length();
39 |
40 | public VLArray bytes();
41 |
42 | public void bindLocation(Location loc, short repeatCountInitializer);
43 |
44 | public void tag(byte val);
45 |
46 | @Override
47 | public String toString();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/ByteArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive byte.
12 | */
13 | public interface ByteArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the total size of the array
23 | * @return the data size in bytes
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract byte at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, byte value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/CPEntryPayload.java:
--------------------------------------------------------------------------------
1 | package com.user.examples.javaclassfile;
2 |
3 | import com.ibm.layout.Layout;
4 | import com.ibm.layout.Pointer;
5 | import com.ibm.layout.PointerType;
6 | import com.ibm.layout.PriviledgedVLArray;
7 |
8 | public interface CPEntryPayload extends PriviledgedVLArray {
9 | default long arrayLength(PointerType ptr) {
10 | @SuppressWarnings("unchecked")
11 | Pointer cpEntryPtr = (Pointer) ptr.castTo(CPEntry.class);
12 |
13 | switch (cpEntryPtr.lValue().tag()) {
14 | case 1:
15 | @SuppressWarnings("unchecked")
16 | Pointer utf8Ptr = (Pointer) ptr.castTo(CONSTANTUtf8Info.class);
17 | return utf8Ptr.lValue().length() + 2;
18 | case 3:
19 | //CONSTANT_Integer 3
20 | case 4:
21 | //CONSTANT_Float 4
22 | return 4;
23 | case 5:
24 | //CONSTANT_Long 5
25 | case 6:
26 | //CONSTANT_Double 6
27 | return 8;
28 | case 7:
29 | //CONSTANT_Class 7
30 | return 2;
31 | case 8:
32 | //CONSTANT_String 8
33 | return 2;
34 | case 9:
35 | //CONSTANT_Fieldref 9
36 | case 10:
37 | //CONSTANT_Methodref 10
38 | case 11:
39 | //CONSTANT_InterfaceMethodref 11
40 | return 4;
41 | case 12:
42 | //CONSTANT_NameAndType 12
43 | return 4;
44 | case 15:
45 | //CONSTANT_MethodHandle 15
46 | return 3;
47 | case 16:
48 | //CONSTANT_MethodType 16
49 | return 2;
50 | case 18:
51 | //CONSTANT_InvokeDynamic 18
52 | return 4;
53 | }
54 | return 0;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/CharArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive char.
12 | */
13 | public interface CharArray2D extends LayoutType {
14 |
15 |
16 | /**
17 | * Get the length of 1st dimension
18 | * @return number of elements in 1st dimension.
19 | */
20 | public long dim1();
21 |
22 | /**
23 | * Get the total size of the array
24 | * @return the data size in bytes
25 | */
26 | public long dim2();
27 |
28 | /**
29 | * Get an array element
30 | * @param i index in 1st dim
31 | * @param j index in 2nd dim
32 | * @return value of the array element
33 | */
34 | public abstract char at(long i, long j);
35 |
36 | /**
37 | * Set an array element
38 | * @param i index in 1st dim
39 | * @param j index in 2nd dim
40 | * @param value new value of the array element
41 | */
42 | public abstract void put(long i, long j, char value);
43 |
44 | /**
45 | * Get the total size of the array
46 | * @return the data size in bytes
47 | */
48 | public long sizeof();
49 |
50 | @Override
51 | public String toString();
52 | }
53 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/IntArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive int.
12 | */
13 | public interface IntArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the length of 2nd dimension
23 | * @return number of elements in 2nd dimension.
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract int at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, int value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VLS1.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.VLArray;
13 | import com.ibm.layout.Layout;
14 | import com.ibm.layout.LayoutDesc;
15 |
16 | /* Generated by LD2J */
17 | @LayoutDesc({"a:jbyte:1","b:Byte[a]:0","c:jbyte:1","d:Byte[c]:0","e:jbyte:1","f:Byte[e]:0"})
18 | public interface VLS1 extends Layout {
19 |
20 | interface EffectiveAddress {
21 |
22 | public BytePointer a();
23 |
24 | public Pointer b();
25 |
26 | public BytePointer c();
27 |
28 | public Pointer d();
29 |
30 | public BytePointer e();
31 |
32 | public Pointer f();
33 |
34 | }
35 |
36 | public VLS1.EffectiveAddress EA();
37 |
38 | public long sizeof();
39 |
40 | public byte a();
41 |
42 | public VLArray b();
43 |
44 | public byte c();
45 |
46 | public VLArray d();
47 |
48 | public byte e();
49 |
50 | public VLArray f();
51 |
52 | public void a(byte val);
53 |
54 | public void c(byte val);
55 |
56 | @Override
57 | public String toString();
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/LongArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive long.
12 | */
13 | public interface LongArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the length of 2nd dimension
23 | * @return number of elements in 2nd dimension.
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract long at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, long value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof() ;
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/FloatArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive Float.
12 | */
13 | public interface FloatArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the length of 2nd dimension
23 | * @return number of elements in 2nd dimension.
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract float at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, float value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/ShortArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive short.
12 | */
13 | public interface ShortArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the length of 2nd dimension
23 | * @return number of elements in 2nd dimension.
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract short at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, short value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/Attributes.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.javaclassfile;
9 |
10 | import com.ibm.layout.ShortPointer ;
11 | import com.ibm.layout.IntPointer ;
12 | import com.ibm.layout.Pointer;
13 | import com.ibm.layout.Location;
14 | import com.ibm.layout.VLArray;
15 | import com.ibm.layout.Layout;
16 | import com.ibm.layout.LayoutDesc;
17 |
18 | /* Generated by LD2J */
19 | @LayoutDesc({">attrNameIndex:jshort:2",">attrLength:jint:4",">info:Byte[attrLength]:0"})
20 | public interface Attributes extends Layout {
21 |
22 | interface EffectiveAddress {
23 |
24 | public ShortPointer attrNameIndex();
25 |
26 | public IntPointer attrLength();
27 |
28 | public Pointer info();
29 |
30 | }
31 |
32 | public Attributes.EffectiveAddress EA();
33 |
34 | public long sizeof();
35 |
36 | public short attrNameIndex();
37 |
38 | public int attrLength();
39 |
40 | public VLArray info();
41 |
42 | public void bindLocation(Location loc, int repeatCountInitializer);
43 |
44 | public void attrNameIndex(short val);
45 |
46 | @Override
47 | public String toString();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/com.user.src/com/user/types/VLSLong1.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.types;
9 |
10 | import com.ibm.layout.LongPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.VLArray;
13 | import com.ibm.layout.Layout;
14 | import com.ibm.layout.LayoutDesc;
15 |
16 | /* Generated by LD2J */
17 | @LayoutDesc({"a:jlong:8","b:Long[a]:0","c:jlong:8","d:Long[c]:0","e:jlong:8","f:Long[e]:0"})
18 | public interface VLSLong1 extends Layout {
19 |
20 | interface EffectiveAddress {
21 |
22 | public LongPointer a();
23 |
24 | public Pointer b();
25 |
26 | public LongPointer c();
27 |
28 | public Pointer d();
29 |
30 | public LongPointer e();
31 |
32 | public Pointer f();
33 |
34 | }
35 |
36 | public VLSLong1.EffectiveAddress EA();
37 |
38 | public long sizeof();
39 |
40 | public long a();
41 |
42 | public VLArray b();
43 |
44 | public long c();
45 |
46 | public VLArray d();
47 |
48 | public long e();
49 |
50 | public VLArray f();
51 |
52 | public void a(long val);
53 |
54 | public void c(long val);
55 |
56 | @Override
57 | public String toString();
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/DoubleArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primtive double.
12 | */
13 | public interface DoubleArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the length of 2nd dimension
23 | * @return number of elements in 2nd dimension.
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract double at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, double value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/BooleanArray2D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 2D array of primitive boolean.
12 | */
13 | public interface BooleanArray2D extends LayoutType {
14 |
15 | /**
16 | * Get the length of 1st dimension
17 | * @return number of elements in 1st dimension.
18 | */
19 | public long dim1();
20 |
21 | /**
22 | * Get the length of 2nd dimension
23 | * @return number of elements in 2nd dimension.
24 | */
25 | public long dim2();
26 |
27 | /**
28 | * Get an array element
29 | * @param i index in 1st dim
30 | * @param j index in 2nd dim
31 | * @return value of the array element
32 | */
33 | public abstract boolean at(long i, long j);
34 |
35 | /**
36 | * Set an array element
37 | * @param i index in 1st dim
38 | * @param j index in 2nd dim
39 | * @param value new value of the array element
40 | */
41 | public abstract void put(long i, long j, boolean value);
42 |
43 | /**
44 | * Get the total size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/multivla/MultiVla.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.multivla;
9 |
10 | import com.ibm.layout.BytePointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.VLArray;
13 | import com.ibm.layout.Layout;
14 | import com.ibm.layout.LayoutDesc;
15 |
16 | /* Generated by LD2J */
17 | @LayoutDesc({"a:jbyte:1","b:Byte[a]:0","c:jbyte:1","d:Byte[c]:0","e:jbyte:1","f:Byte[e]:0"})
18 | public interface MultiVla extends Layout {
19 |
20 | interface EffectiveAddress {
21 |
22 | public BytePointer a();
23 |
24 | public Pointer b();
25 |
26 | public BytePointer c();
27 |
28 | public Pointer d();
29 |
30 | public BytePointer e();
31 |
32 | public Pointer f();
33 |
34 | }
35 |
36 | public MultiVla.EffectiveAddress EA();
37 |
38 | public long sizeof();
39 |
40 | public byte a();
41 |
42 | public VLArray b();
43 |
44 | public byte c();
45 |
46 | public VLArray d();
47 |
48 | public byte e();
49 |
50 | public VLArray f();
51 |
52 | public void a(byte val);
53 |
54 | public void c(byte val);
55 |
56 | @Override
57 | public String toString();
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/com.ibm.layout.bin/jni_src/com_ibm_layout_UnsafeHelper.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | /* DO NOT EDIT THIS FILE - it is machine generated */
9 | #include
10 | /* Header for class com_ibm_layout_UnsafeHelper */
11 |
12 | #ifndef _Included_com_ibm_layout_UnsafeHelper
13 | #define _Included_com_ibm_layout_UnsafeHelper
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 | /*
18 | * Class: com_ibm_layout_UnsafeHelper
19 | * Method: bufferFromAddressImpl
20 | * Signature: (JJ)Ljava/nio/ByteBuffer;
21 | */
22 | JNIEXPORT jobject JNICALL Java_com_ibm_layout_UnsafeHelper_bufferFromAddressImpl
23 | (JNIEnv *, jclass, jlong, jlong);
24 |
25 | /*
26 | * Class: com_ibm_layout_UnsafeHelper
27 | * Method: getDBBAddress
28 | * Signature: (Ljava/nio/ByteBuffer;)J
29 | */
30 | JNIEXPORT jlong JNICALL Java_com_ibm_layout_UnsafeHelper_getDBBAddress
31 | (JNIEnv *, jclass, jobject);
32 |
33 | /*
34 | * Class: com_ibm_layout_UnsafeHelper
35 | * Method: getDBBLength
36 | * Signature: (Ljava/nio/ByteBuffer;)J
37 | */
38 | JNIEXPORT jlong JNICALL Java_com_ibm_layout_UnsafeHelper_getDBBLength
39 | (JNIEnv *, jclass, jobject);
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
44 | #endif
45 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/jni_src/com_ibm_layout_UnsafeHelper.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | /* DO NOT EDIT THIS FILE - it is machine generated */
9 | #include
10 | /* Header for class com_ibm_layout_UnsafeHelper */
11 |
12 | #ifndef _Included_com_ibm_layout_UnsafeHelper
13 | #define _Included_com_ibm_layout_UnsafeHelper
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 | /*
18 | * Class: com_ibm_layout_UnsafeHelper
19 | * Method: bufferFromAddressImpl
20 | * Signature: (JJ)Ljava/nio/ByteBuffer;
21 | */
22 | JNIEXPORT jobject JNICALL Java_com_ibm_layout_UnsafeHelper_bufferFromAddressImpl
23 | (JNIEnv *, jclass, jlong, jlong);
24 |
25 | /*
26 | * Class: com_ibm_layout_UnsafeHelper
27 | * Method: getDBBAddress
28 | * Signature: (Ljava/nio/ByteBuffer;)J
29 | */
30 | JNIEXPORT jlong JNICALL Java_com_ibm_layout_UnsafeHelper_getDBBAddress
31 | (JNIEnv *, jclass, jobject);
32 |
33 | /*
34 | * Class: com_ibm_layout_UnsafeHelper
35 | * Method: getDBBLength
36 | * Signature: (Ljava/nio/ByteBuffer;)J
37 | */
38 | JNIEXPORT jlong JNICALL Java_com_ibm_layout_UnsafeHelper_getDBBLength
39 | (JNIEnv *, jclass, jobject);
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
44 | #endif
45 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/Layout.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | import java.lang.reflect.Constructor;
11 |
12 | /**
13 | * A singleton layout.
14 | *
15 | * Example Usage
16 | *
17 | * Point c = Point.getLayout(Point.class);
18 | * Location loc = new Location(new byte[(int)c.sizeof()]);
19 | * c.bindLocation(loc);
20 | * c.x(10);
21 | * c.y(20);
22 | *
23 | */
24 | public interface Layout extends LayoutType {
25 | //TODO need to make sure src is of the same type as current layout
26 | void copyFrom(Layout src);
27 |
28 | /**
29 | * Create a singleton layout instance
30 | * @param cls The layout class.
31 | * @param subclass of Layout
32 | * @return a layout instance
33 | */
34 | public static T getLayout(final Class cls) {
35 | try {
36 | LayoutHelper f = LayoutHelper.getFactory();
37 | Class implCls = f.genLayoutImpl(cls);
38 | Constructor ctor = implCls.getDeclaredConstructor();
39 | ctor.setAccessible(true);
40 | T newInst = ctor.newInstance();
41 | return newInst;
42 | } catch (Exception e) {
43 | e.printStackTrace();
44 | }
45 | return null;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/IntArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive int.
12 | */
13 | public interface IntArray1D extends LayoutType {
14 | /**
15 | * Get the number of array elements.
16 | * @return the number of array elements
17 | */
18 | public long getLength();
19 |
20 | /**
21 | * Get an array element
22 | * @param index the element index
23 | * @return a layout targeting the array element
24 | */
25 | public abstract int at(long index);
26 |
27 | /**
28 | * Set an array element
29 | * @param index the element index
30 | * @param value new value of the array element
31 | */
32 | public abstract void put(long index, int value);
33 |
34 | /**
35 | * Extract a sub range of the array
36 | * @param startIdx the starting array index
37 | * @param length the number of array elements to extract
38 | * @return a layout targeting a sub range of the array
39 | */
40 | public abstract IntArray1D range(long startIdx, long length);
41 |
42 | /**
43 | * Get the size of the array
44 | * @return the data size in bytes
45 | */
46 | public long sizeof();
47 |
48 | @Override
49 | public String toString();
50 | }
51 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/ByteArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive byte.
12 | */
13 | public interface ByteArray1D extends LayoutType {
14 |
15 | /**
16 | * Get the number of array elements.
17 | * @return the number of array elements
18 | */
19 | public long getLength();
20 |
21 | /**
22 | * Get an array element
23 | * @param index the element index
24 | * @return value of the array element
25 | */
26 | public abstract byte at(long index);
27 |
28 | /**
29 | * Set an array element
30 | * @param index the element index
31 | * @param value new value of the array element
32 | */
33 | public abstract void put(long index, byte value);
34 |
35 | /**
36 | * Extract a sub range of the array
37 | * @param startIdx the starting array index
38 | * @param length the number of array elements to extract
39 | * @return a layout targeting a sub range of the array
40 | */
41 | public abstract ByteArray1D range(long startIdx, long length);
42 |
43 | /**
44 | * Get the size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/FloatArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.FloatArray2D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 |
13 | /**
14 | * Generated implementation of FloatArray2D
15 | */
16 | final class FloatArray2DImpl extends LayoutTypeImpl implements FloatArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 |
21 | protected FloatArray2DImpl(long dim1, long dim2) {
22 | this.dim1 = dim1;
23 | this.dim2 = dim2;
24 | }
25 |
26 | @Override
27 | public float at(long i, long j) {
28 | return UnsafeImplHelper.loadNativeFloat(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 4);
29 | }
30 |
31 | @Override
32 | public void put(long i, long j, float val) {
33 | UnsafeImplHelper.storeNativeFloat(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 4, val);
34 | }
35 |
36 | public final long dim1() {
37 | return dim1;
38 | }
39 |
40 | public final long dim2() {
41 | return dim2;
42 | }
43 |
44 | public long sizeof() {
45 | return dim1 * dim2 * 4;
46 | }
47 |
48 | @Override
49 | public boolean containsVLA() {
50 | return false;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/CharArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive char.
12 | */
13 | public interface CharArray1D extends LayoutType {
14 |
15 | /**
16 | * Get the number of array elements.
17 | * @return the number of array elements
18 | */
19 | public long getLength();
20 |
21 | /**
22 | * Get an array element
23 | * @param index the element index
24 | * @return a layout targeting the array element
25 | */
26 | public abstract char at(long index);
27 |
28 | /**
29 | * Set an array element
30 | * @param index the element index
31 | * @param value new value of the array element
32 | */
33 | public abstract void put(long index, char value);
34 |
35 | /**
36 | * Extract a sub range of the array
37 | * @param startIdx the starting array index
38 | * @param length the number of array elements to extract
39 | * @return a layout targeting a sub range of the array
40 | */
41 | public abstract CharArray1D range(long startIdx, long length);
42 |
43 | /**
44 | * Get the size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/LongArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive long.
12 | */
13 | public interface LongArray1D extends LayoutType {
14 |
15 | /**
16 | * Get the number of array elements.
17 | * @return the number of array elements
18 | */
19 | public long getLength();
20 |
21 | /**
22 | * Get an array element
23 | * @param index the element index
24 | * @return a layout targeting the array element
25 | */
26 | public abstract long at(long index);
27 |
28 | /**
29 | * Set an array element
30 | * @param index the element index
31 | * @param value new value of the array element
32 | */
33 | public abstract void put(long index, long value);
34 |
35 | /**
36 | * Extract a sub range of the array
37 | * @param startIdx the starting array index
38 | * @param length the number of array elements to extract
39 | * @return a layout targeting a sub range of the array
40 | */
41 | public abstract LongArray1D range(long startIdx, long length);
42 |
43 | /**
44 | * Get the size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/FloatArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive float.
12 | */
13 | public interface FloatArray1D extends LayoutType {
14 |
15 | /**
16 | * Get the number of array elements.
17 | * @return the number of array elements
18 | */
19 | public long getLength();
20 |
21 | /**
22 | * Get an array element
23 | * @param index the element index
24 | * @return a layout targeting the array element
25 | */
26 | public abstract float at(long index);
27 |
28 | /**
29 | * Set an array element
30 | * @param index the element index
31 | * @param value new value of the array element
32 | */
33 | public abstract void put(long index, float value);
34 |
35 | /**
36 | * Extract a sub range of the array
37 | * @param startIdx the starting array index
38 | * @param length the number of array elements to extract
39 | * @return a layout targeting a sub range of the array
40 | */
41 | public abstract FloatArray1D range(long startIdx, long length);
42 |
43 | /**
44 | * Get the size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/ShortArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive short.
12 | */
13 | public interface ShortArray1D extends LayoutType {
14 |
15 | /**
16 | * Get the number of array elements.
17 | * @return the number of array elements
18 | */
19 | public long getLength();
20 |
21 | /**
22 | * Get an array element
23 | * @param index the element index
24 | * @return a layout targeting the array element
25 | */
26 | public abstract short at(long index);
27 |
28 | /**
29 | * Set an array element
30 | * @param index the element index
31 | * @param value new value of the array element
32 | */
33 | public abstract void put(long index, short value);
34 |
35 | /**
36 | * Extract a sub range of the array
37 | * @param startIdx the starting array index
38 | * @param length the number of array elements to extract
39 | * @return a layout targeting a sub range of the array
40 | */
41 | public abstract ShortArray1D range(long startIdx, long length);
42 |
43 | /**
44 | * Get the size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/DoubleArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive double.
12 | */
13 | public interface DoubleArray1D extends LayoutType {
14 |
15 | /**
16 | * Get the number of array elements.
17 | * @return the number of array elements
18 | */
19 | public long getLength();
20 |
21 | /**
22 | * Get an array element
23 | * @param index the element index
24 | * @return a layout targeting the array element
25 | */
26 | public abstract double at(long index);
27 |
28 | /**
29 | * Set an array element
30 | * @param index the element index
31 | * @param value new value of the array element
32 | */
33 | public abstract void put(long index, double value);
34 |
35 | /**
36 | * Extract a sub range of the array
37 | * @param startIdx the starting array index
38 | * @param length the number of array elements to extract
39 | * @return a layout targeting a sub range of the array
40 | */
41 | public abstract DoubleArray1D range(long startIdx, long length);
42 |
43 | /**
44 | * Get the size of the array
45 | * @return the data size in bytes
46 | */
47 | public long sizeof();
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/BooleanArray1D.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 | /**
11 | * 1D array of primitive boolean.
12 | */
13 | public interface BooleanArray1D extends LayoutType {
14 | /**
15 | * Get the number of array elements.
16 | * @return the number of array elements
17 | */
18 | public long getLength();
19 |
20 | /**
21 | * Get an array element
22 | * @param index the element index
23 | * @return a layout targeting the array element
24 | */
25 | public abstract boolean at(long index);
26 |
27 | /**
28 | * Set an array element
29 | * @param index the element index
30 | * @param value new value of the array element
31 | */
32 | public abstract void put(long index, boolean value);
33 |
34 | /**
35 | * Extract a sub range of the array
36 | * @param startIdx the starting array index
37 | * @param length the number of array elements to extract
38 | * @return a layout targeting a sub range of the array
39 | */
40 | public abstract BooleanArray1D range(long startIdx, long length);
41 |
42 | /**
43 | * Get the size of the array
44 | * @return the data size in bytes
45 | */
46 | public long sizeof();
47 |
48 |
49 | @Override
50 | public String toString();
51 | }
52 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/Fields.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.javaclassfile;
9 |
10 | import com.ibm.layout.ShortPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({">accessFlags:jshort:2",">nameIndex:jshort:2",">descriptorIndex:jshort:2",">attributesCount:jshort:2",">attributeInfo:Attributes[attributesCount]:0"})
19 | public interface Fields extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public ShortPointer accessFlags();
24 |
25 | public ShortPointer nameIndex();
26 |
27 | public ShortPointer descriptorIndex();
28 |
29 | public ShortPointer attributesCount();
30 |
31 | public Pointer attributeInfo();
32 |
33 | }
34 |
35 | public Fields.EffectiveAddress EA();
36 |
37 | public long sizeof();
38 |
39 | public short accessFlags();
40 |
41 | public short nameIndex();
42 |
43 | public short descriptorIndex();
44 |
45 | public short attributesCount();
46 |
47 | public VLArray attributeInfo();
48 |
49 | public void bindLocation(Location loc, short repeatCountInitializer);
50 |
51 | public void accessFlags(short val);
52 |
53 | public void nameIndex(short val);
54 |
55 | public void descriptorIndex(short val);
56 |
57 | @Override
58 | public String toString();
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/javaclassfile/Methods.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.javaclassfile;
9 |
10 | import com.ibm.layout.ShortPointer ;
11 | import com.ibm.layout.Pointer;
12 | import com.ibm.layout.Location;
13 | import com.ibm.layout.VLArray;
14 | import com.ibm.layout.Layout;
15 | import com.ibm.layout.LayoutDesc;
16 |
17 | /* Generated by LD2J */
18 | @LayoutDesc({">accessFlags:jshort:2",">nameIndex:jshort:2",">descriptorIndex:jshort:2",">attributesCount:jshort:2",">attributeInfo:Attributes[attributesCount]:0"})
19 | public interface Methods extends Layout {
20 |
21 | interface EffectiveAddress {
22 |
23 | public ShortPointer accessFlags();
24 |
25 | public ShortPointer nameIndex();
26 |
27 | public ShortPointer descriptorIndex();
28 |
29 | public ShortPointer attributesCount();
30 |
31 | public Pointer attributeInfo();
32 |
33 | }
34 |
35 | public Methods.EffectiveAddress EA();
36 |
37 | public long sizeof();
38 |
39 | public short accessFlags();
40 |
41 | public short nameIndex();
42 |
43 | public short descriptorIndex();
44 |
45 | public short attributesCount();
46 |
47 | public VLArray attributeInfo();
48 |
49 | public void bindLocation(Location loc, short repeatCountInitializer);
50 |
51 | public void accessFlags(short val);
52 |
53 | public void nameIndex(short val);
54 |
55 | public void descriptorIndex(short val);
56 |
57 | @Override
58 | public String toString();
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/IntArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.IntArray2D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 |
13 | /**
14 | * Generated implementation of IntArray2D
15 | */
16 | final class IntArray2DImpl extends LayoutTypeImpl implements IntArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | @Override
21 | public int at(long i, long j) {
22 | return UnsafeImplHelper.loadNativeInt(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 4);
23 | }
24 |
25 | @Override
26 | public void put(long i, long j, int val) {
27 | UnsafeImplHelper.storeNativeInt(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 4, val);
28 | }
29 |
30 | protected IntArray2DImpl(long dim1, long dim2) {
31 | this.dim1 = dim1;
32 | this.dim2 = dim2;
33 | }
34 |
35 | public final long dim1() {
36 | return dim1;
37 | }
38 |
39 | public final long dim2() {
40 | return dim2;
41 | }
42 |
43 | public long sizeof() {
44 | return dim1 * dim2 * 4;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | StringBuffer sb = new StringBuffer("[");
50 | for (long i = 0; i < dim1; i++) {
51 | for (long j = 0; j < dim2; j++) {
52 | sb.append(" " + at(i, j));
53 | }
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/CharArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.CharArray2D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 |
13 | /**
14 | * Generated implementation of CharArray2D
15 | */
16 | final class CharArray2DImpl extends LayoutTypeImpl implements CharArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | protected CharArray2DImpl(long dim1, long dim2) {
21 | this.dim1 = dim1;
22 | this.dim2 = dim2;
23 | }
24 |
25 | @Override
26 | public char at(long i, long j) {
27 | return UnsafeImplHelper.loadNativeChar(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 2);
28 | }
29 |
30 | @Override
31 | public void put(long i, long j, char val) {
32 | UnsafeImplHelper.storeNativeChar(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 2, val);
33 | }
34 |
35 | public final long dim1() {
36 | return dim1;
37 | }
38 |
39 | public final long dim2() {
40 | return dim2;
41 | }
42 |
43 | public long sizeof() {
44 | return dim1 * dim2 * 2;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | StringBuffer sb = new StringBuffer("[");
50 | for (long i = 0; i < dim1; i++) {
51 | for (long j = 0; j < dim2; j++) {
52 | sb.append(" " + at(i, j));
53 | }
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/LongArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.LayoutTypeImpl;
11 | import com.ibm.layout.LongArray2D;
12 |
13 | /**
14 | * Generated implementation of LongArray2D
15 | */
16 | final class LongArray2DImpl extends LayoutTypeImpl implements LongArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | protected LongArray2DImpl(long dim1, long dim2) {
21 | this.dim1 = dim1;
22 | this.dim2 = dim2;
23 | }
24 |
25 | @Override
26 | public long at(long i, long j) {
27 | return UnsafeImplHelper.loadNativeLong(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 8);
28 | }
29 |
30 | @Override
31 | public void put(long i, long j, long val) {
32 | UnsafeImplHelper.storeNativeLong(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 8, val);
33 | }
34 |
35 | public final long dim1() {
36 | return dim1;
37 | }
38 |
39 | public final long dim2() {
40 | return dim2;
41 | }
42 |
43 | public long sizeof() {
44 | return dim1 * dim2 * 8;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | StringBuffer sb = new StringBuffer("[");
50 | for (long i = 0; i < dim1; i++) {
51 | for (long j = 0; j < dim2; j++) {
52 | sb.append(" " + at(i, j));
53 | }
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/ShortArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.LayoutTypeImpl;
11 | import com.ibm.layout.ShortArray2D;
12 |
13 | /**
14 | * Generated implementation of ShortArray2D
15 | */
16 | final class ShortArray2DImpl extends LayoutTypeImpl implements ShortArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | protected ShortArray2DImpl(long dim1, long dim2) {
21 | this.dim1 = dim1;
22 | this.dim2 = dim2;
23 | }
24 |
25 | @Override
26 | public short at(long i, long j) {
27 | return UnsafeImplHelper.loadNativeShort(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 2);
28 | }
29 |
30 | @Override
31 | public void put(long i, long j, short val) {
32 | UnsafeImplHelper.storeNativeShort(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 2, val);
33 | }
34 |
35 | public long dim1() {
36 | return dim1;
37 | }
38 |
39 | public final long dim2() {
40 | return dim2;
41 | }
42 |
43 | public long sizeof() {
44 | return dim1 * dim2 * 2;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | StringBuffer sb = new StringBuffer("[");
50 | for (long i = 0; i < dim1; i++) {
51 | for (long j = 0; j < dim2; j++) {
52 | sb.append(" " + at(i, j));
53 | }
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/DoubleArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.DoubleArray2D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 |
13 | /**
14 | * Generated implementation of DoubleArray2D
15 | */
16 | final class DoubleArray2DImpl extends LayoutTypeImpl implements DoubleArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | protected DoubleArray2DImpl(long dim1, long dim2) {
21 | this.dim1 = dim1;
22 | this.dim2 = dim2;
23 | }
24 |
25 | @Override
26 | public double at(long i, long j) {
27 | return UnsafeImplHelper.loadNativeDouble(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 8);
28 | }
29 |
30 | @Override
31 | public void put(long i, long j, double val) {
32 | UnsafeImplHelper.storeNativeDouble(this.location.getData(), this.location.getOffset() + (i * dim2 + j) * 8, val);
33 | }
34 |
35 | public final long dim1() {
36 | return dim1;
37 | }
38 |
39 | public final long dim2() {
40 | return dim2;
41 | }
42 |
43 | public long sizeof() {
44 | return dim1 * dim2 * 8;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | StringBuffer sb = new StringBuffer("[");
50 | for (long i = 0; i < dim1; i++) {
51 | for (long j = 0; j < dim2; j++) {
52 | sb.append(" " + at(i, j));
53 | }
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/ByteArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.ByteArray2D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 |
13 | /**
14 | * Generated implementation of ByteArray2D
15 | */
16 | final class ByteArray2DImpl extends LayoutTypeImpl implements ByteArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | protected ByteArray2DImpl(long dim1, long dim2) {
21 | this.dim1 = dim1;
22 | this.dim2 = dim2;
23 | }
24 |
25 |
26 | @Override
27 | public byte at(long i, long j) {
28 | return UnsafeImplHelper.loadNativeByte(this.location.getData(), this.location.getOffset() + (i * dim2 + j));
29 | }
30 |
31 | @Override
32 | public void put(long i, long j, byte val) {
33 | UnsafeImplHelper.storeNativeByte(this.location.getData(), this.location.getOffset() + (i * dim2 + j), val);
34 | }
35 |
36 | @Override
37 | public final long dim1() {
38 | return dim1;
39 | }
40 |
41 | @Override
42 | public final long dim2() {
43 | return dim2;
44 | }
45 |
46 | @Override
47 | public long sizeof() {
48 | return dim1 * dim2;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | StringBuffer sb = new StringBuffer("[");
54 | for (long i = 0; i < dim1; i++) {
55 | for (long j = 0; j < dim2; j++) {
56 | sb.append(" " + at(i, j));
57 | }
58 | }
59 | sb.append(" ]");
60 | return sb.toString();
61 | }
62 |
63 | @Override
64 | public boolean containsVLA() {
65 | return false;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/BooleanArray2DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.BooleanArray2D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 |
13 | /**
14 | * Generated implementation of BooleanArray2D
15 | */
16 | final class BooleanArray2DImpl extends LayoutTypeImpl implements BooleanArray2D {
17 | protected final long dim1;
18 | protected final long dim2;
19 |
20 | public BooleanArray2DImpl(long dim1, long dim2) {
21 | this.dim1 = dim1;
22 | this.dim2 = dim2;
23 | }
24 |
25 | @Override
26 | public boolean at(long i, long j) {
27 | return UnsafeImplHelper.loadNativeBoolean(this.location.getData(), this.location.getOffset() + (i * dim2 + j));
28 | }
29 |
30 | @Override
31 | public void put(long i, long j, boolean val) {
32 | UnsafeImplHelper.storeNativeBoolean(this.location.getData(), this.location.getOffset() + (i * dim2 + j), val);
33 | }
34 |
35 | @Override
36 | public final long dim1() {
37 | return dim1;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | StringBuffer sb = new StringBuffer("[");
43 | for (long i = 0; i < dim1; i++) {
44 | for (long j = 0; j < dim2; j++) {
45 | sb.append(" " + at(i, j));
46 | }
47 | }
48 | sb.append(" ]");
49 | return sb.toString();
50 | }
51 |
52 | @Override
53 | public long sizeof() {
54 | return dim1 * dim2;
55 | }
56 |
57 | @Override
58 | public final long dim2() {
59 | return dim2;
60 | }
61 |
62 | @Override
63 | public boolean containsVLA() {
64 | return false;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/LongArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.LayoutTypeImpl;
11 | import com.ibm.layout.Location;
12 | import com.ibm.layout.LongArray1D;
13 |
14 | /**
15 | * Generated implementation of LongArray1D
16 | */
17 | final class LongArray1DImpl extends LayoutTypeImpl implements LongArray1D {
18 | protected final long length;
19 |
20 | protected LongArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public long at(long index) {
26 | return UnsafeImplHelper.loadNativeLong(this.location.getData(), this.location.getOffset() + index * 8);
27 | }
28 |
29 | @Override
30 | public void put(long index, long value) {
31 | UnsafeImplHelper.storeNativeLong(this.location.getData(), this.location.getOffset() + index * 8, value);
32 | }
33 |
34 | @Override
35 | public LongArray1D range(long startIdx, long length) {
36 | LongArray1DImpl l = new LongArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx * 8);
38 | l.bindLocation(loc);
39 | return l;
40 | }
41 |
42 | public final long getLength() {
43 | return length;
44 | }
45 |
46 | public long sizeof() {
47 | return 8 * length;
48 | }
49 |
50 | public String toString() {
51 | StringBuffer sb = new StringBuffer("[");
52 | for (long i = 0; i < length; i++) {
53 | sb.append(" " + at(i));
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/FloatArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.FloatArray1D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 | import com.ibm.layout.Location;
13 |
14 | /**
15 | * Generated implementation of FloatArray1D
16 | */
17 | final class FloatArray1DImpl extends LayoutTypeImpl implements FloatArray1D {
18 | protected final long length;
19 |
20 | protected FloatArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public float at(long index) {
26 | return UnsafeImplHelper.loadNativeFloat(this.location.getData(), this.location.getOffset() + index * 4);
27 | }
28 |
29 | @Override
30 | public void put(long index, float value) {
31 | UnsafeImplHelper.storeNativeFloat(this.location.getData(), this.location.getOffset() + index * 4, value);
32 | }
33 |
34 | @Override
35 | public FloatArray1D range(long startIdx, long length) {
36 | FloatArray1DImpl d = new FloatArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx * 4);
38 | d.bindLocation(loc);
39 | return d;
40 | }
41 |
42 | public final long getLength() {
43 | return length;
44 | }
45 |
46 | public long sizeof() {
47 | return 4 * length;
48 | }
49 |
50 | public String toString() {
51 | StringBuffer sb = new StringBuffer("[");
52 | for (long i = 0; i < length; i++) {
53 | sb.append(" " + at(i));
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/IntArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.IntArray1D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 | import com.ibm.layout.Location;
13 |
14 | /**
15 | * Generated implementation of IntArray1D
16 | */
17 | final class IntArray1DImpl extends LayoutTypeImpl implements IntArray1D {
18 | protected final long length;
19 |
20 | protected IntArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public int at(long index) {
26 | return UnsafeImplHelper.loadNativeInt(this.location.getData(), this.location.getOffset() + index * 4);
27 | }
28 |
29 | @Override
30 | public void put(long index, int value) {
31 | UnsafeImplHelper.storeNativeInt(this.location.getData(), this.location.getOffset() + index * 4, value);
32 | }
33 |
34 | @Override
35 | public IntArray1D range(long startIdx, long length) {
36 | IntArray1DImpl i = new IntArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx * 4);
38 | i.bindLocation(loc);
39 | return i;
40 | }
41 |
42 | public final long getLength() {
43 | return length;
44 | }
45 |
46 | public long sizeof() {
47 | return 4 * length;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | StringBuffer sb = new StringBuffer("[");
53 | for (long i = 0; i < length; i++) {
54 | sb.append(" " + at(i));
55 | }
56 | sb.append(" ]");
57 | return sb.toString();
58 | }
59 |
60 | @Override
61 | public boolean containsVLA() {
62 | return false;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/ShortArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.LayoutTypeImpl;
11 | import com.ibm.layout.Location;
12 | import com.ibm.layout.ShortArray1D;
13 |
14 | /**
15 | * Generated implementation of ShortArray1D
16 | */
17 | final class ShortArray1DImpl extends LayoutTypeImpl implements ShortArray1D {
18 | protected final long length;
19 |
20 | protected ShortArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 | @Override
24 | public short at(long index) {
25 | return UnsafeImplHelper.loadNativeShort(this.location.getData(), this.location.getOffset() + index * 2);
26 | }
27 |
28 | @Override
29 | public void put(long index, short value) {
30 | UnsafeImplHelper.storeNativeShort(this.location.getData(), this.location.getOffset() + index * 2, value);
31 | }
32 |
33 | @Override
34 | public ShortArray1D range(long startIdx, long length) {
35 | ShortArray1DImpl s = new ShortArray1DImpl(length);
36 | Location loc = new Location(this.location, startIdx * 2);
37 | s.bindLocation(loc);
38 | return s;
39 | }
40 |
41 | public long getLength() {
42 | return length;
43 | }
44 |
45 | public long sizeof() {
46 | return 2 * length;
47 | }
48 |
49 | public String toString() {
50 | StringBuffer sb = new StringBuffer("[");
51 | for (long i = 0; i < length; i++) {
52 | sb.append(" " + at(i));
53 | }
54 | sb.append(" ]");
55 | return sb.toString();
56 | }
57 |
58 | @Override
59 | public boolean containsVLA() {
60 | return false;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/CharArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.CharArray1D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 | import com.ibm.layout.Location;
13 |
14 | /**
15 | * Generated implementation of CharArray1D
16 | */
17 | final class CharArray1DImpl extends LayoutTypeImpl implements CharArray1D {
18 | protected final long length;
19 |
20 | protected CharArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public char at(long index) {
26 | return UnsafeImplHelper.loadNativeChar(this.location.getData(), this.location.getOffset() + index * 2);
27 | }
28 |
29 | @Override
30 | public void put(long index, char value) {
31 | UnsafeImplHelper.storeNativeChar(this.location.getData(), this.location.getOffset() + index * 2, value);
32 | }
33 |
34 | @Override
35 | public CharArray1D range(long startIdx, long length) {
36 | CharArray1DImpl c = new CharArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx * 2);
38 | c.bindLocation(loc);
39 | return c;
40 | }
41 |
42 | public final long getLength() {
43 | return length;
44 | }
45 |
46 | public long sizeof() {
47 | return 2 * length;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | StringBuffer sb = new StringBuffer("[");
53 | for (long i = 0; i < length; i++) {
54 | sb.append(" " + at(i));
55 | }
56 | sb.append(" ]");
57 | return sb.toString();
58 | }
59 |
60 | @Override
61 | public boolean containsVLA() {
62 | return false;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/DoubleArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.DoubleArray1D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 | import com.ibm.layout.Location;
13 |
14 | /**
15 | * Generated implementation of DoubleArray1D
16 | */
17 | final class DoubleArray1DImpl extends LayoutTypeImpl implements DoubleArray1D {
18 | protected final long length;
19 |
20 | protected DoubleArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public double at(long index) {
26 | return UnsafeImplHelper.loadNativeDouble(this.location.getData(), this.location.getOffset() + index * 8);
27 | }
28 |
29 | @Override
30 | public void put(long index, double value) {
31 | UnsafeImplHelper.storeNativeDouble(this.location.getData(), this.location.getOffset() + index * 8, value);
32 | }
33 |
34 | @Override
35 | public DoubleArray1D range(long startIdx, long length) {
36 | DoubleArray1DImpl d = new DoubleArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx * 8);
38 | d.bindLocation(loc);
39 | return d;
40 | }
41 |
42 | public final long getLength() {
43 | return length;
44 | }
45 |
46 | public long sizeof() {
47 | return 8 * length;
48 | }
49 |
50 | public String toString() {
51 | StringBuffer sb = new StringBuffer("[");
52 | for (long i = 0; i < length; i++) {
53 | sb.append(" " + at(i));
54 | }
55 | sb.append(" ]");
56 | return sb.toString();
57 | }
58 |
59 | @Override
60 | public boolean containsVLA() {
61 | return false;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/ByteArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.ByteArray1D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 | import com.ibm.layout.Location;
13 |
14 | /**
15 | * Generated implementation of ByteArray1D
16 | */
17 | final class ByteArray1DImpl extends LayoutTypeImpl implements ByteArray1D {
18 | protected final long length;
19 |
20 | public ByteArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public byte at(long index) {
26 | return UnsafeImplHelper.loadNativeByte(this.location.getData(), this.location.getOffset() + index);
27 | }
28 |
29 | @Override
30 | public void put(long index, byte value) {
31 | UnsafeImplHelper.storeNativeByte(this.location.getData(), this.location.getOffset() + index, value);
32 | }
33 |
34 | @Override
35 | public final ByteArray1D range(long startIdx, long length) {
36 | ByteArray1DImpl b = new ByteArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx);
38 | b.bindLocation(loc);
39 | return b;
40 | }
41 |
42 | @Override
43 | public final long getLength() {
44 | return length;
45 | }
46 |
47 | @Override
48 | public final long sizeof() {
49 | return length;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | StringBuffer sb = new StringBuffer("[");
55 | for (long i = 0; i < length; i++) {
56 | sb.append(" " + at(i));
57 | }
58 | sb.append(" ]");
59 | return sb.toString();
60 | }
61 |
62 | @Override
63 | public boolean containsVLA() {
64 | return false;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/BooleanArray1DImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.BooleanArray1D;
11 | import com.ibm.layout.LayoutTypeImpl;
12 | import com.ibm.layout.Location;
13 |
14 | /**
15 | * Generated implementation of BooleanArray1D
16 | */
17 | final class BooleanArray1DImpl extends LayoutTypeImpl implements BooleanArray1D {
18 | protected final long length;
19 |
20 | protected BooleanArray1DImpl(long length) {
21 | this.length = length;
22 | }
23 |
24 | @Override
25 | public boolean at(long index) {
26 | return UnsafeImplHelper.loadNativeBoolean(this.location.getData(), this.location.getOffset() + index);
27 | }
28 |
29 | @Override
30 | public void put(long index, boolean value) {
31 | UnsafeImplHelper.storeNativeBoolean(this.location.getData(), this.location.getOffset() + index, value);
32 | }
33 |
34 | @Override
35 | public BooleanArray1D range(long startIdx, long length) {
36 | BooleanArray1DImpl b = new BooleanArray1DImpl(length);
37 | Location loc = new Location(this.location, startIdx);
38 | b.bindLocation(loc);
39 | return b;
40 | }
41 |
42 | @Override
43 | public long getLength() {
44 | return length;
45 | }
46 |
47 | @Override
48 | public long sizeof() {
49 | return length;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | StringBuffer sb = new StringBuffer("[");
55 | for (long i = 0; i < length; i++) {
56 | sb.append(" " + at(i));
57 | }
58 | sb.append(" ]");
59 | return sb.toString();
60 | }
61 |
62 | @Override
63 | public boolean containsVLA() {
64 | return false;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/IntPointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.IntPointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutType;
13 | import com.ibm.layout.LayoutTypeImpl;
14 | import com.ibm.layout.Location;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class IntPointerImpl extends LayoutTypeImpl implements IntPointer {
21 | public int lValue() {
22 | return UnsafeImplHelper.loadNativeInt(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "IntPointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public IntPointer atOffset(long offset) {
58 | IntPointer newPointer = LayoutType.getPrimPointer(int.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 4));
60 | return newPointer;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/BytePointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.BytePointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutType;
13 | import com.ibm.layout.LayoutTypeImpl;
14 | import com.ibm.layout.Location;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class BytePointerImpl extends LayoutTypeImpl implements BytePointer {
21 | public byte lValue() {
22 | return UnsafeImplHelper.loadNativeByte(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "BytePointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public BytePointer atOffset(long offset) {
58 | BytePointer newPointer = LayoutType.getPrimPointer(byte.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 1));
60 | return newPointer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/LongPointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.Layout;
11 | import com.ibm.layout.LayoutType;
12 | import com.ibm.layout.LayoutTypeImpl;
13 | import com.ibm.layout.Location;
14 | import com.ibm.layout.LongPointer;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class LongPointerImpl extends LayoutTypeImpl implements LongPointer {
21 | public long lValue() {
22 | return UnsafeImplHelper.loadNativeLong(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "LongPointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public LongPointer atOffset(long offset) {
58 | LongPointer newPointer = LayoutType.getPrimPointer(long.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 8));
60 | return newPointer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/ShortPointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.Layout;
11 | import com.ibm.layout.LayoutType;
12 | import com.ibm.layout.LayoutTypeImpl;
13 | import com.ibm.layout.Location;
14 | import com.ibm.layout.PointerType;
15 | import com.ibm.layout.ShortPointer;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class ShortPointerImpl extends LayoutTypeImpl implements ShortPointer {
21 | public short lValue() {
22 | return UnsafeImplHelper.loadNativeShort(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "ShortPointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public ShortPointer atOffset(long offset) {
58 | ShortPointer newPointer = LayoutType.getPrimPointer(short.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 2));
60 | return newPointer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/FloatPointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.FloatPointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutType;
13 | import com.ibm.layout.LayoutTypeImpl;
14 | import com.ibm.layout.Location;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class FloatPointerImpl extends LayoutTypeImpl implements FloatPointer {
21 | public float lValue() {
22 | return UnsafeImplHelper.loadNativeFloat(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "FloatPointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public FloatPointer atOffset(long offset) {
58 | FloatPointer newPointer = LayoutType.getPrimPointer(float.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 4));
60 | return newPointer;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/CharPointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.CharPointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutType;
13 | import com.ibm.layout.LayoutTypeImpl;
14 | import com.ibm.layout.Location;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class CharPointerImpl extends LayoutTypeImpl implements CharPointer {
21 | public char lValue() {
22 | return UnsafeImplHelper.loadNativeChar(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {//FIX castTo on all
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "CharPointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public CharPointer atOffset(long offset) {
58 | CharPointer newPointer = LayoutType.getPrimPointer(char.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 2));
60 | return newPointer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/DoublePointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.DoublePointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutType;
13 | import com.ibm.layout.LayoutTypeImpl;
14 | import com.ibm.layout.Location;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class DoublePointerImpl extends LayoutTypeImpl implements DoublePointer {
21 | public double lValue() {
22 | return UnsafeImplHelper.loadNativeDouble(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "DoublePointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public DoublePointer atOffset(long offset) {
58 | DoublePointer newPointer = LayoutType.getPrimPointer(double.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 8));
60 | return newPointer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/gen/BooleanPointerImpl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout.gen;
9 |
10 | import com.ibm.layout.BooleanPointer;
11 | import com.ibm.layout.Layout;
12 | import com.ibm.layout.LayoutType;
13 | import com.ibm.layout.LayoutTypeImpl;
14 | import com.ibm.layout.Location;
15 | import com.ibm.layout.PointerType;
16 |
17 | /**
18 | * Pointer Layout
19 | */
20 | public class BooleanPointerImpl extends LayoutTypeImpl implements BooleanPointer {
21 | public boolean lValue() {
22 | return UnsafeImplHelper.loadNativeBoolean(this.location.getData(), this.location.getOffset());
23 | }
24 |
25 | public long sizeof() {
26 | return (long) UnsafeImplHelper.getUnsafe().addressSize();
27 | }
28 |
29 | @SuppressWarnings("unchecked")
30 | public PointerType castTo(Class> clazz) {
31 | LayoutType pointer = null;
32 | if (Layout.class.isAssignableFrom(clazz)) {
33 | pointer = LayoutType.getPointer((Class) clazz);
34 | } else {
35 | pointer = LayoutType.getPrimPointer(clazz);
36 | }
37 | pointer.bindLocation(this.location);
38 | return (PointerType) pointer;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "BooleanPointer base: " + this.location.getData() + " offset: " + this.location.getOffset();
44 | }
45 |
46 | @Override
47 | public boolean containsVLA() {
48 | return false;
49 | }
50 |
51 | @Override
52 | public Location getLocation() {
53 | return this.location;
54 | }
55 |
56 | @Override
57 | public BooleanPointer atOffset(long offset) {
58 | BooleanPointer newPointer = LayoutType.getPrimPointer(boolean.class);
59 | newPointer.bindLocation(new Location(this.location, offset * 1));
60 | return newPointer;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/com.ibm.layout.src/com/ibm/layout/Location.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014, 2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.ibm.layout;
9 |
10 |
11 | import sun.misc.Unsafe;
12 | /**
13 | * Location object representing addressable memory
14 | *
15 | */
16 | public class Location {
17 |
18 | private final byte[] data;
19 | private final long offset;
20 | private static final Unsafe unsafe = UnsafeHelper.getUnsafe();
21 | private static final long arrayBase = unsafe.arrayBaseOffset(byte[].class);
22 |
23 | /**
24 | * Overlay a location on top of a byte array
25 | *
26 | * @param data byte array
27 | */
28 | public Location(byte[] data) {
29 | this.data = data;
30 | this.offset = arrayBase;
31 | }
32 |
33 | /**
34 | * Overlay a location on top of a native address
35 | *
36 | * @param addr, a raw pointer to native memory
37 | */
38 | public Location(long addr) {
39 | this.data = null;
40 | this.offset = addr;
41 | }
42 |
43 | /**
44 | * Create a new location from at an offset from an existing location
45 | *
46 | * @param loc a raw pointer to native memory
47 | * @param offset offset
48 | */
49 | public Location(Location loc, long offset) {
50 | this.data = loc.getData();
51 | this.offset = offset + loc.getOffset();
52 | }
53 |
54 | /**
55 | * Return array that stores the data of the layout bound to it in bytes.
56 | * @return array that stores the data of the layout bound to it in bytes.
57 | */
58 | public byte[] getData() {
59 | return data;
60 | }
61 |
62 | /**
63 | * Return the offset of the location at which memory is allocated.
64 | * @return offset.
65 | */
66 | public long getOffset() {
67 | return offset;
68 | }
69 |
70 | /**
71 | * Check if there is enough space in the location to overlay a layout.
72 | *
73 | * @param dataLength of the layout to be overlaid.
74 | * @return True if there is enough space, false otherwise.
75 | */
76 | public boolean checkDataFits(long dataLength) {
77 | if (data == null) {
78 | return true;
79 | } else {
80 | return (dataLength <= data.length);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/com.user.src/com/user/examples/variablelengtharray/TestVariableLengthArray.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package com.user.examples.variablelengtharray;
9 |
10 | import java.lang.reflect.Field;
11 |
12 | import com.ibm.layout.Layout;
13 | import com.ibm.layout.Location;
14 | import com.user.types.Int;
15 |
16 | import sun.misc.Unsafe;
17 |
18 | public class TestVariableLengthArray {
19 | static Unsafe unsafe = null;
20 | static {
21 | try {
22 | Field field = Unsafe.class.getDeclaredField("theUnsafe");
23 | field.setAccessible(true);
24 | unsafe = (Unsafe)field.get(null);
25 | } catch (Exception e) {
26 | System.out.println("Could not get unsafe\n Test could not run.");
27 | e.printStackTrace();
28 | System.exit(0);
29 | }
30 | }
31 |
32 | public static void main(String[] args) {
33 | System.out.println("== testVariableLengthArray ==");
34 |
35 | //create variable length array with repeatCountInitializer
36 | VariableLengthArray variableLengthArray = Layout.getLayout(VariableLengthArray.class);
37 | //sizeof(jint) + sizeof(ArrayElement)*10
38 | ArrayElement element = Layout.getLayout(ArrayElement.class);
39 | long ptr = unsafe.allocateMemory(4 + element.sizeof() * 10);
40 | variableLengthArray.bindLocation(new Location(ptr), 10);
41 |
42 | System.out.println("lengthOfArray field is " + variableLengthArray.lengthOfArray());
43 | System.out.println("length of VLArray is " + variableLengthArray.elements().getVLALength());
44 |
45 | //overlay array on existing memory
46 | VariableLengthArray variableLengthArray2 = Layout.getLayout(VariableLengthArray.class);
47 | //sizeof(jint) + sizeof(ArrayElement)*5
48 | long ptr2 = unsafe.allocateMemory(4 + element.sizeof() * 5);
49 | Location loc = new Location(ptr2);
50 | //set lengthOfArray to 5
51 | Int lengthOfArray = Layout.getLayout(Int.class);
52 | lengthOfArray.bindLocation(loc);
53 | lengthOfArray.value(5);
54 | //bind to location
55 | variableLengthArray2.bindLocation(loc);
56 |
57 | System.out.println("lengthOfArray field is " + variableLengthArray2.lengthOfArray());
58 | System.out.println("length of VLArray is " + variableLengthArray2.elements().getVLALength());
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------