00001 /*************************************************************************** 00002 * Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 00026 #include "BaseClass.h" 00027 00028 // inclusion of the generated files (generated out of BaseClassPy.xml) 00029 #include "BaseClassPy.h" 00030 #include "BaseClassPy.cpp" 00031 00032 using namespace Base; 00033 00034 // returns a string which represent the object e.g. when printed in python 00035 std::string BaseClassPy::representation(void) const 00036 { 00037 return std::string("<binding object>"); 00038 } 00039 00040 00041 PyObject* BaseClassPy::isDerivedFrom(PyObject *args) 00042 { 00043 char *name; 00044 if (!PyArg_ParseTuple(args, "s", &name)) // convert args: Python->C 00045 return NULL; // NULL triggers exception 00046 00047 Base::Type type = Base::Type::fromName(name); 00048 if (type != Base::Type::badType() && getBaseClassPtr()->getTypeId().isDerivedFrom(type)) { 00049 Py_INCREF(Py_True); 00050 return Py_True; 00051 } 00052 else { 00053 Py_INCREF(Py_False); 00054 return Py_False; 00055 } 00056 } 00057 00058 PyObject* BaseClassPy::getAllDerivedFrom(PyObject *args) 00059 { 00060 if (!PyArg_ParseTuple(args, "")) // convert args: Python->C 00061 return NULL; // NULL triggers exception 00062 00063 std::vector<Base::Type> ary; 00064 Base::Type::getAllDerivedFrom(getBaseClassPtr()->getTypeId(), ary); 00065 Py::List res; 00066 for (std::vector<Base::Type>::iterator it = ary.begin(); it != ary.end(); ++it) 00067 res.append(Py::String(it->getName())); 00068 return Py::new_reference_to(res); 00069 } 00070 00071 Py::String BaseClassPy::getType(void) const 00072 { 00073 return Py::String(std::string(getBaseClassPtr()->getTypeId().getName())); 00074 } 00075 00076 Py::Int BaseClassPy::getModule(void) const 00077 { 00078 return Py::Int(); 00079 } 00080 00081 PyObject *BaseClassPy::getCustomAttributes(const char* /*attr*/) const 00082 { 00083 return 0; 00084 } 00085 00086 int BaseClassPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) 00087 { 00088 return 0; 00089 } 00090 00091