View Javadoc

1   package com.ochafik.lang.jnaerator.runtime;
2   
3   import com.sun.jna.ptr.ByReference;
4   
5   public class NativeSizeByReference extends ByReference {
6       public NativeSizeByReference() {
7           this(new NativeSize(0));
8       }
9   
10      public NativeSizeByReference(NativeSize value) {
11          super(NativeSize.SIZE);
12          setValue(value);
13      }
14  
15      public void setValue(NativeSize value) {
16          if (NativeSize.SIZE == 4)
17  			getPointer().setInt(0, value.intValue());
18  		else if (NativeSize.SIZE == 8)
19  			getPointer().setLong(0, value.longValue());
20  		else
21  			throw new RuntimeException("GCCLong has to be either 4 or 8 bytes.");
22      }
23  
24      public NativeSize getValue() {
25  		if (NativeSize.SIZE == 4)
26  			return new NativeSize(getPointer().getInt(0));
27  		else if (NativeSize.SIZE == 8)
28  			return new NativeSize(getPointer().getLong(0));
29  		else
30  			throw new RuntimeException("GCCLong has to be either 4 or 8 bytes.");
31      }
32  }