PartFeaturePy.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 PartFeaturePyImp.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 Part;
00018 
00020 PyTypeObject PartFeaturePy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.Feature",     /*tp_name*/
00024     sizeof(PartFeaturePy),                       /*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 shape object classes",           /*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     Part::PartFeaturePy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::PartFeaturePy::GetterSetter,                     /*tp_getset */
00055     &App::DocumentObjectPy::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     Part::PartFeaturePy::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 PartFeaturePy::Methods[] = {
00075     {NULL, NULL, 0, NULL}               /* Sentinel */
00076 };
00077 
00078 
00079 
00081 PyGetSetDef PartFeaturePy::GetterSetter[] = {
00082     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00083 };
00084 
00085 
00086 
00087 //--------------------------------------------------------------------------
00088 // Parents structure
00089 //--------------------------------------------------------------------------
00090 PyParentObject PartFeaturePy::Parents[] = { PARENTSPartPartFeaturePy };
00091 
00092 //--------------------------------------------------------------------------
00093 // Constructor
00094 //--------------------------------------------------------------------------
00095 PartFeaturePy::PartFeaturePy(Feature *pcObject, PyTypeObject *T)
00096     : DocumentObjectPy(reinterpret_cast<DocumentObjectPy::PointerType>(pcObject), T)
00097 {
00098 }
00099 
00100 PyObject *PartFeaturePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00101 {
00102     // never create such objects with the constructor
00103     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'PartFeaturePy'.");
00104  
00105     return 0;
00106 }
00107 
00108 int PartFeaturePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00109 {
00110     return 0;
00111 }
00112 
00113 //--------------------------------------------------------------------------
00114 // destructor
00115 //--------------------------------------------------------------------------
00116 PartFeaturePy::~PartFeaturePy()                                // Everything handled in parent
00117 {
00118 }
00119 
00120 //--------------------------------------------------------------------------
00121 // PartFeaturePy representation
00122 //--------------------------------------------------------------------------
00123 PyObject *PartFeaturePy::_repr(void)
00124 {
00125     return Py_BuildValue("s", representation().c_str());
00126 }
00127 
00128 //--------------------------------------------------------------------------
00129 // PartFeaturePy Attributes
00130 //--------------------------------------------------------------------------
00131 PyObject *PartFeaturePy::_getattr(char *attr)                           // __getattr__ function: note only need to handle new state
00132 {
00133     try {
00134         // getter method for special Attributes (e.g. dynamic ones)
00135         PyObject *r = getCustomAttributes(attr);
00136         if(r) return r;
00137     }
00138 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00139     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00140     {
00141         std::string str;
00142         str += "FreeCAD exception thrown (";
00143         str += e.what();
00144         str += ")";
00145         e.ReportException();
00146         PyErr_SetString(PyExc_Exception,str.c_str());
00147         return NULL;
00148     }
00149     catch(const std::exception& e) // catch other c++ exceptions
00150     {
00151         std::string str;
00152         str += "FC++ exception thrown (";
00153         str += e.what();
00154         str += ")";
00155         Base::Console().Error(str.c_str());
00156         PyErr_SetString(PyExc_Exception,str.c_str());
00157         return NULL;
00158     }
00159     catch(const Py::Exception&)
00160     {
00161         // The exception text is already set
00162         return NULL;
00163     }
00164     catch(...)  // catch the rest!
00165     {
00166         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00167         return NULL;
00168     }
00169 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00170     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00171     {
00172         std::string str;
00173         str += "FreeCAD exception thrown (";
00174         str += e.what();
00175         str += ")";
00176         e.ReportException();
00177         PyErr_SetString(PyExc_Exception,str.c_str());
00178         return NULL;
00179     }
00180     catch(const Py::Exception&)
00181     {
00182         // The exception text is already set
00183         return NULL;
00184     }
00185 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00186 
00187     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00188     if (rvalue == NULL)
00189     {
00190         PyErr_Clear();
00191         return DocumentObjectPy::_getattr(attr);
00192     }
00193     else
00194     {
00195         return rvalue;
00196     }
00197 }
00198 
00199 int PartFeaturePy::_setattr(char *attr, PyObject *value)        // __setattr__ function: note only need to handle new state
00200 {
00201     try {
00202         // setter for  special Attributes (e.g. dynamic ones)
00203         int r = setCustomAttributes(attr, value);
00204         if(r==1) return 0;
00205     }
00206 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00207     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00208     {
00209         std::string str;
00210         str += "FreeCAD exception thrown (";
00211         str += e.what();
00212         str += ")";
00213         e.ReportException();
00214         PyErr_SetString(PyExc_Exception,str.c_str());
00215         return -1;
00216     }
00217     catch(const std::exception& e) // catch other c++ exceptions
00218     {
00219         std::string str;
00220         str += "FC++ exception thrown (";
00221         str += e.what();
00222         str += ")";
00223         Base::Console().Error(str.c_str());
00224         PyErr_SetString(PyExc_Exception,str.c_str());
00225         return -1;
00226     }
00227     catch(const Py::Exception&)
00228     {
00229         // The exception text is already set
00230         return -1;
00231     }
00232     catch(...)  // catch the rest!
00233     {
00234         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00235         return -1;
00236     }
00237 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00238     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00239     {
00240         std::string str;
00241         str += "FreeCAD exception thrown (";
00242         str += e.what();
00243         str += ")";
00244         e.ReportException();
00245         PyErr_SetString(PyExc_Exception,str.c_str());
00246         return -1;
00247     }
00248     catch(const Py::Exception&)
00249     {
00250         // The exception text is already set
00251         return -1;
00252     }
00253 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00254 
00255     return DocumentObjectPy::_setattr(attr, value);
00256 }
00257 
00258 Feature *PartFeaturePy::getFeaturePtr(void) const
00259 {
00260     return static_cast<Feature *>(_pcTwinPointer);
00261 }
00262 
00263 #if 0
00264 /* From here on come the methods you have to implement, but NOT in this module. Implement in PartFeaturePyImp.cpp! This prototypes 
00265  * are just for convenience when you add a new method.
00266  */
00267 
00268 
00269 // returns a string which represents the object e.g. when printed in python
00270 std::string PartFeaturePy::representation(void) const
00271 {
00272     return std::string("<Feature object>");
00273 }
00274 
00275 
00276 
00277 PyObject *PartFeaturePy::getCustomAttributes(const char* attr) const
00278 {
00279     return 0;
00280 }
00281 
00282 int PartFeaturePy::setCustomAttributes(const char* attr, PyObject *obj)
00283 {
00284     return 0; 
00285 }
00286 #endif
00287 
00288 
00289 

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