Commit d6e76274 authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Add support for exception handling in the generated proxy code.

parent 900bc569
......@@ -109,6 +109,65 @@ static void init_proxy(const statement_list_t *stmts)
print_proxy( "\n");
print_proxy( "#include \"%s\"\n", header_name);
print_proxy( "\n");
print_proxy( "#ifndef USE_COMPILER_EXCEPTIONS\n");
print_proxy( "\n");
print_proxy( "#include \"wine/exception.h\"\n");
print_proxy( "#undef RpcTryExcept\n");
print_proxy( "#undef RpcExcept\n");
print_proxy( "#undef RpcEndExcept\n");
print_proxy( "#undef RpcExceptionCode\n");
print_proxy( "\n");
print_proxy( "struct __proxy_frame\n");
print_proxy( "{\n");
print_proxy( " EXCEPTION_REGISTRATION_RECORD frame;\n");
print_proxy( " sigjmp_buf jmp;\n");
print_proxy( " DWORD code;\n");
print_proxy( " MIDL_STUB_MESSAGE *stub;\n");
print_proxy( "};\n");
print_proxy( "\n");
print_proxy( "static DWORD __proxy_exception_handler( EXCEPTION_RECORD *record,\n");
print_proxy( " EXCEPTION_REGISTRATION_RECORD *frame,\n");
print_proxy( " CONTEXT *context,\n");
print_proxy( " EXCEPTION_REGISTRATION_RECORD **pdispatcher )\n");
print_proxy( "{\n");
print_proxy( " struct __proxy_frame *proxy_frame = (struct __proxy_frame *)frame;\n");
print_proxy( "\n");
print_proxy( " if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))\n");
print_proxy( " return ExceptionContinueSearch;\n");
print_proxy( " if (proxy_frame->stub->dwStubPhase == PROXY_SENDRECEIVE)\n");
print_proxy( " return ExceptionContinueSearch;\n");
print_proxy( "\n");
print_proxy( " proxy_frame->code = record->ExceptionCode;\n");
print_proxy( " __wine_rtl_unwind( frame, record );\n");
print_proxy( " __wine_pop_frame( frame );\n");
print_proxy( " siglongjmp( proxy_frame->jmp, 1 );\n");
print_proxy( "}\n");
print_proxy( "\n");
print_proxy( "#define RpcTryExcept \\\n");
print_proxy( " do { \\\n");
print_proxy( " struct __proxy_frame __proxy_frame; \\\n");
print_proxy( " __proxy_frame.frame.Handler = __proxy_exception_handler; \\\n");
print_proxy( " __proxy_frame.stub = &_StubMsg; \\\n");
print_proxy( " if (!sigsetjmp( __proxy_frame.jmp, 0 )) \\\n");
print_proxy( " { \\\n");
print_proxy( " __wine_push_frame( &__proxy_frame.frame ); \\\n");
print_proxy( " {\n");
print_proxy( "\n");
print_proxy( "#define RpcExcept(expr) \\\n");
print_proxy( " } \\\n");
print_proxy( " __wine_pop_frame( &__proxy_frame.frame ); \\\n");
print_proxy( " } \\\n");
print_proxy( " else \\\n");
print_proxy( " {\n");
print_proxy( "\n");
print_proxy( "#define RpcEndExcept \\\n");
print_proxy( " } \\\n");
print_proxy( " } while(0);\n");
print_proxy( "\n");
print_proxy( "#define RpcExceptionCode() (__proxy_frame.code)\n");
print_proxy( "\n");
print_proxy( "#endif /* USE_COMPILER_EXCEPTIONS */\n");
print_proxy( "\n");
write_formatstringsdecl(proxy, indent, stmts, need_proxy);
write_stubdescproto();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment