diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-09 14:38:53 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-10 08:43:17 -0300 |
commit | e823354fc4e1b5518d47d986bd25b1533637e64f (patch) | |
tree | 7269a5c40480e2cdcacf8e31ca9ee2d410458b7c | |
parent | 8eb50faa234bc5d26ac721ca8fe5f263cf55230d (diff) |
Adds 2 convenience methods to ShibokenGenerator to check for refcount mods.
The new expressively named methods hasMethodsWithReferenceCountModifications
and needsReferenceCountControl returns boolean values to help generation
of code for reference counting support.
-rw-r--r-- | shibokengenerator.cpp | 20 | ||||
-rw-r--r-- | shibokengenerator.h | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index 4bcb038f8..82eff597b 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -1091,6 +1091,26 @@ bool ShibokenGenerator::hasMultipleInheritanceInAncestry(const AbstractMetaClass return hasMultipleInheritanceInAncestry(metaClass->baseClass()); } +bool ShibokenGenerator::needsReferenceCountControl(const AbstractMetaClass* metaClass) +{ + if (!metaClass->fields().isEmpty()) + return true; + return hasMethodsWithReferenceCountModifications(metaClass); +} + +bool ShibokenGenerator::hasMethodsWithReferenceCountModifications(const AbstractMetaClass* metaClass) +{ + foreach (const AbstractMetaFunction* func, metaClass->functions()) { + foreach (FunctionModification func_mod, func->modifications()) { + foreach (ArgumentModification arg_mod, func_mod.argument_mods) { + if (!arg_mod.referenceCounts.isEmpty()) + return true; + } + } + } + return false; +} + bool ShibokenGenerator::classNeedsGetattroFunction(const AbstractMetaClass* metaClass) { if (!metaClass) diff --git a/shibokengenerator.h b/shibokengenerator.h index a675aa749..cae9943b1 100644 --- a/shibokengenerator.h +++ b/shibokengenerator.h @@ -177,6 +177,12 @@ public: /// Returns true if there are cases of multiple inheritance in any of its ancestors. bool hasMultipleInheritanceInAncestry(const AbstractMetaClass* metaClass); + /// Returns true if the class needs reference counting control. + bool needsReferenceCountControl(const AbstractMetaClass* metaClass); + + /// Returns true if the class has any method that modifies the reference counting of any of its arguments. + bool hasMethodsWithReferenceCountModifications(const AbstractMetaClass* metaClass); + /// Returns true if the class needs to have a getattro function. bool classNeedsGetattroFunction(const AbstractMetaClass* metaClass); |