Please add documentation of the bitfield ordering for ctypes.Structure types
未關閉
還沒有人認領這個 Issue。
docs
topic-ctypes
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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
)
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 ctypes 關於 Structure、BigEndianStructure 和 LittleEndianStructure 的文件開始,將提供的位元欄位範例作為需要說明的案例。確定並記錄 little-endian、big-endian 和 native 結構的定義順序,包括依賴架構的行為,並驗證所得文字沒有歧義。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100