[m-rev.] for review: implementation of char library for Java

James Goddard goddardjames at yahoo.com
Thu Dec 11 19:14:26 AEDT 2003


Estimated hours taken: 0.5
Branches: main

Implemented some library functions for the char library in java.

library/char.m:
	Implemented the following predicates in java:

		char__to_int/2
		char__max_char_value/1

Index: char.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/char.m,v
retrieving revision 1.44
diff -u -d -r1.44 char.m
--- char.m	7 Nov 2003 16:51:34 -0000	1.44
+++ char.m	11 Dec 2003 08:12:30 -0000
@@ -477,6 +477,28 @@
 	SUCCESS_INDICATOR = (Character == Int);
 ").
 
+:- pragma foreign_proc("Java",
+        char__to_int(Character::in, Int::out),
+	[will_not_call_mercury, promise_pure, thread_safe],
+"
+        Int = (int) Character;
+").
+
+:- pragma foreign_proc("Java",
+        char__to_int(Character::in, Int::in),
+        [will_not_call_mercury, promise_pure, thread_safe],
+"
+        succeeded = ((int) Character == Int);
+").
+
+:- pragma foreign_proc("Java",
+        char__to_int(Character::out, Int::in),
+        [will_not_call_mercury, promise_pure, thread_safe],
+"
+	Character = (char) Int;
+	succeeded = ((int) Character == Int);
+").
+
 % We used unsigned character codes, so the minimum character code
 % is always zero.
 
@@ -499,6 +521,12 @@
 	// i.e. only the Unicode characters that fit in 16 bits.
 	// For our purposes, it doesn't matter.
 	Max = 0xffff;
+").
+:- pragma foreign_proc("Java",
+	char__max_char_value(Max::out),
+	[will_not_call_mercury, promise_pure, thread_safe],
+"
+	Max = (int) java.lang.Character.MAX_VALUE;
 ").
 
 %-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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