diff --git a/mono/metadata/object.c b/mono/metadata/object.c index a95eeaa94b06..c2c41734946e 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -3448,6 +3448,28 @@ mono_field_set_value (MonoObject *obj, MonoClassField *field, void *value) MONO_EXTERNAL_ONLY_GC_UNSAFE_VOID (mono_field_set_value_internal (obj, field, value)); } +void +mono_field_set_value_offset_internal (MonoObject* obj, MonoClassField* field, int declaring_field_offset, void* value) +{ + void* dest; + + if ((field->type->attrs & FIELD_ATTRIBUTE_STATIC)) + return; + + dest = (char*)obj + field->offset + declaring_field_offset - MONO_ABI_SIZEOF(MonoObject); +#if ENABLE_NETCORE + mono_copy_value (field->type, dest, value, value && field->type->type == MONO_TYPE_PTR); +#else + mono_copy_value (field->type, dest, value, FALSE); +#endif +} + +void +mono_unity_field_set_value_offset (MonoObject* obj, MonoClassField* field, int declaring_field_offset, void* value) +{ + MONO_EXTERNAL_ONLY_GC_UNSAFE_VOID (mono_field_set_value_offset_internal (obj, field, declaring_field_offset, value)); +} + void mono_field_static_set_value_internal (MonoVTable *vt, MonoClassField *field, void *value) { @@ -3576,6 +3598,27 @@ mono_field_get_value_internal (MonoObject *obj, MonoClassField *field, void *val mono_copy_value (field->type, value, src, TRUE); } +void +mono_field_get_value_offset_internal(MonoObject* obj, MonoClassField* field, int declaring_field_offset, void* value) +{ + MONO_REQ_GC_UNSAFE_MODE; + + void* src; + + g_assert (obj); + + g_return_if_fail (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)); + + src = (char*)obj + field->offset + declaring_field_offset - MONO_ABI_SIZEOF(MonoObject); + mono_copy_value (field->type, value, src, TRUE); +} + +void +mono_unity_field_get_value_offset(MonoObject* obj, MonoClassField* field, int declaring_field_offset, void* value) +{ + MONO_EXTERNAL_ONLY_GC_UNSAFE_VOID (mono_field_get_value_offset_internal (obj, field, declaring_field_offset, value)); +} + /** * mono_field_get_value_object: * \param domain domain where the object will be created (if boxing) @@ -9413,6 +9456,22 @@ mono_array_length (MonoArray *array) MONO_EXTERNAL_ONLY (uintptr_t, mono_array_length_internal (array)); } +void +mono_unity_array_set_range(MonoArray* dest, uintptr_t destidx, void* src, uintptr_t byteSize) +{ + int32_t element_size = mono_array_element_size (dest->obj.vtable->klass); + char* start = mono_array_addr_with_size_fast (dest, element_size, destidx); + memcpy(start, src, byteSize); +} + +void +mono_unity_array_get_range(MonoArray* src, uintptr_t srcidx, void* dest, uintptr_t byteSize) +{ + int32_t element_size = mono_array_element_size(src->obj.vtable->klass); + char* start = mono_array_addr_with_size_fast(src, element_size, srcidx); + memcpy(dest, start, byteSize); +} + #ifdef ENABLE_CHECKED_BUILD_GC /** diff --git a/mono/metadata/object.h b/mono/metadata/object.h index 377e3fcd7e18..a83f870f1621 100644 --- a/mono/metadata/object.h +++ b/mono/metadata/object.h @@ -117,6 +117,12 @@ mono_array_addr_with_size (MonoArray *array, int size, uintptr_t idx); MONO_API MONO_RT_EXTERNAL_ONLY uintptr_t mono_array_length (MonoArray *array); +MONO_API MONO_RT_EXTERNAL_ONLY void +mono_unity_array_set_range(MonoArray* dest, uintptr_t destidx, void* src, uintptr_t byteSize); + +MONO_API MONO_RT_EXTERNAL_ONLY void +mono_unity_array_get_range(MonoArray* src, uintptr_t srcidx, void* dest, uintptr_t byteSize); + MONO_API MONO_RT_EXTERNAL_ONLY MonoString* mono_string_empty (MonoDomain *domain); @@ -347,6 +353,12 @@ mono_field_static_get_value (MonoVTable *vt, MonoClassField *field, void *value) MONO_API MONO_RT_EXTERNAL_ONLY MonoObject * mono_field_get_value_object (MonoDomain *domain, MonoClassField *field, MonoObject *obj); +MONO_API MONO_RT_EXTERNAL_ONLY void +mono_unity_field_set_value_offset (MonoObject* obj, MonoClassField* field, int declaring_field_offset, void* value); + +MONO_API MONO_RT_EXTERNAL_ONLY void +mono_unity_field_get_value_offset (MonoObject* obj, MonoClassField* field, int declaring_field_offset, void* value); + MONO_API MONO_RT_EXTERNAL_ONLY void mono_property_set_value (MonoProperty *prop, void *obj, void **params, MonoObject **exc);