Added a version save isinsnace function

Added wxPoint2DDouble


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18190 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-12-10 22:37:10 +00:00
parent 9b126063b3
commit ef84703240
11 changed files with 172 additions and 48 deletions

View File

@@ -1976,6 +1976,7 @@ bool wxSize_helper(PyObject* source, wxSize** obj) {
return FALSE;
}
bool wxPoint_helper(PyObject* source, wxPoint** obj) {
// If source is an object instance then it may already be the right type
@@ -2112,12 +2113,43 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
error:
PyErr_SetString(PyExc_TypeError,
"Expected a wxColour object or a string containing a colour "
"name or '#RRGGBB'.");
"Expected a wxColour object or a string containing a colour name or '#RRGGBB'.");
return FALSE;
}
bool wxPoint2DDouble_helper(PyObject* source, wxPoint2DDouble** obj) {
// If source is an object instance then it may already be the right type
if (PyInstance_Check(source)) {
wxPoint2DDouble* ptr;
if (SWIG_GetPtrObj(source, (void **)&ptr, "_wxPoint2DDouble_p"))
goto error;
*obj = ptr;
return TRUE;
}
// otherwise a length-2 sequence of floats is expected
if (PySequence_Check(source) && PySequence_Length(source) == 2) {
PyObject* o1 = PySequence_GetItem(source, 0);
PyObject* o2 = PySequence_GetItem(source, 1);
// This should really check for integers, not numbers -- but that would break code.
if (!PyNumber_Check(o1) || !PyNumber_Check(o2)) {
Py_DECREF(o1);
Py_DECREF(o2);
goto error;
}
**obj = wxPoint2DDouble(PyFloat_AsDouble(o1), PyFloat_AsDouble(o2));
Py_DECREF(o1);
Py_DECREF(o2);
return TRUE;
}
error:
PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of floats or a wxPoint2DDouble object.");
return FALSE;
}
//----------------------------------------------------------------------
PyObject* wxArrayString2PyList_helper(const wxArrayString& arr) {