X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fstring-icalls.c;h=71bd1f7ebe0f84a29f8570e354c3669b487aec17;hb=0699279f1fe5c695f1a3174de13925af51a1a78f;hp=4b8f9f9a420935159260cfae571496299df1b3be;hpb=4ba3ae74aaba78aa736ee994534234df0f785b21;p=mono.git diff --git a/mono/metadata/string-icalls.c b/mono/metadata/string-icalls.c index 4b8f9f9a420..71bd1f7ebe0 100644 --- a/mono/metadata/string-icalls.c +++ b/mono/metadata/string-icalls.c @@ -13,20 +13,44 @@ #include #include #include +#include #include #include #include #include -#include #include +#include /* Internal helper methods */ static gboolean string_icall_is_in_array (MonoArray *chars, gint32 arraylength, gunichar2 chr); -static gint32 -string_icall_cmp_char (gunichar2 c1, gunichar2 c2, gint16 mode); +static MonoString* +empty_string (MonoDomain *domain) +{ + MonoVTable *vtable = mono_class_vtable (domain, mono_defaults.string_class); + MonoObject *o; + static MonoClassField *empty_field = NULL; + + if (!empty_field) { + MonoClassField *field; + gpointer iter; + + iter = NULL; + while ((field = mono_class_get_fields (mono_defaults.string_class, &iter))) { + if (!strcmp (field->name, "Empty")) + break; + } + + g_assert (field); + empty_field = field; + } + + mono_field_static_get_value (vtable, empty_field, &o); + g_assert (o); + return (MonoString*)o; +} MonoString * ves_icall_System_String_ctor_charp (gpointer dummy, gunichar2 *value) @@ -34,14 +58,15 @@ ves_icall_System_String_ctor_charp (gpointer dummy, gunichar2 *value) gint32 i, length; MonoDomain *domain; + MONO_ARCH_SAVE_REGS; + domain = mono_domain_get (); if (value == NULL) - length = 0; - else { - for (i = 0; *(value + i) != '\0'; i++); - length = i; - } + return empty_string (domain); + + for (i = 0; *(value + i) != '\0'; i++); + length = i; return mono_string_new_utf16 (domain, value, length); } @@ -54,6 +79,11 @@ ves_icall_System_String_ctor_char_int (gpointer dummy, gunichar2 value, gint32 c gunichar2 *chars; gint32 i; + MONO_ARCH_SAVE_REGS; + + if (count < 0) + mono_raise_exception (mono_get_exception_argument_out_of_range ("count")); + domain = mono_domain_get (); res = mono_string_new_size (domain, count); @@ -70,6 +100,8 @@ ves_icall_System_String_ctor_charp_int_int (gpointer dummy, gunichar2 *value, gi gunichar2 *begin; MonoDomain * domain; + MONO_ARCH_SAVE_REGS; + domain = mono_domain_get (); if ((value == NULL) && (length != 0)) @@ -78,10 +110,8 @@ ves_icall_System_String_ctor_charp_int_int (gpointer dummy, gunichar2 *value, gi if ((sindex < 0) || (length < 0)) mono_raise_exception (mono_get_exception_argument_out_of_range ("Out of range")); - if (length == 0) { /* fixme: return String.Empty here */ - g_warning ("string doesn't yet support empy strings in char* constructor"); - g_assert_not_reached (); - } + if (length == 0) + return empty_string (domain); begin = (gunichar2 *) (value + sindex); @@ -93,12 +123,12 @@ ves_icall_System_String_ctor_sbytep (gpointer dummy, gint8 *value) { MonoDomain *domain; + MONO_ARCH_SAVE_REGS; + domain = mono_domain_get (); - if (NULL == value) { /* fixme: return String.Empty here */ - g_warning ("string doesn't yet support empy strings in char* constructor"); - g_assert_not_reached (); - } + if (NULL == value) + return empty_string (domain); return mono_string_new (domain, (const char *) value); } @@ -106,9 +136,14 @@ ves_icall_System_String_ctor_sbytep (gpointer dummy, gint8 *value) MonoString * ves_icall_System_String_ctor_sbytep_int_int (gpointer dummy, gint8 *value, gint32 sindex, gint32 length) { - char *begin; + guchar *begin; MonoDomain *domain; + MonoString *res; + gunichar2 *chars; + int i; + MONO_ARCH_SAVE_REGS; + domain = mono_domain_get (); if ((value == NULL) && (length != 0)) @@ -117,9 +152,13 @@ ves_icall_System_String_ctor_sbytep_int_int (gpointer dummy, gint8 *value, gint3 if ((sindex < 0) || (length < 0)) mono_raise_exception (mono_get_exception_argument_out_of_range ("Out of range")); - begin = (char *) (value + sindex); + begin = (guchar *) (value + sindex); + res = mono_string_new_size (domain, length); + chars = mono_string_chars (res); + for (i = 0; i < length; ++i) + chars [i] = begin [i]; - return mono_string_new_len (domain, begin, length); + return res; } MonoString * @@ -127,11 +166,14 @@ ves_icall_System_String_ctor_chara (gpointer dummy, MonoArray *value) { MonoDomain *domain; - MONO_CHECK_ARG_NULL (value); - + MONO_ARCH_SAVE_REGS; + domain = mono_domain_get (); - - return mono_string_new_utf16 (domain, (gunichar2 *) mono_array_addr(value, gunichar2, 0), value->max_length); + + if (value == NULL) + return mono_string_new_utf16 (domain, NULL, 0); + else + return mono_string_new_utf16 (domain, (gunichar2 *) mono_array_addr(value, gunichar2, 0), value->max_length); } MonoString * @@ -140,7 +182,16 @@ ves_icall_System_String_ctor_chara_int_int (gpointer dummy, MonoArray *value, { MonoDomain *domain; - MONO_CHECK_ARG_NULL (value); + MONO_ARCH_SAVE_REGS; + + if (value == NULL) + mono_raise_exception (mono_get_exception_argument_null ("value")); + if (sindex < 0) + mono_raise_exception (mono_get_exception_argument_out_of_range ("startIndex")); + if (length < 0) + mono_raise_exception (mono_get_exception_argument_out_of_range ("length")); + if (sindex + length > mono_array_length (value)) + mono_raise_exception (mono_get_exception_argument_out_of_range ("Out of range")); domain = mono_domain_get (); @@ -149,33 +200,56 @@ ves_icall_System_String_ctor_chara_int_int (gpointer dummy, MonoArray *value, MonoString * ves_icall_System_String_ctor_encoding (gpointer dummy, gint8 *value, gint32 sindex, - gint32 length, MonoObject *enc) -{ - g_warning("string.ctor with encoding obj unimplemented"); - g_assert_not_reached (); - return NULL; + gint32 length, MonoObject *enc) +{ + MonoArray *arr; + MonoString *s; + MonoObject *exc; + MonoDomain *domain = mono_domain_get (); + MonoMethod *get_string; + gpointer args [1]; + MonoClass *klass; + + MONO_ARCH_SAVE_REGS; + + if ((value == NULL) || (length == 0)) + return mono_string_new_size (mono_domain_get (), 0); + if (enc == NULL) + mono_raise_exception (mono_get_exception_argument_null ("enc")); + if (sindex < 0) + mono_raise_exception (mono_get_exception_argument_out_of_range ("startIndex")); + if (length < 0) + mono_raise_exception (mono_get_exception_argument_out_of_range ("length")); + + arr = mono_array_new (domain, mono_defaults.byte_class, length); + memcpy (mono_array_addr (arr, guint8, 0), value + sindex, length); + + /* Find the System.Text.Encoding class */ + for (klass = enc->vtable->klass; klass->parent->parent != NULL; klass = klass->parent) + ; + + get_string = mono_class_get_method_from_name (klass, "GetString", 1); + args [0] = arr; + s = (MonoString*)mono_runtime_invoke (get_string, enc, args, &exc); + if (!s || exc) + mono_raise_exception (mono_get_exception_argument ("", "Unable to decode the array into a valid string.")); + + return s; } -MonoBoolean -ves_icall_System_String_InternalEquals (MonoString *str1, MonoString *str2) +/* This function is redirected to String.CreateString () + by mono_marshal_get_native_wrapper () */ +void +ves_icall_System_String_ctor_RedirectToCreateString (void) { - gunichar2 *str1ptr; - gunichar2 *str2ptr; - gint32 str1len; - - /* Length checking is done in C# */ - str1len = mono_string_length(str1); - - str1ptr = mono_string_chars(str1); - str2ptr = mono_string_chars(str2); - - return (0 == memcmp(str1ptr, str2ptr, str1len * sizeof(gunichar2))); + g_assert_not_reached (); } MonoString * ves_icall_System_String_InternalJoin (MonoString *separator, MonoArray * value, gint32 sindex, gint32 count) { MonoString * ret; + MonoString *current; gint32 length; gint32 pos; gint32 insertlen; @@ -185,12 +259,17 @@ ves_icall_System_String_InternalJoin (MonoString *separator, MonoArray * value, gunichar2 *dest; gunichar2 *src; + MONO_ARCH_SAVE_REGS; + insert = mono_string_chars(separator); insertlen = mono_string_length(separator); length = 0; for (pos = sindex; pos != sindex + count; pos++) { - length += mono_string_length(mono_array_get(value, MonoString *, pos)); + current = mono_array_get (value, MonoString *, pos); + if (current != NULL) + length += mono_string_length (current); + if (pos < sindex + count - 1) length += insertlen; } @@ -200,11 +279,14 @@ ves_icall_System_String_InternalJoin (MonoString *separator, MonoArray * value, destpos = 0; for (pos = sindex; pos != sindex + count; pos++) { - src = mono_string_chars(mono_array_get(value, MonoString *, pos)); - srclen = mono_string_length(mono_array_get(value, MonoString *, pos)); + current = mono_array_get (value, MonoString *, pos); + if (current != NULL) { + src = mono_string_chars (current); + srclen = mono_string_length (current); - memcpy(dest + destpos, src, srclen * sizeof(gunichar2)); - destpos += srclen; + memcpy (dest + destpos, src, srclen * sizeof(gunichar2)); + destpos += srclen; + } if (pos < sindex + count - 1) { memcpy(dest + destpos, insert, insertlen * sizeof(gunichar2)); @@ -225,6 +307,8 @@ ves_icall_System_String_InternalInsert (MonoString *me, gint32 sindex, MonoStrin gint32 srclen; gint32 insertlen; + MONO_ARCH_SAVE_REGS; + src = mono_string_chars(me); srclen = mono_string_length(me); @@ -249,6 +333,8 @@ ves_icall_System_String_InternalReplace_Char (MonoString *me, gunichar2 oldChar, gunichar2 *dest; gint32 i, srclen; + MONO_ARCH_SAVE_REGS; + src = mono_string_chars(me); srclen = mono_string_length(me); @@ -265,66 +351,6 @@ ves_icall_System_String_InternalReplace_Char (MonoString *me, gunichar2 oldChar, return ret; } -MonoString * -ves_icall_System_String_InternalReplace_Str (MonoString *me, MonoString *oldValue, MonoString *newValue) -{ - MonoString *ret; - gunichar2 *src; - gunichar2 *dest; - gunichar2 *oldstr; - gunichar2 *newstr; - gint32 i, destpos; - gint32 occurr; - gint32 newsize; - gint32 oldstrlen; - gint32 newstrlen; - gint32 srclen; - - occurr = 0; - destpos = 0; - - oldstr = mono_string_chars(oldValue); - oldstrlen = mono_string_length(oldValue); - - if (NULL != newValue) { - newstr = mono_string_chars(newValue); - newstrlen = mono_string_length(newValue); - } else - newstrlen = 0; - - src = mono_string_chars(me); - srclen = mono_string_length(me); - - if (oldstrlen != newstrlen) { - for (i = 0; i <= srclen - oldstrlen; i++) - if (0 == memcmp(src + i, oldstr, oldstrlen * sizeof(gunichar2))) - occurr++; - - newsize = srclen + ((newstrlen - oldstrlen) * occurr); - } else - newsize = srclen; - - ret = mono_string_new_size( mono_domain_get (), newsize); - dest = mono_string_chars(ret); - - i = 0; - while (i < srclen) { - if (0 == memcmp(src + i, oldstr, oldstrlen * sizeof(gunichar2))) { - if (newstrlen > 0) { - memcpy(dest + destpos, newstr, newstrlen * sizeof(gunichar2)); - destpos += newstrlen; - } - i += oldstrlen; - } else { - dest[destpos] = src[i]; - destpos++; - i++; - } - } - - return ret; -} - MonoString * ves_icall_System_String_InternalRemove (MonoString *me, gint32 sindex, gint32 count) { @@ -333,6 +359,8 @@ ves_icall_System_String_InternalRemove (MonoString *me, gint32 sindex, gint32 co gunichar2 *dest; gunichar2 *src; + MONO_ARCH_SAVE_REGS; + srclen = mono_string_length(me); ret = mono_string_new_size( mono_domain_get (), srclen - count); @@ -351,6 +379,8 @@ ves_icall_System_String_InternalCopyTo (MonoString *me, gint32 sindex, MonoArray gunichar2 *destptr = (gunichar2 *) mono_array_addr(dest, gunichar2, dindex); gunichar2 *src = mono_string_chars(me); + MONO_ARCH_SAVE_REGS; + memcpy(destptr, src + sindex, sizeof(gunichar2) * count); } @@ -367,6 +397,8 @@ ves_icall_System_String_InternalSplit (MonoString *me, MonoArray *separator, gin gunichar2 cmpchar; + MONO_ARCH_SAVE_REGS; + src = mono_string_chars(me); srcsize = mono_string_length(me); arrsize = mono_array_length(separator); @@ -384,12 +416,8 @@ ves_icall_System_String_InternalSplit (MonoString *me, MonoArray *separator, gin /* if no split chars found return the string */ if (splitsize == 0) { - retarr = mono_array_new(mono_domain_get(), mono_defaults.string_class, 1); - tmpstr = mono_string_new_size( mono_domain_get (), srcsize); - tmpstrptr = mono_string_chars(tmpstr); - - memcpy(tmpstrptr, src, srcsize * sizeof(gunichar2)); - mono_array_set(retarr, MonoString *, 0, tmpstr); + retarr = mono_array_new(mono_domain_get(), mono_get_string_class (), 1); + mono_array_setref (retarr, 0, me); return retarr; } @@ -397,7 +425,7 @@ ves_icall_System_String_InternalSplit (MonoString *me, MonoArray *separator, gin if (splitsize != count) splitsize++; - retarr = mono_array_new(mono_domain_get(), mono_defaults.string_class, splitsize); + retarr = mono_array_new(mono_domain_get(), mono_get_string_class (), splitsize); for (i = 0; i != srcsize && arrpos != count; i++) { if (string_icall_is_in_array(separator, arrsize, src[i])) { if (arrpos == count - 1) @@ -409,7 +437,7 @@ ves_icall_System_String_InternalSplit (MonoString *me, MonoArray *separator, gin tmpstrptr = mono_string_chars(tmpstr); memcpy(tmpstrptr, src + lastpos, tmpstrsize * sizeof(gunichar2)); - mono_array_set(retarr, MonoString *, arrpos, tmpstr); + mono_array_setref (retarr, arrpos, tmpstr); arrpos++; lastpos = i + 1; } @@ -421,7 +449,7 @@ ves_icall_System_String_InternalSplit (MonoString *me, MonoArray *separator, gin tmpstrptr = mono_string_chars(tmpstr); memcpy(tmpstrptr, src + lastpos, tmpstrsize * sizeof(gunichar2)); - mono_array_set(retarr, MonoString *, arrpos, tmpstr); + mono_array_setref (retarr, arrpos, tmpstr); } return retarr; @@ -450,6 +478,8 @@ ves_icall_System_String_InternalTrim (MonoString *me, MonoArray *chars, gint32 t gint32 srclen, newlen, arrlen; gint32 i, lenfirst, lenlast; + MONO_ARCH_SAVE_REGS; + srclen = mono_string_length(me); src = mono_string_chars(me); arrlen = mono_array_length(chars); @@ -476,6 +506,8 @@ ves_icall_System_String_InternalTrim (MonoString *me, MonoArray *chars, gint32 t } newlen = srclen - lenfirst - lenlast; + if (newlen == srclen) + return me; ret = mono_string_new_size( mono_domain_get (), newlen); dest = mono_string_chars(ret); @@ -485,45 +517,6 @@ ves_icall_System_String_InternalTrim (MonoString *me, MonoArray *chars, gint32 t return ret; } -gint32 -ves_icall_System_String_InternalIndexOf_Char (MonoString *me, gunichar2 value, gint32 sindex, gint32 count) -{ - gint32 pos; - gunichar2 *src; - - src = mono_string_chars(me); - for (pos = sindex; pos != count + sindex; pos++) { - if ( src [pos] == value) - return pos; - } - - return -1; -} - -gint32 -ves_icall_System_String_InternalIndexOf_Str (MonoString *me, MonoString *value, gint32 sindex, gint32 count) -{ - gint32 lencmpstr; - gint32 pos, i; - gunichar2 *src; - gunichar2 *cmpstr; - - lencmpstr = mono_string_length(value); - - src = mono_string_chars(me); - cmpstr = mono_string_chars(value); - - count -= lencmpstr; - for (pos = sindex; pos <= sindex + count; pos++) { - for (i = 0; src [pos + i] == cmpstr [i];) { - if (++i == lencmpstr) - return pos; - } - } - - return -1; -} - gint32 ves_icall_System_String_InternalIndexOfAny (MonoString *me, MonoArray *arr, gint32 sindex, gint32 count) { @@ -532,6 +525,8 @@ ves_icall_System_String_InternalIndexOfAny (MonoString *me, MonoArray *arr, gint gint32 arraysize; gunichar2 *src; + MONO_ARCH_SAVE_REGS; + arraysize = mono_array_length(arr); src = mono_string_chars(me); @@ -550,6 +545,8 @@ ves_icall_System_String_InternalLastIndexOf_Char (MonoString *me, gunichar2 valu gint32 pos; gunichar2 *src; + MONO_ARCH_SAVE_REGS; + src = mono_string_chars(me); for (pos = sindex; pos > sindex - count; pos--) { if (src [pos] == value) @@ -567,6 +564,8 @@ ves_icall_System_String_InternalLastIndexOf_Str (MonoString *me, MonoString *val gunichar2 *src; gunichar2 *cmpstr; + MONO_ARCH_SAVE_REGS; + lencmpstr = mono_string_length(value); src = mono_string_chars(me); @@ -588,6 +587,8 @@ ves_icall_System_String_InternalLastIndexOfAny (MonoString *me, MonoArray *anyOf gint32 arraysize; gunichar2 *src; + MONO_ARCH_SAVE_REGS; + arraysize = mono_array_length(anyOf); src = mono_string_chars(me); @@ -610,6 +611,8 @@ ves_icall_System_String_InternalPad (MonoString *me, gint32 width, gunichar2 chr gint32 srclen; gint32 i; + MONO_ARCH_SAVE_REGS; + srclen = mono_string_length(me); src = mono_string_chars(me); @@ -634,47 +637,11 @@ ves_icall_System_String_InternalPad (MonoString *me, gint32 width, gunichar2 chr return ret; } -MonoString * -ves_icall_System_String_InternalToLower (MonoString *me) -{ - MonoString * ret; - gunichar2 *src; - gunichar2 *dest; - gint32 i; - - ret = mono_string_new_size(mono_domain_get (), mono_string_length(me)); - - src = mono_string_chars (me); - dest = mono_string_chars (ret); - - for (i = 0; i < mono_string_length (me); ++i) - dest[i] = g_unichar_tolower(src[i]); - - return ret; -} - -MonoString * -ves_icall_System_String_InternalToUpper (MonoString *me) -{ - int i; - MonoString * ret; - gunichar2 *src; - gunichar2 *dest; - - ret = mono_string_new_size(mono_domain_get (), mono_string_length(me)); - - src = mono_string_chars (me); - dest = mono_string_chars (ret); - - for (i = 0; i < mono_string_length (me); ++i) - dest[i] = g_unichar_toupper(src[i]); - - return ret; -} - MonoString * ves_icall_System_String_InternalAllocateStr (gint32 length) { + MONO_ARCH_SAVE_REGS; + return mono_string_new_size(mono_domain_get (), length); } @@ -684,10 +651,12 @@ ves_icall_System_String_InternalStrcpy_Str (MonoString *dest, gint32 destPos, Mo gunichar2 *srcptr; gunichar2 *destptr; + MONO_ARCH_SAVE_REGS; + srcptr = mono_string_chars (src); destptr = mono_string_chars (dest); - memcpy(destptr + destPos, srcptr, mono_string_length(src) * sizeof(gunichar2)); + g_memmove (destptr + destPos, srcptr, mono_string_length(src) * sizeof(gunichar2)); } void @@ -696,126 +665,71 @@ ves_icall_System_String_InternalStrcpy_StrN (MonoString *dest, gint32 destPos, M gunichar2 *srcptr; gunichar2 *destptr; + MONO_ARCH_SAVE_REGS; + srcptr = mono_string_chars (src); destptr = mono_string_chars (dest); - memcpy(destptr + destPos, srcptr + startPos, count * sizeof(gunichar2)); -} - -MonoString * -ves_icall_System_String_InternalIntern (MonoString *str) -{ - return mono_string_intern(str); + g_memmove (destptr + destPos, srcptr + startPos, count * sizeof(gunichar2)); } -MonoString * -ves_icall_System_String_InternalIsInterned (MonoString *str) -{ - return mono_string_is_interned(str); -} - -gint32 -ves_icall_System_String_InternalCompareStr_N (MonoString *s1, gint32 i1, MonoString *s2, gint32 i2, gint32 length, MonoBoolean inCase) +void +ves_icall_System_String_InternalStrcpy_Chars (MonoString *dest, gint32 destPos, MonoArray *src) { - /* c translation of C# code from old string.cs.. :) */ - gint32 lenstr1; - gint32 lenstr2; - gint32 charcmp; - gunichar2 *str1; - gunichar2 *str2; + gunichar2 *srcptr; + gunichar2 *destptr; - gint32 pos; - gint16 mode; - - if (inCase) - mode = 1; - else - mode = 0; + MONO_ARCH_SAVE_REGS; - lenstr1 = mono_string_length(s1); - lenstr2 = mono_string_length(s2); + srcptr = mono_array_addr (src, gunichar2, 0); + destptr = mono_string_chars (dest); - str1 = mono_string_chars(s1); - str2 = mono_string_chars(s2); + g_memmove (destptr + destPos, srcptr, mono_array_length (src) * sizeof(gunichar2)); +} - pos = 0; +void +ves_icall_System_String_InternalStrcpy_CharsN (MonoString *dest, gint32 destPos, MonoArray *src, gint32 startPos, gint32 count) +{ + gunichar2 *srcptr; + gunichar2 *destptr; - for (pos = 0; pos != length; pos++) { - if (i1 + pos >= lenstr1 || i2 + pos >= lenstr2) - break; + MONO_ARCH_SAVE_REGS; - charcmp = string_icall_cmp_char(str1[i1 + pos], str2[i2 + pos], mode); - if (charcmp != 0) - return charcmp; - } + srcptr = mono_array_addr (src, gunichar2, 0); + destptr = mono_string_chars (dest); - /* the lesser wins, so if we have looped until length we just need to check the last char */ - if (pos == length) { - return string_icall_cmp_char(str1[i1 + pos - 1], str2[i2 + pos - 1], mode); - } + g_memmove (destptr + destPos, srcptr + startPos, count * sizeof(gunichar2)); +} - /* Test if one the strings has been compared to the end */ - if (i1 + pos >= lenstr1) { - if (i2 + pos >= lenstr2) - return 0; - else - return -1; - } else if (i2 + pos >= lenstr2) - return 1; +MonoString * +ves_icall_System_String_InternalIntern (MonoString *str) +{ + MONO_ARCH_SAVE_REGS; - /* if not, check our last char only.. (can this happen?) */ - return string_icall_cmp_char(str1[i1 + pos], str2[i2 + pos], mode); + return mono_string_intern(str); } -gint32 -ves_icall_System_String_GetHashCode (MonoString *me) +MonoString * +ves_icall_System_String_InternalIsInterned (MonoString *str) { - int i, h = 0; - gunichar2 *data = mono_string_chars (me); + MONO_ARCH_SAVE_REGS; - for (i = 0; i < mono_string_length (me); ++i) - h = (h << 5) - h + data [i]; - - return h; + return mono_string_is_interned(str); } gunichar2 ves_icall_System_String_get_Chars (MonoString *me, gint32 idx) { + MONO_ARCH_SAVE_REGS; + + if ((idx < 0) || (idx >= mono_string_length (me))) + mono_raise_exception (mono_get_exception_index_out_of_range ()); return mono_string_chars(me)[idx]; } -/* @mode : 0 = StringCompareModeDirect - 1 = StringCompareModeCaseInsensitive - 2 = StringCompareModeOrdinal -*/ -static gint32 -string_icall_cmp_char (gunichar2 c1, gunichar2 c2, gint16 mode) +void +ves_icall_System_String_InternalCharCopy (gunichar2 *src, gunichar2 *dest, gint32 count) { - gint32 result; - GUnicodeType c1type, c2type; - - c1type = g_unichar_type (c1); - c2type = g_unichar_type (c2); - - switch (mode) { - case 0: - /* TODO: compare with culture info */ - if (c1type == G_UNICODE_UPPERCASE_LETTER && c2type == G_UNICODE_LOWERCASE_LETTER) - return 1; - - if (c1type == G_UNICODE_LOWERCASE_LETTER && c2type == G_UNICODE_UPPERCASE_LETTER) - return -1; - - result = (gint32) c1 - c2; - break; - case 1: - result = (gint32) (c1type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c1) : c1) - - (c2type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c2) : c2); - break; - case 2: - result = (gint32) c1 - c2; - break; - } + MONO_ARCH_SAVE_REGS; - return ((result < 0) ? -1 : (result > 0) ? 1 : 0); + memcpy (dest, src, sizeof (gunichar2) * count); }