Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /src/common/data-buffer-sig.sml
ViewVC logotype

View of /src/common/data-buffer-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 209 - (download) (annotate)
Tue Jun 17 03:28:53 2008 UTC (11 years, 3 months ago) by jhr
File size: 8863 byte(s)
  Hooks for explicit memory management.
(* data-buffer-sig.sml
 *
 * COPYRIGHT (c) 2008 John Reppy (http://cs.uchicago.edu/~jhr)
 * All rights reserved.
 *
 * This is an interface to arrays of 3d types that are allocated in the C heap.
 * It is designed to support the images, vertex arrays, draw buffers, etc.
 *)

signature DATA_BUFFER =
  sig

    type 'a buffer
    type 'a buffer2 = ('a * 'a) buffer
    type 'a buffer3 = ('a * 'a * 'a) buffer
    type 'a buffer4 = ('a * 'a * 'a * 'a) buffer

  (* sizes of element types *)
    type 'a size
    val sizeb   : Int8.int size
    val size2b  : (Int8.int * Int8.int) size
    val size3b  : (Int8.int * Int8.int * Int8.int) size
    val size4b  : (Int8.int * Int8.int * Int8.int * Int8.int) size
    val sizeub  : Word8.word size
    val size2ub : (Word8.word * Word8.word) size
    val size3ub : (Word8.word * Word8.word * Word8.word) size
    val size4ub : (Word8.word * Word8.word * Word8.word * Word8.word) size
    val sizes   : Int16.int size
    val size2s  : (Int16.int * Int16.int) size
    val size3s  : (Int16.int * Int16.int * Int16.int) size
    val size4s  : (Int16.int * Int16.int * Int16.int * Int16.int) size
    val sizeus  : Word16.word size
    val size2us : (Word16.word * Word16.word) size
    val size3us : (Word16.word * Word16.word * Word16.word) size
    val size4us : (Word16.word * Word16.word * Word16.word * Word16.word) size
    val sizei   : Int32.int size
    val size2i  : (Int32.int * Int32.int) size
    val size3i  : (Int32.int * Int32.int * Int32.int) size
    val size4i  : (Int32.int * Int32.int * Int32.int * Int32.int) size
    val sizeui  : Word32.word size
    val size2ui : (Word32.word * Word32.word) size
    val size3ui : (Word32.word * Word32.word * Word32.word) size
    val size4ui : (Word32.word * Word32.word * Word32.word * Word32.word) size
    val sizef   : Float.float size
    val size2f  : (Float.float * Float.float) size
    val size3f  : (Float.float * Float.float * Float.float) size
    val size4f  : (Float.float * Float.float * Float.float * Float.float) size
    val sized   : Double.double size
    val size2d  : (Double.double * Double.double) size
    val size3d  : (Double.double * Double.double * Double.double) size
    val size4d  : (Double.double * Double.double * Double.double * Double.double) size

    val make : {
	    alloc : C_Size.word -> MLton.Pointer.t,
	    free : MLton.Pointer.t -> unit
	  } -> ('a size * int) -> 'a buffer

    val new : ('a size * int) -> 'a buffer
    val delete : 'a buffer -> unit
    val valid : 'a buffer -> bool
    val length : 'a buffer -> int

  (* monomorphic get/set operations on buffers *)
    val getb  : (Int8.int buffer * int) -> Int8.int
    val setb  : (Int8.int buffer * int * Int8.int) -> unit
    val getub : (Word8.word buffer * int) -> Word8.word
    val setub : (Word8.word buffer * int * Word8.word) -> unit
    val gets  : (Int16.int buffer * int) -> Int16.int
    val sets  : (Int16.int buffer * int * Int16.int) -> unit
    val getus : (Word16.word buffer * int) -> Word16.word
    val setus : (Word16.word buffer * int * Word16.word) -> unit
    val geti  : (Int32.int buffer * int) -> Int32.int
    val seti  : (Int32.int buffer * int * Int32.int) -> unit
    val getui : (Word32.word buffer * int) -> Word32.word
    val setui : (Word32.word buffer * int * Word32.word) -> unit
    val getf  : (Float.float buffer * int) -> Float.float
    val setf  : (Float.float buffer * int * Float.float) -> unit
    val getd  : (Double.double buffer * int) -> Double.double
    val setd  : (Double.double buffer * int * Double.double) -> unit

    val get2b  : (Int8.int buffer2 * int) -> (Int8.int * Int8.int)
    val set2b  : (Int8.int buffer2 * int * (Int8.int * Int8.int)) -> unit
    val get2ub : (Word8.word buffer2 * int) -> (Word8.word * Word8.word)
    val set2ub : (Word8.word buffer2 * int * (Word8.word * Word8.word)) -> unit
    val get2s  : (Int16.int buffer2 * int) -> (Int16.int * Int16.int)
    val set2s  : (Int16.int buffer2 * int * (Int16.int * Int16.int)) -> unit
    val get2us : (Word16.word buffer2 * int) -> (Word16.word * Word16.word)
    val set2us : (Word16.word buffer2 * int * (Word16.word * Word16.word)) -> unit
    val get2i  : (Int32.int buffer2 * int) -> (Int32.int * Int32.int)
    val set2i  : (Int32.int buffer2 * int * (Int32.int * Int32.int)) -> unit
    val get2ui : (Word32.word buffer2 * int) -> (Word32.word * Word32.word)
    val set2ui : (Word32.word buffer2 * int * (Word32.word * Word32.word)) -> unit
    val get2f  : (Float.float buffer2 * int) -> (Float.float * Float.float)
    val set2f  : (Float.float buffer2 * int * (Float.float * Float.float)) -> unit
    val get2d  : (Double.double buffer2 * int) -> (Double.double * Double.double)
    val set2d  : (Double.double buffer2 * int * (Double.double * Double.double)) -> unit

    val get3b  : (Int8.int buffer3 * int) -> (Int8.int * Int8.int * Int8.int)
    val set3b  : (Int8.int buffer3 * int * (Int8.int * Int8.int * Int8.int)) -> unit
    val get3ub : (Word8.word buffer3 * int) -> (Word8.word * Word8.word * Word8.word)
    val set3ub : (Word8.word buffer3 * int * (Word8.word * Word8.word * Word8.word)) -> unit
    val get3s  : (Int16.int buffer3 * int) -> (Int16.int * Int16.int * Int16.int)
    val set3s  : (Int16.int buffer3 * int * (Int16.int * Int16.int * Int16.int)) -> unit
    val get3us : (Word16.word buffer3 * int) -> (Word16.word * Word16.word * Word16.word)
    val set3us : (Word16.word buffer3 * int * (Word16.word * Word16.word * Word16.word)) -> unit
    val get3i  : (Int32.int buffer3 * int) -> (Int32.int * Int32.int * Int32.int)
    val set3i  : (Int32.int buffer3 * int * (Int32.int * Int32.int * Int32.int)) -> unit
    val get3ui : (Word32.word buffer3 * int) -> (Word32.word * Word32.word * Word32.word)
    val set3ui : (Word32.word buffer3 * int * (Word32.word * Word32.word * Word32.word)) -> unit
    val get3f  : (Float.float buffer3 * int) -> (Float.float * Float.float * Float.float)
    val set3f  : (Float.float buffer3 * int * (Float.float * Float.float * Float.float)) -> unit
    val get3d  : (Double.double buffer3 * int) -> (Double.double * Double.double * Double.double)
    val set3d  : (Double.double buffer3 * int * (Double.double * Double.double * Double.double)) -> unit

    val get4b  : (Int8.int buffer4 * int) -> (Int8.int * Int8.int * Int8.int * Int8.int)
    val set4b  : (Int8.int buffer4 * int * (Int8.int * Int8.int * Int8.int * Int8.int)) -> unit
    val get4ub : (Word8.word buffer4 * int) -> (Word8.word * Word8.word * Word8.word * Word8.word)
    val set4ub : (Word8.word buffer4 * int * (Word8.word * Word8.word * Word8.word * Word8.word)) -> unit
    val get4s  : (Int16.int buffer4 * int) -> (Int16.int * Int16.int * Int16.int * Int16.int)
    val set4s  : (Int16.int buffer4 * int * (Int16.int * Int16.int * Int16.int * Int16.int)) -> unit
    val get4us : (Word16.word buffer4 * int) -> (Word16.word * Word16.word * Word16.word * Word16.word)
    val set4us : (Word16.word buffer4 * int * (Word16.word * Word16.word * Word16.word * Word16.word)) -> unit
    val get4i  : (Int32.int buffer4 * int) -> (Int32.int * Int32.int * Int32.int * Int32.int)
    val set4i  : (Int32.int buffer4 * int * (Int32.int * Int32.int * Int32.int * Int32.int)) -> unit
    val get4ui : (Word32.word buffer4 * int) -> (Word32.word * Word32.word * Word32.word * Word32.word)
    val set4ui : (Word32.word buffer4 * int * (Word32.word * Word32.word * Word32.word * Word32.word)) -> unit
    val get4f  : (Float.float buffer4 * int) -> (Float.float * Float.float * Float.float * Float.float)
    val set4f  : (Float.float buffer4 * int * (Float.float * Float.float * Float.float * Float.float)) -> unit
    val get4d  : (Double.double buffer4 * int) -> (Double.double * Double.double * Double.double * Double.double)
    val set4d  : (Double.double buffer4 * int * (Double.double * Double.double * Double.double * Double.double)) -> unit

  (* polymorphic operations on buffers *)
    val get : 'a buffer * int -> 'a
    val set : 'a buffer * int * 'a -> unit
    val update : 'a buffer * int * ('a -> 'a) -> unit
    val app : ('a -> unit) -> 'a buffer -> unit
    val appi : (int * 'a -> unit) -> 'a buffer -> unit
    val modify : ('a -> 'a) -> 'a buffer -> unit
    val modifyi : (int * 'a -> 'a) -> 'a buffer -> unit
    val tabulate : ('a buffer * (int -> 'a)) -> unit

  (* moving data in and out of SML *)
    val mapToVector : 'a buffer * ('a -> 'b) -> 'b vector
    val mapToArray : 'a buffer * ('a -> 'b) -> 'b array

  (* support for passing buffers to C code.  Note that it is the responsibility of client code to
   * make sure that data that is visibile to C is also retained by the SML heap.
   *)
    val withPtr : ('a buffer * ({data : MLton.Pointer.t, szb :  C_Size.word, elemSzb : C_Size.word} -> unit)) -> unit
    val touch : 'a buffer -> unit

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0