widl: Add support for exception handling in the generated server code.
This commit is contained in:
parent
336a7dc182
commit
900bc5697e
|
@ -382,7 +382,63 @@ static void init_server(void)
|
|||
print_server("#include <string.h>\n");
|
||||
fprintf(server, "\n");
|
||||
print_server("#include \"%s\"\n", header_name);
|
||||
fprintf(server, "\n");
|
||||
print_server("\n");
|
||||
print_server("#ifndef USE_COMPILER_EXCEPTIONS\n");
|
||||
print_server("\n");
|
||||
print_server("#include \"wine/exception.h\"\n");
|
||||
print_server("#undef RpcTryExcept\n");
|
||||
print_server("#undef RpcExcept\n");
|
||||
print_server("#undef RpcEndExcept\n");
|
||||
print_server("#undef RpcExceptionCode\n");
|
||||
print_server("\n");
|
||||
print_server( "struct __server_frame\n");
|
||||
print_server( "{\n");
|
||||
print_server( " EXCEPTION_REGISTRATION_RECORD frame;\n");
|
||||
print_server( " sigjmp_buf jmp;\n");
|
||||
print_server( "};\n");
|
||||
print_server( "\n");
|
||||
print_server("static DWORD __server_exception_handler( EXCEPTION_RECORD *record,\n");
|
||||
print_server(" EXCEPTION_REGISTRATION_RECORD *frame,\n");
|
||||
print_server(" CONTEXT *context,\n");
|
||||
print_server(" EXCEPTION_REGISTRATION_RECORD **pdispatcher )\n");
|
||||
print_server("{\n");
|
||||
print_server(" struct __server_frame *server_frame = (struct __server_frame *)frame;\n");
|
||||
print_server("\n");
|
||||
print_server(" if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))\n");
|
||||
print_server(" return ExceptionContinueSearch;\n");
|
||||
print_server("\n");
|
||||
print_server(" if (record->ExceptionCode != STATUS_ACCESS_VIOLATION &&\n");
|
||||
print_server(" record->ExceptionCode != STATUS_DATATYPE_MISALIGNMENT &&\n");
|
||||
print_server(" record->ExceptionCode != RPC_X_BAD_STUB_DATA &&\n");
|
||||
print_server(" record->ExceptionCode != RPC_S_INVALID_BOUND)\n");
|
||||
print_server(" return ExceptionContinueSearch;\n");
|
||||
print_server("\n");
|
||||
print_server(" __wine_rtl_unwind( frame, record );\n");
|
||||
print_server(" __wine_pop_frame( frame );\n");
|
||||
print_server(" siglongjmp( server_frame->jmp, 1 );\n");
|
||||
print_server("}\n");
|
||||
print_server("#define RpcTryExcept \\\n");
|
||||
print_server(" do { \\\n");
|
||||
print_server(" struct __server_frame __server_frame; \\\n");
|
||||
print_server(" __server_frame.frame.Handler = __server_exception_handler; \\\n");
|
||||
print_server(" if (!sigsetjmp( __server_frame.jmp, 0 )) \\\n");
|
||||
print_server(" { \\\n");
|
||||
print_server(" __wine_push_frame( &__server_frame.frame ); \\\n");
|
||||
print_server(" {\n");
|
||||
print_server("\n");
|
||||
print_server("#define RpcExcept(expr) \\\n");
|
||||
print_server(" } \\\n");
|
||||
print_server(" __wine_pop_frame( &__server_frame.frame ); \\\n");
|
||||
print_server(" } \\\n");
|
||||
print_server(" else \\\n");
|
||||
print_server(" {\n");
|
||||
print_server("\n");
|
||||
print_server("#define RpcEndExcept \\\n");
|
||||
print_server(" } \\\n");
|
||||
print_server(" } while(0);\n");
|
||||
print_server("\n");
|
||||
print_server("#endif /* USE_COMPILER_EXCEPTIONS */\n");
|
||||
print_server("\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue