Author: martin
Date: 2005-04-18 00:49:13 -0400 (Mon, 18 Apr 2005)
New Revision: 43184

Modified:
   trunk/mcs/gmcs/
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/attribute.cs
Log:
**** Merged r41898 from MCS ****



Property changes on: trunk/mcs/gmcs
___________________________________________________________________
Name: gmcs
   + Latest GMCS merging status:
- merged everything until r39544 (on January 26th).
- r37007 will never be merged; it's a mcs-only change.


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-04-18 04:41:13 UTC (rev 43183)
+++ trunk/mcs/gmcs/ChangeLog    2005-04-18 04:49:13 UTC (rev 43184)
@@ -1,3 +1,8 @@
+2005-03-16  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * attribute.cs: Encode ThrowOnUnmappableChar and BestFitMapping
+       attributes.
+
 2005-03-16  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Remove TypeManager.LookupType and TypeManager.LookupTypeDirect.

Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-04-18 04:41:13 UTC (rev 43183)
+++ trunk/mcs/gmcs/attribute.cs 2005-04-18 04:49:13 UTC (rev 43184)
@@ -1083,17 +1083,24 @@
                        CharSet charset = CharSet.Ansi;
                        bool preserve_sig = true;
                        string entry_point = name;
+                       bool best_fit_mapping = false;
+                       bool throw_on_unmappable = false;
 
+                       bool best_fit_mapping_set = false;
+                       bool throw_on_unmappable_set = false;
+
+                       MethodInfo set_best_fit = null;
+                       MethodInfo set_throw_on = null;
+
                        if (field_info_arr != null) {
                                int char_set_extra = 0;
 
                                for (int i = 0; i < field_info_arr.Length; i++) 
{
                                        switch (field_info_arr [i].Name) {
                                                case "BestFitMapping":
-                                                       Report.Error (-1, 
Location,
-                                                                     "There is 
no way to set the ThrowOnUnmappableChar " +
-                                                                     "property 
with Reflection");
-                                                       return null;
+                                                       best_fit_mapping = 
(bool) field_values_arr [i];
+                                                       best_fit_mapping_set = 
true;
+                                                       break;
                                                case "CallingConvention":
                                                        cc = 
(CallingConvention) field_values_arr [i];
                                                        break;
@@ -1113,11 +1120,9 @@
                                                        char_set_extra |= 0x40;
                                                        break;
                                                case "ThrowOnUnmappableChar":
-                                                       Report.Error (-1, 
Location,
-                                                                     "There is 
no way to set the ThrowOnUnmappableChar " +
-                                                                     "property 
with Reflection");
-                                                       return null;
-                                                       
+                                                       throw_on_unmappable = 
(bool) field_values_arr [i];
+                                                       throw_on_unmappable_set 
= true;
+                                                       break;
                                                default: 
                                                        throw new 
InternalErrorException (field_info_arr [i].ToString ());
                                        }
@@ -1125,6 +1130,17 @@
                                charset |= (CharSet)char_set_extra;
                        }
 
+                       if (throw_on_unmappable_set || best_fit_mapping_set) {
+                               set_best_fit = typeof (MethodBuilder).GetMethod 
("set_BestFitMapping", BindingFlags.Instance | BindingFlags.Public | 
BindingFlags.NonPublic);
+                               set_throw_on = typeof (MethodBuilder).GetMethod 
("set_ThrowOnUnmappableChar", BindingFlags.Instance | BindingFlags.Public | 
BindingFlags.NonPublic);
+
+                               if ((set_best_fit == null) || (set_throw_on == 
null)) {
+                                       Report.Error (-1, Location,
+                                                                 "The 
ThrowOnUnmappableChar and BestFitMapping attributes can only be emitted when 
running on the mono runtime.");
+                                       return null;
+                               }
+                       }
+
                        try {
                                MethodBuilder mb = builder.DefinePInvokeMethod (
                                        name, dll_name, entry_point, flags | 
MethodAttributes.HideBySig | MethodAttributes.PinvokeImpl,
@@ -1132,6 +1148,11 @@
 
                                if (preserve_sig)
                                        mb.SetImplementationFlags 
(MethodImplAttributes.PreserveSig);
+
+                               if (throw_on_unmappable_set)
+                                       set_throw_on.Invoke (mb, 0, null, new 
object [] { throw_on_unmappable }, null);
+                               if (best_fit_mapping_set)
+                                       set_best_fit.Invoke (mb, 0, null, new 
object [] { best_fit_mapping }, null);
                        
                                return mb;
                        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to