Add support for combined name and pointer typedef#131
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #131 +/- ##
=======================================
Coverage 92.73% 92.74%
=======================================
Files 21 21
Lines 2381 2384 +3
=======================================
+ Hits 2208 2211 +3
Misses 173 173
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
24b5e5d to
3370154
Compare
Contributor
|
With the example you gave, this change will create the following stubfile: # Generated by cstruct-stubgen
from typing import BinaryIO, Literal, overload
import dissect.cstruct as __cs__
from typing_extensions import TypeAlias
class _c_func(__cs__.cstruct):
class _IMAGE_DATA_DIRECTORY(__cs__.Structure):
VirtualAddress: _c_func.uint32
Size: _c_func.uint32
@overload
def __init__(self, VirtualAddress: _c_func.uint32 | None = ..., Size: _c_func.uint32 | None = ...): ...
@overload
def __init__(self, fh: bytes | memoryview | bytearray | BinaryIO, /): ...
IMAGE_DATA_DIRECTORY: TypeAlias = _IMAGE_DATA_DIRECTORY
class _IMAGE_DATA_DIRECTORY*(__cs__.Pointer): ...
# Technically `c_func` is an instance of `_c_func`, but then we can't use it in type hints
c_func: TypeAlias = _c_funcI would expect something like the following instead. PIMAGE_DATA_DIRECTORY: TypeAlias = Pointer[_IMAGE_DATA_DIRECTORY]Could you fix this and add a test for it? |
6b0e1db to
70898f7
Compare
Miauwkeru
approved these changes
Jul 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #132.
Allows more easy copy/pasting from Microsoft and other structure definitions such as:
With this PR it correctly parses
IMAGE_DATA_DIRECTORYand*PIMAGE_DATA_DIRECTORY.