Skip to content
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 29 commits into from
Sep 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
883dbd7
Updated name schema of C atoms
MatrixEditor Sep 7, 2024
fc8f68b
Renamed _Py to py and added c importer module
MatrixEditor Sep 7, 2024
fac0cd3
ConsAtom (C)
MatrixEditor Sep 7, 2024
b261135
Changed CpLayer parsing logic
MatrixEditor Sep 8, 2024
6e00b01
CpConditionAtom implementation
MatrixEditor Sep 8, 2024
bf727f2
Changed CAPI definition file
MatrixEditor Sep 8, 2024
8983f26
Added CpOffsetAtom
MatrixEditor Sep 8, 2024
039aea7
New primitive atom for python classes
MatrixEditor Sep 8, 2024
f2b3333
Updated pack_many catom callback
MatrixEditor Sep 8, 2024
7e65756
CpBytesAtom implementation
MatrixEditor Sep 8, 2024
214d108
Pascal-String C implementation
MatrixEditor Sep 8, 2024
a9a2dda
Implementation for C enum atoms
MatrixEditor Sep 8, 2024
d531275
Change version to 2.2.0-rc
MatrixEditor Sep 8, 2024
64802f3
C varint implementation
MatrixEditor Sep 9, 2024
162b208
Removed CpContext_GetAttr* methods
MatrixEditor Sep 9, 2024
2fa8817
Fix CpVarIntAtom on Windows
MatrixEditor Sep 9, 2024
c85b45e
Renamed atom implementation files
MatrixEditor Sep 11, 2024
06a278a
CpComputedAtom implementation
MatrixEditor Sep 14, 2024
f5d4931
CpLazyAtom implementation
MatrixEditor Sep 14, 2024
792f15c
CpCStringAtom implementation
MatrixEditor Sep 14, 2024
9966a7e
Renamed *_t python types
MatrixEditor Sep 15, 2024
875f520
Moved C sources into ccaterpillar directory
MatrixEditor Sep 15, 2024
29d91e9
CpIntAtomObject Docs
MatrixEditor Sep 15, 2024
4eac7b1
Added Python class names of C types to capi.dat
MatrixEditor Sep 15, 2024
3aa6bae
Updated Tutorial documentation
MatrixEditor Sep 15, 2024
2ec7343
Removed all field-* related types
MatrixEditor Sep 28, 2024
a1cde82
Updated stub file
MatrixEditor Sep 28, 2024
d21f29e
New feature: global type handlers for capi structs
MatrixEditor Sep 29, 2024
5a27851
Updated documentation and bumped version to 2.2.0
MatrixEditor Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed CpLayer parsing logic
MatrixEditor committed Sep 8, 2024
commit b261135758e31aa84a8432274bb8c7f499437cd1
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ python_add_library(
src/context.c
src/state.c
src/struct.c
src/layer.c

src/parsing_typeof.c
src/parsing_sizeof.c
@@ -37,6 +38,9 @@ python_add_library(
src/atomimpl/stringatomobj.c
src/atomimpl/constatomobj.c

src/atomimpl/builtins/builtinatomobj.c
src/atomimpl/builtins/repeatedatomobj.c

WITH_SOABI
)

5 changes: 4 additions & 1 deletion docs/sphinx/source/extensions/refcounts.dat
Original file line number Diff line number Diff line change
@@ -43,4 +43,7 @@ CpLayer_New:CpLayerObject*:+1

CpIntAtom_Unpack:PyObject*:+1

CpFloatAtom_Unpack:PyObject*:+1
CpFloatAtom_Unpack:PyObject*:+1

CpRepeatedAtom_GetLength:PyObject*:+1
CpRepeatedAtom_Unpack:PyObject*:+1
63 changes: 63 additions & 0 deletions src/atomimpl/builtins/builtinatomobj.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* builtinatom C implementation */

#include "caterpillar/caterpillar.h"

#include <structmember.h>

/* impl */
static PyObject*
cp_builtinatomobj_new(PyTypeObject* type, PyObject* args, PyObject* kw)
{
CpBuiltinAtomObject* self;
self = (CpBuiltinAtomObject*)type->tp_alloc(type, 0);
if (self == NULL)
return NULL;
self->ob_base.ob_bits = NULL;
self->ob_base.ob_pack = NULL;
self->ob_base.ob_pack_many = NULL;
self->ob_base.ob_unpack = NULL;
self->ob_base.ob_unpack_many = NULL;
self->ob_base.ob_size = NULL;
self->ob_base.ob_type = NULL;
return (PyObject*)self;
}

static void
cp_builtinatomobj_dealloc(CpBuiltinAtomObject* self)
{
self->ob_base.ob_bits = NULL;
self->ob_base.ob_pack = NULL;
self->ob_base.ob_pack_many = NULL;
self->ob_base.ob_unpack = NULL;
self->ob_base.ob_unpack_many = NULL;
self->ob_base.ob_size = NULL;
self->ob_base.ob_type = NULL;
Py_TYPE(self)->tp_free((PyObject*)self);
}

static int
cp_builtinatomobj_init(CpBuiltinAtomObject* self, PyObject* args, PyObject* kw)
{
_Cp_InitNoArgs(CpBuiltinAtomObject, args, kw);
}

// TODO member methods
static PyObject*
cp_builtinatomobj_as_mapping_getitem(CpBuiltinAtomObject* self,
PyObject* length)
{
return (PyObject*)CpRepeatedAtom_New((PyObject*)self, length);
}

static PyMappingMethods CpFieldAtom_MappingMethods = {
.mp_subscript = (binaryfunc)cp_builtinatomobj_as_mapping_getitem,
};

PyTypeObject CpBuiltinAtom_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "CpBuiltinAtom", // tp_name
.tp_basicsize = sizeof(CpBuiltinAtomObject),
.tp_dealloc = (destructor)cp_builtinatomobj_dealloc,
.tp_init = (initproc)cp_builtinatomobj_init,
.tp_new = (newfunc)cp_builtinatomobj_new,
.tp_as_mapping = &CpFieldAtom_MappingMethods,
};
Loading