[m-rev.] diff: test odd-sized foreign types

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Oct 30 14:30:12 AEDT 2002


Estimated hours taken: 0.5

tests/valid/Mmakefile:
tests/valid/big_foreign_type.m:
	Add a new test case to test foreign types whose size is different
	than "MR_Word".

Workspace: /home/ceres/fjh/mercury
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.116
diff -u -d -r1.116 Mmakefile
--- tests/valid/Mmakefile	29 Oct 2002 07:01:10 -0000	1.116
+++ tests/valid/Mmakefile	30 Oct 2002 03:17:44 -0000
@@ -74,6 +74,7 @@
 	explicit_quant \
 	fail_ite \
 	followcode_det_problem \
+	big_foreign_type \
 	foreign_underscore_var \
 	func_int_bug_main \
 	func_default_modes \
Index: tests/valid/big_foreign_type.m
===================================================================
RCS file: tests/valid/big_foreign_type.m
diff -N tests/valid/big_foreign_type.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/big_foreign_type.m	30 Oct 2002 03:26:57 -0000
@@ -0,0 +1,53 @@
+% Test the use of foreign types,
+% e.g. those that don't fit exactly into a single word.
+
+:- module big_foreign_type.
+:- interface.
+
+:- type foo.
+:- pragma foreign_type(c, foo, "struct Foo").
+:- type foo2.
+:- pragma foreign_type(c, foo2, "char").
+:- type foo3.
+:- pragma foreign_type(c, foo3, "double").
+:- type foo4.
+:- pragma foreign_type(c, foo4, "enum e").
+
+:- func bar(foo) = foo.
+:- func bar2(foo2) = foo2.
+:- func bar3(foo3) = foo3.
+:- func bar4(foo4) = foo4.
+
+:- func baz(foo) = foo.
+:- func baz2(foo2) = foo2.
+:- func baz3(foo3) = foo3.
+:- func baz4(foo4) = foo4.
+
+:- implementation.
+
+:- pragma c_header_code("
+	struct Foo {
+		int x, y, z;
+	};
+
+	enum e { e0, e1, e2, e42 = 42 };
+").
+
+:- pragma foreign_proc(c, bar(X::in) = (Y::out),
+	[will_not_call_mercury, promise_pure], "Y = X;").
+:- pragma foreign_proc(c, bar2(X::in) = (Y::out),
+	[will_not_call_mercury, promise_pure], "Y = X;").
+:- pragma foreign_proc(c, bar3(X::in) = (Y::out),
+	[will_not_call_mercury, promise_pure], "Y = 2.0 * X;").
+:- pragma foreign_proc(c, bar4(X::in) = (Y::out),
+	[will_not_call_mercury, promise_pure], "Y = X;").
+
+baz(X) = X.
+baz2(X) = X.
+baz3(X) = X.
+baz4(X) = X.
+
+:- pragma export(baz(in) = out, "baz").
+:- pragma export(baz2(in) = out, "baz2").
+:- pragma export(baz3(in) = out, "baz3").
+:- pragma export(baz4(in) = out, "baz4").

-- 
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