summaryrefslogtreecommitdiff
path: root/src/classlibnative
diff options
context:
space:
mode:
Diffstat (limited to 'src/classlibnative')
-rw-r--r--src/classlibnative/bcltype/arraynative.cpp99
-rw-r--r--src/classlibnative/bcltype/arraynative.inl329
-rw-r--r--src/classlibnative/bcltype/number.cpp53
-rw-r--r--src/classlibnative/bcltype/number.h3
-rw-r--r--src/classlibnative/bcltype/objectnative.cpp11
-rw-r--r--src/classlibnative/bcltype/stringnative.cpp5
-rw-r--r--src/classlibnative/bcltype/system.cpp306
-rw-r--r--src/classlibnative/bcltype/system.h24
-rw-r--r--src/classlibnative/float/floatdouble.cpp27
-rw-r--r--src/classlibnative/float/floatsingle.cpp69
-rw-r--r--src/classlibnative/inc/calendardata.h165
-rw-r--r--src/classlibnative/inc/floatsingle.h38
-rw-r--r--src/classlibnative/inc/nlsinfo.h169
-rw-r--r--src/classlibnative/inc/nlstable.h121
-rw-r--r--src/classlibnative/nls/CMakeLists.txt2
-rw-r--r--src/classlibnative/nls/calendardata.cpp985
-rw-r--r--src/classlibnative/nls/encodingdata.cpp579
-rw-r--r--src/classlibnative/nls/nlsinfo.cpp3203
-rw-r--r--src/classlibnative/nls/nlstable.cpp259
19 files changed, 427 insertions, 6020 deletions
diff --git a/src/classlibnative/bcltype/arraynative.cpp b/src/classlibnative/bcltype/arraynative.cpp
index 0eae8b2d07..c54d2f3c31 100644
--- a/src/classlibnative/bcltype/arraynative.cpp
+++ b/src/classlibnative/bcltype/arraynative.cpp
@@ -17,6 +17,8 @@
#include "security.h"
#include "invokeutil.h"
+#include "arraynative.inl"
+
FCIMPL1(INT32, ArrayNative::GetRank, ArrayBase* array)
{
FCALL_CONTRACT;
@@ -173,7 +175,7 @@ void ArrayInitializeWorker(ARRAYBASEREF * arrayRef,
PCODE ctorFtn = pCanonMT->GetSlot(slot);
-#ifdef _X86_
+#if defined(_TARGET_X86_) && !defined(FEATURE_PAL)
BEGIN_CALL_TO_MANAGED();
@@ -204,7 +206,7 @@ void ArrayInitializeWorker(ARRAYBASEREF * arrayRef,
}
END_CALL_TO_MANAGED();
-#else // _X86_
+#else // _TARGET_X86_ && !FEATURE_PAL
//
// This is quite a bit slower, but it is portable.
//
@@ -228,7 +230,7 @@ void ArrayInitializeWorker(ARRAYBASEREF * arrayRef,
offset += size;
}
-#endif // _X86_
+#endif // !_TARGET_X86_ || FEATURE_PAL
}
@@ -883,85 +885,25 @@ void memmoveGCRefs(void *dest, const void *src, size_t len)
NOTHROW;
GC_NOTRIGGER;
MODE_COOPERATIVE;
- PRECONDITION(CheckPointer(dest));
- PRECONDITION(CheckPointer(src));
- PRECONDITION(len >= 0);
SO_TOLERANT;
}
CONTRACTL_END;
+ _ASSERTE(dest != nullptr);
+ _ASSERTE(src != nullptr);
+
// Make sure everything is pointer aligned
_ASSERTE(IS_ALIGNED(dest, sizeof(SIZE_T)));
_ASSERTE(IS_ALIGNED(src, sizeof(SIZE_T)));
_ASSERTE(IS_ALIGNED(len, sizeof(SIZE_T)));
- size_t size = len;
- BYTE * dmem = (BYTE *)dest;
- BYTE * smem = (BYTE *)src;
-
- GCHeapMemoryBarrier();
-
- if (dmem <= smem || smem + size <= dmem)
- {
- // copy 16 bytes at a time
- while (size >= 4 * sizeof(SIZE_T))
- {
- size -= 4 * sizeof(SIZE_T);
- ((SIZE_T *)dmem)[0] = ((SIZE_T *)smem)[0];
- ((SIZE_T *)dmem)[1] = ((SIZE_T *)smem)[1];
- ((SIZE_T *)dmem)[2] = ((SIZE_T *)smem)[2];
- ((SIZE_T *)dmem)[3] = ((SIZE_T *)smem)[3];
- smem += 4 * sizeof(SIZE_T);
- dmem += 4 * sizeof(SIZE_T);
- }
-
- if ((size & (2 * sizeof(SIZE_T))) != 0)
- {
- ((SIZE_T *)dmem)[0] = ((SIZE_T *)smem)[0];
- ((SIZE_T *)dmem)[1] = ((SIZE_T *)smem)[1];
- smem += 2 * sizeof(SIZE_T);
- dmem += 2 * sizeof(SIZE_T);
- }
+ _ASSERTE(CheckPointer(dest));
+ _ASSERTE(CheckPointer(src));
- if ((size & sizeof(SIZE_T)) != 0)
- {
- ((SIZE_T *)dmem)[0] = ((SIZE_T *)smem)[0];
- }
- }
- else
+ if (len != 0 && dest != src)
{
- smem += size;
- dmem += size;
-
- // copy 16 bytes at a time
- while (size >= 4 * sizeof(SIZE_T))
- {
- size -= 4 * sizeof(SIZE_T);
- smem -= 4 * sizeof(SIZE_T);
- dmem -= 4 * sizeof(SIZE_T);
- ((SIZE_T *)dmem)[3] = ((SIZE_T *)smem)[3];
- ((SIZE_T *)dmem)[2] = ((SIZE_T *)smem)[2];
- ((SIZE_T *)dmem)[1] = ((SIZE_T *)smem)[1];
- ((SIZE_T *)dmem)[0] = ((SIZE_T *)smem)[0];
- }
-
- if ((size & (2 * sizeof(SIZE_T))) != 0)
- {
- smem -= 2 * sizeof(SIZE_T);
- dmem -= 2 * sizeof(SIZE_T);
- ((SIZE_T *)dmem)[1] = ((SIZE_T *)smem)[1];
- ((SIZE_T *)dmem)[0] = ((SIZE_T *)smem)[0];
- }
-
- if ((size & sizeof(SIZE_T)) != 0)
- {
- smem -= sizeof(SIZE_T);
- dmem -= sizeof(SIZE_T);
- ((SIZE_T *)dmem)[0] = ((SIZE_T *)smem)[0];
- }
+ InlinedMemmoveGCRefsHelper(dest, src, len);
}
-
- SetCardsAfterBulkCopy((Object**)dest, len);
}
void ArrayNative::ArrayCopyNoTypeCheck(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length)
@@ -1186,18 +1128,6 @@ void ArrayNative::CheckElementType(TypeHandle elementType)
// TODO: We also should check for type/member visibility here. To do that we can replace
// the following chunk of code with a simple InvokeUtil::CanAccessClass call.
// But it's too late to make this change in Dev10 and we want SL4 to be compatible with Dev10.
-#ifndef FEATURE_CORECLR
- // Make sure security allows us access to the array type - if it is critical, convert that to a
- // demand for full trust
- if (!SecurityStackWalk::HasFlagsOrFullyTrusted(0))
- {
- if (Security::TypeRequiresTransparencyCheck(pMT, true))
- {
- // If we're creating a critical type, convert the critical check into a demand for full trust
- Security::SpecialDemand(SSWT_LATEBOUND_LINKDEMAND, SECURITY_FULL_TRUST);
- }
- }
-#else
if (Security::TypeRequiresTransparencyCheck(pMT))
{
// The AccessCheckOptions flag doesn't matter because we just need to get the caller.
@@ -1210,11 +1140,10 @@ void ArrayNative::CheckElementType(TypeHandle elementType)
accessCheckOptions.DemandMemberAccessOrFail(&sCtx, pMT, FALSE /*visibilityCheck*/);
}
-#endif // !FEATURE_CORECLR
// Check for byref-like types.
if (pMT->IsByRefLike())
- COMPlusThrow(kNotSupportedException, W("NotSupported_ByRefLike[]"));
+ COMPlusThrow(kNotSupportedException, W("NotSupported_ByRefLikeArray"));
// Check for open generic types.
if (pMT->IsGenericTypeDefinition() || pMT->ContainsGenericVariables())
@@ -1222,7 +1151,7 @@ void ArrayNative::CheckElementType(TypeHandle elementType)
// Check for Void.
if (elementType.GetSignatureCorElementType() == ELEMENT_TYPE_VOID)
- COMPlusThrow(kNotSupportedException, W("NotSupported_Void[]"));
+ COMPlusThrow(kNotSupportedException, W("NotSupported_VoidArray"));
// That's all the dangerous simple types we know, it must be OK.
return;
diff --git a/src/classlibnative/bcltype/arraynative.inl b/src/classlibnative/bcltype/arraynative.inl
new file mode 100644
index 0000000000..b29e1a9b73
--- /dev/null
+++ b/src/classlibnative/bcltype/arraynative.inl
@@ -0,0 +1,329 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// File: ArrayNative.cpp
+//
+
+//
+// This file contains the native methods that support the Array class
+//
+
+#ifndef _ARRAYNATIVE_INL_
+#define _ARRAYNATIVE_INL_
+
+#include "gchelpers.inl"
+
+FORCEINLINE void InlinedForwardGCSafeCopyHelper(void *dest, const void *src, size_t len)
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_COOPERATIVE;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(dest != nullptr);
+ _ASSERTE(src != nullptr);
+ _ASSERTE(dest != src);
+ _ASSERTE(len != 0);
+
+ // To be able to copy forwards, the destination buffer cannot start inside the source buffer
+ _ASSERTE((SIZE_T)dest - (SIZE_T)src >= len);
+
+ // Make sure everything is pointer aligned
+ _ASSERTE(IS_ALIGNED(dest, sizeof(SIZE_T)));
+ _ASSERTE(IS_ALIGNED(src, sizeof(SIZE_T)));
+ _ASSERTE(IS_ALIGNED(len, sizeof(SIZE_T)));
+
+ _ASSERTE(CheckPointer(dest));
+ _ASSERTE(CheckPointer(src));
+
+ SIZE_T *dptr = (SIZE_T *)dest;
+ SIZE_T *sptr = (SIZE_T *)src;
+
+ while (true)
+ {
+ if ((len & sizeof(SIZE_T)) != 0)
+ {
+ *dptr = *sptr;
+
+ len ^= sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ ++sptr;
+ ++dptr;
+ }
+
+#if defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__))
+ if ((len & (2 * sizeof(SIZE_T))) != 0)
+ {
+ __m128 v = _mm_loadu_ps((float *)sptr);
+ _mm_storeu_ps((float *)dptr, v);
+
+ len ^= 2 * sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ sptr += 2;
+ dptr += 2;
+ }
+
+ // Align the destination pointer to 16 bytes for the next set of 16-byte copies
+ if (((SIZE_T)dptr & sizeof(SIZE_T)) != 0)
+ {
+ *dptr = *sptr;
+
+ ++sptr;
+ ++dptr;
+ len -= sizeof(SIZE_T);
+ if (len < 4 * sizeof(SIZE_T))
+ {
+ continue;
+ }
+ }
+
+ // Copy 32 bytes at a time
+ _ASSERTE(len >= 4 * sizeof(SIZE_T));
+ do
+ {
+ __m128 v = _mm_loadu_ps((float *)sptr);
+ _mm_store_ps((float *)dptr, v);
+ v = _mm_loadu_ps((float *)(sptr + 2));
+ _mm_store_ps((float *)(dptr + 2), v);
+
+ sptr += 4;
+ dptr += 4;
+ len -= 4 * sizeof(SIZE_T);
+ } while (len >= 4 * sizeof(SIZE_T));
+ if (len == 0)
+ {
+ return;
+ }
+#else // !(defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__)))
+ if ((len & (2 * sizeof(SIZE_T))) != 0)
+ {
+ // Read two values and write two values to hint the use of wide loads and stores
+ SIZE_T p0 = sptr[0];
+ SIZE_T p1 = sptr[1];
+ dptr[0] = p0;
+ dptr[1] = p1;
+
+ len ^= 2 * sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ sptr += 2;
+ dptr += 2;
+ }
+
+ // Copy 16 (on 32-bit systems) or 32 (on 64-bit systems) bytes at a time
+ _ASSERTE(len >= 4 * sizeof(SIZE_T));
+ while (true)
+ {
+ // Read two values and write two values to hint the use of wide loads and stores
+ SIZE_T p0 = sptr[0];
+ SIZE_T p1 = sptr[1];
+ dptr[0] = p0;
+ dptr[1] = p1;
+ p0 = sptr[2];
+ p1 = sptr[3];
+ dptr[2] = p0;
+ dptr[3] = p1;
+
+ len -= 4 * sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ sptr += 4;
+ dptr += 4;
+ }
+#endif // defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__))
+ }
+}
+
+FORCEINLINE void InlinedBackwardGCSafeCopyHelper(void *dest, const void *src, size_t len)
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_COOPERATIVE;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(dest != nullptr);
+ _ASSERTE(src != nullptr);
+ _ASSERTE(dest != src);
+ _ASSERTE(len != 0);
+
+ // To be able to copy backwards, the source buffer cannot start inside the destination buffer
+ _ASSERTE((SIZE_T)src - (SIZE_T)dest >= len);
+
+ // Make sure everything is pointer aligned
+ _ASSERTE(IS_ALIGNED(dest, sizeof(SIZE_T)));
+ _ASSERTE(IS_ALIGNED(src, sizeof(SIZE_T)));
+ _ASSERTE(IS_ALIGNED(len, sizeof(SIZE_T)));
+
+ _ASSERTE(CheckPointer(dest));
+ _ASSERTE(CheckPointer(src));
+
+ SIZE_T *dptr = (SIZE_T *)((BYTE *)dest + len);
+ SIZE_T *sptr = (SIZE_T *)((BYTE *)src + len);
+
+ while (true)
+ {
+ if ((len & sizeof(SIZE_T)) != 0)
+ {
+ --sptr;
+ --dptr;
+
+ *dptr = *sptr;
+
+ len ^= sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ }
+
+#if defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__))
+ if ((len & (2 * sizeof(SIZE_T))) != 0)
+ {
+ sptr -= 2;
+ dptr -= 2;
+
+ __m128 v = _mm_loadu_ps((float *)sptr);
+ _mm_storeu_ps((float *)dptr, v);
+
+ len ^= 2 * sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ }
+
+ // Align the destination pointer to 16 bytes for the next set of 16-byte copies
+ if (((SIZE_T)dptr & sizeof(SIZE_T)) != 0)
+ {
+ --sptr;
+ --dptr;
+
+ *dptr = *sptr;
+
+ len -= sizeof(SIZE_T);
+ if (len < 4 * sizeof(SIZE_T))
+ {
+ continue;
+ }
+ }
+
+ // Copy 32 bytes at a time
+ _ASSERTE(len >= 4 * sizeof(SIZE_T));
+ do
+ {
+ sptr -= 4;
+ dptr -= 4;
+
+ __m128 v = _mm_loadu_ps((float *)(sptr + 2));
+ _mm_store_ps((float *)(dptr + 2), v);
+ v = _mm_loadu_ps((float *)sptr);
+ _mm_store_ps((float *)dptr, v);
+
+ len -= 4 * sizeof(SIZE_T);
+ } while (len >= 4 * sizeof(SIZE_T));
+ if (len == 0)
+ {
+ return;
+ }
+#else // !(defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__)))
+ if ((len & (2 * sizeof(SIZE_T))) != 0)
+ {
+ sptr -= 2;
+ dptr -= 2;
+
+ // Read two values and write two values to hint the use of wide loads and stores
+ SIZE_T p1 = sptr[1];
+ SIZE_T p0 = sptr[0];
+ dptr[1] = p1;
+ dptr[0] = p0;
+
+ len ^= 2 * sizeof(SIZE_T);
+ if (len == 0)
+ {
+ return;
+ }
+ }
+
+ // Copy 16 (on 32-bit systems) or 32 (on 64-bit systems) bytes at a time
+ _ASSERTE(len >= 4 * sizeof(SIZE_T));
+ do
+ {
+ sptr -= 4;
+ dptr -= 4;
+
+ // Read two values and write two values to hint the use of wide loads and stores
+ SIZE_T p0 = sptr[2];
+ SIZE_T p1 = sptr[3];
+ dptr[2] = p0;
+ dptr[3] = p1;
+ p0 = sptr[0];
+ p1 = sptr[1];
+ dptr[0] = p0;
+ dptr[1] = p1;
+
+ len -= 4 * sizeof(SIZE_T);
+ } while (len != 0);
+ return;
+#endif // defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__))
+ }
+}
+
+FORCEINLINE void InlinedMemmoveGCRefsHelper(void *dest, const void *src, size_t len)
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_COOPERATIVE;
+ SO_TOLERANT;
+ }
+ CONTRACTL_END;
+
+ _ASSERTE(dest != nullptr);
+ _ASSERTE(src != nullptr);
+ _ASSERTE(dest != src);
+ _ASSERTE(len != 0);
+
+ // Make sure everything is pointer aligned
+ _ASSERTE(IS_ALIGNED(dest, sizeof(SIZE_T)));
+ _ASSERTE(IS_ALIGNED(src, sizeof(SIZE_T)));
+ _ASSERTE(IS_ALIGNED(len, sizeof(SIZE_T)));
+
+ _ASSERTE(CheckPointer(dest));
+ _ASSERTE(CheckPointer(src));
+
+ GCHeapMemoryBarrier();
+
+ // To be able to copy forwards, the destination buffer cannot start inside the source buffer
+ if ((size_t)dest - (size_t)src >= len)
+ {
+ InlinedForwardGCSafeCopyHelper(dest, src, len);
+ }
+ else
+ {
+ InlinedBackwardGCSafeCopyHelper(dest, src, len);
+ }
+
+ InlinedSetCardsAfterBulkCopyHelper((Object**)dest, len);
+}
+
+#endif // !_ARRAYNATIVE_INL_
diff --git a/src/classlibnative/bcltype/number.cpp b/src/classlibnative/bcltype/number.cpp
index 3f2d63c70e..34169a77ed 100644
--- a/src/classlibnative/bcltype/number.cpp
+++ b/src/classlibnative/bcltype/number.cpp
@@ -1294,14 +1294,6 @@ STRINGREF NumberToString(NUMBER* number, wchar format, int nMaxDigits, NUMFMTREF
STRINGREF sZero=NULL;
// @TODO what if not sequential?
-#ifndef FEATURE_CORECLR
- if (numfmt->iDigitSubstitution == 2) // native digits
- {
- PTRARRAYREF aDigits = numfmt->sNativeDigits;
- if (aDigits!=NULL && aDigits->GetNumComponents()>0)
- sZero=(STRINGREF)aDigits->GetAt(0);
- }
-#endif
// Do the worst case calculation
/* US English - for Double.MinValue.ToString("C99"); we require 514 characters
@@ -2557,51 +2549,6 @@ FCIMPL3_VII(Object*, COMNumber::FormatUInt64, UINT64 value, StringObject* format
}
FCIMPLEND
-#if !defined(FEATURE_CORECLR)
-//
-// Used by base types that are not in mscorlib.dll (such as System.Numerics.BigInteger in System.Core.dll)
-// Note that the allDigits buffer must be fixed across this call or you will introduce a GC Hole.
-//
-FCIMPL4(Object*, COMNumber::FormatNumberBuffer, BYTE* number, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE, __in_z wchar_t* allDigits)
-{
- FCALL_CONTRACT;
-
- wchar fmt;
- int digits;
- NUMBER* pNumber;
-
- struct _gc
- {
- STRINGREF refFormat;
- NUMFMTREF refNumFmt;
- STRINGREF refRetString;
- } gc;
-
- gc.refFormat = ObjectToSTRINGREF(formatUNSAFE);
- gc.refNumFmt = (NUMFMTREF)numfmtUNSAFE;
- gc.refRetString = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
- if (gc.refNumFmt == 0) COMPlusThrowArgumentNull(W("NumberFormatInfo"));
-
- pNumber = (NUMBER*) number;
-
- pNumber->allDigits = allDigits;
-
- fmt = ParseFormatSpecifier(gc.refFormat, &digits);
- if (fmt != 0) {
- gc.refRetString = NumberToString(pNumber, fmt, digits, gc.refNumFmt);
- }
- else {
- gc.refRetString = NumberToStringFormat(pNumber, gc.refFormat, gc.refNumFmt);
- }
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.refRetString);
-}
-FCIMPLEND
-
-#endif // !FEATURE_CORECLR
FCIMPL2(FC_BOOL_RET, COMNumber::NumberBufferToDecimal, BYTE* number, DECIMAL* value)
{
diff --git a/src/classlibnative/bcltype/number.h b/src/classlibnative/bcltype/number.h
index 87bab3b9f6..db66435117 100644
--- a/src/classlibnative/bcltype/number.h
+++ b/src/classlibnative/bcltype/number.h
@@ -33,9 +33,6 @@ public:
static FCDECL3(Object*, FormatUInt32, UINT32 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
static FCDECL3_VII(Object*, FormatInt64, INT64 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
static FCDECL3_VII(Object*, FormatUInt64, UINT64 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
-#if !defined(FEATURE_CORECLR)
- static FCDECL4(Object*, FormatNumberBuffer, BYTE* number, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE, __in_z wchar_t* allDigits);
-#endif // !FEATURE_CORECLR
static FCDECL2(FC_BOOL_RET, NumberBufferToDecimal, BYTE* number, DECIMAL* value);
static FCDECL2(FC_BOOL_RET, NumberBufferToDouble, BYTE* number, double* value);
diff --git a/src/classlibnative/bcltype/objectnative.cpp b/src/classlibnative/bcltype/objectnative.cpp
index bf65ad1ff5..82b189d5c8 100644
--- a/src/classlibnative/bcltype/objectnative.cpp
+++ b/src/classlibnative/bcltype/objectnative.cpp
@@ -18,13 +18,7 @@
#include "field.h"
#include "object.h"
#include "comsynchronizable.h"
-#ifdef FEATURE_REMOTING
-#include "remoting.h"
-#endif
#include "eeconfig.h"
-#ifdef FEATURE_REMOTING
-#include "objectclone.h"
-#endif
#include "mdaassistants.h"
@@ -212,11 +206,6 @@ NOINLINE static Object* GetClassHelper(OBJECTREF objRef)
HELPER_METHOD_FRAME_BEGIN_RET_ATTRIB_1(Frame::FRAME_ATTR_EXACT_DEPTH|Frame::FRAME_ATTR_CAPTURE_DEPTH_2, refType);
-#ifdef FEATURE_REMOTING
- if (objRef->IsTransparentProxy())
- refType = CRemotingServices::GetClass(objRef);
- else
-#endif
refType = typeHandle.GetManagedClassObject();
HELPER_METHOD_FRAME_END();
diff --git a/src/classlibnative/bcltype/stringnative.cpp b/src/classlibnative/bcltype/stringnative.cpp
index 1e6b132b17..af6593a6be 100644
--- a/src/classlibnative/bcltype/stringnative.cpp
+++ b/src/classlibnative/bcltype/stringnative.cpp
@@ -160,12 +160,7 @@ FCIMPLEND
inline COMNlsHashProvider * GetCurrentNlsHashProvider()
{
LIMITED_METHOD_CONTRACT;
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
- return curDomain->m_pNlsHashProvider;
-#else
return &COMNlsHashProvider::s_NlsHashProvider;
-#endif // FEATURE_CORECLR
}
FCIMPL3(INT32, COMString::Marvin32HashString, StringObject* thisRefUNSAFE, INT32 strLen, INT64 additionalEntropy) {
diff --git a/src/classlibnative/bcltype/system.cpp b/src/classlibnative/bcltype/system.cpp
index 8bb3409974..c36d2e1066 100644
--- a/src/classlibnative/bcltype/system.cpp
+++ b/src/classlibnative/bcltype/system.cpp
@@ -31,9 +31,6 @@
#include "array.h"
#include "eepolicy.h"
-#if !defined(FEATURE_CORECLR)
-#include "metahost.h"
-#endif // !FEATURE_CORECLR
#ifdef FEATURE_WINDOWSPHONE
Volatile<BOOL> g_fGetPhoneVersionInitialized;
@@ -44,14 +41,37 @@ typedef BOOL (*pfnGetPhoneVersion)(LPOSVERSIONINFO lpVersionInformation);
pfnGetPhoneVersion g_pfnGetPhoneVersion = NULL;
#endif
+typedef void(WINAPI *pfnGetSystemTimeAsFileTime)(LPFILETIME lpSystemTimeAsFileTime);
+extern pfnGetSystemTimeAsFileTime g_pfnGetSystemTimeAsFileTime;
+
+void WINAPI InitializeGetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
+{
+ pfnGetSystemTimeAsFileTime func = NULL;
+
+#ifndef FEATURE_PAL
+ HMODULE hKernel32 = WszLoadLibrary(W("kernel32.dll"));
+ if (hKernel32 != NULL)
+ {
+ func = (pfnGetSystemTimeAsFileTime)GetProcAddress(hKernel32, "GetSystemTimePreciseAsFileTime");
+ }
+ if (func == NULL)
+#endif
+ {
+ func = &::GetSystemTimeAsFileTime;
+ }
+
+ g_pfnGetSystemTimeAsFileTime = func;
+ func(lpSystemTimeAsFileTime);
+}
+
+pfnGetSystemTimeAsFileTime g_pfnGetSystemTimeAsFileTime = &InitializeGetSystemTimeAsFileTime;
FCIMPL0(INT64, SystemNative::__GetSystemTimeAsFileTime)
{
FCALL_CONTRACT;
INT64 timestamp;
-
- ::GetSystemTimeAsFileTime((FILETIME*)&timestamp);
+ g_pfnGetSystemTimeAsFileTime((FILETIME*)&timestamp);
#if BIGENDIAN
timestamp = (INT64)(((UINT64)timestamp >> 32) | ((UINT64)timestamp << 32));
@@ -83,20 +103,6 @@ FCIMPLEND;
-#ifndef FEATURE_CORECLR
-INT64 QCALLTYPE SystemNative::GetWorkingSet()
-{
- QCALL_CONTRACT;
-
- DWORD memUsage = 0;
-
- BEGIN_QCALL;
- memUsage = WszGetWorkingSet();
- END_QCALL;
-
- return memUsage;
-}
-#endif // !FEATURE_CORECLR
VOID QCALLTYPE SystemNative::Exit(INT32 exitcode)
{
@@ -312,24 +318,7 @@ FCIMPLEND
FCIMPL0(StringObject*, SystemNative::GetDeveloperPath)
{
-#ifdef FEATURE_FUSION
- FCALL_CONTRACT;
-
- STRINGREF refDevPath = NULL;
- LPWSTR pPath = NULL;
- DWORD lgth = 0;
-
- HELPER_METHOD_FRAME_BEGIN_RET_1(refDevPath);
-
- SystemDomain::System()->GetDevpathW(&pPath, &lgth);
- if(lgth)
- refDevPath = StringObject::NewString(pPath, lgth);
-
- HELPER_METHOD_FRAME_END();
- return (StringObject*)OBJECTREFToObject(refDevPath);
-#else
return NULL;
-#endif
}
FCIMPLEND
@@ -377,24 +366,6 @@ FCIMPL0(StringObject*, SystemNative::GetHostBindingFile);
}
FCIMPLEND
-#ifndef FEATURE_CORECLR
-
-void QCALLTYPE SystemNative::_GetSystemVersion(QCall::StringHandleOnStack retVer)
-{
- QCALL_CONTRACT;
- BEGIN_QCALL;
-
- WCHAR wszVersion[_MAX_PATH];
- DWORD dwVersion = _MAX_PATH;
-
- // Get the version
- IfFailThrow(g_pCLRRuntime->GetVersionString(wszVersion, &dwVersion));
- retVer.Set(wszVersion);
-
- END_QCALL;
-}
-
-#endif
INT32 QCALLTYPE SystemNative::GetProcessorCount()
{
@@ -439,16 +410,7 @@ LPVOID QCALLTYPE SystemNative::GetRuntimeInterfaceImpl(
BEGIN_QCALL;
-#ifdef FEATURE_CORECLR
IfFailThrow(E_NOINTERFACE);
-#else
- HRESULT hr = g_pCLRRuntime->GetInterface(clsid, riid, &pUnk);
-
- if (FAILED(hr))
- hr = g_pCLRRuntime->QueryInterface(riid, &pUnk);
-
- IfFailThrow(hr);
-#endif
END_QCALL;
@@ -560,11 +522,9 @@ void SystemNative::GenericFailFast(STRINGREF refMesgString, EXCEPTIONREF refExce
#ifndef FEATURE_PAL
// If we have the exception object, then try to setup
// the watson bucket if it has any details.
-#ifdef FEATURE_CORECLR
// On CoreCLR, Watson may not be enabled. Thus, we should
// skip this, if required.
if (IsWatsonEnabled())
-#endif // FEATURE_CORECLR
{
BEGIN_SO_INTOLERANT_CODE(pThread);
if ((gc.refExceptionForWatsonBucketing == NULL) || !SetupWatsonBucketsForFailFast(gc.refExceptionForWatsonBucketing))
@@ -649,36 +609,6 @@ FCIMPL2(VOID, SystemNative::FailFastWithException, StringObject* refMessageUNSAF
}
FCIMPLEND
-
-#ifndef FEATURE_CORECLR
-BOOL QCALLTYPE SystemNative::IsCLRHosted()
-{
- QCALL_CONTRACT;
-
- BOOL retVal = false;
- BEGIN_QCALL;
- retVal = (CLRHosted() & CLRHOSTED) != 0;
- END_QCALL;
-
- return retVal;
-}
-
-void QCALLTYPE SystemNative::TriggerCodeContractFailure(ContractFailureKind failureKind, LPCWSTR pMessage, LPCWSTR pCondition, LPCWSTR exceptionAsString)
-{
- QCALL_CONTRACT;
-
- BEGIN_QCALL;
-
- GCX_COOP();
-
- EEPolicy::HandleCodeContractFailure(pMessage, pCondition, exceptionAsString);
- // Note: if the host chose to throw an exception, we've returned from this method and
- // will throw that exception in managed code, because it's easier to pass the right parameters there.
-
- END_QCALL;
-}
-#endif // !FEATURE_CORECLR
-
FCIMPL0(FC_BOOL_RET, SystemNative::IsServerGC)
{
FCALL_CONTRACT;
@@ -704,195 +634,9 @@ BOOL QCALLTYPE SystemNative::WinRTSupported()
#endif // FEATURE_COMINTEROP
-// Helper method to retrieve OS Version based on the environment.
-BOOL GetOSVersionForEnvironment(LPOSVERSIONINFO lpVersionInformation)
-{
-#ifdef FEATURE_WINDOWSPHONE
- // Return phone version information if it is available
- if (!g_fGetPhoneVersionInitialized)
- {
- HMODULE hPhoneInfo = WszLoadLibrary(W("phoneinfo.dll"));
- if(hPhoneInfo != NULL)
- g_pfnGetPhoneVersion = (pfnGetPhoneVersion)GetProcAddress(hPhoneInfo, "GetPhoneVersion");
-
- g_fGetPhoneVersionInitialized = true;
- }
-
- if (g_pfnGetPhoneVersion!= NULL)
- return g_pfnGetPhoneVersion(lpVersionInformation);
-#endif // FEATURE_WINDOWSPHONE
-
- return ::GetOSVersion(lpVersionInformation);
-}
-
-
-/*
- * SystemNative::GetOSVersion - Fcall corresponding to System.Environment.GetVersion
- * It calls clr!GetOSVersion to get the real OS version even when running in
- * app compat. Calling kernel32!GetVersionEx() directly will be shimmed and will return the
- * fake OS version. In order to avoid this the call to getVersionEx is made via mscoree.dll.
- * Mscoree.dll resides in system32 dir and is never lied about OS version.
- */
-
-FCIMPL1(FC_BOOL_RET, SystemNative::GetOSVersion, OSVERSIONINFOObject *osVer)
-{
- FCALL_CONTRACT;
-
- OSVERSIONINFO ver;
- ver.dwOSVersionInfoSize = osVer->dwOSVersionInfoSize;
-
- BOOL ret = GetOSVersionForEnvironment(&ver);
-
- if(ret)
- {
- osVer->dwMajorVersion = ver.dwMajorVersion;
- osVer->dwMinorVersion = ver.dwMinorVersion;
- osVer->dwBuildNumber = ver.dwBuildNumber;
- osVer->dwPlatformId = ver.dwPlatformId;
-
- HELPER_METHOD_FRAME_BEGIN_RET_1(osVer);
- SetObjectReference((OBJECTREF*)&(osVer->szCSDVersion), StringObject::NewString(ver.szCSDVersion), GetAppDomain());
- HELPER_METHOD_FRAME_END();
- }
-
- FC_RETURN_BOOL(ret);
-}
-FCIMPLEND
-
-/*
- * SystemNative::GetOSVersionEx - Fcall implementation for System.Environment.GetVersionEx
- * Similar as above except this takes OSVERSIONINFOEX structure as input
- */
-
-FCIMPL1(FC_BOOL_RET, SystemNative::GetOSVersionEx, OSVERSIONINFOEXObject *osVer)
-{
- FCALL_CONTRACT;
-
- OSVERSIONINFOEX ver;
- ver.dwOSVersionInfoSize = osVer->dwOSVersionInfoSize;
-
- BOOL ret = GetOSVersionForEnvironment((OSVERSIONINFO *)&ver);
-
- if(ret)
- {
- osVer->dwMajorVersion = ver.dwMajorVersion;
- osVer->dwMinorVersion = ver.dwMinorVersion;
- osVer->dwBuildNumber = ver.dwBuildNumber;
- osVer->dwPlatformId = ver.dwPlatformId;
- osVer->wServicePackMajor = ver.wServicePackMajor;
- osVer->wServicePackMinor = ver.wServicePackMinor;
- osVer->wSuiteMask = ver.wSuiteMask;
- osVer->wProductType = ver.wProductType;
- osVer->wReserved = ver.wReserved;
-
- HELPER_METHOD_FRAME_BEGIN_RET_1(osVer);
- SetObjectReference((OBJECTREF*)&(osVer->szCSDVersion), StringObject::NewString(ver.szCSDVersion), GetAppDomain());
- HELPER_METHOD_FRAME_END();
- }
-
- FC_RETURN_BOOL(ret);
-}
-FCIMPLEND
-
-
-#ifndef FEATURE_CORECLR
-//
-// SystemNative::LegacyFormatMode - Fcall implementation for System.TimeSpan.LegacyFormatMode
-// checks for the DWORD "TimeSpan_LegacyFormatMode" CLR config option
-//
-FCIMPL0(FC_BOOL_RET, SystemNative::LegacyFormatMode)
-{
- FCALL_CONTRACT;
-
- DWORD flag = 0;
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), FCThrow(kStackOverflowException));
- flag = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_TimeSpan_LegacyFormatMode);
- END_SO_INTOLERANT_CODE;
- if (flag)
- FC_RETURN_BOOL(TRUE);
- else
- FC_RETURN_BOOL(FALSE);
-}
-FCIMPLEND
-#endif // !FEATURE_CORECLR
-#ifndef FEATURE_CORECLR
-//
-// SystemNative::CheckLegacyManagedDeflateStream - Fcall implementation for System.IO.Compression.DeflateStream
-// checks for the DWORD "NetFx45_LegacyManagedDeflateStream" CLR config option
-//
-// Move this into a separate CLRConfigQCallWrapper class once CLRConfig has been refactored!
-//
-FCIMPL0(FC_BOOL_RET, SystemNative::CheckLegacyManagedDeflateStream)
-{
- FCALL_CONTRACT;
-
- DWORD flag = 0;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), FCThrow(kStackOverflowException));
- flag = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_NetFx45_LegacyManagedDeflateStream);
- END_SO_INTOLERANT_CODE;
-
- if (flag)
- FC_RETURN_BOOL(TRUE);
- else
- FC_RETURN_BOOL(FALSE);
-}
-FCIMPLEND
-#endif // !FEATURE_CORECLR
-
-#ifndef FEATURE_CORECLR
-//
-// SystemNative::CheckThrowUnobservedTaskExceptions - Fcall implementation for System.Threading.Tasks.TaskExceptionHolder
-// checks for the DWORD "ThrowUnobservedTaskExceptions" CLR config option
-//
-FCIMPL0(FC_BOOL_RET, SystemNative::CheckThrowUnobservedTaskExceptions)
-{
- FCALL_CONTRACT;
-
- DWORD flag = 0;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), FCThrow(kStackOverflowException));
- flag = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_ThrowUnobservedTaskExceptions);
- END_SO_INTOLERANT_CODE;
-
- if (flag)
- FC_RETURN_BOOL(TRUE);
- else
- FC_RETURN_BOOL(FALSE);
-}
-FCIMPLEND
-
-BOOL QCALLTYPE SystemNative::LegacyDateTimeParseMode()
-{
- QCALL_CONTRACT;
-
- BOOL retVal = false;
- BEGIN_QCALL;
- retVal = (BOOL) CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_DateTime_NetFX35ParseMode);
- END_QCALL;
-
- return retVal;
-}
-
-//
-// This method used with DateTimeParse to fix the parsing of AM/PM like "1/10 5 AM" case
-//
-BOOL QCALLTYPE SystemNative::EnableAmPmParseAdjustment()
-{
- QCALL_CONTRACT;
-
- BOOL retVal = false;
- BEGIN_QCALL;
- retVal = (BOOL) CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_DateTime_NetFX40AmPmParseAdjustment);
- END_QCALL;
-
- return retVal;
-}
-
-#endif // !FEATURE_CORECLR
diff --git a/src/classlibnative/bcltype/system.h b/src/classlibnative/bcltype/system.h
index 9edc595039..986c55b31e 100644
--- a/src/classlibnative/bcltype/system.h
+++ b/src/classlibnative/bcltype/system.h
@@ -74,13 +74,6 @@ public:
static FCDECL0(INT64, __GetSystemTimeAsFileTime);
static FCDECL0(UINT32, GetCurrentProcessorNumber);
static FCDECL0(UINT32, GetTickCount);
- static FCDECL1(FC_BOOL_RET, GetOSVersion, OSVERSIONINFOObject *osVer);
- static FCDECL1(FC_BOOL_RET, GetOSVersionEx, OSVERSIONINFOEXObject *osVer);
-
-#ifndef FEATURE_CORECLR
- static
- INT64 QCALLTYPE GetWorkingSet();
-#endif // !FEATURE_CORECLR
static
void QCALLTYPE Exit(INT32 exitcode);
@@ -96,10 +89,6 @@ public:
static FCDECL1(VOID, FailFast, StringObject* refMessageUNSAFE);
static FCDECL2(VOID, FailFastWithExitCode, StringObject* refMessageUNSAFE, UINT exitCode);
static FCDECL2(VOID, FailFastWithException, StringObject* refMessageUNSAFE, ExceptionObject* refExceptionUNSAFE);
-#ifndef FEATURE_CORECLR
- static void QCALLTYPE TriggerCodeContractFailure(ContractFailureKind failureKind, LPCWSTR pMessage, LPCWSTR pCondition, LPCWSTR exceptionAsText);
- static BOOL QCALLTYPE IsCLRHosted();
-#endif // !FEATURE_CORECLR
static FCDECL0(StringObject*, GetDeveloperPath);
static FCDECL1(Object*, _GetEnvironmentVariable, StringObject* strVar);
@@ -123,23 +112,10 @@ public:
// Return a method info for the method were the exception was thrown
static FCDECL1(ReflectMethodObject*, GetMethodFromStackTrace, ArrayBase* pStackTraceUNSAFE);
-#ifndef FEATURE_CORECLR
- // Functions on the System.TimeSpan class
- static FCDECL0(FC_BOOL_RET, LegacyFormatMode);
- // Function on the DateTime
- static BOOL QCALLTYPE EnableAmPmParseAdjustment();
- static BOOL QCALLTYPE LegacyDateTimeParseMode();
-#endif // !FEATURE_CORECLR
// Move this into a separate CLRConfigQCallWrapper class once CLRConfif has been refactored:
-#ifndef FEATURE_CORECLR
- static FCDECL0(FC_BOOL_RET, CheckLegacyManagedDeflateStream);
-#endif // !FEATURE_CORECLR
-#ifndef FEATURE_CORECLR
- static FCDECL0(FC_BOOL_RET, CheckThrowUnobservedTaskExceptions);
-#endif // !FEATURE_CORECLR
private:
// Common processing code for FailFast
diff --git a/src/classlibnative/float/floatdouble.cpp b/src/classlibnative/float/floatdouble.cpp
index d9603c0636..6f593e503c 100644
--- a/src/classlibnative/float/floatdouble.cpp
+++ b/src/classlibnative/float/floatdouble.cpp
@@ -9,8 +9,6 @@
#include "floatdouble.h"
-#define IS_DBL_INFINITY(x) (((*((INT64*)((void*)&x))) & I64(0x7FFFFFFFFFFFFFFF)) == I64(0x7FF0000000000000))
-
// The default compilation mode is /fp:precise, which disables floating-point intrinsics. This
// default compilation mode has previously caused performance regressions in floating-point code.
// We enable /fp:fast semantics for the majority of the math functions, as it will speed up performance
@@ -86,13 +84,6 @@ FCIMPLEND
FCIMPL2_VV(double, COMDouble::Atan2, double y, double x)
FCALL_CONTRACT;
- // atan2(+/-INFINITY, +/-INFINITY) produces +/-0.78539816339744828 (x is +INFINITY) and
- // +/-2.3561944901923448 (x is -INFINITY) instead of the expected value of NaN. We handle
- // that case here ourselves.
- if (IS_DBL_INFINITY(y) && IS_DBL_INFINITY(x)) {
- return (double)(y / x);
- }
-
return (double)atan2(y, x);
FCIMPLEND
@@ -174,24 +165,6 @@ FCIMPLEND
FCIMPL2_VV(double, COMDouble::Pow, double x, double y)
FCALL_CONTRACT;
- // The CRT version of pow preserves the NaN payload of x over the NaN payload of y.
-
- if(_isnan(y)) {
- return y; // IEEE 754-2008: NaN payload must be preserved
- }
-
- if(_isnan(x)) {
- return x; // IEEE 754-2008: NaN payload must be preserved
- }
-
- // The CRT version of pow does not return NaN for pow(-1.0, +/-INFINITY) and
- // instead returns +1.0.
-
- if(IS_DBL_INFINITY(y) && (x == -1.0)) {
- INT64 result = CLR_NAN_64;
- return (*((double*)((INT64*)&result)));
- }
-
return (double)pow(x, y);
FCIMPLEND
diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp
index 7e2ea0adc6..c7b7d4126b 100644
--- a/src/classlibnative/float/floatsingle.cpp
+++ b/src/classlibnative/float/floatsingle.cpp
@@ -9,18 +9,12 @@
#include "floatsingle.h"
-#define IS_FLT_INFINITY(x) (((*((INT32*)((void*)&x))) & 0x7FFFFFFF) == 0x7F800000)
-
// Windows x86 and Windows ARM/ARM64 may not define _isnanf() or _copysignf() but they do
// define _isnan() and _copysign(). We will redirect the macros to these other functions if
// the macro is not defined for the platform. This has the side effect of a possible implicit
// upcasting for arguments passed in and an explicit downcasting for the _copysign() call.
#if (defined(_TARGET_X86_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)) && !defined(FEATURE_PAL)
-#if !defined(_isnanf)
-#define _isnanf _isnan
-#endif
-
#if !defined(_copysignf)
#define _copysignf (float)_copysign
#endif
@@ -49,7 +43,7 @@
/*=====================================Abs=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Abs, float x)
+FCIMPL1_V(float, COMSingle::Abs, float x)
FCALL_CONTRACT;
return (float)fabsf(x);
@@ -58,7 +52,7 @@ FCIMPLEND
/*=====================================Acos=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Acos, float x)
+FCIMPL1_V(float, COMSingle::Acos, float x)
FCALL_CONTRACT;
return (float)acosf(x);
@@ -67,7 +61,7 @@ FCIMPLEND
/*=====================================Asin=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Asin, float x)
+FCIMPL1_V(float, COMSingle::Asin, float x)
FCALL_CONTRACT;
return (float)asinf(x);
@@ -76,7 +70,7 @@ FCIMPLEND
/*=====================================Atan=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Atan, float x)
+FCIMPL1_V(float, COMSingle::Atan, float x)
FCALL_CONTRACT;
return (float)atanf(x);
@@ -85,23 +79,16 @@ FCIMPLEND
/*=====================================Atan2====================================
**
==============================================================================*/
-FCIMPL2(float, COMSingle::Atan2, float y, float x)
+FCIMPL2_VV(float, COMSingle::Atan2, float y, float x)
FCALL_CONTRACT;
- // atan2f(+/-INFINITY, +/-INFINITY) produces +/-0.785398163f (x is +INFINITY) and
- // +/-2.35619449f (x is -INFINITY) instead of the expected value of NaN. We handle
- // that case here ourselves.
- if (IS_FLT_INFINITY(y) && IS_FLT_INFINITY(x)) {
- return (float)(y / x);
- }
-
return (float)atan2f(y, x);
FCIMPLEND
/*====================================Ceil======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Ceil, float x)
+FCIMPL1_V(float, COMSingle::Ceil, float x)
FCALL_CONTRACT;
return (float)ceilf(x);
@@ -110,7 +97,7 @@ FCIMPLEND
/*=====================================Cos======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Cos, float x)
+FCIMPL1_V(float, COMSingle::Cos, float x)
FCALL_CONTRACT;
return (float)cosf(x);
@@ -119,7 +106,7 @@ FCIMPLEND
/*=====================================Cosh=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Cosh, float x)
+FCIMPL1_V(float, COMSingle::Cosh, float x)
FCALL_CONTRACT;
return (float)coshf(x);
@@ -128,7 +115,7 @@ FCIMPLEND
/*=====================================Exp======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Exp, float x)
+FCIMPL1_V(float, COMSingle::Exp, float x)
FCALL_CONTRACT;
return (float)expf(x);
@@ -137,7 +124,7 @@ FCIMPLEND
/*====================================Floor=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Floor, float x)
+FCIMPL1_V(float, COMSingle::Floor, float x)
FCALL_CONTRACT;
return (float)floorf(x);
@@ -146,7 +133,7 @@ FCIMPLEND
/*=====================================Log======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Log, float x)
+FCIMPL1_V(float, COMSingle::Log, float x)
FCALL_CONTRACT;
return (float)logf(x);
@@ -155,7 +142,7 @@ FCIMPLEND
/*====================================Log10=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Log10, float x)
+FCIMPL1_V(float, COMSingle::Log10, float x)
FCALL_CONTRACT;
return (float)log10f(x);
@@ -173,34 +160,16 @@ FCIMPLEND
/*=====================================Pow======================================
**
==============================================================================*/
-FCIMPL2(float, COMSingle::Pow, float x, float y)
+FCIMPL2_VV(float, COMSingle::Pow, float x, float y)
FCALL_CONTRACT;
- // The CRT version of pow preserves the NaN payload of x over the NaN payload of y.
-
- if(_isnanf(y)) {
- return y; // IEEE 754-2008: NaN payload must be preserved
- }
-
- if(_isnanf(x)) {
- return x; // IEEE 754-2008: NaN payload must be preserved
- }
-
- // The CRT version of powf does not return NaN for powf(-1.0f, +/-INFINITY) and
- // instead returns +1.0f.
-
- if(IS_FLT_INFINITY(y) && (x == -1.0f)) {
- INT32 result = CLR_NAN_32;
- return (*((float*)((INT32*)&result)));
- }
-
return (float)powf(x, y);
FCIMPLEND
/*====================================Round=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Round, float x)
+FCIMPL1_V(float, COMSingle::Round, float x)
FCALL_CONTRACT;
// If the number has no fractional part do nothing
@@ -225,7 +194,7 @@ FCIMPLEND
/*=====================================Sin======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Sin, float x)
+FCIMPL1_V(float, COMSingle::Sin, float x)
FCALL_CONTRACT;
return (float)sinf(x);
@@ -234,7 +203,7 @@ FCIMPLEND
/*=====================================Sinh=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Sinh, float x)
+FCIMPL1_V(float, COMSingle::Sinh, float x)
FCALL_CONTRACT;
return (float)sinhf(x);
@@ -243,7 +212,7 @@ FCIMPLEND
/*=====================================Sqrt=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Sqrt, float x)
+FCIMPL1_V(float, COMSingle::Sqrt, float x)
FCALL_CONTRACT;
return (float)sqrtf(x);
@@ -252,7 +221,7 @@ FCIMPLEND
/*=====================================Tan======================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Tan, float x)
+FCIMPL1_V(float, COMSingle::Tan, float x)
FCALL_CONTRACT;
return (float)tanf(x);
@@ -261,7 +230,7 @@ FCIMPLEND
/*=====================================Tanh=====================================
**
==============================================================================*/
-FCIMPL1(float, COMSingle::Tanh, float x)
+FCIMPL1_V(float, COMSingle::Tanh, float x)
FCALL_CONTRACT;
return (float)tanhf(x);
diff --git a/src/classlibnative/inc/calendardata.h b/src/classlibnative/inc/calendardata.h
deleted file mode 100644
index f30660ee99..0000000000
--- a/src/classlibnative/inc/calendardata.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-////////////////////////////////////////////////////////////////////////////
-//
-// Class: CalendarData
-//
-
-//
-// Purpose: This module implements the methods of the CalendarData
-// class. These methods are the helper functions for the
-// Locale class.
-//
-// Date: July 4, 2007
-//
-////////////////////////////////////////////////////////////////////////////
-
-#ifndef _CALENDARDATA_H
-#define _CALENDARDATA_H
-
-//
-// Data store for the calendar data.
-//
-class CalendarData : Object
-{
-
- //
- // WARNING: These properties should stay in-sync with CalendarData.cs
- //
-private:
- // Identity
- STRINGREF sNativeName ; // Calendar Name for the locale (fallback for calendar only records)
-
- // Formats
- PTRARRAYREF saShortDates ; // Short Data format, default first
- PTRARRAYREF saYearMonths ; // Year/Month Data format, default first
- PTRARRAYREF saLongDates ; // Long Data format, default first
- STRINGREF sMonthDay ; // Month/Day format
-
- // Calendar Parts Names
- PTRARRAYREF saEraNames ; // Names of Eras
- PTRARRAYREF saAbbrevEraNames ; // Abbreviated Era Names
- PTRARRAYREF saAbbrevEnglishEraNames ; // Abbreviated Era Names in English
- PTRARRAYREF saDayNames ; // Day Names, null to use locale data, starts on Sunday
- PTRARRAYREF saAbbrevDayNames ; // Abbrev Day Names, null to use locale data, starts on Sunday
- PTRARRAYREF saSuperShortDayNames ; // Super short Day of week names
- PTRARRAYREF saMonthNames ; // Month Names (13)
- PTRARRAYREF saAbbrevMonthNames ; // Abbrev Month Names (13)
- PTRARRAYREF saMonthGenitiveNames ; // Genitive Month Names (13)
- PTRARRAYREF saAbbrevMonthGenitiveNames; // Genitive Abbrev Month Names (13)
- PTRARRAYREF saLeapYearMonthNames ; // Multiple strings for the month names in a leap year.
-
- // Year, digits have to be at end to make marshaller happy?
- INT32 iTwoDigitYearMax ; // Max 2 digit year (for Y2K bug data entry)
- INT32 iCurrentEra ; // our current era #
-
- // Use overrides?
- CLR_BOOL bUseUserOverrides ; // True if we want user overrides.
-
- //
- // Helpers
- //
- static BOOL CallGetCalendarInfoEx(LPCWSTR localeName, int calendar, int calType, STRINGREF* pOutputStrRef);
- static BOOL CallGetCalendarInfoEx(LPCWSTR localeName, int calendar, int calType, INT32* pOutputInt32);
- static BOOL GetCalendarDayInfo(LPCWSTR localeName, int calendar, int calType, PTRARRAYREF* pOutputStrings);
- static BOOL GetCalendarMonthInfo(LPCWSTR localeName, int calendar, int calType, PTRARRAYREF* pOutputStrings);
-// TODO: NLS Arrowhead -Windows 7 If the OS had data this could use it, but Windows doesn't expose data for eras in enough detail
-// static BOOL GetCalendarEraInfo(LPCWSTR localeName, int calendar, PTRARRAYREF* pOutputEras);
- static BOOL CallEnumCalendarInfo(__in_z LPCWSTR localeName, __in int calendar, __in int calType,
- __in int lcType, __inout PTRARRAYREF* pOutputStrings);
-
- static void CheckSpecialCalendar(INT32* pCalendarInt, StackSString* pLocaleNameStackBuffer);
-public:
- //
- // ecall function for methods in CalendarData
- //
- static FCDECL1(INT32, nativeGetTwoDigitYearMax, INT32 nValue);
- static FCDECL3(FC_BOOL_RET, nativeGetCalendarData, CalendarData* calendarDataUNSAFE, StringObject* pLocaleNameUNSAFE, INT32 calendar);
- static FCDECL3(INT32, nativeGetCalendars, StringObject* pLocaleNameUNSAFE, CLR_BOOL bUseOverrides, I4Array* calendars);
- static FCDECL3(Object*, nativeEnumTimeFormats, StringObject* pLocaleNameUNSAFE, INT32 dwFlags, CLR_BOOL useUserOverride);
-};
-
-typedef CalendarData* CALENDARDATAREF;
-
-#ifndef LOCALE_RETURN_GENITIVE_NAMES
-#define LOCALE_RETURN_GENITIVE_NAMES 0x10000000 //Flag to return the Genitive forms of month names
-#endif
-
-#ifndef CAL_RETURN_GENITIVE_NAMES
-#define CAL_RETURN_GENITIVE_NAMES LOCALE_RETURN_GENITIVE_NAMES // return genitive forms of month names
-#endif
-
-#ifndef CAL_SERASTRING
-#define CAL_SERASTRING 0x00000004 // era name for IYearOffsetRanges, eg A.D.
-#endif
-
-#ifndef CAL_SMONTHDAY
-#define CAL_SMONTHDAY 0x00000038 // Month/day pattern (reserve for potential inclusion in a future version)
-#define CAL_SABBREVERASTRING 0x00000039 // Abbreviated era string (eg: AD)
-#endif
-
-#define RESERVED_CAL_JULIAN 13 // Julian calendar (data looks like GREGORIAN_US)
-#define RESERVED_CAL_JAPANESELUNISOLAR 14 // Japaenese Lunisolar calendar (data looks like CAL_JAPANESE)
-#define RESERVED_CAL_CHINESELUNISOLAR 15 // Algorithmic
-#define RESERVED_CAL_SAKA 16 // reserved to match Office but not implemented in our code
-#define RESERVED_CAL_LUNAR_ETO_CHN 17 // reserved to match Office but not implemented in our code
-#define RESERVED_CAL_LUNAR_ETO_KOR 18 // reserved to match Office but not implemented in our code
-#define RESERVED_CAL_LUNAR_ETO_ROKUYOU 19 // reserved to match Office but not implemented in our code
-#define RESERVED_CAL_KOREANLUNISOLAR 20 // Algorithmic
-#define RESERVED_CAL_TAIWANLUNISOLAR 21 // Algorithmic
-#define RESERVED_CAL_PERSIAN 22 // Algorithmic
-
-// These are vista properties
-#ifndef CAL_UMALQURA
-#define CAL_UMALQURA 23
-#endif
-
-#ifndef CAL_SSHORTESTDAYNAME1
-#define CAL_SSHORTESTDAYNAME1 0x00000031
-#define CAL_SSHORTESTDAYNAME2 0x00000032
-#define CAL_SSHORTESTDAYNAME3 0x00000033
-#define CAL_SSHORTESTDAYNAME4 0x00000034
-#define CAL_SSHORTESTDAYNAME5 0x00000035
-#define CAL_SSHORTESTDAYNAME6 0x00000036
-#define CAL_SSHORTESTDAYNAME7 0x00000037
-#endif
-
-#ifndef CAL_ITWODIGITYEARMAX
- #define CAL_ITWODIGITYEARMAX 0x00000030 // two digit year max
-#endif // CAL_ITWODIGITYEARMAX
-#ifndef CAL_RETURN_NUMBER
- #define CAL_RETURN_NUMBER 0x20000000 // return number instead of string
-#endif // CAL_RETURN_NUMBER
-
-#ifndef LOCALE_SNAME
-#define LOCALE_SNAME 0x0000005c // locale name (ie: en-us)
-#define LOCALE_SDURATION 0x0000005d // time duration format
-#define LOCALE_SKEYBOARDSTOINSTALL 0x0000005e
-#define LOCALE_SSHORTESTDAYNAME1 0x00000060 // Shortest day name for Monday
-#define LOCALE_SSHORTESTDAYNAME2 0x00000061 // Shortest day name for Tuesday
-#define LOCALE_SSHORTESTDAYNAME3 0x00000062 // Shortest day name for Wednesday
-#define LOCALE_SSHORTESTDAYNAME4 0x00000063 // Shortest day name for Thursday
-#define LOCALE_SSHORTESTDAYNAME5 0x00000064 // Shortest day name for Friday
-#define LOCALE_SSHORTESTDAYNAME6 0x00000065 // Shortest day name for Saturday
-#define LOCALE_SSHORTESTDAYNAME7 0x00000066 // Shortest day name for Sunday
-#define LOCALE_SISO639LANGNAME2 0x00000067 // 3 character ISO abbreviated language name
-#define LOCALE_SISO3166CTRYNAME2 0x00000068 // 3 character ISO country name
-#define LOCALE_SNAN 0x00000069 // Not a Number
-#define LOCALE_SPOSINFINITY 0x0000006a // + Infinity
-#define LOCALE_SNEGINFINITY 0x0000006b // - Infinity
-#define LOCALE_SSCRIPTS 0x0000006c // Typical scripts in the locale
-#define LOCALE_SPARENT 0x0000006d // Fallback name for resources
-#define LOCALE_SCONSOLEFALLBACKNAME 0x0000006e // Fallback name for within the console
-#define LOCALE_SLANGDISPLAYNAME 0x0000006f // Lanugage Display Name for a language
-#endif // LOCALE_SNAME
-#ifndef LOCALE_SSHORTTIME
-#define LOCALE_SSHORTTIME 0x00000079 // short time format (ie: no seconds, just h:mm)
-#endif // LOCALE_SSHORTTIME
-
-#ifndef TIME_NOSECONDS
-#define TIME_NOSECONDS 0x00000002 // do not use seconds
-#endif
-
-#endif
-
diff --git a/src/classlibnative/inc/floatsingle.h b/src/classlibnative/inc/floatsingle.h
index f8a1dda0fd..8296e2d37a 100644
--- a/src/classlibnative/inc/floatsingle.h
+++ b/src/classlibnative/inc/floatsingle.h
@@ -10,26 +10,26 @@
class COMSingle {
public:
- FCDECL1(static float, Abs, float x);
- FCDECL1(static float, Acos, float x);
- FCDECL1(static float, Asin, float x);
- FCDECL1(static float, Atan, float x);
- FCDECL2(static float, Atan2, float y, float x);
- FCDECL1(static float, Ceil, float x);
- FCDECL1(static float, Cos, float x);
- FCDECL1(static float, Cosh, float x);
- FCDECL1(static float, Exp, float x);
- FCDECL1(static float, Floor, float x);
- FCDECL1(static float, Log, float x);
- FCDECL1(static float, Log10, float x);
+ FCDECL1_V(static float, Abs, float x);
+ FCDECL1_V(static float, Acos, float x);
+ FCDECL1_V(static float, Asin, float x);
+ FCDECL1_V(static float, Atan, float x);
+ FCDECL2_VV(static float, Atan2, float y, float x);
+ FCDECL1_V(static float, Ceil, float x);
+ FCDECL1_V(static float, Cos, float x);
+ FCDECL1_V(static float, Cosh, float x);
+ FCDECL1_V(static float, Exp, float x);
+ FCDECL1_V(static float, Floor, float x);
+ FCDECL1_V(static float, Log, float x);
+ FCDECL1_V(static float, Log10, float x);
FCDECL1(static float, ModF, float* iptr);
- FCDECL2(static float, Pow, float x, float y);
- FCDECL1(static float, Round, float x);
- FCDECL1(static float, Sin, float x);
- FCDECL1(static float, Sinh, float x);
- FCDECL1(static float, Sqrt, float x);
- FCDECL1(static float, Tan, float x);
- FCDECL1(static float, Tanh, float x);
+ FCDECL2_VV(static float, Pow, float x, float y);
+ FCDECL1_V(static float, Round, float x);
+ FCDECL1_V(static float, Sin, float x);
+ FCDECL1_V(static float, Sinh, float x);
+ FCDECL1_V(static float, Sqrt, float x);
+ FCDECL1_V(static float, Tan, float x);
+ FCDECL1_V(static float, Tanh, float x);
};
#endif // _FLOATSINGLE_H_
diff --git a/src/classlibnative/inc/nlsinfo.h b/src/classlibnative/inc/nlsinfo.h
index a5dc13f9a8..505827bc90 100644
--- a/src/classlibnative/inc/nlsinfo.h
+++ b/src/classlibnative/inc/nlsinfo.h
@@ -18,10 +18,6 @@
#ifndef _NLSINFO_H_
#define _NLSINFO_H_
-#define DEFAULT_SORT_VERSION 0
-#define SORT_VERSION_WHIDBEY 0x00001000
-#define SORT_VERSION_V4 0x00060101
-
//
//This structure must map 1-for-1 with the InternalDataItem structure in
//System.Globalization.EncodingTable.
@@ -43,80 +39,22 @@ struct CodePageDataItem {
const char * names;
};
-// Normalization
-typedef BOOL (*PFN_NORMALIZATION_IS_NORMALIZED_STRING)
- ( int NormForm, LPCWSTR lpInString, int cchInString);
-
-typedef int (*PFN_NORMALIZATION_NORMALIZE_STRING)
- ( int NormForm, LPCWSTR lpInString, int cchInString, LPWSTR lpOutString, int cchOutString);
-
-typedef BYTE* (*PFN_NORMALIZATION_INIT_NORMALIZATION)
- ( int NormForm, BYTE* pTableData);
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Forward declarations
-//
-////////////////////////////////////////////////////////////////////////////
-
-class CharTypeTable;
-class CasingTable;
-class SortingTable;
-class NativeTextInfo;
-class CultureDataBaseObject;
-
-class COMNlsInfo {
-
+class COMNlsInfo
+{
public:
-#ifdef FEATURE_SYNTHETIC_CULTURES
- static INT32 WstrToInteger4(__in_z LPCWSTR wstrLocale, __in int Radix);
-#endif // FEATURE_SYNTHETIC_CULTURES
- static INT32 GetCHTLanguage();
- static INT32 CallGetSystemDefaultUILanguage();
static INT32 CallGetUserDefaultUILanguage();
- static LANGID GetDownLevelSystemDefaultUILanguage();
-
- //
- // Native helper functions for methods in CultureInfo.
- //
- static BOOL QCALLTYPE InternalGetDefaultLocaleName(INT32 langType, QCall::StringHandleOnStack defaultLocaleName);
- static BOOL QCALLTYPE InternalGetUserDefaultUILanguage(QCall::StringHandleOnStack userDefaultUiLanguage);
- static BOOL QCALLTYPE InternalGetSystemDefaultUILanguage(QCall::StringHandleOnStack systemDefaultUiLanguage);
-
-// Added but disabled from desktop in .NET 4.0, stayed disabled in .NET 4.5
-#ifdef FEATURE_CORECLR
- static FCDECL0(Object*, nativeGetResourceFallbackArray);
-#endif
//
// Native helper functions for methods in DateTimeFormatInfo
//
static FCDECL1(FC_BOOL_RET, nativeSetThreadLocale, StringObject* localeNameUNSAFE);
- static FCDECL2(Object*, nativeGetLocaleInfoEx, StringObject* localeNameUNSAFE, INT32 lcType);
- static FCDECL2(INT32, nativeGetLocaleInfoExInt, StringObject* localeNameUNSAFE, INT32 lcType);
//
// Native helper functions for CultureData
//
- static FCDECL1(FC_BOOL_RET, nativeInitCultureData, CultureDataBaseObject *data);
- static FCDECL3(FC_BOOL_RET, nativeGetNumberFormatInfoValues, StringObject* localeNameUNSAFE, NumberFormatInfo* nfi, CLR_BOOL useUserOverride);
- static FCDECL1(Object*, LCIDToLocaleName, LCID lcid);
- static FCDECL1(INT32, LocaleNameToLCID, StringObject* localeNameUNSAFE);
- static INT32 QCALLTYPE InternalCompareString (INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName, LPCWSTR string1, INT32 offset1, INT32 length1, LPCWSTR string2, INT32 offset2, INT32 length2, INT32 flags);
- static INT32 QCALLTYPE InternalGetGlobalizedHashCode(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName, LPCWSTR pString, INT32 length, INT32 dwFlagsIn, BOOL bForceRandomizedHashing, INT64 additionalEntropy);
-
- static BOOL QCALLTYPE InternalIsSortable(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName, LPCWSTR pString, INT32 length);
- static INT_PTR QCALLTYPE InternalInitSortHandle(LPCWSTR localeName, INT_PTR* handleOrigin);
- static INT_PTR InitSortHandleHelper(LPCWSTR localeName, INT_PTR* handleOrigin);
- static INT_PTR InternalInitOsSortHandle(LPCWSTR localeName, INT_PTR* handleOrigin);
-#ifndef FEATURE_CORECLR
- static INT_PTR InternalInitVersionedSortHandle(LPCWSTR localeName, INT_PTR* handleOrigin);
- static INT_PTR InternalInitVersionedSortHandle(LPCWSTR localeName, INT_PTR* handleOrigin, DWORD sortVersion);
- static DWORD QCALLTYPE InternalGetSortVersion();
-#endif
- static BOOL QCALLTYPE InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR lpLocaleName, NLSVERSIONINFOEX * lpVersionInformation);
+ static INT32 QCALLTYPE InternalGetGlobalizedHashCode(INT_PTR handle, LPCWSTR localeName, LPCWSTR pString, INT32 length, INT32 dwFlagsIn, INT64 additionalEntropy);
//
// Native helper function for methods in EncodingTable
@@ -124,103 +62,6 @@ public:
static FCDECL0(INT32, nativeGetNumEncodingItems);
static FCDECL0(EncodingDataItem *, nativeGetEncodingTableDataPointer);
static FCDECL0(CodePageDataItem *, nativeGetCodePageTableDataPointer);
-#if FEATURE_CODEPAGES_FILE
- static FCDECL3(LPVOID, nativeCreateOpenFileMapping,
- StringObject* inSectionNameUNSAFE, int inBytesToAllocate, HANDLE *mappedFile);
-#endif // FEATURE_CODEPAGES_FILE
-
- //
- // Native helper function for methods in CharacterInfo
- //
- static FCDECL0(void, AllocateCharTypeTable);
-
- //
- // Native helper function for methods in TextInfo
- //
- static FCDECL5(FC_CHAR_RET, InternalChangeCaseChar, INT_PTR handle, INT_PTR handleOrigin, StringObject* localeNameUNSAFE, CLR_CHAR wch, CLR_BOOL bIsToUpper);
- static FCDECL5(Object*, InternalChangeCaseString, INT_PTR handle, INT_PTR handleOrigin, StringObject* localeNameUNSAFE, StringObject* pString, CLR_BOOL bIsToUpper);
- static FCDECL6(INT32, InternalGetCaseInsHash, INT_PTR handle, INT_PTR handleOrigin, StringObject* localeNameUNSAFE, LPVOID strA, CLR_BOOL bForceRandomizedHashing, INT64 additionalEntropy);
- static INT32 QCALLTYPE InternalCompareStringOrdinalIgnoreCase(LPCWSTR string1, INT32 index1, LPCWSTR string2, INT32 index2, INT32 length1, INT32 length2);
-
- static BOOL QCALLTYPE InternalTryFindStringOrdinalIgnoreCase(
- __in DWORD dwFindNLSStringFlags, // mutually exclusive flags: FIND_FROMSTART, FIND_STARTSWITH, FIND_FROMEND, FIND_ENDSWITH
- __in_ecount(cchSource) LPCWSTR lpStringSource, // the string we search in
- __in int cchSource, // number of characters lpStringSource after sourceIndex
- __in int sourceIndex, // index from where the search will start in lpStringSource
- __in_ecount(cchValue) LPCWSTR lpStringValue, // the string we search for
- __in int cchValue,
- __out int* foundIndex); // the index in lpStringSource where we found lpStringValue
-
- //
- // Native helper function for methods in Normalization
- //
- static FCDECL6(int, nativeNormalizationNormalizeString,
- int NormForm, int& iError,
- StringObject* inString, int inLength,
- CHARArray* outChars, int outLength);
- static FCDECL4(FC_BOOL_RET, nativeNormalizationIsNormalizedString,
- int NormForm, int& iError,
- StringObject* inString, int cwLength);
-
- static void QCALLTYPE nativeNormalizationInitNormalization(int NormForm, BYTE* pTableData);
-
- //
- // QCalls prototype
- //
-
- static int QCALLTYPE nativeEnumCultureNames(INT32 cultureTypes, QCall::ObjectHandleOnStack retStringArray);
-
- static int QCALLTYPE InternalFindNLSStringEx(
- __in_opt INT_PTR handle, // optional sort handle
- __in_opt INT_PTR handleOrigin, // optional pointer to the native function that created the sort handle
- __in_z LPCWSTR lpLocaleName, // locale name
- __in int dwFindNLSStringFlags, // search falg
- __in_ecount(cchSource) LPCWSTR lpStringSource, // the string we search in
- __in int cchSource, // number of characters lpStringSource after sourceIndex
- __in int sourceIndex, // index from where the search will start in lpStringSource
- __in_ecount(cchValue) LPCWSTR lpStringValue, // the string we search for
- __in int cchValue); // length of the string we search for
-
- static int QCALLTYPE InternalGetSortKey(
- __in_opt INT_PTR handle, // PSORTHANDLE
- __in_opt INT_PTR handleOrigin, // optional pointer to the native function that created the sort handle
- __in_z LPCWSTR pLocaleName, // locale name
- __in int flags, // flags
- __in_ecount(cchSource) LPCWSTR pStringSource, // Source string
- __in int cchSource, // number of characters in lpStringSource
- __in_ecount(cchTarget) PBYTE pTarget, // Target data buffer (may be null to count)
- __in int cchTarget); // Character count for target buffer
-
-
-private:
-
- //
- // Internal helper functions.
- //
- static LPVOID internalEnumSystemLocales(DWORD dwFlags);
- static INT32 CompareOrdinal(__in_ecount(Length1) WCHAR* strAChars, int Length1, __in_ecount(Length2) WCHAR* strBChars, int Length2 );
- static INT32 FastIndexOfString(__in WCHAR *sourceString, INT32 startIndex, INT32 endIndex, __in_ecount(patternLength) WCHAR *pattern, INT32 patternLength);
- static INT32 FastIndexOfStringInsensitive(__in WCHAR *sourceString, INT32 startIndex, INT32 endIndex, __in_ecount(patternLength) WCHAR *pattern, INT32 patternLength);
- static INT32 FastLastIndexOfString(__in WCHAR *sourceString, INT32 startIndex, INT32 endIndex, __in_ecount(patternLength) WCHAR *pattern, INT32 patternLength);
- static INT32 FastLastIndexOfStringInsensitive(__in WCHAR *sourceString, INT32 startIndex, INT32 endIndex, __in_ecount(patternLength) WCHAR *pattern, INT32 patternLength);
-
- static BOOL GetNativeDigitsFromWin32(LPCWSTR locale, PTRARRAYREF* pOutputStrAry, BOOL useUserOverride);
- static BOOL CallGetLocaleInfoEx(LPCWSTR locale, int lcType, STRINGREF* pOutputStrRef, BOOL useUserOverride);
- static BOOL CallGetLocaleInfoEx(LPCWSTR locale, int lcType, INT32* pOutputInt32, BOOL useUserOverride);
-
- static BOOL IsWindows7();
-
- //
- // Definitions.
- //
-
-#ifndef FEATURE_COREFX_GLOBALIZATION
- // Normalization
- static HMODULE m_hNormalization;
- static PFN_NORMALIZATION_IS_NORMALIZED_STRING m_pfnNormalizationIsNormalizedStringFunc;
- static PFN_NORMALIZATION_NORMALIZE_STRING m_pfnNormalizationNormalizeStringFunc;
- static PFN_NORMALIZATION_INIT_NORMALIZATION m_pfnNormalizationInitNormalizationFunc;
-#endif
private:
//
@@ -231,8 +72,6 @@ private:
const static int m_nCodePageTableItems;
const static CodePageDataItem CodePageDataTable[];
-
- static INT_PTR EnsureValidSortHandle(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName);
};
-#endif // _NLSINFO_H_
+#endif // _NLSINFO_H_ \ No newline at end of file
diff --git a/src/classlibnative/inc/nlstable.h b/src/classlibnative/inc/nlstable.h
deleted file mode 100644
index b5f5a4bca6..0000000000
--- a/src/classlibnative/inc/nlstable.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// ==++==
-//
-
-//
-
-//
-// TODO: NLS Arrowhead - when we have win7 unicode support this can "go away"
-// ==--==
-#ifndef _NLSTABLE_H
-#define _NLSTABLE_H
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Class: NLSTable
-//
-// Purpose: The base class for NLS+ table. This class provides the utility
-// functions to open and map a view of NLS+ data files.
-//
-// Date: August 31, 1999
-//
-////////////////////////////////////////////////////////////////////////////
-
-typedef LPWORD P844_TABLE; // ptr to 8:4:4 table
-
-//
-// Macros For High and Low Nibbles of a BYTE.
-//
-#define LO_NIBBLE(b) ((BYTE)((BYTE)(b) & 0xF))
-#define HI_NIBBLE(b) ((BYTE)(((BYTE)(b) >> 4) & 0xF))
-
-//
-// Macros for Extracting the 8:4:4 Index Values.
-//
-#define GET8(w) (HIBYTE(w))
-#define GETHI4(w) (HI_NIBBLE(LOBYTE(w)))
-#define GETLO4(w) (LO_NIBBLE(LOBYTE(w)))
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Traverse844Byte
-//
-// Traverses the 8:4:4 translation table for the given wide character. It
-// returns the final value of the 8:4:4 table, which is a BYTE in length.
-//
-// NOTE: Offsets in table are in BYTES.
-//
-// Broken Down Version:
-// --------------------
-// Incr = pTable[GET8(wch)] / sizeof(WORD);
-// Incr = pTable[Incr + GETHI4(wch)];
-// Value = (BYTE *)pTable[Incr + GETLO4(wch)];
-//
-//
-////////////////////////////////////////////////////////////////////////////
-
-inline BYTE& Traverse844Byte(const WORD * pTable, WCHAR wch)
-{
- return (
- ((BYTE *)pTable)[
- pTable[
- (pTable[GET8(wch)] / sizeof(WORD)) + GETHI4(wch)
- ] + GETLO4(wch)
- ]
- );
-}
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Traverse844Word
-//
-// Traverses the 8:4:4 translation table for the given wide character. It
-// returns the final value of the 8:4:4 table, which is a WORD in length.
-//
-// Broken Down Version:
-// --------------------
-// Incr = pTable[GET8(wch)];
-// Incr = pTable[Incr + GETHI4(wch)];
-// Value = pTable[Incr + GETLO4(wch)];
-//
-//
-////////////////////////////////////////////////////////////////////////////
-
-inline WORD Traverse844Word(const WORD * pTable, WCHAR wch)
-{
- return (pTable[pTable[pTable[GET8(wch)] + GETHI4(wch)] + GETLO4(wch)]);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//
-// GET_INCR_VALUE
-//
-// Gets the value of a given wide character from the given 8:4:4 table. It
-// then uses the value as an increment by adding it to the given wide
-// character code point.
-//
-// NOTE: Whenever there is no translation for the given code point, the
-// tables will return an increment value of 0. This way, the
-// wide character passed in is the same value that is returned.
-//
-// DEFINED AS A MACRO.
-//
-//
-////////////////////////////////////////////////////////////////////////////
-
-inline WCHAR GetIncrValue(const WORD * p844Tbl, WCHAR wch)
-{
- return ((WCHAR)(wch + Traverse844Word(p844Tbl, wch)));
-}
-
-class NLSTable
-{
- public:
- static HANDLE CreateSharedMemoryMapping(const LPCWSTR pMappingName, const int iSize );
- static PBYTE OpenOrCreateMemoryMapping(const LPCWSTR pMappingName, const int iSize , HANDLE *mappedFile);
-};
-
-#endif // _NLSTABLE_H
diff --git a/src/classlibnative/nls/CMakeLists.txt b/src/classlibnative/nls/CMakeLists.txt
index d109ec2eb0..d6451b96b7 100644
--- a/src/classlibnative/nls/CMakeLists.txt
+++ b/src/classlibnative/nls/CMakeLists.txt
@@ -1,8 +1,6 @@
set( COMMLS_WKS_SOURCES
- calendardata.cpp
encodingdata.cpp
nlsinfo.cpp
- nlstable.cpp
)
add_library_clr(comnls_wks ${COMMLS_WKS_SOURCES})
diff --git a/src/classlibnative/nls/calendardata.cpp b/src/classlibnative/nls/calendardata.cpp
deleted file mode 100644
index 95d071cc93..0000000000
--- a/src/classlibnative/nls/calendardata.cpp
+++ /dev/null
@@ -1,985 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-////////////////////////////////////////////////////////////////////////////
-//
-// Class: CalendarData
-//
-
-//
-// Purpose: This module implements the methods of the CalendarData
-// class. These methods are the helper functions for the
-// Locale class.
-//
-// Date: July 4, 2007
-//
-////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-#include "object.h"
-#include "excep.h"
-#include "vars.hpp"
-#include "interoputil.h"
-#include "corhost.h"
-
-#include <winnls.h>
-
-#include "calendardata.h"
-#include "nlsinfo.h"
-#include "newapis.h"
-
-////////////////////////////////////////////////////////////////////////
-//
-// Call the Win32 GetCalendarInfoEx() using the specified calendar and LCTYPE.
-// The return value can be INT32 or an allocated managed string object, depending on
-// which version's called.
-//
-// Parameters:
-// OUT pOutputInt32 The output int32 value.
-// OUT pOutputRef The output string value.
-//
-////////////////////////////////////////////////////////////////////////
-BOOL CalendarData::CallGetCalendarInfoEx(LPCWSTR localeName, int calendar, int calType, INT32* pOutputInt32)
-{
- CONTRACTL
- {
- GC_NOTRIGGER;
- MODE_ANY;
- SO_TOLERANT;
- } CONTRACTL_END;
-
- int result = 0;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), return result; )
-
- // Just stick it right into the output int
- _ASSERT((calType & CAL_RETURN_NUMBER) != 0);
- result = NewApis::GetCalendarInfoEx(localeName, calendar, NULL, calType, NULL, 0, (LPDWORD)pOutputInt32);
-
- END_SO_INTOLERANT_CODE
-
- return (result != 0);
-}
-
-BOOL CalendarData::CallGetCalendarInfoEx(LPCWSTR localeName, int calendar, int calType, STRINGREF* pOutputStrRef)
-{
- CONTRACTL
- {
- THROWS; // We can throw since we are allocating managed string.
- DISABLED(GC_TRIGGERS); // Disabled 'cause it don't work right now
- MODE_ANY;
- SO_TOLERANT;
- } CONTRACTL_END;
-
- // The maximum size for values returned from GetLocaleInfo is 80 characters.
- WCHAR buffer[80];
- int result = 0;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), return result; )
-
- _ASSERT((calType & CAL_RETURN_NUMBER) == 0);
- result = NewApis::GetCalendarInfoEx(localeName, calendar, NULL, calType, buffer, 80, NULL);
-
- if (result != 0)
- {
- _ASSERTE(pOutputStrRef != NULL);
- *pOutputStrRef = StringObject::NewString(buffer, result - 1);
- }
-
- END_SO_INTOLERANT_CODE
-
- return (result != 0);
-}
-
-////////////////////////////////////////////////////////////////////////
-//
-// Get the native day names
-//
-// NOTE: There's a disparity between .Net & windows day orders, the input day should
-// start with Sunday
-//
-// Parameters:
-// OUT pOutputStrings The output string[] value.
-//
-////////////////////////////////////////////////////////////////////////
-BOOL CalendarData::GetCalendarDayInfo(LPCWSTR localeName, int calendar, int calType, PTRARRAYREF* pOutputStrings)
-{
- CONTRACTL
- {
- THROWS; // We can throw since we are allocating managed string.
- INJECT_FAULT(COMPlusThrowOM());
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- SO_TOLERANT;
- } CONTRACTL_END;
-
- // The maximum size for values returned from GetLocaleInfo is 80 characters.
- WCHAR buffer[80];
- int result = 0;
-
- _ASSERT((calType & CAL_RETURN_NUMBER) == 0);
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), return result;)
-
- //
- // We'll need a new array of 7 items
- //
- // Allocate the array of STRINGREFs. We don't need to check for null because the GC will throw
- // an OutOfMemoryException if there's not enough memory.
- //
- PTRARRAYREF ResultArray = (PTRARRAYREF)AllocateObjectArray(7, g_pStringClass);
-
- GCPROTECT_BEGIN(ResultArray);
-
- // Get each one of them
- for (int i = 0; i < 7; i++, calType++)
- {
- result = NewApis::GetCalendarInfoEx(localeName, calendar, NULL, calType, buffer, 80, NULL);
-
- // Note that the returned string is null terminated, so even an empty string will be 1
- if (result != 0)
- {
- // Make a string for this entry
- STRINGREF stringResult = StringObject::NewString(buffer, result - 1);
- ResultArray->SetAt(i, (OBJECTREF)stringResult);
- }
-
- // On the first iteration we need to go from CAL_SDAYNAME7 to CAL_SDAYNAME1, so subtract 7 before the ++ happens
- // This is because the framework starts on sunday and windows starts on monday when counting days
- if (i == 0) calType -= 7;
- }
- GCPROTECT_END();
-
- _ASSERTE(pOutputStrings != NULL);
- *pOutputStrings = ResultArray;
-
- END_SO_INTOLERANT_CODE
-
- return (result != 0);
-}
-
-
-
-////////////////////////////////////////////////////////////////////////
-//
-// Get the native month names
-//
-// Parameters:
-// OUT pOutputStrings The output string[] value.
-//
-////////////////////////////////////////////////////////////////////////
-BOOL CalendarData::GetCalendarMonthInfo(LPCWSTR localeName, int calendar, int calType, PTRARRAYREF* pOutputStrings)
-{
- CONTRACTL
- {
- THROWS; // We can throw since we are allocating managed string.
- INJECT_FAULT(COMPlusThrowOM());
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- SO_TOLERANT;
- } CONTRACTL_END;
-
- // The maximum size for values returned from GetLocaleInfo is 80 characters.
- WCHAR buffer[80];
- int result = 0;
-
- _ASSERT((calType & CAL_RETURN_NUMBER) == 0);
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), return result;)
-
- //
- // We'll need a new array of 13 items
- //
- // Allocate the array of STRINGREFs. We don't need to check for null because the GC will throw
- // an OutOfMemoryException if there's not enough memory.
- //
- PTRARRAYREF ResultArray = (PTRARRAYREF)AllocateObjectArray(13, g_pStringClass);
-
- GCPROTECT_BEGIN(ResultArray);
-
- // Get each one of them
- for (int i = 0; i < 13; i++, calType++)
- {
- result = NewApis::GetCalendarInfoEx(localeName, calendar, NULL, calType, buffer, 80, NULL);
-
- // If we still have failure, then mark as empty string
- if (result == 0)
- {
- buffer[0] = W('0');
- result = 1;
-
-
- }
-
- // Note that the returned string is null terminated, so even an empty string will be 1
- // Make a string for this entry
- STRINGREF stringResult = StringObject::NewString(buffer, result - 1);
- ResultArray->SetAt(i, (OBJECTREF)stringResult);
- }
- GCPROTECT_END();
-
- _ASSERTE(pOutputStrings != NULL);
- *pOutputStrings = ResultArray;
-
- END_SO_INTOLERANT_CODE
-
- return (result != 0);
-}
-
-//
-// struct to help our calendar data enumaration callback
-//
-struct enumData
-{
- int count; // # of strings found so far
- LPWSTR userOverride; // pointer to user override string if used
- LPWSTR stringsBuffer; // pointer to a buffer to use for the strings.
- LPWSTR endOfBuffer; // pointer to the end of the stringsBuffer ( must be < this to write)
-};
-
-//
-// callback itself
-//
-BOOL CALLBACK EnumCalendarInfoCallback(__in_z LPWSTR lpCalendarInfoString, __in CALID Calendar, __in_opt LPWSTR pReserved, __in LPARAM lParam)
-{
- CONTRACTL
- {
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- SO_TOLERANT;
- PRECONDITION(CheckPointer(lpCalendarInfoString));
- PRECONDITION(CheckPointer((LPVOID)lParam));
- } CONTRACTL_END;
-
- // Cast our data to the right type
- enumData* pData = (enumData*)lParam;
-
- // If we had a user override, check to make sure this differs
- if (pData->userOverride == NULL ||
- wcscmp(pData->userOverride, lpCalendarInfoString) != 0)
- {
- // They're different, add it to our buffer
- LPWSTR pStart = pData->stringsBuffer;
- LPCWSTR pEnd = pData->endOfBuffer;
- while (pStart < pEnd && *lpCalendarInfoString != 0)
- {
- *(pStart++) = *(lpCalendarInfoString++);
- }
-
- // Add a \0
- if (pStart < pEnd)
- {
- *(pStart++) = 0;
-
- // Did it finish?
- if (pStart <= pEnd)
- {
- // It finished, use it
- pData->count++;
- pData->stringsBuffer = pStart;
- }
- }
- }
-
- return TRUE;
-}
-
-//
-// CallEnumCalendarInfo
-//
-// Get the list of whichever calendar property from the OS. If user override is passed in, then check GetLocaleInfo as well
-// to see if a user override is set.
-//
-// We build a list of strings, first calling getlocaleinfo if necessary, and then the enums. The strings are null terminated,
-// with a double null ending the list. Once we have the list we can allocate our COMStrings and arrays from the count.
-//
-// We need a helper structure to pass as an lParam
-//
-BOOL CalendarData::CallEnumCalendarInfo(__in_z LPCWSTR localeName, __in int calendar, __in int calType,
- __in int lcType, __inout PTRARRAYREF* pOutputStrings)
-{
- CONTRACTL
- {
- THROWS; // We can throw since we are allocating managed string.
- INJECT_FAULT(COMPlusThrowOM());
- DISABLED(GC_TRIGGERS); // Disabled 'cause it don't work right now
- MODE_COOPERATIVE;
- SO_TOLERANT;
- } CONTRACTL_END;
-
- BOOL result = TRUE;
-
- // Our longest string in culture.xml is shorter than this and it has lots of \x type characters, so this should be long enough by far.
- WCHAR stringBuffer[512];
-
- struct enumData data;
- data.count = 0;
- data.userOverride = NULL;
- data.stringsBuffer = stringBuffer;
- data.endOfBuffer = stringBuffer + 512; // We're adding WCHAR sizes
-
- // First call GetLocaleInfo if necessary
- if ((lcType && ((lcType & LOCALE_NOUSEROVERRIDE) == 0)) &&
- // Get user locale, see if it matches localeName.
- // Note that they should match exactly, including letter case
- NewApis::GetUserDefaultLocaleName(stringBuffer, 512) && wcscmp(localeName, stringBuffer) == 0)
- {
- // They want user overrides, see if the user calendar matches the input calendar
- CALID userCalendar = 0;
- NewApis::GetLocaleInfoEx(localeName, LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER, (LPWSTR)&userCalendar,
- sizeof(userCalendar) / sizeof(WCHAR) );
-
- // If the calendars were the same, see if the locales were the same
- if ((int)userCalendar == calendar) // todo: cast to compile on MAC
- {
- // They matched, get the user override since locale & calendar match
- int i = NewApis::GetLocaleInfoEx(localeName, lcType, stringBuffer, 512);
-
- // if it succeeded, advance the pointer and remember the override for the later callers
- if (i > 0)
- {
- // Remember this was the override (so we can look for duplicates later in the enum function)
- data.userOverride = data.stringsBuffer;
-
- // Advance to the next free spot (i includes counting the \0)
- data.stringsBuffer += i;
-
- // And our count...
- data.count++;
- }
- }
- }
-
- // Now call the enumeration API. Work is done by our callback function
- NewApis::EnumCalendarInfoExEx(EnumCalendarInfoCallback, localeName, calendar, calType, (LPARAM)&data);
-
- // Now we have a list of data, fail if we didn't find anything.
- if (data.count == 0) return FALSE;
-
- // Now we need to allocate our stringarray and populate it
- STATIC_CONTRACT_SO_TOLERANT;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), return (result); )
-
- // Get our array object (will throw, don't have to check it)
- PTRARRAYREF dataArray = (PTRARRAYREF) AllocateObjectArray(data.count, g_pStringClass);
-
- GCPROTECT_BEGIN(dataArray);
- LPCWSTR buffer = stringBuffer; // Restart @ buffer beginning
- for(DWORD i = 0; i < (DWORD)data.count; i++)
- {
- OBJECTREF o = (OBJECTREF) StringObject::NewString(buffer);
-
- if (calType == CAL_SABBREVERASTRING || calType == CAL_SERASTRING)
- {
- // Eras are enumerated backwards. (oldest era name first, but
- // Japanese calendar has newest era first in array, and is only
- // calendar with multiple eras)
- dataArray->SetAt((DWORD)data.count - i - 1, o);
- }
- else
- {
- dataArray->SetAt(i, o);
- }
-
- buffer += (lstrlenW(buffer) + 1);
- }
- GCPROTECT_END();
-
- _ASSERTE(pOutputStrings != NULL);
- *pOutputStrings = dataArray;
-
- END_SO_INTOLERANT_CODE
-
- return result;
-}
-
-////////////////////////////////////////////////////////////////////////
-//
-// For calendars like Gregorain US/Taiwan/UmAlQura, they are not available
-// in all OS or all localized versions of OS.
-// If OS does not support these calendars, we will fallback by using the
-// appropriate fallback calendar and locale combination to retrieve data from OS.
-//
-// Parameters:
-// __deref_inout pCalendarInt:
-// Pointer to the calendar ID. This will be updated to new fallback calendar ID if needed.
-// __in_out pLocaleNameStackBuffer
-// Pointer to the StackSString object which holds the locale name to be checked.
-// This will be updated to new fallback locale name if needed.
-//
-////////////////////////////////////////////////////////////////////////
-
-void CalendarData::CheckSpecialCalendar(INT32* pCalendarInt, StackSString* pLocaleNameStackBuffer)
-{
- // Gregorian-US isn't always available in the OS, however it is the same for all locales
- switch (*pCalendarInt)
- {
- case CAL_GREGORIAN_US:
- // See if this works
- if (0 == NewApis::GetCalendarInfoEx(*pLocaleNameStackBuffer, *pCalendarInt, NULL, CAL_SCALNAME, NULL, 0, NULL))
- {
- // Failed, set it to a locale (fa-IR) that's alway has Gregorian US available in the OS
- pLocaleNameStackBuffer->Set(W("fa-IR"), 5);
- }
- // See if that works
- if (0 == NewApis::GetCalendarInfoEx(*pLocaleNameStackBuffer, *pCalendarInt, NULL, CAL_SCALNAME, NULL, 0, NULL))
- {
- // Failed again, just use en-US with the gregorian calendar
- pLocaleNameStackBuffer->Set(W("en-US"), 5);
- *pCalendarInt = CAL_GREGORIAN;
- }
- break;
- case CAL_TAIWAN:
- // Taiwan calendar data is not always in all language version of OS due to Geopolical reasons.
- // It is only available in zh-TW localized versions of Windows.
- // Let's check if OS supports it. If not, fallback to Greogrian localized for Taiwan calendar.
- if (0 == NewApis::GetCalendarInfoEx(*pLocaleNameStackBuffer, *pCalendarInt, NULL, CAL_SCALNAME, NULL, 0, NULL))
- {
- *pCalendarInt = CAL_GREGORIAN;
- }
- break;
- case CAL_UMALQURA:
- // UmAlQura is only available in Vista and above, so we will need to fallback to Hijri if it is not available in the OS.
- if (0 == NewApis::GetCalendarInfoEx(*pLocaleNameStackBuffer, *pCalendarInt, NULL, CAL_SCALNAME, NULL, 0, NULL))
- {
- // There are no differences in DATA between UmAlQura and Hijri, and
- // UmAlQura isn't available before Vista, so just use Hijri..
- *pCalendarInt = CAL_HIJRI;
- }
- break;
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-//
-// Implementation for CalendarInfo.nativeGetCalendarData
-//
-// Retrieve calendar properties from the native side
-//
-// Parameters:
-// pCalendarData: This is passed from a managed structure CalendarData.cs
-// pLocaleNameUNSAFE: Locale name associated with the locale for this calendar
-// calendar: Calendar ID
-//
-// NOTE: Calendars depend on the locale name that creates it. Only a few
-// properties are available without locales using CalendarData.GetCalendar(int)
-//
-////////////////////////////////////////////////////////////////////////
-
-FCIMPL3(FC_BOOL_RET, CalendarData::nativeGetCalendarData, CalendarData* calendarDataUNSAFE, StringObject* pLocaleNameUNSAFE, INT32 calendar)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(pLocaleNameUNSAFE));
- } CONTRACTL_END;
-
-
- // The maximum allowed string length in GetLocaleInfo is 80 WCHARs.
- BOOL ret = TRUE;
-
- struct _gc
- {
- STRINGREF localeName;
- CALENDARDATAREF calendarData;
- } gc;
-
- // Dereference our gc objects
- gc.localeName = (STRINGREF)pLocaleNameUNSAFE;
- gc.calendarData = (CALENDARDATAREF)calendarDataUNSAFE;
-
- // Need to set up the frame since we will be allocating managed strings.
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- // create a local copy of the string in order to pass it to helper methods that trigger GCs like GetCalendarDayInfo and GetCalendarMonthInfo
- StackSString localeNameStackBuffer( gc.localeName->GetBuffer() );
-
- // Conveniently this is the same as LOCALE_NOUSEROVERRIDE, so we can use this for both
- int useOverrides = (gc.calendarData->bUseUserOverrides) ? 0 : CAL_NOUSEROVERRIDE;
-
- // Helper string
- STRINGREF stringResult = NULL;
-
- //
- // Windows doesn't support some calendars right now, so remap those.
- //
- if (calendar >= 13 && calendar < 23)
- {
- switch (calendar)
- {
- case RESERVED_CAL_PERSIAN: // don't change if we have Persian calendar
- break;
-
- case RESERVED_CAL_JAPANESELUNISOLAR: // Data looks like Japanese
- calendar=CAL_JAPAN;
- break;
- case RESERVED_CAL_JULIAN: // Data looks like gregorian US
- case RESERVED_CAL_CHINESELUNISOLAR: // Algorithmic, so actual data is irrelevent
- case RESERVED_CAL_SAKA: // reserved to match Office but not implemented in our code, so data is irrelevent
- case RESERVED_CAL_LUNAR_ETO_CHN: // reserved to match Office but not implemented in our code, so data is irrelevent
- case RESERVED_CAL_LUNAR_ETO_KOR: // reserved to match Office but not implemented in our code, so data is irrelevent
- case RESERVED_CAL_LUNAR_ETO_ROKUYOU: // reserved to match Office but not implemented in our code, so data is irrelevent
- case RESERVED_CAL_KOREANLUNISOLAR: // Algorithmic, so actual data is irrelevent
- case RESERVED_CAL_TAIWANLUNISOLAR: // Algorithmic, so actual data is irrelevent
- default:
- calendar = CAL_GREGORIAN_US;
- break;
- }
- }
-
- //
- // Speical handling for some special calendar due to OS limitation.
- // This includes calendar like Taiwan calendar, UmAlQura calendar, etc.
- //
- CheckSpecialCalendar(&calendar, &localeNameStackBuffer);
-
-
- // Numbers
- ret &= CallGetCalendarInfoEx(localeNameStackBuffer, calendar,
- CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER | useOverrides,
- &(gc.calendarData->iTwoDigitYearMax));
-
- if (ret == FALSE) // failed call
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_ITWODIGITYEARMAX");
- }
-
- _ASSERTE(ret == TRUE);
-
- // Strings
- if (CallGetCalendarInfoEx(localeNameStackBuffer, calendar, CAL_SCALNAME , &stringResult))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->sNativeName), stringResult, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SCALNAME");
- ret = FALSE;
- }
- if (CallGetCalendarInfoEx(localeNameStackBuffer, calendar, CAL_SMONTHDAY | useOverrides, &stringResult))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->sMonthDay), stringResult, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read RESERVED_CAL_SMONTHDAY");
- ret = FALSE;
- }
-
- // String Arrays
- // Formats
- PTRARRAYREF array = NULL;
- if (CallEnumCalendarInfo(localeNameStackBuffer, calendar, CAL_SSHORTDATE, LOCALE_SSHORTDATE | useOverrides, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saShortDates), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SSHORTDATE");
- ret = FALSE;
- }
- if (CallEnumCalendarInfo(localeNameStackBuffer, calendar, CAL_SLONGDATE, LOCALE_SLONGDATE | useOverrides, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saLongDates), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SLONGDATE");
- ret = FALSE;
- }
-
- // Get the YearMonth pattern.
- // Before Windows Vista, NLS would not write the Year/Month pattern into the reg key.
- // This causes GetLocaleInfo() to retrieve the Gregorian localized calendar pattern even when the calendar is not Gregorian localized.
- // So we will call GetLocaleInfo() only when the reg key for sYearMonth is there.
- //
- // If the key does not exist, leave yearMonthPattern to be null, so that we will pick up the default table value.
-
- int useOverridesForYearMonthPattern = useOverrides;
- if (useOverridesForYearMonthPattern == 0)
- {
- HKEY hkey = NULL;
- useOverridesForYearMonthPattern = CAL_NOUSEROVERRIDE;
- if (WszRegOpenKeyEx(HKEY_CURRENT_USER, W("Control Panel\\International"), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
- {
- if (WszRegQueryValueEx(hkey, W("sYearMonth"), 0, NULL, NULL, NULL) == ERROR_SUCCESS)
- {
- // The sYearMonth key exists. Call GetLocaleInfo() to read it.
- useOverridesForYearMonthPattern = 0; // now we can use the overrides
- }
- RegCloseKey(hkey);
- }
- }
-
- if (CallEnumCalendarInfo(localeNameStackBuffer, calendar, CAL_SYEARMONTH, LOCALE_SYEARMONTH | useOverridesForYearMonthPattern, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saYearMonths), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SYEARMONTH");
- ret = FALSE;
- }
-
- // Day & Month Names
- // These are all single calType entries, 1 per day, so we have to make 7 or 13 calls to collect all the names
-
- // Day
- // Note that we're off-by-one since managed starts on sunday and windows starts on monday
- if (GetCalendarDayInfo(localeNameStackBuffer, calendar, CAL_SDAYNAME7, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saDayNames), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SDAYNAME7");
- ret = FALSE;
- }
- if (GetCalendarDayInfo(localeNameStackBuffer, calendar, CAL_SABBREVDAYNAME7, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saAbbrevDayNames), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SABBREVDAYNAME7");
- ret = FALSE;
- }
-
- // Month names
- if (GetCalendarMonthInfo(localeNameStackBuffer, calendar, CAL_SMONTHNAME1, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saMonthNames), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SMONTHNAME1");
- ret = FALSE;
- }
-
- if (GetCalendarMonthInfo(localeNameStackBuffer, calendar, CAL_SABBREVMONTHNAME1, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saAbbrevMonthNames), array, NULL);
- else
- {
- _ASSERTE(!"nativeGetCalendarData could not read CAL_SABBREVMONTHNAME1");
- ret = FALSE;
- }
-
- //
- // The following LCTYPE are not supported in some platforms. If the call fails,
- // don't return a failure.
- //
- if (GetCalendarDayInfo(localeNameStackBuffer, calendar, CAL_SSHORTESTDAYNAME7, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saSuperShortDayNames), array, NULL);
-
-
- // Gregorian may have genitive month names
- if (calendar == CAL_GREGORIAN)
- {
- if (GetCalendarMonthInfo(localeNameStackBuffer, calendar, CAL_SMONTHNAME1 | CAL_RETURN_GENITIVE_NAMES, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saMonthGenitiveNames), array, NULL);
- // else we ignore the error and let managed side copy the normal month names
- if (GetCalendarMonthInfo(localeNameStackBuffer, calendar, CAL_SABBREVMONTHNAME1 | CAL_RETURN_GENITIVE_NAMES, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saAbbrevMonthGenitiveNames), array, NULL);
- // else we ignore the error and let managed side copy the normal month names
- }
-
-// leap year names are only different for month 6 in Hebrew calendar
-// PTRARRAYREF saLeapYearMonthNames ; // Multiple strings for the month names in a leap year. (Hebrew's the only one that has these)
-
- // Calendar Parts Names
- if (CallEnumCalendarInfo(localeNameStackBuffer, calendar, CAL_SERASTRING, NULL, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saEraNames), array, NULL);
- // else we set the era in managed code
- if (CallEnumCalendarInfo(localeNameStackBuffer, calendar, CAL_SABBREVERASTRING, NULL, &array))
- SetObjectReference((OBJECTREF*)&(gc.calendarData->saAbbrevEraNames), array, NULL);
- // else we set the era in managed code
-
- // PTRARRAYREF saAbbrevEnglishEraNames ; // Abbreviated Era Names in English
-
- //
- // Calendar Era Info
- // Note that calendar era data (offsets, etc) is hard coded for each calendar since this
- // data is implementation specific and not dynamic (except perhaps Japanese)
- //
-
- HELPER_METHOD_FRAME_END();
-
- FC_RETURN_BOOL(ret);
-}
-FCIMPLEND
-
-//
-// Get the system two digit year max value for the specified calendar
-//
-FCIMPL1(INT32, CalendarData::nativeGetTwoDigitYearMax, INT32 calendar)
-{
- FCALL_CONTRACT;
-
- DWORD dwTwoDigitYearMax = (DWORD) -1;
-
- HELPER_METHOD_FRAME_BEGIN_RET_0();
-
- WCHAR strName[LOCALE_NAME_MAX_LENGTH];
-
- // Really we should just be able to pass NULL for the locale name since that
- // causes the OS to look up the user default locale name. The downlevel APIS could
- // emulate this as necessary
- if (NewApis::GetUserDefaultLocaleName(strName,NumItems(strName)) == 0 ||
- NewApis::GetCalendarInfoEx(strName, calendar, NULL, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER, NULL, 0,&dwTwoDigitYearMax) == 0)
- {
- dwTwoDigitYearMax = (DWORD) -1;
- goto lExit;
- }
-
-lExit: ;
- HELPER_METHOD_FRAME_END();
-
- return (dwTwoDigitYearMax);
-}
-FCIMPLEND
-
-//
-// nativeGetCalendars
-//
-// Get the list of acceptable calendars for this user/locale
-//
-// Might be a better way to marshal the int[] for calendars
-// We expect the input array to be 23 ints long. We then fill up the first "count" ints and return the count.
-// The caller should then make it a smaller array.
-//
-
-// Perhaps we could do something more like this...
-//U1ARRAYREF rgbOut = (U1ARRAYREF) AllocatePrimitiveArray(ELEMENT_TYPE_U1, cb);
-//memcpyNoGCRefs(rgbOut->GetDirectPointerToNonObjectElements(), rgbKey, cb * sizeof(BYTE));
-//
-//refRetVal = rgbOut;
-//
-//HELPER_METHOD_FRAME_END();
-//return (U1Array*) OBJECTREFToObject(refRetVal);
-
-//
-// struct to help our calendar data enumaration callback
-//
-struct enumCalendarsData
-{
- int count; // # of strings found so far
- CALID userOverride; // user override value (if found)
- INT32* calendarList; // list of calendars found so far
-};
-
-//
-// callback itself
-//
-BOOL CALLBACK EnumCalendarsCallback(__in_z LPWSTR lpCalendarInfoString, __in CALID Calendar, __in_opt LPWSTR pReserved, __in LPARAM lParam)
-{
- CONTRACTL
- {
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- SO_TOLERANT;
- PRECONDITION(CheckPointer(lpCalendarInfoString));
- PRECONDITION(CheckPointer((LPVOID)lParam));
- } CONTRACTL_END;
-
- // Cast our data to the right type
- enumCalendarsData* pData = (enumCalendarsData*)lParam;
-
- // If we had a user override, check to make sure this differs
- if (pData->userOverride == Calendar)
- {
- // Its the same, just return
- return TRUE;
- }
-
- // They're different, add it to our buffer, check we have room
- if (pData->count < 23)
- {
- pData->calendarList[pData->count++] = Calendar;
- }
-
- return TRUE;
-}
-
-FCIMPL3(INT32, CalendarData::nativeGetCalendars, StringObject* pLocaleNameUNSAFE, CLR_BOOL useOverrides, I4Array* calendarsUNSAFE)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(pLocaleNameUNSAFE));
- } CONTRACTL_END;
-
- int ret = 0;
-
- struct _gc
- {
- STRINGREF localeName;
- I4ARRAYREF calendarsRef;
- } gc;
-
- // Dereference our string
- gc.localeName = (STRINGREF)pLocaleNameUNSAFE;
- gc.calendarsRef = (I4ARRAYREF)calendarsUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- int calendarBuffer[23];
- struct enumCalendarsData data;
- data.count = 0;
- data.userOverride = 0;
- data.calendarList = calendarBuffer;
-
- // First call GetLocaleInfo if necessary
- if (useOverrides)
- {
- // They want user overrides, see if the user calendar matches the input calendar
-
- CALID userCalendar = 0;
- NewApis::GetLocaleInfoEx( gc.localeName->GetBuffer(), LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER,
- (LPWSTR)&userCalendar, sizeof(userCalendar) / sizeof(WCHAR) );
-
- // If we got a default, then use it as the first calendar
- if (userCalendar != 0)
- {
- data.userOverride = userCalendar;
- data.calendarList[data.count++] = userCalendar;
- }
- }
-
- // Now call the enumeration API. Work is done by our callback function
- NewApis::EnumCalendarInfoExEx(EnumCalendarsCallback, gc.localeName->GetBuffer(), ENUM_ALL_CALENDARS, CAL_ICALINTVALUE, (LPARAM)&(data));
-
- // Copy to the output array
- for (int i = 0; i < data.count; i++)
- {
- (gc.calendarsRef->GetDirectPointerToNonObjectElements())[i] = calendarBuffer[i];
- }
-
- ret = data.count;
- HELPER_METHOD_FRAME_END();
-
- // Now we have a list of data, return the count
- return ret;
-}
-FCIMPLEND
-
-//
-// nativeEnumTimeFormats
-//
-// Enumerate all of the time formats (long times) on the system.
-// Windows only has 1 time format so there's nothing like an LCTYPE here.
-//
-// Note that if the locale is the user default locale windows ALWAYS returns the user override value first.
-// (ie: there's no no-user-override option for this API)
-//
-// We reuse the enumData structure since it works for us.
-//
-
-//
-// callback itself
-//
-BOOL CALLBACK EnumTimeFormatsCallback(__in_z LPCWSTR lpTimeFormatString, __in LPARAM lParam)
-{
- CONTRACTL
- {
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- SO_TOLERANT;
- PRECONDITION(CheckPointer(lpTimeFormatString));
- PRECONDITION(CheckPointer((LPVOID)lParam));
- } CONTRACTL_END;
-
- // Cast our data to the right type
- enumData* pData = (enumData*)lParam;
-
- // Don't have to worry about user overrides (the enum adds them)
- // add it to our buffer
- LPWSTR pStart = pData->stringsBuffer;
- LPCWSTR pEnd = pData->endOfBuffer;
- while (pStart < pEnd && *lpTimeFormatString != 0)
- {
- *(pStart++) = *(lpTimeFormatString++);
- }
-
- // Add a \0
- if (pStart < pEnd)
- {
- *(pStart++) = 0;
-
- // Did it finish?
- if (pStart <= pEnd)
- {
- // It finished, use it
- pData->count++;
- pData->stringsBuffer = pStart;
- }
- }
-
- return TRUE;
-}
-
-//
-// nativeEnumTimeFormats that calls the callback above
-//
-FCIMPL3(Object*, CalendarData::nativeEnumTimeFormats,
- StringObject* pLocaleNameUNSAFE, INT32 dwFlags, CLR_BOOL useUserOverride)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(pLocaleNameUNSAFE));
- } CONTRACTL_END;
-
-
- struct _gc
- {
- STRINGREF localeName;
- PTRARRAYREF timeFormatsArray;
- } gc;
-
- // Dereference our gc objects
- gc.localeName = (STRINGREF)pLocaleNameUNSAFE;
- gc.timeFormatsArray = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- // Our longest string in culture.xml is shorter than this and it has lots of \x type characters, so this should be long enough by far.
- WCHAR stringBuffer[512];
- struct enumData data;
- data.count = 0;
- data.userOverride = NULL;
- data.stringsBuffer = stringBuffer;
- data.endOfBuffer = stringBuffer + 512; // We're adding WCHAR sizes
-
- // Now call the enumeration API. Work is done by our callback function
- NewApis::EnumTimeFormatsEx((TIMEFMT_ENUMPROCEX)EnumTimeFormatsCallback, gc.localeName->GetBuffer(), dwFlags, (LPARAM)&data);
-
- if (data.count > 0)
- {
- // Now we need to allocate our stringarray and populate it
- // Get our array object (will throw, don't have to check it)
- gc.timeFormatsArray = (PTRARRAYREF) AllocateObjectArray(data.count, g_pStringClass);
-
- LPCWSTR buffer = stringBuffer; // Restart @ buffer beginning
- for(DWORD i = 0; i < (DWORD)data.count; i++) // todo: cast to compile on Mac
- {
- OBJECTREF o = (OBJECTREF) StringObject::NewString(buffer);
- gc.timeFormatsArray->SetAt(i, o);
-
- buffer += (lstrlenW(buffer) + 1);
- }
-
- if(!useUserOverride && data.count > 1)
- {
- // Since there is no "NoUserOverride" aware EnumTimeFormatsEx, we always get an override
- // The override is the first entry if it is overriden.
- // We can check if we have overrides by checking the GetLocaleInfo with no override
- // If we do have an override, we don't know if it is a user defined override or if the
- // user has just selected one of the predefined formats so we can't just remove it
- // but we can move it down.
- WCHAR timeFormatNoUserOverride[LOCALE_NAME_MAX_LENGTH];
- DWORD lcType = (dwFlags == TIME_NOSECONDS) ? LOCALE_SSHORTTIME : LOCALE_STIMEFORMAT;
- lcType |= LOCALE_NOUSEROVERRIDE;
- int result = NewApis::GetLocaleInfoEx(gc.localeName->GetBuffer(), lcType, timeFormatNoUserOverride, LOCALE_NAME_MAX_LENGTH);
- if(result != 0)
- {
- STRINGREF firstTimeFormat = (STRINGREF)gc.timeFormatsArray->GetAt(0);
- if(wcscmp(timeFormatNoUserOverride, firstTimeFormat->GetBuffer())!=0)
- {
- gc.timeFormatsArray->SetAt(0, gc.timeFormatsArray->GetAt(1));
- gc.timeFormatsArray->SetAt(1, firstTimeFormat);
- }
- }
- }
-
- }
-
- HELPER_METHOD_FRAME_END();
- return OBJECTREFToObject(gc.timeFormatsArray);
-}
-FCIMPLEND
-
-
diff --git a/src/classlibnative/nls/encodingdata.cpp b/src/classlibnative/nls/encodingdata.cpp
index bf5c73fd63..c6021256be 100644
--- a/src/classlibnative/nls/encodingdata.cpp
+++ b/src/classlibnative/nls/encodingdata.cpp
@@ -17,7 +17,6 @@
//
// Please KEEP this table SORTED ALPHABETICALLY! We do a binary search on this array.
const EncodingDataItem COMNlsInfo::EncodingDataTable[] = {
-#ifdef FEATURE_CORECLR
// encoding name, codepage.
{"ANSI_X3.4-1968", 20127 },
{"ANSI_X3.4-1986", 20127 },
@@ -63,429 +62,6 @@ const EncodingDataItem COMNlsInfo::EncodingDataTable[] = {
{"x-unicode-1-1-utf-8", 65001 },
{"x-unicode-2-0-utf-7", 65000 },
{"x-unicode-2-0-utf-8", 65001 },
-#else
- // Total Items: 455
-// encoding name, codepage.
-{"437", 437},
-{"ANSI_X3.4-1968", 20127},
-{"ANSI_X3.4-1986", 20127},
-// {L"_autodetect", 50932},
-// {L"_autodetect_all", 50001},
-// {L"_autodetect_kr", 50949},
-{"arabic", 28596},
-{"ascii", 20127},
-{"ASMO-708", 708},
-{"Big5", 950},
-{"Big5-HKSCS", 950},
-{"CCSID00858", 858},
-{"CCSID00924", 20924},
-{"CCSID01140", 1140},
-{"CCSID01141", 1141},
-{"CCSID01142", 1142},
-{"CCSID01143", 1143},
-{"CCSID01144", 1144},
-{"CCSID01145", 1145},
-{"CCSID01146", 1146},
-{"CCSID01147", 1147},
-{"CCSID01148", 1148},
-{"CCSID01149", 1149},
-{"chinese", 936},
-{"cn-big5", 950},
-{"CN-GB", 936},
-{"CP00858", 858},
-{"CP00924", 20924},
-{"CP01140", 1140},
-{"CP01141", 1141},
-{"CP01142", 1142},
-{"CP01143", 1143},
-{"CP01144", 1144},
-{"CP01145", 1145},
-{"CP01146", 1146},
-{"CP01147", 1147},
-{"CP01148", 1148},
-{"CP01149", 1149},
-{"cp037", 37},
-{"cp1025", 21025},
-{"CP1026", 1026},
-{"cp1256", 1256},
-{"CP273", 20273},
-{"CP278", 20278},
-{"CP280", 20280},
-{"CP284", 20284},
-{"CP285", 20285},
-{"cp290", 20290},
-{"cp297", 20297},
-{"cp367", 20127},
-{"cp420", 20420},
-{"cp423", 20423},
-{"cp424", 20424},
-{"cp437", 437},
-{"CP500", 500},
-{"cp50227", 50227},
- //{L"cp50229", 50229},
-{"cp819", 28591},
-{"cp850", 850},
-{"cp852", 852},
-{"cp855", 855},
-{"cp857", 857},
-{"cp858", 858},
-{"cp860", 860},
-{"cp861", 861},
-{"cp862", 862},
-{"cp863", 863},
-{"cp864", 864},
-{"cp865", 865},
-{"cp866", 866},
-{"cp869", 869},
-{"CP870", 870},
-{"CP871", 20871},
-{"cp875", 875},
-{"cp880", 20880},
-{"CP905", 20905},
-//{L"cp930", 50930},
-//{L"cp933", 50933},
-//{L"cp935", 50935},
-//{L"cp937", 50937},
-//{L"cp939", 50939},
-{"csASCII", 20127},
-{"csbig5", 950},
-{"csEUCKR", 51949},
-{"csEUCPkdFmtJapanese", 51932},
-{"csGB2312", 936},
-{"csGB231280", 936},
-{"csIBM037", 37},
-{"csIBM1026", 1026},
-{"csIBM273", 20273},
-{"csIBM277", 20277},
-{"csIBM278", 20278},
-{"csIBM280", 20280},
-{"csIBM284", 20284},
-{"csIBM285", 20285},
-{"csIBM290", 20290},
-{"csIBM297", 20297},
-{"csIBM420", 20420},
-{"csIBM423", 20423},
-{"csIBM424", 20424},
-{"csIBM500", 500},
-{"csIBM870", 870},
-{"csIBM871", 20871},
-{"csIBM880", 20880},
-{"csIBM905", 20905},
-{"csIBMThai", 20838},
-{"csISO2022JP", 50221},
-{"csISO2022KR", 50225},
-{"csISO58GB231280", 936},
-{"csISOLatin1", 28591},
-{"csISOLatin2", 28592},
-{"csISOLatin3", 28593},
-{"csISOLatin4", 28594},
-{"csISOLatin5", 28599},
-{"csISOLatin9", 28605},
-{"csISOLatinArabic", 28596},
-{"csISOLatinCyrillic", 28595},
-{"csISOLatinGreek", 28597},
-{"csISOLatinHebrew", 28598},
-{"csKOI8R", 20866},
-{"csKSC56011987", 949},
-{"csPC8CodePage437", 437},
-{"csShiftJIS", 932},
-{"csUnicode11UTF7", 65000},
-{"csWindows31J", 932},
-{"cyrillic", 28595},
-{"DIN_66003", 20106},
-{"DOS-720", 720},
-{"DOS-862", 862},
-{"DOS-874", 874},
-{"ebcdic-cp-ar1", 20420},
-{"ebcdic-cp-be", 500},
-{"ebcdic-cp-ca", 37},
-{"ebcdic-cp-ch", 500},
-{"EBCDIC-CP-DK", 20277},
-{"ebcdic-cp-es", 20284},
-{"ebcdic-cp-fi", 20278},
-{"ebcdic-cp-fr", 20297},
-{"ebcdic-cp-gb", 20285},
-{"ebcdic-cp-gr", 20423},
-{"ebcdic-cp-he", 20424},
-{"ebcdic-cp-is", 20871},
-{"ebcdic-cp-it", 20280},
-{"ebcdic-cp-nl", 37},
-{"EBCDIC-CP-NO", 20277},
-{"ebcdic-cp-roece", 870},
-{"ebcdic-cp-se", 20278},
-{"ebcdic-cp-tr", 20905},
-{"ebcdic-cp-us", 37},
-{"ebcdic-cp-wt", 37},
-{"ebcdic-cp-yu", 870},
-{"EBCDIC-Cyrillic", 20880},
-{"ebcdic-de-273+euro", 1141},
-{"ebcdic-dk-277+euro", 1142},
-{"ebcdic-es-284+euro", 1145},
-{"ebcdic-fi-278+euro", 1143},
-{"ebcdic-fr-297+euro", 1147},
-{"ebcdic-gb-285+euro", 1146},
-{"ebcdic-international-500+euro", 1148},
-{"ebcdic-is-871+euro", 1149},
-{"ebcdic-it-280+euro", 1144},
-{"EBCDIC-JP-kana", 20290},
-{"ebcdic-Latin9--euro", 20924},
-{"ebcdic-no-277+euro", 1142},
-{"ebcdic-se-278+euro", 1143},
-{"ebcdic-us-37+euro", 1140},
-{"ECMA-114", 28596},
-{"ECMA-118", 28597},
-{"ELOT_928", 28597},
-{"euc-cn", 51936},
-{"euc-jp", 51932},
-{"euc-kr", 51949},
-{"Extended_UNIX_Code_Packed_Format_for_Japanese", 51932},
-{"GB18030", 54936},
-{"GB2312", 936},
-{"GB2312-80", 936},
-{"GB231280", 936},
-{"GBK", 936},
-{"GB_2312-80", 936},
-{"German", 20106},
-{"greek", 28597},
-{"greek8", 28597},
-{"hebrew", 28598},
-{"hz-gb-2312", 52936},
-{"IBM-Thai", 20838},
-{"IBM00858", 858},
-{"IBM00924", 20924},
-{"IBM01047", 1047},
-{"IBM01140", 1140},
-{"IBM01141", 1141},
-{"IBM01142", 1142},
-{"IBM01143", 1143},
-{"IBM01144", 1144},
-{"IBM01145", 1145},
-{"IBM01146", 1146},
-{"IBM01147", 1147},
-{"IBM01148", 1148},
-{"IBM01149", 1149},
-{"IBM037", 37},
-{"IBM1026", 1026},
-{"IBM273", 20273},
-{"IBM277", 20277},
-{"IBM278", 20278},
-{"IBM280", 20280},
-{"IBM284", 20284},
-{"IBM285", 20285},
-{"IBM290", 20290},
-{"IBM297", 20297},
-{"IBM367", 20127},
-{"IBM420", 20420},
-{"IBM423", 20423},
-{"IBM424", 20424},
-{"IBM437", 437},
-{"IBM500", 500},
-{"ibm737", 737},
-{"ibm775", 775},
-{"ibm819", 28591},
-{"IBM850", 850},
-{"IBM852", 852},
-{"IBM855", 855},
-{"IBM857", 857},
-{"IBM860", 860},
-{"IBM861", 861},
-{"IBM862", 862},
-{"IBM863", 863},
-{"IBM864", 864},
-{"IBM865", 865},
-{"IBM866", 866},
-{"IBM869", 869},
-{"IBM870", 870},
-{"IBM871", 20871},
-{"IBM880", 20880},
-{"IBM905", 20905},
-{"irv", 20105},
-{"ISO-10646-UCS-2", 1200},
-{"iso-2022-jp", 50220},
-{"iso-2022-jpeuc", 51932},
-{"iso-2022-kr", 50225},
-{"iso-2022-kr-7", 50225},
-{"iso-2022-kr-7bit", 50225},
-{"iso-2022-kr-8", 51949},
-{"iso-2022-kr-8bit", 51949},
-{"iso-8859-1", 28591},
-{"iso-8859-11", 874},
-{"iso-8859-13", 28603},
-{"iso-8859-15", 28605},
-{"iso-8859-2", 28592},
-{"iso-8859-3", 28593},
-{"iso-8859-4", 28594},
-{"iso-8859-5", 28595},
-{"iso-8859-6", 28596},
-{"iso-8859-7", 28597},
-{"iso-8859-8", 28598},
-{"ISO-8859-8 Visual", 28598},
-{"iso-8859-8-i", 38598},
-{"iso-8859-9", 28599},
-{"iso-ir-100", 28591},
-{"iso-ir-101", 28592},
-{"iso-ir-109", 28593},
-{"iso-ir-110", 28594},
-{"iso-ir-126", 28597},
-{"iso-ir-127", 28596},
-{"iso-ir-138", 28598},
-{"iso-ir-144", 28595},
-{"iso-ir-148", 28599},
-{"iso-ir-149", 949},
-{"iso-ir-58", 936},
-{"iso-ir-6", 20127},
-{"ISO646-US", 20127},
-{"iso8859-1", 28591},
-{"iso8859-2", 28592},
-{"ISO_646.irv:1991", 20127},
-{"iso_8859-1", 28591},
-{"ISO_8859-15", 28605},
-{"iso_8859-1:1987", 28591},
-{"iso_8859-2", 28592},
-{"iso_8859-2:1987", 28592},
-{"ISO_8859-3", 28593},
-{"ISO_8859-3:1988", 28593},
-{"ISO_8859-4", 28594},
-{"ISO_8859-4:1988", 28594},
-{"ISO_8859-5", 28595},
-{"ISO_8859-5:1988", 28595},
-{"ISO_8859-6", 28596},
-{"ISO_8859-6:1987", 28596},
-{"ISO_8859-7", 28597},
-{"ISO_8859-7:1987", 28597},
-{"ISO_8859-8", 28598},
-{"ISO_8859-8:1988", 28598},
-{"ISO_8859-9", 28599},
-{"ISO_8859-9:1989", 28599},
-{"Johab", 1361},
-{"koi", 20866},
-{"koi8", 20866},
-{"koi8-r", 20866},
-{"koi8-ru", 21866},
-{"koi8-u", 21866},
-{"koi8r", 20866},
-{"korean", 949},
-{"ks-c-5601", 949},
-{"ks-c5601", 949},
-{"KSC5601", 949},
-{"KSC_5601", 949},
-{"ks_c_5601", 949},
-{"ks_c_5601-1987", 949},
-{"ks_c_5601-1989", 949},
-{"ks_c_5601_1987", 949},
-{"l1", 28591},
-{"l2", 28592},
-{"l3", 28593},
-{"l4", 28594},
-{"l5", 28599},
-{"l9", 28605},
-{"latin1", 28591},
-{"latin2", 28592},
-{"latin3", 28593},
-{"latin4", 28594},
-{"latin5", 28599},
-{"latin9", 28605},
-{"logical", 28598},
-{"macintosh", 10000},
-{"ms_Kanji", 932},
-{"Norwegian", 20108},
-{"NS_4551-1", 20108},
-{"PC-Multilingual-850+euro", 858},
-{"SEN_850200_B", 20107},
-{"shift-jis", 932},
-{"shift_jis", 932},
-{"sjis", 932},
-{"Swedish", 20107},
-{"TIS-620", 874},
-{"ucs-2", 1200},
-{"unicode", 1200},
-{"unicode-1-1-utf-7", 65000},
-{"unicode-1-1-utf-8", 65001},
-{"unicode-2-0-utf-7", 65000},
-{"unicode-2-0-utf-8", 65001},
-// People get confused about the FFFE here. We can't change this because it'd break existing apps.
-// This has been this way for a long time, including in Mlang.
-{"unicodeFFFE", 1201}, // Big Endian, BOM seems backwards, think of the BOM in little endian order.
-{"us", 20127},
-{"us-ascii", 20127},
-{"utf-16", 1200},
-{"UTF-16BE", 1201},
-{"UTF-16LE", 1200},
-{"utf-32", 12000},
-{"UTF-32BE", 12001},
-{"UTF-32LE", 12000},
-{"utf-7", 65000},
-{"utf-8", 65001},
-{"visual", 28598},
-{"windows-1250", 1250},
-{"windows-1251", 1251},
-{"windows-1252", 1252},
-{"windows-1253", 1253},
-{"Windows-1254", 1254},
-{"windows-1255", 1255},
-{"windows-1256", 1256},
-{"windows-1257", 1257},
-{"windows-1258", 1258},
-{"windows-874", 874},
-{"x-ansi", 1252},
-{"x-Chinese-CNS", 20000},
-{"x-Chinese-Eten", 20002},
-{"x-cp1250", 1250},
-{"x-cp1251", 1251},
-{"x-cp20001", 20001},
-{"x-cp20003", 20003},
-{"x-cp20004", 20004},
-{"x-cp20005", 20005},
-{"x-cp20261", 20261},
-{"x-cp20269", 20269},
-{"x-cp20936", 20936},
-{"x-cp20949", 20949},
-{"x-cp50227", 50227},
-//{L"x-cp50229", 50229},
-//{L"X-EBCDIC-JapaneseAndUSCanada", 50931},
-{"X-EBCDIC-KoreanExtended", 20833},
-{"x-euc", 51932},
-{"x-euc-cn", 51936},
-{"x-euc-jp", 51932},
-{"x-Europa", 29001},
-{"x-IA5", 20105},
-{"x-IA5-German", 20106},
-{"x-IA5-Norwegian", 20108},
-{"x-IA5-Swedish", 20107},
-{"x-iscii-as", 57006},
-{"x-iscii-be", 57003},
-{"x-iscii-de", 57002},
-{"x-iscii-gu", 57010},
-{"x-iscii-ka", 57008},
-{"x-iscii-ma", 57009},
-{"x-iscii-or", 57007},
-{"x-iscii-pa", 57011},
-{"x-iscii-ta", 57004},
-{"x-iscii-te", 57005},
-{"x-mac-arabic", 10004},
-{"x-mac-ce", 10029},
-{"x-mac-chinesesimp", 10008},
-{"x-mac-chinesetrad", 10002},
-{"x-mac-croatian", 10082},
-{"x-mac-cyrillic", 10007},
-{"x-mac-greek", 10006},
-{"x-mac-hebrew", 10005},
-{"x-mac-icelandic", 10079},
-{"x-mac-japanese", 10001},
-{"x-mac-korean", 10003},
-{"x-mac-romanian", 10010},
-{"x-mac-thai", 10021},
-{"x-mac-turkish", 10081},
-{"x-mac-ukrainian", 10017},
-{"x-ms-cp932", 932},
-{"x-sjis", 932},
-{"x-unicode-1-1-utf-7", 65000},
-{"x-unicode-1-1-utf-8", 65001},
-{"x-unicode-2-0-utf-7", 65000},
-{"x-unicode-2-0-utf-8", 65001},
-{"x-x-big5", 950},
-
-#endif // FEATURE_CORECLR
};
@@ -503,7 +79,6 @@ const int COMNlsInfo::m_nEncodingDataTableItems =
//
const CodePageDataItem COMNlsInfo::CodePageDataTable[] = {
-#ifdef FEATURE_CORECLR
// Total Items:
// code page, family code page, web name, header name, body name, flags
@@ -517,160 +92,6 @@ const CodePageDataItem COMNlsInfo::CodePageDataTable[] = {
MapCodePageDataItem( 65000, 1200, "utf-7", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "Unicode (UTF-7)"
MapCodePageDataItem( 65001, 1200, "utf-8", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Unicode (UTF-8)"
-#else //FEATURE_CORECLR
-
-// Total Items: 146
-// code page, family code page, web name, header name, body name, flags
-
-
- MapCodePageDataItem( 37, 1252, "IBM037", 0), // "IBM EBCDIC (US-Canada)"
- MapCodePageDataItem( 437, 1252, "IBM437", 0), // "OEM United States"
- MapCodePageDataItem( 500, 1252, "IBM500", 0), // "IBM EBCDIC (International)"
- MapCodePageDataItem( 708, 1256, "ASMO-708", MIMECONTF_BROWSER | MIMECONTF_SAVABLE_BROWSER), // "Arabic (ASMO 708)"
- MapCodePageDataItem( 720, 1256, "DOS-720", MIMECONTF_BROWSER | MIMECONTF_SAVABLE_BROWSER), // "Arabic (DOS)"
- MapCodePageDataItem( 737, 1253, "ibm737", 0), // "Greek (DOS)"
- MapCodePageDataItem( 775, 1257, "ibm775", 0), // "Baltic (DOS)"
- MapCodePageDataItem( 850, 1252, "ibm850", 0), // "Western European (DOS)"
- MapCodePageDataItem( 852, 1250, "ibm852", MIMECONTF_BROWSER | MIMECONTF_SAVABLE_BROWSER), // "Central European (DOS)"
- MapCodePageDataItem( 855, 1252, "IBM855", 0), // "OEM Cyrillic"
- MapCodePageDataItem( 857, 1254, "ibm857", 0), // "Turkish (DOS)"
- MapCodePageDataItem( 858, 1252, "IBM00858", 0), // "OEM Multilingual Latin I"
- MapCodePageDataItem( 860, 1252, "IBM860", 0), // "Portuguese (DOS)"
- MapCodePageDataItem( 861, 1252, "ibm861", 0), // "Icelandic (DOS)"
- MapCodePageDataItem( 862, 1255, "DOS-862", MIMECONTF_BROWSER | MIMECONTF_SAVABLE_BROWSER), // "Hebrew (DOS)"
- MapCodePageDataItem( 863, 1252, "IBM863", 0), // "French Canadian (DOS)"
- MapCodePageDataItem( 864, 1256, "IBM864", 0), // "Arabic (864)"
- MapCodePageDataItem( 865, 1252, "IBM865", 0), // "Nordic (DOS)"
- MapCodePageDataItem( 866, 1251, "cp866", MIMECONTF_BROWSER | MIMECONTF_SAVABLE_BROWSER), // "Cyrillic (DOS)"
- MapCodePageDataItem( 869, 1253, "ibm869", 0), // "Greek, Modern (DOS)"
- MapCodePageDataItem( 870, 1250, "IBM870", 0), // "IBM EBCDIC (Multilingual Latin-2)"
- MapCodePageDataItem( 874, 874, "windows-874", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Thai (Windows)"
- MapCodePageDataItem( 875, 1253, "cp875", 0), // "IBM EBCDIC (Greek Modern)"
- MapCodePageDataItem( 932, 932, "|shift_jis|iso-2022-jp|iso-2022-jp", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Japanese (Shift-JIS)"
- MapCodePageDataItem( 936, 936, "gb2312", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Chinese Simplified (GB2312)"
- MapCodePageDataItem( 949, 949, "ks_c_5601-1987", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Korean"
- MapCodePageDataItem( 950, 950, "big5", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Chinese Traditional (Big5)"
- MapCodePageDataItem( 1026, 1254, "IBM1026", 0), // "IBM EBCDIC (Turkish Latin-5)"
- MapCodePageDataItem( 1047, 1252, "IBM01047", 0), // "IBM Latin-1"
- MapCodePageDataItem( 1140, 1252, "IBM01140", 0), // "IBM EBCDIC (US-Canada-Euro)"
- MapCodePageDataItem( 1141, 1252, "IBM01141", 0), // "IBM EBCDIC (Germany-Euro)"
- MapCodePageDataItem( 1142, 1252, "IBM01142", 0), // "IBM EBCDIC (Denmark-Norway-Euro)"
- MapCodePageDataItem( 1143, 1252, "IBM01143", 0), // "IBM EBCDIC (Finland-Sweden-Euro)"
- MapCodePageDataItem( 1144, 1252, "IBM01144", 0), // "IBM EBCDIC (Italy-Euro)"
- MapCodePageDataItem( 1145, 1252, "IBM01145", 0), // "IBM EBCDIC (Spain-Euro)"
- MapCodePageDataItem( 1146, 1252, "IBM01146", 0), // "IBM EBCDIC (UK-Euro)"
- MapCodePageDataItem( 1147, 1252, "IBM01147", 0), // "IBM EBCDIC (France-Euro)"
- MapCodePageDataItem( 1148, 1252, "IBM01148", 0), // "IBM EBCDIC (International-Euro)"
- MapCodePageDataItem( 1149, 1252, "IBM01149", 0), // "IBM EBCDIC (Icelandic-Euro)"
- MapCodePageDataItem( 1200, 1200, "utf-16", MIMECONTF_SAVABLE_BROWSER), // "Unicode"
- MapCodePageDataItem( 1201, 1200, "utf-16BE", 0), // Big Endian, old FFFE BOM seems backwards, think of the BOM in little endian order.
- MapCodePageDataItem( 1250, 1250, "|windows-1250|windows-1250|iso-8859-2", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Central European (Windows)"
- MapCodePageDataItem( 1251, 1251, "|windows-1251|windows-1251|koi8-r", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Cyrillic (Windows)"
- MapCodePageDataItem( 1252, 1252, "|Windows-1252|Windows-1252|iso-8859-1", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Western European (Windows)"
- MapCodePageDataItem( 1253, 1253, "|windows-1253|windows-1253|iso-8859-7", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Greek (Windows)"
- MapCodePageDataItem( 1254, 1254, "|windows-1254|windows-1254|iso-8859-9", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Turkish (Windows)"
- MapCodePageDataItem( 1255, 1255, "windows-1255", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Hebrew (Windows)"
- MapCodePageDataItem( 1256, 1256, "windows-1256", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Arabic (Windows)"
- MapCodePageDataItem( 1257, 1257, "windows-1257", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Baltic (Windows)"
- MapCodePageDataItem( 1258, 1258, "windows-1258", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Vietnamese (Windows)"
- MapCodePageDataItem( 1361, 949, "Johab", 0), // "Korean (Johab)"
- MapCodePageDataItem( 10000, 1252, "macintosh", 0), // "Western European (Mac)"
- MapCodePageDataItem( 10001, 932, "x-mac-japanese", 0), // "Japanese (Mac)"
- MapCodePageDataItem( 10002, 950, "x-mac-chinesetrad", 0), // "Chinese Traditional (Mac)"
- MapCodePageDataItem( 10003, 949, "x-mac-korean", 0), // "Korean (Mac)"
- MapCodePageDataItem( 10004, 1256, "x-mac-arabic", 0), // "Arabic (Mac)"
- MapCodePageDataItem( 10005, 1255, "x-mac-hebrew", 0), // "Hebrew (Mac)"
- MapCodePageDataItem( 10006, 1253, "x-mac-greek", 0), // "Greek (Mac)"
- MapCodePageDataItem( 10007, 1251, "x-mac-cyrillic", 0), // "Cyrillic (Mac)"
- MapCodePageDataItem( 10008, 936, "x-mac-chinesesimp", 0), // "Chinese Simplified (Mac)"
- MapCodePageDataItem( 10010, 1250, "x-mac-romanian", 0), // "Romanian (Mac)"
- MapCodePageDataItem( 10017, 1251, "x-mac-ukrainian", 0), // "Ukrainian (Mac)"
- MapCodePageDataItem( 10021, 874, "x-mac-thai", 0), // "Thai (Mac)"
- MapCodePageDataItem( 10029, 1250, "x-mac-ce", 0), // "Central European (Mac)"
- MapCodePageDataItem( 10079, 1252, "x-mac-icelandic", 0), // "Icelandic (Mac)"
- MapCodePageDataItem( 10081, 1254, "x-mac-turkish", 0), // "Turkish (Mac)"
- MapCodePageDataItem( 10082, 1250, "x-mac-croatian", 0), // "Croatian (Mac)"
- MapCodePageDataItem( 12000, 1200, "utf-32", 0), // "Unicode (UTF-32)"
- MapCodePageDataItem( 12001, 1200, "utf-32BE", 0), // "Unicode (UTF-32 Big Endian)"
- MapCodePageDataItem( 20000, 950, "x-Chinese-CNS", 0), // "Chinese Traditional (CNS)"
- MapCodePageDataItem( 20001, 950, "x-cp20001", 0), // "TCA Taiwan"
- MapCodePageDataItem( 20002, 950, "x-Chinese-Eten", 0), // "Chinese Traditional (Eten)"
- MapCodePageDataItem( 20003, 950, "x-cp20003", 0), // "IBM5550 Taiwan"
- MapCodePageDataItem( 20004, 950, "x-cp20004", 0), // "TeleText Taiwan"
- MapCodePageDataItem( 20005, 950, "x-cp20005", 0), // "Wang Taiwan"
- MapCodePageDataItem( 20105, 1252, "x-IA5", 0), // "Western European (IA5)"
- MapCodePageDataItem( 20106, 1252, "x-IA5-German", 0), // "German (IA5)"
- MapCodePageDataItem( 20107, 1252, "x-IA5-Swedish", 0), // "Swedish (IA5)"
- MapCodePageDataItem( 20108, 1252, "x-IA5-Norwegian", 0), // "Norwegian (IA5)"
- MapCodePageDataItem( 20127, 1252, "us-ascii", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "US-ASCII"
- MapCodePageDataItem( 20261, 1252, "x-cp20261", 0), // "T.61"
- MapCodePageDataItem( 20269, 1252, "x-cp20269", 0), // "ISO-6937"
- MapCodePageDataItem( 20273, 1252, "IBM273", 0), // "IBM EBCDIC (Germany)"
- MapCodePageDataItem( 20277, 1252, "IBM277", 0), // "IBM EBCDIC (Denmark-Norway)"
- MapCodePageDataItem( 20278, 1252, "IBM278", 0), // "IBM EBCDIC (Finland-Sweden)"
- MapCodePageDataItem( 20280, 1252, "IBM280", 0), // "IBM EBCDIC (Italy)"
- MapCodePageDataItem( 20284, 1252, "IBM284", 0), // "IBM EBCDIC (Spain)"
- MapCodePageDataItem( 20285, 1252, "IBM285", 0), // "IBM EBCDIC (UK)"
- MapCodePageDataItem( 20290, 932, "IBM290", 0), // "IBM EBCDIC (Japanese katakana)"
- MapCodePageDataItem( 20297, 1252, "IBM297", 0), // "IBM EBCDIC (France)"
- MapCodePageDataItem( 20420, 1256, "IBM420", 0), // "IBM EBCDIC (Arabic)"
- MapCodePageDataItem( 20423, 1253, "IBM423", 0), // "IBM EBCDIC (Greek)"
- MapCodePageDataItem( 20424, 1255, "IBM424", 0), // "IBM EBCDIC (Hebrew)"
- MapCodePageDataItem( 20833, 949, "x-EBCDIC-KoreanExtended", 0), // "IBM EBCDIC (Korean Extended)"
- MapCodePageDataItem( 20838, 874, "IBM-Thai", 0), // "IBM EBCDIC (Thai)"
- MapCodePageDataItem( 20866, 1251, "koi8-r", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Cyrillic (KOI8-R)"
- MapCodePageDataItem( 20871, 1252, "IBM871", 0), // "IBM EBCDIC (Icelandic)"
- MapCodePageDataItem( 20880, 1251, "IBM880", 0), // "IBM EBCDIC (Cyrillic Russian)"
- MapCodePageDataItem( 20905, 1254, "IBM905", 0), // "IBM EBCDIC (Turkish)"
- MapCodePageDataItem( 20924, 1252, "IBM00924", 0), // "IBM Latin-1"
- MapCodePageDataItem( 20932, 932, "EUC-JP", 0), // "Japanese (JIS 0208-1990 and 0212-1990)"
- MapCodePageDataItem( 20936, 936, "x-cp20936", 0), // "Chinese Simplified (GB2312-80)"
- MapCodePageDataItem( 20949, 949, "x-cp20949", 0), // "Korean Wansung"
- MapCodePageDataItem( 21025, 1251, "cp1025", 0), // "IBM EBCDIC (Cyrillic Serbian-Bulgarian)"
- MapCodePageDataItem( 21866, 1251, "koi8-u", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Cyrillic (KOI8-U)"
- MapCodePageDataItem( 28591, 1252, "iso-8859-1", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Western European (ISO)"
- MapCodePageDataItem( 28592, 1250, "iso-8859-2", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Central European (ISO)"
- MapCodePageDataItem( 28593, 1254, "iso-8859-3", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "Latin 3 (ISO)"
- MapCodePageDataItem( 28594, 1257, "iso-8859-4", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Baltic (ISO)"
- MapCodePageDataItem( 28595, 1251, "iso-8859-5", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Cyrillic (ISO)"
- MapCodePageDataItem( 28596, 1256, "iso-8859-6", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Arabic (ISO)"
- MapCodePageDataItem( 28597, 1253, "iso-8859-7", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Greek (ISO)"
- MapCodePageDataItem( 28598, 1255, "iso-8859-8", MIMECONTF_BROWSER | MIMECONTF_SAVABLE_BROWSER), // "Hebrew (ISO-Visual)"
- MapCodePageDataItem( 28599, 1254, "iso-8859-9", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Turkish (ISO)"
- MapCodePageDataItem( 28603, 1257, "iso-8859-13", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "Estonian (ISO)"
- MapCodePageDataItem( 28605, 1252, "iso-8859-15", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Latin 9 (ISO)"
- MapCodePageDataItem( 29001, 1252, "x-Europa", 0), // "Europa"
- MapCodePageDataItem( 38598, 1255, "iso-8859-8-i", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Hebrew (ISO-Logical)"
- MapCodePageDataItem( 50220, 932, "iso-2022-jp", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "Japanese (JIS)"
- MapCodePageDataItem( 50221, 932, "|csISO2022JP|iso-2022-jp|iso-2022-jp", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Japanese (JIS-Allow 1 byte Kana)"
- MapCodePageDataItem( 50222, 932, "iso-2022-jp", 0), // "Japanese (JIS-Allow 1 byte Kana - SO/SI)"
- MapCodePageDataItem( 50225, 949, "|iso-2022-kr|euc-kr|iso-2022-kr", MIMECONTF_MAILNEWS), // "Korean (ISO)"
- MapCodePageDataItem( 50227, 936, "x-cp50227", 0), // "Chinese Simplified (ISO-2022)"
-//MapCodePageDataItem( 50229, 950, L"x-cp50229", L"x-cp50229", L"x-cp50229", 0}, // "Chinese Traditional (ISO-2022)"
-//MapCodePageDataItem( 50930, 932, L"cp930", L"cp930", L"cp930", 0}, // "IBM EBCDIC (Japanese and Japanese Katakana)"
-//MapCodePageDataItem( 50931, 932, L"x-EBCDIC-JapaneseAndUSCanada", L"x-EBCDIC-JapaneseAndUSCanada", L"x-EBCDIC-JapaneseAndUSCanada", 0}, // "IBM EBCDIC (Japanese and US-Canada)"
-//MapCodePageDataItem( 50933, 949, L"cp933", L"cp933", L"cp933", 0}, // "IBM EBCDIC (Korean and Korean Extended)"
-//MapCodePageDataItem( 50935, 936, L"cp935", L"cp935", L"cp935", 0}, // "IBM EBCDIC (Simplified Chinese)"
-//MapCodePageDataItem( 50937, 950, L"cp937", L"cp937", L"cp937", 0}, // "IBM EBCDIC (Traditional Chinese)"
-//MapCodePageDataItem( 50939, 932, L"cp939", L"cp939", L"cp939", 0}, // "IBM EBCDIC (Japanese and Japanese-Latin)"
- MapCodePageDataItem( 51932, 932, "euc-jp", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Japanese (EUC)"
- MapCodePageDataItem( 51936, 936, "EUC-CN", 0), // "Chinese Simplified (EUC)"
- MapCodePageDataItem( 51949, 949, "euc-kr", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "Korean (EUC)"
- MapCodePageDataItem( 52936, 936, "hz-gb-2312", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Chinese Simplified (HZ)"
- MapCodePageDataItem( 54936, 936, "GB18030", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Chinese Simplified (GB18030)"
- MapCodePageDataItem( 57002, 57002, "x-iscii-de", 0), // "ISCII Devanagari"
- MapCodePageDataItem( 57003, 57003, "x-iscii-be", 0), // "ISCII Bengali"
- MapCodePageDataItem( 57004, 57004, "x-iscii-ta", 0), // "ISCII Tamil"
- MapCodePageDataItem( 57005, 57005, "x-iscii-te", 0), // "ISCII Telugu"
- MapCodePageDataItem( 57006, 57006, "x-iscii-as", 0), // "ISCII Assamese"
- MapCodePageDataItem( 57007, 57007, "x-iscii-or", 0), // "ISCII Oriya"
- MapCodePageDataItem( 57008, 57008, "x-iscii-ka", 0), // "ISCII Kannada"
- MapCodePageDataItem( 57009, 57009, "x-iscii-ma", 0), // "ISCII Malayalam"
- MapCodePageDataItem( 57010, 57010, "x-iscii-gu", 0), // "ISCII Gujarati"
- MapCodePageDataItem( 57011, 57011, "x-iscii-pa", 0), // "ISCII Punjabi"
- MapCodePageDataItem( 65000, 1200, "utf-7", MIMECONTF_MAILNEWS | MIMECONTF_SAVABLE_MAILNEWS), // "Unicode (UTF-7)"
- MapCodePageDataItem( 65001, 1200, "utf-8", MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER), // "Unicode (UTF-8)"
-#endif // FEATURE_CORECLR
// End of data.
MapCodePageDataItem( 0, 0, NULL, 0),
diff --git a/src/classlibnative/nls/nlsinfo.cpp b/src/classlibnative/nls/nlsinfo.cpp
index 0e034c4a0c..fa288c0e0a 100644
--- a/src/classlibnative/nls/nlsinfo.cpp
+++ b/src/classlibnative/nls/nlsinfo.cpp
@@ -33,7 +33,6 @@
#include "metasig.h"
#include "nls.h"
#include "nlsinfo.h"
-#include "nlstable.h"
//#include <mlang.h>
#include "sortversioning.h"
@@ -44,70 +43,6 @@
// Constant Declarations.
//
-#ifndef COMPARE_OPTIONS_IGNORECASE
-#define COMPARE_OPTIONS_IGNORECASE 0x00000001
-#endif
-
-#ifndef LOCALE_SNAME
-#define LOCALE_SNAME 0x0000005c
-#endif
-
-#ifndef LOCALE_SNAN
-#define LOCALE_SNAN 0x00000069
-#endif
-
-#ifndef LOCALE_SPOSINFINITY
-#define LOCALE_SPOSINFINITY 0x0000006a
-#endif
-
-#ifndef LOCALE_SNEGINFINITY
-#define LOCALE_SNEGINFINITY 0x0000006b
-#endif
-
-#ifndef LOCALE_SPARENT
-#define LOCALE_SPARENT 0x0000006d
-#endif
-
-#ifndef LOCALE_SCONSOLEFALLBACKNAME
-#define LOCALE_SCONSOLEFALLBACKNAME 0x0000006e // Fallback name for within the console
-#endif
-
-#ifndef LOCALE_SISO3166CTRYNAME2
-#define LOCALE_SISO3166CTRYNAME2 0x00000068
-#endif
-
-#ifndef LOCALE_SISO639LANGNAME2
-#define LOCALE_SISO639LANGNAME2 0x00000067
-#endif
-
-#ifndef LOCALE_SSHORTESTDAYNAME1
-#define LOCALE_SSHORTESTDAYNAME1 0x00000060
-#endif
-
-// Windows 7 LCTypes
-#ifndef LOCALE_INEUTRAL
-#define LOCALE_INEUTRAL 0x00000071 // Returns 0 for specific cultures, 1 for neutral cultures.
-#endif
-
-#ifndef LCMAP_TITLECASE
-#define LCMAP_TITLECASE 0x00000300 // Title Case Letters
-#endif
-
-// Windows 8 LCTypes
-#ifndef LCMAP_SORTHANDLE
-#define LCMAP_SORTHANDLE 0x20000000
-#endif
-
-#ifndef LCMAP_HASH
-#define LCMAP_HASH 0x00040000
-#endif
-
-#ifndef LOCALE_REPLACEMENT
-#define LOCALE_REPLACEMENT 0x00000008 // locales that replace shipped locales (callback flag only)
-#endif // LOCALE_REPLACEMENT
-
-#define LOCALE_MAX_STRING_SIZE 530 // maximum sice of LOCALE_SKEYBOARDSTOINSTALL, currently 5 "long" + 2 "short" keyboard signatures (YI + 3).
-
#define MAX_STRING_VALUE 512
// TODO: NLS Arrowhead -Be nice if we could depend more on the OS for this
@@ -115,344 +50,7 @@
#define LANGID_ZH_TW 0x0404
// Language ID for CHT (Hong-Kong)
#define LANGID_ZH_HK 0x0c04
-#define REGION_NAME_0404 W("\x53f0\x7063")
-#if BIGENDIAN
-#define INTERNATIONAL_CURRENCY_SYMBOL W("\x00a4")
-#else
-#define INTERNATIONAL_CURRENCY_SYMBOL W("\xa400")
-#endif
-
-inline BOOL IsCustomCultureId(LCID lcid)
-{
- return (lcid == LOCALE_CUSTOM_DEFAULT || lcid == LOCALE_CUSTOM_UNSPECIFIED);
-}
-
-#ifndef FEATURE_COREFX_GLOBALIZATION
-//
-// Normalization Implementation
-//
-#define NORMALIZATION_DLL MAKEDLLNAME(W("normalization"))
-HMODULE COMNlsInfo::m_hNormalization = NULL;
-PFN_NORMALIZATION_IS_NORMALIZED_STRING COMNlsInfo::m_pfnNormalizationIsNormalizedStringFunc = NULL;
-PFN_NORMALIZATION_NORMALIZE_STRING COMNlsInfo::m_pfnNormalizationNormalizeStringFunc = NULL;
-PFN_NORMALIZATION_INIT_NORMALIZATION COMNlsInfo::m_pfnNormalizationInitNormalizationFunc = NULL;
-#endif // FEATURE_COREFX_GLOBALIZATION
-
-#if FEATURE_CODEPAGES_FILE
-/*============================nativeCreateOpenFileMapping============================
-**Action: Create or open a named memory file mapping.
-**Returns: Pointer to named section, or NULL if failed
-**Arguments:
-** StringObject* inSectionName - name of section to open/create
-** int inBytesToAllocate - desired size of memory section in bytes
-** We use the last 4 bytes (must be aligned, so only choose
-** inBytesToAllocate in multiples of 4) to indicate if the
-** section is set or not. AFTER section is initialized, set
-** those 4 bytes to non-0, otherwise you'll get get new
-** heap memory all the time.
-** HANDLE* mappedFile - is the handle of the memory mapped file. this is
-** out parameter.
-**
-** NOTE: We'll try to open the same object, so we can share names. We don't lock
-** though, so 2 thread could get the same object, but thread 1 might not
-** have initialized it yet.
-**
-** NOTE: For NT you should add a Global\ to the beginning of the name if you
-** want to share it machine wide.
-**
-==============================================================================*/
-FCIMPL3(LPVOID, COMNlsInfo::nativeCreateOpenFileMapping,
- StringObject* inSectionNameUNSAFE, int inBytesToAllocate, HANDLE *mappedFile)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(inSectionNameUNSAFE));
- PRECONDITION(inBytesToAllocate % 4 == 0);
- PRECONDITION(inBytesToAllocate > 0);
- PRECONDITION(CheckPointer(mappedFile));
- } CONTRACTL_END;
-
- // Need a place for our result
- LPVOID pResult = NULL;
-
- STRINGREF inString(inSectionNameUNSAFE);
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(inString);
-
- _ASSERTE(inBytesToAllocate % 4 == 0); // Expected 4 bytes boundaries so we don't get unaligned
- _ASSERTE(inBytesToAllocate > 0); // Pointless to have <=0 allocation
-
- StackSString inNameStackBuffer (inString->GetBuffer());
- pResult = NLSTable::OpenOrCreateMemoryMapping((LPCWSTR)inNameStackBuffer, inBytesToAllocate, mappedFile);
-
- // Worst case allocate some memory, use holder
- // if (pResult == NULL) pResult = new BYTE[inBytesToAllocate];
- if (pResult == NULL)
- {
- // Need to use a NewHolder
- NewArrayHolder<BYTE> holder (new BYTE[inBytesToAllocate]);
- pResult = holder;
- // Zero out the mapCodePageCached field (an int value, and it's used to check if the section is initialized or not.)
- BYTE* pByte = (BYTE*)pResult;
- FillMemory(pByte + inBytesToAllocate - sizeof(int), sizeof(int), 0);
- holder.SuppressRelease();
- }
-
- HELPER_METHOD_FRAME_END();
-
- return pResult;
-}
-FCIMPLEND
-#endif // FEATURE_CODEPAGES_FILE
-
-// InternalIsSortable
-//
-// Called by CompareInfo.IsSortable() to determine if a string has entirely sortable (ie: defined) code points.
-BOOL QCALLTYPE COMNlsInfo::InternalIsSortable(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName, LPCWSTR string, INT32 length)
-{
- CONTRACTL
- {
- QCALL_CHECK;
- PRECONDITION(CheckPointer(string));
- } CONTRACTL_END;
- BOOL result = FALSE;
- BEGIN_QCALL;
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- if(!(curDomain->m_bUseOsSorting))
- {
- handle = EnsureValidSortHandle(handle, handleOrigin, localeName);
- result = SortVersioning::SortDllIsDefinedString((SortVersioning::PSORTHANDLE) handle, COMPARE_STRING, 0, string, length);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- result = (curDomain->m_pCustomSortLibrary->pIsNLSDefinedString)(COMPARE_STRING, 0, NULL, string, length);
- }
- else
-#endif
- {
- // Function should be COMPARE_STRING, dwFlags should be NULL, lpVersionInfo should be NULL for now
- result = NewApis::IsNLSDefinedString(COMPARE_STRING, 0, NULL, string, length);
- }
-
- END_QCALL;
- return result;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//
-// InternalGetUserDefaultLocaleName
-//
-// Returns a string with the name of our LCID and returns 0 in LCID.
-// If we cant return
-//
-////////////////////////////////////////////////////////////////////////////
-// This is new to longhorn
-BOOL QCALLTYPE COMNlsInfo::InternalGetDefaultLocaleName(INT32 langType, QCall::StringHandleOnStack defaultLocaleName)
-{
- CONTRACTL
- {
- QCALL_CHECK;
- PRECONDITION((langType == LOCALE_SYSTEM_DEFAULT) || (langType == LOCALE_USER_DEFAULT));
- } CONTRACTL_END;
-
- BOOL result;
- BEGIN_QCALL;
-
- WCHAR strName[LOCALE_NAME_MAX_LENGTH];
- int size = 0;
-
- if (langType == LOCALE_SYSTEM_DEFAULT)
- {
- size = NewApis::GetSystemDefaultLocaleName(strName,NumItems(strName));
- }
- else
- {
- _ASSERT(langType == LOCALE_USER_DEFAULT);
- size = NewApis::GetUserDefaultLocaleName(strName,NumItems(strName));
- }
-
- // Not found, either not longhorn (no LOCALE_SNAME) or not a valid name
- if (size == 0)
- {
- result = false;
- }
- else
- {
- defaultLocaleName.Set(strName);
- result = true;
- }
- END_QCALL;
- return result;
-}
-
-BOOL QCALLTYPE COMNlsInfo::InternalGetSystemDefaultUILanguage(QCall::StringHandleOnStack systemDefaultUiLanguage)
-{
- QCALL_CONTRACT;
- BOOL result;
- BEGIN_QCALL;
-
- WCHAR localeName[LOCALE_NAME_MAX_LENGTH];
-
- int systemDefaultUiLcid = GetSystemDefaultUILanguage();
- if(systemDefaultUiLcid == LANGID_ZH_TW)
- {
- if (!NewApis::IsZhTwSku())
- {
- systemDefaultUiLcid = LANGID_ZH_HK;
- }
- }
-
- int length = NewApis::LCIDToLocaleName(systemDefaultUiLcid, localeName, NumItems(localeName), 0);
- if (length == 0)
- {
- result = false;
- }
- else
- {
- systemDefaultUiLanguage.Set(localeName);
- result = true;
- }
-
- END_QCALL;
- return result;
-}
-
-/*
- */
-BOOL QCALLTYPE COMNlsInfo::InternalGetUserDefaultUILanguage(QCall::StringHandleOnStack userDefaultUiLanguage)
-{
- QCALL_CONTRACT;
- BOOL result;
- BEGIN_QCALL;
-
- WCHAR wszBuffer[LOCALE_NAME_MAX_LENGTH];
- LPCWSTR wszLangName=NULL;
-
- int res= 0;
- ULONG uLangCount=0;
- ULONG uBufLen=0;
- res= NewApis::GetUserPreferredUILanguages (MUI_LANGUAGE_NAME,&uLangCount,NULL,&uBufLen);
- if (res == 0)
- ThrowLastError();
-
-
- NewArrayHolder<WCHAR> sPreferredLanguages(NULL);
-
- if (uBufLen > 0 && uLangCount > 0 )
- {
- sPreferredLanguages = new WCHAR[uBufLen];
- res= NewApis::GetUserPreferredUILanguages (MUI_LANGUAGE_NAME,&uLangCount,sPreferredLanguages,&uBufLen);
-
- if (res == 0)
- ThrowLastError();
-
- wszLangName=sPreferredLanguages;
-// Review size_t to int conversion (possible loss of data).
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4267)
-#endif
- res=wcslen(wszLangName)+1;
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
- }
- else
- {
- res=0;
- }
-
- if (res == 0) {
- res = NewApis::GetUserDefaultLocaleName(wszBuffer,NumItems(wszBuffer));
- wszLangName=wszBuffer;
- }
-
-
- // If not found, either not longhorn (no LOCALE_SNAME) or not a valid name
- if (res == 0)
- {
- // Didn't find string, return an empty string.
- result = false;
- }
- else
- {
- userDefaultUiLanguage.Set(wszLangName);
- result = true;
- }
-
- // Return the found language name. LCID should be found one already.
- END_QCALL;
- return result;
-}
-
-// Added but disabled from desktop in .NET 4.0, stayed disabled in .NET 4.5
-#ifdef FEATURE_CORECLR
-FCIMPL0(Object*, COMNlsInfo::nativeGetResourceFallbackArray)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- } CONTRACTL_END;
-
- DWORD dwFlags = MUI_MERGE_USER_FALLBACK | MUI_MERGE_SYSTEM_FALLBACK;
- ULONG cchLanguagesBuffer = 0;
- ULONG ulNumLanguages = 0;
- BOOL result = FALSE;
-
- struct _gc
- {
- PTRARRAYREF resourceFallbackArray;
- } gc;
-
- gc.resourceFallbackArray = NULL;
-
- // If the resource lookups we're planning on doing are going to be written to a non-Unicode console,
- // then we should ideally only return languages that can be displayed correctly on the console. The
- // trick is guessing at whether we're writing this data to the console, which we can't do well.
- // Instead, we ask new apps to call GetConsoleFallbackUICulture & fall back to en-US.
- bool disableUserFallback;
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), FCThrow(kStackOverflowException));
- disableUserFallback = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Resources_DisableUserPreferredFallback) == 1
- END_SO_INTOLERANT_CODE;
-
- if (disableUserFallback)
- return NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- // first call with null buffer to get size
- result = NewApis::GetThreadPreferredUILanguages(dwFlags, &ulNumLanguages, NULL, &cchLanguagesBuffer);
- if (cchLanguagesBuffer > 0)
- {
- NewArrayHolder<WCHAR> stringBuffer = new (nothrow) WCHAR[cchLanguagesBuffer];
- if (stringBuffer != NULL)
- {
- result = NewApis::GetThreadPreferredUILanguages(dwFlags, &ulNumLanguages, stringBuffer, &cchLanguagesBuffer);
- _ASSERTE(result);
-
- // now string into strings
- gc.resourceFallbackArray = (PTRARRAYREF) AllocateObjectArray(ulNumLanguages, g_pStringClass);
-
- LPCWSTR buffer = stringBuffer; // Restart @ buffer beginning
- for(DWORD i = 0; i < ulNumLanguages; i++)
- {
- OBJECTREF o = (OBJECTREF) StringObject::NewString(buffer);
- gc.resourceFallbackArray->SetAt(i, o);
- buffer += (lstrlenW(buffer) + 1);
- }
- }
- }
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.resourceFallbackArray);
-
-}
-FCIMPLEND
-#endif // FEATURE_CORECLR
INT32 COMNlsInfo::CallGetUserDefaultUILanguage()
{
@@ -488,1267 +86,12 @@ INT32 COMNlsInfo::CallGetUserDefaultUILanguage()
return s_lcid;
}
-INT_PTR COMNlsInfo::EnsureValidSortHandle(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName)
-{
- LIMITED_METHOD_CONTRACT;
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- if(!(curDomain->m_bUseOsSorting) && handleOrigin == (INT_PTR) SortVersioning::GetSortHandle && ((SortVersioning::PSORTHANDLE) handle)->dwNLSVersion == curDomain->m_sortVersion)
- {
- return handle;
- }
-
- if(curDomain->m_bUseOsSorting && curDomain->m_pCustomSortLibrary == NULL && handleOrigin == (INT_PTR) NewApis::LCMapStringEx)
- {
- return handle;
- }
-
- if(curDomain->m_bUseOsSorting && curDomain->m_pCustomSortLibrary != NULL && handleOrigin == (INT_PTR) curDomain->m_pCustomSortLibrary->pLCMapStringEx)
- {
- return handle;
- }
-
- // At this point, we can't reuse the sort handle (it has different sort semantics than this domain) so we need to get a new one.
- INT_PTR newHandleOrigin;
- return InitSortHandleHelper(localeName, &newHandleOrigin);
-#else
- // For CoreCLR, on Windows 8 and up the handle will be valid. on downlevels the handle will be null
- return handle;
-#endif
-}
-
-#ifdef FEATURE_SYNTHETIC_CULTURES
-////////////////////////////////////////////////////////////////////////////
-//
-// WstrToInteger4
-//
-////////////////////////////////////////////////////////////////////////////
-
-/*=================================WstrToInteger4==================================
-**Action: Convert a Unicode string to an integer. Error checking is ignored.
-**Returns: The integer value of wstr
-**Arguments:
-** wstr: NULL terminated wide string. Can have character 0'-'9', 'a'-'f', and 'A' - 'F'
-** Radix: radix to be used in the conversion.
-**Exceptions: None.
-==============================================================================*/
-
-INT32 COMNlsInfo::WstrToInteger4(
- __in_z LPCWSTR wstr,
- __in int Radix)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- SO_TOLERANT;
- PRECONDITION(CheckPointer(wstr));
- PRECONDITION(Radix > 1 && Radix <= 16);
- } CONTRACTL_END;
- INT32 Value = 0;
- int Base = 1;
-
- for (int Length = Wszlstrlen(wstr) - 1; Length >= 0; Length--)
-
- {
- WCHAR ch = wstr[Length];
- _ASSERTE((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'));
- if (ch >= 'a')
- {
- ch = ch - 'a' + 'A';
- }
-
- Value += ((ch >= 'A') ? (ch - 'A' + 10) : (ch - '0')) * Base;
- Base *= Radix;
- }
-
- return (Value);
-}
-#endif // FEATURE_SYNTHETIC_CULTURES
-
-
-#ifndef FEATURE_CORECLR
-FCIMPL1(FC_BOOL_RET, COMNlsInfo::nativeSetThreadLocale, StringObject* localeNameUNSAFE)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- LCID lcid = 0;
-
- // TODO: NLS Arrowhead -A bit scary becausue Set ThreadLocale can't handle custom cultures?
- STRINGREF localeName = (STRINGREF)localeNameUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(localeName);
- lcid=NewApis::LocaleNameToLCID(localeName->GetBuffer(),0);
- if (lcid == 0)
- {
- ThrowHR(HRESULT_FROM_WIN32(GetLastError()));
- }
- HELPER_METHOD_FRAME_END();
-
-
- BOOL result = TRUE;
-
- // SetThreadLocale doesn't handle names/custom cultures
-#ifdef _MSC_VER
-// Get rid of the SetThreadLocale warning in OACR:
-#pragma warning(push)
-#pragma warning(disable:38010)
-#endif
- result = ::SetThreadLocale(lcid);
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
- FC_RETURN_BOOL(result);
-}
-FCIMPLEND
-#endif
-
-
-FCIMPL2(Object*, COMNlsInfo::nativeGetLocaleInfoEx, StringObject* localeNameUNSAFE, INT32 lcType)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- struct _gc
- {
- STRINGREF localeName;
- STRINGREF refRetVal;
- } gc;
-
- // Dereference our string
- gc.refRetVal = NULL;
- gc.localeName = (STRINGREF)localeNameUNSAFE;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
- StackSString localeNameStackBuffer( gc.localeName->GetBuffer() );
-
- WCHAR buffer[LOCALE_MAX_STRING_SIZE];
- int result = NewApis::GetLocaleInfoEx(localeNameStackBuffer, lcType, buffer, NumItems(buffer));
-
- // Make a string out of it
- if (result != 0)
- {
- // Exclude the NULL char at the end, except that LOCALE_FONTSIGNATURE isn't
- // really a string, so we need the last character too.
- gc.refRetVal = StringObject::NewString(buffer, ((lcType & ~LOCALE_NOUSEROVERRIDE) == LOCALE_FONTSIGNATURE) ? result : result-1);
- }
- else
- {
- }
- HELPER_METHOD_FRAME_END();
- return OBJECTREFToObject(gc.refRetVal);
-}
-FCIMPLEND
-
-
-FCIMPL2(INT32, COMNlsInfo::nativeGetLocaleInfoExInt, StringObject* localeNameUNSAFE, INT32 lcType)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- INT32 result = 0;
-
- // Dereference our string
- STRINGREF localeName = (STRINGREF)localeNameUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(localeName);
-
- lcType |= LOCALE_RETURN_NUMBER;
-
- if (NewApis::GetLocaleInfoEx(localeName->GetBuffer(), lcType, (LPWSTR)&result, sizeof(INT32) / sizeof (WCHAR)) == 0)
- {
- // return value of 0 indicates failure and error value is supposed to be set.
- // shouldn't ever really happen
- _ASSERTE(!"catastrophic failure calling NewApis::nativeGetLocaleInfoExInt! This could be a CultureInfo bug (bad localeName string) or maybe a GCHole.");
- }
-
- HELPER_METHOD_FRAME_END();
-
- return result;
-}
-FCIMPLEND
-
-
-
-////////////////////////////////////////////////////////////////////////
-//
-// Call the Win32 GetLocaleInfo() using the specified lcid to retrieve
-// the native digits, probably from the registry override. The return
-// indicates whether the call was successful.
-//
-// Parameters:
-// IN lcid the LCID to make the Win32 call with
-// OUT pOutputStrAry The output managed string array.
-//
-////////////////////////////////////////////////////////////////////////
-BOOL COMNlsInfo::GetNativeDigitsFromWin32(LPCWSTR locale, PTRARRAYREF * pOutputStrAry, BOOL useUserOverride)
-{
- CONTRACTL
- {
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- THROWS;
- } CONTRACTL_END;
-
- WCHAR buffer[11];
- int result = 0;
-
- DWORD lcType = LOCALE_SNATIVEDIGITS;
- if(!useUserOverride)
- {
- lcType |= LOCALE_NOUSEROVERRIDE;
- }
- result = NewApis::GetLocaleInfoEx(locale, lcType, buffer, 11);
- // Be very unforgiving and only support strings of size 10 plus the NULL
- if (result == 11)
- {
- // Break up the unmanaged ten-character ZLS into what NFI wants (a managed
- // ten-string array).
- //
- // Allocate the array of STRINGREFs. We don't need to check for null because the GC will throw
- // an OutOfMemoryException if there's not enough memory.
- //
- PTRARRAYREF DigitArray = (PTRARRAYREF) AllocateObjectArray(10, g_pStringClass);
-
- GCPROTECT_BEGIN(DigitArray);
- for(DWORD i = 0; i < 10; i++) {
- OBJECTREF o = (OBJECTREF) StringObject::NewString(buffer + i, 1);
- DigitArray->SetAt(i, o);
- }
- GCPROTECT_END();
-
- _ASSERTE(pOutputStrAry != NULL);
- *pOutputStrAry = DigitArray;
- }
-
- return (result == 11);
-}
-
-
-////////////////////////////////////////////////////////////////////////
-//
-// Call the Win32 GetLocaleInfoEx() using the specified lcid and LCTYPE.
-// The return value can be INT32 or an allocated managed string object, depending on
-// which version's called.
-//
-// Parameters:
-// OUT pOutputInt32 The output int32 value.
-// OUT pOutputRef The output string value.
-//
-////////////////////////////////////////////////////////////////////////
-BOOL COMNlsInfo::CallGetLocaleInfoEx(LPCWSTR localeName, int lcType, INT32* pOutputInt32, BOOL useUserOverride)
-{
- CONTRACTL
- {
- GC_NOTRIGGER;
- MODE_ANY;
- NOTHROW;
- } CONTRACTL_END;
-
- int result = 0;
-
- _ASSERT((lcType & LOCALE_RETURN_NUMBER) != 0);
- if(!useUserOverride)
- {
- lcType |= LOCALE_NOUSEROVERRIDE;
- }
- result = NewApis::GetLocaleInfoEx(localeName, lcType, (LPWSTR)pOutputInt32, sizeof(*pOutputInt32));
-
- return (result != 0);
-}
-
-BOOL COMNlsInfo::CallGetLocaleInfoEx(LPCWSTR localeName, int lcType, STRINGREF* pOutputStrRef, BOOL useUserOverride)
-{
- CONTRACTL
- {
- THROWS; // We can throw since we are allocating managed string.
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- } CONTRACTL_END;
-
- WCHAR buffer[LOCALE_NAME_MAX_LENGTH];
- int result = 0;
-
- _ASSERT((lcType & LOCALE_RETURN_NUMBER) == 0);
- if(!useUserOverride)
- {
- lcType |= LOCALE_NOUSEROVERRIDE;
- }
- result = NewApis::GetLocaleInfoEx(localeName, lcType, buffer, LOCALE_NAME_MAX_LENGTH);
-
- if (result != 0)
- {
- _ASSERTE(pOutputStrRef != NULL);
- *pOutputStrRef = StringObject::NewString(buffer, result - 1);
- }
-
- return (result != 0);
-}
-
-FCIMPL1(Object*, COMNlsInfo::LCIDToLocaleName, LCID lcid)
-{
- FCALL_CONTRACT;
-
- STRINGREF refRetVal = NULL;
-
- // The maximum size for locale name is 85 characters.
- WCHAR localeName[LOCALE_NAME_MAX_LENGTH];
- int result = 0;
-
- HELPER_METHOD_FRAME_BEGIN_RET_0();
-
- // Note that this'll return neutral names (unlike native Vista APIs)
- result = NewApis::LCIDToLocaleName(lcid, localeName, LOCALE_NAME_MAX_LENGTH, 0);
-
- if (result != 0)
- {
- refRetVal = StringObject::NewString(localeName, result - 1);
- }
- else
- {
- refRetVal = StringObject::GetEmptyString();
- }
-
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(refRetVal);
-}
-FCIMPLEND
-
-FCIMPL1(INT32, COMNlsInfo::LocaleNameToLCID, StringObject* localeNameUNSAFE)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- INT32 result = 0;
-
- // Dereference our string
- STRINGREF localeName = (STRINGREF)localeNameUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(localeName);
-
- // Note that this'll return neutral names (unlike native Vista APIs)
- result = NewApis::LocaleNameToLCID(localeName->GetBuffer(), 0);
-
- HELPER_METHOD_FRAME_END();
-
- return result;
-}
-FCIMPLEND
-
-////////////////////////////////////////////////////////////////////////
-//
-// Implementation of CultureInfo.nativeGetNumberFormatInfoValues.
-//
-// Retrieve NumberFormatInfo (NFI) properties from windows
-//
-// Parameters:
-// IN/OUT pNumfmtUNSAFE
-// The pointer of the managed NumberFormatInfo passed
-// from the managed side.
-// Note that the native NumberFormatInfo* is defined
-// in COMNumber.h
-// Note:
-// Managed string will be allocated and assign to the string fields in
-// the managed NumberFormatInfo passed in pNumftUNSAFE
-//
-////////////////////////////////////////////////////////////////////////
-
-
-/*
- This is the list of the data members in the managed NumberFormatInfo and their
- corresponding LCTYPE().
-
- Win32 GetLocaleInfo() constants Data members in NumberFormatInfo in the defined order.
- LOCALE_SPOSITIVE // String positiveSign
- LOCALE_SNEGATIVE // String negativeSign
- LOCALE_SDECIMAL // String numberDecimalSeparator
- LOCALE_SGROUPING // String numberGroupSeparator
- LOCALE_SMONGROUPING // String currencyGroupSeparator
- LOCALE_SMONDECIMALSEP // String currencyDecimalSeparator
- LOCALE_SCURRENCY // String currencySymbol
- N/A // String ansiCurrencySymbol
- N/A // String nanSymbol
- N/A // String positiveInfinitySymbol
- N/A // String negativeInfinitySymbol
- N/A // String percentDecimalSeparator
- N/A // String percentGroupSeparator
- N/A // String percentSymbol
- N/A // String perMilleSymbol
-
- N/A // int m_dataItem
-
- LOCALE_IDIGITS | LOCALE_RETURN_NUMBER, // int numberDecimalDigits
- LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER, // int currencyDecimalDigits
- LOCALE_ICURRENCY | LOCALE_RETURN_NUMBER, // int currencyPositivePattern
- LOCALE_INEGCURR | LOCALE_RETURN_NUMBER, // int currencyNegativePattern
- LOCALE_INEGNUMBER| LOCALE_RETURN_NUMBER, // int numberNegativePattern
- N/A // int percentPositivePattern
- N/A // int percentNegativePattern
- N/A // int percentDecimalDigits
- N/A // bool isReadOnly=false;
- N/A // internal bool m_useUserOverride;
-*/
-FCIMPL3(FC_BOOL_RET, COMNlsInfo::nativeGetNumberFormatInfoValues,
- StringObject* localeNameUNSAFE, NumberFormatInfo* pNumfmtUNSAFE, CLR_BOOL useUserOverride) {
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- BOOL ret = TRUE;
-
- struct _gc
- {
- STRINGREF localeName;
- STRINGREF stringResult;
- NUMFMTREF numfmt;
- PTRARRAYREF tempArray;
- } gc;
-
- // Dereference our string
- gc.localeName = (STRINGREF)localeNameUNSAFE;
- gc.numfmt = (NUMFMTREF) pNumfmtUNSAFE;
- gc.stringResult = NULL;
- gc.tempArray = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
- StackSString localeNameStackBuffer( gc.localeName->GetBuffer() );
-
- // Calling SString::ConvertToUnicode once
- LPCWSTR pLocaleName = localeNameStackBuffer;
-
- //
- // NOTE: We pass the stringResult allocated in the stack and assign it to the fields
- // in numfmt after calling CallGetLocaleInfo(). The reason for this is that CallGetLocaleInfo()
- // allocates a string object, and it may trigger a GC and cause numfmt to be moved.
- // That's why we use the stringResult allocated in the stack since it will not be moved.
- // After CallGetLocaleInfo(), we know that numfmt will not be moved, and it's safe to assign
- // the stringResult to its field.
- //
-
- // String values
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_SPOSITIVESIGN , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sPositive), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
-
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_SNEGATIVESIGN , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sNegative), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_SDECIMAL , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sNumberDecimal), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_STHOUSAND , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sNumberGroup), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_SMONTHOUSANDSEP , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sCurrencyGroup), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_SMONDECIMALSEP , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sCurrencyDecimal), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
- if (CallGetLocaleInfoEx(pLocaleName, LOCALE_SCURRENCY , &gc.stringResult, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sCurrency), gc.stringResult, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
-
-
- // Numeric values
- ret &= CallGetLocaleInfoEx(pLocaleName, LOCALE_IDIGITS | LOCALE_RETURN_NUMBER , &(gc.numfmt->cNumberDecimals), useUserOverride);
- _ASSERT(ret == TRUE);
- ret &= CallGetLocaleInfoEx(pLocaleName, LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER , &(gc.numfmt->cCurrencyDecimals), useUserOverride);
- _ASSERT(ret == TRUE);
- ret &= CallGetLocaleInfoEx(pLocaleName, LOCALE_ICURRENCY | LOCALE_RETURN_NUMBER , &(gc.numfmt->cPosCurrencyFormat), useUserOverride);
- _ASSERT(ret == TRUE);
- ret &= CallGetLocaleInfoEx(pLocaleName, LOCALE_INEGCURR | LOCALE_RETURN_NUMBER , &(gc.numfmt->cNegCurrencyFormat), useUserOverride);
- _ASSERT(ret == TRUE);
- ret &= CallGetLocaleInfoEx(pLocaleName, LOCALE_INEGNUMBER| LOCALE_RETURN_NUMBER , &(gc.numfmt->cNegativeNumberFormat), useUserOverride);
- _ASSERT(ret == TRUE);
- ret &= CallGetLocaleInfoEx(pLocaleName, LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER, &(gc.numfmt->iDigitSubstitution), useUserOverride);
- _ASSERT(ret == TRUE);
-
- // LOCALE_SNATIVEDIGITS (gc.tempArray of strings)
- if (GetNativeDigitsFromWin32(pLocaleName, &gc.tempArray, useUserOverride)) {
- SetObjectReference((OBJECTREF*)&(gc.numfmt->sNativeDigits), gc.tempArray, NULL);
- }
- else {
- ret = FALSE;
- _ASSERT(FALSE);
- }
-
- HELPER_METHOD_FRAME_END();
- FC_RETURN_BOOL(ret);
-}
-FCIMPLEND
-
-
-////////////////////////////////////////////////////////////////////////
-//
-// Culture enumeration helper functions
-//
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Enum values for System.Globalization.CultureTypes
-//
-////////////////////////////////////////////////////////////////////////////
-
-// Neutral cultures are cultures like "en", "de", "zh", etc, for enumeration this includes ALL neutrals regardless of other flags
-#define CULTURETYPES_NEUTRALCULTURES 0x0001
-
-// Non-netural cultuers. Examples are "en-us", "zh-tw", etc., for enumeration this includes ALL specifics regardless of other flags
-#define CULTURETYPES_SPECIFICCULTURES 0x0002
-
-// Win32 installed cultures in the system and exists in the framework too., this is effectively all cultures
-#define CULTURETYPES_INSTALLEDWIN32CULTURES 0x0004
-
-// User defined custom culture
-#define CULTURETYPES_USERCUSTOMCULTURE 0x0008
-
-// User defined replacement custom culture.
-#define CULTURETYPES_REPLACEMENTCULTURES 0x0010
-// [Obsolete("This value has been deprecated. Please use other values in CultureTypes.")]
-// Culture exists in Win32 but not in the Framework. // TODO: All cultures or no cultures?
-#define CULTURETYPES_WINDOWSONLYCULTURES 0x0020
-// [Obsolete("This value has been deprecated. Please use other values in CultureTypes.")]
-// the language tag match a culture that ships with the .NET framework, effectively all cultures since we get them from windows
-#define CULTURETYPES_FRAMEWORKCULTURES 0x0040
-
-
-const LPCWSTR WHIDBEY_FRAMEWORK_CULTURE_LIST [] =
-{
- W(""),
- W("af"),
- W("af-za"),
- W("ar"),
- W("ar-ae"),
- W("ar-bh"),
- W("ar-dz"),
- W("ar-eg"),
- W("ar-iq"),
- W("ar-jo"),
- W("ar-kw"),
- W("ar-lb"),
- W("ar-ly"),
- W("ar-ma"),
- W("ar-om"),
- W("ar-qa"),
- W("ar-sa"),
- W("ar-sy"),
- W("ar-tn"),
- W("ar-ye"),
- W("az"),
- W("az-cyrl-az"),
- W("az-latn-az"),
- W("be"),
- W("be-by"),
- W("bg"),
- W("bg-bg"),
- W("ca"),
- W("ca-es"),
- W("cs"),
- W("cs-cz"),
- W("da"),
- W("da-dk"),
- W("de"),
- W("de-at"),
- W("de-ch"),
- W("de-de"),
- W("de-li"),
- W("de-lu"),
- W("dv"),
- W("dv-mv"),
- W("el"),
- W("el-gr"),
- W("en"),
- W("en-029"),
- W("en-au"),
- W("en-bz"),
- W("en-ca"),
- W("en-gb"),
- W("en-ie"),
- W("en-jm"),
- W("en-nz"),
- W("en-ph"),
- W("en-tt"),
- W("en-us"),
- W("en-za"),
- W("en-zw"),
- W("es"),
- W("es-ar"),
- W("es-bo"),
- W("es-cl"),
- W("es-co"),
- W("es-cr"),
- W("es-do"),
- W("es-ec"),
- W("es-es"),
- W("es-gt"),
- W("es-hn"),
- W("es-mx"),
- W("es-ni"),
- W("es-pa"),
- W("es-pe"),
- W("es-pr"),
- W("es-py"),
- W("es-sv"),
- W("es-uy"),
- W("es-ve"),
- W("et"),
- W("et-ee"),
- W("eu"),
- W("eu-es"),
- W("fa"),
- W("fa-ir"),
- W("fi"),
- W("fi-fi"),
- W("fo"),
- W("fo-fo"),
- W("fr"),
- W("fr-be"),
- W("fr-ca"),
- W("fr-ch"),
- W("fr-fr"),
- W("fr-lu"),
- W("fr-mc"),
- W("gl"),
- W("gl-es"),
- W("gu"),
- W("gu-in"),
- W("he"),
- W("he-il"),
- W("hi"),
- W("hi-in"),
- W("hr"),
- W("hr-hr"),
- W("hu"),
- W("hu-hu"),
- W("hy"),
- W("hy-am"),
- W("id"),
- W("id-id"),
- W("is"),
- W("is-is"),
- W("it"),
- W("it-ch"),
- W("it-it"),
- W("ja"),
- W("ja-jp"),
- W("ka"),
- W("ka-ge"),
- W("kk"),
- W("kk-kz"),
- W("kn"),
- W("kn-in"),
- W("ko"),
- W("ko-kr"),
- W("kok"),
- W("kok-in"),
- W("ky"),
- W("ky-kg"),
- W("lt"),
- W("lt-lt"),
- W("lv"),
- W("lv-lv"),
- W("mk"),
- W("mk-mk"),
- W("mn"),
- W("mn-mn"),
- W("mr"),
- W("mr-in"),
- W("ms"),
- W("ms-bn"),
- W("ms-my"),
- W("nb-no"),
- W("nl"),
- W("nl-be"),
- W("nl-nl"),
- W("nn-no"),
- W("no"),
- W("pa"),
- W("pa-in"),
- W("pl"),
- W("pl-pl"),
- W("pt"),
- W("pt-br"),
- W("pt-pt"),
- W("ro"),
- W("ro-ro"),
- W("ru"),
- W("ru-ru"),
- W("sa"),
- W("sa-in"),
- W("sk"),
- W("sk-sk"),
- W("sl"),
- W("sl-si"),
- W("sq"),
- W("sq-al"),
- W("sr"),
- W("sr-cyrl-cs"),
- W("sr-latn-cs"),
- W("sv"),
- W("sv-fi"),
- W("sv-se"),
- W("sw"),
- W("sw-ke"),
- W("syr"),
- W("syr-sy"),
- W("ta"),
- W("ta-in"),
- W("te"),
- W("te-in"),
- W("th"),
- W("th-th"),
- W("tr"),
- W("tr-tr"),
- W("tt"),
- W("tt-ru"),
- W("uk"),
- W("uk-ua"),
- W("ur"),
- W("ur-pk"),
- W("uz"),
- W("uz-cyrl-uz"),
- W("uz-latn-uz"),
- W("vi"),
- W("vi-vn"),
- W("zh-chs"),
- W("zh-cht"),
- W("zh-cn"),
- W("zh-hans"),
- W("zh-hant"),
- W("zh-hk"),
- W("zh-mo"),
- W("zh-sg"),
- W("zh-tw")
-};
-#define WHIDBEY_FRAMEWORK_CULTURE_LIST_LENGTH (sizeof(WHIDBEY_FRAMEWORK_CULTURE_LIST) / sizeof(WHIDBEY_FRAMEWORK_CULTURE_LIST[0]))
-
-////////////////////////////////////////////////////////////////////////////
-//
-// NlsCompareInvariantNoCase
-//
-// This routine does fast caseless comparison without needing the tables.
-// This helps us do the comparisons we need to load the tables :-)
-//
-// Returns 0 if identical, <0 if pFirst if first string sorts first.
-//
-// This is only intended to help with our locale name comparisons,
-// which are effectively limited to A-Z, 0-9, a-z and - where A-Z and a-z
-// compare as equal.
-//
-// WARNING: [\]^_` will be less than A-Z because we make everything lower
-// case before comparing them.
-//
-// When bNullEnd is TRUE, both of the strings should be null-terminator to be considered equal.
-// When bNullEnd is FALSE, the strings are considered equal when we reach the number of characters specifed by size
-// or when null terminators are reached, whichever happens first (strncmp-like behavior)
-//
-////////////////////////////////////////////////////////////////////////////
-
-int NlsCompareInvariantNoCase(
- LPCWSTR pFirst,
- LPCWSTR pSecond,
- int size,
- BOOL bNullEnd)
-{
- int i=0;
- WCHAR first;
- WCHAR second;
-
- for (;
- size > 0 && (first = *pFirst) != 0 && (second = *pSecond) != 0;
- size--, pFirst++, pSecond++)
- {
- // Make them lower case
- if ((first >= 'A') && (first <= 'Z')) first |= 0x20;
- if ((second >= 'A') && (second <= 'Z')) second |= 0x20;
-
- // Get the diff
- i = (first - second);
-
- // Are they the same?
- if (i == 0)
- continue;
-
- // Otherwise the difference. Remember we made A-Z into lower case, so
- // the characters [\]^_` will sort < A-Z and also < a-z. (Those are the
- // characters between A-Z and a-Z in ascii)
- return i;
- }
-
- // When we are here, one of these holds:
- // size == 0
- // or one of the strings has a null terminator
- // or both of the string reaches null terminator
-
- if (bNullEnd || size != 0)
- {
- // If bNullEnd is TRUE, always check for null terminator.
- // If bNullEnd is FALSE, we still have to check if one of the strings is terminated eariler
- // than another (hense the size != 0 check).
-
- // See if one string ended first
- if (*pFirst != 0 || *pSecond != 0)
- {
- // Which one?
- return *pFirst == 0 ? -1 : 1;
- }
- }
-
- // Return our difference (0)
- return i;
-}
-
-BOOL IsWhidbeyFrameworkCulture(__in LPCWSTR lpLocaleString)
-{
- int iBottom = 0;
- int iTop = WHIDBEY_FRAMEWORK_CULTURE_LIST_LENGTH - 1;
-
- // Do a binary search for our name
- while (iBottom <= iTop)
- {
- int iMiddle = (iBottom + iTop) / 2;
- int result = NlsCompareInvariantNoCase(lpLocaleString, WHIDBEY_FRAMEWORK_CULTURE_LIST[iMiddle], LOCALE_NAME_MAX_LENGTH, TRUE);
- if (result == 0)
- {
- return TRUE;
- }
- if (result < 0)
- {
- // pLocaleName was < pTest
- iTop = iMiddle - 1;
- }
- else
- {
- // pLocaleName was > pTest
- iBottom = iMiddle + 1;
- }
- }
-
- return FALSE;
-}
-
-// Just Check to see if the OS thinks it is a valid locle
-BOOL WINAPI IsOSValidLocaleName(__in LPCWSTR lpLocaleName, bool bIsNeutralLocale)
-{
-#ifndef ENABLE_DOWNLEVEL_FOR_NLS
- return ::IsValidLocaleName(lpLocaleName);
-#else
- BOOL IsWindows7 = NewApis::IsWindows7Platform();
- // if we're < Win7, we didn't know about neutrals or the invariant.
- if (!IsWindows7 && (bIsNeutralLocale || (lpLocaleName[0] == 0)))
- {
- return false;
- }
-
- // Work around the name/lcid thingy (can't just link to ::IsValidLocaleName())
- LCID lcid = NewApis::LocaleNameToLCID(lpLocaleName, 0);
-
- if (IsCustomCultureId(lcid))
- {
- return false;
- }
-
- if (bIsNeutralLocale)
- {
- // In this case, we're running on Windows 7.
- // For neutral locales, use GetLocaleInfoW.
- // If GetLocaleInfoW works, then the OS knows about it.
- return (::GetLocaleInfoW(lcid, LOCALE_ILANGUAGE, NULL, 0) != 0);
- }
-
- // This is not a custom locale.
- // Call IsValidLocale() to check if the LCID is installed.
- // IsValidLocale doesn't work for neutral locales.
- return IsValidLocale(lcid, LCID_INSTALLED);
-#endif
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Check the dwFlags, which has the 'attributes' of the locale, and decide
-// if the locale should be included in the enumeration based on
-// the desired CultureTypes.
-//
-////////////////////////////////////////////////////////////////////////////
-
-BOOL ShouldIncludeByCultureType(INT32 cultureTypes, LPCWSTR lpLocaleString, INT32 dwFlags)
-{
-
- if ((cultureTypes & CULTURETYPES_NEUTRALCULTURES) &&
- ((dwFlags & LOCALE_NEUTRALDATA) || (lpLocaleString[0] == 0))) // Invariant culture get enumerated with the neutrals
- {
- return TRUE;
- }
-
- if ((cultureTypes & CULTURETYPES_SPECIFICCULTURES) &&
- ((dwFlags & LOCALE_SPECIFICDATA) && (lpLocaleString[0] != 0))) // Invariant culture does not get enumerated with the specifics
- {
- return TRUE;
- }
-
- if (cultureTypes & CULTURETYPES_INSTALLEDWIN32CULTURES)
- {
- // The user asks for installed Win32 culture, so check
- // if this locale is installed. In W7 and above, when ::IsValidLocaleName()
- // returns true, it means that it is installed.
- // In downlevel (including Vista), we will convert the name to LCID.
- // When the LCID is not a custom locale, we will call ::IsValidLocale(.., LCID_INSTALLED)
- // to verify if the locale is installed.
- // In Vista, we treat custom locale as installed.
- if (IsOSValidLocaleName(lpLocaleString, (dwFlags & LOCALE_NEUTRALDATA) == LOCALE_NEUTRALDATA))
- {
- return TRUE;
- }
- }
-
- if ((cultureTypes & CULTURETYPES_USERCUSTOMCULTURE) &&
- (dwFlags & LOCALE_SUPPLEMENTAL))
- {
- return TRUE;
- }
-
- if ((cultureTypes & CULTURETYPES_REPLACEMENTCULTURES) &&
- (dwFlags & LOCALE_REPLACEMENT))
- {
- return TRUE;
- }
-
- if ((cultureTypes & CULTURETYPES_FRAMEWORKCULTURES) &&
- IsWhidbeyFrameworkCulture(lpLocaleString))
- {
- return TRUE;
- }
-
- //
- // No need to check CULTURETYPES_WINDOWSONLYCULTURES and CULTURETYPES_FRAMEWORKCULTURES
- // since they are deprecated, and they are handled in the managed code before calling
- // nativeEnumCultureNames.
- //
-
- return FALSE;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Struct to hold context to be used in the callback for
-// EnumLocaleProcessingCallback
-//
-////////////////////////////////////////////////////////////////////////////
-
-typedef struct
-{
- PTRARRAYREF pCultureNamesArray;
- INT32 count;
- INT32 cultureTypes;
-} ENUM_LOCALE_DATA;
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Callback for NewApis::EnumSystemLocalesEx to count the number of
-// locales to be enumerated.
-//
-////////////////////////////////////////////////////////////////////////////
-
-BOOL CALLBACK EnumLocaleCountCallback(__in_z LPCWSTR lpLocaleString, __in DWORD dwFlags, __in LPARAM lParam)
-{
- ENUM_LOCALE_DATA* pData = (ENUM_LOCALE_DATA*)lParam;
-
- if (ShouldIncludeByCultureType(pData->cultureTypes, lpLocaleString, dwFlags))
- {
- (pData->count)++;
- }
- return TRUE;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Callback for NewApis::EnumSystemLocalesEx to add the locale name
-// into the allocated managed string array.
-//
-////////////////////////////////////////////////////////////////////////////
-
-BOOL CALLBACK EnumLocaleProcessingCallback(__in_z LPCWSTR lpLocaleString, __in DWORD dwFlags, __in LPARAM lParam)
-{
- ENUM_LOCALE_DATA* pData = (ENUM_LOCALE_DATA*)lParam;
-
- if (ShouldIncludeByCultureType(pData->cultureTypes, lpLocaleString, dwFlags))
- {
- GCX_COOP();
-
- GCPROTECT_BEGIN(pData->pCultureNamesArray);
-
- OBJECTREF cultureString = (OBJECTREF) StringObject::NewString(lpLocaleString);
- pData->pCultureNamesArray->SetAt(pData->count, cultureString);
- pData->count++;
-
- GCPROTECT_END();
- }
-
- return TRUE;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-//
-// Called by CultureData.GetCultures() to enumerate the names of cultures.
-// It first calls NewApis::EnumSystemLocalesEx to count the number of
-// locales to be enumerated. And it will allocate an managed string
-// array with the count. And fill the array with the culture names in
-// the 2nd call to NewAPis::EnumSystemLocalesEx.
-//
-////////////////////////////////////////////////////////////////////////////
-
-
-int QCALLTYPE COMNlsInfo::nativeEnumCultureNames(INT32 cultureTypes, QCall::ObjectHandleOnStack retStringArray)
-{
- CONTRACTL
- {
- QCALL_CHECK;
- // Check CultureTypes.WindowsOnlyCultures and CultureTYpes.FrameworkCultures are deprecated and is
- // handled in the managed code side to provide fallback behavior.
- //PRECONDITION((cultureTypes & (CULTURETYPES_WINDOWSONLYCULTURES | CULTURETYPES_FRAMEWORKCULTURES) == 0));
- } CONTRACTL_END;
-
-
- int result;
- DWORD dwFlags = 0;
- PTRARRAYREF cultureNamesArray = NULL;
- ENUM_LOCALE_DATA enumData = { NULL, 0, cultureTypes};
-
- BEGIN_QCALL;
-
- //
- // if CultureTypes.FrameworkCulture is specified we'll enumerate all cultures
- // and filter according to the Whidbey framework culture list (for compatibility)
- //
-
- if (cultureTypes & CULTURETYPES_FRAMEWORKCULTURES)
- {
- dwFlags |= LOCALE_NEUTRALDATA | LOCALE_SPECIFICDATA;
- }
-
- // Map CultureTypes to Windows enumeration values.
- if (cultureTypes & CULTURETYPES_NEUTRALCULTURES)
- {
- dwFlags |= LOCALE_NEUTRALDATA;
- }
-
- if (cultureTypes & CULTURETYPES_SPECIFICCULTURES)
- {
- dwFlags |= LOCALE_SPECIFICDATA;
- }
-
- if (cultureTypes & CULTURETYPES_INSTALLEDWIN32CULTURES)
- {
- // Windows 7 knows about neutrals, whereas Vista and lower don't.
- if (NewApis::IsWindows7Platform())
- {
- dwFlags |= LOCALE_SPECIFICDATA | LOCALE_NEUTRALDATA;
- }
- else
- {
- dwFlags |= LOCALE_SPECIFICDATA;
- }
- }
-
- dwFlags |= (cultureTypes & CULTURETYPES_USERCUSTOMCULTURE) ? LOCALE_SUPPLEMENTAL: 0;
-
- // We need special handling for Replacement cultures because Windows does not have a way to enumerate it directly.
- // Replacement locale check will be only used when CultureTypes.SpecificCultures is NOT used.
- dwFlags |= (cultureTypes & CULTURETYPES_REPLACEMENTCULTURES) ? LOCALE_SPECIFICDATA | LOCALE_NEUTRALDATA: 0;
-
-
- result = NewApis::EnumSystemLocalesEx((LOCALE_ENUMPROCEX)EnumLocaleCountCallback, dwFlags, (LPARAM)&enumData, NULL) == TRUE ? 1 : 0;
-
- if (result)
- {
-
- GCX_COOP();
-
- GCPROTECT_BEGIN(cultureNamesArray);
-
- // Now we need to allocate our culture names string array and populate it
- // Get our array object (will throw, don't have to check it)
- cultureNamesArray = (PTRARRAYREF) AllocateObjectArray(enumData.count, g_pStringClass);
-
- // In the context struct passed to EnumSystemLocalesEx, reset the count and assign the newly allocated string array
- // to hold culture names to be enumerated.
- enumData.count = 0;
- enumData.pCultureNamesArray = cultureNamesArray;
-
- result = NewApis::EnumSystemLocalesEx((LOCALE_ENUMPROCEX)EnumLocaleProcessingCallback, dwFlags, (LPARAM)&enumData, NULL);
-
- if (result)
- {
- retStringArray.Set(cultureNamesArray);
- }
- GCPROTECT_END();
- }
- END_QCALL
-
- return result;
-
-}
-
-//
-// InternalCompareString is used in the managed side to handle the synthetic CompareInfo methods (IndexOf, LastIndexOf, IsPrfix, and IsSuffix)
-//
-INT32 QCALLTYPE COMNlsInfo::InternalCompareString(
- INT_PTR handle,
- INT_PTR handleOrigin,
- LPCWSTR localeName,
- LPCWSTR string1, INT32 offset1, INT32 length1,
- LPCWSTR string2, INT32 offset2, INT32 length2,
- INT32 flags)
-{
- CONTRACTL
- {
- QCALL_CHECK;
- PRECONDITION(CheckPointer(string1));
- PRECONDITION(CheckPointer(string2));
- PRECONDITION(CheckPointer(localeName));
- } CONTRACTL_END;
-
- INT32 result = 1;
- BEGIN_QCALL;
-
- handle = EnsureValidSortHandle(handle, handleOrigin, localeName);
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- if(!(curDomain->m_bUseOsSorting))
- {
- result = SortVersioning::SortDllCompareString((SortVersioning::PSORTHANDLE) handle, flags, &string1[offset1], length1, &string2[offset2], length2, NULL, 0);
- }
- else if (curDomain->m_pCustomSortLibrary != NULL) {
- result = (curDomain->m_pCustomSortLibrary->pCompareStringEx)(handle != NULL ? NULL : localeName, flags, &string1[offset1], length1, &string2[offset2], length2, NULL, NULL, (LPARAM) handle);
- }
- else
-#endif
- {
- result = NewApis::CompareStringEx(handle != NULL ? NULL : localeName, flags, &string1[offset1], length1, &string2[offset2], length2,NULL,NULL, (LPARAM) handle);
- }
-
- switch (result)
- {
- case CSTR_LESS_THAN:
- result = -1;
- break;
-
- case CSTR_EQUAL:
- result = 0;
- break;
-
- case CSTR_GREATER_THAN:
- result = 1;
- break;
-
- case 0:
- default:
- _ASSERTE(!"catastrophic failure calling NewApis::CompareStringEx! This could be a CultureInfo, RegionInfo, or Calendar bug (bad localeName string) or maybe a GCHole.");
- break;
- }
-
- END_QCALL;
- return result;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//
-// UseConstantSpaceHashAlgorithm
-// Check for the DWORD "NetFx45_CultureAwareComparerGetHashCode_LongStrings" CLR config option.
-//
-// .Net 4.5 introduces an opt-in algorithm for determining the hash code of strings that
-// uses a constant amount of memory instead of memory proportional to the size of the string
-//
-// A non-zero value will enable the new algorithm:
-//
-// 1) Config file (MyApp.exe.config)
-// <?xml version ="1.0"?>
-// <configuration>
-// <runtime>
-// <NetFx45_CultureAwareComparerGetHashCode_LongStrings enabled="1"/>
-// </runtime>
-// </configuration>
-// 2) Environment variable
-// set NetFx45_CultureAwareComparerGetHashCode_LongStrings=1
-// 3) RegistryKey
-// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
-// "NetFx45_CultureAwareComparerGetHashCode_LongStrings"=dword:00000001
-//
-////////////////////////////////////////////////////////////////////////////
-BOOL UseConstantSpaceHashAlgorithm()
-{
- static bool configChecked = false;
- static BOOL useConstantSpaceHashAlgorithm = FALSE;
-
- if(!configChecked)
- {
- BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return false);
- useConstantSpaceHashAlgorithm = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_NetFx45_CultureAwareComparerGetHashCode_LongStrings) != 0;
- END_SO_INTOLERANT_CODE;
-
- configChecked = true;
- }
- return useConstantSpaceHashAlgorithm;
-}
-
-
-
////////////////////////////////////////////////////////////////////////////
//
// InternalGetGlobalizedHashCode
//
////////////////////////////////////////////////////////////////////////////
-INT32 QCALLTYPE COMNlsInfo::InternalGetGlobalizedHashCode(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR localeName, LPCWSTR string, INT32 length, INT32 dwFlagsIn, BOOL bForceRandomizedHashing, INT64 additionalEntropy)
+INT32 QCALLTYPE COMNlsInfo::InternalGetGlobalizedHashCode(INT_PTR handle, LPCWSTR localeName, LPCWSTR string, INT32 length, INT32 dwFlagsIn, INT64 additionalEntropy)
{
CONTRACTL
{
@@ -1760,7 +103,6 @@ INT32 QCALLTYPE COMNlsInfo::InternalGetGlobalizedHashCode(INT_PTR handle, INT_PT
INT32 iReturnHash = 0;
BEGIN_QCALL;
- handle = EnsureValidSortHandle(handle, handleOrigin, localeName);
int byteCount = 0;
//
@@ -1770,706 +112,38 @@ INT32 QCALLTYPE COMNlsInfo::InternalGetGlobalizedHashCode(INT_PTR handle, INT_PT
COMPlusThrowArgumentNull(W("string"),W("ArgumentNull_String"));
}
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-#endif // FEATURE_CORECLR
-
- if(length > 0 && UseConstantSpaceHashAlgorithm()
- // Note that we can't simply do the hash without the entropy and then try to add it after the fact we need the hash function itself to pass entropy to its inputs.
-#ifdef FEATURE_RANDOMIZED_STRING_HASHING
- && !bForceRandomizedHashing
-#ifndef FEATURE_CORECLR
- && !curDomain->m_pNlsHashProvider->GetUseRandomHashing()
-#else
- && !COMNlsHashProvider::s_NlsHashProvider.GetUseRandomHashing()
-#endif // FEATURE_CORECLR
-#endif // FEATURE_RANDOMIZED_STRING_HASHING
- )
- {
-#ifndef FEATURE_CORECLR
- if(!(curDomain->m_bUseOsSorting))
- {
- iReturnHash=SortVersioning::SortDllGetHashCode((SortVersioning::PSORTHANDLE) handle, dwFlagsIn, string, length, NULL, 0);
- }
- else
-#endif
- {
- int iRes = 0;
- int iHashValue = 0;
-
-#ifndef FEATURE_CORECLR
- if (curDomain->m_pCustomSortLibrary != NULL)
- {
- iRes = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(localeName, dwFlagsIn | LCMAP_HASH, string, length, (LPWSTR) &iHashValue, sizeof(INT32), NULL, NULL, 0);
- }
- else
-#endif
- {
- iRes = NewApis::LCMapStringEx(localeName, dwFlagsIn | LCMAP_HASH, string, length, (LPWSTR) &iHashValue, sizeof(INT32), NULL, NULL, 0);
- }
-
- if(iRes != 0)
- {
- iReturnHash = iHashValue;
- }
- }
- }
-
- if(iReturnHash == 0)
- {
- DWORD dwFlags = (LCMAP_SORTKEY | dwFlagsIn);
-
- //
- // Caller has already verified that the string is not of zero length
- //
- // Assert if we might hit an AV in LCMapStringEx for the invariant culture.
- _ASSERTE(length > 0 || (dwFlags & LCMAP_LINGUISTIC_CASING) == 0);
-#ifndef FEATURE_CORECLR
- if(!(curDomain->m_bUseOsSorting))
- {
- byteCount=SortVersioning::SortDllGetSortKey((SortVersioning::PSORTHANDLE) handle, dwFlagsIn, string, length, NULL, 0, NULL, 0);
- }
- else if (curDomain->m_pCustomSortLibrary != NULL)
- {
- byteCount = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : localeName, dwFlags, string, length, NULL, 0, NULL, NULL, (LPARAM) handle);
- }
- else
-#endif
- {
- byteCount=NewApis::LCMapStringEx(handle != NULL ? NULL : localeName, dwFlags, string, length, NULL, 0, NULL, NULL, (LPARAM) handle);
- }
-
- //A count of 0 indicates that we either had an error or had a zero length string originally.
- if (byteCount==0) {
- COMPlusThrow(kArgumentException, W("Arg_MustBeString"));
- }
-
- // We used to use a NewArrayHolder here, but it turns out that hurts our large # process
- // scalability in ASP.Net hosting scenarios, using the quick bytes instead mostly stack
- // allocates and ups throughput by 8% in 100 process case, 5% in 1000 process case
- {
- CQuickBytesSpecifySize<MAX_STRING_VALUE * sizeof(WCHAR)> qbBuffer;
- BYTE* pByte = (BYTE*)qbBuffer.AllocThrows(byteCount);
-
-#ifndef FEATURE_CORECLR
- if(!(curDomain->m_bUseOsSorting))
- {
- SortVersioning::SortDllGetSortKey((SortVersioning::PSORTHANDLE) handle, dwFlagsIn, string, length, pByte, byteCount, NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : localeName, dwFlags, string, length, (LPWSTR)pByte, byteCount, NULL, NULL, (LPARAM) handle);
- }
- else
-#endif
- {
- NewApis::LCMapStringEx(handle != NULL ? NULL : localeName, dwFlags, string, length, (LPWSTR)pByte, byteCount, NULL,NULL, (LPARAM) handle);
- }
-
-#ifndef FEATURE_CORECLR
- iReturnHash = curDomain->m_pNlsHashProvider->HashSortKey(pByte, byteCount, bForceRandomizedHashing, additionalEntropy);
-#else
- iReturnHash = COMNlsHashProvider::s_NlsHashProvider.HashSortKey(pByte, byteCount, bForceRandomizedHashing, additionalEntropy);
-#endif // FEATURE_CORECLR
- }
- }
- END_QCALL;
- return(iReturnHash);
-}
-
-inline BOOL IsInvariantLocale(STRINGREF localeName)
-{
- return localeName->GetStringLength() == 0;
-}
-
-// InternalChangeCaseChar
-//
-// Call LCMapStringEx with a char to make it upper or lower case
-// Note that if the locale is English or Invariant we'll try just mapping it if its < 0x7f
-FCIMPL5(FC_CHAR_RET, COMNlsInfo::InternalChangeCaseChar,
- INT_PTR handle, // optional sort handle
- INT_PTR handleOrigin, StringObject* localeNameUNSAFE, CLR_CHAR wch, CLR_BOOL bIsToUpper)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- CLR_CHAR retVal = '\0';
- int ret_LCMapStringEx = -1;
-
- // Dereference our string
- STRINGREF localeName(localeNameUNSAFE);
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(localeName);
-
- BOOL isInvariantLocale = IsInvariantLocale(localeName);
- // Check for Invariant to avoid A/V in LCMapStringEx
- DWORD linguisticCasing = (isInvariantLocale) ? 0 : LCMAP_LINGUISTIC_CASING;
-
- handle = EnsureValidSortHandle(handle, handleOrigin, localeName->GetBuffer());
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- //For a versioned sort, Invariant should still use the OS
- if(!(curDomain->m_bUseOsSorting) && !isInvariantLocale)
- {
- ret_LCMapStringEx = SortVersioning::SortDllChangeCase((SortVersioning::PSORTHANDLE) handle,
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing:
- LCMAP_LOWERCASE | linguisticCasing,
- &wch,
- 1,
- &retVal,
- 1,
- NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- ret_LCMapStringEx = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : localeName->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing:
- LCMAP_LOWERCASE | linguisticCasing,
- &wch,
- 1,
- &retVal,
- 1,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- else
-#endif
- {
- ret_LCMapStringEx = NewApis::LCMapStringEx(handle != NULL ? NULL : localeName->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing:
- LCMAP_LOWERCASE | linguisticCasing,
- &wch,
- 1,
- &retVal,
- 1,
- NULL,
- NULL,
- (LPARAM) handle);
- }
-
- if (0 == ret_LCMapStringEx)
- {
- // return value of 0 indicates failure and error value is supposed to be set.
- // shouldn't ever really happen
- _ASSERTE(!"catastrophic failure calling NewApis::InternalChangeCaseChar! This could be a CultureInfo or CompareInfo bug (bad localeName string) or maybe a GCHole.");
- }
-
- HELPER_METHOD_FRAME_END(); // localeName is now unprotected
- return retVal;
-}
-FCIMPLEND
-
-// InternalChangeCaseString
-//
-// Call LCMapStringEx with a string to make it upper or lower case
-// Note that if the locale is English or Invariant we'll try just mapping it if its < 0x7f
-//
-// We typically expect the output string to be the same size as the input. If not
-// we have to count, reallocate the output buffer, and try again.
-FCIMPL5(Object*, COMNlsInfo::InternalChangeCaseString,
- INT_PTR handle, // optional sort handle
- INT_PTR handleOrigin, StringObject* localeNameUNSAFE, StringObject* pStringUNSAFE, CLR_BOOL bIsToUpper)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(pStringUNSAFE));
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- } CONTRACTL_END;
-
- struct _gc
- {
- STRINGREF pResult;
- STRINGREF pString;
- STRINGREF pLocale;
- } gc;
-
- gc.pResult = NULL;
- gc.pString = ObjectToSTRINGREF(pStringUNSAFE);
- gc.pLocale = ObjectToSTRINGREF(localeNameUNSAFE);
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc)
-
- handle = EnsureValidSortHandle(handle, handleOrigin, gc.pLocale->GetBuffer());
-
- //
- // Get the length of the string.
- //
- int nLengthInput = gc.pString->GetStringLength();
- int nLengthOutput = nLengthInput; // initially we assume the string length does not change.
-
- BOOL isInvariantLocale = IsInvariantLocale(gc.pLocale);
- // Check for Invariant to avoid A/V in LCMapStringEx
- DWORD linguisticCasing = (isInvariantLocale) ? 0 : LCMAP_LINGUISTIC_CASING;
- // Check for Invariant to avoid A/V in LCMapStringEx
+ DWORD dwFlags = (LCMAP_SORTKEY | dwFlagsIn);
//
- // Check if we have the empty string.
+ // Caller has already verified that the string is not of zero length
//
- if (nLengthInput == 0)
+ // Assert if we might hit an AV in LCMapStringEx for the invariant culture.
+ _ASSERTE(length > 0 || (dwFlags & LCMAP_LINGUISTIC_CASING) == 0);
{
- gc.pResult = ObjectToSTRINGREF(gc.pString);
+ byteCount=NewApis::LCMapStringEx(handle != NULL ? NULL : localeName, dwFlags, string, length, NULL, 0, NULL, NULL, (LPARAM) handle);
}
- else
- {
- //
- // Create the result string.
- //
- gc.pResult = StringObject::NewString(nLengthOutput);
- LPWSTR pResultStr = gc.pResult->GetBuffer();
-
- int result;
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- //Invariant should always use OS
- if(!(curDomain->m_bUseOsSorting) && !isInvariantLocale)
- {
- result = SortVersioning::SortDllChangeCase((SortVersioning::PSORTHANDLE) handle,
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing:
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- pResultStr,
- nLengthOutput,
- NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- result = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : (gc.pLocale)->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing :
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- pResultStr,
- nLengthOutput,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- else
-#endif
- {
- result = NewApis::LCMapStringEx(handle != NULL ? NULL : (gc.pLocale)->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing :
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- pResultStr,
- nLengthOutput,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- if(0 == result)
- {
- // Failure: Detect if that's due to insufficient buffer
- if (GetLastError()!= ERROR_INSUFFICIENT_BUFFER)
- {
- ThrowLastError();
- }
- // need to update buffer
-#ifndef FEATURE_CORECLR
- //Invariant should always use OS
- if(!(curDomain->m_bUseOsSorting) && !IsInvariantLocale(gc.pLocale))
- {
- nLengthOutput = SortVersioning::SortDllChangeCase((SortVersioning::PSORTHANDLE) handle,
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing:
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- NULL,
- 0,
- NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- nLengthOutput = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : (gc.pLocale)->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing :
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- NULL,
- 0,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- else
-#endif
- {
- nLengthOutput = NewApis::LCMapStringEx(handle != NULL ? NULL : (gc.pLocale)->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing :
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- NULL,
- 0,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- if (nLengthOutput == 0)
- {
- // return value of 0 indicates failure and error value is supposed to be set.
- // shouldn't ever really happen
- _ASSERTE(!"catastrophic failure calling NewApis::InternalChangeCaseString! This could be a CultureInfo or CompareInfo bug (bad localeName string) or maybe a GCHole.");
- }
- _ASSERTE(nLengthOutput > 0);
- // NOTE: The length of the required buffer does not include the terminating null character.
- // So it can be used as-is for our calculations -- the length we pass in to NewString also does
- // not include the terminating null character.
- // MSDN documentation could be interpreted to mean that the length returned includes the terminating
- // NULL character, but that's not the case.
-
- // NOTE: Also note that we let the GC take care of the previously allocated pResult.
-
- gc.pResult = StringObject::NewString(nLengthOutput);
- pResultStr = gc.pResult->GetBuffer();
-#ifndef FEATURE_CORECLR
- //Invariant should always use OS
- if(!(curDomain->m_bUseOsSorting) && !IsInvariantLocale(gc.pLocale))
- {
- result = SortVersioning::SortDllChangeCase((SortVersioning::PSORTHANDLE) handle,
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing:
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- pResultStr,
- nLengthOutput,
- NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- result = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : (gc.pLocale)->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing :
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- pResultStr,
- nLengthOutput,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- else
-#endif
- {
- result = NewApis::LCMapStringEx(handle != NULL ? NULL : (gc.pLocale)->GetBuffer(),
- bIsToUpper?LCMAP_UPPERCASE | linguisticCasing :
- LCMAP_LOWERCASE | linguisticCasing,
- gc.pString->GetBuffer(),
- nLengthInput,
- pResultStr,
- nLengthOutput,
- NULL,
- NULL,
- (LPARAM) handle);
- }
-
- if(0 == result)
- {
- // return value of 0 indicates failure and error value is supposed to be set.
- // shouldn't ever really happen
- _ASSERTE(!"catastrophic failure calling NewApis::InternalChangeCaseString! This could be a CultureInfo or CompareInfo bug (bad localeName string) or maybe a GCHole.");
- }
- }
-
- pResultStr[nLengthOutput] = 0;
- }
-
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.pResult);
-}
-FCIMPLEND
-
-/*================================InternalGetCaseInsHash================================
-**Action:
-**Returns:
-**Arguments:
-**Exceptions:
-==============================================================================*/
-FCIMPL6(INT32, COMNlsInfo::InternalGetCaseInsHash,
- INT_PTR handle, // optional sort handle
- INT_PTR handleOrigin, StringObject* localeNameUNSAFE, LPVOID pvStrA, CLR_BOOL bForceRandomizedHashing, INT64 additionalEntropy)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(localeNameUNSAFE));
- PRECONDITION(CheckPointer(pvStrA));
- } CONTRACTL_END;
-
- STRINGREF localeName = ObjectToSTRINGREF(localeNameUNSAFE);
- STRINGREF strA;
-
- INT32 result;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(GetThread(), FCThrow(kStackOverflowException))
-
- *((LPVOID *)&strA)=pvStrA;
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-#endif
-
- //
- // If we know that we don't have any high characters (the common case) we can
- // call a hash function that knows how to do a very fast case conversion. If
- // we find characters above 0x80, it's much faster to convert the entire string
- // to Uppercase and then call the standard hash function on it.
- //
- // TODO: NLS Arrowhead -We aren't consistent with the fast casing cultures (any en? fr? de?)
- if (IsCultureEnglishOrInvariant((localeName)->GetBuffer()) && // If we're en-US or Invariant
- ((IS_STRING_STATE_UNDETERMINED(strA->GetHighCharState()) && // and we're undetermined
- IS_FAST_CASING(strA->InternalCheckHighChars())) || // and its fast casing when determined
- IS_FAST_CASING(strA->GetHighCharState()))) // or we're fast casing that's already determined
+ //A count of 0 indicates that we either had an error or had a zero length string originally.
+ if (byteCount==0)
{
- // Notice that for Turkish and Azeri we don't get here and shouldn't use this
- // fast path because of their special Latin casing rules.
-#ifndef FEATURE_CORECLR
- result = curDomain->m_pNlsHashProvider->HashiStringKnownLower80(strA->GetBuffer(), strA->GetStringLength(), bForceRandomizedHashing, additionalEntropy);
-#else
- result = COMNlsHashProvider::s_NlsHashProvider.HashiStringKnownLower80(strA->GetBuffer(), strA->GetStringLength(), bForceRandomizedHashing, additionalEntropy);
-#endif // FEATURE_CORECLR
+ COMPlusThrow(kArgumentException, W("Arg_MustBeString"));
}
- else
- {
- handle = EnsureValidSortHandle(handle, handleOrigin, localeName->GetBuffer());
-
- // Make it upper case
- CQuickBytes newBuffer;
- INT32 length = strA->GetStringLength();
- WCHAR *pNewStr = (WCHAR *)newBuffer.AllocThrows((length + 1) * sizeof(WCHAR));
-
- // Work around an A/V in LCMapStringEx for the invariant culture.
- // Revisit this after Vista SP2 has been deployed everywhere.
- DWORD linguisticCasing = 0;
- if (localeName->GetStringLength() > 0) // if not the invariant culture...
- {
- linguisticCasing = LCMAP_LINGUISTIC_CASING;
- }
-
- int lcmapResult;
-#ifndef FEATURE_CORECLR
- if(!(curDomain->m_bUseOsSorting))
- {
- lcmapResult = SortVersioning::SortDllChangeCase((SortVersioning::PSORTHANDLE) handle,
- LCMAP_UPPERCASE | linguisticCasing,
- strA->GetBuffer(),
- length,
- pNewStr,
- length,
- NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- lcmapResult = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : localeName->GetBuffer(),
- LCMAP_UPPERCASE | linguisticCasing,
- strA->GetBuffer(),
- length,
- pNewStr,
- length,
- NULL, NULL, (LPARAM) handle);
- }
- else
-#endif
- {
- lcmapResult = NewApis::LCMapStringEx(handle != NULL ? NULL : localeName->GetBuffer(),
- LCMAP_UPPERCASE | linguisticCasing,
- strA->GetBuffer(),
- length,
- pNewStr,
- length,
- NULL, NULL, (LPARAM) handle);
- }
-
- if (lcmapResult == 0)
- {
- // return value of 0 indicates failure and error value is supposed to be set.
- // shouldn't ever really happen
- _ASSERTE(!"catastrophic failure calling NewApis::InternalGetCaseInsHash! This could be a CultureInfo or CompareInfo bug (bad localeName string) or maybe a GCHole.");
- }
- pNewStr[length]='\0';
- // Get hash for the upper case of the new string
-
-#ifndef FEATURE_CORECLR
- result = curDomain->m_pNlsHashProvider->HashString(pNewStr, length, (BOOL)bForceRandomizedHashing, additionalEntropy);
-#else
- result = COMNlsHashProvider::s_NlsHashProvider.HashString(pNewStr, length, (BOOL)bForceRandomizedHashing, additionalEntropy);
-#endif // FEATURE_CORECLR
- }
-
- END_SO_INTOLERANT_CODE
-
- return result;
-}
-FCIMPLEND
-
-// Fast path for finding a String using OrdinalIgnoreCase rules
-// returns true if the fast path succeeded, with foundIndex set to the location where the String was found or -1
-// Returns false when FindStringOrdinal isn't handled (we don't have our own general version of this function to fall back on)
-// Note for future optimizations: kernel32!FindStringOrdinal(ignoreCase=TRUE) uses per-character table lookup
-// to map to upper case before comparison, but isn't otherwise optimized
-BOOL QCALLTYPE COMNlsInfo::InternalTryFindStringOrdinalIgnoreCase(
- __in DWORD dwFindNLSStringFlags, // mutually exclusive flags: FIND_FROMSTART, FIND_STARTSWITH, FIND_FROMEND, FIND_ENDSWITH
- __in_ecount(cchSource) LPCWSTR lpStringSource, // the string we search in
- __in int cchSource, // number of characters lpStringSource after sourceIndex
- __in int sourceIndex, // index from where the search will start in lpStringSource
- __in_ecount(cchValue) LPCWSTR lpStringValue, // the string we search for
- __in int cchValue,
- __out int* foundIndex) // the index in lpStringSource where we found lpStringValue
-{
- CONTRACTL
+ // We used to use a NewArrayHolder here, but it turns out that hurts our large # process
+ // scalability in ASP.Net hosting scenarios, using the quick bytes instead mostly stack
+ // allocates and ups throughput by 8% in 100 process case, 5% in 1000 process case
{
- QCALL_CHECK;
- PRECONDITION(lpStringSource != NULL);
- PRECONDITION(lpStringValue != NULL);
- PRECONDITION(cchSource>=0);
- PRECONDITION(cchValue>=0);
- PRECONDITION((dwFindNLSStringFlags & FIND_NLS_STRING_FLAGS_NEGATION) == 0);
- } CONTRACTL_END;
-
- BOOL result = FALSE;
-
- BEGIN_QCALL;
-
- LPCWSTR lpSearchStart = NULL;
- if (dwFindNLSStringFlags & (FIND_FROMEND | FIND_ENDSWITH))
- {
- lpSearchStart = &lpStringSource[sourceIndex - cchSource + 1];
- }
- else {
- lpSearchStart = &lpStringSource[sourceIndex];
- }
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
+ CQuickBytesSpecifySize<MAX_STRING_VALUE * sizeof(WCHAR)> qbBuffer;
+ BYTE* pByte = (BYTE*)qbBuffer.AllocThrows(byteCount);
- // Check if the default sorting is overridden
- if (curDomain->m_pCustomSortLibrary != NULL)
- {
- *foundIndex = (curDomain->m_pCustomSortLibrary->pFindStringOrdinal)(
- dwFindNLSStringFlags,
- lpSearchStart,
- cchSource,
- lpStringValue,
- cchValue,
- TRUE);
- result = TRUE;
- }
- else
-#endif
- {
-#ifndef FEATURE_CORESYSTEM
- // kernel function pointer
- typedef int (WINAPI *PFNFindStringOrdinal)(DWORD, LPCWSTR, INT, LPCWSTR, INT, BOOL);
- static PFNFindStringOrdinal FindStringOrdinal = NULL;
-
- // initizalize kernel32!FindStringOrdinal
- if (FindStringOrdinal == NULL)
{
- PFNFindStringOrdinal result = NULL;
-
- HMODULE hMod=WszGetModuleHandle(WINDOWS_KERNEL32_DLLNAME_W);
- if(hMod != NULL)
- result=(PFNFindStringOrdinal)GetProcAddress(hMod,"FindStringOrdinal");
-
- FindStringOrdinal = (result != NULL) ? result : (PFNFindStringOrdinal)-1;
+ NewApis::LCMapStringEx(handle != NULL ? NULL : localeName, dwFlags, string, length, (LPWSTR)pByte, byteCount, NULL,NULL, (LPARAM) handle);
}
- // call into the kernel
- if (FindStringOrdinal != (PFNFindStringOrdinal)-1)
-#endif
- {
- *foundIndex = FindStringOrdinal(
- dwFindNLSStringFlags,
- lpSearchStart,
- cchSource,
- lpStringValue,
- cchValue,
- TRUE);
- result = TRUE;
- }
- }
- // if we found the pattern string, fixup the index before we return
- if (*foundIndex >= 0)
- {
- if (dwFindNLSStringFlags & (FIND_FROMEND | FIND_ENDSWITH))
- *foundIndex += (sourceIndex - cchSource + 1);
- else
- *foundIndex += sourceIndex;
+ iReturnHash = COMNlsHashProvider::s_NlsHashProvider.HashSortKey(pByte, byteCount, true, additionalEntropy);
}
END_QCALL;
-
- return result;
-}
-
-
-// InternalCompareStringOrdinalIgnoreCase
-//
-// Call ::CompareStringOrdinal for native ordinal behavior
-INT32 QCALLTYPE COMNlsInfo::InternalCompareStringOrdinalIgnoreCase(
- LPCWSTR string1, INT32 index1,
- LPCWSTR string2, INT32 index2,
- INT32 length1,
- INT32 length2)
-{
- CONTRACTL
- {
- QCALL_CHECK;
- PRECONDITION(CheckPointer(string1));
- PRECONDITION(CheckPointer(string2));
- } CONTRACTL_END;
-
- INT32 result = 0;
-
- BEGIN_QCALL;
- //
- // Get the arguments.
- // We assume the caller checked them before calling us
- //
-
- // We don't allow the -1 that native code allows
- _ASSERT(length1 >= 0);
- _ASSERT(length2 >= 0);
-
- // Do the comparison
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- if (curDomain->m_pCustomSortLibrary != NULL) {
- result = (curDomain->m_pCustomSortLibrary->pCompareStringOrdinal)(string1 + index1, length1, string2 + index2, length2, TRUE);
- }
- else
-#endif
- {
- result = NewApis::CompareStringOrdinal(string1 + index1, length1, string2 + index2, length2, TRUE);
- }
-
- // The native call shouldn't fail
- _ASSERT(result != 0);
- if (result == 0)
- {
- // return value of 0 indicates failure and error value is supposed to be set.
- // shouldn't ever really happen
- _ASSERTE(!"catastrophic failure calling NewApis::CompareStringOrdinal! This is usually due to bad arguments.");
- }
-
- // Adjust the result to the expected -1, 0, 1 result
- result -= 2;
-
- END_QCALL;
-
- return result;
+ return(iReturnHash);
}
/**
@@ -2501,163 +175,6 @@ FCIMPL0(CodePageDataItem *, COMNlsInfo::nativeGetCodePageTableDataPointer)
}
FCIMPLEND
-
-#ifndef FEATURE_COREFX_GLOBALIZATION
-//
-// Normalization
-//
-
-FCIMPL6(int, COMNlsInfo::nativeNormalizationNormalizeString,
- int NormForm, int& iError,
- StringObject* inChars, int inLength,
- CHARArray* outChars, int outLength )
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(inChars));
- PRECONDITION(CheckPointer(outChars, NULL_OK));
- } CONTRACTL_END;
-
- // Dereference our string
- STRINGREF inString(inChars);
- LPWSTR inCharsBuffer = inString->GetBuffer();
-
- CHARARRAYREF outCharArray(outChars);
- LPWSTR outCharsBuffer = (outCharArray != NULL) ? ((LPWSTR) (outCharArray->GetDirectPointerToNonObjectElements())) : NULL;
-
- // The OS APIs do not always set last error in success, so we have to do it explicitly
- SetLastError(ERROR_SUCCESS);
-
- int iResult = m_pfnNormalizationNormalizeStringFunc(
- NormForm, inCharsBuffer, inLength, outCharsBuffer, outLength);
-
- // Get our error if necessary
- if (iResult <= 0)
- {
- // if the length is <= 0 there was an error
- iError = GetLastError();
-
- // Go ahead and return positive lengths/indexes so we don't get confused
- iResult = -iResult;
- }
- else
- {
- iError = 0; // ERROR_SUCCESS
- }
-
- return iResult;
-}
-FCIMPLEND
-
-FCIMPL4( FC_BOOL_RET, COMNlsInfo::nativeNormalizationIsNormalizedString,
- int NormForm, int& iError,
- StringObject* chars, int inLength )
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(chars));
- } CONTRACTL_END;
-
- STRINGREF inString(chars);
- LPWSTR charsBuffer = inString->GetBuffer();
-
- // The OS APIs do not always set last error in success, so we have to do it explicitly
- SetLastError(ERROR_SUCCESS);
-
- // Ask if its normalized
- BOOL bResult = m_pfnNormalizationIsNormalizedStringFunc( NormForm, charsBuffer, inLength);
-
- // May need an error
- if (bResult == false)
- {
- // If its false there may have been an error
- iError = GetLastError();
- }
- else
- {
- iError = 0; // ERROR_SUCCESS
- }
-
- FC_RETURN_BOOL(bResult);
-}
-FCIMPLEND
-
-void QCALLTYPE COMNlsInfo::nativeNormalizationInitNormalization(int NormForm, BYTE* pTableData)
-{
- QCALL_CONTRACT;
-
- BEGIN_QCALL;
-
- if (m_hNormalization == NULL)
- {
- HMODULE hNormalization = NULL;
-
- if (pTableData == NULL)
- {
- // Use OS implementation
- hNormalization = GetModuleHandleW(W("kernel32.dll"));
- if (!hNormalization)
- ThrowLastError();
- }
-#ifndef FEATURE_CORECLR
- // in coreclr we should always find the normalization in kernel32 as it supports Win7 and up
- else
- {
- HRESULT hr = g_pCLRRuntime->LoadLibrary(NORMALIZATION_DLL, &hNormalization);
- if (FAILED(hr))
- ThrowHR(hr);
- }
-#endif // FEATURE_CORECLR
-
- _ASSERTE(hNormalization != NULL);
- m_hNormalization = hNormalization;
- }
-
- if (m_pfnNormalizationIsNormalizedStringFunc == NULL)
- {
- FARPROC pfn = GetProcAddress(m_hNormalization, "IsNormalizedString");
- if (pfn == NULL)
- ThrowLastError();
- m_pfnNormalizationIsNormalizedStringFunc = (PFN_NORMALIZATION_IS_NORMALIZED_STRING)pfn;
- }
-
- if (m_pfnNormalizationNormalizeStringFunc == NULL)
- {
- FARPROC pfn = GetProcAddress(m_hNormalization, "NormalizeString");
- if (pfn == NULL)
- ThrowLastError();
- m_pfnNormalizationNormalizeStringFunc = (PFN_NORMALIZATION_NORMALIZE_STRING)pfn;
- }
-
- if (pTableData != NULL)
- {
- if (m_pfnNormalizationInitNormalizationFunc == NULL)
- {
- FARPROC pfn = GetProcAddress(m_hNormalization, "InitNormalization");
- if (pfn == NULL)
- ThrowLastError();
- m_pfnNormalizationInitNormalizationFunc = (PFN_NORMALIZATION_INIT_NORMALIZATION)pfn;
- }
-
- BYTE* pResult = m_pfnNormalizationInitNormalizationFunc( NormForm, pTableData);
- if (pResult == NULL)
- ThrowOutOfMemory();
- }
-
- END_QCALL;
-}
-
-#endif // FEATURE_COREFX_GLOBALIZATION
-
-
-//
-// This table should be sorted using case-insensitive ordinal order.
-// In the managed code, String.CompareStringOrdinalWC() is used to sort this.
-//
-
-
/**
* This function returns the number of items in EncodingDataTable.
*/
@@ -2669,689 +186,3 @@ FCIMPL0(INT32, COMNlsInfo::nativeGetNumEncodingItems)
return (m_nEncodingDataTableItems);
}
FCIMPLEND
-
-
-
-typedef CultureDataBaseObject* CULTUREDATAREF;
-
-// nativeInitCultureData checks with the OS to see if this is a valid culture.
-// If so we populate a limited number of fields. If its not valid we return false.
-//
-// The fields we populate:
-//
-// sWindowsName -- The name that windows thinks this culture is, ie:
-// en-US if you pass in en-US
-// de-DE_phoneb if you pass in de-DE_phoneb
-// fj-FJ if you pass in fj (neutral, on a pre-Windows 7 machine)
-// fj if you pass in fj (neutral, post-Windows 7 machine)
-//
-// sRealName -- The name you used to construct the culture, in pretty form
-// en-US if you pass in EN-us
-// en if you pass in en
-// de-DE_phoneb if you pass in de-DE_phoneb
-//
-// sSpecificCulture -- The specific culture for this culture
-// en-US for en-US
-// en-US for en
-// de-DE_phoneb for alt sort
-// fj-FJ for fj (neutral)
-//
-// sName -- The IETF name of this culture (ie: no sort info, could be neutral)
-// en-US if you pass in en-US
-// en if you pass in en
-// de-DE if you pass in de-DE_phoneb
-//
-// bNeutral -- TRUE if it is a neutral locale
-//
-// For a neutral we just populate the neutral name, but we leave the windows name pointing to the
-// windows locale that's going to provide data for us.
-//
-FCIMPL1(FC_BOOL_RET, COMNlsInfo::nativeInitCultureData, CultureDataBaseObject *cultureDataUNSAFE)
-{
- FCALL_CONTRACT;
-
- BOOL success=FALSE;
-
- struct _gc
- {
- STRINGREF stringResult;
- CULTUREDATAREF cultureData;
- } gc;
-
- gc.stringResult = NULL;
- gc.cultureData = (CULTUREDATAREF) cultureDataUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- WCHAR buffer[LOCALE_NAME_MAX_LENGTH];
- int result;
-
- StackSString realNameBuffer( ((STRINGREF)gc.cultureData->sRealName)->GetBuffer() );
-
- // Call GetLocaleInfoEx and see if the OS knows about it.
- // Note that GetLocaleInfoEx has variations:
- // * Pre-Vista it fails and has to go downlevel
- // * Vista succeeds, but not for neutrals
- // * Win7 succeeds for all locales.
- // * Mac does ???
- // The differences should be handled by the NewApis wrapper
- result = NewApis::GetLocaleInfoEx(realNameBuffer, LOCALE_SNAME, buffer, NumItems(buffer));
-
- // Did it fail?
- if (result == 0)
- {
- // Not a real locale, fail
- goto Exit;
- }
-
- // It worked, note that the name is the locale name, so use that (even for neutrals)
- // We need to clean up our "real" name, which should look like the windows name right now
- // so overwrite the input with the cleaned up name
- gc.stringResult = StringObject::NewString(buffer, result-1);
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sRealName), gc.stringResult, NULL);
-
- // Check for neutrality, don't expect to fail
- // (buffer has our name in it, so we don't have to do the gc. stuff)
- DWORD bNeutral;
- if (0 == NewApis::GetLocaleInfoEx(buffer, LOCALE_INEUTRAL | LOCALE_RETURN_NUMBER, (LPWSTR)&bNeutral, sizeof(bNeutral)/sizeof(WCHAR)))
- goto Exit;
-
- // Remember our neutrality
- gc.cultureData->bNeutral = (bNeutral != 0);
-
- gc.cultureData->bWin32Installed = (IsOSValidLocaleName(buffer, gc.cultureData->bNeutral) != 0);
- gc.cultureData->bFramework = (IsWhidbeyFrameworkCulture(buffer) != 0);
-
-
- // Note: Parents will be set dynamically
-
- // Start by assuming the windows name'll be the same as the specific name since windows knows
- // about specifics on all versions. For macs it also works. Only for downlevel Neutral locales
- // does this have to change.
- gc.stringResult = StringObject::NewString(buffer, result-1);
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sWindowsName), gc.stringResult, NULL);
-
- // Neutrals and non-neutrals are slightly different
- if (gc.cultureData->bNeutral)
- {
- // Neutral Locale
-
- // IETF name looks like neutral name
- gc.stringResult = StringObject::NewString(buffer, result-1);
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sName), gc.stringResult, NULL);
-
- // Specific locale name is whatever ResolveLocaleName (win7+) returns.
- // (Buffer has our name in it, and we can recycle that because windows resolves it before writing to the buffer)
- result = NewApis::ResolveLocaleName(buffer, buffer, NumItems(buffer));
-
- // 0 is failure, 1 is invariant (""), which we expect
- if (result < 1) goto Exit;
-
- // We found a locale name, so use it.
- // In vista this should look like a sort name (de-DE_phoneb) or a specific culture (en-US) and be in the "pretty" form
- gc.stringResult = StringObject::NewString(buffer, result - 1);
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sSpecificCulture), gc.stringResult, NULL);
-
-#ifdef FEATURE_CORECLR
- if (!IsWindows7())
- {
- // For neutrals on Windows 7 + the neutral windows name can be the same as the neutral name,
- // but on pre windows 7 names it has to be the specific, so we have to fix it in that case.
- gc.stringResult = StringObject::NewString(buffer, result - 1);
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sWindowsName), gc.stringResult, NULL);
- }
-#endif
-
-
- }
- else
- {
- // Specific Locale
-
- // Specific culture's the same as the locale name since we know its not neutral
- // On mac we'll use this as well, even for neutrals. There's no obvious specific
- // culture to use and this isn't exposed, but behaviorally this is correct on mac.
- // Note that specifics include the sort name (de-DE_phoneb)
- gc.stringResult = StringObject::NewString(buffer, result-1);
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sSpecificCulture), gc.stringResult, NULL);
-
- // We need the IETF name (sname)
- // If we aren't an alt sort locale then this is the same as the windows name.
- // If we are an alt sort locale then this is the same as the part before the _ in the windows name
- // This is for like de-DE_phoneb and es-ES_tradnl that hsouldn't have the _ part
-
- int localeNameLength = result - 1;
-
- LCID lcid = NewApis::LocaleNameToLCID(buffer, 0);
- if (!IsCustomCultureId(lcid))
- {
- LPCWSTR index = wcschr(buffer, W('_'));
- if(index) // Not a custom culture and looks like an alt sort name
- {
- // Looks like an alt sort, and has a appropriate sort LCID (so not custom), make it smaller for the RFC 4646 style name
- localeNameLength = static_cast<int>(index - buffer);
- }
- }
-
- gc.stringResult = StringObject::NewString(buffer, localeNameLength);
- _ASSERTE(gc.stringResult != NULL);
-
- // Now use that name
- SetObjectReference((OBJECTREF*)&(gc.cultureData->sName), gc.stringResult, NULL);
- }
-
-#ifdef FEATURE_CORECLR
- // For Silverlight make sure that the sorting tables are available (< Vista may not have east asian installed)
- result = NewApis::CompareStringEx(((STRINGREF)gc.cultureData->sWindowsName)->GetBuffer(),
- 0, W("A"), 1, W("B"), 1, NULL, NULL, 0);
- if (result == 0) goto Exit;
-#endif
-
- // It succeeded.
- success = TRUE;
-
-Exit: {}
-
- HELPER_METHOD_FRAME_END();
-
- FC_RETURN_BOOL(success);
-}
-FCIMPLEND
-
-
-// Return true if we're on Windows 7 (ie: if we have neutral native support)
-BOOL COMNlsInfo::IsWindows7()
-{
- static BOOL bChecked=FALSE;
- static BOOL bIsWindows7=FALSE;
-
- if (!bChecked)
- {
- // LOCALE_INEUTRAL is first supported on Windows 7
- if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_INEUTRAL, NULL, 0) != 0)
- {
- // Success, we're win7
- bIsWindows7 = TRUE;
- }
-
- // Either way we checked now
- bChecked = TRUE;
- }
-
- return bIsWindows7;
-}
-
-//
-// QCall implementation
-//
-int QCALLTYPE COMNlsInfo::InternalFindNLSStringEx(
- __in_opt INT_PTR handle, // optional sort handle
- __in_opt INT_PTR handleOrigin,
- __in_z LPCWSTR lpLocaleName, // locale name
- __in int dwFindNLSStringFlags, // search falg
- __in_ecount(cchSource) LPCWSTR lpStringSource, // the string we search in
- __in int cchSource, // number of characters lpStringSource after sourceIndex
- __in int sourceIndex, // index from where the search will start in lpStringSource
- __in_ecount(cchValue) LPCWSTR lpStringValue, // the string we search for
- __in int cchValue) // length of the string we search for
-{
- CONTRACTL {
- QCALL_CHECK;
- PRECONDITION(lpLocaleName != NULL);
- PRECONDITION(lpStringSource != NULL);
- PRECONDITION(lpStringValue != NULL);
- PRECONDITION(cchSource>=0);
- PRECONDITION(cchValue>=0);
- } CONTRACTL_END;
-
- int retValue = -1;
-
- BEGIN_QCALL;
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
- handle = EnsureValidSortHandle(handle, handleOrigin, lpLocaleName);
-#endif
-
- #define RESERVED_FIND_ASCII_STRING 0x20000000 // This flag used only to tell the sorting DLL can assume the string characters are in ASCII.
-
-#ifndef FEATURE_CORECLR
- int asciiFlag = (dwFindNLSStringFlags & RESERVED_FIND_ASCII_STRING);
-#endif // FEATURE_CORECLR
-
- dwFindNLSStringFlags &= ~RESERVED_FIND_ASCII_STRING;
-
- if (cchValue == 0)
- {
- retValue = sourceIndex; // keep Whidbey compatibility
- goto lExit;
- }
-
- if (sourceIndex<0 || cchSource<0 ||
- ((dwFindNLSStringFlags & (FIND_FROMEND | FIND_ENDSWITH)) && (sourceIndex+1<cchSource)))
- {
- goto lExit;
- }
-
- if (dwFindNLSStringFlags & COMPARE_OPTIONS_ORDINAL)
- {
- if (dwFindNLSStringFlags & (FIND_FROMEND | FIND_ENDSWITH))
- {
- retValue = NewApis::LastIndexOfString(
- lpLocaleName,
- &lpStringSource[sourceIndex - cchSource + 1],
- cchSource,
- lpStringValue,
- cchValue,
- dwFindNLSStringFlags & FIND_NLS_STRING_FLAGS_NEGATION,
- dwFindNLSStringFlags & FIND_ENDSWITH);
- if (retValue >= 0)
- {
- retValue += sourceIndex - cchSource + 1;
- }
- }
- else
- {
- retValue = NewApis::IndexOfString(
- lpLocaleName,
- &lpStringSource[sourceIndex],
- cchSource,
- lpStringValue,
- cchValue,
- dwFindNLSStringFlags & FIND_NLS_STRING_FLAGS_NEGATION,
- dwFindNLSStringFlags & FIND_STARTSWITH);
-
- if (retValue >= 0)
- {
- retValue += sourceIndex;
- }
- }
- }
- else
- {
- if (dwFindNLSStringFlags & (FIND_FROMEND | FIND_ENDSWITH))
- {
-#ifndef FEATURE_CORECLR
- if(!(curDomain->m_bUseOsSorting))
- {
- retValue = SortVersioning::SortDllFindString((SortVersioning::PSORTHANDLE) handle,
- dwFindNLSStringFlags | asciiFlag,
- &lpStringSource[sourceIndex - cchSource + 1],
- cchSource,
- lpStringValue,
- cchValue,
- NULL, NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- retValue = (curDomain->m_pCustomSortLibrary->pFindNLSStringEx)(
- handle != NULL ? NULL : lpLocaleName,
- dwFindNLSStringFlags,
- &lpStringSource[sourceIndex - cchSource + 1],
- cchSource,
- lpStringValue,
- cchValue, NULL, NULL, NULL, (LPARAM) handle);
- }
- else
-#endif
- {
- retValue = NewApis::FindNLSStringEx(
- handle != NULL ? NULL : lpLocaleName,
- dwFindNLSStringFlags,
- &lpStringSource[sourceIndex - cchSource + 1],
- cchSource,
- lpStringValue,
- cchValue, NULL, NULL, NULL, (LPARAM) handle);
- }
-
- if (retValue >= 0)
- {
- retValue += sourceIndex - cchSource + 1;
- }
- }
- else
- {
-#ifndef FEATURE_CORECLR
- if(!(curDomain->m_bUseOsSorting))
- {
- retValue = SortVersioning::SortDllFindString((SortVersioning::PSORTHANDLE) handle,
- dwFindNLSStringFlags | asciiFlag,
- &lpStringSource[sourceIndex],
- cchSource,
- lpStringValue,
- cchValue,
- NULL, NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- retValue = (curDomain->m_pCustomSortLibrary->pFindNLSStringEx)(
- handle != NULL ? NULL : lpLocaleName,
- dwFindNLSStringFlags,
- &lpStringSource[sourceIndex],
- cchSource,
- lpStringValue,
- cchValue, NULL, NULL, NULL, (LPARAM) handle);
- }
- else
-#endif
- {
- retValue = NewApis::FindNLSStringEx(
- handle != NULL ? NULL : lpLocaleName,
- dwFindNLSStringFlags,
- &lpStringSource[sourceIndex],
- cchSource,
- lpStringValue,
- cchValue, NULL, NULL, NULL, (LPARAM) handle);
- }
-
- if (retValue >= 0)
- {
- retValue += sourceIndex;
- }
- }
- }
-
-lExit:
-
- END_QCALL;
-
- return retValue;
-}
-
-
-int QCALLTYPE COMNlsInfo::InternalGetSortKey(
- __in_opt INT_PTR handle, // PSORTHANDLE
- __in_opt INT_PTR handleOrigin,
- __in_z LPCWSTR pLocaleName, // locale name
- __in int flags, // flags
- __in_ecount(cchSource) LPCWSTR pStringSource, // Source string
- __in int cchSource, // number of characters in lpStringSource
- __in_ecount(cchTarget) PBYTE pTarget, // Target data buffer (may be null to count)
- __in int cchTarget) // Character count for target buffer
-{
- CONTRACTL {
- QCALL_CHECK;
- PRECONDITION(pLocaleName != NULL);
- PRECONDITION(pStringSource != NULL);
-// PRECONDITION(pTarget != NULL);
- PRECONDITION(cchSource>=0);
-// PRECONDITION(cchTarget>=0);
- } CONTRACTL_END;
-
- int retValue = 0;
-
- BEGIN_QCALL;
-
-
-#ifndef FEATURE_CORECLR
- handle = EnsureValidSortHandle(handle, handleOrigin, pLocaleName);
-
- AppDomain* curDomain = GetAppDomain();
-
- if(!(curDomain->m_bUseOsSorting))
- {
- retValue = SortVersioning::SortDllGetSortKey((SortVersioning::PSORTHANDLE) handle,
- flags,
- pStringSource,
- cchSource,
- pTarget,
- cchTarget,
- NULL, 0);
- }
- else if(curDomain->m_pCustomSortLibrary != NULL)
- {
- retValue = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(handle != NULL ? NULL : pLocaleName,
- flags | LCMAP_SORTKEY,
- pStringSource,
- cchSource,
- (LPWSTR)pTarget,
- cchTarget,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- else
-#endif
- {
- // Just call NewApis::LCMapStringEx to do our work
- retValue = NewApis::LCMapStringEx(handle != NULL ? NULL : pLocaleName,
- flags | LCMAP_SORTKEY,
- pStringSource,
- cchSource,
- (LPWSTR)pTarget,
- cchTarget,
- NULL,
- NULL,
- (LPARAM) handle);
- }
- END_QCALL;
-
- return retValue;
-}
-
-
-// We allow InternalInitSortHandle to return a NULL value
-// this is the case for Silverlight or when the appdomain has custom sorting.
-// So all the methods that take a SortHandle, also have to
-// be able to just call the slower api that looks up the tables based on the locale name
-INT_PTR QCALLTYPE COMNlsInfo::InternalInitSortHandle(LPCWSTR localeName, __out INT_PTR* handleOrigin)
-{
- CONTRACTL {
- QCALL_CHECK;
- PRECONDITION(localeName != NULL);
- } CONTRACTL_END;
-
- INT_PTR pSort = NULL;
-
- BEGIN_QCALL;
-
- pSort = InitSortHandleHelper(localeName, handleOrigin);
-
- END_QCALL;
-
- return pSort;
-}
-
-INT_PTR COMNlsInfo::InitSortHandleHelper(LPCWSTR localeName, __out INT_PTR* handleOrigin)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- CANNOT_TAKE_LOCK;
- PRECONDITION(localeName != NULL);
- } CONTRACTL_END;
-
- INT_PTR pSort = NULL;
-
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
-#if _DEBUG
- _ASSERTE(curDomain->m_bSortingInitialized);
-#endif
-
- if(curDomain->m_bUseOsSorting)
- {
- pSort = InternalInitOsSortHandle(localeName, handleOrigin);
- }
- else
- {
- pSort = InternalInitVersionedSortHandle(localeName, handleOrigin);
- }
-#else
- // coreclr will try to initialize the handle and if running on downlevel it'll just return null
- pSort = InternalInitOsSortHandle(localeName, handleOrigin);
-#endif // FEATURE_CORECLR
- return pSort;
-}
-
-#ifndef FEATURE_CORECLR
-INT_PTR COMNlsInfo::InternalInitVersionedSortHandle(LPCWSTR localeName, __out INT_PTR* handleOrigin)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- CANNOT_TAKE_LOCK;
- PRECONDITION(localeName != NULL);
- } CONTRACTL_END;
-
- AppDomain* curDomain = GetAppDomain();
-
- if(curDomain->m_pCustomSortLibrary != NULL)
- {
- return NULL;
- }
-
- return InternalInitVersionedSortHandle(localeName, handleOrigin, curDomain->m_sortVersion);
-}
-
-INT_PTR COMNlsInfo::InternalInitVersionedSortHandle(LPCWSTR localeName, __out INT_PTR* handleOrigin, DWORD sortVersion)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- CANNOT_TAKE_LOCK;
- PRECONDITION(localeName != NULL);
- } CONTRACTL_END;
-
- INT_PTR pSort = NULL;
-
- _ASSERTE(NewApis::NotLeakingFrameworkOnlyCultures(localeName));
-
- *handleOrigin = (INT_PTR) SortVersioning::GetSortHandle;
-
- // try the requested version
- if(sortVersion != DEFAULT_SORT_VERSION)
- {
- NLSVERSIONINFO sortVersionInfo;
- sortVersionInfo.dwNLSVersionInfoSize = sizeof(NLSVERSIONINFO);
- sortVersionInfo.dwNLSVersion = sortVersion;
- sortVersionInfo.dwDefinedVersion = sortVersion;
- pSort = (INT_PTR) SortVersioning::GetSortHandle(localeName, &sortVersionInfo);
- }
-
- // fallback to default version
- if(pSort == NULL)
- {
- pSort = (INT_PTR) SortVersioning::GetSortHandle(localeName, NULL);
- }
-
- _ASSERTE(RunningOnWin8() || pSort != NULL);
-
- return pSort;
-}
-#endif //FEATURE_CORECLR
-
-// Can return NULL
-INT_PTR COMNlsInfo::InternalInitOsSortHandle(LPCWSTR localeName, __out INT_PTR* handleOrigin)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- CANNOT_TAKE_LOCK;
- PRECONDITION(localeName != NULL);
- } CONTRACTL_END;
-
- INT_PTR pSort = NULL;
-
- AppDomain* curDomain = GetAppDomain();
-
-#ifndef FEATURE_CORECLR
- if (RunningOnWin8() || curDomain->m_pCustomSortLibrary != NULL)
-#else
- if (RunningOnWin8())
-#endif //FEATURE_CORECLR
- {
- LPARAM lSortHandle;
- int ret;
-
-#ifndef FEATURE_CORECLR
- if (curDomain->m_pCustomSortLibrary != NULL)
- {
- ret = (curDomain->m_pCustomSortLibrary->pLCMapStringEx)(localeName, LCMAP_SORTHANDLE, NULL, 0, (LPWSTR) &lSortHandle, sizeof(LPARAM), NULL, NULL, 0);
- *handleOrigin = (INT_PTR) curDomain->m_pCustomSortLibrary->pLCMapStringEx;
- }
- else
-#endif //FEATURE_CORECLR
- {
- ret = NewApis::LCMapStringEx(localeName, LCMAP_SORTHANDLE, NULL, 0, (LPWSTR) &lSortHandle, sizeof(LPARAM), NULL, NULL, 0);
- *handleOrigin = (INT_PTR) NewApis::LCMapStringEx;
- }
-
- if (ret != 0)
- {
- pSort = (INT_PTR) lSortHandle;
- }
- }
-
- return pSort;
-}
-
-BOOL QCALLTYPE COMNlsInfo::InternalGetNlsVersionEx(INT_PTR handle, INT_PTR handleOrigin, LPCWSTR lpLocaleName, NLSVERSIONINFOEX * lpVersionInformation)
-{
- CONTRACTL {
- QCALL_CHECK;
- } CONTRACTL_END;
-
- BOOL ret = FALSE;
-
- BEGIN_QCALL;
-#ifndef FEATURE_CORECLR
- AppDomain* curDomain = GetAppDomain();
-
- if(curDomain->m_bUseOsSorting)
- {
- if(curDomain->m_pCustomSortLibrary != NULL)
- {
- ret = (curDomain->m_pCustomSortLibrary->pGetNLSVersionEx)(COMPARE_STRING, lpLocaleName, lpVersionInformation);
- }
- else
- {
- ret = GetNLSVersionEx(COMPARE_STRING, lpLocaleName, lpVersionInformation);
- }
- }
- else
- {
- handle = EnsureValidSortHandle(handle, handleOrigin, lpLocaleName);
-
- NLSVERSIONINFO nlsVersion;
- nlsVersion.dwNLSVersionInfoSize = sizeof(NLSVERSIONINFO);
-
- ret = SortVersioning::SortGetNLSVersion((SortVersioning::PSORTHANDLE) handle, COMPARE_STRING, &nlsVersion);
-
- lpVersionInformation->dwNLSVersion = nlsVersion.dwNLSVersion;
- lpVersionInformation->dwDefinedVersion = nlsVersion.dwDefinedVersion;
- lpVersionInformation->dwEffectiveId = 0;
- ZeroMemory(&(lpVersionInformation->guidCustomVersion), sizeof(GUID));
- }
-#else
- ret = GetNLSVersionEx(COMPARE_STRING, lpLocaleName, lpVersionInformation);
-#endif // FEATURE_CORECLR
- END_QCALL;
-
- return ret;
-}
-
-#ifndef FEATURE_CORECLR
-DWORD QCALLTYPE COMNlsInfo::InternalGetSortVersion()
-{
- CONTRACTL {
- QCALL_CHECK;
- } CONTRACTL_END;
-
- DWORD version = DEFAULT_SORT_VERSION;
-
- BEGIN_QCALL;
-
- AppDomain* curDomain = GetAppDomain();
- version = curDomain->m_sortVersion;
-
- END_QCALL;
-
- return version;
-}
-
-#endif //FEATURE_CORECLR
diff --git a/src/classlibnative/nls/nlstable.cpp b/src/classlibnative/nls/nlstable.cpp
deleted file mode 100644
index dd395153d4..0000000000
--- a/src/classlibnative/nls/nlstable.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#include "common.h"
-#include <winwrap.h>
-#include <excep.h> // For COMPlusThrow
-#include <appdomain.hpp>
-#include <assembly.hpp>
-#include "nlstable.h" // Class declaration
-
-#if FEATURE_CODEPAGES_FILE
-
-/*=================================CreateSharedMemoryMapping==================================
-**Action: Create a file mapping object which can be shared among different users under Windows NT/2000.
-** Actually its just a memory mapped section of the swapfile.
-**Returns: The file mapping handle. NULL if any error happens.
-**Arguments:
-** pMappingName the name of the file mapping object.
-** iSize Size to use
-**Exceptions:
-**Note:
-** This function creates a DACL which grants GENERIC_ALL access to members of the "Everyone" group.
-** Then create a security descriptor using this DACL. Finally, use this SA to create the file mapping object.
-** WARNING:
-** This creates a shared file or shared paged memory section (if hFile == INVALID_HANDLE_VALUE) that is shared machine-wide
-** Therefore for side-by-side to work, the mapping names must be unique per version!
-** We utilize this feature for code pages in case it hasn't changed across versions we can still reuse the
-** tables, but it seems suspicious for other applications (as commented in MapDataFile below)
-==============================================================================*/
-// static method
-HANDLE NLSTable::CreateSharedMemoryMapping(const LPCWSTR pMappingName, const int iSize ) {
- CONTRACTL {
- THROWS;
- GC_NOTRIGGER;
- MODE_ANY;
- PRECONDITION(iSize > 0);
- PRECONDITION(CheckPointer(pMappingName));
- } CONTRACTL_END;
-
- HANDLE hFileMap = NULL;
-
- SECURITY_DESCRIPTOR sd ;
- SECURITY_ATTRIBUTES sa ;
-
- //
- // Create the sid for the Everyone group.
- //
- SID_IDENTIFIER_AUTHORITY siaWorld = SECURITY_WORLD_SID_AUTHORITY;
- PSID pSID = NULL;
- int nSidSize;
-
- PACL pDACL = NULL;
- int nAclSize;
-
- CQuickBytes newBuffer;
-
- if (!AllocateAndInitializeSid(&siaWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pSID)) {
- goto ErrorExit;
- }
-
- nSidSize = GetLengthSid(pSID);
-
- //
- // Create Discretionary Access Control List (DACL).
- //
-
- // First calculate the size of the DACL, since this is a linked-list like structure which contains one or more
- // ACE (access control entry)
- nAclSize = sizeof(ACL) // the header structure of ACL
- + sizeof(ACCESS_ALLOWED_ACE) + nSidSize; // and one "access allowed ACE".
-
- // We know the size needed for DACL now, so create it.
- // An exception is thrown if OOM happens.
- pDACL = (PACL) (newBuffer.AllocThrows(nAclSize));
- if(!InitializeAcl( pDACL, nAclSize, ACL_REVISION ))
- goto ErrorExit;
-
- // Add the "access allowed ACE", meaning:
- // we will allow members of the "Everyone" group to have SECTION_MAP_READ | SECTION_QUERY access to the file mapping object.
- // for memory sections the creator will still be allowed to create it.
- if(!AddAccessAllowedAce( pDACL, ACL_REVISION, SECTION_MAP_READ | SECTION_QUERY, pSID ))
- goto ErrorExit;
-
- //
- // Create Security descriptor (SD).
- //
- if(!InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION ))
- goto ErrorExit;
- // Set the previously created DACL to this SD.
- if(!SetSecurityDescriptorDacl( &sd, TRUE, pDACL, FALSE ))
- goto ErrorExit;
-
- // Create Security Attribute (SA).
- sa.nLength = sizeof( sa ) ;
- sa.bInheritHandle = TRUE ;
- sa.lpSecurityDescriptor = &sd ;
-
- //
- // Finally, create the file mapping using the SA.
- //
-
- // If we are on Windows 2000 or later, try to open it in global namespace. The \global namespace is ignored if
- // Terminal service is not running.
- WCHAR globalSectionName[MAX_LONGPATH];
- wcscpy_s(globalSectionName, COUNTOF(globalSectionName), W("Global\\"));
- if (wcslen(pMappingName) + wcslen(globalSectionName) >= MAX_LONGPATH) {
- goto ErrorExit;
- }
- wcscat_s(globalSectionName, COUNTOF(globalSectionName), pMappingName);
-
- // Try to create the section in the Global\ namespace. The CreateFileMapping() will ignore Global\ namespace if Terminal Service
- // is not running.
- hFileMap = WszCreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0, iSize, globalSectionName);
-
- // If not allowed to be global (like terminal server) or not WinNT, then open it in local namespace.
- if (hFileMap == NULL)
- {
- // Not WinNT or access denied for Global\ namespace, try the local namespace. When Terminal service is running, the Local\ namespace
- // means the namespace "Sessions\<n>\BasedNamedObjects".
- hFileMap = WszCreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0, iSize, pMappingName);
- }
-
-ErrorExit:
- if(pSID)
- FreeSid( pSID );
-
- // If still not allowed, try building one with no name
- if (hFileMap == NULL)
- {
- hFileMap = WszCreateFileMapping(
- INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, iSize, NULL);
- }
-
- return (hFileMap) ;
-}
-
-/*=================================OpenOrCreateMemoryMapping==================================
-**Action: Opens an existing memory mapped object, or creates a new one (by calling above fn).
-** Worst case just allocate some memory.
-**Returns: The pointer to our memory. NULL if any error happens.
-**Arguments:
-** pMappingName the name of the file mapping object.
-** iSize Size to use
-**Exceptions:
-**
-**IMPORTANT:
-** Memory mapped sections are cleared when set. We expect the caller to set the last int
-** to a non-zero value, so we test this flag. If it is still zero when we open it, we
-** assume that we've gotten a result in an unfinished state and allocate a new one instead
-** of trying to use the one with the zeros.
-**
-**Note:
-** This function creates a DACL which grants GENERIC_ALL access to members of the "Everyone" group.
-** Then create a security descriptor using this DACL. Finally, use this SA to create the file mapping object.
-** WARNING:
-** This creates a shared file or shared paged memory section (if hFile == INVALID_HANDLE_VALUE) that is shared machine-wide
-** Therefore for side-by-side to work, the mapping names must be unique per version!
-** We utilize this feature for code pages in case it hasn't changed across versions we can still reuse the
-** tables, but it seems suspicious for other applications (as commented in MapDataFile below)
-==============================================================================*/
-PBYTE NLSTable::OpenOrCreateMemoryMapping(const LPCWSTR pMappingName, const int iSize, HANDLE* mappedFile)
-{
- CONTRACTL
- {
- THROWS;
- DISABLED(GC_TRIGGERS); //
- MODE_ANY;
- PRECONDITION(iSize % 4 == 0);
- PRECONDITION(iSize > 0);
- PRECONDITION(CheckPointer(pMappingName));
- PRECONDITION(CheckPointer(mappedFile));
- } CONTRACTL_END;
-
- _ASSERTE(pMappingName != NULL); // Must have a string name.
- _ASSERTE(iSize > 0); // Pointless to have <= 0 allocation
- _ASSERTE(iSize % 4 == 0); // Need 4 byte alignment for flag check
-
- LPVOID pResult = NULL;
-
- // Try creating/opening it.
- HANDLE hMap = NULL;
-
- *mappedFile = hMap;
- // Calls into OS a lot, should switch to preemp mode
- GCX_PREEMP();
-
- // First try opening it. It might already be in existence
- // The assumption here is that it's rare that we will hit the cases where two or more threads are trying to create
- // the named section at the same time. Therefore, the following code does not use critical section or mutex trying
- // to synchornize different threads.
-
- // Try to open it in global namespace. The global\ namespace is ignored if terminal service is not running.
- WCHAR globalSectionName[MAX_LONGPATH];
- wcscpy_s(globalSectionName, COUNTOF(globalSectionName), W("Global\\"));
- if (wcslen(pMappingName) + wcslen(globalSectionName) >= MAX_LONGPATH)
- return NULL;
-
- wcscat_s(globalSectionName, COUNTOF(globalSectionName), pMappingName);
-
- hMap = WszOpenFileMapping(FILE_MAP_READ, TRUE, globalSectionName);
- if (hMap == NULL) {
- // If access is denied for global\namespace or the name is not opened in global namespace, try the local namespace.
- // Also if we're rotor or win 9x.
- hMap = WszOpenFileMapping(FILE_MAP_READ, TRUE, pMappingName);
- }
-
- if (hMap != NULL) {
- // We got a section, map a view, READ ONLY!
- pResult = MapViewOfFile( hMap, FILE_MAP_READ, 0, 0, 0);
-
- // Anything found?
- if (pResult != NULL)
- {
- // Make sure our result is allocated. We expect a non-0 flag to be set for last int of our section
- const int* pFlag = (int*)(((BYTE*)pResult) + iSize - 4);
- if (*pFlag != 0)
- {
- *mappedFile = hMap;
- // Found a valid already opened section!
- return (PBYTE)pResult;
- }
-
- // Couldn't find it, unmap it.
- UnmapViewOfFile(pResult);
- pResult = NULL;
- }
-
- // We can't use this one, so close it
- CloseHandle(hMap);
- hMap = NULL;
- }
-
- // Didn't get a section, try to create one, NT/XP/.Net gets security permissions, 9X doesn't,
- // but our helper fn takes care of that for us.
- hMap = NLSTable::CreateSharedMemoryMapping(pMappingName, iSize);
-
- // Were we successfull?
- if (hMap != NULL)
- {
- // We have hMap, try to get our section
- pResult = MapViewOfFile( hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
-
- // Don't close hMap unless we aren't using it.
- // That confuses the mapping stuff and we lose the name, it'll close when runtime shuts down.
- if (pResult == NULL)
- {
- CloseHandle(hMap);
- hMap = NULL;
- }
- // There is no need to zero out the mapCodePageCached field, since the initial contents of the pages in the file mapping object are zero.
-
- *mappedFile = hMap;
- }
-
- return (PBYTE)pResult;
-}
-
-#endif