diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 308 | ||||
-rw-r--r-- | cpp/src/slice2cpp/GenUtil.cpp | 33 | ||||
-rw-r--r-- | cpp/src/slice2cpp/GenUtil.h | 20 | ||||
-rw-r--r-- | cpp/src/slice2docbook/Gen.cpp | 53 | ||||
-rw-r--r-- | cpp/src/slice2docbook/GenUtil.cpp | 15 |
5 files changed, 163 insertions, 266 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 398dcc8cfbe..1f4997233fd 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -68,16 +68,15 @@ Slice::Gen::Gen(const string& name, H.open(fileH.c_str()); if(!H) { - cerr << name << ": can't open `" << fileH << "' for writing: " - << strerror(errno) << endl; + cerr << name << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl; return; } C.open(fileC.c_str()); if(!C) { - cerr << name << ": can't open `" << fileC << "' for writing: " - << strerror(errno) << endl; + cerr << name << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl; + return; } printHeader(H); @@ -226,8 +225,7 @@ Slice::Gen::printHeader(Output& out) out << '\n'; } -Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -275,13 +273,11 @@ Slice::Gen::TypesVisitor::visitVector(const VectorPtr& p) H << sp; H << nl << "class __U__" << name << " { };"; - H << nl << "void" << _dllExport << " __write(::IceInternal::Stream*, const " - << name << "&, __U__" << name << ");"; - H << nl << "void" << _dllExport << " __read(::IceInternal::Stream*, " - << name << "&, __U__" << name << ");"; + H << nl << "void" << _dllExport << " __write(::IceInternal::Stream*, const " << name << "&, __U__" << name + << ");"; + H << nl << "void" << _dllExport << " __read(::IceInternal::Stream*, " << name << "&, __U__" << name << ");"; C << sp; - C << nl << "void" << nl << scope - << "::__write(::IceInternal::Stream* __os, const " << scoped << "& v, ::" + C << nl << "void" << nl << scope << "::__write(::IceInternal::Stream* __os, const " << scoped << "& v, ::" << scope << "::__U__" << name << ')'; C << sb; C << nl << "__os -> write(::Ice::Int(v.size()));"; @@ -292,9 +288,8 @@ Slice::Gen::TypesVisitor::visitVector(const VectorPtr& p) C.dec(); C << eb; C << sp; - C << nl << "void" << nl << scope - << "::__read(::IceInternal::Stream* __is, " << scoped << "& v, ::" - << scope << "::__U__" << name << ')'; + C << nl << "void" << nl << scope << "::__read(::IceInternal::Stream* __is, " << scoped << "& v, ::" << scope + << "::__U__" << name << ')'; C << sb; C << nl << "::Ice::Int sz;"; C << nl << "__is -> read(sz);"; @@ -347,8 +342,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) H << nl << "void" << _dllExport << " __write(::IceInternal::Stream*, " << name << ");"; H << nl << "void" << _dllExport << " __read(::IceInternal::Stream*, " << name << "&);"; C << sp; - C << nl << "void" << nl << scope - << "::__write(::IceInternal::Stream* __os, " << scoped << " v)"; + C << nl << "void" << nl << scope << "::__write(::IceInternal::Stream* __os, " << scoped << " v)"; C << sb; if(sz <= numeric_limits<Ice::Byte>::max()) C << nl << "__os -> write(static_cast< ::Ice::Byte>(v));"; @@ -360,8 +354,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) C << nl << "__os -> write(static_cast< ::Ice::Long>(v));"; C << eb; C << sp; - C << nl << "void" << nl << scope << "::__read(::IceInternal::Stream* __is, " - << scoped << "& v)"; + C << nl << "void" << nl << scope << "::__read(::IceInternal::Stream* __is, " << scoped << "& v)"; C << sb; if(sz <= numeric_limits<Ice::Byte>::max()) { @@ -399,8 +392,7 @@ Slice::Gen::TypesVisitor::visitNative(const NativePtr& p) H << nl << "typedef ::IceNative::" << name << ' ' << name << ';'; } -Slice::Gen::ProxyDeclVisitor::ProxyDeclVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::ProxyDeclVisitor::ProxyDeclVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -459,8 +451,7 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p) H << nl << "class " << name << ';'; } -Slice::Gen::ProxyVisitor::ProxyVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::ProxyVisitor::ProxyVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -560,14 +551,13 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) H << nl << "private: "; H.inc(); H << sp; - H << nl << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> " - << "__createDelegateM();"; + H << nl << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();"; H << eb << ';'; C << sp; - C << nl << "::IceInternal::Handle< ::IceDelegateM::Ice::Object>" - << nl << "IceProxy" << scoped << "::__createDelegateM()" << sb; - C << nl << "return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>" - << "(new ::IceDelegateM" << scoped << ");"; + C << nl << "::IceInternal::Handle< ::IceDelegateM::Ice::Object>"; + C << nl << "IceProxy" << scoped << "::__createDelegateM()"; + C << sb; + C << nl << "return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM" << scoped << ");"; C << eb; } @@ -637,8 +627,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << retS << ' ' << name << params << ';'; C << sp; - C << nl << retS << nl << "IceProxy" << scoped << paramsDecl - << sb; + C << nl << retS << nl << "IceProxy" << scoped << paramsDecl; + C << sb; C << nl << "::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase = __getDelegate();"; C << nl << "::IceDelegate" << scope << "* __del = dynamic_cast< ::IceDelegate" << scope << "*>(__delBase.get());"; C << nl; @@ -648,8 +638,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << eb; } -Slice::Gen::DelegateVisitor::DelegateVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::DelegateVisitor::DelegateVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -791,8 +780,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) H << nl << "virtual " << retS << ' ' << name << params << " = 0;"; } -Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -947,8 +935,8 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << "virtual " << retS << ' ' << name << params << ';'; C << sp; - C << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl - << sb; + C << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl; + C << sb; C << nl << "::IceInternal::Outgoing __out(__emitter(), __reference());"; if(ret || !outParams.empty() || !throws.empty()) C << nl << "::IceInternal::Stream* __is = __out.is();"; @@ -967,7 +955,6 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) Ice::Int cnt = 0; for(r = throws.begin(); r != throws.end(); ++r) { - C.dec(); C << nl << "case " << cnt++ << ':'; C << sb; TypeStringList li; @@ -979,18 +966,15 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) else C << nl << "throw __ex;"; C << eb; - C.inc(); } C << eb; - C << nl - << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);"; + C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);"; C << eb; } else { C.inc(); - C << nl - << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);"; + C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);"; C.dec(); } writeAllocateCode(C, TypeStringList(), ret); @@ -1000,8 +984,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << eb; } -Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -1037,8 +1020,7 @@ Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p) H << nl << "class " << name << ';'; } -Slice::Gen::ObjectVisitor::ObjectVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::ObjectVisitor::ObjectVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -1104,24 +1086,19 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << "operator " << name << "Ptr() const;"; H << nl << name << "* operator->() const;"; H << eb << ';'; - C << sp << nl << scoped.substr(2) << "PtrE::" << name << "PtrE(const " - << name << "PtrE& p)"; + C << sp << nl << scoped.substr(2) << "PtrE::" << name << "PtrE(const " << name << "PtrE& p)"; C << sb; C << nl << "_ptr = p._ptr;"; C << eb; - C << sp << nl << scoped.substr(2) << "PtrE::" << name << "PtrE(const " - << scoped << "Ptr& p)"; + C << sp << nl << scoped.substr(2) << "PtrE::" << name << "PtrE(const " << scoped << "Ptr& p)"; C << sb; C << nl << "_ptr = p;"; C << eb; - C << sp << nl << scoped.substr(2) << "PtrE::operator " << scoped - << "Ptr() const"; + C << sp << nl << scoped.substr(2) << "PtrE::operator " << scoped << "Ptr() const"; C << sb; - C << nl << "return " << scoped << "Ptr(dynamic_cast< " << scoped - << "*>(_ptr.get()));"; + C << nl << "return " << scoped << "Ptr(dynamic_cast< " << scoped << "*>(_ptr.get()));"; C << eb; - C << sp << nl << scoped << '*' << nl << scoped.substr(2) - << "PtrE::operator->() const"; + C << sp << nl << scoped << '*' << nl << scoped.substr(2) << "PtrE::operator->() const"; C << sb; C << nl << "return dynamic_cast< " << scoped << "*>(_ptr.get());"; C << eb; @@ -1138,8 +1115,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList::iterator q = bases.begin(); while(q != bases.end()) { - H << "virtual public " << (*q) -> scoped() - << "PrxE"; + H << "virtual public " << (*q) -> scoped() << "PrxE"; if(++q != bases.end()) H << ',' << nl; } @@ -1156,27 +1132,22 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << "operator " << name << "Prx() const;"; H << nl << "::IceProxy" << scoped << "* operator->() const;"; H << eb << ';'; - C << sp << nl << scoped.substr(2) << "PrxE::" << name - << "PrxE(const " << name << "PrxE& p)"; + C << sp << nl << scoped.substr(2) << "PrxE::" << name << "PrxE(const " << name << "PrxE& p)"; C << sb; C << nl << "_prx = p._prx;"; C << eb; - C << sp << nl << scoped.substr(2) << "PrxE::" << name - << "PrxE(const " << scoped << "Prx& p)"; + C << sp << nl << scoped.substr(2) << "PrxE::" << name << "PrxE(const " << scoped << "Prx& p)"; C << sb; C << nl << "_prx = p;"; C << eb; - C << sp << nl << scoped.substr(2) << "PrxE::operator " << scoped - << "Prx() const"; + C << sp << nl << scoped.substr(2) << "PrxE::operator " << scoped << "Prx() const"; C << sb; - C << nl << "return " << scoped << "Prx(dynamic_cast< ::IceProxy" - << scoped << "*>(_prx.get()));"; + C << nl << "return " << scoped << "Prx(dynamic_cast< ::IceProxy" << scoped << "*>(_prx.get()));"; C << eb; - C << sp << nl << "::IceProxy" << scoped << '*' << nl - << scoped.substr(2) << "PrxE::operator->() const"; + C << sp << nl << "::IceProxy" << scoped << '*'; + C << nl << scoped.substr(2) << "PrxE::operator->() const"; C << sb; - C << nl << "return dynamic_cast< ::IceProxy" << scoped - << "*>(_prx.get());"; + C << nl << "return dynamic_cast< ::IceProxy" << scoped << "*>(_prx.get());"; C << eb; } @@ -1263,8 +1234,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << sp; H << nl << "virtual const std::string* _classIds();"; C << sp; - C << nl << "std::string " << scoped.substr(2) - << "::__ids[" << ids.size() << "] ="; + C << nl << "std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] ="; C << sb; q = ids.begin(); while(q != ids.end()) @@ -1275,8 +1245,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) } C << eb << ';'; C << sp; - C << nl << "std::string " << scoped.substr(2) - << "::__classIds[" << classIds.size() << "] ="; + C << nl << "std::string " << scoped.substr(2) << "::__classIds[" << classIds.size() << "] ="; C << sb; q = classIds.begin(); while(q != classIds.end()) @@ -1287,18 +1256,15 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) } C << eb << ';'; C << sp; - C << nl << "bool" << nl << scoped.substr(2) - << "::_isA(const std::string& s)"; + C << nl << "bool" << nl << scoped.substr(2) << "::_isA(const std::string& s)"; C << sb; C << nl << "std::string* b = __ids;"; C << nl << "std::string* e = __ids + " << ids.size() << ';'; - C << nl << "std::pair<std::string*, std::string*> r = " - << "std::equal_range(b, e, s);"; + C << nl << "std::pair<std::string*, std::string*> r = std::equal_range(b, e, s);"; C << nl << "return r.first != r.second;"; C << eb; C << sp; - C << nl << "const std::string*" << nl << scoped.substr(2) - << "::_classIds()"; + C << nl << "const std::string*" << nl << scoped.substr(2) << "::_classIds()"; C << sb; C << nl << "return __classIds;"; C << eb; @@ -1316,65 +1282,65 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) if(!bases.empty() && !bases.front() -> isInterface()) base = bases.front(); - if(!p -> isLocal() && !p -> operations().empty()) + if(!p -> isLocal()) { OperationList allOperations = p -> allOperations(); - StringList allOpNames; - transform(allOperations.begin(), allOperations.end(), - back_inserter(allOpNames), - ::Ice::memFun(&Operation::name)); - StringList other; - other.push_back("_isA"); - //other.sort(); - allOpNames.merge(other); - allOpNames.unique(); - - StringList::iterator q; - - H << sp; - H << nl << "static std::string __names[" << allOpNames.size() << "];"; - H << nl << "virtual ::IceInternal::DispatchStatus " - << "__dispatch(::IceInternal::Incoming&, const std::string&);"; - C << sp; - C << nl << "std::string " << scoped.substr(2) << "::__names[" - << allOpNames.size() << "] ="; - C << sb; - q = allOpNames.begin(); - while(q != allOpNames.end()) - { - C << nl << '"' << *q << '"'; - if(++q != allOpNames.end()) - C << ','; - } - C << eb << ';'; - C << sp; - C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2) - << "::__dispatch(::IceInternal::Incoming& in, const std::string& s)"; - C << sb; - C << nl << "std::string* b = __names;"; - C << nl << "std::string* e = __names + " << allOpNames.size() << ';'; - C << nl << "std::pair<std::string*, std::string*> r = " - << "std::equal_range(b, e, s);"; - C << nl << "if(r.first == r.second)"; - C.inc(); - C << nl << "return ::IceInternal::DispatchOperationNotExist;"; - C.dec(); - C << sp; - C << nl << "switch(r.first - __names)"; - C << sb; - int i = 0; - for(q = allOpNames.begin(); q != allOpNames.end(); ++q) + if(!p -> allOperations().empty()) { - C.dec(); - C << nl << "case " << i++ << ':'; + StringList allOpNames; + transform(allOperations.begin(), allOperations.end(), back_inserter(allOpNames), + ::Ice::memFun(&Operation::name)); + StringList other; + other.push_back("_isA"); + //other.sort(); + allOpNames.merge(other); + allOpNames.unique(); + + StringList::iterator q; + + H << sp; + H << nl << "static std::string __names[" << allOpNames.size() << "];"; + H << nl << "virtual ::IceInternal::DispatchStatus " + << "__dispatch(::IceInternal::Incoming&, const std::string&);"; + C << sp; + C << nl << "std::string " << scoped.substr(2) << "::__names[" << allOpNames.size() << "] ="; + C << sb; + q = allOpNames.begin(); + while(q != allOpNames.end()) + { + C << nl << '"' << *q << '"'; + if(++q != allOpNames.end()) + C << ','; + } + C << eb << ';'; + C << sp; + C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2) + << "::__dispatch(::IceInternal::Incoming& in, const std::string& s)"; + C << sb; + C << nl << "std::string* b = __names;"; + C << nl << "std::string* e = __names + " << allOpNames.size() << ';'; + C << nl << "std::pair<std::string*, std::string*> r = std::equal_range(b, e, s);"; + C << nl << "if(r.first == r.second)"; C.inc(); - C << nl << "return ___" << *q << "(in);"; + C << nl << "return ::IceInternal::DispatchOperationNotExist;"; + C.dec(); + C << sp; + C << nl << "switch(r.first - __names)"; + C << sb; + int i = 0; + for(q = allOpNames.begin(); q != allOpNames.end(); ++q) + { + C << nl << "case " << i++ << ':'; + C << sb; + C << nl << "return ___" << *q << "(in);"; + C << eb; + } + C << eb; + C << sp; + C << nl << "assert(false);"; + C << nl << "return ::IceInternal::DispatchOperationNotExist;"; + C << eb; } - C << eb; - C << sp; - C << nl << "assert(false);"; - C << nl << "return ::IceInternal::DispatchOperationNotExist;"; - C << eb; } H << sp; H << nl << "virtual void __write(::IceInternal::Stream*);"; @@ -1386,8 +1352,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) for(q = dataMembers.begin(); q != dataMembers.end(); ++q) memberList.push_back(make_pair((*q) -> type(), (*q) -> name())); C << sp; - C << nl << "void" << nl << scoped.substr(2) - << "::__write(::IceInternal::Stream* __os)"; + C << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::Stream* __os)"; C << sb; C << nl << "__os -> startWriteEncaps();"; writeMarshalCode(C, memberList, 0); @@ -1408,8 +1373,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) } C << eb; C << sp; - C << nl << "void" << nl << scoped.substr(2) - << "::__read(::IceInternal::Stream* __is)"; + C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::Stream* __is)"; C << sb; C << nl << "__is -> startReadEncaps();"; writeUnmarshalCode(C, memberList, 0); @@ -1496,11 +1460,10 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) if(!cl -> isLocal()) { - H << nl << "::IceInternal::DispatchStatus ___" << name - << "(::IceInternal::Incoming&);"; + H << nl << "::IceInternal::DispatchStatus ___" << name << "(::IceInternal::Incoming&);"; C << sp; - C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) - << "::___" << name << "(::IceInternal::Incoming& __in)"; + C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "::___" << name + << "(::IceInternal::Incoming& __in)"; C << sb; if(!inParams.empty()) C << nl << "::IceInternal::Stream* __is = __in.is();"; @@ -1528,8 +1491,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << nl << "catch(" << exceptionTypeToString(*r) << " __ex)"; C << sb; C << nl << "__os -> write(" << cnt++ << ");"; - if(ClassDeclPtr::dynamicCast(*r) || - ProxyPtr::dynamicCast(*r)) + if(ClassDeclPtr::dynamicCast(*r) || ProxyPtr::dynamicCast(*r)) { string s = "static_cast< "; s += inputTypeToString(*r); @@ -1557,8 +1519,7 @@ Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p) H << nl << s << ' ' << name << ';'; } -Slice::Gen::IceVisitor::IceVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::IceVisitor::IceVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -1594,17 +1555,11 @@ Slice::Gen::IceVisitor::visitClassDecl(const ClassDeclPtr& p) if(!p -> isLocal()) { H << sp; - H << nl << "void" << _dllExport << " incRef(::IceProxy" << scoped - << "*);"; - H << nl << "void" << _dllExport << " decRef(::IceProxy" << scoped - << "*);"; + H << nl << "void" << _dllExport << " incRef(::IceProxy" << scoped << "*);"; + H << nl << "void" << _dllExport << " decRef(::IceProxy" << scoped << "*);"; H << sp; - H << nl << "void" << _dllExport - << " checkedCast(::IceProxy::Ice::Object*, ::IceProxy" - << scoped << "*&);"; - H << nl << "void" << _dllExport - << " uncheckedCast(::IceProxy::Ice::Object*, ::IceProxy" - << scoped << "*&);"; + H << nl << "void" << _dllExport << " checkedCast(::IceProxy::Ice::Object*, ::IceProxy" << scoped << "*&);"; + H << nl << "void" << _dllExport << " uncheckedCast(::IceProxy::Ice::Object*, ::IceProxy" << scoped << "*&);"; } } @@ -1620,16 +1575,12 @@ Slice::Gen::IceVisitor::visitClassDefStart(const ClassDefPtr& p) if(!p -> isLocal()) { C << sp; - C << nl << "void IceInternal::incRef(::IceProxy" << scoped - << "* p) { p -> __incRef(); }"; - C << nl << "void IceInternal::decRef(::IceProxy" << scoped - << "* p) { p -> __decRef(); }"; + C << nl << "void IceInternal::incRef(::IceProxy" << scoped << "* p) { p -> __incRef(); }"; + C << nl << "void IceInternal::decRef(::IceProxy" << scoped << "* p) { p -> __decRef(); }"; C << sp; - C << nl << "void IceInternal::checkedCast(::IceProxy::Ice::Object* b, " - << "::IceProxy" << scoped << "*& d)"; + C << nl << "void IceInternal::checkedCast(::IceProxy::Ice::Object* b, ::IceProxy" << scoped << "*& d)"; C << sb; - C << nl << "d = dynamic_cast< ::IceProxy" << scoped - << "*>(b);"; + C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b);"; C << nl << "if(!d && b -> _isA(\"" << scoped << "\"))"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ';'; @@ -1637,11 +1588,9 @@ Slice::Gen::IceVisitor::visitClassDefStart(const ClassDefPtr& p) C << eb; C << eb; C << sp; - C << nl << "void IceInternal::uncheckedCast(::IceProxy::Ice::Object* b, " - << "::IceProxy" << scoped << "*& d)"; + C << nl << "void IceInternal::uncheckedCast(::IceProxy::Ice::Object* b, ::IceProxy" << scoped << "*& d)"; C << sb; - C << nl << "d = dynamic_cast< ::IceProxy" << scoped - << "*>(b);"; + C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b);"; C << nl << "if(!d)"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ';'; @@ -1651,8 +1600,7 @@ Slice::Gen::IceVisitor::visitClassDefStart(const ClassDefPtr& p) } } -Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, - const string& dllExport) +Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { } @@ -1686,17 +1634,13 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) string scoped = p -> scoped(); H << sp; - H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name - << "Ptr;"; + H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name << "Ptr;"; if(!p -> isLocal()) { - H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped - << "> " << name << "Prx;"; + H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;"; H << sp; - H << nl << "void" << _dllExport << " __write(::IceInternal::Stream*, const " - << name << "Prx&);"; - H << nl << "void" << _dllExport << " __read(::IceInternal::Stream*, " - << name << "Prx&);"; + H << nl << "void" << _dllExport << " __write(::IceInternal::Stream*, const " << name << "Prx&);"; + H << nl << "void" << _dllExport << " __read(::IceInternal::Stream*, " << name << "Prx&);"; } } @@ -1712,15 +1656,13 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) scope.erase(0, 2); C << sp; - C << nl << "void" << nl << scope - << "::__write(::IceInternal::Stream* __os, const " << scoped << "Prx& v)"; + C << nl << "void" << nl << scope << "::__write(::IceInternal::Stream* __os, const " << scoped << "Prx& v)"; C << sb; // TODO: Should be ::Ice::__write C << nl << "::IceInternal::write(__os, ::Ice::ObjectPrx(v));"; C << eb; C << sp; - C << nl << "void" << nl << scope - << "::__read(::IceInternal::Stream* __is, " << scoped << "Prx& v)"; + C << nl << "void" << nl << scope << "::__read(::IceInternal::Stream* __is, " << scoped << "Prx& v)"; C << sb; C << nl << "::Ice::ObjectPrx proxy;"; // TODO: Should be ::Ice::__read diff --git a/cpp/src/slice2cpp/GenUtil.cpp b/cpp/src/slice2cpp/GenUtil.cpp index e6b37e6a27c..ea9107d04b1 100644 --- a/cpp/src/slice2cpp/GenUtil.cpp +++ b/cpp/src/slice2cpp/GenUtil.cpp @@ -195,8 +195,7 @@ Slice::exceptionTypeToString(const TypePtr& type) } void -Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, - const string& param, bool marshal) +Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal) { const char* func = marshal ? "write(" : "read("; const char* stream = marshal ? "__os" : "__is"; @@ -219,8 +218,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, else { out << nl << "::Ice::ObjectPtr __obj;"; - out << nl << stream << " -> read(__obj, " << cl -> scoped() - << "::__classIds[0]);"; + out << nl << stream << " -> read(__obj, " << cl -> scoped() << "::__classIds[0]);"; out << nl << "if(!__obj)"; ClassDefPtr def = cl -> definition(); if(def && !def -> isAbstract()) @@ -233,16 +231,13 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, else { out.inc(); - out << nl - << "throw ::Ice::NoFactoryException(__FILE__, __LINE__);"; + out << nl << "throw ::Ice::NoFactoryException(__FILE__, __LINE__);"; out.dec(); } - out << nl << param << " = " << cl -> scoped() - << "Ptr::dynamicCast(__obj);"; + out << nl << param << " = " << cl -> scoped() << "Ptr::dynamicCast(__obj);"; out << nl << "if(!" << param << ')'; out.inc(); - out << nl - << "throw ::Ice::ValueUnmarshalException(__FILE__, __LINE__);"; + out << nl << "throw ::Ice::ValueUnmarshalException(__FILE__, __LINE__);"; out.dec(); } out << eb; @@ -256,8 +251,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, if(BuiltinPtr::dynamicCast(vec -> type())) out << nl << stream << " -> " << func << param << ");"; else - out << nl << vec -> scope() << "::__" << func << stream\ - << ", " << param << ", " << vec -> scope() + out << nl << vec -> scope() << "::__" << func << stream << ", " << param << ", " << vec -> scope() << "::__U__" << vec -> name() << "());"; return; } @@ -273,14 +267,11 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, constructed = proxy -> _class(); } - out << nl << constructed -> scope() << "::__" << func << stream << ", " - << param << ");"; + out << nl << constructed -> scope() << "::__" << func << stream << ", " << param << ");"; } void -Slice::writeMarshalCode(Output& out, - const list<pair<TypePtr, string> >& params, - const TypePtr& ret) +Slice::writeMarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { list<pair<TypePtr, string> >::const_iterator p; for(p = params.begin(); p != params.end(); ++p) @@ -290,9 +281,7 @@ Slice::writeMarshalCode(Output& out, } void -Slice::writeUnmarshalCode(Output& out, - const list<pair<TypePtr, string> >& params, - const TypePtr& ret) +Slice::writeUnmarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { list<pair<TypePtr, string> >::const_iterator p; for(p = params.begin(); p != params.end(); ++p) @@ -302,9 +291,7 @@ Slice::writeUnmarshalCode(Output& out, } void -Slice::writeAllocateCode(Output& out, - const list<pair<TypePtr, string> >& params, - const TypePtr& ret) +Slice::writeAllocateCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { list<pair<TypePtr, string> > ps = params; if(ret) diff --git a/cpp/src/slice2cpp/GenUtil.h b/cpp/src/slice2cpp/GenUtil.h index 7dd9a6404b3..48646d52b1a 100644 --- a/cpp/src/slice2cpp/GenUtil.h +++ b/cpp/src/slice2cpp/GenUtil.h @@ -23,22 +23,10 @@ std::string inputTypeToString(const TypePtr&); std::string outputTypeToString(const TypePtr&); std::string exceptionTypeToString(const TypePtr&); -void writeMarshalUnmarshalCode(Output&, - const TypePtr&, - const std::string&, - bool); - -void writeMarshalCode(Output&, - const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); - -void writeUnmarshalCode(Output&, - const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); - -void writeAllocateCode(Output&, - const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); +void writeMarshalUnmarshalCode(Output&, const TypePtr&, const std::string&, bool); +void writeMarshalCode(Output&, const std::list<std::pair<TypePtr, std::string> >&, const TypePtr&); +void writeUnmarshalCode(Output&, const std::list<std::pair<TypePtr, std::string> >&, const TypePtr&); +void writeAllocateCode(Output&, const std::list<std::pair<TypePtr, std::string> >&, const TypePtr&); } diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp index 4acd74fa535..8b8bc08734b 100644 --- a/cpp/src/slice2docbook/Gen.cpp +++ b/cpp/src/slice2docbook/Gen.cpp @@ -15,17 +15,15 @@ using namespace std; using namespace Slice; -Slice::Gen::Gen(const string& name, const string& file, bool standAlone, - bool noGlobals) - : _standAlone(standAlone), - _noGlobals(noGlobals), - _chapter("section") // Could also be "chapter" +Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool noGlobals) : + _standAlone(standAlone), + _noGlobals(noGlobals), + _chapter("section") // Could also be "chapter" { O.open(file.c_str()); if(!O) { - cerr << name << ": can't open `" << file << "' for writing: " - << strerror(errno) << endl; + cerr << name << ": can't open `" << file << "' for writing: " << strerror(errno) << endl; return; } } @@ -77,12 +75,10 @@ Slice::Gen::visitUnitEnd(const UnitPtr& p) void Slice::Gen::visitModuleStart(const ModulePtr& p) { - start(_chapter + " id=" + scopedToId(p -> scoped()), - p -> scoped().substr(2)); + start(_chapter + " id=" + scopedToId(p -> scoped()), p -> scoped().substr(2)); start("section", "Overview"); O.zeroIndent(); - O << nl << "<synopsis>module <classname>" << p -> name() - << "</classname></synopsis>"; + O << nl << "<synopsis>module <classname>" << p -> name() << "</classname></synopsis>"; O.restoreIndent(); printComment(p); visitContainer(p); @@ -118,9 +114,8 @@ Slice::Gen::visitContainer(const ContainerPtr& p) ClassList classes = p -> classes(); ClassList interfaces; - interfaces.splice(interfaces.end(), classes, - remove_if(classes.begin(), classes.end(), - ::Ice::memFun(&ClassDef::isInterface)), + interfaces.splice(interfaces.end(), + classes, remove_if(classes.begin(), classes.end(), ::Ice::memFun(&ClassDef::isInterface)), classes.end()); classes.sort(); @@ -257,8 +252,7 @@ Slice::Gen::visitContainer(const ContainerPtr& p) start("section id=" + scopedToId((*q) -> scoped()), (*q) -> name()); O.zeroIndent(); - O << nl << "<synopsis>vector< " - << typeToString(type) << " > <type>" << (*q) -> name() + O << nl << "<synopsis>vector< " << typeToString(type) << " > <type>" << (*q) -> name() << "</type>;</synopsis>"; O.restoreIndent(); @@ -299,8 +293,7 @@ Slice::Gen::visitContainer(const ContainerPtr& p) start("section id=" + scopedToId((*q) -> scoped()), (*q) -> name()); O.zeroIndent(); - O << nl << "<synopsis>native <type>" << (*q) -> name() - << "</type>;</synopsis>"; + O << nl << "<synopsis>native <type>" << (*q) -> name() << "</type>;</synopsis>"; O.restoreIndent(); printComment(*q); @@ -314,8 +307,7 @@ Slice::Gen::visitContainer(const ContainerPtr& p) void Slice::Gen::visitClassDefStart(const ClassDefPtr& p) { - start(_chapter + " id=" + scopedToId(p -> scoped()), - p -> scoped().substr(2)); + start(_chapter + " id=" + scopedToId(p -> scoped()), p -> scoped().substr(2)); start("section", "Overview"); O.zeroIndent(); @@ -333,8 +325,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) O.inc(); O << nl << "extends "; O.inc(); - O << "<classname>" << bases.front() -> scoped().substr(2) - << "</classname>"; + O << "<classname>" << bases.front() -> scoped().substr(2) << "</classname>"; bases.pop_front(); O.dec(); O.dec(); @@ -350,8 +341,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) ClassList::iterator q = bases.begin(); while(q != bases.end()) { - O << nl << "<classname>" << (*q) -> scoped().substr(2) - << "</classname>"; + O << nl << "<classname>" << (*q) -> scoped().substr(2) << "</classname>"; if(++q != bases.end()) O << ","; } @@ -427,15 +417,13 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) start("section id=" + scopedToId((*q) -> scoped()), (*q) -> name()); O.zeroIndent(); - O << nl << "<synopsis>" - << (returnType ? typeToString(returnType) : "<type>void</type>") + O << nl << "<synopsis>" << (returnType ? typeToString(returnType) : "<type>void</type>") << " <function>" << (*q) -> name() << "</function>("; O.inc(); TypeStringList::iterator r = inputParams.begin(); while(r != inputParams.end()) { - O << nl << typeToString(r -> first) << " <parameter>" - << r -> second << "</parameter>"; + O << nl << typeToString(r -> first) << " <parameter>" << r -> second << "</parameter>"; if(++r != inputParams.end()) O << ','; } @@ -445,8 +433,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) r = outputParams.begin(); while(r != outputParams.end()) { - O << nl << typeToString(r -> first) << " <parameter>" - << r -> second << "</parameter>"; + O << nl << typeToString(r -> first) << " <parameter>" << r -> second << "</parameter>"; if(++r != outputParams.end()) O << ','; } @@ -485,8 +472,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) start("section id=" + scopedToId((*q) -> scoped()), (*q) -> name()); O.zeroIndent(); - O << nl << "<synopsis>" - << typeToString(type) << " <structfield>" << (*q) -> name() + O << nl << "<synopsis>" << typeToString(type) << " <structfield>" << (*q) -> name() << "</structfield>;</synopsis>"; O.restoreIndent(); @@ -531,8 +517,7 @@ Slice::Gen::getTagged(const string& tag, string& comment) if(begin == string::npos) return result; - string::size_type pos1 = - comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1); + string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1); if(pos1 == string::npos) { comment.erase(begin); diff --git a/cpp/src/slice2docbook/GenUtil.cpp b/cpp/src/slice2docbook/GenUtil.cpp index 1827ec2f829..52b9c90a4e2 100644 --- a/cpp/src/slice2docbook/GenUtil.cpp +++ b/cpp/src/slice2docbook/GenUtil.cpp @@ -37,13 +37,11 @@ Slice::typeToString(const TypePtr& type) BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) - result = "<type>" + string(builtinTable[builtin -> kind()]) - + "</type>"; + result = "<type>" + string(builtinTable[builtin -> kind()]) + "</type>"; ProxyPtr proxy = ProxyPtr::dynamicCast(type); if(proxy) - result = "<classname>" + proxy -> _class() -> scoped().substr(2) + - "*</classname>"; + result = "<classname>" + proxy -> _class() -> scoped().substr(2) + "*</classname>"; ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); if(cl) @@ -55,8 +53,7 @@ Slice::typeToString(const TypePtr& type) if(result.empty()) result = "<type>" + contained -> scoped().substr(2) + "</type>"; - result = "<link linkend=" + scopedToId(contained -> scoped()) + ">" - + result + "</link>"; + result = "<link linkend=" + scopedToId(contained -> scoped()) + ">" + result + "</link>"; } if(result.empty()) @@ -80,8 +77,7 @@ Slice::addLink(const string& s, const ContainerPtr& container) ContainedPtr p = ContainedPtr::dynamicCast(types.front()); if(p) - result = "<link linkend=" + scopedToId(p -> scoped()) + ">" - + result + "</link>"; + result = "<link linkend=" + scopedToId(p -> scoped()) + ">" + result + "</link>"; return result; } @@ -89,8 +85,7 @@ Slice::addLink(const string& s, const ContainerPtr& container) ContainedList contList = container -> lookupContained(s, false); if(!contList.empty()) { - string result = "<link linkend=" + - scopedToId(contList.front() -> scoped()) + ">"; + string result = "<link linkend=" + scopedToId(contList.front() -> scoped()) + ">"; if(ModulePtr::dynamicCast(contList.front())) result += "<classname>" + s + "</classname>"; |