mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-13 17:13:53 +00:00
Decoupling generic_type from type_caster_generic.
This commit is contained in:
parent
e345db05bd
commit
3d4bf091f3
@ -60,7 +60,7 @@ public:
|
|||||||
/* Process optional arguments, if any */
|
/* Process optional arguments, if any */
|
||||||
process_attributes<Extra...>::init(extra..., &record);
|
process_attributes<Extra...>::init(extra..., &record);
|
||||||
|
|
||||||
generic_type::initialize(record);
|
generic_type::initialize(record, &modified_type_caster_generic_load_impl::local_load);
|
||||||
|
|
||||||
if (has_alias) {
|
if (has_alias) {
|
||||||
auto &instances = record.module_local ? registered_local_types_cpp() : get_internals().registered_types_cpp;
|
auto &instances = record.module_local ? registered_local_types_cpp() : get_internals().registered_types_cpp;
|
||||||
|
@ -1082,7 +1082,8 @@ class generic_type : public object {
|
|||||||
public:
|
public:
|
||||||
PYBIND11_OBJECT_DEFAULT(generic_type, object, PyType_Check)
|
PYBIND11_OBJECT_DEFAULT(generic_type, object, PyType_Check)
|
||||||
protected:
|
protected:
|
||||||
void initialize(const type_record &rec) {
|
void initialize(const type_record &rec,
|
||||||
|
void *(*type_caster_module_local_load)(PyObject *, const type_info *)) {
|
||||||
if (rec.scope && hasattr(rec.scope, "__dict__") && rec.scope.attr("__dict__").contains(rec.name))
|
if (rec.scope && hasattr(rec.scope, "__dict__") && rec.scope.attr("__dict__").contains(rec.name))
|
||||||
pybind11_fail("generic_type: cannot initialize type \"" + std::string(rec.name) +
|
pybind11_fail("generic_type: cannot initialize type \"" + std::string(rec.name) +
|
||||||
"\": an object with that name is already defined");
|
"\": an object with that name is already defined");
|
||||||
@ -1128,7 +1129,7 @@ protected:
|
|||||||
|
|
||||||
if (rec.module_local) {
|
if (rec.module_local) {
|
||||||
// Stash the local typeinfo and loader so that external modules can access it.
|
// Stash the local typeinfo and loader so that external modules can access it.
|
||||||
tinfo->module_local_load = &type_caster_generic::local_load; // TODO classh_type_casters local_load
|
tinfo->module_local_load = type_caster_module_local_load;
|
||||||
setattr(m_ptr, PYBIND11_MODULE_LOCAL_ID, capsule(tinfo));
|
setattr(m_ptr, PYBIND11_MODULE_LOCAL_ID, capsule(tinfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1295,7 +1296,7 @@ public:
|
|||||||
/* Process optional arguments, if any */
|
/* Process optional arguments, if any */
|
||||||
process_attributes<Extra...>::init(extra..., &record);
|
process_attributes<Extra...>::init(extra..., &record);
|
||||||
|
|
||||||
generic_type::initialize(record);
|
generic_type::initialize(record, &type_caster_generic::local_load);
|
||||||
|
|
||||||
if (has_alias) {
|
if (has_alias) {
|
||||||
auto &instances = record.module_local ? registered_local_types_cpp() : get_internals().registered_types_cpp;
|
auto &instances = record.module_local ? registered_local_types_cpp() : get_internals().registered_types_cpp;
|
||||||
|
Loading…
Reference in New Issue
Block a user