/[classpath]/classpath/gnu/java/nio/GenericMappedByteFileBuffer.cpp
ViewVC logotype

Diff of /classpath/gnu/java/nio/GenericMappedByteFileBuffer.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by rveldema, Mon Mar 11 16:24:12 2002 UTC revision 1.2 by rveldema, Tue Mar 12 11:36:22 2002 UTC
# Line 1  Line 1 
1  package manta.runtime;  package gnu.java.nio;
2    
3  import java.nio.*;  import java.nio.*;
4    
# Line 11  final public class MappedTYPEFileBuffer Line 11  final public class MappedTYPEFileBuffer
11   extends TYPEBuffer   extends TYPEBuffer
12  #endif  #endif
13  {  {
14      public long address;
15    boolean ro;    boolean ro;
16    boolean direct;    boolean direct;
17    FileChannelImpl ch;    public FileChannelImpl ch;
18    
19    MappedTYPEFileBuffer(FileChannelImpl ch)    public MappedTYPEFileBuffer(FileChannelImpl ch)
20    {    {
21      this.ch = ch;      this.ch = ch;
22        address = ch.address;
23    }    }
24    
25    MappedTYPEFileBuffer(MappedTYPEFileBuffer b)    public MappedTYPEFileBuffer(MappedTYPEFileBuffer b)
26    {    {
27      this.ro = b.ro;      this.ro = b.ro;
28      this.ch = b.ch;      this.ch = b.ch;
29        address = b.address;
30    }    }
31    
32    boolean isReadOnly()    public boolean isReadOnly()
33    {    {
34      return ro;      return ro;
35    }    }
36    
37  #if SIZE == 1  #if SIZE == 1
38  #define GO(TYPE,ELT) \  #define GO(TYPE,ELT) \
39   static MantaNative ELT nio_read_ ## TYPE ## _file_channel(FileChannelImpl ch, int index); \   public static native ELT nio_read_ ## TYPE ## _file_channel(FileChannelImpl ch, int index); \
40   static MantaNative void nio_write_ ## TYPE ## _file_channel(FileChannelImpl ch, int index, ELT value)   public static native void nio_write_ ## TYPE ## _file_channel(FileChannelImpl ch, int index, ELT value)
41            
42    GO(Byte,byte);    GO(Byte,byte);
43    GO(Short,short);    GO(Short,short);
# Line 45  final public class MappedTYPEFileBuffer Line 48  final public class MappedTYPEFileBuffer
48    GO(Double,double);    GO(Double,double);
49  #endif  #endif
50    
51  public ELT get()  final public ELT get()
52    {    {
53      ELT a = MappedByteFileBuffer.nio_read_TYPE_file_channel(ch, pos);      ELT a = MappedByteFileBuffer.nio_read_TYPE_file_channel(ch, position());
54      pos += SIZE;      position(position() + SIZE);
55      return a;      return a;
56    }    }
57    
58  public TYPEBuffer put(ELT b)  final public TYPEBuffer put(ELT b)
59    {    {
60      MappedByteFileBuffer.nio_write_TYPE_file_channel(ch, pos, b);      MappedByteFileBuffer.nio_write_TYPE_file_channel(ch, position(), b);
61      pos += SIZE;      position(position() + SIZE);
62      return this;      return this;
63    }    }
64    
65  public ELT get(int index)  final public ELT get(int index)
66    {    {
67      ELT a = MappedByteFileBuffer.nio_read_TYPE_file_channel(ch, index);      ELT a = MappedByteFileBuffer.nio_read_TYPE_file_channel(ch, index);
68      return a;      return a;
69    }    }
70    
71  public TYPEBuffer put(int index, ELT b)  final public TYPEBuffer put(int index, ELT b)
72    {    {
73      MappedByteFileBuffer.nio_write_TYPE_file_channel(ch, index, b);      MappedByteFileBuffer.nio_write_TYPE_file_channel(ch, index, b);
74      return this;      return this;
75    }    }
76    
77  public TYPEBuffer compact()  final public TYPEBuffer compact()
78    {    {
79      return this;      return this;
80    }    }
81    
82  public  boolean isDirect()  final public  boolean isDirect()
83    {    {
84      return direct;      return direct;
85    }    }
86    
87  public TYPEBuffer slice()  final public TYPEBuffer slice()
88    {    {
89      MappedTYPEFileBuffer A = new MappedTYPEFileBuffer(this);      MappedTYPEFileBuffer A = new MappedTYPEFileBuffer(this);
90      return A;      return A;
# Line 99  public  TYPEBuffer asReadOnlyBuffer() Line 102  public  TYPEBuffer asReadOnlyBuffer()
102    }    }
103    
104  #define CONVERT(TYPE,STYPE)                                     \  #define CONVERT(TYPE,STYPE)                                     \
105      public  TYPE ## Buffer as ## TYPE ## Buffer()               \  final    public  TYPE ## Buffer as ## TYPE ## Buffer()          \
106      {                                                           \      {                                                           \
107          return new Mapped ## TYPE ## FileBuffer(ch);            \          return new Mapped ## TYPE ## FileBuffer(ch);            \
108      }                                                           \      }                                                           \
109  public  STYPE get ## TYPE()                                     \  final public  STYPE get ## TYPE()                                       \
110    {                                                             \    {                                                             \
111      STYPE a = MappedByteFileBuffer.nio_read_ ## TYPE ## _file_channel(ch, pos); \      STYPE a = MappedByteFileBuffer.nio_read_ ## TYPE ## _file_channel(ch, position());  \
112      pos += SIZE;                                                \      position(position() + SIZE);                                                \
113      return a;                                                   \      return a;                                                   \
114    }                                                             \    }                                                             \
115  public TYPEBuffer put ## TYPE(STYPE value)                              \  final public TYPEBuffer put ## TYPE(STYPE value)                                \
116    {                                                             \    {                                                             \
117      MappedByteFileBuffer.nio_write_ ## TYPE ## _file_channel(ch, pos, value);   \      MappedByteFileBuffer.nio_write_ ## TYPE ## _file_channel(ch, position(), value);    \
118      pos += SIZE;                                                \      position(position() + SIZE);                                                \
119      return this;                                                \      return this;                                                \
120    }                                                             \    }                                                             \
121  public STYPE get ## TYPE(int index)                                     \  final public STYPE get ## TYPE(int index)                                       \
122    {                                                             \    {                                                             \
123      STYPE a = MappedByteFileBuffer.nio_read_ ## TYPE ## _file_channel(ch, index);       \      STYPE a = MappedByteFileBuffer.nio_read_ ## TYPE ## _file_channel(ch, index);       \
124      return a;                                                   \      return a;                                                   \
125    }                                                             \    }                                                             \
126  public  TYPEBuffer put ## TYPE(int index, STYPE value)          \  final public  TYPEBuffer put ## TYPE(int index, STYPE value)            \
127    {                                                             \    {                                                             \
128      MappedByteFileBuffer.nio_write_ ## TYPE ## _file_channel(ch, index, value); \      MappedByteFileBuffer.nio_write_ ## TYPE ## _file_channel(ch, index, value); \
129      return this;                                                \      return this;                                                \

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26