我能通过C API编写一个Python抽象类吗?

2024-10-01 22:31:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用一些c代码,我想通过c api将其包装成一个python抽象类。你知道吗

我使用的源代码是:https://github.com/samba-team/samba/tree/master/libgpo/gpext(samba项目的一部分)

我有两个结构,一个gp\u扩展结构和一个gp\u扩展\u方法结构。gp\u extension结构包含对gp\u extension\u methods结构的引用。你知道吗

struct gp_extension {
    struct GUID *guid;
    const char *name;
    struct gp_extension_methods *methods;
    struct gp_extension *prev, *next;
};

struct gp_extension_methods {

    NTSTATUS (*initialize)(TALLOC_CTX *mem_ctx);

    NTSTATUS (*process_group_policy)(TALLOC_CTX *mem_ctx,
                     uint32_t flags,
                     struct registry_key *root_key,
                     const struct security_token *token,
                     const struct GROUP_POLICY_OBJECT *deleted_gpo_list,
                     const struct GROUP_POLICY_OBJECT *changed_gpo_list);

    NTSTATUS (*get_reg_config)(TALLOC_CTX *mem_ctx,
                   struct gp_extension_reg_info **info);

    NTSTATUS (*shutdown)(void);
};

我想通过c api将这些方法结合起来,并创建一个gp\u扩展抽象基类,其中gp\u扩展\u方法是派生类必须实现的抽象方法。你知道吗

我的问题是,有人知道这是否可以通过pythoncapi实现吗?如果是的话,有人知道我在哪里可以找到一个例子吗(我已经搜索了,但是没有找到任何东西)?你知道吗


Tags: 方法keyapiextension结构memstructmethods

热门问题