Add support for defining variadic callbacks via ctypes
オープン
まだ誰も着手していません。
extension-modules
topic-ctypes
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Feature or enhancement
Proposal:
When defining a callback with ctypes (CFUNCTYPE) it would be helpful to be able to replicate variadic functionality
for instance, take the following c code
void FormatPrintf(datap* format, char* fmt, ...) {
va_list args;
int length = 0;
va_start(args, fmt);
length = vsnprintf(NULL, 0, fmt, args);
va_end(args);
if (format->length + length > format->size) {
return;
}
va_start(args, fmt);
(void)vsnprintf(format->buffer, length, fmt, args);
va_end(args);
return;
}
Making something compatible with ctypes
@CFUNCTYPE(None, ctypes.POINTER(datap), ctypes.c_char_p, ctypes.c_variadic)
def FormatPrintf(format, fmt, variadic)
args = variadic.va_list
...
Maybe even could be handled as a pyobject list of ctypes objects as the variadic on the python side. Not sure what all the options are explicitly.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue にある ctypes CFUNCTYPE callback のエントリポイントと、C の variadic callback の例から始めます。variadic 引数でサポートされる表現と動作を明確にし、そのような callback の定義と呼び出しが機能することを示すために必要なテストを決定します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- api
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100