Support out-pointers to structs.
Modified: trunk/reactos/tools/widl/ChangeLog
Modified: trunk/reactos/tools/widl/server.c
_____
Modified: trunk/reactos/tools/widl/ChangeLog
--- trunk/reactos/tools/widl/ChangeLog 2005-04-17 19:33:50 UTC (rev
14655)
+++ trunk/reactos/tools/widl/ChangeLog 2005-04-17 19:45:06 UTC (rev
14656)
@@ -1,5 +1,11 @@
ChangeLog
+2005-04-17 ekohl
+
+ tools/widl/server.c
+
+Support out-pointers to structs.
+
2005-04-15 ekohl
tools/widl/client.c
_____
Modified: trunk/reactos/tools/widl/server.c
--- trunk/reactos/tools/widl/server.c 2005-04-17 19:33:50 UTC (rev
14655)
+++ trunk/reactos/tools/widl/server.c 2005-04-17 19:45:06 UTC (rev
14656)
@@ -412,7 +412,7 @@
}
-static void print_message_buffer_size(func_t *func)
+static void print_message_buffer_size(func_t *func, unsigned int
*type_offset)
{
unsigned int alignment = 0;
int size = 0;
@@ -423,6 +423,11 @@
int empty_line;
var_t *var;
+ int start_new_line = 0;
+ int add_plus = 0;
+
+ unsigned int local_type_offset = *type_offset;
+
fprintf(server, "\n");
print_server("_StubMsg.BufferLength =");
if (func->args)
@@ -436,7 +441,7 @@
{
if (is_base_type(var->type))
{
- if (size != 0 && last_size != 0)
+ if (start_new_line)
{
print_server("_StubMsg.BufferLength +=");
}
@@ -480,21 +485,23 @@
return;
}
- if (last_size != -1)
+ if (add_plus)
fprintf(server, " +");
fprintf(server, " %dU", (size == 0) ? 0 : size +
alignment);
last_size = size;
+ start_new_line = 0;
+ add_plus = 1;
}
else if (var->type->type == RPC_FC_RP)
{
if (size == 0)
{
- fprintf(server, " 0;\n");
+ fprintf(server, " 12U;\n");
}
else if (last_size != 0)
{
- fprintf(server, ";\n");
+ fprintf(server, " + 12U;\n");
last_size = 0;
}
@@ -504,10 +511,38 @@
print_server("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_server("(unsigned char __RPC_FAR *)%s,\n",
var->name);
print_server("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u]);\n",
- 0); /* FIXME */
+ local_type_offset + 4); /* FIXME */
indent--;
fprintf(server,"\n");
+
+ start_new_line = 1;
}
+
+ /* calculate the next type offset */
+ if (var->ptr_level == 0)
+ {
+ if ((var->type->type == RPC_FC_RP) &&
+ (var->type->ref->ref->type == RPC_FC_STRUCT))
+ {
+ var_t *field = var->type->ref->ref->fields;
+ int tsize = 9;
+
+ while (NEXT_LINK(field)) field =
NEXT_LINK(field);
+ while (field)
+ {
+ tsize++;
+ field = PREV_LINK(field);
+ }
+ if (tsize % 2)
+ tsize++;
+
+ local_type_offset += tsize;
+ }
+ }
+ else if (var->ptr_level == 1)
+ {
+ local_type_offset += 4;
+ }
}
}
}
@@ -515,6 +550,12 @@
/* return value size */
if (!is_void(func->def->type, NULL))
{
+ if (start_new_line)
+ {
+ print_server("_StubMsg.BufferLength +=");
+ add_plus = 0;
+ }
+
switch(func->def->type->type)
{
case RPC_FC_BYTE:
@@ -544,7 +585,7 @@
return;
}
- if (last_size != -1)
+ if (add_plus)
fprintf(server, " +");
fprintf(server, " %dU", (size == 0) ? 0 : size + alignment);
@@ -1296,7 +1337,7 @@
/* allocate and fill the return message buffer */
if (use_return_buffer(func))
{
- print_message_buffer_size(func);
+ print_message_buffer_size(func, &type_offset);
print_server("_pRpcMessage->BufferLength =
_StubMsg.BufferLength;\n");
fprintf(server, "\n");
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");