All Packages  This Package  Class Hierarchy  Class Search  Index

Class posix.CPtr
java.lang.Object
   |
   +----posix.CPtr

  Summary

public class  CPtr
     extends java.lang.Object
{
          // Fields 10
     public static final int CBYTE_TYPE;
     public static final int CDBL_TYPE;
     public static final int CFLT_TYPE;
     public static final int CINT_TYPE;
     public static final int CLONG_TYPE;
     public static final int CPTR_TYPE;
     public static final int CSHORT_TYPE;
     static final long NULL;
     long addr;
     int size;

          // Constructors 2
     CPtr();
     CPtr(long, int);

          // Methods 18
     public static native int alignOf(int);
     public static native int sizeOf(int);

     public native void copyIn(int, byte[], int, int);
     public native void copyOut(int, byte[], int, int);
     public native byte getByte(int);
     public int getCInt(int);
     public native int getCInt(int, int);
     public short getCShort(int);
     public native short getCShort(int, int);
     public native int getInt(int);
     public native short getShort(int);
     public native void setByte(int, byte);
     public void setCInt(int, int);
     public native void setCInt(int, int, int);
     public native void setCShort(int, int, short);
     public void setCShort(int, short);
     public native void setInt(int, int);
     public native void setShort(int, short);

          // Inner Classes 1
     public static class CPtr.Struct
}

Read and write memory reachable through a C ptr. Memory access is bounds checked to keep it within the size of region addressed by the C ptr. Only classes within the posix package can create CPtr objects, and the use of this class is completely safe at present. This is because we know the size of, for instance, shared memory segments or memory allocated with C malloc. At some future date, we may need the ability to dereference arbitrary C pointers - those dereferences will be unsafe.

We have not yet implemented the floating and 64-bit types for get/set due to a lack of need.

Author:
Stuart D. Gathman Copyright (C) 1998 Business Management Systems, Inc.

This code is distributed under the GNU Library General Public License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


  Cross Reference

Extended By:
Malloc

Returned By:
SharedMem.attach()





  Fields

· addr

Summary  |  Top
   long addr


· size

Summary  |  Top
   int size


· NULL

Summary  |  Top
   static final long NULL

A null CPtr value.


· CBYTE_TYPE

Summary  |  Top
   public static final int CBYTE_TYPE

Type codes for alignOf() and sizeOf().


· CSHORT_TYPE

Summary  |  Top
   public static final int CSHORT_TYPE

Type codes for alignOf() and sizeOf().


· CINT_TYPE

Summary  |  Top
   public static final int CINT_TYPE

Type codes for alignOf() and sizeOf().


· CLONG_TYPE

Summary  |  Top
   public static final int CLONG_TYPE

Type codes for alignOf() and sizeOf().


· CFLT_TYPE

Summary  |  Top
   public static final int CFLT_TYPE

Type codes for alignOf() and sizeOf().


· CDBL_TYPE

Summary  |  Top
   public static final int CDBL_TYPE

Type codes for alignOf() and sizeOf().


· CPTR_TYPE

Summary  |  Top
   public static final int CPTR_TYPE

Type codes for alignOf() and sizeOf().


  Constructors

· CPtr

Summary  |  Top

   CPtr() 


· CPtr

Summary  |  Top
   CPtr(long addr, 
        int size) 


  Methods

· alignOf

Summary  |  Top
   public static native int alignOf(int type) 

Get the alignment of a C type. Can be used to compute C struct offsets in a mostly system independent manner.



· sizeOf

Summary  |  Top
   public static native int sizeOf(int type) 

Get the size of a C type. Can be used to compute C struct offsets in a mostly system independent manner.



· copyOut

Summary  |  Top
   public native void copyOut(int off, 
                              byte[] ba, 
                              int pos, 
                              int cnt) 

Copy bytes out of C memory into a Java byte array.



· copyIn

Summary  |  Top
   public native void copyIn(int off, 
                             byte[] ba, 
                             int pos, 
                             int cnt) 

Copy a Java byte array into C memory.



· getByte

Summary  |  Top
   public native byte getByte(int off) 


· setByte

Summary  |  Top
   public native void setByte(int off, 
                              byte val) 


· getShort

Summary  |  Top
   public native short getShort(int off) 


· setShort

Summary  |  Top
   public native void setShort(int off, 
                               short val) 


· getInt

Summary  |  Top
   public native int getInt(int off) 


· setInt

Summary  |  Top
   public native void setInt(int off, 
                             int val) 


· getCShort

Summary  |  Top
   public native short getCShort(int off, 
                                 int idx) 


· setCShort

Summary  |  Top
   public native void setCShort(int off, 
                                int idx, 
                                short val) 


· getCInt

Summary  |  Top
   public native int getCInt(int off, 
                             int idx) 


· setCInt

Summary  |  Top
   public native void setCInt(int off, 
                              int idx, 
                              int val) 


· getCShort

Summary  |  Top
   public short getCShort(int off) 


· setCShort

Summary  |  Top
   public void setCShort(int off, 
                         short val) 


· getCInt

Summary  |  Top
   public int getCInt(int off) 


· setCInt

Summary  |  Top
   public void setCInt(int off, 
                       int val) 


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7