Commit 02236f06 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Fix and unify parsing of calling conventions.

Hack handling of 'struct { } *NDR_SCONTEXT;' so we don't cause a parse error as this is a valid C construct. Generate type tests for rpcrt4. Remove PRPC_BINDING_VECTOR and PUUID_VECTOR, they don't exist on Windows. Fix the MIDL_STUB_MESSAGE, MIDL_SERVER_INFO and MIDL_STUBLESS_PROXY_INFO structs. Add NDR_ALLOC_ALL_NODES_CONTEXT, NDR_POINTER_QUEUE_STATE and CS_STUB_INFO.
parent 4d73e10c
...@@ -178,7 +178,7 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE ...@@ -178,7 +178,7 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE
memset(pRpcMessage, 0, sizeof(RPC_MESSAGE)); memset(pRpcMessage, 0, sizeof(RPC_MESSAGE));
/* not everyone allocates stack space for w2kReserved */ /* not everyone allocates stack space for w2kReserved */
memset(pStubMsg, 0, sizeof(*pStubMsg) - sizeof(pStubMsg->w2kReserved)); memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));
pStubMsg->ReuseBuffer = FALSE; pStubMsg->ReuseBuffer = FALSE;
pStubMsg->IsClient = TRUE; pStubMsg->IsClient = TRUE;
...@@ -202,7 +202,7 @@ unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_M ...@@ -202,7 +202,7 @@ unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_M
assert( pRpcMsg && pStubMsg && pStubDesc ); assert( pRpcMsg && pStubMsg && pStubDesc );
/* not everyone allocates stack space for w2kReserved */ /* not everyone allocates stack space for w2kReserved */
memset(pStubMsg, 0, sizeof(*pStubMsg) - sizeof(pStubMsg->w2kReserved)); memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));
pStubMsg->ReuseBuffer = TRUE; pStubMsg->ReuseBuffer = TRUE;
pStubMsg->IsClient = FALSE; pStubMsg->IsClient = FALSE;
......
Makefile Makefile
generated.ok
rpc.ok rpc.ok
testlist.c testlist.c
...@@ -6,6 +6,7 @@ TESTDLL = rpcrt4.dll ...@@ -6,6 +6,7 @@ TESTDLL = rpcrt4.dll
IMPORTS = rpcrt4 IMPORTS = rpcrt4
CTESTS = \ CTESTS = \
generated.c \
rpc.c rpc.c
@MAKE_TEST_RULES@ @MAKE_TEST_RULES@
......
...@@ -50,14 +50,14 @@ typedef struct _RPC_BINDING_VECTOR ...@@ -50,14 +50,14 @@ typedef struct _RPC_BINDING_VECTOR
{ {
unsigned long Count; unsigned long Count;
RPC_BINDING_HANDLE BindingH[1]; RPC_BINDING_HANDLE BindingH[1];
} RPC_BINDING_VECTOR, *PRPC_BINDING_VECTOR; } RPC_BINDING_VECTOR;
#define rpc_binding_vector_t RPC_BINDING_VECTOR #define rpc_binding_vector_t RPC_BINDING_VECTOR
typedef struct _UUID_VECTOR typedef struct _UUID_VECTOR
{ {
unsigned long Count; unsigned long Count;
UUID *Uuid[1]; UUID *Uuid[1];
} UUID_VECTOR, *PUUID_VECTOR; } UUID_VECTOR;
#define uuid_vector_t UUID_VECTOR #define uuid_vector_t UUID_VECTOR
typedef struct _RPC_IF_ID typedef struct _RPC_IF_ID
...@@ -162,11 +162,11 @@ RPCRTAPI RPC_STATUS RPC_ENTRY ...@@ -162,11 +162,11 @@ RPCRTAPI RPC_STATUS RPC_ENTRY
RpcEpResolveBinding( RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec ); RpcEpResolveBinding( RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec );
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
RpcEpRegisterA( RPC_IF_HANDLE IfSpec, PRPC_BINDING_VECTOR BindingVector, RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR* BindingVector,
PUUID_VECTOR UuidVector, unsigned char *Annotation ); UUID_VECTOR* UuidVector, unsigned char *Annotation );
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
RpcEpRegisterW( RPC_IF_HANDLE IfSpec, PRPC_BINDING_VECTOR BindingVector, RpcEpRegisterW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR* BindingVector,
PUUID_VECTOR UuidVector, unsigned short *Annotation ); UUID_VECTOR* UuidVector, unsigned short *Annotation );
#define RpcEpRegister WINELIB_NAME_AW(RpcEpRegister) #define RpcEpRegister WINELIB_NAME_AW(RpcEpRegister)
RPCRTAPI RPC_STATUS RPC_ENTRY RPCRTAPI RPC_STATUS RPC_ENTRY
......
...@@ -129,6 +129,8 @@ typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(_wine_boolean flag); ...@@ -129,6 +129,8 @@ typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(_wine_boolean flag);
struct _MIDL_STUB_MESSAGE; struct _MIDL_STUB_MESSAGE;
struct _MIDL_STUB_DESC; struct _MIDL_STUB_DESC;
struct _FULL_PTR_XLAT_TABLES; struct _FULL_PTR_XLAT_TABLES;
struct NDR_ALLOC_ALL_NODES_CONTEXT;
struct NDR_POINTER_QUEUE_STATE;
typedef void (__RPC_USER *EXPR_EVAL)(struct _MIDL_STUB_MESSAGE *); typedef void (__RPC_USER *EXPR_EVAL)(struct _MIDL_STUB_MESSAGE *);
typedef const unsigned char *PFORMAT_STRING; typedef const unsigned char *PFORMAT_STRING;
...@@ -143,6 +145,13 @@ typedef struct ...@@ -143,6 +145,13 @@ typedef struct
unsigned long *ActualCountArray; unsigned long *ActualCountArray;
} ARRAY_INFO, *PARRAY_INFO; } ARRAY_INFO, *PARRAY_INFO;
typedef struct
{
unsigned long WireCodeset;
unsigned long DesiredReceivingCodeset;
void *CSArrayInfo;
} CS_STUB_INFO;
typedef struct _NDR_PIPE_DESC *PNDR_PIPE_DESC; typedef struct _NDR_PIPE_DESC *PNDR_PIPE_DESC;
typedef struct _NDR_PIPE_MESSAGE *PNDR_PIPE_MESSAGE; typedef struct _NDR_PIPE_MESSAGE *PNDR_PIPE_MESSAGE;
typedef struct _NDR_ASYNC_MESSAGE *PNDR_ASYNC_MESSAGE; typedef struct _NDR_ASYNC_MESSAGE *PNDR_ASYNC_MESSAGE;
...@@ -161,12 +170,13 @@ typedef struct _MIDL_STUB_MESSAGE ...@@ -161,12 +170,13 @@ typedef struct _MIDL_STUB_MESSAGE
unsigned char *Memory; unsigned char *Memory;
int IsClient; int IsClient;
int ReuseBuffer; int ReuseBuffer;
unsigned char *AllocAllNodesMemory; struct NDR_ALLOC_ALL_NODES_CONTEXT *pAllocAllNodesContext;
unsigned char *AllocAllNodesMemoryEnd; struct NDR_POINTER_QUEUE_STATE *pPointerQueueState;
int IgnoreEmbeddedPointers; int IgnoreEmbeddedPointers;
unsigned char *PointerBufferMark; unsigned char *PointerBufferMark;
unsigned char fBufferValid; unsigned char fBufferValid;
unsigned char Unused; unsigned char uFlags;
unsigned short UniquePtrCount;
ULONG_PTR MaxCount; ULONG_PTR MaxCount;
unsigned long Offset; unsigned long Offset;
unsigned long ActualCount; unsigned long ActualCount;
...@@ -179,7 +189,7 @@ typedef struct _MIDL_STUB_MESSAGE ...@@ -179,7 +189,7 @@ typedef struct _MIDL_STUB_MESSAGE
const struct _MIDL_STUB_DESC *StubDesc; const struct _MIDL_STUB_DESC *StubDesc;
struct _FULL_PTR_XLAT_TABLES *FullPtrXlatTables; struct _FULL_PTR_XLAT_TABLES *FullPtrXlatTables;
unsigned long FullPtrRefId; unsigned long FullPtrRefId;
unsigned long ulUnused1; unsigned long PointerLength;
int fInDontFree:1; int fInDontFree:1;
int fDontCallFreeInst:1; int fDontCallFreeInst:1;
int fInOnlyParam:1; int fInOnlyParam:1;
...@@ -199,12 +209,21 @@ typedef struct _MIDL_STUB_MESSAGE ...@@ -199,12 +209,21 @@ typedef struct _MIDL_STUB_MESSAGE
unsigned long *SizePtrLengthArray; unsigned long *SizePtrLengthArray;
void *pArgQueue; void *pArgQueue;
unsigned long dwStubPhase; unsigned long dwStubPhase;
PNDR_PIPE_DESC pPipeDesc; void *LowStackMark;
PNDR_ASYNC_MESSAGE pAsyncMsg; PNDR_ASYNC_MESSAGE pAsyncMsg;
PNDR_CORRELATION_INFO pCorrInfo; PNDR_CORRELATION_INFO pCorrInfo;
unsigned char *pCorrMemory; unsigned char *pCorrMemory;
void *pMemoryList; void *pMemoryList;
ULONG_PTR w2kReserved[5]; CS_STUB_INFO *pCSInfo;
unsigned char *ConformanceMark;
unsigned char *VarianceMark;
INT_PTR Unused;
struct _NDR_PROC_CONTEXT *pContext;
INT_PTR Reserved51_1;
INT_PTR Reserved51_2;
INT_PTR Reserved51_3;
INT_PTR Reserved51_4;
INT_PTR Reserved51_5;
} MIDL_STUB_MESSAGE, *PMIDL_STUB_MESSAGE; } MIDL_STUB_MESSAGE, *PMIDL_STUB_MESSAGE;
#include <poppack.h> #include <poppack.h>
...@@ -286,6 +305,18 @@ typedef struct _MIDL_FORMAT_STRING ...@@ -286,6 +305,18 @@ typedef struct _MIDL_FORMAT_STRING
#endif #endif
} MIDL_FORMAT_STRING; } MIDL_FORMAT_STRING;
typedef struct _MIDL_SYNTAX_INFO
{
RPC_SYNTAX_IDENTIFIER TransferSyntax;
RPC_DISPATCH_TABLE* DispatchTable;
PFORMAT_STRING ProcString;
const unsigned short* FmtStringOffset;
PFORMAT_STRING TypeString;
const void* aUserMarshalQuadruple;
ULONG_PTR pReserved1;
ULONG_PTR pReserved2;
} MIDL_SYNTAX_INFO, *PMIDL_SYNTAX_INFO;
typedef void (__RPC_API *STUB_THUNK)( PMIDL_STUB_MESSAGE ); typedef void (__RPC_API *STUB_THUNK)( PMIDL_STUB_MESSAGE );
typedef long (__RPC_API *SERVER_ROUTINE)(); typedef long (__RPC_API *SERVER_ROUTINE)();
...@@ -297,9 +328,9 @@ typedef struct _MIDL_SERVER_INFO_ ...@@ -297,9 +328,9 @@ typedef struct _MIDL_SERVER_INFO_
PFORMAT_STRING ProcString; PFORMAT_STRING ProcString;
const unsigned short *FmtStringOffset; const unsigned short *FmtStringOffset;
const STUB_THUNK *ThunkTable; const STUB_THUNK *ThunkTable;
PFORMAT_STRING LocalFormatTypes; PRPC_SYNTAX_IDENTIFIER pTransferSyntax;
PFORMAT_STRING LocalProcString; ULONG_PTR nCount;
const unsigned short *LocalFmtStringOffset; PMIDL_SYNTAX_INFO pSyntaxInfo;
} MIDL_SERVER_INFO, *PMIDL_SERVER_INFO; } MIDL_SERVER_INFO, *PMIDL_SERVER_INFO;
typedef struct _MIDL_STUBLESS_PROXY_INFO typedef struct _MIDL_STUBLESS_PROXY_INFO
...@@ -307,9 +338,9 @@ typedef struct _MIDL_STUBLESS_PROXY_INFO ...@@ -307,9 +338,9 @@ typedef struct _MIDL_STUBLESS_PROXY_INFO
PMIDL_STUB_DESC pStubDesc; PMIDL_STUB_DESC pStubDesc;
PFORMAT_STRING ProcFormatString; PFORMAT_STRING ProcFormatString;
const unsigned short *FormatStringOffset; const unsigned short *FormatStringOffset;
PFORMAT_STRING LocalFormatTypes; PRPC_SYNTAX_IDENTIFIER pTransferSyntax;
PFORMAT_STRING LocalProcStrings; ULONG_PTR nCount;
const unsigned short *LocalFmtStringOffset; PMIDL_SYNTAX_INFO pSyntaxInfo;
} MIDL_STUBLESS_PROXY_INFO, *PMIDL_STUBLESS_PROXY_INFO; } MIDL_STUBLESS_PROXY_INFO, *PMIDL_STUBLESS_PROXY_INFO;
typedef union _CLIENT_CALL_RETURN typedef union _CLIENT_CALL_RETURN
......
...@@ -33,6 +33,14 @@ use output qw($output); ...@@ -33,6 +33,14 @@ use output qw($output);
use c_function; use c_function;
use c_type; use c_type;
# Defined a couple common regexp tidbits
my $CALL_CONVENTION="__cdecl|__stdcall|" .
"__RPC_API|__RPC_STUB|__RPC_USER|" .
"CALLBACK|CDECL|NTAPI|PASCAL|RPC_ENTRY|RPC_VAR_ENTRY|" .
"VFWAPI|VFWAPIV|WINAPI|WINAPIV|" .
"WINE_UNUSED";
######################################################################## ########################################################################
# new # new
# #
...@@ -1211,11 +1219,7 @@ sub parse_c_function { ...@@ -1211,11 +1219,7 @@ sub parse_c_function {
$self->_parse_c('inline|FAR', \$_, \$line, \$column); $self->_parse_c('inline|FAR', \$_, \$line, \$column);
$self->_parse_c("__cdecl|__stdcall|__RPC_STUB|" . $self->_parse_c($CALL_CONVENTION,
"CALLBACK|CDECL|PASCAL|" .
"RPC_ENTRY|RPC_VAR_ENTRY|" .
"VFWAPIV|VFWAPI|WINAPIV|WINAPI|" .
"WINE_UNUSED",
\$_, \$line, \$column, \$calling_convention); \$_, \$line, \$column, \$calling_convention);
...@@ -1835,6 +1839,16 @@ sub parse_c_typedef { ...@@ -1835,6 +1839,16 @@ sub parse_c_typedef {
\$kind, \$_name, \@field_type_names, \@field_names, \@names)) \$kind, \$_name, \@field_type_names, \@field_names, \@names))
{ {
my $base_name; my $base_name;
foreach my $name (@names)
{
if ($name =~ /^\w+$/)
{
$base_name = $name;
last;
}
}
$base_name="$kind $_name" if (!defined $base_name and defined $_name);
$base_name=$kind if (!defined $base_name);
foreach my $name (@names) { foreach my $name (@names) {
if ($name =~ /^\w+$/) { if ($name =~ /^\w+$/) {
my $type = &$$create_type(); my $type = &$$create_type();
...@@ -1846,10 +1860,6 @@ sub parse_c_typedef { ...@@ -1846,10 +1860,6 @@ sub parse_c_typedef {
$type->field_names([@field_names]); $type->field_names([@field_names]);
&$$found_type($type); &$$found_type($type);
$base_name = $name;
} elsif (!defined($base_name)) {
$self->_parse_c_error($_, $line, $column, "typedef 1");
} elsif ($name =~ /^(\*+)\s*(?:RESTRICTED_POINTER\s+)?(\w+)$/) { } elsif ($name =~ /^(\*+)\s*(?:RESTRICTED_POINTER\s+)?(\w+)$/) {
my $type_name = "$base_name $1"; my $type_name = "$base_name $1";
$name = $2; $name = $2;
...@@ -2004,7 +2014,7 @@ sub parse_c_variable { ...@@ -2004,7 +2014,7 @@ sub parse_c_variable {
$type = $self->_format_c_type($type); $type = $self->_format_c_type($type);
$finished = 1; $finished = 1;
} elsif(s/^((?:enum\s+|struct\s+|union\s+)?\w+\b(?:\s*\*)*\s*\((?:\s*CALLBACK|\s*NTAPI|\s*WINAPI)?(?:\s*\*)*)\s*(\w+)\s*(\)\s*\(.*?\))$//s) { } elsif(s/^((?:enum\s+|struct\s+|union\s+)?\w+\b(?:\s*\*)*\s*\(\s*(?:$CALL_CONVENTION)?(?:\s*\*)*)\s*(\w+)\s*(\)\s*\(.*?\))$//s) {
$type = $self->_format_c_type("$sign$1$3"); $type = $self->_format_c_type("$sign$1$3");
$name = $2; $name = $2;
...@@ -2061,7 +2071,7 @@ sub parse_c_variable { ...@@ -2061,7 +2071,7 @@ sub parse_c_variable {
if($finished) { if($finished) {
# Nothing # Nothing
} elsif(s/^(\((?:__cdecl|PASCAL|WINAPI)?\s*\*?\s*(?:__cdecl|PASCAL|WINAPI)?\w+\s*(?:\[[^\]]*\]\s*)*\))\s*\(//) { } elsif(s/^(\((?:$CALL_CONVENTION)?\s*\*?\s*(?:$CALL_CONVENTION)?\w+\s*(?:\[[^\]]*\]\s*)*\))\s*\(//) {
$self->_update_c_position($&, \$line, \$column); $self->_update_c_position($&, \$line, \$column);
$name = $1; $name = $1;
......
...@@ -908,6 +908,122 @@ __int32 ...@@ -908,6 +908,122 @@ __int32
__int64 __int64
__int8 __int8
%%%dlls/rpcrt4/tests
%%pack
%description
Unit tests for data structure packing
%header
rpc.h
rpcdce.h
rpcdcep.h
rpcndr.h
rpcproxy.h
%include
<stdarg.h>
"windef.h"
"winbase.h"
"rpc.h"
"rpcndr.h"
"rpcproxy.h"
%type
ARRAY_INFO
!CLIENT_CALL_RETURN # FIXME: 20040822: Mishandled by winapi_test
COMM_FAULT_OFFSETS
CS_STUB_INFO
EXPR_EVAL
FULL_PTR_TO_REFID_ELEMENT
FULL_PTR_XLAT_TABLES
GENERIC_BINDING_INFO
GENERIC_BINDING_ROUTINE_PAIR
IDL_CS_CONVERT
I_RPC_HANDLE
MALLOC_FREE_STRUCT
MIDL_FORMAT_STRING
MIDL_SERVER_INFO
MIDL_STUB_DESC
MIDL_STUB_MESSAGE
MIDL_STUBLESS_PROXY_INFO
MIDL_SYNTAX_INFO
NDR_CCONTEXT
NDR_CS_ROUTINES
NDR_CS_SIZE_CONVERT_ROUTINES
NDR_NOTIFY_ROUTINE
NDR_NOTIFY2_ROUTINE
NDR_RUNDOWN
NDR_SCONTEXT
NDR_USER_MARSHAL_INFO
NDR_USER_MARSHAL_INFO_LEVEL1
PARRAY_INFO
PFORMAT_STRING
PFULL_PTR_TO_REFID_ELEMENT
PFULL_PTR_XLAT_TABLES
PGENERIC_BINDING_INFO
PGENERIC_BINDING_ROUTINE_PAIR
PMIDL_SERVER_INFO
PMIDL_STUB_DESC
PMIDL_STUB_MESSAGE
PMIDL_STUBLESS_PROXY_INFO
PMIDL_SYNTAX_INFO
PNDR_ASYNC_MESSAGE
PNDR_CORRELATION_INFO
!PNDR_PIPE_DESC # Only defined in the DDK on Windows
!PNDR_PIPE_MESSAGE # Only defined in the DDK on Windows
PROXY_PHASE
PRPC_CLIENT_INTERFACE
PRPC_DISPATCH_TABLE
PRPC_MESSAGE
PRPC_POLICY
PRPC_PROTSEQ_ENDPOINT
PRPC_SERVER_INTERFACE
PRPC_STUB_FUNCTION
PRPC_SYNTAX_IDENTIFIER
PSCONTEXT_QUEUE
PXMIT_ROUTINE_QUINTUPLE
PUUID_VECTOR
RPC_AUTH_IDENTITY_HANDLE
RPC_AUTH_KEY_RETRIEVAL_FN
RPC_AUTHZ_HANDLE
RPC_BINDING_HANDLE
RPC_BINDING_VECTOR
!RPC_BLOCKING_FN # FIXME: Needs MSWMSG
RPC_CLIENT_INTERFACE
RPC_DISPATCH_FUNCTION
RPC_DISPATCH_TABLE
RPC_IF_HANDLE
RPC_IF_ID
RPC_MESSAGE
RPC_POLICY
RPC_PROTSEQ_ENDPOINT
RPC_SERVER_INTERFACE
RPC_SS_THREAD_HANDLE
RPC_STATUS
RPC_SYNTAX_IDENTIFIER
RPC_VERSION
SCONTEXT_QUEUE
SERVER_ROUTINE
STUB_PHASE
STUB_THUNK
USER_MARSHAL_CB
USER_MARSHAL_CB_TYPE
USER_MARSHAL_FREEING_ROUTINE
USER_MARSHAL_MARSHALLING_ROUTINE
USER_MARSHAL_ROUTINE_QUADRUPLE
USER_MARSHAL_SIZING_ROUTINE
USER_MARSHAL_UNMARSHALLING_ROUTINE
UUID_VECTOR
XLAT_SIDE
XMIT_HELPER_ROUTINE
XMIT_ROUTINE_QUINTUPLE
%%%dlls/shell32/tests %%%dlls/shell32/tests
%%pack %%pack
......
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