From 6bb9f2009090db86a5e52dd8a45ddbc960105965 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 4 Apr 2012 20:17:44 +0200 Subject: [PATCH] msvcrt: Use macros to define RTTI data. --- dlls/msvcrt/cpp.c | 244 +++++++++--------------------------------------------- 1 file changed, 41 insertions(+), 203 deletions(-) diff --git a/dlls/msvcrt/cpp.c b/dlls/msvcrt/cpp.c index dc609c1ccf7..6f5f0a54fbd 100644 --- a/dlls/msvcrt/cpp.c +++ b/dlls/msvcrt/cpp.c @@ -709,46 +709,48 @@ __ASM_EXCEPTION_VTABLE(__non_rtti_object) /* Static RTTI for exported objects */ -static const type_info exception_type_info = -{ - &MSVCRT_type_info_vtable, - NULL, - ".?AVexception@@" -}; - -static const rtti_base_descriptor exception_rtti_base_descriptor = -{ - &exception_type_info, - 0, - { 0, -1, 0 }, - 0 -}; - -static const rtti_base_array exception_rtti_base_array = -{ - { - &exception_rtti_base_descriptor, - NULL, - NULL - } -}; - -static const rtti_object_hierarchy exception_type_hierarchy = -{ - 0, - 0, - 1, - &exception_rtti_base_array -}; +#define DEFINE_RTTI_DATA(name, base_classes, cl1, cl2, mangled_name) \ +static const type_info name ## _type_info = { \ + &MSVCRT_type_info_vtable, \ + NULL, \ + mangled_name \ +}; \ +\ +static const rtti_base_descriptor name ## _rtti_base_descriptor = { \ + &name ##_type_info, \ + base_classes, \ + { 0, -1, 0}, \ + 0 \ +}; \ +\ +static const rtti_base_array name ## _rtti_base_array = { \ + { \ + &name ## _rtti_base_descriptor, \ + cl1, \ + cl2 \ + } \ +}; \ +\ +static const rtti_object_hierarchy name ## _hierarchy = { \ + 0, \ + 0, \ + base_classes+1, \ + &name ## _rtti_base_array \ +}; \ +\ +const rtti_object_locator name ## _rtti = { \ + 0, \ + 0, \ + 0, \ + &name ## _type_info, \ + &name ## _hierarchy \ +} -const rtti_object_locator exception_rtti = -{ - 0, - 0, - 0, - &exception_type_info, - &exception_type_hierarchy -}; +DEFINE_RTTI_DATA( type_info, 0, NULL, NULL, ".?AVtype_info@@" ); +DEFINE_RTTI_DATA( exception, 0, NULL, NULL, ".?AVexception@@" ); +DEFINE_RTTI_DATA( bad_typeid, 1, &exception_rtti_base_descriptor, NULL, ".?AVbad_typeid@@" ); +DEFINE_RTTI_DATA( bad_cast, 1, &exception_rtti_base_descriptor, NULL, ".?AVbad_cast@@" ); +DEFINE_RTTI_DATA( __non_rtti_object, 2, &bad_typeid_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AV__non_rtti_object@@" ); static const cxx_type_info exception_cxx_type_info = { @@ -759,47 +761,6 @@ static const cxx_type_info exception_cxx_type_info = (cxx_copy_ctor)THISCALL(MSVCRT_exception_copy_ctor) }; -static const type_info bad_typeid_type_info = -{ - &MSVCRT_type_info_vtable, - NULL, - ".?AVbad_typeid@@" -}; - -static const rtti_base_descriptor bad_typeid_rtti_base_descriptor = -{ - &bad_typeid_type_info, - 1, - { 0, -1, 0 }, - 0 -}; - -static const rtti_base_array bad_typeid_rtti_base_array = -{ - { - &bad_typeid_rtti_base_descriptor, - &exception_rtti_base_descriptor, - NULL - } -}; - -static const rtti_object_hierarchy bad_typeid_type_hierarchy = -{ - 0, - 0, - 2, - &bad_typeid_rtti_base_array -}; - -const rtti_object_locator bad_typeid_rtti = -{ - 0, - 0, - 0, - &bad_typeid_type_info, - &bad_typeid_type_hierarchy -}; - static const cxx_type_info bad_typeid_cxx_type_info = { 0, @@ -809,47 +770,6 @@ static const cxx_type_info bad_typeid_cxx_type_info = (cxx_copy_ctor)THISCALL(MSVCRT_bad_typeid_copy_ctor) }; -static const type_info bad_cast_type_info = -{ - &MSVCRT_type_info_vtable, - NULL, - ".?AVbad_cast@@" -}; - -static const rtti_base_descriptor bad_cast_rtti_base_descriptor = -{ - &bad_cast_type_info, - 1, - { 0, -1, 0 }, - 0 -}; - -static const rtti_base_array bad_cast_rtti_base_array = -{ - { - &bad_cast_rtti_base_descriptor, - &exception_rtti_base_descriptor, - NULL - } -}; - -static const rtti_object_hierarchy bad_cast_type_hierarchy = -{ - 0, - 0, - 2, - &bad_cast_rtti_base_array -}; - -const rtti_object_locator bad_cast_rtti = -{ - 0, - 0, - 0, - &bad_cast_type_info, - &bad_cast_type_hierarchy -}; - static const cxx_type_info bad_cast_cxx_type_info = { 0, @@ -859,47 +779,6 @@ static const cxx_type_info bad_cast_cxx_type_info = (cxx_copy_ctor)THISCALL(MSVCRT_bad_cast_copy_ctor) }; -static const type_info __non_rtti_object_type_info = -{ - &MSVCRT_type_info_vtable, - NULL, - ".?AV__non_rtti_object@@" -}; - -static const rtti_base_descriptor __non_rtti_object_rtti_base_descriptor = -{ - &__non_rtti_object_type_info, - 2, - { 0, -1, 0 }, - 0 -}; - -static const rtti_base_array __non_rtti_object_rtti_base_array = -{ - { - &__non_rtti_object_rtti_base_descriptor, - &bad_typeid_rtti_base_descriptor, - &exception_rtti_base_descriptor - } -}; - -static const rtti_object_hierarchy __non_rtti_object_type_hierarchy = -{ - 0, - 0, - 3, - &__non_rtti_object_rtti_base_array -}; - -const rtti_object_locator __non_rtti_object_rtti = -{ - 0, - 0, - 0, - &__non_rtti_object_type_info, - &__non_rtti_object_type_hierarchy -}; - static const cxx_type_info __non_rtti_object_cxx_type_info = { 0, @@ -909,47 +788,6 @@ static const cxx_type_info __non_rtti_object_cxx_type_info = (cxx_copy_ctor)THISCALL(MSVCRT___non_rtti_object_copy_ctor) }; -static const type_info type_info_type_info = -{ - &MSVCRT_type_info_vtable, - NULL, - ".?AVtype_info@@" -}; - -static const rtti_base_descriptor type_info_rtti_base_descriptor = -{ - &type_info_type_info, - 0, - { 0, -1, 0 }, - 0 -}; - -static const rtti_base_array type_info_rtti_base_array = -{ - { - &type_info_rtti_base_descriptor, - NULL, - NULL - } -}; - -static const rtti_object_hierarchy type_info_type_hierarchy = -{ - 0, - 0, - 1, - &type_info_rtti_base_array -}; - -const rtti_object_locator type_info_rtti = -{ - 0, - 0, - 0, - &type_info_type_info, - &type_info_type_hierarchy -}; - /* * Exception RTTI for cpp objects */ -- 2.11.4.GIT