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

Override dead bindings when registering a new binding. #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions libshiboken/bindingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ void BindingManager::BindingManagerPrivate::releaseWrapper(void* cptr)
void BindingManager::BindingManagerPrivate::assignWrapper(SbkObject* wrapper, const void* cptr)
{
assert(cptr);
WrapperMap::iterator iter = wrapperMapper.find(cptr);
if (iter == wrapperMapper.end())
wrapperMapper.insert(std::make_pair(cptr, wrapper));
wrapperMapper[cptr] = wrapper;
}

BindingManager::BindingManager()
Expand Down
10 changes: 10 additions & 0 deletions shibokenmodule/typesystem_shiboken.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<custom-type name="PyType" />
<primitive-type name="bool" />
<primitive-type name="unsigned long" />
<primitive-type name="size_t" />
<add-function signature="isValid(PyObject*)" return-type="bool">
<inject-code>
bool isValid = Shiboken::Object::isValid(%1, false);
Expand Down Expand Up @@ -39,6 +40,15 @@
</inject-code>
</add-function>

<add-function signature="getBinding(size_t)" return-type="PyObject *">
<inject-code>
%PYARG_0 = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper((void *)%1);
if(!%PYARG_0) {
PyErr_SetString(PyExc_ValueError, "No binding registered.");
}
</inject-code>
</add-function>

<add-function signature="delete(PyObject*)">
<inject-code>
if (Shiboken::Object::checkType(%1)) {
Expand Down