App/DocumentPy.cpp

Go to the documentation of this file.
00001 
00002 // This file is generated by src/Tools/generateTemaplates/templateClassPyExport.py out of the .XML file
00003 // Every change you make here get lost at the next full rebuild!
00004 // This File is normaly build as an include in DocumentPyImp.cpp! Its not intended to be in a project!
00005 
00006 #include <boost/filesystem/path.hpp>
00007 #include <boost/filesystem/operations.hpp>
00008 #include <boost/filesystem/exception.hpp>
00009 #include <Base/PyObjectBase.h>
00010 #include <Base/Console.h>
00011 #include <Base/Exception.h>
00012 #include <CXX/Objects.hxx>
00013 
00014 #define new DEBUG_CLIENTBLOCK
00015 
00016 using Base::streq;
00017 using namespace App;
00018 
00020 PyTypeObject DocumentPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "App.Document",     /*tp_name*/
00024     sizeof(DocumentPy),                       /*tp_basicsize*/
00025     0,                                                /*tp_itemsize*/
00026     /* methods */
00027     PyDestructor,                                     /*tp_dealloc*/
00028     0,                                                /*tp_print*/
00029     __getattr,                                        /*tp_getattr*/
00030     __setattr,                                        /*tp_setattr*/
00031     0,                                                /*tp_compare*/
00032     __repr,                                           /*tp_repr*/
00033     0,                                                /*tp_as_number*/
00034     0,                                                /*tp_as_sequence*/
00035     0,                                                /*tp_as_mapping*/
00036     0,                                                /*tp_hash*/
00037     0,                                                /*tp_call */
00038     0,                                                /*tp_str  */
00039     0,                                                /*tp_getattro*/
00040     0,                                                /*tp_setattro*/
00041     /* --- Functions to access object as input/output buffer ---------*/
00042     0,                                                /* tp_as_buffer */
00043     /* --- Flags to define presence of optional/expanded features */
00044     Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,        /*tp_flags */
00045     "This is a Document class",           /*tp_doc */
00046     0,                                                /*tp_traverse */
00047     0,                                                /*tp_clear */
00048     0,                                                /*tp_richcompare */
00049     0,                                                /*tp_weaklistoffset */
00050     0,                                                /*tp_iter */
00051     0,                                                /*tp_iternext */
00052     App::DocumentPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     App::DocumentPy::GetterSetter,                     /*tp_getset */
00055     &App::PropertyContainerPy::Type,                        /*tp_base */
00056     0,                                                /*tp_dict */
00057     0,                                                /*tp_descr_get */
00058     0,                                                /*tp_descr_set */
00059     0,                                                /*tp_dictoffset */
00060     __PyInit,                                         /*tp_init */
00061     0,                                                /*tp_alloc */
00062     App::DocumentPy::PyMake,/*tp_new */
00063     0,                                                /*tp_free   Low-level free-memory routine */
00064     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00065     0,                                                /*tp_bases */
00066     0,                                                /*tp_mro    method resolution order */
00067     0,                                                /*tp_cache */
00068     0,                                                /*tp_subclasses */
00069     0,                                                /*tp_weaklist */
00070     0                                                 /*tp_del */
00071 };
00072 
00074 PyMethodDef DocumentPy::Methods[] = {
00075     {"save",
00076         (PyCFunction) staticCallback_save,
00077         METH_VARARGS,
00078         "Save the document to disc"
00079     },
00080     {"restore",
00081         (PyCFunction) staticCallback_restore,
00082         METH_VARARGS,
00083         "Restore the document from disc"
00084     },
00085     {"openTransaction",
00086         (PyCFunction) staticCallback_openTransaction,
00087         METH_VARARGS,
00088         "Open a new Undo/Redo transaction."
00089     },
00090     {"abortTransaction",
00091         (PyCFunction) staticCallback_abortTransaction,
00092         METH_VARARGS,
00093         "Abort an Undo/Redo transaction (rollback)"
00094     },
00095     {"commitTransaction",
00096         (PyCFunction) staticCallback_commitTransaction,
00097         METH_VARARGS,
00098         "Commit an Undo/Redo transaction"
00099     },
00100     {"addObject",
00101         (PyCFunction) staticCallback_addObject,
00102         METH_VARARGS,
00103         "Add an object with given type and name to the document"
00104     },
00105     {"removeObject",
00106         (PyCFunction) staticCallback_removeObject,
00107         METH_VARARGS,
00108         "Remove an object from the document"
00109     },
00110     {"copyObject",
00111         (PyCFunction) staticCallback_copyObject,
00112         METH_VARARGS,
00113         "Copy an object from another document to this document"
00114     },
00115     {"moveObject",
00116         (PyCFunction) staticCallback_moveObject,
00117         METH_VARARGS,
00118         "Move an object from another document to this document"
00119     },
00120     {"undo",
00121         (PyCFunction) staticCallback_undo,
00122         METH_VARARGS,
00123         "Undo one transaction"
00124     },
00125     {"redo",
00126         (PyCFunction) staticCallback_redo,
00127         METH_VARARGS,
00128         "Redo a previosly undid transaction"
00129     },
00130     {"clearUndos",
00131         (PyCFunction) staticCallback_clearUndos,
00132         METH_VARARGS,
00133         "Clear the undo stack of the document"
00134     },
00135     {"recompute",
00136         (PyCFunction) staticCallback_recompute,
00137         METH_VARARGS,
00138         "Recompute the document"
00139     },
00140     {"getObject",
00141         (PyCFunction) staticCallback_getObject,
00142         METH_VARARGS,
00143         "Return the object with the given name"
00144     },
00145     {"getObjectsByLabel",
00146         (PyCFunction) staticCallback_getObjectsByLabel,
00147         METH_VARARGS,
00148         "Return the objects with the given label name.\nNOTE: It's possible that several objects have the same label name."
00149     },
00150     {"findObjects",
00151         (PyCFunction) staticCallback_findObjects,
00152         METH_VARARGS,
00153         "findObjects([string (type)], [string (name)]) -> list\nReturn a list of objects that match the specified type and name.\nBoth parameters are optional."
00154     },
00155     {"supportedTypes",
00156         (PyCFunction) staticCallback_supportedTypes,
00157         METH_VARARGS,
00158         "A list of supported types of objects"
00159     },
00160     {"getTempFileName",
00161         (PyCFunction) staticCallback_getTempFileName,
00162         METH_VARARGS,
00163         "Returns a file name with path in the temp directory of the document."
00164     },
00165     {NULL, NULL, 0, NULL}               /* Sentinel */
00166 };
00167 
00168 
00169 
00171 PyGetSetDef DocumentPy::GetterSetter[] = {
00172     {"DependencyGraph",
00173         (getter) staticCallback_getDependencyGraph,
00174         (setter) staticCallback_setDependencyGraph, 
00175         "The dependency graph as GraphViz text",
00176         NULL
00177     },
00178     {"ActiveObject",
00179         (getter) staticCallback_getActiveObject,
00180         (setter) staticCallback_setActiveObject, 
00181         "The active object of the document",
00182         NULL
00183     },
00184     {"Objects",
00185         (getter) staticCallback_getObjects,
00186         (setter) staticCallback_setObjects, 
00187         "The list of object handled by this document",
00188         NULL
00189     },
00190     {"UndoMode",
00191         (getter) staticCallback_getUndoMode,
00192         (setter) staticCallback_setUndoMode, 
00193         "The Undo mode of the Document (0 = no Undo, 1 = Undo/Redo)",
00194         NULL
00195     },
00196     {"UndoRedoMemSize",
00197         (getter) staticCallback_getUndoRedoMemSize,
00198         (setter) staticCallback_setUndoRedoMemSize, 
00199         "The size of the Undo stack in byte",
00200         NULL
00201     },
00202     {"UndoCount",
00203         (getter) staticCallback_getUndoCount,
00204         (setter) staticCallback_setUndoCount, 
00205         "Number of possible Undos",
00206         NULL
00207     },
00208     {"RedoCount",
00209         (getter) staticCallback_getRedoCount,
00210         (setter) staticCallback_setRedoCount, 
00211         "Number of possible Redos",
00212         NULL
00213     },
00214     {"UndoNames",
00215         (getter) staticCallback_getUndoNames,
00216         (setter) staticCallback_setUndoNames, 
00217         "A list of Undo names",
00218         NULL
00219     },
00220     {"RedoNames",
00221         (getter) staticCallback_getRedoNames,
00222         (setter) staticCallback_setRedoNames, 
00223         "A List of Redo names",
00224         NULL
00225     },
00226     {"Name",
00227         (getter) staticCallback_getName,
00228         (setter) staticCallback_setName, 
00229         "The internal name of the document",
00230         NULL
00231     },
00232     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00233 };
00234 
00235 // save() callback and implementer
00236 // PyObject*  DocumentPy::save(PyObject *args){};
00237 // has to be implemented in DocumentPyImp.cpp
00238 PyObject * DocumentPy::staticCallback_save (PyObject *self, PyObject *args)
00239 {
00240     // test if twin object not allready deleted
00241     if (!((PyObjectBase*) self)->isValid()){
00242         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00243         return NULL;
00244     }
00245 
00246     // test if object is set Const
00247     if (((PyObjectBase*) self)->isConst()){
00248         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00249         return NULL;
00250     }
00251 
00252     try { // catches all exceptions coming up from c++ and generate a python exception
00253         PyObject* ret = ((DocumentPy*)self)->save(args);
00254         if (ret != 0)
00255             ((DocumentPy*)self)->startNotify();
00256         return ret;
00257     }
00258     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00259     {
00260         std::string str;
00261         str += "FreeCAD exception thrown (";
00262         str += e.what();
00263         str += ")";
00264         e.ReportException();
00265         PyErr_SetString(PyExc_Exception,str.c_str());
00266         return NULL;
00267     }
00268     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00269     {
00270         std::string str;
00271         str += "File system exception thrown (";
00272         //str += e.who();
00273         //str += ", ";
00274         str += e.what();
00275         str += ")\n";
00276         Base::Console().Error(str.c_str());
00277         PyErr_SetString(PyExc_Exception,str.c_str());
00278         return NULL;
00279     }
00280     catch(const Py::Exception&)
00281     {
00282         // The exception text is already set
00283         return NULL;
00284     }
00285     catch(const char* e) // catch simple string exceptions
00286     {
00287         Base::Console().Error(e);
00288         PyErr_SetString(PyExc_Exception,e);
00289         return NULL;
00290     }
00291     // in debug not all exceptions will be catched to get the attention of the developer!
00292 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00293     catch(const std::exception& e) // catch other c++ exceptions
00294     {
00295         std::string str;
00296         str += "FC++ exception thrown (";
00297         str += e.what();
00298         str += ")";
00299         Base::Console().Error(str.c_str());
00300         PyErr_SetString(PyExc_Exception,str.c_str());
00301         return NULL;
00302     }
00303     catch(...)  // catch the rest!
00304     {
00305         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00306         return NULL;
00307     }
00308 #endif
00309 }
00310 
00311 // restore() callback and implementer
00312 // PyObject*  DocumentPy::restore(PyObject *args){};
00313 // has to be implemented in DocumentPyImp.cpp
00314 PyObject * DocumentPy::staticCallback_restore (PyObject *self, PyObject *args)
00315 {
00316     // test if twin object not allready deleted
00317     if (!((PyObjectBase*) self)->isValid()){
00318         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00319         return NULL;
00320     }
00321 
00322     // test if object is set Const
00323     if (((PyObjectBase*) self)->isConst()){
00324         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00325         return NULL;
00326     }
00327 
00328     try { // catches all exceptions coming up from c++ and generate a python exception
00329         PyObject* ret = ((DocumentPy*)self)->restore(args);
00330         if (ret != 0)
00331             ((DocumentPy*)self)->startNotify();
00332         return ret;
00333     }
00334     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00335     {
00336         std::string str;
00337         str += "FreeCAD exception thrown (";
00338         str += e.what();
00339         str += ")";
00340         e.ReportException();
00341         PyErr_SetString(PyExc_Exception,str.c_str());
00342         return NULL;
00343     }
00344     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00345     {
00346         std::string str;
00347         str += "File system exception thrown (";
00348         //str += e.who();
00349         //str += ", ";
00350         str += e.what();
00351         str += ")\n";
00352         Base::Console().Error(str.c_str());
00353         PyErr_SetString(PyExc_Exception,str.c_str());
00354         return NULL;
00355     }
00356     catch(const Py::Exception&)
00357     {
00358         // The exception text is already set
00359         return NULL;
00360     }
00361     catch(const char* e) // catch simple string exceptions
00362     {
00363         Base::Console().Error(e);
00364         PyErr_SetString(PyExc_Exception,e);
00365         return NULL;
00366     }
00367     // in debug not all exceptions will be catched to get the attention of the developer!
00368 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00369     catch(const std::exception& e) // catch other c++ exceptions
00370     {
00371         std::string str;
00372         str += "FC++ exception thrown (";
00373         str += e.what();
00374         str += ")";
00375         Base::Console().Error(str.c_str());
00376         PyErr_SetString(PyExc_Exception,str.c_str());
00377         return NULL;
00378     }
00379     catch(...)  // catch the rest!
00380     {
00381         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00382         return NULL;
00383     }
00384 #endif
00385 }
00386 
00387 // openTransaction() callback and implementer
00388 // PyObject*  DocumentPy::openTransaction(PyObject *args){};
00389 // has to be implemented in DocumentPyImp.cpp
00390 PyObject * DocumentPy::staticCallback_openTransaction (PyObject *self, PyObject *args)
00391 {
00392     // test if twin object not allready deleted
00393     if (!((PyObjectBase*) self)->isValid()){
00394         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00395         return NULL;
00396     }
00397 
00398     // test if object is set Const
00399     if (((PyObjectBase*) self)->isConst()){
00400         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00401         return NULL;
00402     }
00403 
00404     try { // catches all exceptions coming up from c++ and generate a python exception
00405         PyObject* ret = ((DocumentPy*)self)->openTransaction(args);
00406         if (ret != 0)
00407             ((DocumentPy*)self)->startNotify();
00408         return ret;
00409     }
00410     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00411     {
00412         std::string str;
00413         str += "FreeCAD exception thrown (";
00414         str += e.what();
00415         str += ")";
00416         e.ReportException();
00417         PyErr_SetString(PyExc_Exception,str.c_str());
00418         return NULL;
00419     }
00420     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00421     {
00422         std::string str;
00423         str += "File system exception thrown (";
00424         //str += e.who();
00425         //str += ", ";
00426         str += e.what();
00427         str += ")\n";
00428         Base::Console().Error(str.c_str());
00429         PyErr_SetString(PyExc_Exception,str.c_str());
00430         return NULL;
00431     }
00432     catch(const Py::Exception&)
00433     {
00434         // The exception text is already set
00435         return NULL;
00436     }
00437     catch(const char* e) // catch simple string exceptions
00438     {
00439         Base::Console().Error(e);
00440         PyErr_SetString(PyExc_Exception,e);
00441         return NULL;
00442     }
00443     // in debug not all exceptions will be catched to get the attention of the developer!
00444 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00445     catch(const std::exception& e) // catch other c++ exceptions
00446     {
00447         std::string str;
00448         str += "FC++ exception thrown (";
00449         str += e.what();
00450         str += ")";
00451         Base::Console().Error(str.c_str());
00452         PyErr_SetString(PyExc_Exception,str.c_str());
00453         return NULL;
00454     }
00455     catch(...)  // catch the rest!
00456     {
00457         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00458         return NULL;
00459     }
00460 #endif
00461 }
00462 
00463 // abortTransaction() callback and implementer
00464 // PyObject*  DocumentPy::abortTransaction(PyObject *args){};
00465 // has to be implemented in DocumentPyImp.cpp
00466 PyObject * DocumentPy::staticCallback_abortTransaction (PyObject *self, PyObject *args)
00467 {
00468     // test if twin object not allready deleted
00469     if (!((PyObjectBase*) self)->isValid()){
00470         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00471         return NULL;
00472     }
00473 
00474     // test if object is set Const
00475     if (((PyObjectBase*) self)->isConst()){
00476         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00477         return NULL;
00478     }
00479 
00480     try { // catches all exceptions coming up from c++ and generate a python exception
00481         PyObject* ret = ((DocumentPy*)self)->abortTransaction(args);
00482         if (ret != 0)
00483             ((DocumentPy*)self)->startNotify();
00484         return ret;
00485     }
00486     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00487     {
00488         std::string str;
00489         str += "FreeCAD exception thrown (";
00490         str += e.what();
00491         str += ")";
00492         e.ReportException();
00493         PyErr_SetString(PyExc_Exception,str.c_str());
00494         return NULL;
00495     }
00496     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00497     {
00498         std::string str;
00499         str += "File system exception thrown (";
00500         //str += e.who();
00501         //str += ", ";
00502         str += e.what();
00503         str += ")\n";
00504         Base::Console().Error(str.c_str());
00505         PyErr_SetString(PyExc_Exception,str.c_str());
00506         return NULL;
00507     }
00508     catch(const Py::Exception&)
00509     {
00510         // The exception text is already set
00511         return NULL;
00512     }
00513     catch(const char* e) // catch simple string exceptions
00514     {
00515         Base::Console().Error(e);
00516         PyErr_SetString(PyExc_Exception,e);
00517         return NULL;
00518     }
00519     // in debug not all exceptions will be catched to get the attention of the developer!
00520 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00521     catch(const std::exception& e) // catch other c++ exceptions
00522     {
00523         std::string str;
00524         str += "FC++ exception thrown (";
00525         str += e.what();
00526         str += ")";
00527         Base::Console().Error(str.c_str());
00528         PyErr_SetString(PyExc_Exception,str.c_str());
00529         return NULL;
00530     }
00531     catch(...)  // catch the rest!
00532     {
00533         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00534         return NULL;
00535     }
00536 #endif
00537 }
00538 
00539 // commitTransaction() callback and implementer
00540 // PyObject*  DocumentPy::commitTransaction(PyObject *args){};
00541 // has to be implemented in DocumentPyImp.cpp
00542 PyObject * DocumentPy::staticCallback_commitTransaction (PyObject *self, PyObject *args)
00543 {
00544     // test if twin object not allready deleted
00545     if (!((PyObjectBase*) self)->isValid()){
00546         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00547         return NULL;
00548     }
00549 
00550     // test if object is set Const
00551     if (((PyObjectBase*) self)->isConst()){
00552         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00553         return NULL;
00554     }
00555 
00556     try { // catches all exceptions coming up from c++ and generate a python exception
00557         PyObject* ret = ((DocumentPy*)self)->commitTransaction(args);
00558         if (ret != 0)
00559             ((DocumentPy*)self)->startNotify();
00560         return ret;
00561     }
00562     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00563     {
00564         std::string str;
00565         str += "FreeCAD exception thrown (";
00566         str += e.what();
00567         str += ")";
00568         e.ReportException();
00569         PyErr_SetString(PyExc_Exception,str.c_str());
00570         return NULL;
00571     }
00572     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00573     {
00574         std::string str;
00575         str += "File system exception thrown (";
00576         //str += e.who();
00577         //str += ", ";
00578         str += e.what();
00579         str += ")\n";
00580         Base::Console().Error(str.c_str());
00581         PyErr_SetString(PyExc_Exception,str.c_str());
00582         return NULL;
00583     }
00584     catch(const Py::Exception&)
00585     {
00586         // The exception text is already set
00587         return NULL;
00588     }
00589     catch(const char* e) // catch simple string exceptions
00590     {
00591         Base::Console().Error(e);
00592         PyErr_SetString(PyExc_Exception,e);
00593         return NULL;
00594     }
00595     // in debug not all exceptions will be catched to get the attention of the developer!
00596 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00597     catch(const std::exception& e) // catch other c++ exceptions
00598     {
00599         std::string str;
00600         str += "FC++ exception thrown (";
00601         str += e.what();
00602         str += ")";
00603         Base::Console().Error(str.c_str());
00604         PyErr_SetString(PyExc_Exception,str.c_str());
00605         return NULL;
00606     }
00607     catch(...)  // catch the rest!
00608     {
00609         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00610         return NULL;
00611     }
00612 #endif
00613 }
00614 
00615 // addObject() callback and implementer
00616 // PyObject*  DocumentPy::addObject(PyObject *args){};
00617 // has to be implemented in DocumentPyImp.cpp
00618 PyObject * DocumentPy::staticCallback_addObject (PyObject *self, PyObject *args)
00619 {
00620     // test if twin object not allready deleted
00621     if (!((PyObjectBase*) self)->isValid()){
00622         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00623         return NULL;
00624     }
00625 
00626     // test if object is set Const
00627     if (((PyObjectBase*) self)->isConst()){
00628         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00629         return NULL;
00630     }
00631 
00632     try { // catches all exceptions coming up from c++ and generate a python exception
00633         PyObject* ret = ((DocumentPy*)self)->addObject(args);
00634         if (ret != 0)
00635             ((DocumentPy*)self)->startNotify();
00636         return ret;
00637     }
00638     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00639     {
00640         std::string str;
00641         str += "FreeCAD exception thrown (";
00642         str += e.what();
00643         str += ")";
00644         e.ReportException();
00645         PyErr_SetString(PyExc_Exception,str.c_str());
00646         return NULL;
00647     }
00648     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00649     {
00650         std::string str;
00651         str += "File system exception thrown (";
00652         //str += e.who();
00653         //str += ", ";
00654         str += e.what();
00655         str += ")\n";
00656         Base::Console().Error(str.c_str());
00657         PyErr_SetString(PyExc_Exception,str.c_str());
00658         return NULL;
00659     }
00660     catch(const Py::Exception&)
00661     {
00662         // The exception text is already set
00663         return NULL;
00664     }
00665     catch(const char* e) // catch simple string exceptions
00666     {
00667         Base::Console().Error(e);
00668         PyErr_SetString(PyExc_Exception,e);
00669         return NULL;
00670     }
00671     // in debug not all exceptions will be catched to get the attention of the developer!
00672 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00673     catch(const std::exception& e) // catch other c++ exceptions
00674     {
00675         std::string str;
00676         str += "FC++ exception thrown (";
00677         str += e.what();
00678         str += ")";
00679         Base::Console().Error(str.c_str());
00680         PyErr_SetString(PyExc_Exception,str.c_str());
00681         return NULL;
00682     }
00683     catch(...)  // catch the rest!
00684     {
00685         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00686         return NULL;
00687     }
00688 #endif
00689 }
00690 
00691 // removeObject() callback and implementer
00692 // PyObject*  DocumentPy::removeObject(PyObject *args){};
00693 // has to be implemented in DocumentPyImp.cpp
00694 PyObject * DocumentPy::staticCallback_removeObject (PyObject *self, PyObject *args)
00695 {
00696     // test if twin object not allready deleted
00697     if (!((PyObjectBase*) self)->isValid()){
00698         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00699         return NULL;
00700     }
00701 
00702     // test if object is set Const
00703     if (((PyObjectBase*) self)->isConst()){
00704         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00705         return NULL;
00706     }
00707 
00708     try { // catches all exceptions coming up from c++ and generate a python exception
00709         PyObject* ret = ((DocumentPy*)self)->removeObject(args);
00710         if (ret != 0)
00711             ((DocumentPy*)self)->startNotify();
00712         return ret;
00713     }
00714     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00715     {
00716         std::string str;
00717         str += "FreeCAD exception thrown (";
00718         str += e.what();
00719         str += ")";
00720         e.ReportException();
00721         PyErr_SetString(PyExc_Exception,str.c_str());
00722         return NULL;
00723     }
00724     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00725     {
00726         std::string str;
00727         str += "File system exception thrown (";
00728         //str += e.who();
00729         //str += ", ";
00730         str += e.what();
00731         str += ")\n";
00732         Base::Console().Error(str.c_str());
00733         PyErr_SetString(PyExc_Exception,str.c_str());
00734         return NULL;
00735     }
00736     catch(const Py::Exception&)
00737     {
00738         // The exception text is already set
00739         return NULL;
00740     }
00741     catch(const char* e) // catch simple string exceptions
00742     {
00743         Base::Console().Error(e);
00744         PyErr_SetString(PyExc_Exception,e);
00745         return NULL;
00746     }
00747     // in debug not all exceptions will be catched to get the attention of the developer!
00748 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00749     catch(const std::exception& e) // catch other c++ exceptions
00750     {
00751         std::string str;
00752         str += "FC++ exception thrown (";
00753         str += e.what();
00754         str += ")";
00755         Base::Console().Error(str.c_str());
00756         PyErr_SetString(PyExc_Exception,str.c_str());
00757         return NULL;
00758     }
00759     catch(...)  // catch the rest!
00760     {
00761         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00762         return NULL;
00763     }
00764 #endif
00765 }
00766 
00767 // copyObject() callback and implementer
00768 // PyObject*  DocumentPy::copyObject(PyObject *args){};
00769 // has to be implemented in DocumentPyImp.cpp
00770 PyObject * DocumentPy::staticCallback_copyObject (PyObject *self, PyObject *args)
00771 {
00772     // test if twin object not allready deleted
00773     if (!((PyObjectBase*) self)->isValid()){
00774         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00775         return NULL;
00776     }
00777 
00778     // test if object is set Const
00779     if (((PyObjectBase*) self)->isConst()){
00780         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00781         return NULL;
00782     }
00783 
00784     try { // catches all exceptions coming up from c++ and generate a python exception
00785         PyObject* ret = ((DocumentPy*)self)->copyObject(args);
00786         if (ret != 0)
00787             ((DocumentPy*)self)->startNotify();
00788         return ret;
00789     }
00790     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00791     {
00792         std::string str;
00793         str += "FreeCAD exception thrown (";
00794         str += e.what();
00795         str += ")";
00796         e.ReportException();
00797         PyErr_SetString(PyExc_Exception,str.c_str());
00798         return NULL;
00799     }
00800     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00801     {
00802         std::string str;
00803         str += "File system exception thrown (";
00804         //str += e.who();
00805         //str += ", ";
00806         str += e.what();
00807         str += ")\n";
00808         Base::Console().Error(str.c_str());
00809         PyErr_SetString(PyExc_Exception,str.c_str());
00810         return NULL;
00811     }
00812     catch(const Py::Exception&)
00813     {
00814         // The exception text is already set
00815         return NULL;
00816     }
00817     catch(const char* e) // catch simple string exceptions
00818     {
00819         Base::Console().Error(e);
00820         PyErr_SetString(PyExc_Exception,e);
00821         return NULL;
00822     }
00823     // in debug not all exceptions will be catched to get the attention of the developer!
00824 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00825     catch(const std::exception& e) // catch other c++ exceptions
00826     {
00827         std::string str;
00828         str += "FC++ exception thrown (";
00829         str += e.what();
00830         str += ")";
00831         Base::Console().Error(str.c_str());
00832         PyErr_SetString(PyExc_Exception,str.c_str());
00833         return NULL;
00834     }
00835     catch(...)  // catch the rest!
00836     {
00837         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00838         return NULL;
00839     }
00840 #endif
00841 }
00842 
00843 // moveObject() callback and implementer
00844 // PyObject*  DocumentPy::moveObject(PyObject *args){};
00845 // has to be implemented in DocumentPyImp.cpp
00846 PyObject * DocumentPy::staticCallback_moveObject (PyObject *self, PyObject *args)
00847 {
00848     // test if twin object not allready deleted
00849     if (!((PyObjectBase*) self)->isValid()){
00850         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00851         return NULL;
00852     }
00853 
00854     // test if object is set Const
00855     if (((PyObjectBase*) self)->isConst()){
00856         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00857         return NULL;
00858     }
00859 
00860     try { // catches all exceptions coming up from c++ and generate a python exception
00861         PyObject* ret = ((DocumentPy*)self)->moveObject(args);
00862         if (ret != 0)
00863             ((DocumentPy*)self)->startNotify();
00864         return ret;
00865     }
00866     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00867     {
00868         std::string str;
00869         str += "FreeCAD exception thrown (";
00870         str += e.what();
00871         str += ")";
00872         e.ReportException();
00873         PyErr_SetString(PyExc_Exception,str.c_str());
00874         return NULL;
00875     }
00876     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00877     {
00878         std::string str;
00879         str += "File system exception thrown (";
00880         //str += e.who();
00881         //str += ", ";
00882         str += e.what();
00883         str += ")\n";
00884         Base::Console().Error(str.c_str());
00885         PyErr_SetString(PyExc_Exception,str.c_str());
00886         return NULL;
00887     }
00888     catch(const Py::Exception&)
00889     {
00890         // The exception text is already set
00891         return NULL;
00892     }
00893     catch(const char* e) // catch simple string exceptions
00894     {
00895         Base::Console().Error(e);
00896         PyErr_SetString(PyExc_Exception,e);
00897         return NULL;
00898     }
00899     // in debug not all exceptions will be catched to get the attention of the developer!
00900 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00901     catch(const std::exception& e) // catch other c++ exceptions
00902     {
00903         std::string str;
00904         str += "FC++ exception thrown (";
00905         str += e.what();
00906         str += ")";
00907         Base::Console().Error(str.c_str());
00908         PyErr_SetString(PyExc_Exception,str.c_str());
00909         return NULL;
00910     }
00911     catch(...)  // catch the rest!
00912     {
00913         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00914         return NULL;
00915     }
00916 #endif
00917 }
00918 
00919 // undo() callback and implementer
00920 // PyObject*  DocumentPy::undo(PyObject *args){};
00921 // has to be implemented in DocumentPyImp.cpp
00922 PyObject * DocumentPy::staticCallback_undo (PyObject *self, PyObject *args)
00923 {
00924     // test if twin object not allready deleted
00925     if (!((PyObjectBase*) self)->isValid()){
00926         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00927         return NULL;
00928     }
00929 
00930     // test if object is set Const
00931     if (((PyObjectBase*) self)->isConst()){
00932         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00933         return NULL;
00934     }
00935 
00936     try { // catches all exceptions coming up from c++ and generate a python exception
00937         PyObject* ret = ((DocumentPy*)self)->undo(args);
00938         if (ret != 0)
00939             ((DocumentPy*)self)->startNotify();
00940         return ret;
00941     }
00942     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00943     {
00944         std::string str;
00945         str += "FreeCAD exception thrown (";
00946         str += e.what();
00947         str += ")";
00948         e.ReportException();
00949         PyErr_SetString(PyExc_Exception,str.c_str());
00950         return NULL;
00951     }
00952     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00953     {
00954         std::string str;
00955         str += "File system exception thrown (";
00956         //str += e.who();
00957         //str += ", ";
00958         str += e.what();
00959         str += ")\n";
00960         Base::Console().Error(str.c_str());
00961         PyErr_SetString(PyExc_Exception,str.c_str());
00962         return NULL;
00963     }
00964     catch(const Py::Exception&)
00965     {
00966         // The exception text is already set
00967         return NULL;
00968     }
00969     catch(const char* e) // catch simple string exceptions
00970     {
00971         Base::Console().Error(e);
00972         PyErr_SetString(PyExc_Exception,e);
00973         return NULL;
00974     }
00975     // in debug not all exceptions will be catched to get the attention of the developer!
00976 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00977     catch(const std::exception& e) // catch other c++ exceptions
00978     {
00979         std::string str;
00980         str += "FC++ exception thrown (";
00981         str += e.what();
00982         str += ")";
00983         Base::Console().Error(str.c_str());
00984         PyErr_SetString(PyExc_Exception,str.c_str());
00985         return NULL;
00986     }
00987     catch(...)  // catch the rest!
00988     {
00989         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00990         return NULL;
00991     }
00992 #endif
00993 }
00994 
00995 // redo() callback and implementer
00996 // PyObject*  DocumentPy::redo(PyObject *args){};
00997 // has to be implemented in DocumentPyImp.cpp
00998 PyObject * DocumentPy::staticCallback_redo (PyObject *self, PyObject *args)
00999 {
01000     // test if twin object not allready deleted
01001     if (!((PyObjectBase*) self)->isValid()){
01002         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01003         return NULL;
01004     }
01005 
01006     // test if object is set Const
01007     if (((PyObjectBase*) self)->isConst()){
01008         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01009         return NULL;
01010     }
01011 
01012     try { // catches all exceptions coming up from c++ and generate a python exception
01013         PyObject* ret = ((DocumentPy*)self)->redo(args);
01014         if (ret != 0)
01015             ((DocumentPy*)self)->startNotify();
01016         return ret;
01017     }
01018     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01019     {
01020         std::string str;
01021         str += "FreeCAD exception thrown (";
01022         str += e.what();
01023         str += ")";
01024         e.ReportException();
01025         PyErr_SetString(PyExc_Exception,str.c_str());
01026         return NULL;
01027     }
01028     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01029     {
01030         std::string str;
01031         str += "File system exception thrown (";
01032         //str += e.who();
01033         //str += ", ";
01034         str += e.what();
01035         str += ")\n";
01036         Base::Console().Error(str.c_str());
01037         PyErr_SetString(PyExc_Exception,str.c_str());
01038         return NULL;
01039     }
01040     catch(const Py::Exception&)
01041     {
01042         // The exception text is already set
01043         return NULL;
01044     }
01045     catch(const char* e) // catch simple string exceptions
01046     {
01047         Base::Console().Error(e);
01048         PyErr_SetString(PyExc_Exception,e);
01049         return NULL;
01050     }
01051     // in debug not all exceptions will be catched to get the attention of the developer!
01052 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01053     catch(const std::exception& e) // catch other c++ exceptions
01054     {
01055         std::string str;
01056         str += "FC++ exception thrown (";
01057         str += e.what();
01058         str += ")";
01059         Base::Console().Error(str.c_str());
01060         PyErr_SetString(PyExc_Exception,str.c_str());
01061         return NULL;
01062     }
01063     catch(...)  // catch the rest!
01064     {
01065         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01066         return NULL;
01067     }
01068 #endif
01069 }
01070 
01071 // clearUndos() callback and implementer
01072 // PyObject*  DocumentPy::clearUndos(PyObject *args){};
01073 // has to be implemented in DocumentPyImp.cpp
01074 PyObject * DocumentPy::staticCallback_clearUndos (PyObject *self, PyObject *args)
01075 {
01076     // test if twin object not allready deleted
01077     if (!((PyObjectBase*) self)->isValid()){
01078         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01079         return NULL;
01080     }
01081 
01082     // test if object is set Const
01083     if (((PyObjectBase*) self)->isConst()){
01084         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01085         return NULL;
01086     }
01087 
01088     try { // catches all exceptions coming up from c++ and generate a python exception
01089         PyObject* ret = ((DocumentPy*)self)->clearUndos(args);
01090         if (ret != 0)
01091             ((DocumentPy*)self)->startNotify();
01092         return ret;
01093     }
01094     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01095     {
01096         std::string str;
01097         str += "FreeCAD exception thrown (";
01098         str += e.what();
01099         str += ")";
01100         e.ReportException();
01101         PyErr_SetString(PyExc_Exception,str.c_str());
01102         return NULL;
01103     }
01104     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01105     {
01106         std::string str;
01107         str += "File system exception thrown (";
01108         //str += e.who();
01109         //str += ", ";
01110         str += e.what();
01111         str += ")\n";
01112         Base::Console().Error(str.c_str());
01113         PyErr_SetString(PyExc_Exception,str.c_str());
01114         return NULL;
01115     }
01116     catch(const Py::Exception&)
01117     {
01118         // The exception text is already set
01119         return NULL;
01120     }
01121     catch(const char* e) // catch simple string exceptions
01122     {
01123         Base::Console().Error(e);
01124         PyErr_SetString(PyExc_Exception,e);
01125         return NULL;
01126     }
01127     // in debug not all exceptions will be catched to get the attention of the developer!
01128 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01129     catch(const std::exception& e) // catch other c++ exceptions
01130     {
01131         std::string str;
01132         str += "FC++ exception thrown (";
01133         str += e.what();
01134         str += ")";
01135         Base::Console().Error(str.c_str());
01136         PyErr_SetString(PyExc_Exception,str.c_str());
01137         return NULL;
01138     }
01139     catch(...)  // catch the rest!
01140     {
01141         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01142         return NULL;
01143     }
01144 #endif
01145 }
01146 
01147 // recompute() callback and implementer
01148 // PyObject*  DocumentPy::recompute(PyObject *args){};
01149 // has to be implemented in DocumentPyImp.cpp
01150 PyObject * DocumentPy::staticCallback_recompute (PyObject *self, PyObject *args)
01151 {
01152     // test if twin object not allready deleted
01153     if (!((PyObjectBase*) self)->isValid()){
01154         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01155         return NULL;
01156     }
01157 
01158     // test if object is set Const
01159     if (((PyObjectBase*) self)->isConst()){
01160         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01161         return NULL;
01162     }
01163 
01164     try { // catches all exceptions coming up from c++ and generate a python exception
01165         PyObject* ret = ((DocumentPy*)self)->recompute(args);
01166         if (ret != 0)
01167             ((DocumentPy*)self)->startNotify();
01168         return ret;
01169     }
01170     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01171     {
01172         std::string str;
01173         str += "FreeCAD exception thrown (";
01174         str += e.what();
01175         str += ")";
01176         e.ReportException();
01177         PyErr_SetString(PyExc_Exception,str.c_str());
01178         return NULL;
01179     }
01180     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01181     {
01182         std::string str;
01183         str += "File system exception thrown (";
01184         //str += e.who();
01185         //str += ", ";
01186         str += e.what();
01187         str += ")\n";
01188         Base::Console().Error(str.c_str());
01189         PyErr_SetString(PyExc_Exception,str.c_str());
01190         return NULL;
01191     }
01192     catch(const Py::Exception&)
01193     {
01194         // The exception text is already set
01195         return NULL;
01196     }
01197     catch(const char* e) // catch simple string exceptions
01198     {
01199         Base::Console().Error(e);
01200         PyErr_SetString(PyExc_Exception,e);
01201         return NULL;
01202     }
01203     // in debug not all exceptions will be catched to get the attention of the developer!
01204 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01205     catch(const std::exception& e) // catch other c++ exceptions
01206     {
01207         std::string str;
01208         str += "FC++ exception thrown (";
01209         str += e.what();
01210         str += ")";
01211         Base::Console().Error(str.c_str());
01212         PyErr_SetString(PyExc_Exception,str.c_str());
01213         return NULL;
01214     }
01215     catch(...)  // catch the rest!
01216     {
01217         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01218         return NULL;
01219     }
01220 #endif
01221 }
01222 
01223 // getObject() callback and implementer
01224 // PyObject*  DocumentPy::getObject(PyObject *args){};
01225 // has to be implemented in DocumentPyImp.cpp
01226 PyObject * DocumentPy::staticCallback_getObject (PyObject *self, PyObject *args)
01227 {
01228     // test if twin object not allready deleted
01229     if (!((PyObjectBase*) self)->isValid()){
01230         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01231         return NULL;
01232     }
01233 
01234     // test if object is set Const
01235     if (((PyObjectBase*) self)->isConst()){
01236         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01237         return NULL;
01238     }
01239 
01240     try { // catches all exceptions coming up from c++ and generate a python exception
01241         PyObject* ret = ((DocumentPy*)self)->getObject(args);
01242         if (ret != 0)
01243             ((DocumentPy*)self)->startNotify();
01244         return ret;
01245     }
01246     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01247     {
01248         std::string str;
01249         str += "FreeCAD exception thrown (";
01250         str += e.what();
01251         str += ")";
01252         e.ReportException();
01253         PyErr_SetString(PyExc_Exception,str.c_str());
01254         return NULL;
01255     }
01256     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01257     {
01258         std::string str;
01259         str += "File system exception thrown (";
01260         //str += e.who();
01261         //str += ", ";
01262         str += e.what();
01263         str += ")\n";
01264         Base::Console().Error(str.c_str());
01265         PyErr_SetString(PyExc_Exception,str.c_str());
01266         return NULL;
01267     }
01268     catch(const Py::Exception&)
01269     {
01270         // The exception text is already set
01271         return NULL;
01272     }
01273     catch(const char* e) // catch simple string exceptions
01274     {
01275         Base::Console().Error(e);
01276         PyErr_SetString(PyExc_Exception,e);
01277         return NULL;
01278     }
01279     // in debug not all exceptions will be catched to get the attention of the developer!
01280 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01281     catch(const std::exception& e) // catch other c++ exceptions
01282     {
01283         std::string str;
01284         str += "FC++ exception thrown (";
01285         str += e.what();
01286         str += ")";
01287         Base::Console().Error(str.c_str());
01288         PyErr_SetString(PyExc_Exception,str.c_str());
01289         return NULL;
01290     }
01291     catch(...)  // catch the rest!
01292     {
01293         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01294         return NULL;
01295     }
01296 #endif
01297 }
01298 
01299 // getObjectsByLabel() callback and implementer
01300 // PyObject*  DocumentPy::getObjectsByLabel(PyObject *args){};
01301 // has to be implemented in DocumentPyImp.cpp
01302 PyObject * DocumentPy::staticCallback_getObjectsByLabel (PyObject *self, PyObject *args)
01303 {
01304     // test if twin object not allready deleted
01305     if (!((PyObjectBase*) self)->isValid()){
01306         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01307         return NULL;
01308     }
01309 
01310     // test if object is set Const
01311     if (((PyObjectBase*) self)->isConst()){
01312         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01313         return NULL;
01314     }
01315 
01316     try { // catches all exceptions coming up from c++ and generate a python exception
01317         PyObject* ret = ((DocumentPy*)self)->getObjectsByLabel(args);
01318         if (ret != 0)
01319             ((DocumentPy*)self)->startNotify();
01320         return ret;
01321     }
01322     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01323     {
01324         std::string str;
01325         str += "FreeCAD exception thrown (";
01326         str += e.what();
01327         str += ")";
01328         e.ReportException();
01329         PyErr_SetString(PyExc_Exception,str.c_str());
01330         return NULL;
01331     }
01332     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01333     {
01334         std::string str;
01335         str += "File system exception thrown (";
01336         //str += e.who();
01337         //str += ", ";
01338         str += e.what();
01339         str += ")\n";
01340         Base::Console().Error(str.c_str());
01341         PyErr_SetString(PyExc_Exception,str.c_str());
01342         return NULL;
01343     }
01344     catch(const Py::Exception&)
01345     {
01346         // The exception text is already set
01347         return NULL;
01348     }
01349     catch(const char* e) // catch simple string exceptions
01350     {
01351         Base::Console().Error(e);
01352         PyErr_SetString(PyExc_Exception,e);
01353         return NULL;
01354     }
01355     // in debug not all exceptions will be catched to get the attention of the developer!
01356 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01357     catch(const std::exception& e) // catch other c++ exceptions
01358     {
01359         std::string str;
01360         str += "FC++ exception thrown (";
01361         str += e.what();
01362         str += ")";
01363         Base::Console().Error(str.c_str());
01364         PyErr_SetString(PyExc_Exception,str.c_str());
01365         return NULL;
01366     }
01367     catch(...)  // catch the rest!
01368     {
01369         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01370         return NULL;
01371     }
01372 #endif
01373 }
01374 
01375 // findObjects() callback and implementer
01376 // PyObject*  DocumentPy::findObjects(PyObject *args){};
01377 // has to be implemented in DocumentPyImp.cpp
01378 PyObject * DocumentPy::staticCallback_findObjects (PyObject *self, PyObject *args)
01379 {
01380     // test if twin object not allready deleted
01381     if (!((PyObjectBase*) self)->isValid()){
01382         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01383         return NULL;
01384     }
01385 
01386     // test if object is set Const
01387     if (((PyObjectBase*) self)->isConst()){
01388         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01389         return NULL;
01390     }
01391 
01392     try { // catches all exceptions coming up from c++ and generate a python exception
01393         PyObject* ret = ((DocumentPy*)self)->findObjects(args);
01394         if (ret != 0)
01395             ((DocumentPy*)self)->startNotify();
01396         return ret;
01397     }
01398     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01399     {
01400         std::string str;
01401         str += "FreeCAD exception thrown (";
01402         str += e.what();
01403         str += ")";
01404         e.ReportException();
01405         PyErr_SetString(PyExc_Exception,str.c_str());
01406         return NULL;
01407     }
01408     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01409     {
01410         std::string str;
01411         str += "File system exception thrown (";
01412         //str += e.who();
01413         //str += ", ";
01414         str += e.what();
01415         str += ")\n";
01416         Base::Console().Error(str.c_str());
01417         PyErr_SetString(PyExc_Exception,str.c_str());
01418         return NULL;
01419     }
01420     catch(const Py::Exception&)
01421     {
01422         // The exception text is already set
01423         return NULL;
01424     }
01425     catch(const char* e) // catch simple string exceptions
01426     {
01427         Base::Console().Error(e);
01428         PyErr_SetString(PyExc_Exception,e);
01429         return NULL;
01430     }
01431     // in debug not all exceptions will be catched to get the attention of the developer!
01432 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01433     catch(const std::exception& e) // catch other c++ exceptions
01434     {
01435         std::string str;
01436         str += "FC++ exception thrown (";
01437         str += e.what();
01438         str += ")";
01439         Base::Console().Error(str.c_str());
01440         PyErr_SetString(PyExc_Exception,str.c_str());
01441         return NULL;
01442     }
01443     catch(...)  // catch the rest!
01444     {
01445         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01446         return NULL;
01447     }
01448 #endif
01449 }
01450 
01451 // supportedTypes() callback and implementer
01452 // PyObject*  DocumentPy::supportedTypes(PyObject *args){};
01453 // has to be implemented in DocumentPyImp.cpp
01454 PyObject * DocumentPy::staticCallback_supportedTypes (PyObject *self, PyObject *args)
01455 {
01456     // test if twin object not allready deleted
01457     if (!((PyObjectBase*) self)->isValid()){
01458         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01459         return NULL;
01460     }
01461 
01462     // test if object is set Const
01463     if (((PyObjectBase*) self)->isConst()){
01464         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01465         return NULL;
01466     }
01467 
01468     try { // catches all exceptions coming up from c++ and generate a python exception
01469         PyObject* ret = ((DocumentPy*)self)->supportedTypes(args);
01470         if (ret != 0)
01471             ((DocumentPy*)self)->startNotify();
01472         return ret;
01473     }
01474     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01475     {
01476         std::string str;
01477         str += "FreeCAD exception thrown (";
01478         str += e.what();
01479         str += ")";
01480         e.ReportException();
01481         PyErr_SetString(PyExc_Exception,str.c_str());
01482         return NULL;
01483     }
01484     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01485     {
01486         std::string str;
01487         str += "File system exception thrown (";
01488         //str += e.who();
01489         //str += ", ";
01490         str += e.what();
01491         str += ")\n";
01492         Base::Console().Error(str.c_str());
01493         PyErr_SetString(PyExc_Exception,str.c_str());
01494         return NULL;
01495     }
01496     catch(const Py::Exception&)
01497     {
01498         // The exception text is already set
01499         return NULL;
01500     }
01501     catch(const char* e) // catch simple string exceptions
01502     {
01503         Base::Console().Error(e);
01504         PyErr_SetString(PyExc_Exception,e);
01505         return NULL;
01506     }
01507     // in debug not all exceptions will be catched to get the attention of the developer!
01508 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01509     catch(const std::exception& e) // catch other c++ exceptions
01510     {
01511         std::string str;
01512         str += "FC++ exception thrown (";
01513         str += e.what();
01514         str += ")";
01515         Base::Console().Error(str.c_str());
01516         PyErr_SetString(PyExc_Exception,str.c_str());
01517         return NULL;
01518     }
01519     catch(...)  // catch the rest!
01520     {
01521         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01522         return NULL;
01523     }
01524 #endif
01525 }
01526 
01527 // getTempFileName() callback and implementer
01528 // PyObject*  DocumentPy::getTempFileName(PyObject *args){};
01529 // has to be implemented in DocumentPyImp.cpp
01530 PyObject * DocumentPy::staticCallback_getTempFileName (PyObject *self, PyObject *args)
01531 {
01532     // test if twin object not allready deleted
01533     if (!((PyObjectBase*) self)->isValid()){
01534         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01535         return NULL;
01536     }
01537 
01538     // test if object is set Const
01539     if (((PyObjectBase*) self)->isConst()){
01540         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01541         return NULL;
01542     }
01543 
01544     try { // catches all exceptions coming up from c++ and generate a python exception
01545         PyObject* ret = ((DocumentPy*)self)->getTempFileName(args);
01546         if (ret != 0)
01547             ((DocumentPy*)self)->startNotify();
01548         return ret;
01549     }
01550     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01551     {
01552         std::string str;
01553         str += "FreeCAD exception thrown (";
01554         str += e.what();
01555         str += ")";
01556         e.ReportException();
01557         PyErr_SetString(PyExc_Exception,str.c_str());
01558         return NULL;
01559     }
01560     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01561     {
01562         std::string str;
01563         str += "File system exception thrown (";
01564         //str += e.who();
01565         //str += ", ";
01566         str += e.what();
01567         str += ")\n";
01568         Base::Console().Error(str.c_str());
01569         PyErr_SetString(PyExc_Exception,str.c_str());
01570         return NULL;
01571     }
01572     catch(const Py::Exception&)
01573     {
01574         // The exception text is already set
01575         return NULL;
01576     }
01577     catch(const char* e) // catch simple string exceptions
01578     {
01579         Base::Console().Error(e);
01580         PyErr_SetString(PyExc_Exception,e);
01581         return NULL;
01582     }
01583     // in debug not all exceptions will be catched to get the attention of the developer!
01584 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01585     catch(const std::exception& e) // catch other c++ exceptions
01586     {
01587         std::string str;
01588         str += "FC++ exception thrown (";
01589         str += e.what();
01590         str += ")";
01591         Base::Console().Error(str.c_str());
01592         PyErr_SetString(PyExc_Exception,str.c_str());
01593         return NULL;
01594     }
01595     catch(...)  // catch the rest!
01596     {
01597         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01598         return NULL;
01599     }
01600 #endif
01601 }
01602 
01603 // DependencyGraph() callback and implementer
01604 // PyObject*  DocumentPy::DependencyGraph(PyObject *args){};
01605 // has to be implemented in DocumentPyImp.cpp
01606 PyObject * DocumentPy::staticCallback_getDependencyGraph (PyObject *self, void * /*closure*/)
01607 {
01608     if (!((PyObjectBase*) self)->isValid()){
01609         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01610         return NULL;
01611     }
01612 
01613     try {
01614         return Py::new_reference_to(((DocumentPy*)self)->getDependencyGraph());
01615     } catch (const Py::Exception&) {
01616         // The exception text is already set
01617         return NULL;
01618     } catch (...) {
01619         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'DependencyGraph' of object 'Document'");
01620         return NULL;
01621     }
01622 }
01623 
01624 int DocumentPy::staticCallback_setDependencyGraph (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01625 {
01626     if (!((PyObjectBase*) self)->isValid()){
01627         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01628         return -1;
01629     }
01630 
01631     PyErr_SetString(PyExc_AttributeError, "Attribute 'DependencyGraph' of object 'Document' is read-only");
01632     return -1;
01633 }
01634 
01635 // ActiveObject() callback and implementer
01636 // PyObject*  DocumentPy::ActiveObject(PyObject *args){};
01637 // has to be implemented in DocumentPyImp.cpp
01638 PyObject * DocumentPy::staticCallback_getActiveObject (PyObject *self, void * /*closure*/)
01639 {
01640     if (!((PyObjectBase*) self)->isValid()){
01641         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01642         return NULL;
01643     }
01644 
01645     try {
01646         return Py::new_reference_to(((DocumentPy*)self)->getActiveObject());
01647     } catch (const Py::Exception&) {
01648         // The exception text is already set
01649         return NULL;
01650     } catch (...) {
01651         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'ActiveObject' of object 'Document'");
01652         return NULL;
01653     }
01654 }
01655 
01656 int DocumentPy::staticCallback_setActiveObject (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01657 {
01658     if (!((PyObjectBase*) self)->isValid()){
01659         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01660         return -1;
01661     }
01662 
01663     PyErr_SetString(PyExc_AttributeError, "Attribute 'ActiveObject' of object 'Document' is read-only");
01664     return -1;
01665 }
01666 
01667 // Objects() callback and implementer
01668 // PyObject*  DocumentPy::Objects(PyObject *args){};
01669 // has to be implemented in DocumentPyImp.cpp
01670 PyObject * DocumentPy::staticCallback_getObjects (PyObject *self, void * /*closure*/)
01671 {
01672     if (!((PyObjectBase*) self)->isValid()){
01673         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01674         return NULL;
01675     }
01676 
01677     try {
01678         return Py::new_reference_to(((DocumentPy*)self)->getObjects());
01679     } catch (const Py::Exception&) {
01680         // The exception text is already set
01681         return NULL;
01682     } catch (...) {
01683         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Objects' of object 'Document'");
01684         return NULL;
01685     }
01686 }
01687 
01688 int DocumentPy::staticCallback_setObjects (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01689 {
01690     if (!((PyObjectBase*) self)->isValid()){
01691         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01692         return -1;
01693     }
01694 
01695     PyErr_SetString(PyExc_AttributeError, "Attribute 'Objects' of object 'Document' is read-only");
01696     return -1;
01697 }
01698 
01699 // UndoMode() callback and implementer
01700 // PyObject*  DocumentPy::UndoMode(PyObject *args){};
01701 // has to be implemented in DocumentPyImp.cpp
01702 PyObject * DocumentPy::staticCallback_getUndoMode (PyObject *self, void * /*closure*/)
01703 {
01704     if (!((PyObjectBase*) self)->isValid()){
01705         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01706         return NULL;
01707     }
01708 
01709     try {
01710         return Py::new_reference_to(((DocumentPy*)self)->getUndoMode());
01711     } catch (const Py::Exception&) {
01712         // The exception text is already set
01713         return NULL;
01714     } catch (...) {
01715         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'UndoMode' of object 'Document'");
01716         return NULL;
01717     }
01718 }
01719 
01720 int DocumentPy::staticCallback_setUndoMode (PyObject *self, PyObject *value, void * /*closure*/)
01721 {    
01722     if (!((PyObjectBase*) self)->isValid()){
01723         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01724         return -1;
01725     }
01726     if (((PyObjectBase*) self)->isConst()){
01727         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
01728         return -1;
01729     }
01730 
01731     try {
01732         ((DocumentPy*)self)->setUndoMode(Py::Int(value,false));
01733         return 0;
01734     } catch (const Py::Exception&) {
01735         // The exception text is already set
01736         return -1;
01737     } catch (...) {
01738         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'UndoMode' of object 'Document'");
01739         return -1;
01740     }
01741 }
01742 
01743 // UndoRedoMemSize() callback and implementer
01744 // PyObject*  DocumentPy::UndoRedoMemSize(PyObject *args){};
01745 // has to be implemented in DocumentPyImp.cpp
01746 PyObject * DocumentPy::staticCallback_getUndoRedoMemSize (PyObject *self, void * /*closure*/)
01747 {
01748     if (!((PyObjectBase*) self)->isValid()){
01749         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01750         return NULL;
01751     }
01752 
01753     try {
01754         return Py::new_reference_to(((DocumentPy*)self)->getUndoRedoMemSize());
01755     } catch (const Py::Exception&) {
01756         // The exception text is already set
01757         return NULL;
01758     } catch (...) {
01759         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'UndoRedoMemSize' of object 'Document'");
01760         return NULL;
01761     }
01762 }
01763 
01764 int DocumentPy::staticCallback_setUndoRedoMemSize (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01765 {
01766     if (!((PyObjectBase*) self)->isValid()){
01767         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01768         return -1;
01769     }
01770 
01771     PyErr_SetString(PyExc_AttributeError, "Attribute 'UndoRedoMemSize' of object 'Document' is read-only");
01772     return -1;
01773 }
01774 
01775 // UndoCount() callback and implementer
01776 // PyObject*  DocumentPy::UndoCount(PyObject *args){};
01777 // has to be implemented in DocumentPyImp.cpp
01778 PyObject * DocumentPy::staticCallback_getUndoCount (PyObject *self, void * /*closure*/)
01779 {
01780     if (!((PyObjectBase*) self)->isValid()){
01781         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01782         return NULL;
01783     }
01784 
01785     try {
01786         return Py::new_reference_to(((DocumentPy*)self)->getUndoCount());
01787     } catch (const Py::Exception&) {
01788         // The exception text is already set
01789         return NULL;
01790     } catch (...) {
01791         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'UndoCount' of object 'Document'");
01792         return NULL;
01793     }
01794 }
01795 
01796 int DocumentPy::staticCallback_setUndoCount (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01797 {
01798     if (!((PyObjectBase*) self)->isValid()){
01799         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01800         return -1;
01801     }
01802 
01803     PyErr_SetString(PyExc_AttributeError, "Attribute 'UndoCount' of object 'Document' is read-only");
01804     return -1;
01805 }
01806 
01807 // RedoCount() callback and implementer
01808 // PyObject*  DocumentPy::RedoCount(PyObject *args){};
01809 // has to be implemented in DocumentPyImp.cpp
01810 PyObject * DocumentPy::staticCallback_getRedoCount (PyObject *self, void * /*closure*/)
01811 {
01812     if (!((PyObjectBase*) self)->isValid()){
01813         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01814         return NULL;
01815     }
01816 
01817     try {
01818         return Py::new_reference_to(((DocumentPy*)self)->getRedoCount());
01819     } catch (const Py::Exception&) {
01820         // The exception text is already set
01821         return NULL;
01822     } catch (...) {
01823         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'RedoCount' of object 'Document'");
01824         return NULL;
01825     }
01826 }
01827 
01828 int DocumentPy::staticCallback_setRedoCount (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01829 {
01830     if (!((PyObjectBase*) self)->isValid()){
01831         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01832         return -1;
01833     }
01834 
01835     PyErr_SetString(PyExc_AttributeError, "Attribute 'RedoCount' of object 'Document' is read-only");
01836     return -1;
01837 }
01838 
01839 // UndoNames() callback and implementer
01840 // PyObject*  DocumentPy::UndoNames(PyObject *args){};
01841 // has to be implemented in DocumentPyImp.cpp
01842 PyObject * DocumentPy::staticCallback_getUndoNames (PyObject *self, void * /*closure*/)
01843 {
01844     if (!((PyObjectBase*) self)->isValid()){
01845         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01846         return NULL;
01847     }
01848 
01849     try {
01850         return Py::new_reference_to(((DocumentPy*)self)->getUndoNames());
01851     } catch (const Py::Exception&) {
01852         // The exception text is already set
01853         return NULL;
01854     } catch (...) {
01855         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'UndoNames' of object 'Document'");
01856         return NULL;
01857     }
01858 }
01859 
01860 int DocumentPy::staticCallback_setUndoNames (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01861 {
01862     if (!((PyObjectBase*) self)->isValid()){
01863         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01864         return -1;
01865     }
01866 
01867     PyErr_SetString(PyExc_AttributeError, "Attribute 'UndoNames' of object 'Document' is read-only");
01868     return -1;
01869 }
01870 
01871 // RedoNames() callback and implementer
01872 // PyObject*  DocumentPy::RedoNames(PyObject *args){};
01873 // has to be implemented in DocumentPyImp.cpp
01874 PyObject * DocumentPy::staticCallback_getRedoNames (PyObject *self, void * /*closure*/)
01875 {
01876     if (!((PyObjectBase*) self)->isValid()){
01877         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01878         return NULL;
01879     }
01880 
01881     try {
01882         return Py::new_reference_to(((DocumentPy*)self)->getRedoNames());
01883     } catch (const Py::Exception&) {
01884         // The exception text is already set
01885         return NULL;
01886     } catch (...) {
01887         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'RedoNames' of object 'Document'");
01888         return NULL;
01889     }
01890 }
01891 
01892 int DocumentPy::staticCallback_setRedoNames (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01893 {
01894     if (!((PyObjectBase*) self)->isValid()){
01895         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01896         return -1;
01897     }
01898 
01899     PyErr_SetString(PyExc_AttributeError, "Attribute 'RedoNames' of object 'Document' is read-only");
01900     return -1;
01901 }
01902 
01903 // Name() callback and implementer
01904 // PyObject*  DocumentPy::Name(PyObject *args){};
01905 // has to be implemented in DocumentPyImp.cpp
01906 PyObject * DocumentPy::staticCallback_getName (PyObject *self, void * /*closure*/)
01907 {
01908     if (!((PyObjectBase*) self)->isValid()){
01909         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01910         return NULL;
01911     }
01912 
01913     try {
01914         return Py::new_reference_to(((DocumentPy*)self)->getName());
01915     } catch (const Py::Exception&) {
01916         // The exception text is already set
01917         return NULL;
01918     } catch (...) {
01919         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Name' of object 'Document'");
01920         return NULL;
01921     }
01922 }
01923 
01924 int DocumentPy::staticCallback_setName (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01925 {
01926     if (!((PyObjectBase*) self)->isValid()){
01927         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01928         return -1;
01929     }
01930 
01931     PyErr_SetString(PyExc_AttributeError, "Attribute 'Name' of object 'Document' is read-only");
01932     return -1;
01933 }
01934 
01935 
01936 
01937 //--------------------------------------------------------------------------
01938 // Parents structure
01939 //--------------------------------------------------------------------------
01940 PyParentObject DocumentPy::Parents[] = { PARENTSAppDocumentPy };
01941 
01942 //--------------------------------------------------------------------------
01943 // Constructor
01944 //--------------------------------------------------------------------------
01945 DocumentPy::DocumentPy(Document *pcObject, PyTypeObject *T)
01946     : PropertyContainerPy(reinterpret_cast<PropertyContainerPy::PointerType>(pcObject), T)
01947 {
01948 }
01949 
01950 PyObject *DocumentPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
01951 {
01952     // never create such objects with the constructor
01953     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'DocumentPy'.");
01954  
01955     return 0;
01956 }
01957 
01958 int DocumentPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
01959 {
01960     return 0;
01961 }
01962 
01963 //--------------------------------------------------------------------------
01964 // destructor
01965 //--------------------------------------------------------------------------
01966 DocumentPy::~DocumentPy()                                // Everything handled in parent
01967 {
01968 }
01969 
01970 //--------------------------------------------------------------------------
01971 // DocumentPy representation
01972 //--------------------------------------------------------------------------
01973 PyObject *DocumentPy::_repr(void)
01974 {
01975     return Py_BuildValue("s", representation().c_str());
01976 }
01977 
01978 //--------------------------------------------------------------------------
01979 // DocumentPy Attributes
01980 //--------------------------------------------------------------------------
01981 PyObject *DocumentPy::_getattr(char *attr)                              // __getattr__ function: note only need to handle new state
01982 {
01983     try {
01984         // getter method for special Attributes (e.g. dynamic ones)
01985         PyObject *r = getCustomAttributes(attr);
01986         if(r) return r;
01987     }
01988 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01989     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01990     {
01991         std::string str;
01992         str += "FreeCAD exception thrown (";
01993         str += e.what();
01994         str += ")";
01995         e.ReportException();
01996         PyErr_SetString(PyExc_Exception,str.c_str());
01997         return NULL;
01998     }
01999     catch(const std::exception& e) // catch other c++ exceptions
02000     {
02001         std::string str;
02002         str += "FC++ exception thrown (";
02003         str += e.what();
02004         str += ")";
02005         Base::Console().Error(str.c_str());
02006         PyErr_SetString(PyExc_Exception,str.c_str());
02007         return NULL;
02008     }
02009     catch(const Py::Exception&)
02010     {
02011         // The exception text is already set
02012         return NULL;
02013     }
02014     catch(...)  // catch the rest!
02015     {
02016         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
02017         return NULL;
02018     }
02019 #else  // DONT_CATCH_CXX_EXCEPTIONS  
02020     catch(const Base::Exception& e) // catch the FreeCAD exceptions
02021     {
02022         std::string str;
02023         str += "FreeCAD exception thrown (";
02024         str += e.what();
02025         str += ")";
02026         e.ReportException();
02027         PyErr_SetString(PyExc_Exception,str.c_str());
02028         return NULL;
02029     }
02030     catch(const Py::Exception&)
02031     {
02032         // The exception text is already set
02033         return NULL;
02034     }
02035 #endif  // DONT_CATCH_CXX_EXCEPTIONS
02036 
02037     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
02038     if (rvalue == NULL)
02039     {
02040         PyErr_Clear();
02041         return PropertyContainerPy::_getattr(attr);
02042     }
02043     else
02044     {
02045         return rvalue;
02046     }
02047 }
02048 
02049 int DocumentPy::_setattr(char *attr, PyObject *value)   // __setattr__ function: note only need to handle new state
02050 {
02051     try {
02052         // setter for  special Attributes (e.g. dynamic ones)
02053         int r = setCustomAttributes(attr, value);
02054         if(r==1) return 0;
02055     }
02056 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
02057     catch(const Base::Exception& e) // catch the FreeCAD exceptions
02058     {
02059         std::string str;
02060         str += "FreeCAD exception thrown (";
02061         str += e.what();
02062         str += ")";
02063         e.ReportException();
02064         PyErr_SetString(PyExc_Exception,str.c_str());
02065         return -1;
02066     }
02067     catch(const std::exception& e) // catch other c++ exceptions
02068     {
02069         std::string str;
02070         str += "FC++ exception thrown (";
02071         str += e.what();
02072         str += ")";
02073         Base::Console().Error(str.c_str());
02074         PyErr_SetString(PyExc_Exception,str.c_str());
02075         return -1;
02076     }
02077     catch(const Py::Exception&)
02078     {
02079         // The exception text is already set
02080         return -1;
02081     }
02082     catch(...)  // catch the rest!
02083     {
02084         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
02085         return -1;
02086     }
02087 #else  // DONT_CATCH_CXX_EXCEPTIONS  
02088     catch(const Base::Exception& e) // catch the FreeCAD exceptions
02089     {
02090         std::string str;
02091         str += "FreeCAD exception thrown (";
02092         str += e.what();
02093         str += ")";
02094         e.ReportException();
02095         PyErr_SetString(PyExc_Exception,str.c_str());
02096         return -1;
02097     }
02098     catch(const Py::Exception&)
02099     {
02100         // The exception text is already set
02101         return -1;
02102     }
02103 #endif  // DONT_CATCH_CXX_EXCEPTIONS
02104 
02105     return PropertyContainerPy::_setattr(attr, value);
02106 }
02107 
02108 Document *DocumentPy::getDocumentPtr(void) const
02109 {
02110     return static_cast<Document *>(_pcTwinPointer);
02111 }
02112 
02113 #if 0
02114 /* From here on come the methods you have to implement, but NOT in this module. Implement in DocumentPyImp.cpp! This prototypes 
02115  * are just for convenience when you add a new method.
02116  */
02117 
02118 
02119 // returns a string which represents the object e.g. when printed in python
02120 std::string DocumentPy::representation(void) const
02121 {
02122     return std::string("<Document object>");
02123 }
02124 
02125 PyObject* DocumentPy::save(PyObject *args)
02126 {
02127     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02128     return 0;
02129 }
02130 
02131 PyObject* DocumentPy::restore(PyObject *args)
02132 {
02133     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02134     return 0;
02135 }
02136 
02137 PyObject* DocumentPy::openTransaction(PyObject *args)
02138 {
02139     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02140     return 0;
02141 }
02142 
02143 PyObject* DocumentPy::abortTransaction(PyObject *args)
02144 {
02145     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02146     return 0;
02147 }
02148 
02149 PyObject* DocumentPy::commitTransaction(PyObject *args)
02150 {
02151     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02152     return 0;
02153 }
02154 
02155 PyObject* DocumentPy::addObject(PyObject *args)
02156 {
02157     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02158     return 0;
02159 }
02160 
02161 PyObject* DocumentPy::removeObject(PyObject *args)
02162 {
02163     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02164     return 0;
02165 }
02166 
02167 PyObject* DocumentPy::copyObject(PyObject *args)
02168 {
02169     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02170     return 0;
02171 }
02172 
02173 PyObject* DocumentPy::moveObject(PyObject *args)
02174 {
02175     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02176     return 0;
02177 }
02178 
02179 PyObject* DocumentPy::undo(PyObject *args)
02180 {
02181     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02182     return 0;
02183 }
02184 
02185 PyObject* DocumentPy::redo(PyObject *args)
02186 {
02187     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02188     return 0;
02189 }
02190 
02191 PyObject* DocumentPy::clearUndos(PyObject *args)
02192 {
02193     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02194     return 0;
02195 }
02196 
02197 PyObject* DocumentPy::recompute(PyObject *args)
02198 {
02199     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02200     return 0;
02201 }
02202 
02203 PyObject* DocumentPy::getObject(PyObject *args)
02204 {
02205     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02206     return 0;
02207 }
02208 
02209 PyObject* DocumentPy::getObjectsByLabel(PyObject *args)
02210 {
02211     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02212     return 0;
02213 }
02214 
02215 PyObject* DocumentPy::findObjects(PyObject *args)
02216 {
02217     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02218     return 0;
02219 }
02220 
02221 PyObject* DocumentPy::supportedTypes(PyObject *args)
02222 {
02223     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02224     return 0;
02225 }
02226 
02227 PyObject* DocumentPy::getTempFileName(PyObject *args)
02228 {
02229     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
02230     return 0;
02231 }
02232 
02233 
02234 
02235 Py::String DocumentPy::getDependencyGraph(void) const
02236 {
02237     //return Py::String();
02238     throw Py::AttributeError("Not yet implemented");
02239 }
02240 
02241 Py::Object DocumentPy::getActiveObject(void) const
02242 {
02243     //return Py::Object();
02244     throw Py::AttributeError("Not yet implemented");
02245 }
02246 
02247 Py::List DocumentPy::getObjects(void) const
02248 {
02249     //return Py::List();
02250     throw Py::AttributeError("Not yet implemented");
02251 }
02252 
02253 Py::Int DocumentPy::getUndoMode(void) const
02254 {
02255     //return Py::Int();
02256     throw Py::AttributeError("Not yet implemented");
02257 }
02258 
02259 void  DocumentPy::setUndoMode(Py::Int arg)
02260 {
02261     throw Py::AttributeError("Not yet implemented");
02262 }
02263 
02264 Py::Int DocumentPy::getUndoRedoMemSize(void) const
02265 {
02266     //return Py::Int();
02267     throw Py::AttributeError("Not yet implemented");
02268 }
02269 
02270 Py::Int DocumentPy::getUndoCount(void) const
02271 {
02272     //return Py::Int();
02273     throw Py::AttributeError("Not yet implemented");
02274 }
02275 
02276 Py::Int DocumentPy::getRedoCount(void) const
02277 {
02278     //return Py::Int();
02279     throw Py::AttributeError("Not yet implemented");
02280 }
02281 
02282 Py::List DocumentPy::getUndoNames(void) const
02283 {
02284     //return Py::List();
02285     throw Py::AttributeError("Not yet implemented");
02286 }
02287 
02288 Py::List DocumentPy::getRedoNames(void) const
02289 {
02290     //return Py::List();
02291     throw Py::AttributeError("Not yet implemented");
02292 }
02293 
02294 Py::String DocumentPy::getName(void) const
02295 {
02296     //return Py::String();
02297     throw Py::AttributeError("Not yet implemented");
02298 }
02299 
02300 PyObject *DocumentPy::getCustomAttributes(const char* attr) const
02301 {
02302     return 0;
02303 }
02304 
02305 int DocumentPy::setCustomAttributes(const char* attr, PyObject *obj)
02306 {
02307     return 0; 
02308 }
02309 #endif
02310 
02311 
02312 

Generated on Wed Nov 23 19:00:08 2011 for FreeCAD by  doxygen 1.6.1