[m-rev.] for review: minor changes for valuetype foreign_types

Tyson Dowd trd at cs.mu.OZ.AU
Tue Jan 22 14:19:35 AEDT 2002


On 21-Jan-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 20-Jan-2002, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > A few minor fixes promped by petdr's addition of support for value types
> > for foreign_type.
> ...
> > doc/reference_manual.texi:
> > 	Improve the documentation wording for pragma foreign_type, and
> > 	remove the XXX saying that we should accept value types, because
> > 	we now accept value types.
> 
> It's not right to remove that XXX, since you've only fixed part of the
> problem -- after petdr's change, user-defined value types are supported,
> but builtin value types such as `int32' still aren't.

They are.

:- pragma foreign_type(il, int32, "valuetype [mscorlib]System.Int32").

> The documentation should explain this,
> and there should still an XXX comment.

They documentation is correct, I guess we could make it clearer that you
should use the value type name for the builtin types.


===================================================================


Estimated hours taken: 0.5
Branches: main

Some changes prompted by fjh's review of the fixes I made to petdr's
change to make valuetypes work in pragma foreign_type for IL.

compiler/ilasm.m:
	Improve the documentation of name_to_simple type.

doc/reference_manual.texi:
	Document how to access builtin types like int32 using foreign_type 
	valuetype syntax.


Index: compiler/ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.30
diff -u -r1.30 ilasm.m
--- compiler/ilasm.m	21 Jan 2002 04:39:17 -0000	1.30
+++ compiler/ilasm.m	22 Jan 2002 02:22:50 -0000
@@ -749,9 +749,10 @@
 
 name_to_simple_type(Name, Type) :-
 		% Parition II section 'Built-in Types' (7.2 in Beta2) states
-		% that all builtin types *must* be rereferenced by their
-		% special encoding.  See Parition I 'Built-In Types' 
-		% (8.2.2 in Beta2) for the list of all builtin types.
+		% that all builtin types *must* be referenced by their
+		% special encoding in signatures. 
+		% See Parition I 'Built-In Types' % (8.2.2 in Beta2) for the
+		% list of all builtin types.
 	Name = structured_name(AssemblyName, QualifiedName, _),
 	AssemblyName = assembly("mscorlib"),
 	QualifiedName = ["System", TypeName],
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.237
diff -u -r1.237 reference_manual.texi
--- doc/reference_manual.texi	21 Jan 2002 04:39:23 -0000	1.237
+++ doc/reference_manual.texi	22 Jan 2002 02:29:01 -0000
@@ -5472,17 +5472,25 @@
 Note that extra whitespace is not handled --- there should only be a single
 space between the class keyword and the assembly specifier.
 @c XXX we should handle whitespace better
+Value types which have a special name (such as @samp{int32}) can be
+named using their valuetype syntax, they will be marshalled using their
+special name (as is required by section 7.2 of Partition II of the ECMA
+CLI documentation).
 
 For example:
 
 @example
 :- type xmldoc.
 :- pragma foreign_type(il, xmldoc, "class [System.Xml]System.Xml.XmlDocument").
+:- type int32.
+:- pragma foreign_type(il, int32, "valuetype [mscorlib]System.Int32").
 @end example
 
 ensures that on the .NET CLR backend the Mercury type @samp{xmldoc} is
 marshalled by the backend as @samp{System.Xml.XmlDocument} from assembly
- at samp{System.Xml}.
+ at samp{System.Xml}, and that the Mercury type @samp{int32} will be
+marshalled by the backend as @samp{int32}.
+
 The following example shows how one can use the marshalled data from C#. 
 
 @example


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list