aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetalang.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-03-26 18:36:24 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:09:58 -0300
commit6b0973be81abe9c67f49336d92370e758b2a44e1 (patch)
tree77fa1291f0c08a087cc66c495ca7a01d56ef6e52 /abstractmetalang.cpp
parent4b275c5317256b66596ed289332f1df4d372b9e5 (diff)
Adds convenience methods regarding copy constructors to AbstractMetaClass.
Diffstat (limited to 'abstractmetalang.cpp')
-rw-r--r--abstractmetalang.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index 66610171..c7d0adf4 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -1552,6 +1552,24 @@ bool AbstractMetaClass::hasConstructors() const
return queryFunctions(Constructors).size();
}
+bool AbstractMetaClass::hasCopyConstructor() const
+{
+ foreach (const AbstractMetaFunction* ctor, queryFunctions(Constructors)) {
+ if (ctor->isCopyConstructor())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasPrivateCopyConstructor() const
+{
+ foreach (const AbstractMetaFunction* ctor, queryFunctions(Constructors)) {
+ if (ctor->isCopyConstructor() && ctor->isPrivate())
+ return true;
+ }
+ return false;
+}
+
void AbstractMetaClass::addDefaultConstructor()
{
AbstractMetaFunction *f = new AbstractMetaFunction;
@@ -1571,6 +1589,38 @@ void AbstractMetaClass::addDefaultConstructor()
addFunction(f);
}
+void AbstractMetaClass::addDefaultCopyConstructor(bool isPrivate)
+{
+ AbstractMetaFunction* f = new AbstractMetaFunction;
+ f->setName(name());
+ f->setOwnerClass(this);
+ f->setFunctionType(AbstractMetaFunction::ConstructorFunction);
+ f->setDeclaringClass(this);
+
+ AbstractMetaType* argType = new AbstractMetaType;
+ argType->setTypeEntry(typeEntry());
+ argType->setReference(true);
+ argType->setConstant(true);
+ argType->setTypeUsagePattern(AbstractMetaType::ValuePattern);
+
+ AbstractMetaArgument* arg = new AbstractMetaArgument;
+ arg->setType(argType);
+ arg->setName(name());
+ f->addArgument(arg);
+
+ uint attr = AbstractMetaAttributes::Native;
+ attr |= AbstractMetaAttributes::Final;
+ if (isPrivate)
+ attr |= AbstractMetaAttributes::Private;
+ else
+ attr |= AbstractMetaAttributes::Public;
+ f->setAttributes(attr);
+ f->setImplementingClass(this);
+ f->setOriginalAttributes(f->attributes());
+
+ addFunction(f);
+}
+
bool AbstractMetaClass::hasFunction(const AbstractMetaFunction *f) const
{
return functions_contains(m_functions, f);