DocumentObjectPy.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 DocumentObjectPyImp.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 DocumentObjectPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "App.DocumentObject",     /*tp_name*/
00024     sizeof(DocumentObjectPy),                       /*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 the father of all classes handled by the document",           /*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::DocumentObjectPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     App::DocumentObjectPy::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::DocumentObjectPy::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 DocumentObjectPy::Methods[] = {
00075     {"touch",
00076         (PyCFunction) staticCallback_touch,
00077         METH_VARARGS,
00078         "Mark the object as changed (touched)"
00079     },
00080     {"purgeTouched",
00081         (PyCFunction) staticCallback_purgeTouched,
00082         METH_VARARGS,
00083         "Mark the object as unchanged"
00084     },
00085     {NULL, NULL, 0, NULL}               /* Sentinel */
00086 };
00087 
00088 
00089 
00091 PyGetSetDef DocumentObjectPy::GetterSetter[] = {
00092     {"OutList",
00093         (getter) staticCallback_getOutList,
00094         (setter) staticCallback_setOutList, 
00095         "A list of all objects this object links to.",
00096         NULL
00097     },
00098     {"InList",
00099         (getter) staticCallback_getInList,
00100         (setter) staticCallback_setInList, 
00101         "A list of all objects which link tobthis object.",
00102         NULL
00103     },
00104     {"Name",
00105         (getter) staticCallback_getName,
00106         (setter) staticCallback_setName, 
00107         "Return the internal name of this object",
00108         NULL
00109     },
00110     {"Document",
00111         (getter) staticCallback_getDocument,
00112         (setter) staticCallback_setDocument, 
00113         "Return the document this object is part of",
00114         NULL
00115     },
00116     {"State",
00117         (getter) staticCallback_getState,
00118         (setter) staticCallback_setState, 
00119         "State of the object in the document",
00120         NULL
00121     },
00122     {"ViewObject",
00123         (getter) staticCallback_getViewObject,
00124         (setter) staticCallback_setViewObject, 
00125         "If the GUI is loaded the associated view provider is returned\nor None if the GUI is not up",
00126         NULL
00127     },
00128     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00129 };
00130 
00131 // touch() callback and implementer
00132 // PyObject*  DocumentObjectPy::touch(PyObject *args){};
00133 // has to be implemented in DocumentObjectPyImp.cpp
00134 PyObject * DocumentObjectPy::staticCallback_touch (PyObject *self, PyObject *args)
00135 {
00136     // test if twin object not allready deleted
00137     if (!((PyObjectBase*) self)->isValid()){
00138         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00139         return NULL;
00140     }
00141 
00142     // test if object is set Const
00143     if (((PyObjectBase*) self)->isConst()){
00144         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00145         return NULL;
00146     }
00147 
00148     try { // catches all exceptions coming up from c++ and generate a python exception
00149         PyObject* ret = ((DocumentObjectPy*)self)->touch(args);
00150         if (ret != 0)
00151             ((DocumentObjectPy*)self)->startNotify();
00152         return ret;
00153     }
00154     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00155     {
00156         std::string str;
00157         str += "FreeCAD exception thrown (";
00158         str += e.what();
00159         str += ")";
00160         e.ReportException();
00161         PyErr_SetString(PyExc_Exception,str.c_str());
00162         return NULL;
00163     }
00164     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00165     {
00166         std::string str;
00167         str += "File system exception thrown (";
00168         //str += e.who();
00169         //str += ", ";
00170         str += e.what();
00171         str += ")\n";
00172         Base::Console().Error(str.c_str());
00173         PyErr_SetString(PyExc_Exception,str.c_str());
00174         return NULL;
00175     }
00176     catch(const Py::Exception&)
00177     {
00178         // The exception text is already set
00179         return NULL;
00180     }
00181     catch(const char* e) // catch simple string exceptions
00182     {
00183         Base::Console().Error(e);
00184         PyErr_SetString(PyExc_Exception,e);
00185         return NULL;
00186     }
00187     // in debug not all exceptions will be catched to get the attention of the developer!
00188 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00189     catch(const std::exception& e) // catch other c++ exceptions
00190     {
00191         std::string str;
00192         str += "FC++ exception thrown (";
00193         str += e.what();
00194         str += ")";
00195         Base::Console().Error(str.c_str());
00196         PyErr_SetString(PyExc_Exception,str.c_str());
00197         return NULL;
00198     }
00199     catch(...)  // catch the rest!
00200     {
00201         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00202         return NULL;
00203     }
00204 #endif
00205 }
00206 
00207 // purgeTouched() callback and implementer
00208 // PyObject*  DocumentObjectPy::purgeTouched(PyObject *args){};
00209 // has to be implemented in DocumentObjectPyImp.cpp
00210 PyObject * DocumentObjectPy::staticCallback_purgeTouched (PyObject *self, PyObject *args)
00211 {
00212     // test if twin object not allready deleted
00213     if (!((PyObjectBase*) self)->isValid()){
00214         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00215         return NULL;
00216     }
00217 
00218     // test if object is set Const
00219     if (((PyObjectBase*) self)->isConst()){
00220         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00221         return NULL;
00222     }
00223 
00224     try { // catches all exceptions coming up from c++ and generate a python exception
00225         PyObject* ret = ((DocumentObjectPy*)self)->purgeTouched(args);
00226         if (ret != 0)
00227             ((DocumentObjectPy*)self)->startNotify();
00228         return ret;
00229     }
00230     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00231     {
00232         std::string str;
00233         str += "FreeCAD exception thrown (";
00234         str += e.what();
00235         str += ")";
00236         e.ReportException();
00237         PyErr_SetString(PyExc_Exception,str.c_str());
00238         return NULL;
00239     }
00240     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00241     {
00242         std::string str;
00243         str += "File system exception thrown (";
00244         //str += e.who();
00245         //str += ", ";
00246         str += e.what();
00247         str += ")\n";
00248         Base::Console().Error(str.c_str());
00249         PyErr_SetString(PyExc_Exception,str.c_str());
00250         return NULL;
00251     }
00252     catch(const Py::Exception&)
00253     {
00254         // The exception text is already set
00255         return NULL;
00256     }
00257     catch(const char* e) // catch simple string exceptions
00258     {
00259         Base::Console().Error(e);
00260         PyErr_SetString(PyExc_Exception,e);
00261         return NULL;
00262     }
00263     // in debug not all exceptions will be catched to get the attention of the developer!
00264 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00265     catch(const std::exception& e) // catch other c++ exceptions
00266     {
00267         std::string str;
00268         str += "FC++ exception thrown (";
00269         str += e.what();
00270         str += ")";
00271         Base::Console().Error(str.c_str());
00272         PyErr_SetString(PyExc_Exception,str.c_str());
00273         return NULL;
00274     }
00275     catch(...)  // catch the rest!
00276     {
00277         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00278         return NULL;
00279     }
00280 #endif
00281 }
00282 
00283 // OutList() callback and implementer
00284 // PyObject*  DocumentObjectPy::OutList(PyObject *args){};
00285 // has to be implemented in DocumentObjectPyImp.cpp
00286 PyObject * DocumentObjectPy::staticCallback_getOutList (PyObject *self, void * /*closure*/)
00287 {
00288     if (!((PyObjectBase*) self)->isValid()){
00289         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00290         return NULL;
00291     }
00292 
00293     try {
00294         return Py::new_reference_to(((DocumentObjectPy*)self)->getOutList());
00295     } catch (const Py::Exception&) {
00296         // The exception text is already set
00297         return NULL;
00298     } catch (...) {
00299         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'OutList' of object 'DocumentObject'");
00300         return NULL;
00301     }
00302 }
00303 
00304 int DocumentObjectPy::staticCallback_setOutList (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00305 {
00306     if (!((PyObjectBase*) self)->isValid()){
00307         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00308         return -1;
00309     }
00310 
00311     PyErr_SetString(PyExc_AttributeError, "Attribute 'OutList' of object 'DocumentObject' is read-only");
00312     return -1;
00313 }
00314 
00315 // InList() callback and implementer
00316 // PyObject*  DocumentObjectPy::InList(PyObject *args){};
00317 // has to be implemented in DocumentObjectPyImp.cpp
00318 PyObject * DocumentObjectPy::staticCallback_getInList (PyObject *self, void * /*closure*/)
00319 {
00320     if (!((PyObjectBase*) self)->isValid()){
00321         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00322         return NULL;
00323     }
00324 
00325     try {
00326         return Py::new_reference_to(((DocumentObjectPy*)self)->getInList());
00327     } catch (const Py::Exception&) {
00328         // The exception text is already set
00329         return NULL;
00330     } catch (...) {
00331         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'InList' of object 'DocumentObject'");
00332         return NULL;
00333     }
00334 }
00335 
00336 int DocumentObjectPy::staticCallback_setInList (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00337 {
00338     if (!((PyObjectBase*) self)->isValid()){
00339         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00340         return -1;
00341     }
00342 
00343     PyErr_SetString(PyExc_AttributeError, "Attribute 'InList' of object 'DocumentObject' is read-only");
00344     return -1;
00345 }
00346 
00347 // Name() callback and implementer
00348 // PyObject*  DocumentObjectPy::Name(PyObject *args){};
00349 // has to be implemented in DocumentObjectPyImp.cpp
00350 PyObject * DocumentObjectPy::staticCallback_getName (PyObject *self, void * /*closure*/)
00351 {
00352     if (!((PyObjectBase*) self)->isValid()){
00353         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00354         return NULL;
00355     }
00356 
00357     try {
00358         return Py::new_reference_to(((DocumentObjectPy*)self)->getName());
00359     } catch (const Py::Exception&) {
00360         // The exception text is already set
00361         return NULL;
00362     } catch (...) {
00363         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Name' of object 'DocumentObject'");
00364         return NULL;
00365     }
00366 }
00367 
00368 int DocumentObjectPy::staticCallback_setName (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00369 {
00370     if (!((PyObjectBase*) self)->isValid()){
00371         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00372         return -1;
00373     }
00374 
00375     PyErr_SetString(PyExc_AttributeError, "Attribute 'Name' of object 'DocumentObject' is read-only");
00376     return -1;
00377 }
00378 
00379 // Document() callback and implementer
00380 // PyObject*  DocumentObjectPy::Document(PyObject *args){};
00381 // has to be implemented in DocumentObjectPyImp.cpp
00382 PyObject * DocumentObjectPy::staticCallback_getDocument (PyObject *self, void * /*closure*/)
00383 {
00384     if (!((PyObjectBase*) self)->isValid()){
00385         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00386         return NULL;
00387     }
00388 
00389     try {
00390         return Py::new_reference_to(((DocumentObjectPy*)self)->getDocument());
00391     } catch (const Py::Exception&) {
00392         // The exception text is already set
00393         return NULL;
00394     } catch (...) {
00395         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Document' of object 'DocumentObject'");
00396         return NULL;
00397     }
00398 }
00399 
00400 int DocumentObjectPy::staticCallback_setDocument (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00401 {
00402     if (!((PyObjectBase*) self)->isValid()){
00403         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00404         return -1;
00405     }
00406 
00407     PyErr_SetString(PyExc_AttributeError, "Attribute 'Document' of object 'DocumentObject' is read-only");
00408     return -1;
00409 }
00410 
00411 // State() callback and implementer
00412 // PyObject*  DocumentObjectPy::State(PyObject *args){};
00413 // has to be implemented in DocumentObjectPyImp.cpp
00414 PyObject * DocumentObjectPy::staticCallback_getState (PyObject *self, void * /*closure*/)
00415 {
00416     if (!((PyObjectBase*) self)->isValid()){
00417         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00418         return NULL;
00419     }
00420 
00421     try {
00422         return Py::new_reference_to(((DocumentObjectPy*)self)->getState());
00423     } catch (const Py::Exception&) {
00424         // The exception text is already set
00425         return NULL;
00426     } catch (...) {
00427         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'State' of object 'DocumentObject'");
00428         return NULL;
00429     }
00430 }
00431 
00432 int DocumentObjectPy::staticCallback_setState (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00433 {
00434     if (!((PyObjectBase*) self)->isValid()){
00435         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00436         return -1;
00437     }
00438 
00439     PyErr_SetString(PyExc_AttributeError, "Attribute 'State' of object 'DocumentObject' is read-only");
00440     return -1;
00441 }
00442 
00443 // ViewObject() callback and implementer
00444 // PyObject*  DocumentObjectPy::ViewObject(PyObject *args){};
00445 // has to be implemented in DocumentObjectPyImp.cpp
00446 PyObject * DocumentObjectPy::staticCallback_getViewObject (PyObject *self, void * /*closure*/)
00447 {
00448     if (!((PyObjectBase*) self)->isValid()){
00449         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00450         return NULL;
00451     }
00452 
00453     try {
00454         return Py::new_reference_to(((DocumentObjectPy*)self)->getViewObject());
00455     } catch (const Py::Exception&) {
00456         // The exception text is already set
00457         return NULL;
00458     } catch (...) {
00459         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'ViewObject' of object 'DocumentObject'");
00460         return NULL;
00461     }
00462 }
00463 
00464 int DocumentObjectPy::staticCallback_setViewObject (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00465 {
00466     if (!((PyObjectBase*) self)->isValid()){
00467         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00468         return -1;
00469     }
00470 
00471     PyErr_SetString(PyExc_AttributeError, "Attribute 'ViewObject' of object 'DocumentObject' is read-only");
00472     return -1;
00473 }
00474 
00475 
00476 
00477 //--------------------------------------------------------------------------
00478 // Parents structure
00479 //--------------------------------------------------------------------------
00480 PyParentObject DocumentObjectPy::Parents[] = { PARENTSAppDocumentObjectPy };
00481 
00482 //--------------------------------------------------------------------------
00483 // Constructor
00484 //--------------------------------------------------------------------------
00485 DocumentObjectPy::DocumentObjectPy(DocumentObject *pcObject, PyTypeObject *T)
00486     : PropertyContainerPy(reinterpret_cast<PropertyContainerPy::PointerType>(pcObject), T)
00487 {
00488 }
00489 
00490 PyObject *DocumentObjectPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00491 {
00492     // never create such objects with the constructor
00493     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'DocumentObjectPy'.");
00494  
00495     return 0;
00496 }
00497 
00498 int DocumentObjectPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00499 {
00500     return 0;
00501 }
00502 
00503 //--------------------------------------------------------------------------
00504 // destructor
00505 //--------------------------------------------------------------------------
00506 DocumentObjectPy::~DocumentObjectPy()                                // Everything handled in parent
00507 {
00508 }
00509 
00510 //--------------------------------------------------------------------------
00511 // DocumentObjectPy representation
00512 //--------------------------------------------------------------------------
00513 PyObject *DocumentObjectPy::_repr(void)
00514 {
00515     return Py_BuildValue("s", representation().c_str());
00516 }
00517 
00518 //--------------------------------------------------------------------------
00519 // DocumentObjectPy Attributes
00520 //--------------------------------------------------------------------------
00521 PyObject *DocumentObjectPy::_getattr(char *attr)                                // __getattr__ function: note only need to handle new state
00522 {
00523     try {
00524         // getter method for special Attributes (e.g. dynamic ones)
00525         PyObject *r = getCustomAttributes(attr);
00526         if(r) return r;
00527     }
00528 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00529     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00530     {
00531         std::string str;
00532         str += "FreeCAD exception thrown (";
00533         str += e.what();
00534         str += ")";
00535         e.ReportException();
00536         PyErr_SetString(PyExc_Exception,str.c_str());
00537         return NULL;
00538     }
00539     catch(const std::exception& e) // catch other c++ exceptions
00540     {
00541         std::string str;
00542         str += "FC++ exception thrown (";
00543         str += e.what();
00544         str += ")";
00545         Base::Console().Error(str.c_str());
00546         PyErr_SetString(PyExc_Exception,str.c_str());
00547         return NULL;
00548     }
00549     catch(const Py::Exception&)
00550     {
00551         // The exception text is already set
00552         return NULL;
00553     }
00554     catch(...)  // catch the rest!
00555     {
00556         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00557         return NULL;
00558     }
00559 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00560     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00561     {
00562         std::string str;
00563         str += "FreeCAD exception thrown (";
00564         str += e.what();
00565         str += ")";
00566         e.ReportException();
00567         PyErr_SetString(PyExc_Exception,str.c_str());
00568         return NULL;
00569     }
00570     catch(const Py::Exception&)
00571     {
00572         // The exception text is already set
00573         return NULL;
00574     }
00575 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00576 
00577     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00578     if (rvalue == NULL)
00579     {
00580         PyErr_Clear();
00581         return PropertyContainerPy::_getattr(attr);
00582     }
00583     else
00584     {
00585         return rvalue;
00586     }
00587 }
00588 
00589 int DocumentObjectPy::_setattr(char *attr, PyObject *value)     // __setattr__ function: note only need to handle new state
00590 {
00591     try {
00592         // setter for  special Attributes (e.g. dynamic ones)
00593         int r = setCustomAttributes(attr, value);
00594         if(r==1) return 0;
00595     }
00596 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00597     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00598     {
00599         std::string str;
00600         str += "FreeCAD exception thrown (";
00601         str += e.what();
00602         str += ")";
00603         e.ReportException();
00604         PyErr_SetString(PyExc_Exception,str.c_str());
00605         return -1;
00606     }
00607     catch(const std::exception& e) // catch other c++ exceptions
00608     {
00609         std::string str;
00610         str += "FC++ exception thrown (";
00611         str += e.what();
00612         str += ")";
00613         Base::Console().Error(str.c_str());
00614         PyErr_SetString(PyExc_Exception,str.c_str());
00615         return -1;
00616     }
00617     catch(const Py::Exception&)
00618     {
00619         // The exception text is already set
00620         return -1;
00621     }
00622     catch(...)  // catch the rest!
00623     {
00624         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00625         return -1;
00626     }
00627 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00628     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00629     {
00630         std::string str;
00631         str += "FreeCAD exception thrown (";
00632         str += e.what();
00633         str += ")";
00634         e.ReportException();
00635         PyErr_SetString(PyExc_Exception,str.c_str());
00636         return -1;
00637     }
00638     catch(const Py::Exception&)
00639     {
00640         // The exception text is already set
00641         return -1;
00642     }
00643 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00644 
00645     return PropertyContainerPy::_setattr(attr, value);
00646 }
00647 
00648 DocumentObject *DocumentObjectPy::getDocumentObjectPtr(void) const
00649 {
00650     return static_cast<DocumentObject *>(_pcTwinPointer);
00651 }
00652 
00653 #if 0
00654 /* From here on come the methods you have to implement, but NOT in this module. Implement in DocumentObjectPyImp.cpp! This prototypes 
00655  * are just for convenience when you add a new method.
00656  */
00657 
00658 
00659 // returns a string which represents the object e.g. when printed in python
00660 std::string DocumentObjectPy::representation(void) const
00661 {
00662     return std::string("<DocumentObject object>");
00663 }
00664 
00665 PyObject* DocumentObjectPy::touch(PyObject *args)
00666 {
00667     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00668     return 0;
00669 }
00670 
00671 PyObject* DocumentObjectPy::purgeTouched(PyObject *args)
00672 {
00673     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00674     return 0;
00675 }
00676 
00677 
00678 
00679 Py::List DocumentObjectPy::getOutList(void) const
00680 {
00681     //return Py::List();
00682     throw Py::AttributeError("Not yet implemented");
00683 }
00684 
00685 Py::List DocumentObjectPy::getInList(void) const
00686 {
00687     //return Py::List();
00688     throw Py::AttributeError("Not yet implemented");
00689 }
00690 
00691 Py::String DocumentObjectPy::getName(void) const
00692 {
00693     //return Py::String();
00694     throw Py::AttributeError("Not yet implemented");
00695 }
00696 
00697 Py::Object DocumentObjectPy::getDocument(void) const
00698 {
00699     //return Py::Object();
00700     throw Py::AttributeError("Not yet implemented");
00701 }
00702 
00703 Py::List DocumentObjectPy::getState(void) const
00704 {
00705     //return Py::List();
00706     throw Py::AttributeError("Not yet implemented");
00707 }
00708 
00709 Py::Object DocumentObjectPy::getViewObject(void) const
00710 {
00711     //return Py::Object();
00712     throw Py::AttributeError("Not yet implemented");
00713 }
00714 
00715 PyObject *DocumentObjectPy::getCustomAttributes(const char* attr) const
00716 {
00717     return 0;
00718 }
00719 
00720 int DocumentObjectPy::setCustomAttributes(const char* attr, PyObject *obj)
00721 {
00722     return 0; 
00723 }
00724 #endif
00725 
00726 
00727 

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