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

Generated on Wed Nov 23 18:59:57 2011 for FreeCAD by  doxygen 1.6.1