Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/interrogate/interfaceMakerPython.cxx

Go to the documentation of this file.
00001 // Filename: interfaceMakerPython.cxx
00002 // Created by:  drose (21Sep01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "interfaceMakerPython.h"
00020 #include "interrogate.h"
00021 
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: InterfaceMakerPython::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 InterfaceMakerPython::
00029 InterfaceMakerPython(InterrogateModuleDef *def) :
00030   InterfaceMaker(def)
00031 {
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: InterfaceMakerPython::write_includes
00036 //       Access: Public, Virtual
00037 //  Description: Generates the list of #include ... whatever that's
00038 //               required by this particular interface to the
00039 //               indicated output stream.
00040 ////////////////////////////////////////////////////////////////////
00041 void InterfaceMakerPython::
00042 write_includes(ostream &out) {
00043   InterfaceMaker::write_includes(out);
00044   out << "#undef HAVE_LONG_LONG\n"
00045       << "#include <Python.h>\n\n";
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: InterfaceMakerPython::test_assert
00050 //       Access: Protected
00051 //  Description: Outputs code to check to see if an assertion has
00052 //               failed while the C++ code was executing, and report
00053 //               this failure back to Python.
00054 ////////////////////////////////////////////////////////////////////
00055 void InterfaceMakerPython::
00056 test_assert(ostream &out, int indent_level) const {
00057   if (watch_asserts) {
00058     out << "#ifndef NDEBUG\n";
00059     indent(out, indent_level)
00060       << "Notify *notify = Notify::ptr();\n";
00061     indent(out, indent_level)
00062       << "if (notify->has_assert_failed()) {\n";
00063     indent(out, indent_level + 2)
00064       << "PyErr_SetString(PyExc_AssertionError, notify->get_assert_error_message().c_str());\n";
00065     indent(out, indent_level + 2)
00066       << "notify->clear_assert_failed();\n";
00067     indent(out, indent_level + 2)
00068       << "return (PyObject *)NULL;\n";
00069     indent(out, indent_level)
00070       << "}\n";
00071     out << "#endif\n";
00072   }
00073 }

Generated on Thu May 1 22:13:01 2003 for DTool by doxygen1.3