Commit acfde97b authored by Dan Hipschman's avatar Dan Hipschman Committed by Alexandre Julliard

rpcrt4, widl: Make pointer layouts compatible with windows; fix conformant array tests.

parent a76d10d1
......@@ -1156,8 +1156,7 @@ static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
unsigned char *Mark = pStubMsg->BufferMark;
unsigned long Offset = pStubMsg->Offset;
unsigned ofs, rep, count, stride, xofs;
unsigned rep, count, stride;
unsigned i;
unsigned char *saved_buffer = NULL;
......@@ -1180,32 +1179,26 @@ static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
ofs = 0;
count = 1;
xofs = 0;
pFormat += 2;
break;
case RPC_FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
ofs = *(const WORD*)&pFormat[6];
count = *(const WORD*)&pFormat[8];
xofs = 0;
pFormat += 10;
break;
case RPC_FC_VARIABLE_REPEAT:
rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
ofs = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[6];
xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
pFormat += 8;
break;
}
for (i = 0; i < rep; i++) {
PFORMAT_STRING info = pFormat;
unsigned char *membase = pMemory + ofs + (i * stride);
unsigned char *bufbase = Mark + ofs + (i * stride);
unsigned char *membase = pMemory + (i * stride);
unsigned char *bufbase = Mark + (i * stride);
unsigned u;
for (u=0; u<count; u++,info+=8) {
......@@ -1241,8 +1234,7 @@ static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char fMustAlloc)
{
unsigned char *Mark = pStubMsg->BufferMark;
unsigned long Offset = pStubMsg->Offset;
unsigned ofs, rep, count, stride, xofs;
unsigned rep, count, stride;
unsigned i;
unsigned char *saved_buffer = NULL;
......@@ -1266,33 +1258,26 @@ static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
ofs = 0;
count = 1;
xofs = 0;
pFormat += 2;
break;
case RPC_FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
ofs = *(const WORD*)&pFormat[6];
count = *(const WORD*)&pFormat[8];
xofs = 0;
pFormat += 10;
break;
case RPC_FC_VARIABLE_REPEAT:
rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
ofs = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[6];
xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
pFormat += 8;
break;
}
/* ofs doesn't seem to matter in this context */
for (i = 0; i < rep; i++) {
PFORMAT_STRING info = pFormat;
unsigned char *membase = *ppMemory + ofs + (i * stride);
unsigned char *bufbase = Mark + ofs + (i * stride);
unsigned char *membase = *ppMemory + (i * stride);
unsigned char *bufbase = Mark + (i * stride);
unsigned u;
for (u=0; u<count; u++,info+=8) {
......@@ -1320,8 +1305,7 @@ static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
unsigned long Offset = pStubMsg->Offset;
unsigned ofs, rep, count, stride, xofs;
unsigned rep, count, stride;
unsigned i;
ULONG saved_buffer_length = 0;
......@@ -1346,31 +1330,25 @@ static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
ofs = 0;
count = 1;
xofs = 0;
pFormat += 2;
break;
case RPC_FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
ofs = *(const WORD*)&pFormat[6];
count = *(const WORD*)&pFormat[8];
xofs = 0;
pFormat += 10;
break;
case RPC_FC_VARIABLE_REPEAT:
rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
ofs = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[6];
xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
pFormat += 8;
break;
}
for (i = 0; i < rep; i++) {
PFORMAT_STRING info = pFormat;
unsigned char *membase = pMemory + ofs + (i * stride);
unsigned char *membase = pMemory + (i * stride);
unsigned u;
for (u=0; u<count; u++,info+=8) {
......@@ -1398,9 +1376,8 @@ static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
static unsigned long EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
unsigned long Offset = pStubMsg->Offset;
unsigned char *Mark = pStubMsg->BufferMark;
unsigned ofs, rep, count, stride, xofs;
unsigned rep, count, stride;
unsigned i;
TRACE("(%p,%p)\n", pStubMsg, pFormat);
......@@ -1419,32 +1396,25 @@ static unsigned long EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
ofs = 0;
count = 1;
xofs = 0;
pFormat += 2;
break;
case RPC_FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
ofs = *(const WORD*)&pFormat[6];
count = *(const WORD*)&pFormat[8];
xofs = 0;
pFormat += 10;
break;
case RPC_FC_VARIABLE_REPEAT:
rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
ofs = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[6];
xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
pFormat += 8;
break;
}
/* ofs doesn't seem to matter in this context */
for (i = 0; i < rep; i++) {
PFORMAT_STRING info = pFormat;
unsigned char *bufbase = Mark + ofs + (i * stride);
unsigned char *bufbase = Mark + (i * stride);
unsigned u;
for (u=0; u<count; u++,info+=8) {
unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
......@@ -1464,8 +1434,7 @@ static void EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
unsigned long Offset = pStubMsg->Offset;
unsigned ofs, rep, count, stride, xofs;
unsigned rep, count, stride;
unsigned i;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
......@@ -1479,25 +1448,19 @@ static void EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
ofs = 0;
count = 1;
xofs = 0;
pFormat += 2;
break;
case RPC_FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
ofs = *(const WORD*)&pFormat[6];
count = *(const WORD*)&pFormat[8];
xofs = 0;
pFormat += 10;
break;
case RPC_FC_VARIABLE_REPEAT:
rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
ofs = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[6];
xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
pFormat += 8;
break;
}
......
......@@ -402,6 +402,35 @@ s_wstr_struct_len(wstr_struct_t *s)
return lstrlenW(s->s);
}
int
s_sum_doub_carr(doub_carr_t *dc)
{
int i, j;
int sum = 0;
for (i = 0; i < dc->n; ++i)
for (j = 0; j < dc->a[i]->n; ++j)
sum += dc->a[i]->a[j];
return sum;
}
void
s_make_pyramid_doub_carr(unsigned char n, doub_carr_t **dc)
{
doub_carr_t *t;
int i, j;
t = MIDL_user_allocate(FIELD_OFFSET(doub_carr_t, a[n]));
t->n = n;
for (i = 0; i < n; ++i)
{
int v = i + 1;
t->a[i] = MIDL_user_allocate(FIELD_OFFSET(doub_carr_1_t, a[v]));
t->a[i]->n = v;
for (j = 0; j < v; ++j)
t->a[i]->a[j] = j + 1;
}
*dc = t;
}
void
s_stop(void)
{
......@@ -714,6 +743,25 @@ pointer_tests(void)
free_list(list);
}
static int
check_pyramid_doub_carr(doub_carr_t *dc)
{
int i, j;
for (i = 0; i < dc->n; ++i)
for (j = 0; j < dc->a[i]->n; ++j)
if (dc->a[i]->a[j] != j + 1)
return FALSE;
return TRUE;
}
static void
free_pyramid_doub_carr(doub_carr_t *dc)
{
int i;
for (i = 0; i < dc->n; ++i)
MIDL_user_free(dc->a[i]);
}
static void
array_tests(void)
{
......@@ -730,6 +778,7 @@ array_tests(void)
cs_t *cs;
int n;
int ca[5] = {1, -2, 3, -4, 5};
doub_carr_t *dc;
ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n");
......@@ -765,22 +814,43 @@ array_tests(void)
cps.ca1 = &c[2];
cps.n = 3;
cps.ca2 = &c[3];
todo_wine ok(sum_cps(&cps) == 53, "RPC sum_cps\n");
ok(sum_cps(&cps) == 53, "RPC sum_cps\n");
cpsc.a = 4;
cpsc.b = 5;
cpsc.c = 1;
cpsc.ca = c;
todo_wine ok(sum_cpsc(&cpsc) == 6, "RPC sum_cpsc\n");
ok(sum_cpsc(&cpsc) == 6, "RPC sum_cpsc\n");
cpsc.a = 4;
cpsc.b = 5;
cpsc.c = 0;
cpsc.ca = c;
todo_wine ok(sum_cpsc(&cpsc) == 10, "RPC sum_cpsc\n");
ok(sum_cpsc(&cpsc) == 10, "RPC sum_cpsc\n");
ok(sum_toplev_conf_2n(c, 3) == 15, "RPC sum_toplev_conf_2n\n");
ok(sum_toplev_conf_cond(c, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
ok(sum_toplev_conf_cond(c, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
dc = malloc(FIELD_OFFSET(doub_carr_t, a[2]));
dc->n = 2;
dc->a[0] = malloc(FIELD_OFFSET(doub_carr_1_t, a[3]));
dc->a[0]->n = 3;
dc->a[0]->a[0] = 5;
dc->a[0]->a[1] = 1;
dc->a[0]->a[2] = 8;
dc->a[1] = malloc(FIELD_OFFSET(doub_carr_1_t, a[2]));
dc->a[1]->n = 2;
dc->a[1]->a[0] = 2;
dc->a[1]->a[1] = 3;
ok(sum_doub_carr(dc) == 19, "RPC sum_doub_carr\n");
free(dc->a[0]);
free(dc->a[1]);
free(dc);
dc = NULL;
make_pyramid_doub_carr(4, &dc);
ok(check_pyramid_doub_carr(dc), "RPC make_pyramid_doub_carr\n");
free_pyramid_doub_carr(dc);
}
static void
......
......@@ -250,5 +250,20 @@ cpp_quote("#endif")
int str_struct_len(str_struct_t *s);
int wstr_struct_len(wstr_struct_t *s);
typedef struct
{
unsigned int n;
[size_is(n)] byte a[];
} doub_carr_1_t;
typedef struct
{
int n;
[size_is(n)] doub_carr_1_t *a[];
} doub_carr_t;
int sum_doub_carr(doub_carr_t *dc);
void make_pyramid_doub_carr(unsigned char n, [out] doub_carr_t **dc);
void stop(void);
}
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