summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-18 10:54:10 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-19 14:58:22 -0300
commite1ea3fe74afca099e7bba884256e0be0e6f7d200 (patch)
treebde6a3b3d38248b64edd6f13e5f84cbee0aa82fc /generator
parent76c2a25f4def623be9c4ab30f2bde36bfed7ae08 (diff)
downloadshiboken-e1ea3fe74afca099e7bba884256e0be0e6f7d200.tar.gz
shiboken-e1ea3fe74afca099e7bba884256e0be0e6f7d200.tar.xz
shiboken-e1ea3fe74afca099e7bba884256e0be0e6f7d200.zip
Rewrite parent control functions.
Updated generator to new API. Fix bug #462 Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 25584ce3..239bd753 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -470,7 +470,8 @@ void CppGenerator::writeDestructorNative(QTextStream &s, const AbstractMetaClass
{
Indentation indentation(INDENT);
s << wrapperName(metaClass) << "::~" << wrapperName(metaClass) << "()" << endl << '{' << endl;
- s << INDENT << "BindingManager::instance().destroyWrapper(this);" << endl;
+ s << INDENT << "SbkObject* wrapper = BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "Wrapper::destroy(wrapper);" << endl;
s << '}' << endl;
}
@@ -523,6 +524,14 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
return;
}
+ //Write declaration/native injected code
+ if (func->hasInjectedCode()) {
+ CodeSnipList snips = func->injectedCodeSnips();
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, CodeSnip::Declaration, TypeSystem::NativeCode, func, lastArg);
+ s << endl;
+ }
+
s << INDENT << "Shiboken::GilState gil;" << endl;
s << INDENT << "Shiboken::AutoDecRef py_override(BindingManager::instance().getOverride(this, \"";
@@ -542,7 +551,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (func->isAbstract()) {
s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"pure virtual method '";
s << func->ownerClass()->name() << '.' << func->name();
- s << "()' not implemented.\");" << endl;
+ s << "()' not implemented.\");" << endl;
s << INDENT << "return ";
if (func->type()) {
s << defaultReturnExpr;
@@ -731,7 +740,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (invalidateReturn) {
s << INDENT << "if (invalidadeArg0)" << endl;
Indentation indentation(INDENT);
- s << INDENT << "BindingManager::instance().invalidateWrapper(" << PYTHON_RETURN_VAR ".object());" << endl;
+ s << INDENT << "Wrapper::invalidate(" << PYTHON_RETURN_VAR ".object());" << endl;
}
foreach (FunctionModification funcMod, func->modifications()) {
@@ -739,7 +748,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (argMod.resetAfterUse) {
s << INDENT << "if (invalidadeArg" << argMod.index << ")" << endl;
Indentation indentation(INDENT);
- s << INDENT << "BindingManager::instance().invalidateWrapper(PyTuple_GET_ITEM(pyargs, ";
+ s << INDENT << "Wrapper::invalidate(PyTuple_GET_ITEM(pyargs, ";
s << (argMod.index - 1) << "));" << endl;
}
}
@@ -2121,15 +2130,15 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
s << INDENT;
if (arg_mod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::TargetLangOwnership) {
- s << "Shiboken::Wrapper::getOwnership(" << pyArgName << ");";
+ s << "Wrapper::getOwnership(" << pyArgName << ");";
} else if (wrappedClass->hasVirtualDestructor()) {
if (arg_mod.index == 0) {
- s << "Shiboken::Wrapper::releaseOwnership(" PYTHON_RETURN_VAR ");";
+ s << "Wrapper::releaseOwnership(" PYTHON_RETURN_VAR ");";
} else {
- s << "BindingManager::instance().transferOwnershipToCpp(" << pyArgName << ");";
+ s << "Wrapper::releaseOwnership(" << pyArgName << ");";
}
} else {
- s << "BindingManager::instance().invalidateWrapper(" << pyArgName << ");";
+ s << "Wrapper::invalidate(" << pyArgName << ");";
}
s << endl;
}
@@ -3798,7 +3807,7 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
else
childVariable = usePyArgs ? "pyargs["+QString::number(childIndex-1)+"]" : "arg";
- s << INDENT << "Shiboken::setParent(" << parentVariable << ", " << childVariable << ");\n";
+ s << INDENT << "Wrapper::setParent(" << parentVariable << ", " << childVariable << ");\n";
return true;
}
@@ -3832,7 +3841,7 @@ void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMeta
}
if (type->isQObject() || type->isObject() || type->isValuePointer())
- s << INDENT << "Shiboken::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "Wrapper::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
}
void CppGenerator::writeHashFunction(QTextStream& s, const AbstractMetaClass* metaClass)