summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Parser.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
commit06a08ecf28e205277336a97a6173db7ccbed1adc (patch)
treea369a5044a63f8cdba9e7c0a461e24ae344486b4 /cpp/src/Slice/Parser.cpp
parentMerge branch 'R3_3_branch' (diff)
parentBug 3924: slice2py missing from VC60 installer (diff)
downloadice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.bz2
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.xz
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.zip
Merge commit 'origin/R3_3_branch'
Conflicts: CHANGES cpp/demo/Freeze/backup/.depend cpp/demo/Freeze/bench/.depend cpp/demo/Freeze/casino/.depend cpp/demo/Freeze/customEvictor/.depend cpp/demo/Freeze/library/.depend cpp/demo/Freeze/phonebook/.depend cpp/demo/Freeze/transform/.depend cpp/demo/Glacier2/callback/.depend cpp/demo/Glacier2/chat/.depend cpp/demo/Ice/async/.depend cpp/demo/Ice/bidir/.depend cpp/demo/Ice/callback/.depend cpp/demo/Ice/converter/.depend cpp/demo/Ice/hello/.depend cpp/demo/Ice/invoke/.depend cpp/demo/Ice/latency/.depend cpp/demo/Ice/minimal/.depend cpp/demo/Ice/multicast/.depend cpp/demo/Ice/nested/.depend cpp/demo/Ice/nrvo/.depend cpp/demo/Ice/session/.depend cpp/demo/Ice/throughput/.depend cpp/demo/Ice/value/.depend cpp/demo/IceBox/hello/.depend cpp/demo/IceGrid/allocate/.depend cpp/demo/IceGrid/icebox/.depend cpp/demo/IceGrid/replication/.depend cpp/demo/IceGrid/sessionActivation/.depend cpp/demo/IceGrid/simple/.depend cpp/demo/IceStorm/clock/.depend cpp/demo/IceStorm/counter/.depend cpp/demo/IceStorm/replicated/.depend cpp/demo/IceStorm/replicated2/.depend cpp/demo/book/freeze_filesystem/.depend cpp/demo/book/lifecycle/.depend cpp/demo/book/printer/.depend cpp/demo/book/simple_filesystem/.depend cpp/src/Freeze/.depend cpp/src/FreezeScript/.depend cpp/src/Ice/.depend cpp/src/Ice/UdpTransceiver.cpp cpp/src/Ice/UdpTransceiver.h cpp/src/IceBox/.depend cpp/src/IceGrid/.depend cpp/src/IceGridLib/.depend cpp/src/IcePatch2/.depend cpp/src/IceStorm/.depend cpp/src/slice2freeze/.depend cpp/test/Freeze/complex/.depend cpp/test/Freeze/dbmap/.depend cpp/test/Freeze/evictor/.depend cpp/test/Freeze/oldevictor/.depend cpp/test/FreezeScript/dbmap/.depend cpp/test/FreezeScript/evictor/.depend cpp/test/Glacier2/attack/.depend cpp/test/Glacier2/dynamicFiltering/.depend cpp/test/Glacier2/router/.depend cpp/test/Glacier2/sessionControl/.depend cpp/test/Glacier2/ssl/.depend cpp/test/Glacier2/staticFiltering/.depend cpp/test/Ice/adapterDeactivation/.depend cpp/test/Ice/background/.depend cpp/test/Ice/binding/.depend cpp/test/Ice/checksum/.depend cpp/test/Ice/checksum/server/.depend cpp/test/Ice/custom/.depend cpp/test/Ice/exceptions/.depend cpp/test/Ice/facets/.depend cpp/test/Ice/faultTolerance/.depend cpp/test/Ice/gc/.depend cpp/test/Ice/hold/.depend cpp/test/Ice/inheritance/.depend cpp/test/Ice/interceptor/.depend cpp/test/Ice/location/.depend cpp/test/Ice/objects/.depend cpp/test/Ice/operations/.depend cpp/test/Ice/proxy/.depend cpp/test/Ice/retry/.depend cpp/test/Ice/servantLocator/.depend cpp/test/Ice/slicing/exceptions/.depend cpp/test/Ice/slicing/objects/.depend cpp/test/Ice/stream/.depend cpp/test/Ice/stringConverter/.depend cpp/test/Ice/timeout/.depend cpp/test/Ice/udp/.depend cpp/test/IceBox/configuration/.depend cpp/test/IceGrid/activation/.depend cpp/test/IceGrid/allocation/.depend cpp/test/IceGrid/deployer/.depend cpp/test/IceGrid/distribution/.depend cpp/test/IceGrid/replicaGroup/.depend cpp/test/IceGrid/replication/.depend cpp/test/IceGrid/session/.depend cpp/test/IceGrid/simple/.depend cpp/test/IceGrid/update/.depend cpp/test/IceSSL/configuration/.depend cpp/test/IceStorm/federation/.depend cpp/test/IceStorm/federation2/.depend cpp/test/IceStorm/rep1/.depend cpp/test/IceStorm/repgrid/.depend cpp/test/IceStorm/repstress/.depend cpp/test/IceStorm/single/.depend cpp/test/IceStorm/stress/.depend cpp/test/Slice/keyword/.depend cs/src/Ice/Instance.cs cs/src/IceSSL/ConnectorI.cs java/demo/book/simple_filesystem/Filesystem/DirectoryI.java java/demo/book/simple_filesystem/Filesystem/FileI.java java/src/IceInternal/TcpConnector.java java/src/IceSSL/ConnectorI.java py/modules/IcePy/.depend rb/src/IceRuby/.depend
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r--cpp/src/Slice/Parser.cpp85
1 files changed, 51 insertions, 34 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 5d682503ec3..d2725b13c24 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -1351,6 +1351,13 @@ Slice::Container::lookupException(const string& scoped, bool printError)
return exceptions.front();
}
+UnitPtr
+Slice::Container::unit() const
+{
+ return SyntaxTreeBase::unit();
+}
+
+
ModuleList
Slice::Container::modules() const
{
@@ -4714,8 +4721,7 @@ Slice::Operation::attributes() const
}
if(i == 2)
{
- cerr << definitionContext()->filename() << ":" << line()
- << ": warning: invalid freeze metadata for operation" << endl;
+ emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation");
}
else
{
@@ -4736,8 +4742,7 @@ Slice::Operation::attributes() const
{
if(result != 0 && (i == int(Supports) || i == int(Never)))
{
- cerr << definitionContext()->filename() << ":" << line()
- << ": warning: invalid freeze metadata for operation" << endl;
+ emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation");
}
else
{
@@ -4751,8 +4756,7 @@ Slice::Operation::attributes() const
if(i == 4)
{
- cerr << definitionContext()->filename() << ":" << line()
- << ": warning: invalid freeze metadata for operation" << endl;
+ emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation");
//
// Set default
@@ -5004,6 +5008,12 @@ Slice::Unit::currentFile() const
}
}
+string
+Slice::Unit::topLevelFile() const
+{
+ return _topLevelFile;
+}
+
int
Slice::Unit::currentLine() const
{
@@ -5057,23 +5067,13 @@ Slice::Unit::scanPosition(const char* s)
}
}
- //
- // Cache full paths to avoid too many full path computations.
- //
- map<string, string>::const_iterator p = _fullPaths.find(currentFile);
- if(p == _fullPaths.end())
- {
- p = _fullPaths.insert(make_pair(currentFile, fullPath(currentFile))).first;
- }
- currentFile = p->second;
-
enum LineType { File, Push, Pop };
LineType type = File;
if(_currentLine == 0)
{
- if(currentFile != _topLevelFile)
+ if(_currentIncludeLevel > 0 || currentFile != _topLevelFile)
{
type = Push;
line.erase(idx);
@@ -5123,6 +5123,7 @@ Slice::Unit::scanPosition(const char* s)
DefinitionContextPtr dc = currentDefinitionContext();
assert(dc);
dc->setFilename(currentFile);
+ _definitionContextMap.insert(make_pair(currentFile, dc));
}
}
@@ -5150,6 +5151,9 @@ Slice::Unit::addGlobalMetaData(const StringList& metaData)
}
else
{
+ //
+ // Append the global metadata to any existing metadata (e.g., default global metadata).
+ //
StringList l = dc->getMetaData();
copy(metaData.begin(), metaData.end(), back_inserter(l));
dc->setMetaData(l);
@@ -5167,36 +5171,27 @@ Slice::Unit::setSeenDefinition()
void
Slice::Unit::error(const char* s)
{
- string file = currentFile();
- if(!file.empty())
- {
- cerr << file << ':' << _currentLine << ": ";
- }
- cerr << s << endl;
+ emitError(currentFile(), _currentLine, s);
_errors++;
}
void
Slice::Unit::error(const string& s)
{
- error(s.c_str());
+ emitError(currentFile(), _currentLine, s);
+ _errors++;
}
void
Slice::Unit::warning(const char* s) const
{
- string file = currentFile();
- if(!file.empty())
- {
- cerr << file << ':' << _currentLine << ": ";
- }
- cerr << "warning: " << s << endl;
+ emitWarning(currentFile(), _currentLine, s);
}
void
Slice::Unit::warning(const string& s) const
{
- warning(s.c_str());
+ emitWarning(currentFile(), _currentLine, s);
}
ContainerPtr
@@ -5233,7 +5228,7 @@ Slice::Unit::currentDefinitionContext() const
void
Slice::Unit::pushDefinitionContext()
{
- _definitionContextStack.push(new DefinitionContext(_currentIncludeLevel, _defaultGlobalMetadata));
+ _definitionContextStack.push(new DefinitionContext(_currentIncludeLevel, _defaultGlobalMetaData));
}
void
@@ -5243,6 +5238,17 @@ Slice::Unit::popDefinitionContext()
_definitionContextStack.pop();
}
+DefinitionContextPtr
+Slice::Unit::findDefinitionContext(const string& file) const
+{
+ map<string, DefinitionContextPtr>::const_iterator p = _definitionContextMap.find(file);
+ if(p != _definitionContextMap.end())
+ {
+ return p->second;
+ }
+ return 0;
+}
+
void
Slice::Unit::addContent(const ContainedPtr& contained)
{
@@ -5453,6 +5459,18 @@ Slice::Unit::includeFiles() const
return _includeFiles;
}
+StringList
+Slice::Unit::allFiles() const
+{
+ StringList result;
+ for(map<string, DefinitionContextPtr>::const_iterator p = _definitionContextMap.begin();
+ p != _definitionContextMap.end(); ++p)
+ {
+ result.push_back(p->first);
+ }
+ return result;
+}
+
int
Slice::Unit::parse(const string& filename, FILE* file, bool debug, Slice::FeatureProfile profile)
{
@@ -5466,7 +5484,6 @@ Slice::Unit::parse(const string& filename, FILE* file, bool debug, Slice::Featur
_currentIncludeLevel = 0;
_featureProfile = profile;
_topLevelFile = fullPath(filename);
- _fullPaths[filename] = _topLevelFile;
pushContainer(this);
pushDefinitionContext();
@@ -5539,7 +5556,7 @@ Slice::Unit::Unit(bool ignRedefs, bool all, bool allowIcePrefix, bool caseSensit
_all(all),
_allowIcePrefix(allowIcePrefix),
_caseSensitive(caseSensitive),
- _defaultGlobalMetadata(defaultGlobalMetadata),
+ _defaultGlobalMetaData(defaultGlobalMetadata),
_errors(0)
{