Piotr Caban : msvcp90: Use throw_exception helper to throw exception object only.

Alexandre Julliard julliard at winehq.org
Fri Aug 27 15:03:34 CDT 2021


Module: wine
Branch: master
Commit: 731dca90c7fa0e09594e1505daca83b75a79815f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=731dca90c7fa0e09594e1505daca83b75a79815f

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Aug 27 13:48:39 2021 +0200

msvcp90: Use throw_exception helper to throw exception object only.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp90/cxx.h       |  8 --------
 dlls/msvcp90/exception.c | 30 +++++++-----------------------
 dlls/msvcp90/misc.c      |  2 +-
 dlls/msvcp90/msvcp90.h   |  1 +
 4 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/dlls/msvcp90/cxx.h b/dlls/msvcp90/cxx.h
index 58f6fe43586..29854d16bab 100644
--- a/dlls/msvcp90/cxx.h
+++ b/dlls/msvcp90/cxx.h
@@ -314,14 +314,6 @@ typedef struct __exception
     int               do_free; /* Whether to free 'name' in our dtor */
 } exception;
 
-/* Internal: throws selected exception */
-typedef enum __exception_type {
-    EXCEPTION,
-    EXCEPTION_BAD_CAST,
-    EXCEPTION_LOGIC_ERROR,
-} exception_type;
-void throw_exception(exception_type, const char *);
-
 /* rtti */
 typedef struct __type_info
 {
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c
index 977bdff9739..e5b6018fe31 100644
--- a/dlls/msvcp90/exception.c
+++ b/dlls/msvcp90/exception.c
@@ -399,7 +399,7 @@ DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_er
 #else
 DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@@")
 #endif
-DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
+DEFINE_CXX_TYPE_INFO(logic_error)
 
 /* length_error class data */
 typedef logic_error length_error;
@@ -817,7 +817,6 @@ bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs
 }
 
 DEFINE_RTTI_DATA1(bad_cast, 0, &exception_rtti_base_descriptor, ".?AVbad_cast at std@@")
-DEFINE_CXX_DATA1(bad_cast, &exception_cxx_type_info, MSVCP_bad_cast_dtor)
 
 /* range_error class data */
 typedef runtime_error range_error;
@@ -1065,28 +1064,14 @@ __ASM_BLOCK_BEGIN(exception_vtables)
             VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
 __ASM_BLOCK_END
 
-/* Internal: throws selected exception */
-void throw_exception(exception_type et, const char *str)
+/* Internal: throws exception */
+void DECLSPEC_NORETURN throw_exception(const char *str)
 {
     exception_name name = EXCEPTION_NAME(str);
+    exception e;
 
-    switch(et) {
-    case EXCEPTION: {
-        exception e;
-        MSVCP_exception_ctor(&e, name);
-        _CxxThrowException(&e, &exception_cxx_type);
-    }
-    case EXCEPTION_BAD_CAST: {
-        bad_cast e;
-        MSVCP_bad_cast_ctor(&e, str);
-        _CxxThrowException(&e, &bad_cast_cxx_type);
-    }
-    case EXCEPTION_LOGIC_ERROR: {
-        logic_error e;
-        MSVCP_logic_error_ctor(&e, name);
-        _CxxThrowException(&e, &logic_error_cxx_type);
-    }
-    }
+    MSVCP_exception_ctor(&e, name);
+    _CxxThrowException(&e, &exception_cxx_type);
 }
 
 /* Internal: throws range_error exception */
@@ -1132,7 +1117,7 @@ void init_exception(void *base)
 
     init_exception_cxx(base);
     init_bad_alloc_cxx(base);
-    init_logic_error_cxx(base);
+    init_logic_error_cxx_type_info(base);
     init_length_error_cxx(base);
     init_out_of_range_cxx(base);
     init_invalid_argument_cxx(base);
@@ -1144,7 +1129,6 @@ void init_exception(void *base)
     init_system_error_cxx_type_info(base);
 #endif
     init_failure_cxx(base);
-    init_bad_cast_cxx(base);
     init_range_error_cxx(base);
 #endif
 }
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c
index 8eacccc1461..5c4f997411a 100644
--- a/dlls/msvcp90/misc.c
+++ b/dlls/msvcp90/misc.c
@@ -700,7 +700,7 @@ unsigned int __cdecl _Random_device(void)
 
     /* TODO: throw correct exception in case of failure */
     if(rand_s(&ret))
-        throw_exception(EXCEPTION, "random number generator failed\n");
+        throw_exception("random number generator failed\n");
     return ret;
 }
 #endif
diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h
index e917fad4e28..4aa88e028d6 100644
--- a/dlls/msvcp90/msvcp90.h
+++ b/dlls/msvcp90/msvcp90.h
@@ -669,5 +669,6 @@ void __cdecl DECLSPEC_NORETURN _Xlength_error(const char*);
 void __cdecl DECLSPEC_NORETURN _Xmem(void);
 void __cdecl DECLSPEC_NORETURN _Xout_of_range(const char*);
 void __cdecl DECLSPEC_NORETURN _Xruntime_error(const char*);
+void DECLSPEC_NORETURN throw_exception(const char*);
 void DECLSPEC_NORETURN throw_failure(const char*);
 void DECLSPEC_NORETURN throw_range_error(const char*);




More information about the wine-cvs mailing list