[m-rev.] diff: C# serializable

Peter Wang novalazy at gmail.com
Wed Nov 3 16:56:39 AEDT 2010


Branches: main

Add serialization of Mercury terms in C# grades.

compiler/mlds_to_cs.m:
        Output [Serializable] attribute on generated classes and enums.

library/bitmap.m:
library/builtin.m:
library/version_array.m:
        Add [Serializable] attribute to hand-written classes.

diff --git a/compiler/mlds_to_cs.m b/compiler/mlds_to_cs.m
index 9433a6a..ab3d60a 100644
--- a/compiler/mlds_to_cs.m
+++ b/compiler/mlds_to_cs.m
@@ -928,7 +928,9 @@ output_defn(Info, Indent, OutputAux, Defn, !IO) :-
                 Kind = mlds_class
             )
         ->
-            OverrideFlags = set_per_instance(Flags, per_instance)
+            OverrideFlags = set_per_instance(Flags, per_instance),
+            io.write_string("[System.Serializable]\n", !IO),
+            indent_line(Indent, !IO)
         ;
             % `static' and `sealed' not wanted or allowed on structs.
             DefnBody = mlds_class(ClassDefn),
diff --git a/library/bitmap.m b/library/bitmap.m
index ed321b2..efbd0cd 100644
--- a/library/bitmap.m
+++ b/library/bitmap.m
@@ -1563,6 +1563,7 @@ public static class MercuryBitmap implements java.io.Serializable {
 ").
 
 :- pragma foreign_code("C#", "
+[System.Serializable]
 public class MercuryBitmap {
     public int num_bits;
     public byte[] elements;
diff --git a/library/builtin.m b/library/builtin.m
index 05a3c15..2649e17 100644
--- a/library/builtin.m
+++ b/library/builtin.m
@@ -1032,6 +1032,7 @@ __Compare____tuple_0_0(object x, object y)
 % example of code which does.
 %
 :- pragma foreign_code("C#", "
+    [System.Serializable]
     public class Void_0
     {
         // Make the constructor private to ensure that we can
diff --git a/library/version_array.m b/library/version_array.m
index 894c1b3..9368ec1 100644
--- a/library/version_array.m
+++ b/library/version_array.m
@@ -1042,6 +1042,7 @@ public interface ML_va {
 //
 // It just wraps the unsafe version is some synchronization logic so
 // that only one thread can be accessing the array at one instant.
+[System.Serializable]
 public class ML_sva : ML_va {
     private ML_uva version_array;
     private object va_lock;
@@ -1105,6 +1106,7 @@ public class ML_sva : ML_va {
 
 // An implementation of version arrays that is only safe when used from
 // a single thread, but *much* faster than the synchronized version.
+[System.Serializable]
 public class ML_uva : ML_va {
     private int                 index;  /* -1 for latest, >= 0 for older */
     private object              value;  /* Valid if index >= 0           */

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list