diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-09-23 20:36:03 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-09-23 20:36:03 +0000 |
commit | 952d6fc109ee750d813c6689f238f621117922e1 (patch) | |
tree | a70606dfd8671cf71e166973313ce36188cdf1dd /cpp/src/Slice/PythonUtil.cpp | |
parent | adding AMD tests (diff) | |
download | ice-952d6fc109ee750d813c6689f238f621117922e1.tar.bz2 ice-952d6fc109ee750d813c6689f238f621117922e1.tar.xz ice-952d6fc109ee750d813c6689f238f621117922e1.zip |
prevent abstract class from being instantiated
Diffstat (limited to 'cpp/src/Slice/PythonUtil.cpp')
-rw-r--r-- | cpp/src/Slice/PythonUtil.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index eb2594c02de..3ba1683101f 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -320,12 +320,19 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) } _out << "):"; _out.inc(); - if(baseName.empty() && !p->hasDataMembers()) + if(baseName.empty() && !p->hasDataMembers() && !p->isAbstract()) { _out << nl << "pass"; } else { + if(p->isAbstract()) + { + _out << nl << "if __builtin__.type(self) == _M_" << fixedScoped << ':'; + _out.inc(); + _out << nl << "raise RuntimeError('" << fixedScoped << " is an abstract class')"; + _out.dec(); + } if(!baseName.empty()) { _out << nl << baseName << ".__init__(self"; @@ -1493,7 +1500,7 @@ changeInclude(const string& orig, const vector<string>& includePaths) void Slice::Python::generate(const UnitPtr& unit, bool all, bool checksum, const vector<string>& includePaths, Output& out) { - out << nl << "import Ice, IcePy"; + out << nl << "import Ice, IcePy, __builtin__"; if(!all) { |