Robert

On 2 Oct 2013, at 14:06, Robert Jordan <[email protected]> wrote

> Jonathan,
> 
> On 02.10.2013 12:21, [email protected] wrote:
>> The following raises so I presume that I have used it incorrectly:
>> 
>>     MonoClass *arrayClass = mono_get_byte_class();
>>     int32_t elementSize = mono_array_element_size(arrayClass);
>> 
>> * Assertion at class.c:8201, condition `ac->rank' not met
>> 
> 
> This is because arrayClass is not the MonoClass of a MonoArray.
> 
> You need something like that:
> 
> // assign the mono array
> uintptr_t byteLength = [self length];
> MonoArray *monoArray = mono_array_new(mono_domain_get(), 
> mono_get_byte_class(), byteLength);
> int32_t elementSize = 
> mono_array_element_size(mono_object_get_class((MonoObject*)monoArray);
> 
Yes. Seems sort of obvious now.

I am vaguely confused by the usage of the MonoClass here and elsewhere.
I have an object, monoArray, yet to query it I require a class reference.
This sort of logic wouldn't generally apply in an OOP environment (certainly 
not in Obj-C).
Generally, instances have a many to one relationship to their class.

What is the general relationship between a MonoObject and its corresponding 
MonoClass?
In the above example do all byte arrays share a MonoClass or is the class 
merely a struct configured for that particular array instance?

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

Reply via email to