From 952d6fc109ee750d813c6689f238f621117922e1 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Thu, 23 Sep 2004 20:36:03 +0000 Subject: prevent abstract class from being instantiated --- cpp/src/Slice/PythonUtil.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cpp/src/Slice/PythonUtil.cpp') 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& includePaths) void Slice::Python::generate(const UnitPtr& unit, bool all, bool checksum, const vector& includePaths, Output& out) { - out << nl << "import Ice, IcePy"; + out << nl << "import Ice, IcePy, __builtin__"; if(!all) { -- cgit v1.2.3