Re: [Mono-dev] Embedded API: mono_array_element_size issue

2013-10-08 Thread personalgame

With player-led events such as the Battle of Lumbridge and community-voted
quests such asBirthright of the Dwarves, the future of Gielinor has been put
in your hands, and it’s your votes that will decide the winner of this
coveted Golden Joystick Award.in http://www.mmo2buy.com/RS2007-Gold.html



--
View this message in context: 
http://mono.1490590.n4.nabble.com/Embedded-API-mono-array-element-size-issue-tp4661021p4661048.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Embedded API: mono_array_element_size issue

2013-10-02 Thread jonat...@mugginsoft.com
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

The entire method is:

- (MonoArray *)monoArray {

// get mono array info
MonoClass *arrayClass = mono_get_byte_class();
int32_t elementSize = mono_array_element_size(arrayClass);
//int32_t elementSize = sizeof(char);  // workaround

// assign the mono array
uintptr_t byteLength = [self length];
MonoArray *monoArray = mono_array_new(mono_domain_get(), arrayClass, 
byteLength);

// copy the NSData bytes  to the Mono array
char *buffer = mono_array_addr_with_size(monoArray, elementSize, 0);
[self getBytes:buffer length:[self length]];

return(monoArray);
}

Jonathan










___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Embedded API: mono_array_element_size issue

2013-10-02 Thread Robert Jordan

Jonathan,

On 02.10.2013 12:21, jonat...@mugginsoft.com 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);


Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list