reply_t vs request_t-可以互换地传递它们吗? [英] reply_t vs request_t - passing them in interchangeably?

查看:122
本文介绍了reply_t vs request_t-可以互换地传递它们吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用XCB时遇到问题.我不了解*_reply_t*_request_t类型之间的区别.

I'm having an issue with XCB. I don't understand the difference between *_reply_t vs *_request_t types.

似乎*_reply_t代替了*_response_t,但是结构却大不相同.

It seems that the *_reply_t is passed in place of the *_response_t, however the structures are very different.

例如:

xcb_randr_get_screen_resources_current_reply_t *reply = xcb_randr_get_screen_resources_current_reply(
        connection, xcb_randr_get_screen_resources_current(connection, root), NULL);

所以现在reply*_reply_t的类型.但是,现在我需要使用xcb_randr_get_screen_resources_current_outputs,它期望第一个参数的类型为xcb_randr_get_screen_resources_current_request_t,如此处的文档所述:

So now reply is the type of *_reply_t. But now I need to use xcb_randr_get_screen_resources_current_outputs which expects the first argument to be of type xcb_randr_get_screen_resources_current_request_t as per the docs here:

http://www.linuxhowtos.org/manpages/3/xcb_randr_get_screen_resources_current_outputs.

          xcb_randr_output_t *xcb_randr_get_screen_resources_current_outputs(
            const xcb_randr_get_screen_resources_current_request_t *reply
          );

但是,第一次调用的响应的类型为xcb_randr_get_screen_resources_current_reply_t(*_reply_t).如何在不强制转换的情况下将其传递到输出调用中?每个文档的结构完全不同:

However the response from the first call is of type xcb_randr_get_screen_resources_current_reply_t (*_reply_t). How is it possible to pass this into the outputs call without casting? The structures are completely different per the docs:

typedef struct xcb_randr_get_screen_resources_current_reply_t {
    uint8_t         response_type;
    uint8_t         pad0;
    uint16_t        sequence;
    uint32_t        length;
    xcb_timestamp_t timestamp;
    xcb_timestamp_t config_timestamp;
    uint16_t        num_crtcs;
    uint16_t        num_outputs;
    uint16_t        num_modes;
    uint16_t        names_len;
    uint8_t         pad1[8];
} xcb_randr_get_screen_resources_current_reply_t;

*_request_t的结构不在我从此处的源代码中获得的文档中:

And the struct for the *_request_t is not in the docs I got it from the source code here:

https://xcb.freedesktop.org/manual/randr_8h_source.html#l00896

   typedef struct xcb_randr_get_screen_resources_current_request_t {
       uint8_t      major_opcode; 
       uint8_t      minor_opcode; 
       uint16_t     length; 
       xcb_window_t window; 
   } xcb_randr_get_screen_resources_current_request_t;

我做ctypes,所以我必须声明要为方法签名预先传递的类型.因此,对于完全不同结构(reply)的某些东西如何进入结构为request的第二次调用,我感到非常困惑.

I do ctypes so I have to declare the type I am going to pass in beforehand for the signature of the method. So I am very confused on how something of a totally different structure (reply) is going into a second call which has structure of request.

推荐答案

我认为您偶然发现的只是一个文档错误.所有声称采用*_request_t的功能实际上都期望使用*_reply_t.从您链接的源头开始,只需查看实际的函数定义(而不是手册页上的内容),就可以找到

I think what you have stumbled upon is simply a documentation bug. All the functions which claim to take *_request_t actually expect *_reply_t. From the very source you linked from, just look at the actual function definition (rather than what the man page says) and you'll find

xcb_randr_output_t *
    xcb_randr_get_screen_resources_current_outputs (const xcb_randr_get_screen_resources_current_reply_t *R  );

您发现的结构实际上并未在文件中的任何位置使用,因此它可能是一些遗忘的遗留物,或者出于兼容性原因可能仍然保留.

The struct you found is not actually used anywhere in the file, so it's probably some forgotten leftover, or maybe is still kept around for compatibility reasons.

这篇关于reply_t vs request_t-可以互换地传递它们吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆