├── .gitignore ├── com.user.bin └── .gitignore ├── com.ibm.layout.bin ├── .gitignore └── jni_src │ ├── layouts.ver │ ├── makefile.lnx64 │ ├── makefile.win32 │ ├── com_ibm_layout_UnsafeHelper.c │ └── com_ibm_layout_UnsafeHelper.h ├── com.user.src └── com │ └── user │ ├── examples │ ├── myline │ │ ├── LD │ │ ├── package-info.java │ │ ├── header.h │ │ ├── MyLine.java │ │ ├── Line.java │ │ ├── Point.java │ │ └── TestMyLine.java │ ├── vlawithoperation │ │ ├── LD │ │ ├── AddOne.java │ │ ├── SubOne.java │ │ ├── TestVlaWitOps.java │ │ ├── Byte.java │ │ └── VlaWithOperation.java │ ├── multivla │ │ ├── LD │ │ ├── TestMultiVla.java │ │ ├── Byte.java │ │ └── MultiVla.java │ ├── variablelengtharray │ │ ├── LD │ │ ├── package-info.java │ │ ├── ArrayElement.java │ │ ├── VariableLengthArray.java │ │ └── TestVariableLengthArray.java │ └── javaclassfile │ │ ├── SampleClass.java │ │ ├── ConstantPool.java │ │ ├── Int.java │ │ ├── Byte.java │ │ ├── Long.java │ │ ├── Float.java │ │ ├── Short.java │ │ ├── Double.java │ │ ├── CPEntry.java │ │ ├── LD │ │ ├── CONSTANTUtf8Info.java │ │ ├── CPEntryPayload.java │ │ ├── Attributes.java │ │ ├── Fields.java │ │ └── Methods.java │ ├── test │ └── package-info.java │ └── types │ ├── package-info.java │ ├── UserDefinedArray.java │ ├── UserPrimArray.java │ ├── MyM3.java │ ├── Point5D_Ext.java │ ├── Point5D_DoubleExt.java │ ├── Int.java │ ├── V4.java │ ├── Byte.java │ ├── Char.java │ ├── Long.java │ ├── MyLine.java │ ├── Float.java │ ├── Short.java │ ├── MyByteArray1DCharSeq.java │ ├── MyDoubleArray1DCharSeq.java │ ├── MyLine_Ext.java │ ├── Double.java │ ├── MyCharArray1DCharSeq.java │ ├── MyIntArray1DCharSeq.java │ ├── MyPrimByteArray1DCharSeq.java │ ├── Boolean.java │ ├── MyFloatArray1DCharSeq.java │ ├── MyPrimCharArray1DCharSeq.java │ ├── MyPrimIntArray1DCharSeq.java │ ├── MyShortArray1DCharSeq.java │ ├── MyLongArray1DCharSeq.java │ ├── MyPrimLongArray1DCharSeq.java │ ├── MyPrimShortArray1DCharSeq.java │ ├── Line.java │ ├── MyPrimFloatArray1DCharSeq.java │ ├── MyPrimDoubleArray1DCharSeq.java │ ├── MyBooleanArray1DCharSeq.java │ ├── Point.java │ ├── MyPrimBooleanArray1DCharSeq.java │ ├── ArrayElement.java │ ├── M3.java │ ├── IntM3.java │ ├── Point3D.java │ ├── AllPoints.java │ ├── VLS2.java │ ├── VLSLong2.java │ ├── Point4D.java │ ├── VLS3.java │ ├── VLSLong3.java │ ├── ArrayCases.java │ ├── VariableLengthArrayWithIntRepeatCount.java │ ├── VariableLengthArrayWithByteRepeatCount.java │ ├── VariableLengthArrayWithCharRepeatCount.java │ ├── VariableLengthArrayWithLongRepeatCount.java │ ├── Point5D.java │ ├── VariableLengthArrayWithShortRepeatCount.java │ ├── Record0.java │ ├── VLS1.java │ └── VLSLong1.java ├── com.ibm.layout.src ├── jni_src │ ├── layouts.ver │ ├── makefile.lnx64 │ ├── makefile.win32 │ ├── com_ibm_layout_UnsafeHelper.c │ └── com_ibm_layout_UnsafeHelper.h └── com │ └── ibm │ └── layout │ ├── PointerType.java │ ├── Endian.java │ ├── ld2j │ ├── Endian.java │ └── VerifierException.java │ ├── package-info.java │ ├── gen │ ├── package-info.java │ ├── FloatArray2DImpl.java │ ├── IntArray2DImpl.java │ ├── CharArray2DImpl.java │ ├── LongArray2DImpl.java │ ├── ShortArray2DImpl.java │ ├── DoubleArray2DImpl.java │ ├── ByteArray2DImpl.java │ ├── BooleanArray2DImpl.java │ ├── LongArray1DImpl.java │ ├── FloatArray1DImpl.java │ ├── IntArray1DImpl.java │ ├── ShortArray1DImpl.java │ ├── CharArray1DImpl.java │ ├── DoubleArray1DImpl.java │ ├── ByteArray1DImpl.java │ ├── BooleanArray1DImpl.java │ ├── IntPointerImpl.java │ ├── BytePointerImpl.java │ ├── LongPointerImpl.java │ ├── ShortPointerImpl.java │ ├── FloatPointerImpl.java │ ├── CharPointerImpl.java │ ├── DoublePointerImpl.java │ └── BooleanPointerImpl.java │ ├── IntPointer.java │ ├── BytePointer.java │ ├── CharPointer.java │ ├── FloatPointer.java │ ├── LongPointer.java │ ├── ShortPointer.java │ ├── DoublePointer.java │ ├── BooleanPointer.java │ ├── Pointer.java │ ├── ComplexVLArray.java │ ├── PriviledgedVLArray.java │ ├── LayoutDesc.java │ ├── VLArray.java │ ├── ByteArray2D.java │ ├── CharArray2D.java │ ├── IntArray2D.java │ ├── LongArray2D.java │ ├── FloatArray2D.java │ ├── ShortArray2D.java │ ├── DoubleArray2D.java │ ├── BooleanArray2D.java │ ├── Layout.java │ ├── IntArray1D.java │ ├── ByteArray1D.java │ ├── CharArray1D.java │ ├── LongArray1D.java │ ├── FloatArray1D.java │ ├── ShortArray1D.java │ ├── DoubleArray1D.java │ ├── BooleanArray1D.java │ └── Location.java ├── .project └── .classpath /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | -------------------------------------------------------------------------------- /com.user.bin/.gitignore: -------------------------------------------------------------------------------- 1 | /com/ 2 | -------------------------------------------------------------------------------- /com.ibm.layout.bin/.gitignore: -------------------------------------------------------------------------------- 1 | /com/ 2 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/myline/LD: -------------------------------------------------------------------------------- 1 | "Point", 2 | "x:jint:4", 3 | "y:jint:4"; 4 | 5 | "Line", 6 | "start:Point:8", 7 | "end:Point:8"; 8 | 9 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/vlawithoperation/LD: -------------------------------------------------------------------------------- 1 | ">Byte", 2 | "val:jbyte:1"; 3 | 4 | "VlaWithOperation", 5 | "a:jbyte:1", 6 | "b:Byte[SubOne a]:0", 7 | "c:jbyte:1", 8 | "d:Byte[AddOne c]:0"; -------------------------------------------------------------------------------- /com.user.src/com/user/examples/multivla/LD: -------------------------------------------------------------------------------- 1 | ">Byte", 2 | "val:jbyte:1"; 3 | 4 | "MultiVla", 5 | "a:jbyte:1", 6 | "b:Byte[a]:0", 7 | "c:jbyte:1", 8 | "d:Byte[c]:0", 9 | "e:jbyte:1", 10 | "f:Byte[e]:0"; -------------------------------------------------------------------------------- /com.user.src/com/user/examples/variablelengtharray/LD: -------------------------------------------------------------------------------- 1 | "ArrayElement", 2 | "item1:jint:4", 3 | "item2:jint:4"; 4 | 5 | "VariableLengthArray", 6 | "lengthOfArray:jint:4", 7 | "elements:ArrayElement[lengthOfArray]:0"; 8 | 9 | -------------------------------------------------------------------------------- /com.ibm.layout.bin/jni_src/layouts.ver: -------------------------------------------------------------------------------- 1 | { 2 | global : 3 | JNI_OnLoad; 4 | JNI_OnUnload; 5 | Java_com_ibm_layout_UnsafeHelper_bufferFromAddressImpl; 6 | Java_com_ibm_layout_UnsafeHelper_getDBBAddress; 7 | Java_com_ibm_layout_UnsafeHelper_getDBBLength; 8 | local : *; 9 | }; 10 | -------------------------------------------------------------------------------- /com.ibm.layout.src/jni_src/layouts.ver: -------------------------------------------------------------------------------- 1 | { 2 | global : 3 | JNI_OnLoad; 4 | JNI_OnUnload; 5 | Java_com_ibm_layout_UnsafeHelper_bufferFromAddressImpl; 6 | Java_com_ibm_layout_UnsafeHelper_getDBBAddress; 7 | Java_com_ibm_layout_UnsafeHelper_getDBBLength; 8 | local : *; 9 | }; 10 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/PointerType.java: -------------------------------------------------------------------------------- 1 | package com.ibm.layout; 2 | 3 | public interface PointerType extends LayoutType { 4 | public Location getLocation(); 5 | 6 | public long sizeof(); 7 | 8 | public PointerType castTo(Class clazz); 9 | 10 | @Override 11 | public String toString(); 12 | } 13 | -------------------------------------------------------------------------------- /com.ibm.layout.bin/jni_src/makefile.lnx64: -------------------------------------------------------------------------------- 1 | PATH_TO_JNI_H = $(JAVA_HOME)/include 2 | 3 | CFLAGS = -I. -I$(PATH_TO_JNI_H) -I$(PATH_TO_JNI_H)/linux -fpic -m64 -Werror -c 4 | 5 | OBJECTS = com_ibm_layout_UnsafeHelper.o 6 | 7 | LIBNAME = liblayouts.so 8 | 9 | all: $(LIBNAME) 10 | 11 | $(LIBNAME): $(OBJECTS) 12 | $(CC) -shared -Wl,--version-script,layouts.ver -Wl,-soname=$(LIBNAME) -m64 -o $@ $(OBJECTS) -lm 13 | 14 | clean: 15 | rm -f $(OBJECTS) $(LIBNAME) 16 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | panama-layout-prototype 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /com.ibm.layout.src/jni_src/makefile.lnx64: -------------------------------------------------------------------------------- 1 | PATH_TO_JNI_H = $(JAVA_HOME)/include 2 | 3 | CFLAGS = -I. -I$(PATH_TO_JNI_H) -I$(PATH_TO_JNI_H)/linux -fpic -m64 -Werror -c 4 | 5 | OBJECTS = com_ibm_layout_UnsafeHelper.o 6 | 7 | LIBNAME = liblayouts.so 8 | 9 | all: $(LIBNAME) 10 | 11 | $(LIBNAME): $(OBJECTS) 12 | $(CC) -shared -Wl,--version-script,layouts.ver -Wl,-soname=$(LIBNAME) -m64 -o $@ $(OBJECTS) -lm 13 | 14 | clean: 15 | rm -f $(OBJECTS) $(LIBNAME) 16 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/Endian.java: -------------------------------------------------------------------------------- 1 | package com.ibm.layout; 2 | 3 | public enum Endian { 4 | BIG(">"), 5 | LITTLE("<"), 6 | NATIVE(""); 7 | 8 | String type; 9 | Endian(String type) { 10 | this.type = type; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | switch (this.name()) { 16 | case "BIG": 17 | return "BE"; 18 | case "LITTLE": 19 | return "LE"; 20 | case "NATIVE": 21 | return "Native"; 22 | default: 23 | return "Native"; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/ld2j/Endian.java: -------------------------------------------------------------------------------- 1 | package com.ibm.layout.ld2j; 2 | 3 | public enum Endian { 4 | BIG(">"), 5 | LITTLE("<"), 6 | NATIVE(""); 7 | 8 | String type; 9 | Endian(String type) { 10 | this.type = type; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | switch (this.name()) { 16 | case "BIG": 17 | return ">"; 18 | case "LITTLE": 19 | return "<"; 20 | case "NATIVE": 21 | return ""; 22 | default: 23 | return ""; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /com.user.src/com/user/test/package-info.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 | /** 9 | * Example code. 10 | */ 11 | package com.user.test; -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/package-info.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 | /** 9 | * Classes supplied by the Java SDK. 10 | */ 11 | package com.ibm.layout; -------------------------------------------------------------------------------- /com.user.src/com/user/examples/myline/package-info.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 | /** 9 | * Sample layout application 10 | */ 11 | package com.user.examples.myline; -------------------------------------------------------------------------------- /com.user.src/com/user/types/package-info.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 | /** 9 | * Generated interface types, defined by users. 10 | */ 11 | package com.user.types; -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/gen/package-info.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 | /** 9 | * Internal implementation classes for primitive arrays 10 | */ 11 | package com.ibm.layout.gen; -------------------------------------------------------------------------------- /com.user.src/com/user/examples/variablelengtharray/package-info.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 | /** 9 | * Sample layout application with variable length arrays 10 | */ 11 | package com.user.examples.variablelengtharray; -------------------------------------------------------------------------------- /com.user.src/com/user/types/UserDefinedArray.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 | * User defined layout 11 | */ 12 | public interface UserDefinedArray extends MyByteArray1DCharSeq { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/UserPrimArray.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 | * User defined layout 11 | */ 12 | public interface UserPrimArray extends MyPrimByteArray1DCharSeq { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/IntPointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface IntPointer extends PointerType { 14 | 15 | public int lValue(); 16 | 17 | public IntPointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/BytePointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface BytePointer extends PointerType { 14 | 15 | public byte lValue(); 16 | 17 | public BytePointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/CharPointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface CharPointer extends PointerType { 14 | 15 | public char lValue(); 16 | 17 | public CharPointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/FloatPointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface FloatPointer extends PointerType { 14 | 15 | public float lValue(); 16 | 17 | public FloatPointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/LongPointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface LongPointer extends PointerType { 14 | 15 | public long lValue(); 16 | 17 | public LongPointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/ShortPointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface ShortPointer extends PointerType { 14 | 15 | public short lValue(); 16 | 17 | public ShortPointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/DoublePointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface DoublePointer extends PointerType { 14 | 15 | public double lValue(); 16 | 17 | public DoublePointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/BooleanPointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface BooleanPointer extends PointerType { 14 | 15 | public boolean lValue(); 16 | 17 | public BooleanPointer atOffset(long offset); 18 | } 19 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/Pointer.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; 9 | 10 | /** 11 | * Pointer Layout 12 | */ 13 | public interface Pointer extends PointerType { 14 | 15 | public T lValue(); 16 | 17 | public Pointer atOffset(long offset); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /com.ibm.layout.bin/jni_src/makefile.win32: -------------------------------------------------------------------------------- 1 | PATH_TO_JNI_H = $(JAVA_HOME)/include 2 | 3 | CC = cl 4 | CFLAGS = -nologo /I. /I$(PATH_TO_JNI_H) /I$(PATH_TO_JNI_H)/win32 -DWIN32 -D_CRT_SECURE_NO_WARNINGS -W3 -WX -c 5 | 6 | OBJECTS = com_ibm_layout_UnsafeHelper.obj 7 | 8 | .suffixes: .res .rc .c .obj 9 | 10 | .rc.res: 11 | rc /nologo $< 12 | 13 | .c.obj: 14 | cl $(CFLAGS) -c $< 15 | 16 | 17 | all: layouts.dll 18 | 19 | layouts.lib: $(OBJECTS) 20 | lib /nologo -subsystem:console -out:layouts.lib -machine:i386 $(OBJECTS) 21 | 22 | layouts.dll: layouts.lib 23 | link /nologo /incremental:no -entry:_DllMainCRTStartup@12 -dll -machine:i386 -subsystem:console -out:layouts.dll -map:layouts.map $(OBJECTS) 24 | 25 | clean: 26 | rm -f $(OBJECTS) layouts.lib layouts.dll layouts.map 27 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/SampleClass.java: -------------------------------------------------------------------------------- 1 | package com.user.examples.javaclassfile; 2 | 3 | import java.lang.invoke.MethodHandle; 4 | import java.lang.invoke.MethodHandles; 5 | import java.lang.invoke.MethodType; 6 | 7 | public class SampleClass { 8 | int field1 = 123123; 9 | double feilds = 1324123.41234123F; 10 | long field2 = 123411L; 11 | float field3 = 1234.1234123F; 12 | static MethodHandle mh = null; 13 | 14 | void meth() { 15 | System.out.println("string1"); 16 | } 17 | 18 | public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException { 19 | System.out.println("blah"); 20 | 21 | mh = MethodHandles.lookup().findStatic(SampleClass.class, "main", MethodType.methodType(void.class, String[].class)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /com.ibm.layout.src/jni_src/makefile.win32: -------------------------------------------------------------------------------- 1 | PATH_TO_JNI_H = $(JAVA_HOME)/include 2 | 3 | CC = cl 4 | CFLAGS = -nologo /I. /I$(PATH_TO_JNI_H) /I$(PATH_TO_JNI_H)/win32 -DWIN32 -D_CRT_SECURE_NO_WARNINGS -W3 -WX -c 5 | 6 | OBJECTS = com_ibm_layout_UnsafeHelper.obj 7 | 8 | .suffixes: .res .rc .c .obj 9 | 10 | .rc.res: 11 | rc /nologo $< 12 | 13 | .c.obj: 14 | cl $(CFLAGS) -c $< 15 | 16 | 17 | all: layouts.dll 18 | 19 | layouts.lib: $(OBJECTS) 20 | lib /nologo -subsystem:console -out:layouts.lib -machine:i386 $(OBJECTS) 21 | 22 | layouts.dll: layouts.lib 23 | link /nologo /incremental:no -entry:_DllMainCRTStartup@12 -dll -machine:i386 -subsystem:console -out:layouts.dll -map:layouts.map $(OBJECTS) 24 | 25 | clean: 26 | rm -f $(OBJECTS) layouts.lib layouts.dll layouts.map 27 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/vlawithoperation/AddOne.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 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.ComplexVLArray; 11 | import com.ibm.layout.Layout; 12 | 13 | public interface AddOne extends ComplexVLArray { 14 | default long arrayLength(long value) { 15 | return (value + 1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/vlawithoperation/SubOne.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 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.ComplexVLArray; 11 | import com.ibm.layout.Layout; 12 | 13 | public interface SubOne extends ComplexVLArray { 14 | default long arrayLength(long value) { 15 | return (value - 1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyM3.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.Array2D; 11 | 12 | /** 13 | * User defined layout 14 | */ 15 | @Deprecated 16 | public interface MyM3 extends M3 { 17 | 18 | public static void initIdent(Array2D vv) { 19 | vv.at(0, 0).value(1); 20 | vv.at(0, 1).value(0); 21 | vv.at(1, 0).value(0); 22 | vv.at(1, 1).value(1); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/ComplexVLArray.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 ComplexVLArray extends VLArray { 11 | /** 12 | * Function that user must override with an implementation that calculates 13 | * the size of the variable length array 14 | * 15 | * @param value in repeat counter 16 | * @return 17 | */ 18 | public long arrayLength(long value); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/PriviledgedVLArray.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 PriviledgedVLArray extends VLArray { 11 | /** 12 | * Function that user must override with an implementation that calculates 13 | * the size of the variable length array 14 | * 15 | * @param ptr pointer to the enclosing layout 16 | * @return 17 | */ 18 | public long arrayLength(PointerType ptr); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Point5D_Ext.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 | /** 11 | * Generated interface 12 | */ 13 | public interface Point5D_Ext extends Point5D { 14 | 15 | public default int sum() { 16 | return this.x() + this.y() + this.z() + this.o() + this.p(); 17 | } 18 | 19 | public default void set(int x, int y, int z, int o, int p) { 20 | this.x(x); 21 | this.y(y); 22 | this.z(z); 23 | this.o(o); 24 | this.p(p); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /com.ibm.layout.src/com/ibm/layout/ld2j/VerifierException.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.ld2j; 9 | 10 | @SuppressWarnings("serial") 11 | class VerifierException extends Exception { 12 | 13 | public VerifierException() { 14 | super(); 15 | } 16 | 17 | /** 18 | * Report a VerifierException for the reason specified. 19 | * @param reason a String message indicating the reason. 20 | */ 21 | public VerifierException(String s) { 22 | super(s); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Point5D_DoubleExt.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 | /** 11 | * Generated interface 12 | */ 13 | public interface Point5D_DoubleExt extends Point5D { 14 | 15 | public default int product() { 16 | return this.x() * this.y() * this.z() * this.o() * this.p(); 17 | } 18 | 19 | public default void set(int x, int y, int z, int o, int p) { 20 | this.x(x); 21 | this.y(y); 22 | this.z(z); 23 | this.o(o); 24 | this.p(p); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/myline/header.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 | /* 9 | * This header file is for demonstration purposes only. The structures below are the 10 | * C equivalent of the layouts descriptions in the LD file. 11 | * 12 | * Ideally, a groveller would parse this file and generate the LD file with layout descriptions 13 | */ 14 | #include "stdint.h" 15 | 16 | struct Point { 17 | uint32_t x; 18 | uint32_t y; 19 | }; 20 | 21 | struct Line { 22 | struct Point start; 23 | struct Point end; 24 | }; 25 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/ConstantPool.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 ConstantPool extends PriviledgedVLArray { 9 | 10 | default long arrayLength(PointerType ptr) { 11 | @SuppressWarnings("unchecked") 12 | Pointer cpCountPtr = (Pointer) ptr.castTo(Short.class); 13 | short cpCount = (short) (cpCountPtr.lValue().val() - 1); 14 | @SuppressWarnings("unchecked") 15 | Pointer entries = (Pointer) cpCountPtr.atOffset(1).castTo(CPEntry.class); 16 | 17 | for (int i = 0; i < cpCount; i++) { 18 | byte tag = entries.lValue().tag(); 19 | if (5 == tag || 6 == tag) { 20 | cpCount--; 21 | } 22 | 23 | entries = (Pointer) entries.atOffset(1); 24 | } 25 | return cpCount; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/multivla/TestMultiVla.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 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.Layout; 11 | import com.ibm.layout.Location; 12 | 13 | public class TestMultiVla { 14 | 15 | public static void main(String[] args) { 16 | System.out.println("== testMultiVla =="); 17 | MultiVla vla = Layout.getLayout(MultiVla.class); 18 | Location loc = new Location(new byte[] {3,1,2,3,2,1,2,4,1,2,3,4}); 19 | vla.bindLocation(loc); 20 | 21 | System.out.println(vla); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/vlawithoperation/TestVlaWitOps.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 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.Layout; 11 | import com.ibm.layout.Location; 12 | 13 | public class TestVlaWitOps { 14 | 15 | public static void main(String[] args) { 16 | System.out.println("== testVlaWithOperation =="); 17 | VlaWithOperation vla = Layout.getLayout(VlaWithOperation.class); 18 | Location loc = new Location(new byte[] {4,1,2,3,2,1,2,3}); 19 | vla.bindLocation(loc); 20 | 21 | System.out.println(vla); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Int.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({"value:jint:4"}) 16 | public interface Int extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public IntPointer value(); 21 | 22 | } 23 | 24 | public Int.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public int value(); 29 | 30 | public void value(int val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/V4.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.IntArray1D; 12 | import com.ibm.layout.Layout; 13 | import com.ibm.layout.LayoutDesc; 14 | 15 | /* Generated by LD2J */ 16 | @LayoutDesc({"v4:jint[4]:16"}) 17 | public interface V4 extends Layout { 18 | 19 | interface EffectiveAddress { 20 | 21 | public IntPointer v4(); 22 | 23 | } 24 | 25 | public V4.EffectiveAddress EA(); 26 | 27 | public long sizeof(); 28 | 29 | public IntArray1D v4(); 30 | 31 | @Override 32 | public String toString(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Byte.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jbyte:1"}) 16 | public interface Byte extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public BytePointer value(); 21 | 22 | } 23 | 24 | public Byte.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public byte value(); 29 | 30 | public void value(byte val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Char.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jchar:2"}) 16 | public interface Char extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public CharPointer value(); 21 | 22 | } 23 | 24 | public Char.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public char value(); 29 | 30 | public void value(char val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Long.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jlong:8"}) 16 | public interface Long extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public LongPointer value(); 21 | 22 | } 23 | 24 | public Long.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public long value(); 29 | 30 | public void value(long val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyLine.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 | /** 11 | * User-defined layout. It extends the class 'Line' which is generated by LD2J. 12 | * 13 | */ 14 | public interface MyLine extends Line { 15 | 16 | public default double length() { 17 | int xdiff = en().x() - st().x(); 18 | int ydiff = en().y() - st().y(); 19 | return Math.sqrt(xdiff * xdiff + ydiff * ydiff); 20 | } 21 | 22 | public default void st(int x, int y) { 23 | st().x(x); 24 | st().y(y); 25 | } 26 | 27 | public default void en(int x, int y) { 28 | en().x(x); 29 | en().y(y); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Float.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.FloatPointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jfloat:4"}) 16 | public interface Float extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public FloatPointer value(); 21 | 22 | } 23 | 24 | public Float.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public float value(); 29 | 30 | public void value(float val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Short.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jshort:2"}) 16 | public interface Short extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public ShortPointer value(); 21 | 22 | } 23 | 24 | public Short.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public short value(); 29 | 30 | public void value(short val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyByteArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyByteArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index).value(); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyDoubleArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyDoubleArray1DCharSeq extends Array1D, CharSequence { 15 | @Override 16 | public default char charAt(int index) { 17 | return (char)at(index).value(); 18 | } 19 | 20 | @Override 21 | public default int length() { 22 | return (int)getLength(); 23 | } 24 | 25 | @Override 26 | public default CharSequence subSequence(int start, int end) { 27 | return (CharSequence)range(start, (end - start)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyLine_Ext.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 | /** 11 | * User-defined layout. It extends the class 'Line' which is generated by LD2J. 12 | * 13 | */ 14 | public interface MyLine_Ext extends MyLine { 15 | 16 | public default double length() { 17 | int xdiff = en().x() - st().x(); 18 | int ydiff = en().y() - st().y(); 19 | return Math.sqrt(xdiff * xdiff + ydiff * ydiff); 20 | } 21 | 22 | public default void st(int x, int y) { 23 | st().x(x); 24 | st().y(y); 25 | } 26 | 27 | public default void en(int x, int y) { 28 | en().x(x); 29 | en().y(y); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/Int.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.IntPointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jint:4"}) 16 | public interface Int extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public IntPointer val(); 21 | 22 | } 23 | 24 | public Int.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public int val(); 29 | 30 | public void val(int val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/multivla/Byte.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jbyte:1"}) 16 | public interface Byte extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public BytePointer val(); 21 | 22 | } 23 | 24 | public Byte.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public byte val(); 29 | 30 | public void val(byte val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Double.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.DoublePointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jdouble:8"}) 16 | public interface Double extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public DoublePointer value(); 21 | 22 | } 23 | 24 | public Double.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public double value(); 29 | 30 | public void value(double val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyCharArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyCharArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index).value(); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyIntArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyIntArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index).value(); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimByteArray1DCharSeq.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.ByteArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimByteArray1DCharSeq extends ByteArray1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /com.user.src/com/user/examples/myline/MyLine.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 | /** 11 | * User-defined layout. It extends the class 'Line' which is generated by LD2J. 12 | */ 13 | public interface MyLine extends Line { 14 | 15 | public default double length() { 16 | int xdiff = end().x() - start().x(); 17 | int ydiff = end().y() - start().y(); 18 | return Math.sqrt(xdiff * xdiff + ydiff * ydiff); 19 | } 20 | 21 | public default void st(int x, int y) { 22 | start().x(x); 23 | start().y(y); 24 | } 25 | 26 | public default void en(int x, int y) { 27 | end().x(x); 28 | end().y(y); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Boolean.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.BooleanPointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"value:jboolean:1"}) 16 | public interface Boolean extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public BooleanPointer value(); 21 | 22 | } 23 | 24 | public Boolean.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public boolean value(); 29 | 30 | public void value(boolean val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyFloatArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyFloatArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index).value(); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimCharArray1DCharSeq.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.CharArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimCharArray1DCharSeq extends CharArray1D, CharSequence { 15 | 16 | @Override 17 | public default CharSequence subSequence(int start, int end) { 18 | return (CharSequence)range(start, (end - start)); 19 | } 20 | 21 | @Override 22 | public default char charAt(int index) { 23 | return (char)at(index); 24 | } 25 | 26 | @Override 27 | public default int length() { 28 | return (int)getLength(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimIntArray1DCharSeq.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.IntArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimIntArray1DCharSeq extends IntArray1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)this.range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyShortArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyShortArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index).value(); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/Byte.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jbyte:1"}) 16 | public interface Byte extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public BytePointer val(); 21 | 22 | } 23 | 24 | public Byte.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public byte val(); 29 | 30 | public void val(byte val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/Long.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.LongPointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jlong:8"}) 16 | public interface Long extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public LongPointer val(); 21 | 22 | } 23 | 24 | public Long.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public long val(); 29 | 30 | public void val(long val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyLongArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyLongArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index).value(); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)range(start, (end - start)); 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimLongArray1DCharSeq.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.LongArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimLongArray1DCharSeq extends LongArray1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)this.range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimShortArray1DCharSeq.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.ShortArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimShortArray1DCharSeq extends ShortArray1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)this.range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/vlawithoperation/Byte.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.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jbyte:1"}) 16 | public interface Byte extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public BytePointer val(); 21 | 22 | } 23 | 24 | public Byte.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public byte val(); 29 | 30 | public void val(byte val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/Line.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({"st:Point:8","en:Point:8"}) 16 | public interface Line extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public Pointer st(); 21 | 22 | public Pointer en(); 23 | 24 | } 25 | 26 | public Line.EffectiveAddress EA(); 27 | 28 | public long sizeof(); 29 | 30 | public Point st(); 31 | 32 | public Point en(); 33 | 34 | @Override 35 | public String toString(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimFloatArray1DCharSeq.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.FloatArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimFloatArray1DCharSeq extends FloatArray1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)this.range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/Float.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.FloatPointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jfloat:4"}) 16 | public interface Float extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public FloatPointer val(); 21 | 22 | } 23 | 24 | public Float.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public float val(); 29 | 30 | public void val(float val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/Short.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.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jshort:2"}) 16 | public interface Short extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public ShortPointer val(); 21 | 22 | } 23 | 24 | public Short.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public short val(); 29 | 30 | public void val(short val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyPrimDoubleArray1DCharSeq.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.DoubleArray1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyPrimDoubleArray1DCharSeq extends DoubleArray1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | return (char)at(index); 19 | } 20 | 21 | @Override 22 | public default int length() { 23 | return (int)getLength(); 24 | } 25 | 26 | @Override 27 | public default CharSequence subSequence(int start, int end) { 28 | return (CharSequence)this.range(start, (end - start)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/javaclassfile/Double.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.DoublePointer ; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({">val:jdouble:8"}) 16 | public interface Double extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public DoublePointer val(); 21 | 22 | } 23 | 24 | public Double.EffectiveAddress EA(); 25 | 26 | public long sizeof(); 27 | 28 | public double val(); 29 | 30 | public void val(double val); 31 | 32 | @Override 33 | public String toString(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /com.user.src/com/user/types/MyBooleanArray1DCharSeq.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.Array1D; 11 | /** 12 | * User defined layout 13 | */ 14 | public interface MyBooleanArray1DCharSeq extends Array1D, CharSequence { 15 | 16 | @Override 17 | public default char charAt(int index) { 18 | char b = (true == at(index).value())? 'T' :'F'; 19 | return b; 20 | } 21 | 22 | @Override 23 | public default int length() { 24 | return (int)getLength(); 25 | } 26 | 27 | @Override 28 | public default CharSequence subSequence(int start, int end) { 29 | return (CharSequence)range(start, (end - start)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /com.user.src/com/user/examples/myline/Line.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.Pointer; 11 | import com.ibm.layout.Layout; 12 | import com.ibm.layout.LayoutDesc; 13 | 14 | /* Generated by LD2J */ 15 | @LayoutDesc({"start:Point:8","end:Point:8"}) 16 | public interface Line extends Layout { 17 | 18 | interface EffectiveAddress { 19 | 20 | public Pointer start(); 21 | 22 | public Pointer 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 | --------------------------------------------------------------------------------