summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/Gen.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-06-19 11:25:17 -0700
committerMark Spruiell <mes@zeroc.com>2007-06-19 11:25:17 -0700
commitddcfe70b4f05fb00e466486fc19076147f79298d (patch)
treeacfa4428263b22b3f9226d04a3fe8f910bd21bdd /cpp/src/slice2cpp/Gen.cpp
parentFor UDP multicast bind to the multicast address rather than 0.0.0.0 unless on... (diff)
downloadice-ddcfe70b4f05fb00e466486fc19076147f79298d.tar.bz2
ice-ddcfe70b4f05fb00e466486fc19076147f79298d.tar.xz
ice-ddcfe70b4f05fb00e466486fc19076147f79298d.zip
bug 2245 - adding support for protected class data members
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 539366963ed..dd7ccf7e8d3 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -3345,6 +3345,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
}
}
+ bool inProtected = false;
+
if(!p->isAbstract())
{
//
@@ -3359,6 +3361,42 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
H << sp << nl << "friend class " << p->name() << "__staticInit;";
}
+
+ inProtected = true;
+ }
+
+ //
+ // Emit data members. Access visibility may be specified by metadata.
+ //
+ DataMemberList dataMembers = p->dataMembers();
+ DataMemberList::const_iterator q;
+ bool prot = p->hasMetaData("protected");
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ if(prot || (*q)->hasMetaData("protected"))
+ {
+ if(!inProtected)
+ {
+ H.dec();
+ H << sp << nl << "protected:";
+ H.inc();
+ inProtected = true;
+ }
+ }
+ else
+ {
+ if(inProtected)
+ {
+ H.dec();
+ H << sp << nl << "public:";
+ H.inc();
+ inProtected = false;
+ }
+ }
+
+ string name = fixKwd((*q)->name());
+ string s = typeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ H << sp << nl << s << ' ' << name << ';';
}
H << eb << ';';
@@ -3369,6 +3407,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
// We need an instance here to trigger initialization if the implementation is in a shared library.
// But we do this only once per source file, because a single instance is sufficient to initialize
// all of the globals in a shared library.
+ //
// For a Slice class Foo, we instantiate a dummy class Foo__staticInit instead of using a static
// Foo instance directly because Foo has a protected destructor.
//
@@ -3678,14 +3717,6 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
}
void
-Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p)
-{
- string name = fixKwd(p->name());
- string s = typeToString(p->type(), _useWstring, p->getMetaData());
- H << nl << s << ' ' << name << ';';
-}
-
-void
Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
{
string scoped = fixKwd(p->scoped());