Hi Rob,

Is WIDL supposed to generate code that's compatible with Windows RPCRT4.DLL?
Because it appears this is currently not the case. When you look at
http://test.winehq.org you'll see that the rpcrt4:server test fails on
pretty much any Windows version.

I investigated a bit more, the failures are caused by an exception 0x6e6
("An internal error occurred in a remote procedure call (RPC)" thrown from
NdrPointerBufferSize() in server_c.c function get_name(). The
mingw-crosscompiled executable doesn't handle that exception which causes
the process to crash. Since this is in WIDL-generated code, I decided to
take a look at what MIDL generates for the same IDL file.

It turns out that MIDL treats the name_t struct as a simple structure, while
WIDL treats it as a complex structure. That made comparison a bit difficult.
Since WIDL never seems to generate simple structures, I tried to convince
MIDL to generate a complex structure too. After a bit of fiddling around
(I'm no IDL expert...) I came up with the following type, a mix of name_t
and sun_t:

typedef struct
{
  [string, size_is(size)] char *name;
  unsigned int size;

  [switch_is(s)] union
  {
    [case(SUN_I)] int i;
    [case(SUN_F1, SUN_F2)] float f;
    [case(SUN_PI)] int *pi;
  } u;

  int s;
} complex_t;

After staring at the WIDL-generated and MIDL-generated code for a while
(which still differed quite a bit), I noticed something interesting: in the
type format string, "unsigned int size" gets encoded as FC_ULONG by WIDL,
but as FC_LONG by MIDL. I then went back to the server_c.c and server_s.c
files generated by WIDL for the tests and changed the type format strings
there (replaced the "unsigned int size" encoding from FC_ULONG by FC_LONG).
With this change, the get_name() test passes :-). It then crashes later on
with an access violation inside NdrVaryingArrayUnmarshall() in
get_5numbers(), but let's take the problems one at a time...

So it appears Windows RPCRT4.dll is not happy with FC_ULONG entries within a
complex structure. I added a bunch of other primitive types to my complex_t
structure to see how they are treated by MIDL. See attached complex.idl file
and the MIDL-generated midl_complex_c.c file (also attached WIDL-generated
widl_complex_c.c for completeness). It appears that MIDL simply drops the
"unsigned" from any base type, at least within complex structures. "unsigned
long" gets encoded as FC_LONG, "unsigned short" as FC_SHORT and "unsigned
small" as FC_SMALL.

Like I said, I'm no IDL expert. Does the stuff above make sense to you? Do
you think it would be a good idea to change WIDL to generate the same
encodings as MIDL?

Thanks, Gé.
/*** Autogenerated by WIDL 1.1.12 from complex.idl - Do not edit ***/
#include <string.h>
#ifdef _ALPHA_
#include <stdarg.h>
#endif

#include "complex.h"

#ifndef DECLSPEC_HIDDEN
#define DECLSPEC_HIDDEN
#endif

#ifndef USE_COMPILER_EXCEPTIONS

#include "wine/exception.h"
#undef RpcTryExcept
#undef RpcExcept
#undef RpcEndExcept
#undef RpcTryFinally
#undef RpcFinally
#undef RpcEndFinally
#undef RpcExceptionCode
#undef RpcAbnormalTermination

struct __exception_frame;
typedef int (*__filter_func)(EXCEPTION_RECORD *, struct __exception_frame *);
typedef void (*__finally_func)(struct __exception_frame *);

#define __DECL_EXCEPTION_FRAME \
    EXCEPTION_REGISTRATION_RECORD frame; \
    __filter_func                 filter; \
    __finally_func                finally; \
    sigjmp_buf                    jmp; \
    DWORD                         code; \
    unsigned char                 abnormal_termination; \
    unsigned char                 filter_level; \
    unsigned char                 finally_level;

struct __exception_frame
{
    __DECL_EXCEPTION_FRAME
};

static DWORD __widl_exception_handler( EXCEPTION_RECORD *record,
                                       EXCEPTION_REGISTRATION_RECORD *frame,
                                       CONTEXT *context,
                                       EXCEPTION_REGISTRATION_RECORD 
**pdispatcher )
{
    struct __exception_frame *exc_frame = (struct __exception_frame *)frame;

    if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | 
EH_NESTED_CALL))
    {
        if (exc_frame->finally_level && (record->ExceptionFlags & (EH_UNWINDING 
| EH_EXIT_UNWIND)))
        {
            exc_frame->abnormal_termination = 1;
            exc_frame->finally( exc_frame );
        }
        return ExceptionContinueSearch;
    }
    exc_frame->code = record->ExceptionCode;
    if (exc_frame->filter_level && exc_frame->filter( record, exc_frame ) == 
EXCEPTION_EXECUTE_HANDLER)
    {
        __wine_rtl_unwind( frame, record );
        if (exc_frame->finally_level > exc_frame->filter_level)
        {
            exc_frame->abnormal_termination = 1;
            exc_frame->finally( exc_frame );
            __wine_pop_frame( frame );
        }
        exc_frame->filter_level = 0;
        siglongjmp( exc_frame->jmp, 1 );
    }
    return ExceptionContinueSearch;
}

#define RpcTryExcept \
    if (!sigsetjmp( __frame->jmp, 0 )) \
    { \
        if (!__frame->finally_level) \
            __wine_push_frame( &__frame->frame ); \
        __frame->filter_level = __frame->finally_level + 1;

#define RpcExcept(expr) \
        if (!__frame->finally_level) \
            __wine_pop_frame( &__frame->frame ); \
        __frame->filter_level = 0; \
    } \
    else \

#define RpcEndExcept

#define RpcExceptionCode() (__frame->code)

#define RpcTryFinally \
    if (!__frame->filter_level) \
        __wine_push_frame( &__frame->frame ); \
    __frame->finally_level = __frame->filter_level + 1;

#define RpcFinally \
    if (!__frame->filter_level) \
        __wine_pop_frame( &__frame->frame ); \
    __frame->finally_level = 0;

#define RpcEndFinally

#define RpcAbnormalTermination() (__frame->abnormal_termination)

#define RpcExceptionInit(filter_func,finally_func) \
    do { \
        __frame->frame.Handler = __widl_exception_handler; \
        __frame->filter = (__filter_func)(filter_func); \
        __frame->finally = (__finally_func)(finally_func); \
        __frame->abnormal_termination = 0; \
        __frame->filter_level = 0; \
        __frame->finally_level = 0; \
    } while (0)

#else /* USE_COMPILER_EXCEPTIONS */

#define RpcExceptionInit(filter_func,finally_func) do {} while(0)
#define __DECL_EXCEPTION_FRAME

#endif /* USE_COMPILER_EXCEPTIONS */


#ifndef _WIN64

#define TYPE_FORMAT_STRING_SIZE 93
#define PROC_FORMAT_STRING_SIZE 7

typedef struct _MIDL_TYPE_FORMAT_STRING
{
    short Pad;
    unsigned char Format[TYPE_FORMAT_STRING_SIZE];
} MIDL_TYPE_FORMAT_STRING;

typedef struct _MIDL_PROC_FORMAT_STRING
{
    short Pad;
    unsigned char Format[PROC_FORMAT_STRING_SIZE];
} MIDL_PROC_FORMAT_STRING;


static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;

/*****************************************************************************
 * IComplex interface
 */

handle_t IComplex_IfHandle;

static const RPC_CLIENT_INTERFACE IComplex___RpcClientInterface =
{
    sizeof(RPC_CLIENT_INTERFACE),
    
{{0xd2531a27,0x4151,0x44cc,{0x9a,0x8c,0x7e,0xd0,0x0d,0x95,0x67,0x57}},{0,0}},
    
{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
    0,
    0,
    0,
    0,
    0,
    0,
};
RPC_IF_HANDLE IComplex_v0_0_c_ifspec DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& 
IComplex___RpcClientInterface;

static const MIDL_STUB_DESC IComplex_StubDesc;

struct __frame_get_complex
{
    __DECL_EXCEPTION_FRAME
    MIDL_STUB_MESSAGE _StubMsg;
    RPC_BINDING_HANDLE _Handle;
};

static void __finally_get_complex( struct __frame_get_complex *__frame )
{
    NdrFreeBuffer(&__frame->_StubMsg);
}

void get_complex(
    complex_t *complex_t)
{
    struct __frame_get_complex __f, * const __frame = &__f;
    RPC_MESSAGE _RpcMessage;
    __frame->_Handle = 0;

    RpcExceptionInit( 0, __finally_get_complex );
    if (!complex_t)
    {
        RpcRaiseException(RPC_X_NULL_REF_POINTER);
    }

    RpcTryFinally
    {
        NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, 
&IComplex_StubDesc, 0);
        __frame->_Handle = IComplex_IfHandle;

        __frame->_StubMsg.BufferLength = 0;
        NdrPointerBufferSize(
            &__frame->_StubMsg,
            (unsigned char *)complex_t,
            (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[88]);

        NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, 
__frame->_Handle);

        NdrPointerMarshall(
            &__frame->_StubMsg,
            (unsigned char *)complex_t,
            (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[88]);

        NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);

        __frame->_StubMsg.BufferStart = _RpcMessage.Buffer;
        __frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + 
_RpcMessage.BufferLength;

        if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != 
NDR_LOCAL_DATA_REPRESENTATION)
            NdrConvert(&__frame->_StubMsg, 
(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[0]);

        NdrPointerUnmarshall(
            &__frame->_StubMsg,
            (unsigned char **)&complex_t,
            (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[88],
            0);

    }
    RpcFinally
    {
        __finally_get_complex( __frame );
    }
    RpcEndFinally
}

#if !defined(__RPC_WIN32__)
#error  Invalid build platform for this stub.
#endif

static const MIDL_STUB_DESC IComplex_StubDesc =
{
    (void *)& IComplex___RpcClientInterface,
    MIDL_user_allocate,
    MIDL_user_free,
    {
        &IComplex_IfHandle,
    },
    0,
    0,
    0,
    0,
    __MIDL_TypeFormatString.Format,
    1, /* -error bounds_check flag */
    0x10001, /* Ndr library version */
    0,
    0x50100a4, /* MIDL Version 5.1.164 */
    0,
    0,
    0,  /* notify & notify_flag routine table */
    1,  /* Flags */
    0,  /* Reserved3 */
    0,  /* Reserved4 */
    0   /* Reserved5 */
};


static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
{
    0,
    {
        0x50,    /* FC_IN_OUT_PARAM */
        0x01,
        NdrFcShort(0x58),
        0x5b,    /* FC_END */
        0x5c,    /* FC_PAD */
        0x0
    }
};

static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
{
    0,
    {
        NdrFcShort(0x0),
/* 2 (char *) */
        0x11, 0x0,      /* FC_RP */
        NdrFcShort(0x2),
/*  6 */
        0x22,    /* FC_C_CSTRING */
        0x44, /* FC_STRING_SIZED */
        0x19, /* Corr desc: field pointer, FC_ULONG */
        0x0, /* no operators */
        NdrFcShort(0x4), /* offset = 4 */
/* 12 (int *) */
        0x12, 0x8,      /* FC_UP [simple_pointer] */
        0x08,   /* FC_LONG */
        0x5c,   /* FC_PAD */
/* 16 (union ) */
        NdrFcShort(0x4),        /* 4 */
        NdrFcShort(0x4),        /* 4 */
        NdrFcLong(0xa), /* 10 */
        NdrFcShort(0x8008),     /* Simple arm type: FC_LONG */
        NdrFcLong(0xfffffffe),  /* -2 */
        NdrFcShort(0x800a),     /* Simple arm type: FC_FLOAT */
        NdrFcLong(0x7), /* 7 */
        NdrFcShort(0x800a),     /* Simple arm type: FC_FLOAT */
        NdrFcLong(0x18f),       /* 399 */
        NdrFcShort(0xffffffe2), /* Offset= -30 (12) */
        NdrFcShort(0xffffffff),
/* 46 */
        0x2b,   /* FC_NON_ENCAPSULATED_UNION */
        0x8,    /* FIXME: always FC_LONG */
        0x8, /* Corr desc: FC_LONG */
        0x0, /* no operators */
        NdrFcShort(0x4), /* offset = 4 */
        NdrFcShort(-36),        /* Offset= -36 (16) */
/* 54 (complex_t) */
        0x1a,   /* FC_BOGUS_STRUCT */
        0x3,    /* 3 */
        NdrFcShort(0x38),       /* 56 */
        NdrFcShort(0x0),
        NdrFcShort(0x18),       /* Offset= 24 (84) */
        0x36,   /* FC_POINTER */
        0x09,   /* FC_ULONG */
        0x0c,   /* FC_DOUBLE */
        0x0b,   /* FC_HYPER */
        0x0a,   /* FC_FLOAT */
        0x09,   /* FC_ULONG */
        0x08,   /* FC_LONG */
        0x07,   /* FC_USHORT */
        0x06,   /* FC_SHORT */
        0x05,   /* FC_WCHAR */
        0x04,   /* FC_USMALL */
        0x03,   /* FC_SMALL */
        0x02,   /* FC_CHAR */
        0x01,   /* FC_BYTE */
        0x38,   /* FC_ALIGNM4 */
        0x4c,   /* FC_EMBEDDED_COMPLEX */
        0x0,    /* FIXME: padding */
        NdrFcShort(0xffdf),     /* Offset= -33 (46) */
        0x08,   /* FC_LONG */
        0x5c,           /* FC_PAD */
        0x5b,           /* FC_END */
/* 84 */
        0x12, 0x0,      /* FC_UP */
        NdrFcShort(0xffb0),     /* Offset= -80 (6) */
/* 88 */
        0x11, 0x0,              /* FC_RP */
        NdrFcShort(0xffffffdc), /* 54 */
        0x0
    }
};


#else /* _WIN64 */

#define TYPE_FORMAT_STRING_SIZE 95
#define PROC_FORMAT_STRING_SIZE 7

typedef struct _MIDL_TYPE_FORMAT_STRING
{
    short Pad;
    unsigned char Format[TYPE_FORMAT_STRING_SIZE];
} MIDL_TYPE_FORMAT_STRING;

typedef struct _MIDL_PROC_FORMAT_STRING
{
    short Pad;
    unsigned char Format[PROC_FORMAT_STRING_SIZE];
} MIDL_PROC_FORMAT_STRING;


static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;

/*****************************************************************************
 * IComplex interface
 */

handle_t IComplex_IfHandle;

static const RPC_CLIENT_INTERFACE IComplex___RpcClientInterface =
{
    sizeof(RPC_CLIENT_INTERFACE),
    
{{0xd2531a27,0x4151,0x44cc,{0x9a,0x8c,0x7e,0xd0,0x0d,0x95,0x67,0x57}},{0,0}},
    
{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
    0,
    0,
    0,
    0,
    0,
    0,
};
RPC_IF_HANDLE IComplex_v0_0_c_ifspec DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& 
IComplex___RpcClientInterface;

static const MIDL_STUB_DESC IComplex_StubDesc;

struct __frame_get_complex
{
    __DECL_EXCEPTION_FRAME
    MIDL_STUB_MESSAGE _StubMsg;
    RPC_BINDING_HANDLE _Handle;
};

static void __finally_get_complex( struct __frame_get_complex *__frame )
{
    NdrFreeBuffer(&__frame->_StubMsg);
}

void get_complex(
    complex_t *complex_t)
{
    struct __frame_get_complex __f, * const __frame = &__f;
    RPC_MESSAGE _RpcMessage;
    __frame->_Handle = 0;

    RpcExceptionInit( 0, __finally_get_complex );
    if (!complex_t)
    {
        RpcRaiseException(RPC_X_NULL_REF_POINTER);
    }

    RpcTryFinally
    {
        NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, 
&IComplex_StubDesc, 0);
        __frame->_Handle = IComplex_IfHandle;

        __frame->_StubMsg.BufferLength = 0;
        NdrPointerBufferSize(
            &__frame->_StubMsg,
            (unsigned char *)complex_t,
            (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[90]);

        NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, 
__frame->_Handle);

        NdrPointerMarshall(
            &__frame->_StubMsg,
            (unsigned char *)complex_t,
            (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[90]);

        NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);

        __frame->_StubMsg.BufferStart = _RpcMessage.Buffer;
        __frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + 
_RpcMessage.BufferLength;

        if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != 
NDR_LOCAL_DATA_REPRESENTATION)
            NdrConvert(&__frame->_StubMsg, 
(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[0]);

        NdrPointerUnmarshall(
            &__frame->_StubMsg,
            (unsigned char **)&complex_t,
            (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[90],
            0);

    }
    RpcFinally
    {
        __finally_get_complex( __frame );
    }
    RpcEndFinally
}

#if !defined(__RPC_WIN64__)
#error  Invalid build platform for this stub.
#endif

static const MIDL_STUB_DESC IComplex_StubDesc =
{
    (void *)& IComplex___RpcClientInterface,
    MIDL_user_allocate,
    MIDL_user_free,
    {
        &IComplex_IfHandle,
    },
    0,
    0,
    0,
    0,
    __MIDL_TypeFormatString.Format,
    1, /* -error bounds_check flag */
    0x10001, /* Ndr library version */
    0,
    0x50100a4, /* MIDL Version 5.1.164 */
    0,
    0,
    0,  /* notify & notify_flag routine table */
    1,  /* Flags */
    0,  /* Reserved3 */
    0,  /* Reserved4 */
    0   /* Reserved5 */
};


static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
{
    0,
    {
        0x50,    /* FC_IN_OUT_PARAM */
        0x01,
        NdrFcShort(0x5a),
        0x5b,    /* FC_END */
        0x5c,    /* FC_PAD */
        0x0
    }
};

static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
{
    0,
    {
        NdrFcShort(0x0),
/* 2 (char *) */
        0x11, 0x0,      /* FC_RP */
        NdrFcShort(0x2),
/*  6 */
        0x22,    /* FC_C_CSTRING */
        0x44, /* FC_STRING_SIZED */
        0x19, /* Corr desc: field pointer, FC_ULONG */
        0x0, /* no operators */
        NdrFcShort(0x8), /* offset = 8 */
/* 12 (int *) */
        0x12, 0x8,      /* FC_UP [simple_pointer] */
        0x08,   /* FC_LONG */
        0x5c,   /* FC_PAD */
/* 16 (union ) */
        NdrFcShort(0x8),        /* 8 */
        NdrFcShort(0x4),        /* 4 */
        NdrFcLong(0xa), /* 10 */
        NdrFcShort(0x8008),     /* Simple arm type: FC_LONG */
        NdrFcLong(0xfffffffe),  /* -2 */
        NdrFcShort(0x800a),     /* Simple arm type: FC_FLOAT */
        NdrFcLong(0x7), /* 7 */
        NdrFcShort(0x800a),     /* Simple arm type: FC_FLOAT */
        NdrFcLong(0x18f),       /* 399 */
        NdrFcShort(0xffffffe2), /* Offset= -30 (12) */
        NdrFcShort(0xffffffff),
/* 46 */
        0x2b,   /* FC_NON_ENCAPSULATED_UNION */
        0x8,    /* FIXME: always FC_LONG */
        0x8, /* Corr desc: FC_LONG */
        0x0, /* no operators */
        NdrFcShort(0x8), /* offset = 8 */
        NdrFcShort(-36),        /* Offset= -36 (16) */
/* 54 (complex_t) */
        0x1a,   /* FC_BOGUS_STRUCT */
        0x7,    /* 7 */
        NdrFcShort(0x48),       /* 72 */
        NdrFcShort(0x0),
        NdrFcShort(0x1a),       /* Offset= 26 (86) */
        0x36,   /* FC_POINTER */
        0x09,   /* FC_ULONG */
        0x39,   /* FC_ALIGNM8 */
        0x0c,   /* FC_DOUBLE */
        0x0b,   /* FC_HYPER */
        0x0a,   /* FC_FLOAT */
        0x09,   /* FC_ULONG */
        0x08,   /* FC_LONG */
        0x07,   /* FC_USHORT */
        0x06,   /* FC_SHORT */
        0x05,   /* FC_WCHAR */
        0x04,   /* FC_USMALL */
        0x03,   /* FC_SMALL */
        0x02,   /* FC_CHAR */
        0x01,   /* FC_BYTE */
        0x39,   /* FC_ALIGNM8 */
        0x4c,   /* FC_EMBEDDED_COMPLEX */
        0x0,    /* FIXME: padding */
        NdrFcShort(0xffde),     /* Offset= -34 (46) */
        0x08,   /* FC_LONG */
        0x40,   /* FC_STRUCTPAD4 */
        0x5c,           /* FC_PAD */
        0x5b,           /* FC_END */
/* 86 */
        0x12, 0x0,      /* FC_UP */
        NdrFcShort(0xffae),     /* Offset= -82 (6) */
/* 90 */
        0x11, 0x0,              /* FC_RP */
        NdrFcShort(0xffffffda), /* 54 */
        0x0
    }
};


#endif /* _WIN64 */
/*
 * A simple interface to test the RPC server.
 *
 * Copyright (C) Google 2007 (Dan Hipschman)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define SUN_I 10
#define SUN_F1 -2
#define SUN_F2 7
#define SUN_PI 399

[
  uuid(D2531A27-4151-44CC-9A8C-7ED00D956757),
#ifndef __midl
  implicit_handle(handle_t IComplex_IfHandle)
#endif
]
interface IComplex
{
cpp_quote("#if 0")
  typedef wchar_t WCHAR;
cpp_quote("#endif")

  typedef struct
  {
    [string, size_is(size)] char *name;
    unsigned int size;

    double double_member;
    hyper hyper_member;
    float float_member;
    unsigned long ulong_member;
    long long_member;
    unsigned short ushort_member;
    short short_member;
    wchar_t wchar_member;
    unsigned small usmall_member;
    small small_member;
    char char_member;
    byte byte_member;

    [switch_is(s)] union
    {
      [case(SUN_I)] int i;
      [case(SUN_F1, SUN_F2)] float f;
      [case(SUN_PI)] int *pi;
    } u;

    int s;
  } complex_t;
  void get_complex([in,out] complex_t *complex_t);
}

/* this ALWAYS GENERATED file contains the RPC client stubs */


 /* File created by MIDL compiler version 7.00.0500 */
/* at Wed Jan 07 15:31:48 2009
 */
/* Compiler settings for complex.idl:
    Os, W1, Zp8, env=Win32 (32b run)
    protocol : dce , ms_ext, c_ext
    error checks: allocation ref bounds_check enum stub_data 
    VC __declspec() decoration level: 
         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
         DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING(  )

#if !defined(_M_IA64) && !defined(_M_AMD64)


#pragma warning( disable: 4049 )  /* more than 64k source lines */
#if _MSC_VER >= 1200
#pragma warning(push)
#endif

#pragma warning( disable: 4211 )  /* redefine extern to static */
#pragma warning( disable: 4232 )  /* dllimport identity*/
#pragma warning( disable: 4024 )  /* array to pointer mapping*/

#include <string.h>

#include "complex.h"

#define TYPE_FORMAT_STRING_SIZE   89                                
#define PROC_FORMAT_STRING_SIZE   9                                 
#define EXPR_FORMAT_STRING_SIZE   1                                 
#define TRANSMIT_AS_TABLE_SIZE    0            
#define WIRE_MARSHAL_TABLE_SIZE   0            

typedef struct _complex_MIDL_TYPE_FORMAT_STRING
    {
    short          Pad;
    unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
    } complex_MIDL_TYPE_FORMAT_STRING;

typedef struct _complex_MIDL_PROC_FORMAT_STRING
    {
    short          Pad;
    unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
    } complex_MIDL_PROC_FORMAT_STRING;

typedef struct _complex_MIDL_EXPR_FORMAT_STRING
    {
    long          Pad;
    unsigned char  Format[ EXPR_FORMAT_STRING_SIZE ];
    } complex_MIDL_EXPR_FORMAT_STRING;


static RPC_SYNTAX_IDENTIFIER  _RpcTransferSyntax = 
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};


extern const complex_MIDL_TYPE_FORMAT_STRING complex__MIDL_TypeFormatString;
extern const complex_MIDL_PROC_FORMAT_STRING complex__MIDL_ProcFormatString;
extern const complex_MIDL_EXPR_FORMAT_STRING complex__MIDL_ExprFormatString;

#define GENERIC_BINDING_TABLE_SIZE   0            


/* Standard interface: IComplex, ver. 0.0,
   GUID={0xD2531A27,0x4151,0x44CC,{0x9A,0x8C,0x7E,0xD0,0x0D,0x95,0x67,0x57}} */



static const RPC_CLIENT_INTERFACE IComplex___RpcClientInterface =
    {
    sizeof(RPC_CLIENT_INTERFACE),
    
{{0xD2531A27,0x4151,0x44CC,{0x9A,0x8C,0x7E,0xD0,0x0D,0x95,0x67,0x57}},{0,0}},
    
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
    0,
    0,
    0,
    0,
    0,
    0x00000000
    };
RPC_IF_HANDLE IComplex_v0_0_c_ifspec = (RPC_IF_HANDLE)& 
IComplex___RpcClientInterface;

extern const MIDL_STUB_DESC IComplex_StubDesc;

static RPC_BINDING_HANDLE IComplex__MIDL_AutoBindHandle;


void get_complex( 
    /* [in] */ handle_t IDL_handle,
    /* [out][in] */ complex_t *complex_t)
{

    RPC_BINDING_HANDLE _Handle  =       0;
    
    RPC_MESSAGE _RpcMessage;
    
    MIDL_STUB_MESSAGE _StubMsg;
    
    if(!complex_t)
        {
        RpcRaiseException(RPC_X_NULL_REF_POINTER);
        }
    RpcTryFinally
        {
        NdrClientInitializeNew(
                          ( PRPC_MESSAGE  )&_RpcMessage,
                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
                          ( PMIDL_STUB_DESC  )&IComplex_StubDesc,
                          0);
        
        
        _Handle = IDL_handle;
        
        
        _StubMsg.BufferLength = 0;
        NdrComplexStructBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
                                    (unsigned char *)complex_t,
                                    (PFORMAT_STRING) 
&complex__MIDL_TypeFormatString.Format[54] );
        
        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, 
_Handle );
        
        NdrComplexStructMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
                                  (unsigned char *)complex_t,
                                  (PFORMAT_STRING) 
&complex__MIDL_TypeFormatString.Format[54] );
        
        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char *) 
_StubMsg.Buffer );
        
        _StubMsg.BufferStart = (unsigned char *) _RpcMessage.Buffer; 
        _StubMsg.BufferEnd   = _StubMsg.BufferStart + _RpcMessage.BufferLength;
        
        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != 
NDR_LOCAL_DATA_REPRESENTATION )
            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) 
&complex__MIDL_ProcFormatString.Format[0] );
        
        NdrComplexStructUnmarshall( (PMIDL_STUB_MESSAGE) &_StubMsg,
                                    (unsigned char * *)&complex_t,
                                    (PFORMAT_STRING) 
&complex__MIDL_TypeFormatString.Format[54],
                                    (unsigned char)0 );
        
        }
    RpcFinally
        {
        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
        
        }
    RpcEndFinally
    
}


#if !defined(__RPC_WIN32__)
#error  Invalid build platform for this stub.
#endif

static const complex_MIDL_PROC_FORMAT_STRING complex__MIDL_ProcFormatString =
    {
        0,
        {
                        0x4e,           /* FC_IN_PARAM_BASETYPE */
                        0xf,            /* FC_IGNORE */
/*  2 */        
                        0x50,           /* FC_IN_OUT_PARAM */
                        0x1,            /* x86 stack size = 1 */
/*  4 */        NdrFcShort( 0x2 ),      /* Type Offset=2 */
/*  6 */        0x5b,           /* FC_END */
                        0x5c,           /* FC_PAD */

                        0x0
        }
    };

static const complex_MIDL_TYPE_FORMAT_STRING complex__MIDL_TypeFormatString =
    {
        0,
        {
                        NdrFcShort( 0x0 ),      /* 0 */
/*  2 */        
                        0x11, 0x0,      /* FC_RP */
/*  4 */        NdrFcShort( 0x32 ),     /* Offset= 50 (54) */
/*  6 */        
                        0x2b,           /* FC_NON_ENCAPSULATED_UNION */
                        0x8,            /* FC_LONG */
/*  8 */        0x8,            /* Corr desc: FC_LONG */
                        0x0,            /*  */
/* 10 */        NdrFcShort( 0x4 ),      /* 4 */
/* 12 */        NdrFcShort( 0x2 ),      /* Offset= 2 (14) */
/* 14 */        NdrFcShort( 0x4 ),      /* 4 */
/* 16 */        NdrFcShort( 0x4 ),      /* 4 */
/* 18 */        NdrFcLong( 0xa ),       /* 10 */
/* 22 */        NdrFcShort( 0x8008 ),   /* Simple arm type: FC_LONG */
/* 24 */        NdrFcLong( 0xfffffffe ),        /* -2 */
/* 28 */        NdrFcShort( 0x800a ),   /* Simple arm type: FC_FLOAT */
/* 30 */        NdrFcLong( 0x7 ),       /* 7 */
/* 34 */        NdrFcShort( 0x800a ),   /* Simple arm type: FC_FLOAT */
/* 36 */        NdrFcLong( 0x18f ),     /* 399 */
/* 40 */        NdrFcShort( 0x4 ),      /* Offset= 4 (44) */
/* 42 */        NdrFcShort( 0xffff ),   /* Offset= -1 (41) */
/* 44 */        
                        0x12, 0x8,      /* FC_UP [simple_pointer] */
/* 46 */        0x8,            /* FC_LONG */
                        0x5c,           /* FC_PAD */
/* 48 */        
                        0x22,           /* FC_C_CSTRING */
                        0x44,           /* FC_STRING_SIZED */
/* 50 */        0x19,           /* Corr desc:  field pointer, FC_ULONG */
                        0x0,            /*  */
/* 52 */        NdrFcShort( 0x4 ),      /* 4 */
/* 54 */        
                        0x1a,           /* FC_BOGUS_STRUCT */
                        0x7,            /* 7 */
/* 56 */        NdrFcShort( 0x38 ),     /* 56 */
/* 58 */        NdrFcShort( 0x0 ),      /* 0 */
/* 60 */        NdrFcShort( 0x18 ),     /* Offset= 24 (84) */
/* 62 */        0x36,           /* FC_POINTER */
                        0x8,            /* FC_LONG */
/* 64 */        0xc,            /* FC_DOUBLE */
                        0xb,            /* FC_HYPER */
/* 66 */        0xa,            /* FC_FLOAT */
                        0x8,            /* FC_LONG */
/* 68 */        0x8,            /* FC_LONG */
                        0x6,            /* FC_SHORT */
/* 70 */        0x6,            /* FC_SHORT */
                        0x5,            /* FC_WCHAR */
/* 72 */        0x3,            /* FC_SMALL */
                        0x3,            /* FC_SMALL */
/* 74 */        0x2,            /* FC_CHAR */
                        0x1,            /* FC_BYTE */
/* 76 */        0x3e,           /* FC_STRUCTPAD2 */
                        0x4c,           /* FC_EMBEDDED_COMPLEX */
/* 78 */        0x0,            /* 0 */
                        NdrFcShort( 0xffb7 ),   /* Offset= -73 (6) */
                        0x8,            /* FC_LONG */
/* 82 */        0x5c,           /* FC_PAD */
                        0x5b,           /* FC_END */
/* 84 */        
                        0x12, 0x0,      /* FC_UP */
/* 86 */        NdrFcShort( 0xffda ),   /* Offset= -38 (48) */

                        0x0
        }
    };

static const unsigned short IComplex_FormatStringOffsetTable[] =
    {
    0
    };


static const MIDL_STUB_DESC IComplex_StubDesc = 
    {
    (void *)& IComplex___RpcClientInterface,
    MIDL_user_allocate,
    MIDL_user_free,
    &IComplex__MIDL_AutoBindHandle,
    0,
    0,
    0,
    0,
    complex__MIDL_TypeFormatString.Format,
    1, /* -error bounds_check flag */
    0x10001, /* Ndr library version */
    0,
    0x70001f4, /* MIDL Version 7.0.500 */
    0,
    0,
    0,  /* notify & notify_flag routine table */
    0x1, /* MIDL flag */
    0, /* cs routines */
    0,   /* proxy/server info */
    0
    };
#if _MSC_VER >= 1200
#pragma warning(pop)
#endif


#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/



Reply via email to