private-attribute-cpp 2.1.0__tar.gz → 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {private_attribute_cpp-2.1.0/private_attribute_cpp.egg-info → private_attribute_cpp-2.1.1}/PKG-INFO +1 -1
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/private_attribute.cpp +22 -29
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/setup.py +1 -1
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/LICENSE +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/MANIFEST.in +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/README.md +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/picosha2.h +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/private_attribute.pyi +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/setup.cfg +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_class_private_attrs.py +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_abc.py +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_attrs.py +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_func.py +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_inheritance.py +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_method.py +0 -0
- {private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_wrap.py +0 -0
{private_attribute_cpp-2.1.0/private_attribute_cpp.egg-info → private_attribute_cpp-2.1.1}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: A Python package that provides a way to define private attributes in C++ implementation.
|
|
5
5
|
Home-page: https://github.com/Locked-chess-official/private_attribute_cpp
|
|
6
6
|
Author: HuangHaoHua
|
|
@@ -178,11 +178,7 @@ namespace {
|
|
|
178
178
|
};
|
|
179
179
|
static std::unordered_map<uintptr_t, std::unordered_map<uintptr_t, PyCodeObject*>> type_allowed_code_map;
|
|
180
180
|
static std::unordered_map<uintptr_t, std::shared_ptr<std::shared_mutex>> all_type_mutex;
|
|
181
|
-
|
|
182
|
-
// INCREFs on assignment and DECREFs on destruction), so the map entry
|
|
183
|
-
// always owns exactly one reference - no dangling-pointer risk when the
|
|
184
|
-
// last external reference to the function disappears.
|
|
185
|
-
static std::unordered_map<uintptr_t, PyObjectStorage> type_need_call;
|
|
181
|
+
static std::unordered_map<uintptr_t, PyObject*> type_need_call;
|
|
186
182
|
static std::unordered_map<uintptr_t, std::unordered_set<TwoStringTuple>> all_type_attr_set;
|
|
187
183
|
namespace {
|
|
188
184
|
static std::unordered_map<uintptr_t, std::unordered_map<uintptr_t,
|
|
@@ -1623,6 +1619,21 @@ PrivateAttr_tp_clear(PyObject* self) noexcept
|
|
|
1623
1619
|
return 0;
|
|
1624
1620
|
}
|
|
1625
1621
|
|
|
1622
|
+
// get_type_need_tp_* : the metaclass counterparts of get_need_tp_*.
|
|
1623
|
+
// get_need_tp_* -> find the original slots of *types created by* the
|
|
1624
|
+
// metaclasses (wrapped with the instance-level
|
|
1625
|
+
// PrivateAttr_tp_* / PrivateAttr_tp_getattro set).
|
|
1626
|
+
// get_type_need_tp_* -> find the original slots of the *metaclasses*
|
|
1627
|
+
// themselves (wrapped with the metaclass-level
|
|
1628
|
+
// PrivateAttrType_getattr / PrivateAttrType_setattr /
|
|
1629
|
+
// register_finalize / PrivateAttrType_tp_traverse /
|
|
1630
|
+
// PrivateAttrType_tp_clear).
|
|
1631
|
+
static getattrofunc get_type_need_tp_getattro(PyTypeObject* cls) noexcept;
|
|
1632
|
+
static setattrofunc get_type_need_tp_setattro(PyTypeObject* cls) noexcept;
|
|
1633
|
+
static traverseproc get_type_need_tp_traverse(PyTypeObject* cls) noexcept;
|
|
1634
|
+
static inquiry get_type_need_tp_clear(PyTypeObject* cls) noexcept;
|
|
1635
|
+
static destructor get_type_need_tp_finalize(PyTypeObject* cls) noexcept;
|
|
1636
|
+
|
|
1626
1637
|
// metaclass-level (type object) traverse/clear: call original if any, and handle AllData-stored type attributes
|
|
1627
1638
|
static int
|
|
1628
1639
|
PrivateAttrType_tp_traverse(PyObject* self, visitproc visit, void* arg) noexcept
|
|
@@ -1644,7 +1655,7 @@ PrivateAttrType_tp_traverse(PyObject* self, visitproc visit, void* arg) noexcept
|
|
|
1644
1655
|
if (res) return res;
|
|
1645
1656
|
}
|
|
1646
1657
|
} else {
|
|
1647
|
-
traverseproc orig =
|
|
1658
|
+
traverseproc orig = get_type_need_tp_traverse(typ);
|
|
1648
1659
|
if (orig) {
|
|
1649
1660
|
int res = orig(self, visit, arg);
|
|
1650
1661
|
if (res) return res;
|
|
@@ -1731,7 +1742,7 @@ PrivateAttrType_tp_clear(PyObject* self) noexcept
|
|
|
1731
1742
|
inquiry orig = ::AllData::all_type_clear[typ_id];
|
|
1732
1743
|
if (orig) orig(self);
|
|
1733
1744
|
} else {
|
|
1734
|
-
inquiry orig =
|
|
1745
|
+
inquiry orig = get_type_need_tp_clear(typ);
|
|
1735
1746
|
if (orig) orig(self);
|
|
1736
1747
|
}
|
|
1737
1748
|
|
|
@@ -1815,8 +1826,8 @@ static PyTypeObject PrivateAttrType = {
|
|
|
1815
1826
|
0, // tp_as_buffer
|
|
1816
1827
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
|
|
1817
1828
|
"metaclass for private attributes", // tp_doc
|
|
1818
|
-
|
|
1819
|
-
|
|
1829
|
+
(traverseproc)PrivateAttrType_tp_traverse, // tp_travers
|
|
1830
|
+
(inquiry)PrivateAttrType_tp_clear, // tp_clear
|
|
1820
1831
|
0, // tp_richcompare
|
|
1821
1832
|
0, // tp_weaklistoffset
|
|
1822
1833
|
0, // tp_iter
|
|
@@ -2505,21 +2516,6 @@ static traverseproc get_need_tp_traverse(PyTypeObject* cls) noexcept;
|
|
|
2505
2516
|
static inquiry get_need_tp_clear(PyTypeObject* cls) noexcept;
|
|
2506
2517
|
static destructor get_need_tp_finalize(PyTypeObject* cls) noexcept;
|
|
2507
2518
|
|
|
2508
|
-
// get_type_need_tp_* : the metaclass counterparts of get_need_tp_*.
|
|
2509
|
-
// get_need_tp_* -> find the original slots of *types created by* the
|
|
2510
|
-
// metaclasses (wrapped with the instance-level
|
|
2511
|
-
// PrivateAttr_tp_* / PrivateAttr_tp_getattro set).
|
|
2512
|
-
// get_type_need_tp_* -> find the original slots of the *metaclasses*
|
|
2513
|
-
// themselves (wrapped with the metaclass-level
|
|
2514
|
-
// PrivateAttrType_getattr / PrivateAttrType_setattr /
|
|
2515
|
-
// register_finalize / PrivateAttrType_tp_traverse /
|
|
2516
|
-
// PrivateAttrType_tp_clear).
|
|
2517
|
-
static getattrofunc get_type_need_tp_getattro(PyTypeObject* cls) noexcept;
|
|
2518
|
-
static setattrofunc get_type_need_tp_setattro(PyTypeObject* cls) noexcept;
|
|
2519
|
-
static traverseproc get_type_need_tp_traverse(PyTypeObject* cls) noexcept;
|
|
2520
|
-
static inquiry get_type_need_tp_clear(PyTypeObject* cls) noexcept;
|
|
2521
|
-
static destructor get_type_need_tp_finalize(PyTypeObject* cls) noexcept;
|
|
2522
|
-
|
|
2523
2519
|
// instance-level traverse/clear for types that use private attributes
|
|
2524
2520
|
static int PrivateAttr_tp_traverse(PyObject* self, visitproc visit, void* arg) noexcept;
|
|
2525
2521
|
static int PrivateAttr_tp_clear(PyObject* self) noexcept;
|
|
@@ -2739,10 +2735,7 @@ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data) n
|
|
|
2739
2735
|
}
|
|
2740
2736
|
|
|
2741
2737
|
if (data.private_func) {
|
|
2742
|
-
|
|
2743
|
-
// data's reference is released by PrivateAttrCreationData::clear()
|
|
2744
|
-
// right after this, and the map entry's reference is released when the
|
|
2745
|
-
// entry is erased in PrivateAttrType_finalize.
|
|
2738
|
+
Py_INCREF(data.private_func);
|
|
2746
2739
|
::AllData::type_need_call[type_id] = data.private_func;
|
|
2747
2740
|
}
|
|
2748
2741
|
|
|
@@ -3231,7 +3224,7 @@ PrivateAttrType_finalize(PyObject* cls) noexcept
|
|
|
3231
3224
|
::AllData::type_allowed_code_map.erase(typ_id);
|
|
3232
3225
|
}
|
|
3233
3226
|
if (::AllData::type_need_call.find(typ_id) != ::AllData::type_need_call.end()) {
|
|
3234
|
-
|
|
3227
|
+
Py_DECREF(::AllData::type_need_call[typ_id]);
|
|
3235
3228
|
::AllData::type_need_call.erase(typ_id);
|
|
3236
3229
|
}
|
|
3237
3230
|
if (::AllData::type_attr_dict.find(typ_id) != ::AllData::type_attr_dict.end()) {
|
{private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1/private_attribute_cpp.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: A Python package that provides a way to define private attributes in C++ implementation.
|
|
5
5
|
Home-page: https://github.com/Locked-chess-official/private_attribute_cpp
|
|
6
6
|
Author: HuangHaoHua
|
|
@@ -18,7 +18,7 @@ readme = open('README.md').read()
|
|
|
18
18
|
|
|
19
19
|
setup(
|
|
20
20
|
name='private_attribute_cpp',
|
|
21
|
-
version='2.1.
|
|
21
|
+
version='2.1.1',
|
|
22
22
|
author="HuangHaoHua",
|
|
23
23
|
author_email="13140752715@example.com",
|
|
24
24
|
description='A Python package that provides a way to define private attributes in C++ implementation.',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_class_private_attrs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-2.1.0 → private_attribute_cpp-2.1.1}/tests/test_private_inheritance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|