diff options
author | Jose <jose@zeroc.com> | 2009-10-03 01:07:56 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2009-10-03 01:07:56 +0200 |
commit | a00430c3a79067e9bdd5a62620fcfbc9da536601 (patch) | |
tree | dbda5220894c256cf73725c6f17d618b8289152d /cpp/src | |
parent | Fixes related to 3772: (diff) | |
download | ice-a00430c3a79067e9bdd5a62620fcfbc9da536601.tar.bz2 ice-a00430c3a79067e9bdd5a62620fcfbc9da536601.tar.xz ice-a00430c3a79067e9bdd5a62620fcfbc9da536601.zip |
4190 - Add header to generated files to indicate they are autogenerated.
commit 910bdd9d5cd71ac2cd357dbe5ee82b7ae81fca89
Merge: 429a086 1873f9f
Author: Jose <jose@zeroc.com>
Date: Sat Oct 3 01:00:34 2009 +0200
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Slice/Util.cpp | 22 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 11 | ||||
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 3 | ||||
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 5 | ||||
-rw-r--r-- | cpp/src/slice2freezej/Main.cpp | 4 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 71 | ||||
-rw-r--r-- | cpp/src/slice2php/Main.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2py/Main.cpp | 3 | ||||
-rw-r--r-- | cpp/src/slice2rb/Main.cpp | 2 |
10 files changed, 83 insertions, 43 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 1c0586e3344..9c764ffe322 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -187,7 +187,7 @@ Slice::JavaGenerator::~JavaGenerator() } void -Slice::JavaGenerator::open(const string& absolute) +Slice::JavaGenerator::open(const string& absolute, const string& file) { assert(_out == 0); @@ -195,6 +195,7 @@ Slice::JavaGenerator::open(const string& absolute) try { out->openClass(absolute, _dir); + printGeneratedHeader(*out, file); } catch(const FileException&) { diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index b5e3cc942e0..3ea6b609c9e 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -349,3 +349,25 @@ Slice::filterMcppWarnings(const string& message) } return out; } + +void +Slice::printGeneratedHeader(IceUtilInternal::Output& out, const string& path, const string& comment) +{ + // + // Get only the file name part of the given path. + // + string file = path; + size_t pos = file.find_last_of("/\\"); + if(string::npos != pos) + { + file = file.substr(pos + 1); + } + + out << "\n\n" << comment << " <auto-generated>"; + out << "\n" << comment; + out << "\n" << comment << " Generated from file `" << file << "'"; + out << "\n" << comment; + out << "\n" << comment << " Warning: do not edit this file."; + out << "\n" << comment; + out << "\n" << comment << " </auto-generated>\n"; +} diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 7ba4f20251e..97424a0a715 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -174,9 +174,10 @@ Slice::Gen::generate(const UnitPtr& p) FileTracker::instance()->addFile(fileC); printHeader(H); + printGeneratedHeader(H, _base + ".ice"); printHeader(C); - H << "\n// Generated from file `" << _base << ".ice'\n"; - C << "\n// Generated from file `" << _base << ".ice'\n"; + printGeneratedHeader(C, _base + ".ice"); + string s = fileH; if(_include.size()) @@ -194,9 +195,9 @@ Slice::Gen::generate(const UnitPtr& p) if(_dllExport.size()) { - C << "\n#ifndef " << _dllExport << "_EXPORTS"; - C << "\n# define " << _dllExport << "_EXPORTS"; - C << "\n#endif"; + C << "\n#ifndef " << _dllExport << "_EXPORTS"; + C << "\n# define " << _dllExport << "_EXPORTS"; + C << "\n#endif"; } C << "\n#include <"; diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index beef9f3c92a..4d2c467e7bc 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -23,6 +23,7 @@ #include <Slice/Checksum.h> #include <Slice/DotNetNames.h> #include <Slice/FileTracker.h> +#include <Slice/Util.h> #include <string.h> using namespace std; @@ -1647,7 +1648,7 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st FileTracker::instance()->addFile(file); printHeader(); - _out << nl << "// Generated from file `" << fileBase << ".ice'"; + printGeneratedHeader(_out, fileBase + ".ice"); _out << sp << nl << "using _System = global::System;"; _out << nl << "using _Microsoft = global::Microsoft;"; diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 685ca10c0cc..1cdfc130779 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -1398,6 +1398,9 @@ gen(const string& name, const UnitPtr& u, const vector<string>& includePaths, co FileTracker::instance()->addFile(fileH); printHeader(H); + printGeneratedHeader(H, string(args[0]) + ".ice"); + + printFreezeTypes(H, dicts, indices); IceUtilInternal::Output CPP; @@ -1411,6 +1414,8 @@ gen(const string& name, const UnitPtr& u, const vector<string>& includePaths, co FileTracker::instance()->addFile(fileC); printHeader(CPP); + printGeneratedHeader(CPP, string(args[0]) + ".ice"); + printFreezeTypes(CPP, dicts, indices); for(vector<string>::const_iterator i = extraHeaders.begin(); i != extraHeaders.end(); ++i) diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 16230ee76b4..a3bbfdfbfa8 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -426,7 +426,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) } } - open(dict.name); + open(dict.name, u->currentFile()); Output& out = output(); @@ -1125,7 +1125,7 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) string memberTypeString = typeToString(dataMember->type(), TypeModeIn); - open(index.name); + open(index.name, u->currentFile()); Output& out = output(); diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 1c6881b3938..fb490ac41c0 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -1657,7 +1657,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) } string absolute = getAbsolute(p, "", "_", opIntfName); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -1787,7 +1787,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -1971,9 +1971,10 @@ Slice::Gen::PackageVisitor::visitModuleStart(const ModulePtr& p) if(!prefix.empty()) { string markerClass = prefix + "." + fixKwd(p->name()) + "._Marker"; - open(markerClass); + open(markerClass, p->file()); Output& out = output(); + out << sp << nl << "interface _Marker"; out << sb; out << eb; @@ -2005,7 +2006,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) DataMemberList allDataMembers = p->allDataMembers(); DataMemberList::const_iterator d; - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -2281,7 +2282,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) DataMemberList members = p->dataMembers(); DataMemberList::const_iterator d; - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -2612,7 +2613,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) string name = fixKwd(p->name()); string absolute = getAbsolute(p); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -3121,7 +3122,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) EnumeratorList::const_iterator en; size_t sz = enumerators.size(); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -3236,9 +3237,10 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) string absolute = getAbsolute(p); TypePtr type = p->type(); - open(absolute); + open(absolute, p->file()); Output& out = output(); + out << sp; writeDocComment(out, p, getDeprecateReason(p, 0, "constant")); out << nl << "public interface " << name; @@ -3390,8 +3392,9 @@ Slice::Gen::HolderVisitor::visitClassDefStart(const ClassDefPtr& p) string name = p->name(); string absolute = getAbsolute(p, "", "", "PrxHolder"); - open(absolute); + open(absolute, p->file()); Output& out = output(); + out << sp << nl << "public final class " << name << "PrxHolder"; out << sb; out << sp << nl << "public" << nl << name << "PrxHolder()"; @@ -3459,8 +3462,16 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) string name = contained->name(); string absolute = getAbsolute(contained, "", "", "Holder"); - open(absolute); + + string file; + if(p->definitionContext()) + { + file = p->definitionContext()->filename(); + } + + open(absolute, file); Output& out = output(); + string typeS = typeToString(p, TypeModeIn, getPackage(contained)); out << sp << nl << "public final class " << name << "Holder"; BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); @@ -3540,8 +3551,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p); - open(getAbsolute(p, "", "", "PrxHelper")); - + open(getAbsolute(p, "", "", "PrxHelper"), p->file()); Output& out = output(); // @@ -3880,7 +3890,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // // Class helper. // - open(getAbsolute(p, "", "", "Helper")); + open(getAbsolute(p, "", "", "Helper"), p->file()); Output& out2 = output(); @@ -3912,7 +3922,7 @@ Slice::Gen::HelperVisitor::visitStructStart(const StructPtr& p) string name = p->name(); string fixedName = fixKwd(name); - open(getAbsolute(p, "", "", "Helper")); + open(getAbsolute(p, "", "", "Helper"), p->file()); Output& out = output(); @@ -4006,8 +4016,9 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) suppressUnchecked = origContentS.find('<') != string::npos; } - open(helper); + open(helper, p->file()); Output& out = output(); + int iter; out << sp << nl << "public final class " << name << "Helper"; @@ -4079,8 +4090,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) StringList metaData = p->getMetaData(); string formalType = typeToString(p, TypeModeIn, package, StringList(), true); - open(helper); + open(helper, p->file()); Output& out = output(); + int iter; out << sp << nl << "public final class " << name << "Helper"; @@ -4132,7 +4144,7 @@ Slice::Gen::HelperVisitor::visitEnum(const EnumPtr& p) string name = p->name(); string fixedName = fixKwd(name); - open(getAbsolute(p, "", "", "Helper")); + open(getAbsolute(p, "", "", "Helper"), p->file()); Output& out = output(); @@ -4172,7 +4184,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "", "Prx"); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -4288,7 +4300,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "_", "Del"); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -4362,8 +4374,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "_", "DelM"); - open(absolute); - + open(absolute, p->file()); Output& out = output(); out << sp << nl << "public final class _" << name << "DelM extends Ice._ObjectDelM implements _" << name << "Del"; @@ -4562,7 +4573,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "_", "DelD"); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -4746,7 +4757,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); string absolute = getAbsolute(p, "", "_", "Disp"); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -5043,7 +5054,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "", "I"); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -5101,7 +5112,7 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "", "I"); - open(absolute); + open(absolute, p->file()); Output& out = output(); @@ -5198,7 +5209,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) string classNameAMI = "AMI_" + cl->name(); string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name); - open(absoluteAMI); + open(absoluteAMI, p->file()); Output& out = output(); @@ -5436,10 +5447,10 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) vector<string> paramsAMD = getParamsAsyncCB(p, classPkg); { - open(absoluteAMD); + open(absoluteAMD, p->file()); Output& out = output(); - + writeDocCommentOp(out, p); out << sp << nl << "public interface " << classNameAMD << '_' << name; out << " extends Ice.AMDCallback"; @@ -5454,10 +5465,10 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } { - open(absoluteAMDI); + open(absoluteAMDI, p->file()); Output& out = output(); - + TypePtr ret = p->returnType(); ParamDeclList outParams; diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index 57d5c945f5e..e943a742838 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -1693,7 +1693,7 @@ compile(int argc, char* argv[]) out << "<?php\n"; printHeader(out); - out << "\n// Generated from file `" << base << ".ice'\n"; + printGeneratedHeader(out, base + ".ice"); // // Generate the PHP mapping. diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 9a7fac7a99f..3af0f9b217b 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -571,8 +571,7 @@ compile(int argc, char* argv[]) FileTracker::instance()->addFile(file); printHeader(out); - out << "\n# Generated from file `" << base << ".ice'\n"; - + printGeneratedHeader(out, base + ".ice", "#"); // // Generate the Python mapping. // diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 94acb028b07..369fc9329db 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -244,7 +244,7 @@ compile(int argc, char* argv[]) FileTracker::instance()->addFile(file); printHeader(out); - out << "\n# Generated from file `" << base << ".ice'\n"; + printGeneratedHeader(out, base + ".ice", "#"); // // Generate the Ruby mapping. |