Skip to content

Commit a9c22b4

Browse files
committed
Deployed 5bca4a1 with MkDocs version: 1.6.1
1 parent 8758cda commit a9c22b4

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

index.html

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
</li>
6868
<li class="toctree-l3"><a class="reference internal" href="#define-sizeof-and-eval">Define, Sizeof, and Eval</a>
6969
</li>
70+
<li class="toctree-l3"><a class="reference internal" href="#accessing-field-definitions">Accessing Field Definitions</a>
71+
</li>
7072
<li class="toctree-l3"><a class="reference internal" href="#ispect-memory">Ispect memory</a>
7173
</li>
7274
</ul>
@@ -272,12 +274,15 @@ <h3 id="nested-structsunions">Nested structs/unions</h3>
272274
&quot;&quot;&quot;
273275
</code></pre>
274276
<h3 id="byte-order-size-and-padding">Byte Order, Size, and Padding</h3>
275-
<p>Suported byte orders:</p>
277+
<p>Python-CStruct supports big-endian, little-endian, and native byte orders, which you can specify using:</p>
276278
<ul>
277-
<li><code>cstruct.LITTLE_ENDIAN</code> - Little endian byte order, standard size, no padding</li>
278-
<li><code>cstruct.BIG_ENDIAN</code> - Big endian byte order, standard size, no padding</li>
279-
<li><code>cstruct.NATIVE_ORDER</code> - Native byte order, native size, padding</li>
279+
<li><code>cstruct.LITTLE_ENDIAN</code> - Little endian byte order, standard size, no padding.</li>
280+
<li><code>cstruct.BIG_ENDIAN</code> - Big endian byte order, standard size, no padding.</li>
281+
<li><code>cstruct.NATIVE_ORDER</code> - Native byte order, native size, padding. Native byte order is big-endian or little-endian, depending on the host system.</li>
280282
</ul>
283+
<p>Standard size depends only on the format character while native size depends on the host system.
284+
For native order, padding is automatically added to align the structure members.</p>
285+
<p>For more information, see the <a href="https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment">struct - Byte Order, Size, and Padding</a> section.</p>
281286
<pre><code class="language-python">class Native(cstruct.MemCStruct):
282287
__byte_order__ = cstruct.NATIVE_ORDER
283288
__def__ = &quot;&quot;&quot;
@@ -400,6 +405,52 @@ <h3 id="define-sizeof-and-eval">Define, Sizeof, and Eval</h3>
400405
}
401406
&quot;&quot;&quot;
402407
</code></pre>
408+
<h3 id="accessing-field-definitions">Accessing Field Definitions</h3>
409+
<p>Python-CStruct provides the <code>__fields_types__</code> attribute at the class level, which allows you to inspect the metadata of each field.
410+
The dictionary contains each field's name as a key and its metadata as a value.
411+
Each field has the following attributes:</p>
412+
<table>
413+
<thead>
414+
<tr>
415+
<th>Attribute</th>
416+
<th>Description</th>
417+
</tr>
418+
</thead>
419+
<tbody>
420+
<tr>
421+
<td><code>kind</code></td>
422+
<td>Indicates whether the field is a primitive type or a nested struct.</td>
423+
</tr>
424+
<tr>
425+
<td><code>c_type</code></td>
426+
<td>The corresponding C type.</td>
427+
</tr>
428+
<tr>
429+
<td><code>ref</code></td>
430+
<td>If the field is a nested struct, this contains a reference to the class representing that struct.</td>
431+
</tr>
432+
<tr>
433+
<td><code>vlen_ex</code></td>
434+
<td>The number of elements in the field.</td>
435+
</tr>
436+
<tr>
437+
<td><code>flexible_array</code></td>
438+
<td>Indicates whether the field is a flexible array.</td>
439+
</tr>
440+
<tr>
441+
<td><code>byte_order</code></td>
442+
<td>The byte order of the field.</td>
443+
</tr>
444+
<tr>
445+
<td><code>offset</code></td>
446+
<td>The relative position of the field within the struct.</td>
447+
</tr>
448+
<tr>
449+
<td><code>padding</code></td>
450+
<td>The number of bytes added before this field for alignment.</td>
451+
</tr>
452+
</tbody>
453+
</table>
403454
<h3 id="ispect-memory">Ispect memory</h3>
404455
<p>The <a href="https://python-cstruct.readthedocs.io/en/latest/api/abstract/#cstruct.abstract.AbstractCStruct.inspect"><code>inspect</code></a> methods displays memory contents in hexadecimal.</p>
405456
<pre><code class="language-python">print(mbr.inspect())
@@ -490,5 +541,5 @@ <h2 id="links">Links</h2>
490541

491542
<!--
492543
MkDocs version : 1.6.1
493-
Build Date UTC : 2025-01-16 19:35:50.915244+00:00
544+
Build Date UTC : 2025-02-18 05:53:39.039107+00:00
494545
-->

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)