[m-rev.] diff: java foreign_type decls

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 28 00:26:44 AEDT 2003


Estimated hours taken: 0.5
Branches: main

library/array.m:
library/io.m:
	Provide Java `pragma foreign_type' declarations for the types
	array.array(T) and io.system_error.  This is needed to avoid
	compilation errors when building in grade `java'.

Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.127
diff -u -d -r1.127 array.m
--- library/array.m	7 Nov 2003 16:51:34 -0000	1.127
+++ library/array.m	27 Nov 2003 10:58:53 -0000
@@ -368,11 +368,27 @@
 
 :- import_module exception, int, require, string.
 
+%
+% Define the array type appropriately for the different targets.
+% Note that the definitions here should match what is output by
+% mlds_to_c.m, mlds_to_il.m, or mlds_to_java.m for mlds__mercury_array_type.
+%
+
 	% MR_ArrayPtr is defined in runtime/mercury_library_types.h.
 :- pragma foreign_type("C", array(T), "MR_ArrayPtr")
 	where equality is array__array_equal,
 	comparison is array__array_compare.
+
 :- pragma foreign_type(il,  array(T), "class [mscorlib]System.Array")
+	where equality is array__array_equal,
+	comparison is array__array_compare.
+
+	% We can't use `java.lang.Object []', since we want
+	% a generic type that is capable of holding any kind
+	% of array, including e.g. `int []'.
+	% Java doesn't have any equivalent of .NET's System.Array
+	% class, so we just use the universal base `java.lang.Object'.
+:- pragma foreign_type(java,  array(T), "/* Array */ java.lang.Object")
 	where equality is array__array_equal,
 	comparison is array__array_compare.
 
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.312
diff -u -d -r1.312 io.m
--- library/io.m	16 Nov 2003 16:48:20 -0000	1.312
+++ library/io.m	27 Nov 2003 02:57:53 -0000
@@ -1422,6 +1422,7 @@
 :- pragma foreign_type(c, io__system_error, "MR_Integer").
 :- pragma foreign_type(il, io__system_error,
 		"class [mscorlib]System.Exception").
+:- pragma foreign_type(java, io__system_error, "java.lang.Exception").
 
 % io__make_err_msg(Error, MessagePrefix, Message):
 %	`Message' is an error message obtained by looking up the

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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