Commit 73dff5c4 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

widl: Prepare marshall and unmarshall code generation functions for

accepting pointers.
parent 86c3a2e7
...@@ -146,7 +146,7 @@ void write_procformatstring(FILE *file, type_t *iface) ...@@ -146,7 +146,7 @@ void write_procformatstring(FILE *file, type_t *iface)
var = PREV_LINK(var); var = PREV_LINK(var);
} }
} }
/* emit return value data */ /* emit return value data */
var = func->def; var = func->def;
if (is_void(var->type, NULL)) if (is_void(var->type, NULL))
...@@ -283,8 +283,6 @@ unsigned int get_required_buffer_size(type_t *type) ...@@ -283,8 +283,6 @@ unsigned int get_required_buffer_size(type_t *type)
void marshall_arguments(FILE *file, int indent, func_t *func) void marshall_arguments(FILE *file, int indent, func_t *func)
{ {
unsigned int alignment;
unsigned int size;
unsigned int last_size = 0; unsigned int last_size = 0;
var_t *var; var_t *var;
...@@ -295,60 +293,69 @@ void marshall_arguments(FILE *file, int indent, func_t *func) ...@@ -295,60 +293,69 @@ void marshall_arguments(FILE *file, int indent, func_t *func)
while (NEXT_LINK(var)) var = NEXT_LINK(var); while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var) while (var)
{ {
alignment = 0; if (var->ptr_level == 0)
switch (var->type->type)
{ {
case RPC_FC_BYTE: unsigned int size;
case RPC_FC_CHAR: unsigned int alignment = 0;
case RPC_FC_SMALL: switch (var->type->type)
case RPC_FC_USMALL: {
size = 1; case RPC_FC_BYTE:
alignment = 0; case RPC_FC_CHAR:
break; case RPC_FC_SMALL:
case RPC_FC_USMALL:
case RPC_FC_WCHAR: size = 1;
case RPC_FC_USHORT: alignment = 0;
case RPC_FC_SHORT: break;
size = 2;
if (last_size != 0 && last_size < 2) case RPC_FC_WCHAR:
alignment = (2 - last_size); case RPC_FC_USHORT:
break; case RPC_FC_SHORT:
size = 2;
if (last_size != 0 && last_size < 2)
alignment = (2 - last_size);
break;
case RPC_FC_ULONG:
case RPC_FC_LONG:
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
size = 4;
if (last_size != 0 && last_size < 4)
alignment = (4 - last_size);
break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
size = 8;
if (last_size != 0 && last_size < 4)
alignment = (4 - last_size);
break;
default:
size = 0;
error("Unknown/unsupported type: %s (0x%02x)\n", var->name, var->type->type);
}
case RPC_FC_ULONG: if (alignment != 0)
case RPC_FC_LONG: print_file(file, indent, "_StubMsg.Buffer += %u;\n", alignment);
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
size = 4;
if (last_size != 0 && last_size < 4)
alignment = (4 - last_size);
break;
case RPC_FC_HYPER: print_file(file, indent, "*(");
case RPC_FC_DOUBLE: write_type(file, var->type, var, var->tname);
size = 8; fprintf(file, " *)_StubMsg.Buffer = ");
if (last_size != 0 && last_size < 4) write_name(file, var);
alignment = (4 - last_size); fprintf(file, ";\n");
break; fprintf(file, "_StubMsg.Buffer += sizeof(");
write_type(file, var->type, var, var->tname);
fprintf(file, ");\n");
fprintf(file, "\n");
default: last_size = size;
size = 0; }
error("Unknown/unsupported type: %s (0x%02x)\n", var->name, var->type->type); else
{
error("marshall_arguments: Pointer level %d not supported for variable %s\n", var->ptr_level, var->name);
last_size = 0;
} }
if (alignment != 0)
print_file(file, indent, "_StubMsg.Buffer += %u;\n", alignment);
print_file(file, indent, "*(");
write_type(file, var->type, var, var->tname);
fprintf(file, " *)_StubMsg.Buffer = ");
write_name(file, var);
fprintf(file, ";\n");
fprintf(file, "_StubMsg.Buffer += sizeof(");
write_type(file, var->type, var, var->tname);
fprintf(file, ");\n");
fprintf(file, "\n");
last_size = size;
var = PREV_LINK(var); var = PREV_LINK(var);
} }
...@@ -356,8 +363,6 @@ void marshall_arguments(FILE *file, int indent, func_t *func) ...@@ -356,8 +363,6 @@ void marshall_arguments(FILE *file, int indent, func_t *func)
void unmarshall_arguments(FILE *file, int indent, func_t *func) void unmarshall_arguments(FILE *file, int indent, func_t *func)
{ {
unsigned int alignment;
unsigned int size;
unsigned int last_size = 0; unsigned int last_size = 0;
var_t *var; var_t *var;
...@@ -368,60 +373,70 @@ void unmarshall_arguments(FILE *file, int indent, func_t *func) ...@@ -368,60 +373,70 @@ void unmarshall_arguments(FILE *file, int indent, func_t *func)
while (NEXT_LINK(var)) var = NEXT_LINK(var); while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var) while (var)
{ {
alignment = 0; if (var->ptr_level == 0)
switch (var->type->type)
{ {
case RPC_FC_BYTE: unsigned int size;
case RPC_FC_CHAR: unsigned int alignment = 0;
case RPC_FC_SMALL:
case RPC_FC_USMALL:
size = 1;
alignment = 0;
break;
case RPC_FC_WCHAR: switch (var->type->type)
case RPC_FC_USHORT: {
case RPC_FC_SHORT: case RPC_FC_BYTE:
size = 2; case RPC_FC_CHAR:
if (last_size != 0 && last_size < 2) case RPC_FC_SMALL:
alignment = (2 - last_size); case RPC_FC_USMALL:
break; size = 1;
alignment = 0;
break;
case RPC_FC_WCHAR:
case RPC_FC_USHORT:
case RPC_FC_SHORT:
size = 2;
if (last_size != 0 && last_size < 2)
alignment = (2 - last_size);
break;
case RPC_FC_ULONG:
case RPC_FC_LONG:
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
size = 4;
if (last_size != 0 && last_size < 4)
alignment = (4 - last_size);
break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
size = 8;
if (last_size != 0 && last_size < 4)
alignment = (4 - last_size);
break;
default:
size = 0;
error("Unknown/unsupported type: %s (0x%02x)\n", var->name, var->type->type);
}
case RPC_FC_ULONG: if (alignment != 0)
case RPC_FC_LONG: print_file(file, indent, "_StubMsg.Buffer += %u;\n", alignment);
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
size = 4;
if (last_size != 0 && last_size < 4)
alignment = (4 - last_size);
break;
case RPC_FC_HYPER: print_file(file, indent, "");
case RPC_FC_DOUBLE: write_name(file, var);
size = 8; fprintf(file, " = *(");
if (last_size != 0 && last_size < 4) write_type(file, var->type, var, var->tname);
alignment = (4 - last_size); fprintf(file, " *)_StubMsg.Buffer;\n");
break; fprintf(file, "_StubMsg.Buffer += sizeof(");
write_type(file, var->type, var, var->tname);
fprintf(file, ");\n");
fprintf(file, "\n");
default: last_size = size;
size = 0; }
error("Unknown/unsupported type: %s (0x%02x)\n", var->name, var->type->type); else
{
error("unmarshall_arguments: Pointer level %d not supported for variable %s\n", var->ptr_level, var->name);
last_size = 0;
} }
if (alignment != 0)
print_file(file, indent, "_StubMsg.Buffer += %u;\n", alignment);
print_file(file, indent, "");
write_name(file, var);
fprintf(file, " = *(");
write_type(file, var->type, var, var->tname);
fprintf(file, " *)_StubMsg.Buffer;\n");
fprintf(file, "_StubMsg.Buffer += sizeof(");
write_type(file, var->type, var, var->tname);
fprintf(file, ");\n");
fprintf(file, "\n");
last_size = size;
var = PREV_LINK(var); var = PREV_LINK(var);
} }
......
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