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/c.sig
ViewVC logotype

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

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

revision 1151, Mon Mar 18 18:41:31 2002 UTC revision 1152, Tue Mar 19 21:36:30 2002 UTC
# Line 21  Line 21 
21       * type (sint, rw) ptr.       * type (sint, rw) ptr.
22       * However, in the case of the "light" version of this object (see below),       * However, in the case of the "light" version of this object (see below),
23       * the object type is ((sint, rw) ptr, ro) obj' while fetching       * the object type is ((sint, rw) ptr, ro) obj' while fetching
24       * from this object gives a value of type (sint, rw) ptr'.  n     * from this object gives a value of type (sint, rw) ptr'.
25       * (In other words, we use the "heavy" versions of value types as witness       * (In other words, we use the "heavy" versions of value types as witness
26       * types -- even in the "light" case.) *)       * types -- even in the "light" case.) *)
27      type ('t, 'c) obj      type ('t, 'c) obj
# Line 143  Line 143 
143      (* bitfields aren't "ordinary objects", so they have their own type *)      (* bitfields aren't "ordinary objects", so they have their own type *)
144      eqtype 'c sbf and 'c ubf      eqtype 'c sbf and 'c ubf
145    
146        structure W : sig
147            (* conversion "witness" values *)
148            type ('from, 'to) witness
149    
150            (* A small calculus for generating new witnesses.
151             * Since the only witness constructors that do anything real are
152             * rw and ro, all this calculus gives you is a way of changing
153             * "const" attributes at any level within a bigger type.
154             *
155             * (The calculus can express nonsensical witnesses -- which
156             * fortunately are harmless because they can't be applied to any
157             * values.) *)
158            val trivial : ('t, 't) witness
159    
160            val pointer : ('from, 'to) witness ->
161                          ('from ptr, 'to ptr) witness
162            val object  : ('st, 'tt) witness ->
163                          (('st, 'c) obj, ('tt, 'c) obj) witness
164            val arr     : ('st, 'tt) witness ->
165                          (('st, 'n) arr, ('tt, 'n) arr) witness
166    
167            val ro      : ('st, 'tt) witness ->
168                          (('st, 'c) obj, ('tt, ro) obj) witness
169            val rw      : ('st, 'tt) witness ->
170                          (('st, 'sc) obj, ('tt, 'tc) obj) witness
171        end
172    
173        (* Object conversions that rely on witnesses: *)
174        val convert : (('st, 'sc) obj, ('tt, 'tc) obj) W.witness ->
175                      ('st, 'sc) obj -> ('tt, 'tc) obj
176        val convert' : (('st, 'sc) obj, ('tt, 'tc) obj) W.witness ->
177                       ('st, 'sc) obj' -> ('tt, 'tc) obj'
178    
179      (*      (*
180       * A family of types and corresponding values representing natural numbers.       * A family of types and corresponding values representing natural numbers.
181       *   (An encoding in SML without using dependent types.)       *   (An encoding in SML without using dependent types.)
# Line 423  Line 456 
456       * Concretely, we make both operations polymorphic in the argument       * Concretely, we make both operations polymorphic in the argument
457       * constness.  Moreover, the second (unsafe) direction is also       * constness.  Moreover, the second (unsafe) direction is also
458       * polymorphic in the result.  This can be used to effectively       * polymorphic in the result.  This can be used to effectively
459       * implement a conversion to "whatever the context wants":       * implement a conversion to "whatever the context wants".
460         *
461         * Note: fun ro x = convert (W.ro W.trivial) x
462         *       etc.
463       *)       *)
464      val ro : ('t, 'c) obj  -> ('t, ro) obj      val ro : ('t, 'c) obj  -> ('t, ro) obj
465      val rw : ('t, 'sc) obj -> ('t, 'tc) obj      val rw : ('t, 'sc) obj -> ('t, 'tc) obj
# Line 508  Line 544 
544          (* alt; needs explicit size (for element) *)          (* alt; needs explicit size (for element) *)
545          val sub' : 't S.size -> ('t, 'c) obj ptr' * int -> ('t, 'c) obj'          val sub' : 't S.size -> ('t, 'c) obj ptr' * int -> ('t, 'c) obj'
546    
547          (* constness manipulation for pointers *)          (* conversions that rely on witnesses *)
548            val convert : (('st, 'sc) obj ptr, ('tt, 'tc) obj ptr) W.witness ->
549                          ('st, 'sc) obj ptr -> ('tt, 'tc) obj ptr
550            val convert' : (('st, 'sc) obj ptr, ('tt, 'tc) obj ptr) W.witness ->
551                           ('st, 'sc) obj ptr' -> ('tt, 'tc) obj ptr'
552    
553            (* constness manipulation for pointers
554             * Note: fun ro x = convert (W.pointer (W.ro W.trivial)) x
555             *       etc. *)
556          val ro : ('t, 'c) obj ptr    -> ('t, ro) obj ptr          val ro : ('t, 'c) obj ptr    -> ('t, ro) obj ptr
557          val rw : ('t, 'sc) obj ptr   -> ('t, 'tc) obj ptr          val rw : ('t, 'sc) obj ptr   -> ('t, 'tc) obj ptr
558          val ro' : ('t, 'c) obj ptr'  -> ('t, ro) obj ptr'          val ro' : ('t, 'c) obj ptr'  -> ('t, ro) obj ptr'

Legend:
Removed from v.1151  
changed lines
  Added in v.1152

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