2020-03-07 18:55:08 +00:00
|
|
|
void printf (string fmt, ...) = #0;
|
2020-03-06 13:28:04 +00:00
|
|
|
typedef struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} Point;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
} Extent;
|
|
|
|
|
|
|
|
typedef struct Rect_s {
|
|
|
|
Point offset;
|
|
|
|
Extent extent;
|
|
|
|
} Rect;
|
|
|
|
|
2020-03-07 18:55:08 +00:00
|
|
|
void *foo (Rect *obj, void *cmd, Rect *o, Point pos, Rect r);
|
2020-03-06 13:28:04 +00:00
|
|
|
|
2020-03-11 10:42:38 +00:00
|
|
|
void *baz (Rect *obj, void *cmd, Rect *o, Point pos)
|
|
|
|
{
|
|
|
|
Rect rect = { {1, 2}, {3, 4} };
|
|
|
|
return foo (obj, cmd, o, pos, rect);
|
|
|
|
}
|
|
|
|
|
2020-03-07 18:55:08 +00:00
|
|
|
void *bar (Rect *obj, void *cmd, Rect *o, Point pos)
|
2020-03-06 13:28:04 +00:00
|
|
|
{
|
|
|
|
Rect rect = { {}, obj.extent };
|
|
|
|
return foo (obj, cmd, o, pos, rect);
|
|
|
|
}
|
|
|
|
|
2020-03-07 18:55:08 +00:00
|
|
|
void *foo (Rect *obj, void *cmd, Rect *o, Point pos, Rect r)
|
|
|
|
{
|
|
|
|
*o = r;
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect obj = { { 1, 2}, { 3, 4} };
|
|
|
|
Rect o = { { 5, 6}, {7, 8} };
|
|
|
|
|
2020-03-06 13:28:04 +00:00
|
|
|
int main (void)
|
|
|
|
{
|
2020-03-11 10:42:38 +00:00
|
|
|
int ret = 0;
|
2020-03-16 03:15:55 +00:00
|
|
|
int ok;
|
|
|
|
|
2020-03-07 18:55:08 +00:00
|
|
|
bar(&obj, nil, &o, obj.offset);
|
2020-03-16 03:15:55 +00:00
|
|
|
ok = (o.offset.x == 0 && o.offset.y == 0
|
|
|
|
&& o.extent.width == 3 && o.extent.height == 4);
|
|
|
|
ret |= !ok;
|
|
|
|
printf ("%d %d %d %d %d\n", o.offset.x, o.offset.y,
|
|
|
|
o.extent.width, o.extent.height, ok);
|
2020-03-11 10:42:38 +00:00
|
|
|
|
|
|
|
baz(&obj, nil, &o, obj.offset);
|
2020-03-16 03:15:55 +00:00
|
|
|
ok = (o.offset.x == 1 && o.offset.y == 2
|
|
|
|
&& o.extent.width == 3 && o.extent.height == 4);
|
|
|
|
ret |= !ok;
|
|
|
|
printf ("%d %d %d %d %d\n", o.offset.x, o.offset.y,
|
|
|
|
o.extent.width, o.extent.height, ok);
|
2020-03-07 18:55:08 +00:00
|
|
|
return ret;
|
2020-03-06 13:28:04 +00:00
|
|
|
}
|