aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-05-19 15:02:02 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:03 -0300
commit22f0c2b7b75a58e417163dc2c24234924917448b (patch)
tree0b3bfd642e08227460f2226658f705b44d4e12e1 /abstractmetabuilder.cpp
parent1785eb816851e19f06fb46124d02c30b12a3a739 (diff)
Remove ancient code commented out years ago.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Ara├║jo <renato.filho@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp144
1 files changed, 0 insertions, 144 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 3f2acbed..85cbc6e8 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -2350,150 +2350,6 @@ void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass* metaClass, const QS
}
}
-#if 0
-static void hide_functions(const AbstractMetaFunctionList &l)
-{
- foreach (AbstractMetaFunction *f, l) {
- FunctionModification mod;
- mod.signature = f->minimalSignature();
- mod.modifiers = FunctionModification::Private;
- ((ComplexTypeEntry *) f->implementingClass()->typeEntry())->addFunctionModification(mod);
- }
-}
-
-static void remove_function(AbstractMetaFunction *f)
-{
- FunctionModification mod;
- mod.removal = TypeSystem::All;
- mod.signature = f->minimalSignature();
- ((ComplexTypeEntry *) f->implementingClass()->typeEntry())->addFunctionModification(mod);
-}
-
-static AbstractMetaFunctionList filter_functions(const AbstractMetaFunctionList &lst, QSet<QString> *signatures)
-{
- AbstractMetaFunctionList functions;
- foreach (AbstractMetaFunction *f, lst) {
- QString signature = f->minimalSignature();
- int start = signature.indexOf(QLatin1Char('(')) + 1;
- int end = signature.lastIndexOf(QLatin1Char(')'));
- signature = signature.mid(start, end - start);
- if (signatures->contains(signature)) {
- remove_function(f);
- continue;
- }
- (*signatures) << signature;
- functions << f;
- }
- return functions;
-}
-
-void AbstractMetaBuilder::setupEquals(AbstractMetaClass */*cls*/)
-{
-// python have operator overloading, so we need all operators declared in C++.
- AbstractMetaFunctionList equals;
- AbstractMetaFunctionList nequals;
-
- QString op_equals = QLatin1String("operator_equal");
- QString opNequals = QLatin1String("operator_not_equal");
-
- AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::ClassImplements
- | AbstractMetaClass::NotRemovedFromTargetLang);
- foreach (AbstractMetaFunction *f, functions) {
- if (f->name() == op_equals)
- equals << f;
- else if (f->name() == opNequals)
- nequals << f;
- }
-
- if (equals.size() || nequals.size()) {
- if (!cls->hasHashFunction()) {
- ReportHandler::warning(QString::fromLatin1("Class '%1' has equals operators but no qHash() function")
- .arg(cls->name()));
- }
-
- hide_functions(equals);
- hide_functions(nequals);
-
- // We only need == if we have both == and !=, and one == for
- // each signature type, like QDateTime::==(QDate) and (QTime)
- // if such a thing exists...
- QSet<QString> func_signatures;
- cls->setEqualsFunctions(filter_functions(equals, &func_signatures));
- cls->setNotEqualsFunctions(filter_functions(nequals, &func_signatures));
- }
-}
-
-void AbstractMetaBuilder::setupComparable(AbstractMetaClass *cls)
-{
- AbstractMetaFunctionList greater;
- AbstractMetaFunctionList greaterEquals;
- AbstractMetaFunctionList less;
- AbstractMetaFunctionList lessEquals;
-
- QString op_greater = QLatin1String("operator_greater");
- QString opGreaterEq = QLatin1String("operator_greater_or_equal");
- QString op_less = QLatin1String("operator_less");
- QString opLessEq = QLatin1String("operator_less_or_equal");
-
- AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::ClassImplements
- | AbstractMetaClass::NotRemovedFromTargetLang);
- foreach (AbstractMetaFunction *f, functions) {
- if (f->name() == op_greater)
- greater << f;
- else if (f->name() == opGreaterEq)
- greaterEquals << f;
- else if (f->name() == op_less)
- less << f;
- else if (f->name() == opLessEq)
- lessEquals << f;
- }
-
- bool hasEquals = cls->equalsFunctions().size() || cls->notEqualsFunctions().size();
-
- // Conditions for comparable is:
- // >, ==, < - The basic case
- // >, == - Less than becomes else case
- // <, == - Greater than becomes else case
- // >=, <= - if (<= && >=) -> equal
- bool mightBeComparable = greater.size() || greaterEquals.size() || less.size() || lessEquals.size()
- || greaterEquals.size() == 1 || lessEquals.size() == 1;
-
- if (mightBeComparable) {
- QSet<QString> signatures;
-
- // We only hide the original functions if we are able to make a compareTo() method
- bool wasComparable = false;
-
- // The three upper cases, prefer the <, == approach
- if (hasEquals && (greater.size() || less.size())) {
- cls->setLessThanFunctions(filter_functions(less, &signatures));
- cls->setGreaterThanFunctions(filter_functions(greater, &signatures));
- filter_functions(greaterEquals, &signatures);
- filter_functions(lessEquals, &signatures);
- wasComparable = true;
- } else if (hasEquals && (greaterEquals.size() || lessEquals.size())) {
- cls->setLessThanEqFunctions(filter_functions(lessEquals, &signatures));
- cls->setGreaterThanEqFunctions(filter_functions(greaterEquals, &signatures));
- wasComparable = true;
- } else if (greaterEquals.size() == 1 || lessEquals.size() == 1) {
- cls->setGreaterThanEqFunctions(greaterEquals);
- cls->setLessThanEqFunctions(lessEquals);
- filter_functions(less, &signatures);
- filter_functions(greater, &signatures);
- wasComparable = true;
- }
-
- if (wasComparable) {
- hide_functions(greater);
- hide_functions(greaterEquals);
- hide_functions(less);
- hide_functions(lessEquals);
- }
- }
-
-}
-#endif
-
static AbstractMetaFunction* findCopyCtor(AbstractMetaClass* cls)
{
AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::Invisible);