Mercurial > projects > qtd
comparison generator/abstractmetalang.cpp @ 335:1e9092e20a67
merge signals branch into default
author | eldar1@eldar1-laptop |
---|---|
date | Sun, 07 Feb 2010 16:04:36 +0000 |
parents | c97e5d15bf95 |
children | 18bd68f586c6 |
comparison
equal
deleted
inserted
replaced
306:70f64e5b5942 | 335:1e9092e20a67 |
---|---|
40 ****************************************************************************/ | 40 ****************************************************************************/ |
41 | 41 |
42 #include "abstractmetalang.h" | 42 #include "abstractmetalang.h" |
43 #include "reporthandler.h" | 43 #include "reporthandler.h" |
44 #include "jumptable.h" | 44 #include "jumptable.h" |
45 #include <iostream> | |
45 | 46 |
46 /******************************************************************************* | 47 /******************************************************************************* |
47 * AbstractMetaType | 48 * AbstractMetaType |
48 */ | 49 */ |
49 AbstractMetaType *AbstractMetaType::copy() const | 50 AbstractMetaType *AbstractMetaType::copy() const |
223 returned += "int"; | 224 returned += "int"; |
224 } else { | 225 } else { |
225 returned += arg->type()->name().replace("[]", "_3").replace(".", "_"); | 226 returned += arg->type()->name().replace("[]", "_3").replace(".", "_"); |
226 } | 227 } |
227 } | 228 } |
229 | |
230 if(this->isConstant()) | |
231 returned += "_const"; | |
232 | |
228 return returned; | 233 return returned; |
229 } | 234 } |
230 | 235 |
231 bool AbstractMetaFunction::operator<(const AbstractMetaFunction &other) const | 236 bool AbstractMetaFunction::operator<(const AbstractMetaFunction &other) const |
232 { | 237 { |
249 } | 254 } |
250 | 255 |
251 // Attributes | 256 // Attributes |
252 if (attributes() == other->attributes()) { | 257 if (attributes() == other->attributes()) { |
253 result |= EqualAttributes; | 258 result |= EqualAttributes; |
259 } | |
260 | |
261 // Constness | |
262 if (isConstant() == other->isConstant()) { | |
263 result |= EqualConstness; | |
254 } | 264 } |
255 | 265 |
256 // Compare types | 266 // Compare types |
257 AbstractMetaType *t = type(); | 267 AbstractMetaType *t = type(); |
258 AbstractMetaType *ot = other->type(); | 268 AbstractMetaType *ot = other->type(); |
666 } | 676 } |
667 | 677 |
668 return QString(); | 678 return QString(); |
669 } | 679 } |
670 | 680 |
671 QString AbstractMetaFunction::minimalSignature() const | 681 QString AbstractMetaFunction::minimalSignature(int reduce) const |
672 { | 682 { |
673 if (!m_cached_minimal_signature.isEmpty()) | 683 if (!m_cached_minimal_signature.isEmpty() && !reduce) |
674 return m_cached_minimal_signature; | 684 return m_cached_minimal_signature; |
675 | 685 |
676 QString minimalSignature = originalName() + "("; | 686 QString minimalSignature = originalName() + "("; |
677 AbstractMetaArgumentList arguments = this->arguments(); | 687 AbstractMetaArgumentList arguments = this->arguments(); |
678 | 688 int argsCount = arguments.count() - reduce; |
679 for (int i=0; i<arguments.count(); ++i) { | 689 for (int i=0; i<argsCount; ++i) { |
680 AbstractMetaType *t = arguments.at(i)->type(); | 690 AbstractMetaType *t = arguments.at(i)->type(); |
681 | 691 |
682 if (i > 0) | 692 if (i > 0) |
683 minimalSignature += ","; | 693 minimalSignature += ","; |
684 | 694 |
687 minimalSignature += ")"; | 697 minimalSignature += ")"; |
688 if (isConstant()) | 698 if (isConstant()) |
689 minimalSignature += "const"; | 699 minimalSignature += "const"; |
690 | 700 |
691 minimalSignature = QMetaObject::normalizedSignature(minimalSignature.toLocal8Bit().constData()); | 701 minimalSignature = QMetaObject::normalizedSignature(minimalSignature.toLocal8Bit().constData()); |
692 m_cached_minimal_signature = minimalSignature; | 702 if(!reduce) |
703 m_cached_minimal_signature = minimalSignature; | |
693 | 704 |
694 return minimalSignature; | 705 return minimalSignature; |
695 } | 706 } |
696 | 707 |
697 FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass *implementor) const | 708 FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass *implementor) const |
1190 return m_property_specs.at(i); | 1201 return m_property_specs.at(i); |
1191 } | 1202 } |
1192 return 0; | 1203 return 0; |
1193 } | 1204 } |
1194 | 1205 |
1195 | 1206 AbstractMetaFunction* AbstractMetaClass::copyConstructor() const |
1207 { | |
1208 AbstractMetaFunctionList ctors = queryFunctions(Constructors); | |
1209 for(int i = 0; i < ctors.size(); i++) | |
1210 { | |
1211 AbstractMetaFunction *ctor = ctors.at(i); | |
1212 if (ctor->arguments().size() > 0) | |
1213 if(ctor->arguments().at(0)->type()->typeEntry() == typeEntry()) | |
1214 return ctor; | |
1215 } | |
1216 | |
1217 return NULL; | |
1218 } | |
1196 | 1219 |
1197 static bool functions_contains(const AbstractMetaFunctionList &l, const AbstractMetaFunction *func) | 1220 static bool functions_contains(const AbstractMetaFunctionList &l, const AbstractMetaFunction *func) |
1198 { | 1221 { |
1199 foreach (const AbstractMetaFunction *f, l) { | 1222 foreach (const AbstractMetaFunction *f, l) { |
1200 if ((f->compareTo(func) & AbstractMetaFunction::PrettySimilar) == AbstractMetaFunction::PrettySimilar) | 1223 if ((f->compareTo(func) & AbstractMetaFunction::PrettySimilar) == AbstractMetaFunction::PrettySimilar) |
1889 { | 1912 { |
1890 QString minimalSignature; | 1913 QString minimalSignature; |
1891 if (isConstant()) | 1914 if (isConstant()) |
1892 minimalSignature += "const "; | 1915 minimalSignature += "const "; |
1893 minimalSignature += typeEntry()->qualifiedCppName(); | 1916 minimalSignature += typeEntry()->qualifiedCppName(); |
1894 if (hasInstantiations()) { | 1917 if (hasInstantiations() && |
1918 (static_cast<const ContainerTypeEntry *>(typeEntry()))->type() != ContainerTypeEntry::StringListContainer) | |
1919 { | |
1895 QList<AbstractMetaType *> instantiations = this->instantiations(); | 1920 QList<AbstractMetaType *> instantiations = this->instantiations(); |
1896 minimalSignature += "<"; | 1921 minimalSignature += "<"; |
1897 for (int i=0;i<instantiations.size();++i) { | 1922 for (int i=0;i<instantiations.size();++i) |
1923 { | |
1898 if (i > 0) | 1924 if (i > 0) |
1899 minimalSignature += ","; | 1925 minimalSignature += ","; |
1900 minimalSignature += instantiations.at(i)->minimalSignature(); | 1926 minimalSignature += instantiations.at(i)->minimalSignature(); |
1901 } | 1927 } |
1902 minimalSignature += ">"; | 1928 minimalSignature += ">"; |