From 766bf49afbebcb889cc8da96664186615c868260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Wed, 7 Feb 2018 13:01:19 -0500 Subject: [metadata] Define getters for MonoClass fields (#6652) * [configure.ac] Add --enable-checked-build=private_types option The idea is that when private_types is turned on, we will hide the definitions of various structs in Mono and only allow access via getter/setter methods. If private_types is off, those same getters would be static inline functions and also the struct definition would be visible (to allow for incremental conversion of existing code). * [metadata] Move _MonoClass definition to class-private-definition.h * [metadata] Define a getter for every MonoClass field in a checked build, the getters are just declared in class-internals.h and defined in class-accessors.h in a non-checked build, the getters are static inline functions in class-internals.h For a field foo of type FooType define FooType m_class_get_foo (MonoClass *klass) { return klass->foo; } The exceptions are fields that are embedded structs, e.g. MonoType byval_arg, for those we return a pointer to the field instead of a copy: MonoType * m_class_get_byval_arg (MonoClass *klass) { return &klass->byval_arg; } * [metadata] Rename MonoClass boolean getters to use is/has names instead of the string m_class_get_fieldname pattern - m_class_is_inited - m_class_is_size_inited - m_class_is_valuetype - m_class_is_enumtype - m_class_is_blittable - m_class_is_unicode - m_class_was_typebuilder - m_class_is_ghcimpl - m_class_has_finalize - m_class_is_delegate - m_class_is_gc_descr_inited - m_class_has_cctor - m_class_has_references - m_class_has_static_refs - m_class_has_no_special_static_fields - m_class_is_com_object - m_class_is_interfaces_inited - m_class_is_simd_type - m_class_is_has_finalize_inited - m_class_is_fields_inited - m_class_has_failure * [metadata] (class-internals.h) Use m_class_get_ getters * [metadata] (class-inlines.h) Use m_class_get_ getters * [metadata] (class-accessors.c) Use m_class_get_ getters; setters not done The setters are not converted. Ultimately, I think that will sort itself out - a few of them are only used from SRE and from MonoClass construction - we will eventually provide setters for just two places and hide them elsewhere. --- msvc/libmonoruntime-common.targets.filters | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'msvc/libmonoruntime-common.targets.filters') diff --git a/msvc/libmonoruntime-common.targets.filters b/msvc/libmonoruntime-common.targets.filters index 6892b165a04..2d501392ae7 100644 --- a/msvc/libmonoruntime-common.targets.filters +++ b/msvc/libmonoruntime-common.targets.filters @@ -28,6 +28,9 @@ Source Files$(MonoRuntimeFilterSubFolder)\common + + Header Files$(MonoRuntimeFilterSubFolder)\common + Header Files$(MonoRuntimeFilterSubFolder)\common @@ -43,6 +46,9 @@ Header Files$(MonoRuntimeFilterSubFolder)\common + + Header Files$(MonoRuntimeFilterSubFolder)\common + Source Files$(MonoRuntimeFilterSubFolder)\common -- cgit v1.2.3