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