python / python/cpython

Please add documentation of the bitfield ordering for ctypes.Structure types

オープン
#118,434 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

docs topic-ctypes
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Documentation

The current documentation for ctypes bit fields is very limited and doesn't cover the definition order. AFAICT this is:
Little endian - LSB first -> MSB last
Big endian - MSB first -> LSB last
Native - ??? This is LSB first -> MSB last on x86 but is that just because it's a little endian architecture?

For example:

class BigOnes(BigEndianStructure):
   _pack_ = 1
    _fields_ = (
        ("bit_0", c_uint16, 1),  # MSBit
        ("bit_1", c_uint16, 1),
        ("bit_2", c_uint16, 1),
        ("bit_3", c_uint16, 1),
        ("nibble_1", c_uint16, 4),
        ("nibble_2", c_uint16, 4),
        ("nibble_3", c_uint16, 4),  # LSBit
        ("byte_3", c_uint16, 8),  # MSByte
        ("byte_4", c_uint16, 8),  # LSByte
    )

Versus:

class LittleOnes(LittleEndianStructure):
    _pack_ = 1
    _fields_ = (
        ("bit_0", c_uint16, 1),  # LSBit
        ("bit_1", c_uint16, 1),
        ("bit_2", c_uint16, 1),
        ("bit_3", c_uint16, 1),
        ("nibble_1", c_uint16, 4),
        ("nibble_2", c_uint16, 4),
        ("nibble_3", c_uint16, 4),  # MSBit
        ("byte_3", c_uint16, 8),  # LSByte
        ("byte_4", c_uint16, 8),  # MSByte
    )

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Structure、BigEndianStructure、LittleEndianStructure に関する ctypes のドキュメントから始め、提示されたビットフィールドの例を説明対象のケースとして使用します。リトルエンディアン、ビッグエンディアン、およびネイティブの構造体について、アーキテクチャ依存の動作を含む定義順序を特定して文書化し、結果のテキストに曖昧さがないことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。