2004-11-01 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Mon, 1 Nov 2004 10:50:23 +0000 (10:50 -0000)
committerZoltan Varga <vargaz@gmail.com>
Mon, 1 Nov 2004 10:50:23 +0000 (10:50 -0000)
* string-icalls.c (ves_icall_System_String_ctor_encoding):
Implement this. Fixes #67264.

* debug-helpers.h debug-helpers.c marshal.c: Move
mono_find_method_by_name to debug-helpers.c.

svn path=/trunk/mono/; revision=35524

mono/metadata/ChangeLog
mono/metadata/debug-helpers.c
mono/metadata/debug-helpers.h
mono/metadata/marshal.c
mono/metadata/string-icalls.c

index 68dd44151d5918371fb866c3931fa05db2c50e6f..e3f80903a1e519bb465680b19b15c3e802a91bb3 100644 (file)
@@ -1,3 +1,11 @@
+2004-11-01  Zoltan Varga  <vargaz@freemail.hu>
+
+       * string-icalls.c (ves_icall_System_String_ctor_encoding): 
+       Implement this. Fixes #67264.
+
+       * debug-helpers.h debug-helpers.c marshal.c: Move 
+       mono_find_method_by_name to debug-helpers.c.
+
 2004-10-31  Zoltan Varga  <vargaz@freemail.hu>
 
        * object.c (mono_release_type_locks): type_initialization_hash is
index 559a37c6f2e1cebe27520f0ac1ee44682b9e8f8e..0179cedbc81b230707ef2b2874bc983c1aba664a 100644 (file)
@@ -525,4 +525,22 @@ mono_method_full_name (MonoMethod *method, gboolean signature)
        return res;
 }
 
+MonoMethod *
+mono_find_method_by_name (MonoClass *klass, const char *name, int param_count)
+{
+       MonoMethod *res = NULL;
+       int i;
+
+       mono_class_init (klass);
+
+       for (i = 0; i < klass->method.count; ++i) {
+               if (klass->methods [i]->name[0] == name [0] && 
+                   !strcmp (name, klass->methods [i]->name) &&
+                   klass->methods [i]->signature->param_count == param_count) {
+                       res = klass->methods [i];
+                       break;
+               }
+       }
+       return res;
+}
 
index 56fbaddf9f7ed6174b96b1a81b973dfaa44e0b7d..9a0f887f9556b344d7e2eab2838bc308fe1dd6b6 100644 (file)
@@ -38,5 +38,7 @@ MonoMethod*     mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImag
 
 char*           mono_method_full_name (MonoMethod *method, gboolean signature);
 
+MonoMethod *    mono_find_method_by_name (MonoClass *klass, const char *name, int param_count);
+
 #endif /* __MONO_DEBUG_HELPERS_H__ */
 
index f7c50087fe2e519947e18494f40f6ade92e9b209..8175d017cde1e4ba9a81ae9f19c663cbe234aae9 100644 (file)
@@ -52,25 +52,6 @@ delegate_hash_table_add (MonoDelegate *d);
 static void
 emit_struct_conv (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_object);
 
-static MonoMethod *
-mono_find_method_by_name (MonoClass *klass, const char *name, int param_count)
-{
-       MonoMethod *res = NULL;
-       int i;
-
-       mono_class_init (klass);
-
-       for (i = 0; i < klass->method.count; ++i) {
-               if (klass->methods [i]->name[0] == name [0] && 
-                   !strcmp (name, klass->methods [i]->name) &&
-                   klass->methods [i]->signature->param_count == param_count) {
-                       res = klass->methods [i];
-                       break;
-               }
-       }
-       return res;
-}
-
 #ifdef DEBUG_RUNTIME_CODE
 static char*
 indenter (MonoDisHelper *dh, MonoMethod *method, guint32 ip_offset)
index 5e213edd6ef0d5bdf425cd6e833b330588007d96..01865fa839e5f9a9cb35bc9301126aeb2e9292ef 100644 (file)
 #include <signal.h>
 #include <string.h>
 #include <mono/metadata/string-icalls.h>
+#include <mono/metadata/class-internals.h>
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/metadata/loader.h>
 #include <mono/metadata/object.h>
 #include <mono/metadata/unicode.h>
 #include <mono/metadata/exception.h>
+#include <mono/metadata/debug-helpers.h>
 
 /* Internal helper methods */
 
@@ -184,10 +186,32 @@ ves_icall_System_String_ctor_encoding (gpointer dummy, gint8 *value, gint32 sind
                                    gint32 length, MonoObject *enc)
 {
        MONO_ARCH_SAVE_REGS;
+       MonoArray *arr;
+       MonoString *s;
+       MonoObject *exc;
+       MonoDomain *domain = mono_domain_get ();
+       MonoMethod *get_string;
+       gpointer args [1];
+
+       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);
+
+       get_string = mono_find_method_by_name (enc->vtable->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."));
 
-       g_warning("string.ctor with encoding obj unimplemented");
-       g_assert_not_reached ();
-       return NULL;
+       return s;
 }
 
 MonoString *