1 /* =========================================================================
2 * Copyright
2005-2007 Charlie Savage
, cfis@interserv.com
4 * Interface for a SWIG generated geos module.
6 * This is free software
; you can redistribute and
/or modify it under
7 * the terms of the GNU Lesser General Public Licence as published
8 * by the Free Software Foundation.
9 * See the COPYING file for more information.
11 * ========================================================================= */
13 /* Convert a Ruby array of GeosLinearRings to a C array.
*/
14 %typemap
(in
,numinputs
=1) (GeosLinearRing
**holes
, size_t nholes
)
16 if
($input
== Py_None
)
23 /* Make sure the input can be treated as an array.
*/
24 if
(!PySequence_Check
($input
))
25 SWIG_exception_fail
(SWIG_RuntimeError
, "in method '" "createPolygon" "', argument " "1"" of type '" "GeosLinearRing *""'");
28 $
2 = PySequence_Size
($input
);
30 /* Allocate space for the C array.
*/
31 $
1 = (GeosLinearRing
**) malloc
($
2*sizeof
(GeosLinearRing
*));
33 for
(size_t i
= 0; i
<$
2; i
++)
35 /* Get the Python Object
*/
36 PyObject
*item
= PySequence_GetItem
($input
,i
);
38 /* Get the underlying pointer and give up ownership of it.
*/
39 GeosLinearRing
*ring
= NULL;
40 int convertResult
= SWIG_ConvertPtr
(item
, (void
**)&ring, $descriptor(GeosLinearRing*), SWIG_POINTER_DISOWN);
41 if
(!SWIG_IsOK
(convertResult
)) {
42 SWIG_exception_fail
(SWIG_ArgError
(convertResult
), "in method '" "createPolygon" "', argument " "1"" of type '" "GeosLinearRing *""'");
45 /* Put the pointer in the array
*/
51 %typemap
(freearg
) (GeosLinearRing
**holes
, size_t nholes
)