001 package com.ochafik.lang.jnaerator.runtime; 002 003 import com.sun.jna.ptr.ByReference; 004 005 public class NativeSizeByReference extends ByReference { 006 public NativeSizeByReference() { 007 this(new NativeSize(0)); 008 } 009 010 public NativeSizeByReference(NativeSize value) { 011 super(NativeSize.SIZE); 012 setValue(value); 013 } 014 015 public void setValue(NativeSize value) { 016 if (NativeSize.SIZE == 4) 017 getPointer().setInt(0, value.intValue()); 018 else if (NativeSize.SIZE == 8) 019 getPointer().setLong(0, value.longValue()); 020 else 021 throw new RuntimeException("GCCLong has to be either 4 or 8 bytes."); 022 } 023 024 public NativeSize getValue() { 025 if (NativeSize.SIZE == 4) 026 return new NativeSize(getPointer().getInt(0)); 027 else if (NativeSize.SIZE == 8) 028 return new NativeSize(getPointer().getLong(0)); 029 else 030 throw new RuntimeException("GCCLong has to be either 4 or 8 bytes."); 031 } 032 }