diff options
author | Mark Spruiell <mes@zeroc.com> | 2007-06-19 11:25:17 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2007-06-19 11:25:17 -0700 |
commit | ddcfe70b4f05fb00e466486fc19076147f79298d (patch) | |
tree | acfa4428263b22b3f9226d04a3fe8f910bd21bdd /cpp/src/slice2cpp | |
parent | For UDP multicast bind to the multicast address rather than 0.0.0.0 unless on... (diff) | |
download | ice-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')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 47 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 1 |
2 files changed, 39 insertions, 9 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()); diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 11ae44bf575..221ccfd68c4 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -260,7 +260,6 @@ private: virtual bool visitExceptionStart(const ExceptionPtr&); virtual bool visitStructStart(const StructPtr&); virtual void visitOperation(const OperationPtr&); - virtual void visitDataMember(const DataMemberPtr&); private: |