Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/ml-nlffi-lib/iptr.sig
ViewVC logotype

Diff of /sml/trunk/src/ml-nlffi-lib/iptr.sig

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

revision 1077, Tue Feb 19 15:48:50 2002 UTC revision 1078, Tue Feb 19 21:26:48 2002 UTC
# Line 1  Line 1 
1  (*  (*
2   * iptr.sig   Interface to an "incomplete" C pointer type.   * iptr.sig   Interface to an "incomplete" C pointer type.
3   *   *
4   *   The code generated from a C interface (call it <A>) containing an   *     The idea is that 'c iobj stands for some (T su, 'c) obj.
5   *   "incomplete" type (i.e., a pointer to a named but otherwise undefined   *     However, since the struct/union in question has not yet been
6   *   struct or union, call it <foo>) will be a functor that takes a structure   *     declared, T is not yet known.  C does let you have pointers
7   *   argument representing this incomplete (pointer-)type.  The signature   *     to such "incomplete" types, and so do we:  It is ok to form
8   *   for this argument structure is POINTER_TO_INCOMPLETE_TYPE.   *     a 'c iobj ptr.  Many of the usual pointer operations are
9   *   *     possible, but there are some (subscript, pointer
10   *   Therefore, for each incomplete struct <foo> there will be a functor   *     arithmetic, dereferencing) that are not.
11   *   argument   *     The C signature (in c.sig) expresses this by explicitly
12   *        structure I_S_<foo> : POINTER_TO_INCOMPLETE_TYPE   *     contraining, e.g., the dereference operator |*| to an argument
13   *   and for each incomplete union <bar> there will be a functor argument   *     of type ('t, 'c) obj ptr instead of the more general 'o ptr.
  *        structure I_U_<bar> : POINTER_TO_INCOMPLETE_TYPE  
  *   in the definition of functor <A>.<A>Fn.  
  *  
  * Actual structures matching POINTER_TO_INCOMPLETE_TYPE can be generated  
  * using the functors PointerToCompleteType (see c-iptr-fn.sml) and  
  * PointerToIncompleteType (see i-iptr-fn.sml).  
14   *   *
15   *   (C) 2001, Lucent Technologies, Bell Labs   *   For each incomplete struct (union) <foo>, the ml-nlffigen tool will
16     *   generate code that refers to the ML type 'c IS_<foo>.iobj
17     *   ('c IU_<foo>iobj) where structure IS_<foo> (IU_<foo>) matches
18     *   signature POINTER_TO_INCOMPLETE_TYPE.
19     *
20     *   By default, the same tool will also generate definitions for these
21     *   ML structures, making each of the iobj types abstract (by invoking
22     *   functor PointerToIncompleteType from internals/i-iptr-fn.sml).
23     *
24     *   If the complete definition of the corresponding S_<foo> (U_<foo>) is
25     *   available, one can alternatively define IS_<foo> (IU_<foo>) by invoking
26     *   functor PointerToCompleteType (internals/c-iptr-fn.sml).  This
27     *   functor reveals (and makes concrete) the conceptual type identity of
28     *
29     *      (S_<foo>.tag su, 'c) obj == 'c IS_<foo>.iobj
30     *   or
31     *      (U_<foo>.tag su, 'c) obj == 'c IU_<foo>.iobj
32     *
33     *   Use the "-incomplete" command line option of ml-nlffigen to suppress
34     *   automatic generation of definitions for abstract I{S|U}_<foo>.iobj types.
35     *
36     *   If you do want to utilize automatic generation of such types but
37     *   want to share them across outputs of multiple invocations of
38     *   ml-nlffigen, use the "-iptr" command line option of ml-nlffigen.
39     *   (If you do not share these definitions in ML, fresh types well
40     *   up being generated for every C interface -- potentially rendering
41     *   the results incompatible with each other.)
42     *
43     *   (C) 2002, Lucent Technologies, Bell Labs
44   *   *
45   * author: Matthias Blume (blume@research.bell-labs.com)   * author: Matthias Blume (blume@research.bell-labs.com)
46   *)   *)
47  signature POINTER_TO_INCOMPLETE_TYPE = sig  signature POINTER_TO_INCOMPLETE_TYPE = sig
48      type 'c iptr                        (* = (? su, unit, 'c) ptr  *)      type 'c iobj
     type 'c iptr'                       (* = (? su, unit, 'c) ptr' *)  
   
     val typ'rw : C.rw iptr C.T.typ  
     val typ'ro : C.ro iptr C.T.typ  
   
     val light : 'c iptr -> 'c iptr'  
     val heavy : 'c iptr' -> 'c iptr  
   
     val get : ('pc iptr, 'c) C.obj -> 'pc iptr  
     val get' : ('pc iptr, 'c) C.obj' -> 'pc iptr'  
   
     val set : ('pc iptr, C.rw) C.obj * 'pc iptr -> unit  
     val set' : ('pc iptr, C.rw) C.obj' * 'pc iptr' -> unit  
   
     val set_voidptr : ('pc iptr, C.rw) C.obj * C.voidptr -> unit  
     val set_voidptr' : ('pc iptr, C.rw) C.obj' * C.voidptr -> unit  
   
     val compare : 'c iptr * 'c iptr -> order  
     val compare' : 'c iptr' * 'c iptr' -> order  
   
     val inject : 'c iptr -> C.voidptr  
     val inject' : 'c iptr' -> C.voidptr  
   
     val cast : 'c iptr C.T.typ -> C.voidptr -> 'c iptr  
     val cast' : 'c iptr C.T.typ -> C.voidptr -> 'c iptr'  
49    
50      val null : 'c iptr C.T.typ -> 'c iptr      (* RTTI for the _pointer_ types: *)
51      val null' : 'c iptr'      val typ'rw : C.rw iobj C.ptr C.T.typ
52        val typ'ro : C.ro iobj C.ptr C.T.typ
53  end  end

Legend:
Removed from v.1077  
changed lines
  Added in v.1078

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