Howard Butler kirjoitti:
On Jul 22, 2008, at 9:48 AM, Ari Jolma wrote:
The trac.osgeo.org does not answer so I'll put this here.
Hobu, would it be ok to have (int len, int *output) typemap. They can
be used in GetHistogram method like this (note that the API is same
for C# but it must use different typemaps. From Band.i:
%typemap(check) (int len, int *output)
{
/* %typemap(check) (int len, int *output) */
if ($1 < 1) $1 = 1; /* stop idiocy */
$2 = (int *)CPLMalloc( $1 * sizeof(int) );
}
Ari,
This isn't too different from what I proposed except for I think that
abusing the check typemap like that (malloc'ing the integer array) is
a recipe for disaster. The check typemap could possibly be run
multiple times, right? Otherwise, it looks pretty close to what I had
for a proposal http://trac.osgeo.org/gdal/changeset/14941 .
Yes.. in fact I just merged the two signatures (which are the same),
changed the default nBuckets to 256 (as in GDAL docs) and added the (int
len, int *output) typemap for non-c#. Ok, so you're suggesting I make
that typemap #ifdef Perl. I don't think check is ever run multiple times
for one match. Using check typemap seems to be the only possibility, if
I want to keep the signature unchaged (I was first proposing a change to
it in the trac message).
I'm for generic typemaps and returning an integer array from a C
function with (int len, int *output) pattern is one IMHO.
Ok, I'll commit this change so that it does nothing for other languages
than Perl.
Cheers,
Ari
I'm open to changing the GetHistogram function signature within Band.i
however you guys wish (ideally to support just using (int len, int
*output) and not having a special typemap for just this function), and
while it would be nice that we wouldn't need the #ifdefs for every
possible language we might ever support ;), it's not the end of the
world either...
Howard
--
Prof. Ari Jolma
Geoinformatiikka / Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev