//--------------------------------adder.cc------------------------------------ #include double addTwoNumbers(double a, double b) {return a+b;} static PyObject *wrap_addTwoNumbers( PyObject *, PyObject * args) { //step 1: get inputs double first = 0.0; double second = 0.0; // Use Py/C API convenience function: int ok = PyArg_ParseTuple( args, "dd", &first, &second); if (!ok) return 0; // raise exception double result = addTwoNumbers( first, second); // Let Python/C API construct a Python floating point # for us return Py_BuildValue( "d", result); } static PyMethodDef adderMethods[] = { {"addThese", wrap_addTwoNumbers, METH_VARARGS, "addThese(a,b)->a+b"}, {0,0} }; extern "C" #ifdef WIN32 __declspec( dllexport) #endif void initadder() { Py_InitModule4( "adder", adderMethods, "additional additions", 0, PYTHON_API_VERSION); return; } // version // $Id$ // End of file