You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@@ -20,5 +20,13 @@ namespace System {
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static void CheckReflectionOnlyLoadSupported()
|
||||
{
|
||||
}
|
||||
|
||||
internal static void CheckLoadFromSupported()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,5 +41,15 @@ namespace System
|
||||
internal static void Perf (bool expr, string msg)
|
||||
{
|
||||
}
|
||||
|
||||
[Conditional("_LOGGING")]
|
||||
public static void Trace (string switchName, params object[]messages)
|
||||
{
|
||||
}
|
||||
|
||||
internal static bool CheckEnabled (string switchName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
176
mcs/class/corlib/ReferenceSources/Buffer.cs
Normal file
176
mcs/class/corlib/ReferenceSources/Buffer.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
namespace System
|
||||
{
|
||||
partial class Buffer
|
||||
{
|
||||
public static int ByteLength (Array array)
|
||||
{
|
||||
// note: the other methods in this class also use ByteLength to test for
|
||||
// null and non-primitive arguments as a side-effect.
|
||||
|
||||
if (array == null)
|
||||
throw new ArgumentNullException ("array");
|
||||
|
||||
int length = _ByteLength (array);
|
||||
if (length < 0)
|
||||
throw new ArgumentException (Locale.GetText ("Object must be an array of primitives."));
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
public static byte GetByte (Array array, int index)
|
||||
{
|
||||
if (index < 0 || index >= ByteLength (array))
|
||||
throw new ArgumentOutOfRangeException ("index");
|
||||
|
||||
return _GetByte (array, index);
|
||||
}
|
||||
|
||||
public static void SetByte (Array array, int index, byte value)
|
||||
{
|
||||
if (index < 0 || index >= ByteLength (array))
|
||||
throw new ArgumentOutOfRangeException ("index");
|
||||
|
||||
_SetByte (array, index, value);
|
||||
}
|
||||
|
||||
public static void BlockCopy (Array src, int srcOffset, Array dst, int dstOffset, int count)
|
||||
{
|
||||
if (src == null)
|
||||
throw new ArgumentNullException ("src");
|
||||
|
||||
if (dst == null)
|
||||
throw new ArgumentNullException ("dst");
|
||||
|
||||
if (srcOffset < 0)
|
||||
throw new ArgumentOutOfRangeException ("srcOffset", Locale.GetText(
|
||||
"Non-negative number required."));
|
||||
|
||||
if (dstOffset < 0)
|
||||
throw new ArgumentOutOfRangeException ("dstOffset", Locale.GetText (
|
||||
"Non-negative number required."));
|
||||
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException ("count", Locale.GetText (
|
||||
"Non-negative number required."));
|
||||
|
||||
// We do the checks in unmanaged code for performance reasons
|
||||
bool res = InternalBlockCopy (src, srcOffset, dst, dstOffset, count);
|
||||
if (!res) {
|
||||
// watch for integer overflow
|
||||
if ((srcOffset > ByteLength (src) - count) || (dstOffset > ByteLength (dst) - count))
|
||||
throw new ArgumentException (Locale.GetText (
|
||||
"Offset and length were out of bounds for the array or count is greater than " +
|
||||
"the number of elements from index to the end of the source collection."));
|
||||
}
|
||||
}
|
||||
|
||||
internal static unsafe void memcpy4 (byte *dest, byte *src, int size) {
|
||||
/*while (size >= 32) {
|
||||
// using long is better than int and slower than double
|
||||
// FIXME: enable this only on correct alignment or on platforms
|
||||
// that can tolerate unaligned reads/writes of doubles
|
||||
((double*)dest) [0] = ((double*)src) [0];
|
||||
((double*)dest) [1] = ((double*)src) [1];
|
||||
((double*)dest) [2] = ((double*)src) [2];
|
||||
((double*)dest) [3] = ((double*)src) [3];
|
||||
dest += 32;
|
||||
src += 32;
|
||||
size -= 32;
|
||||
}*/
|
||||
while (size >= 16) {
|
||||
((int*)dest) [0] = ((int*)src) [0];
|
||||
((int*)dest) [1] = ((int*)src) [1];
|
||||
((int*)dest) [2] = ((int*)src) [2];
|
||||
((int*)dest) [3] = ((int*)src) [3];
|
||||
dest += 16;
|
||||
src += 16;
|
||||
size -= 16;
|
||||
}
|
||||
while (size >= 4) {
|
||||
((int*)dest) [0] = ((int*)src) [0];
|
||||
dest += 4;
|
||||
src += 4;
|
||||
size -= 4;
|
||||
}
|
||||
while (size > 0) {
|
||||
((byte*)dest) [0] = ((byte*)src) [0];
|
||||
dest += 1;
|
||||
src += 1;
|
||||
--size;
|
||||
}
|
||||
}
|
||||
internal static unsafe void memcpy2 (byte *dest, byte *src, int size) {
|
||||
while (size >= 8) {
|
||||
((short*)dest) [0] = ((short*)src) [0];
|
||||
((short*)dest) [1] = ((short*)src) [1];
|
||||
((short*)dest) [2] = ((short*)src) [2];
|
||||
((short*)dest) [3] = ((short*)src) [3];
|
||||
dest += 8;
|
||||
src += 8;
|
||||
size -= 8;
|
||||
}
|
||||
while (size >= 2) {
|
||||
((short*)dest) [0] = ((short*)src) [0];
|
||||
dest += 2;
|
||||
src += 2;
|
||||
size -= 2;
|
||||
}
|
||||
if (size > 0)
|
||||
((byte*)dest) [0] = ((byte*)src) [0];
|
||||
}
|
||||
static unsafe void memcpy1 (byte *dest, byte *src, int size) {
|
||||
while (size >= 8) {
|
||||
((byte*)dest) [0] = ((byte*)src) [0];
|
||||
((byte*)dest) [1] = ((byte*)src) [1];
|
||||
((byte*)dest) [2] = ((byte*)src) [2];
|
||||
((byte*)dest) [3] = ((byte*)src) [3];
|
||||
((byte*)dest) [4] = ((byte*)src) [4];
|
||||
((byte*)dest) [5] = ((byte*)src) [5];
|
||||
((byte*)dest) [6] = ((byte*)src) [6];
|
||||
((byte*)dest) [7] = ((byte*)src) [7];
|
||||
dest += 8;
|
||||
src += 8;
|
||||
size -= 8;
|
||||
}
|
||||
while (size >= 2) {
|
||||
((byte*)dest) [0] = ((byte*)src) [0];
|
||||
((byte*)dest) [1] = ((byte*)src) [1];
|
||||
dest += 2;
|
||||
src += 2;
|
||||
size -= 2;
|
||||
}
|
||||
if (size > 0)
|
||||
((byte*)dest) [0] = ((byte*)src) [0];
|
||||
}
|
||||
|
||||
internal static unsafe void Memcpy (byte *dest, byte *src, int size) {
|
||||
// FIXME: if pointers are not aligned, try to align them
|
||||
// so a faster routine can be used. Handle the case where
|
||||
// the pointers can't be reduced to have the same alignment
|
||||
// (just ignore the issue on x86?)
|
||||
if ((((int)dest | (int)src) & 3) != 0) {
|
||||
if (((int)dest & 1) != 0 && ((int)src & 1) != 0 && size >= 1) {
|
||||
dest [0] = src [0];
|
||||
++dest;
|
||||
++src;
|
||||
--size;
|
||||
}
|
||||
if (((int)dest & 2) != 0 && ((int)src & 2) != 0 && size >= 2) {
|
||||
((short*)dest) [0] = ((short*)src) [0];
|
||||
dest += 2;
|
||||
src += 2;
|
||||
size -= 2;
|
||||
}
|
||||
if ((((int)dest | (int)src) & 1) != 0) {
|
||||
memcpy1 (dest, src, size);
|
||||
return;
|
||||
}
|
||||
if ((((int)dest | (int)src) & 2) != 0) {
|
||||
memcpy2 (dest, src, size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
memcpy4 (dest, src, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
162
mcs/class/corlib/ReferenceSources/CompareInfo.cs
Normal file
162
mcs/class/corlib/ReferenceSources/CompareInfo.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// CompareInfo.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Mono.Globalization.Unicode;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Globalization
|
||||
{
|
||||
partial class CompareInfo
|
||||
{
|
||||
[NonSerialized]
|
||||
SimpleCollator collator;
|
||||
|
||||
// Maps culture IDs to SimpleCollator objects
|
||||
static Dictionary<string, SimpleCollator> collators;
|
||||
static bool managedCollation;
|
||||
static bool managedCollationChecked;
|
||||
|
||||
static bool UseManagedCollation {
|
||||
get {
|
||||
if (!managedCollationChecked) {
|
||||
managedCollation = Environment.internalGetEnvironmentVariable ("MONO_DISABLE_MANAGED_COLLATION") != "yes" && MSCompatUnicodeTable.IsReady;
|
||||
managedCollationChecked = true;
|
||||
}
|
||||
|
||||
return managedCollation;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleCollator GetCollator ()
|
||||
{
|
||||
if (collator != null)
|
||||
return collator;
|
||||
|
||||
if (collators == null) {
|
||||
Interlocked.CompareExchange (ref collators, new Dictionary<string, SimpleCollator> (StringComparer.Ordinal), null);
|
||||
}
|
||||
|
||||
lock (collators) {
|
||||
if (!collators.TryGetValue (m_sortName, out collator)) {
|
||||
collator = new SimpleCollator (CultureInfo.GetCultureInfo (m_name));
|
||||
collators [m_sortName] = collator;
|
||||
}
|
||||
}
|
||||
|
||||
return collator;
|
||||
}
|
||||
|
||||
SortKey CreateSortKeyCore (string source, CompareOptions options)
|
||||
{
|
||||
if (UseManagedCollation)
|
||||
return GetCollator ().GetSortKey (source, options);
|
||||
SortKey key=new SortKey (culture, source, options);
|
||||
|
||||
/* Need to do the icall here instead of in the
|
||||
* SortKey constructor, as we need access to
|
||||
* this instance's collator.
|
||||
*/
|
||||
assign_sortkey (key, source, options);
|
||||
|
||||
return(key);
|
||||
}
|
||||
|
||||
int internal_index_switch (string s, int sindex, int count, char c, CompareOptions opt, bool first)
|
||||
{
|
||||
if (opt == CompareOptions.Ordinal && first)
|
||||
return s.IndexOfUnchecked (c, sindex, count);
|
||||
|
||||
return UseManagedCollation ?
|
||||
internal_index_managed (s, sindex, count, c, opt, first) :
|
||||
internal_index (s, sindex, count, c, opt, first);
|
||||
}
|
||||
|
||||
int internal_index_switch (string s1, int sindex, int count, string s2, CompareOptions opt, bool first)
|
||||
{
|
||||
if (opt == CompareOptions.Ordinal && first)
|
||||
return s1.IndexOfUnchecked (s2, sindex, count);
|
||||
|
||||
return UseManagedCollation ?
|
||||
internal_index_managed (s1, sindex, count, s2, opt, first) :
|
||||
internal_index (s1, sindex, count, s2, opt, first);
|
||||
}
|
||||
|
||||
int internal_compare_switch (string str1, int offset1, int length1, string str2, int offset2, int length2, CompareOptions options)
|
||||
{
|
||||
return UseManagedCollation ?
|
||||
internal_compare_managed (str1, offset1, length1,
|
||||
str2, offset2, length2, options) :
|
||||
internal_compare (str1, offset1, length1,
|
||||
str2, offset2, length2, options);
|
||||
}
|
||||
|
||||
int internal_compare_managed (string str1, int offset1, int length1, string str2, int offset2, int length2, CompareOptions options)
|
||||
{
|
||||
return GetCollator ().Compare (str1, offset1, length1,
|
||||
str2, offset2, length2, options);
|
||||
}
|
||||
|
||||
int internal_index_managed (string s, int sindex, int count, char c, CompareOptions opt, bool first)
|
||||
{
|
||||
return first ?
|
||||
GetCollator ().IndexOf (s, c, sindex, count, opt) :
|
||||
GetCollator ().LastIndexOf (s, c, sindex, count, opt);
|
||||
}
|
||||
|
||||
int internal_index_managed (string s1, int sindex, int count, string s2, CompareOptions opt, bool first)
|
||||
{
|
||||
return first ?
|
||||
GetCollator ().IndexOf (s1, s2, sindex, count, opt) :
|
||||
GetCollator ().LastIndexOf (s1, s2, sindex, count, opt);
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern void assign_sortkey (object key, string source,
|
||||
CompareOptions options);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern int internal_compare (string str1, int offset1,
|
||||
int length1, string str2,
|
||||
int offset2, int length2,
|
||||
CompareOptions options);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern int internal_index (string source, int sindex,
|
||||
int count, char value,
|
||||
CompareOptions options,
|
||||
bool first);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern int internal_index (string source, int sindex,
|
||||
int count, string value,
|
||||
CompareOptions options,
|
||||
bool first);
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,15 @@ namespace System.Globalization
|
||||
// TODO: should query runtime with culture name for a list of culture's calendars
|
||||
int calendarId;
|
||||
|
||||
int numberIndex;
|
||||
|
||||
int iDefaultAnsiCodePage;
|
||||
int iDefaultOemCodePage;
|
||||
int iDefaultMacCodePage;
|
||||
int iDefaultEbcdicCodePage;
|
||||
bool isRightToLeft;
|
||||
string sListSeparator;
|
||||
|
||||
private CultureData (string name)
|
||||
{
|
||||
this.sRealName = name;
|
||||
@@ -95,6 +104,13 @@ namespace System.Globalization
|
||||
// Store for specific data about each calendar
|
||||
invariant.calendars = new CalendarData[CalendarData.MAX_CALENDARS];
|
||||
invariant.calendars[0] = CalendarData.Invariant;
|
||||
|
||||
invariant.iDefaultAnsiCodePage = 1252; // default ansi code page ID (ACP)
|
||||
invariant.iDefaultOemCodePage = 437; // default oem code page ID (OCP or OEM)
|
||||
invariant.iDefaultMacCodePage = 10000; // default macintosh code page
|
||||
invariant.iDefaultEbcdicCodePage = 037; // default EBCDIC code page
|
||||
|
||||
invariant.sListSeparator = ",";
|
||||
|
||||
Interlocked.CompareExchange (ref s_Invariant, invariant, null);
|
||||
}
|
||||
@@ -113,7 +129,8 @@ namespace System.Globalization
|
||||
}
|
||||
}
|
||||
|
||||
public static CultureData GetCultureData (string cultureName, bool useUserOverride, int datetimeIndex, int calendarId, string iso2lang)
|
||||
public static CultureData GetCultureData (string cultureName, bool useUserOverride, int datetimeIndex, int calendarId, int numberIndex, string iso2lang,
|
||||
int ansiCodePage, int oemCodePage, int macCodePage, int ebcdicCodePage, bool rightToLeft, string listSeparator)
|
||||
{
|
||||
if (string.IsNullOrEmpty (cultureName))
|
||||
return Invariant;
|
||||
@@ -122,16 +139,29 @@ namespace System.Globalization
|
||||
cd.fill_culture_data (datetimeIndex);
|
||||
cd.bUseOverrides = useUserOverride;
|
||||
cd.calendarId = calendarId;
|
||||
cd.numberIndex = numberIndex;
|
||||
cd.sISO639Language = iso2lang;
|
||||
cd.iDefaultAnsiCodePage = ansiCodePage;
|
||||
cd.iDefaultOemCodePage = oemCodePage;
|
||||
cd.iDefaultMacCodePage = macCodePage;
|
||||
cd.iDefaultEbcdicCodePage = ebcdicCodePage;
|
||||
cd.isRightToLeft = rightToLeft;
|
||||
cd.sListSeparator = listSeparator;
|
||||
return cd;
|
||||
}
|
||||
|
||||
internal static CultureData GetCultureData (int culture, bool bUseUserOverride)
|
||||
{
|
||||
// Legacy path which we should never hit
|
||||
return null;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
extern void fill_culture_data (int datetimeIndex);
|
||||
|
||||
public CalendarData GetCalendar (int calendarId)
|
||||
{
|
||||
// arrays are 0 based, calendarIds are 1 based
|
||||
// arrays are 0 based, calendarIds are 1 based
|
||||
int calendarIndex = calendarId - 1;
|
||||
|
||||
// Have to have calendars
|
||||
@@ -219,17 +249,71 @@ namespace System.Globalization
|
||||
}
|
||||
}
|
||||
|
||||
internal String CultureName {
|
||||
get {
|
||||
return sRealName;
|
||||
}
|
||||
}
|
||||
|
||||
internal String SCOMPAREINFO {
|
||||
get {
|
||||
return "";
|
||||
internal bool IsInvariantCulture {
|
||||
get {
|
||||
return string.IsNullOrEmpty (sRealName);
|
||||
}
|
||||
}
|
||||
|
||||
internal String CultureName {
|
||||
get {
|
||||
return sRealName;
|
||||
}
|
||||
}
|
||||
|
||||
internal String SCOMPAREINFO {
|
||||
get {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
internal String STEXTINFO {
|
||||
get {
|
||||
return sRealName;
|
||||
}
|
||||
}
|
||||
|
||||
internal int ILANGUAGE {
|
||||
get {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
internal int IDEFAULTANSICODEPAGE {
|
||||
get {
|
||||
return iDefaultAnsiCodePage;
|
||||
}
|
||||
}
|
||||
|
||||
internal int IDEFAULTOEMCODEPAGE {
|
||||
get {
|
||||
return iDefaultOemCodePage;
|
||||
}
|
||||
}
|
||||
|
||||
internal int IDEFAULTMACCODEPAGE {
|
||||
get {
|
||||
return iDefaultMacCodePage;
|
||||
}
|
||||
}
|
||||
|
||||
internal int IDEFAULTEBCDICCODEPAGE {
|
||||
get {
|
||||
return iDefaultEbcdicCodePage;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsRightToLeft {
|
||||
get {
|
||||
return isRightToLeft;
|
||||
}
|
||||
}
|
||||
|
||||
internal String SLIST {
|
||||
get {
|
||||
return sListSeparator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region from reference sources
|
||||
|
||||
@@ -510,5 +594,42 @@ namespace System.Globalization
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
internal static bool IsCustomCultureId(int cultureId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void GetNFIValues (NumberFormatInfo nfi)
|
||||
{
|
||||
if (this.IsInvariantCulture)
|
||||
{
|
||||
// Same as default values
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// We don't have information for the following four. All cultures use
|
||||
// the same value of the number formatting values.
|
||||
//
|
||||
// PercentDecimalDigits
|
||||
// PercentDecimalSeparator
|
||||
// PercentGroupSize
|
||||
// PercentGroupSeparator
|
||||
//
|
||||
fill_number_data (nfi, numberIndex);
|
||||
}
|
||||
|
||||
//
|
||||
// We don't have percent values, so use the number values
|
||||
//
|
||||
nfi.percentDecimalDigits = nfi.numberDecimalDigits;
|
||||
nfi.percentDecimalSeparator = nfi.numberDecimalSeparator;
|
||||
nfi.percentGroupSizes = nfi.numberGroupSizes;
|
||||
nfi.percentGroupSeparator = nfi.numberGroupSeparator;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
extern static void fill_number_data (NumberFormatInfo nfi, int numberIndex);
|
||||
}
|
||||
}
|
||||
|
||||
149
mcs/class/corlib/ReferenceSources/DefaultBinder.cs
Normal file
149
mcs/class/corlib/ReferenceSources/DefaultBinder.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// DefaultBinder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace System
|
||||
{
|
||||
partial class DefaultBinder
|
||||
{
|
||||
static bool CanConvertPrimitive (RuntimeType source, RuntimeType target)
|
||||
{
|
||||
if (source.IsEnum)
|
||||
return false;
|
||||
|
||||
var from = Type.GetTypeCode (source);
|
||||
switch (Type.GetTypeCode (target)) {
|
||||
case TypeCode.Char:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.UInt16:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.Int16:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.UInt16:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.Char:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.Int32:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Char:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.UInt16:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.UInt32:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.Char:
|
||||
case TypeCode.UInt16:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.Int64:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.Char:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.UInt64:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.Char:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.UInt32:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.Single:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.Char:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt64:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case TypeCode.Double:
|
||||
switch (from) {
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Char:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Single:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target == typeof (IntPtr))
|
||||
return source == target;
|
||||
|
||||
if (target == typeof (UIntPtr))
|
||||
return source == target;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool CanConvertPrimitiveObjectToType (Object source, RuntimeType type)
|
||||
{
|
||||
if (source == null)
|
||||
return true;
|
||||
|
||||
var st = source.GetType ();
|
||||
return st == type || CanConvertPrimitive ((RuntimeType) st, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,35 @@ namespace System
|
||||
{
|
||||
return string.Format (CultureInfo.InvariantCulture, key, values);
|
||||
}
|
||||
|
||||
internal static String GetRuntimeResourceString (string key)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
internal static String GetRuntimeResourceString (string key, params object[] values)
|
||||
{
|
||||
return string.Format (CultureInfo.InvariantCulture, key, values);
|
||||
}
|
||||
|
||||
internal static string GetResourceStringEncodingName (int codePage)
|
||||
{
|
||||
switch (codePage) {
|
||||
case 1200: return GetResourceString ("Globalization.cp_1200");
|
||||
case 1201: return GetResourceString ("Globalization.cp_1201");
|
||||
case 12000: return GetResourceString ("Globalization.cp_12000");
|
||||
case 12001: return GetResourceString ("Globalization.cp_12001");
|
||||
case 20127: return GetResourceString ("Globalization.cp_20127");
|
||||
case 65000: return GetResourceString ("Globalization.cp_65000");
|
||||
case 65001: return GetResourceString ("Globalization.cp_65001");
|
||||
default: return codePage.ToString (CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsWindows8OrAbove {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
using System.Security;
|
||||
|
||||
namespace System.Threading
|
||||
{
|
||||
partial class ExecutionContext
|
||||
{
|
||||
internal static ExecutionContext Capture (ref StackCrawlMark stackMark, CaptureOptions options)
|
||||
{
|
||||
return Capture ((options & CaptureOptions.IgnoreSyncCtx) == 0, false);
|
||||
}
|
||||
|
||||
internal static ExecutionContext FastCapture()
|
||||
{
|
||||
return Capture ();
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum CaptureOptions
|
||||
{
|
||||
None = 0x00,
|
||||
|
||||
IgnoreSyncCtx = 0x01, //Don't flow SynchronizationContext
|
||||
|
||||
OptimizeDefaultCase = 0x02, //Faster in the typical case, but can't show the result to users
|
||||
// because they could modify the shared default EC.
|
||||
// Use this only if you won't be exposing the captured EC to users.
|
||||
}
|
||||
|
||||
private static readonly ExecutionContext s_dummyDefaultEC = new ExecutionContext();
|
||||
static internal ExecutionContext PreAllocatedDefault
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get {
|
||||
return s_dummyDefaultEC;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsPreAllocatedDefault
|
||||
{
|
||||
get
|
||||
{
|
||||
return this == s_dummyDefaultEC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal enum StackCrawlMark
|
||||
{
|
||||
LookForMe = 0,
|
||||
LookForMyCaller = 1,
|
||||
LookForMyCallersCaller = 2,
|
||||
LookForThread = 3
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,17 @@ namespace System.Runtime.CompilerServices {
|
||||
{
|
||||
static internal T UnsafeCast<T>(Object o) where T : class
|
||||
{
|
||||
return (T)o;
|
||||
return Array.UnsafeMov<object, T> (o);
|
||||
}
|
||||
|
||||
static internal int UnsafeEnumCast<T>(T val) where T : struct
|
||||
{
|
||||
return Array.UnsafeMov<T, int> (val);
|
||||
}
|
||||
|
||||
static internal long UnsafeEnumCastLong<T>(T val) where T : struct
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
63
mcs/class/corlib/ReferenceSources/MethodBase.cs
Normal file
63
mcs/class/corlib/ReferenceSources/MethodBase.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#if !FULL_AOT_RUNTIME
|
||||
using System.Reflection.Emit;
|
||||
#endif
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Reflection
|
||||
{
|
||||
partial class MethodBase
|
||||
{
|
||||
//
|
||||
// This is a quick version for our own use. We should override
|
||||
// it where possible so that it does not allocate an array.
|
||||
// They cannot be abstract otherwise we break public contract
|
||||
//
|
||||
internal virtual ParameterInfo[] GetParametersInternal ()
|
||||
{
|
||||
// Override me
|
||||
return GetParameters ();
|
||||
}
|
||||
|
||||
internal virtual int GetParametersCount ()
|
||||
{
|
||||
// Override me
|
||||
return GetParametersInternal ().Length;
|
||||
}
|
||||
|
||||
internal virtual Type GetParameterType (int pos)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
internal virtual int get_next_table_index (object obj, int table, bool inc) {
|
||||
#if !FULL_AOT_RUNTIME
|
||||
if (this is MethodBuilder) {
|
||||
MethodBuilder mb = (MethodBuilder)this;
|
||||
return mb.get_next_table_index (obj, table, inc);
|
||||
}
|
||||
if (this is ConstructorBuilder) {
|
||||
ConstructorBuilder mb = (ConstructorBuilder)this;
|
||||
return mb.get_next_table_index (obj, table, inc);
|
||||
}
|
||||
#endif
|
||||
throw new Exception ("Method is not a builder method");
|
||||
}
|
||||
|
||||
internal static MethodBase GetMethodFromHandleNoGenericCheck (RuntimeMethodHandle handle)
|
||||
{
|
||||
return GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal extern static MethodBody GetMethodBodyInternal (IntPtr handle);
|
||||
|
||||
internal static MethodBody GetMethodBody (IntPtr handle)
|
||||
{
|
||||
return GetMethodBodyInternal (handle);
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
extern static MethodBase GetMethodFromHandleInternalType (IntPtr method_handle, IntPtr type_handle);
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,13 @@ namespace System {
|
||||
}
|
||||
}
|
||||
|
||||
// Value from which a new base 16 digit can cause an overflow.
|
||||
const ulong base16MaxOverflowFreeValue = ulong.MaxValue / (16 * 16);
|
||||
|
||||
// From ulong we can only cast to positive long.
|
||||
// As |long.MinValue| > |long.MaxValue| we need to do this to avoid an overflow.
|
||||
const ulong longMinValue = ((ulong) long.MaxValue) + (ulong) -(long.MinValue + long.MaxValue);
|
||||
|
||||
public unsafe static long StringToLong (string value, int fromBase, int flags, int* parsePos)
|
||||
{
|
||||
if ((flags & (IsTight | NoSpace)) == 0)
|
||||
@@ -177,11 +184,13 @@ namespace System {
|
||||
return 0;
|
||||
|
||||
int chars = 0;
|
||||
int digitValue = -1;
|
||||
long result = 0;
|
||||
ulong fromBaseULong = (ulong) fromBase;
|
||||
ulong digitValue = 0;
|
||||
ulong result = 0;
|
||||
|
||||
int len = value.Length;
|
||||
bool negative = false;
|
||||
bool treatAsUnsigned = (flags & ParseNumbers.TreatAsUnsigned) != 0;
|
||||
|
||||
if (len == 0) {
|
||||
// Mimic broken .net behaviour
|
||||
@@ -195,7 +204,7 @@ namespace System {
|
||||
if (fromBase != 10)
|
||||
throw new ArgumentException ("String cannot contain a minus sign if the base is not 10.");
|
||||
|
||||
if ((flags & TreatAsUnsigned) != 0)
|
||||
if (treatAsUnsigned)
|
||||
throw new OverflowException ("Negative number");
|
||||
|
||||
negative = true;
|
||||
@@ -211,9 +220,9 @@ namespace System {
|
||||
while (i < len) {
|
||||
char c = value[i];
|
||||
if (Char.IsNumber (c)) {
|
||||
digitValue = c - '0';
|
||||
digitValue = (ulong) (c - '0');
|
||||
} else if (Char.IsLetter (c)) {
|
||||
digitValue = Char.ToLowerInvariant (c) - 'a' + 10;
|
||||
digitValue = (ulong) (Char.ToLowerInvariant (c) - 'a' + 10);
|
||||
} else {
|
||||
if (i == 0)
|
||||
throw new FormatException ("Could not find any parsable digits.");
|
||||
@@ -224,7 +233,7 @@ namespace System {
|
||||
break;
|
||||
}
|
||||
|
||||
if (digitValue >= fromBase) {
|
||||
if (digitValue >= fromBaseULong) {
|
||||
if (chars > 0) {
|
||||
throw new FormatException ("Additional unparsable "
|
||||
+ "characters are at the end of the string.");
|
||||
@@ -234,7 +243,18 @@ namespace System {
|
||||
}
|
||||
}
|
||||
|
||||
result = fromBase * result + digitValue;
|
||||
if (result <= base16MaxOverflowFreeValue) {
|
||||
result = result * (ulong) fromBaseULong + digitValue;
|
||||
} else {
|
||||
// decompose 64 bit operation into 32 bit operations so we can check for overflows
|
||||
ulong a = (result >> 32) * fromBaseULong;
|
||||
ulong b = (result & uint.MaxValue) * fromBaseULong + digitValue;
|
||||
if (((b >> 32) + a) > uint.MaxValue)
|
||||
throw new OverflowException ();
|
||||
|
||||
result = (a << 32) + b;
|
||||
}
|
||||
|
||||
chars++;
|
||||
++i;
|
||||
}
|
||||
@@ -245,7 +265,24 @@ namespace System {
|
||||
if (parsePos != null)
|
||||
*parsePos = i;
|
||||
|
||||
return negative ? -result : result;
|
||||
if (treatAsUnsigned)
|
||||
return (long) result;
|
||||
|
||||
if (!negative) {
|
||||
if (fromBase == 10 && result > ((ulong) long.MaxValue))
|
||||
throw new OverflowException ();
|
||||
|
||||
return (long)result;
|
||||
}
|
||||
|
||||
if (result <= (ulong) long.MaxValue)
|
||||
return -((long) result);
|
||||
|
||||
if (result > longMinValue)
|
||||
throw new OverflowException ();
|
||||
|
||||
// Avoids overflow of -result when result > long.MaxValue
|
||||
return long.MinValue + (long) (longMinValue - result);
|
||||
}
|
||||
|
||||
public static string IntToString (int value, int toBase, int width, char paddingChar, int flags)
|
||||
|
||||
21
mcs/class/corlib/ReferenceSources/RemotingFieldCachedData.cs
Normal file
21
mcs/class/corlib/ReferenceSources/RemotingFieldCachedData.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Runtime.Remoting.Metadata
|
||||
{
|
||||
class RemotingCachedData
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class RemotingFieldCachedData
|
||||
{
|
||||
internal RemotingFieldCachedData(RuntimeFieldInfo ri)
|
||||
{
|
||||
}
|
||||
|
||||
internal RemotingFieldCachedData(SerializationFieldInfo ri)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
41
mcs/class/corlib/ReferenceSources/RuntimeHandles.cs
Normal file
41
mcs/class/corlib/ReferenceSources/RuntimeHandles.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace System
|
||||
{
|
||||
internal interface IRuntimeMethodInfo
|
||||
{
|
||||
RuntimeMethodHandleInternal Value
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
internal struct RuntimeMethodHandleInternal
|
||||
{
|
||||
internal static RuntimeMethodHandleInternal EmptyHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RuntimeMethodHandleInternal();
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNullHandle()
|
||||
{
|
||||
return m_handle.IsNull();
|
||||
}
|
||||
|
||||
internal IntPtr Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_handle;
|
||||
}
|
||||
}
|
||||
|
||||
internal RuntimeMethodHandleInternal(IntPtr value)
|
||||
{
|
||||
m_handle = value;
|
||||
}
|
||||
|
||||
internal IntPtr m_handle;
|
||||
}
|
||||
}
|
||||
619
mcs/class/corlib/ReferenceSources/RuntimeType.cs
Normal file
619
mcs/class/corlib/ReferenceSources/RuntimeType.cs
Normal file
File diff suppressed because it is too large
Load Diff
94
mcs/class/corlib/ReferenceSources/SecurityContext.cs
Normal file
94
mcs/class/corlib/ReferenceSources/SecurityContext.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// SecurityContext.cs: This is CAS disabled SecurityContext version
|
||||
// it does nothing but has same public API
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !FEATURE_COMPRESSEDSTACK
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Security {
|
||||
|
||||
public sealed class SecurityContext : IDisposable
|
||||
{
|
||||
private SecurityContext ()
|
||||
{
|
||||
}
|
||||
|
||||
public SecurityContext CreateCopy ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
static public SecurityContext Capture ()
|
||||
{
|
||||
return new SecurityContext ();
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
}
|
||||
|
||||
static public bool IsFlowSuppressed ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static public bool IsWindowsIdentityFlowSuppressed ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static public void RestoreFlow ()
|
||||
{
|
||||
}
|
||||
|
||||
// if you got the context then you can use it
|
||||
[SecurityPermission (SecurityAction.Assert, ControlPrincipal = true)]
|
||||
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
|
||||
static public void Run (SecurityContext securityContext, ContextCallback callback, object state)
|
||||
{
|
||||
callback (state);
|
||||
}
|
||||
|
||||
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
|
||||
static public AsyncFlowControl SuppressFlow ()
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
|
||||
static public AsyncFlowControl SuppressFlowWindowsIdentity ()
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
22
mcs/class/corlib/ReferenceSources/SharedStatics.cs
Normal file
22
mcs/class/corlib/ReferenceSources/SharedStatics.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Threading;
|
||||
using StringMaker = System.Security.Util.Tokenizer.StringMaker;
|
||||
|
||||
namespace System
|
||||
{
|
||||
static class SharedStatics
|
||||
{
|
||||
static StringMaker shared;
|
||||
static public StringMaker GetSharedStringMaker ()
|
||||
{
|
||||
if (shared == null)
|
||||
Interlocked.CompareExchange (ref shared, new StringMaker (), null);
|
||||
|
||||
return shared;
|
||||
}
|
||||
|
||||
static public void ReleaseSharedStringMaker (ref StringMaker maker)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
766
mcs/class/corlib/ReferenceSources/String.cs
Normal file
766
mcs/class/corlib/ReferenceSources/String.cs
Normal file
File diff suppressed because it is too large
Load Diff
201
mcs/class/corlib/ReferenceSources/TextInfo.cs
Normal file
201
mcs/class/corlib/ReferenceSources/TextInfo.cs
Normal file
@@ -0,0 +1,201 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Globalization
|
||||
{
|
||||
partial class TextInfo
|
||||
{
|
||||
unsafe static ushort *to_lower_data_low;
|
||||
unsafe static ushort *to_lower_data_high;
|
||||
unsafe static ushort *to_upper_data_low;
|
||||
unsafe static ushort *to_upper_data_high;
|
||||
|
||||
[MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
|
||||
unsafe static extern void GetDataTablePointersLite (out ushort *to_lower_data_low, out ushort *to_lower_data_high, out ushort *to_upper_data_low, out ushort *to_upper_data_high);
|
||||
|
||||
static readonly object cookie = new object ();
|
||||
|
||||
unsafe static void ReadDataTable ()
|
||||
{
|
||||
if (to_lower_data_low == null) {
|
||||
lock (cookie) {
|
||||
if (to_lower_data_low != null)
|
||||
return;
|
||||
|
||||
GetDataTablePointersLite (out to_lower_data_low, out to_lower_data_high, out to_upper_data_low, out to_upper_data_high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe string ToUpperInternal (string str)
|
||||
{
|
||||
if (str.Length == 0)
|
||||
return String.Empty;
|
||||
|
||||
string tmp = String.FastAllocateString (str.Length);
|
||||
fixed (char* source = str, dest = tmp) {
|
||||
|
||||
char* destPtr = (char*)dest;
|
||||
char* sourcePtr = (char*)source;
|
||||
|
||||
for (int n = 0; n < str.Length; n++) {
|
||||
*destPtr = ToUpper (*sourcePtr);
|
||||
sourcePtr++;
|
||||
destPtr++;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
unsafe string ToLowerInternal (string str)
|
||||
{
|
||||
if (str.Length == 0)
|
||||
return String.Empty;
|
||||
|
||||
string tmp = String.FastAllocateString (str.Length);
|
||||
fixed (char* source = str, dest = tmp) {
|
||||
|
||||
char* destPtr = (char*)dest;
|
||||
char* sourcePtr = (char*)source;
|
||||
|
||||
for (int n = 0; n < str.Length; n++) {
|
||||
*destPtr = ToLower (*sourcePtr);
|
||||
sourcePtr++;
|
||||
destPtr++;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
char ToUpperInternal (char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '\u0069': // Latin lowercase i
|
||||
if (!IsAsciiCasingSameAsInvariant)
|
||||
return '\u0130'; // dotted capital I
|
||||
break;
|
||||
case '\u0131': // dotless i
|
||||
return '\u0049'; // I
|
||||
|
||||
case '\u01c5': // see ToLower()
|
||||
return '\u01c4';
|
||||
case '\u01c8': // see ToLower()
|
||||
return '\u01c7';
|
||||
case '\u01cb': // see ToLower()
|
||||
return '\u01ca';
|
||||
case '\u01f2': // see ToLower()
|
||||
return '\u01f1';
|
||||
case '\u0390': // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
|
||||
return '\u03aa'; // it is not in ICU
|
||||
case '\u03b0': // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
|
||||
return '\u03ab'; // it is not in ICU
|
||||
case '\u03d0': // GREEK BETA
|
||||
return '\u0392';
|
||||
case '\u03d1': // GREEK THETA
|
||||
return '\u0398';
|
||||
case '\u03d5': // GREEK PHI
|
||||
return '\u03a6';
|
||||
case '\u03d6': // GREEK PI
|
||||
return '\u03a0';
|
||||
case '\u03f0': // GREEK KAPPA
|
||||
return '\u039a';
|
||||
case '\u03f1': // GREEK RHO
|
||||
return '\u03a1';
|
||||
// am not sure why miscellaneous GREEK symbols are
|
||||
// not handled here.
|
||||
}
|
||||
|
||||
return ToUpperInvariant (c);
|
||||
}
|
||||
|
||||
char ToLowerInternal (char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '\u0049': // Latin uppercase I
|
||||
if (!IsAsciiCasingSameAsInvariant)
|
||||
return '\u0131'; // I becomes dotless i
|
||||
break;
|
||||
case '\u0130': // I-dotted
|
||||
return '\u0069'; // i
|
||||
|
||||
case '\u01c5': // LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
|
||||
return '\u01c6';
|
||||
// \u01c7 -> \u01c9 (LJ) : invariant
|
||||
case '\u01c8': // LATIN CAPITAL LETTER L WITH SMALL LETTER J
|
||||
return '\u01c9';
|
||||
// \u01ca -> \u01cc (NJ) : invariant
|
||||
case '\u01cb': // LATIN CAPITAL LETTER N WITH SMALL LETTER J
|
||||
return '\u01cc';
|
||||
// WITH CARON : invariant
|
||||
// WITH DIAERESIS AND * : invariant
|
||||
|
||||
case '\u01f2': // LATIN CAPITAL LETTER D WITH SMALL LETTER Z
|
||||
return '\u01f3';
|
||||
case '\u03d2': // ? it is not in ICU
|
||||
return '\u03c5';
|
||||
case '\u03d3': // ? it is not in ICU
|
||||
return '\u03cd';
|
||||
case '\u03d4': // ? it is not in ICU
|
||||
return '\u03cb';
|
||||
}
|
||||
return ToLowerInvariant (c);
|
||||
}
|
||||
|
||||
static char ToLowerInvariant (char c)
|
||||
{
|
||||
ReadDataTable ();
|
||||
|
||||
unsafe {
|
||||
if (c <= ((char)0x24cf))
|
||||
return (char) to_lower_data_low [c];
|
||||
if (c >= ((char)0xff21))
|
||||
return (char) to_lower_data_high[c - 0xff21];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static char ToUpperInvariant (char c)
|
||||
{
|
||||
ReadDataTable ();
|
||||
|
||||
unsafe {
|
||||
if (c <= ((char)0x24e9))
|
||||
return (char) to_upper_data_low [c];
|
||||
if (c >= ((char)0xff21))
|
||||
return (char) to_upper_data_high [c - 0xff21];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static unsafe int InternalCompareStringOrdinalIgnoreCase (String strA, int indexA, String strB, int indexB, int lenA, int lenB)
|
||||
{
|
||||
if (strA == null) {
|
||||
return strB == null ? 0 : -1;
|
||||
}
|
||||
if (strB == null) {
|
||||
return 1;
|
||||
}
|
||||
int lengthA = Math.Min (lenA, strA.Length - indexA);
|
||||
int lengthB = Math.Min (lenB, strB.Length - indexB);
|
||||
|
||||
if (lengthA == lengthB && Object.ReferenceEquals (strA, strB))
|
||||
return 0;
|
||||
|
||||
fixed (char* aptr = strA, bptr = strB) {
|
||||
char* ap = aptr + indexA;
|
||||
char* end = ap + Math.Min (lengthA, lengthB);
|
||||
char* bp = bptr + indexB;
|
||||
while (ap < end) {
|
||||
if (*ap != *bp) {
|
||||
char c1 = Char.ToUpperInvariant (*ap);
|
||||
char c2 = Char.ToUpperInvariant (*bp);
|
||||
if (c1 != c2)
|
||||
return c1 - c2;
|
||||
}
|
||||
ap++;
|
||||
bp++;
|
||||
}
|
||||
return lengthA - lengthB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace System
|
||||
{
|
||||
[Flags]
|
||||
internal enum TimeZoneInfoOptions {
|
||||
None = 1,
|
||||
NoThrowOnInvalidTime = 2
|
||||
};
|
||||
}
|
||||
139
mcs/class/corlib/ReferenceSources/Type.cs
Normal file
139
mcs/class/corlib/ReferenceSources/Type.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// Type.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
partial class Type : MemberInfo
|
||||
{
|
||||
internal RuntimeTypeHandle _impl;
|
||||
|
||||
#region Requires stack backtracing fixes in unmanaged type_from_name
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
static extern Type internal_from_name (string name, bool throwOnError, bool ignoreCase);
|
||||
|
||||
public static Type GetType(string typeName)
|
||||
{
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("TypeName");
|
||||
|
||||
return internal_from_name (typeName, false, false);
|
||||
}
|
||||
|
||||
public static Type GetType(string typeName, bool throwOnError)
|
||||
{
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("TypeName");
|
||||
|
||||
Type type = internal_from_name (typeName, throwOnError, false);
|
||||
if (throwOnError && type == null)
|
||||
throw new TypeLoadException ("Error loading '" + typeName + "'");
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
|
||||
{
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("TypeName");
|
||||
|
||||
Type t = internal_from_name (typeName, throwOnError, ignoreCase);
|
||||
if (throwOnError && t == null)
|
||||
throw new TypeLoadException ("Error loading '" + typeName + "'");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Merge with internal_from_name
|
||||
public static Type ReflectionOnlyGetType (string typeName,
|
||||
bool throwIfNotFound,
|
||||
bool ignoreCase)
|
||||
{
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("typeName");
|
||||
int idx = typeName.IndexOf (',');
|
||||
if (idx < 0 || idx == 0 || idx == typeName.Length - 1)
|
||||
throw new ArgumentException ("Assembly qualifed type name is required", "typeName");
|
||||
string an = typeName.Substring (idx + 1);
|
||||
Assembly a;
|
||||
try {
|
||||
a = Assembly.ReflectionOnlyLoad (an);
|
||||
} catch {
|
||||
if (throwIfNotFound)
|
||||
throw;
|
||||
return null;
|
||||
}
|
||||
return a.GetType (typeName.Substring (0, idx), throwIfNotFound, ignoreCase);
|
||||
}
|
||||
|
||||
internal virtual Type InternalResolve ()
|
||||
{
|
||||
return UnderlyingSystemType;
|
||||
}
|
||||
|
||||
internal virtual bool IsUserType {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual MethodInfo GetMethod (MethodInfo fromNoninstanciated)
|
||||
{
|
||||
throw new System.InvalidOperationException ("can only be called in generic type");
|
||||
}
|
||||
|
||||
internal virtual ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
|
||||
{
|
||||
throw new System.InvalidOperationException ("can only be called in generic type");
|
||||
}
|
||||
|
||||
internal virtual FieldInfo GetField (FieldInfo fromNoninstanciated)
|
||||
{
|
||||
throw new System.InvalidOperationException ("can only be called in generic type");
|
||||
}
|
||||
|
||||
public static Type GetTypeFromHandle (RuntimeTypeHandle handle)
|
||||
{
|
||||
if (handle.Value == IntPtr.Zero)
|
||||
// This is not consistent with the other GetXXXFromHandle methods, but
|
||||
// MS.NET seems to do this
|
||||
return null;
|
||||
|
||||
return internal_from_handle (handle.Value);
|
||||
}
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
static extern Type internal_from_handle (IntPtr handle);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user