-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DEV] 2.2.0 - C API Breaking changes #11
Merged
Merged
Conversation
This file contains 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
--- + Implementation for native switch and condition
--- + fixed issues with CpLayer* classes + changed struct to builtinatom
--- + CpPrimitiveAtom <-> patom + Updated _C.pyi + updated tests (padding_atom excluded) + Added CpStruct_Sizeof + Fixed CpState_Seek + Builtin-Atoms now use builtinatom as base class
--- + Removed API functions to pack fields and structs + Fixed repeated atom parsing logic to accept __pack_many__ and __unpack_many__ + New type CpLengthInfoObject + Removed deprecated parsing logic + Added verification logic to paddingatom
... + Python class: "octetstring" + Tests included
--- + Python type: `pstring` + New API functions: CpState_ReadSsize_t, CpPStringAtom_Pack and CpPStringAtom_Unpack + Tests included + Added macro to implement byteorder operator (_CpEndian_ImplSetByteorder)
--- + Python class: `enumeration` + Tests included + Updated roadmap accordingly
MatrixEditor
added
Status: In Progress
Type: Feature
Type: Enhancement
Priority: High
Type: Documentation
and removed
documentation
labels
Sep 8, 2024
MatrixEditor
changed the title
[DEV] 2.2.0 - Breaking changes
[DEV] 2.2.0 - C API Breaking changes
Sep 8, 2024
--- + CpVarIntAtom for both little endian and bigendian + Added C installation candidate to subpackage + Tests included + New C API functions: CpVarIntAtom_New, CpVarIntAtom_Pack, CpVarIntAtom_Unpack, CpVarIntAtom_BSwap, CpVarIntAtom_BSwapUnsignedLongLong, CpVarIntAtom_BSwapLongLong, CpVarIntAtom_BSwapSsize_t + Changed CpEndian and CpArch representation
--- + Enabled tests for C implementation
--- + Tests included + Python type: `computed`
--- + Python type: `lazy` + Tests included + README installation update
--- + Python Type: `cstring` + Tests included + Changed encoding parameter to be optional
--- + int_t -> Int + float_t -> Float + varint_t -> VarInt + const_t -> const + padding_t -> Padding + bool_t -> Bool + char_t -> Char + added missing __bits__ method string to internal module state
--- + CpInvalidDefault and CpDefaultSwitchOption now in separate source file
--- + c.Int Python type documentation + added copybutton to docs
--- + Fixed issue with STRUCT_OPTIONS referenced two times + cstring now parses with greedy option by default + Documentation updates + modified tests adapt to fixed bugs and naming changes
--- + Renamed atom documentation files and removed the "atom" suffix
--- + Removed field related tests
--- + Fixed refcount issue in _CpPack_EvalLength and _CpUnpack_EvalLength + Added Py_TPFLAGS_BASETYPE to all C types + Struct model classes can now be used in pack() and unpack() calls + Added missing operations to CpBinaryExpr and CpUnaryExpr
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.
Minor Release 2.2.0 breaking changes
This release will introduce breaking changes in the C API of this project, reducing the overhead of
CpFieldObject
andsplitting the monolithic parsing functions.
Tasks
What's changed
The native module (
caterpillar._C
) can be installed via pip without the environment variable present:pip install "caterpillar[all]@git+https://github.com/MatrixEditor/caterpillar/#subdirectory=src/ccaterpillar"
The following new C atoms have been added/implemented:
CpBuiltinAtomObject
: Base class for all standard atoms (C-layer) (Python Type:builtinatom
)CpRepeatedAtomObject
: essentially a sequence of atoms (Python Type:repeated
)CpConditionAtomObject
: adds a condition to the target atom (Python Type:conditional
)CpSwitchAtomObject
: simulates a switch statement (Python Type:switch
)CpOffsetAtomObject
: places the atom at a specific offset (Python Type:atoffset
)CpPrimitiveAtomObject
: same asbuiltinatom
but for Python classes (Python Type:patom
)CpBytesAtomObject
: equivalent ofcaterpillar.py.Bytes
(Python Type:octetstring
)CpPStringAtomObject
: Pascal-String implementation (Python Type:pstring
)CpConstAtomObject
: constant expressions (Python Type:const
)CpEnumAtomObject
: support forenum.Enum
types (Python Type:enumeration
)CpVarIntAtomObject
: little endian and big endian variable-length integer objects (Python Type:VarInt
)CpComputedAtomObject
: constant expressions (Python type:computed
): forward references to atoms (Python type:
lazy`): C-Strings with variable padding character (Python type:
cstring`)The following C atoms have been renamed:
CpIntAtomObject
: Python Typeint_t
->Int
CpPaddingAtomObject
: Python Typepadding_t
->Padding
CpFloatAtomObject
: Python Typefloat_t
->Float
CpCharAtomObject
: Python Typechar_t
->Char
CpBoolAtomObject
: Python Typebool_t
->Bool
There are now two python modules which import all available classes at once. They can be accessed via their
language tag (Both implementations are not compatible to each other):
A new unique feature was added to the C module to be able to map Python types to atom types. Using the
TYPE_MAP
one can configure a mapping between a native Python type and its corresponding atom representation:How the C API headers are generated has changed:
src/capi.dat
using the following schema:Defines a C API type for a C structure. The index is optional and the CAPI_TYPE will be inferred as PyTypeObject if none set
Defines a C API object.
Defines a C API function. The function must be present within the source set of this file.
Defines the source file (relative to this file) that contains the function definitions.
The following changes have been made to the C API: