Barry,

The file "${SWIG_INSTALL_PREFIX}/share/swig/{swig_version_here}/java/typemaps.i seems to be the place where the default mappings from unsigned long long to BigInteger are defined. I guess taking inspiration from those typemaps and overriding them could be the way to go.

An alternative I'm thinking of would be to modify MultiDimensional.i with something like the following (untested! just to give the idea) added towards its top

#ifdef SWIGJAVA

// For practical reason we want Java long to be used instead of default BigInteger. This approximation isn't much a problem since there is no real use case to be able to address values in the range [INT64_MAX, UINT64_MAX] for dimension sizes

typedef GInt64 MDimUInt64;

#else

typedef GUInt64 MDimUInt64;

#endif

and then replacing occurrences of GUInt64 (at least those dealing with dimension sizes) with MDimUInt64

Not super pretty admitedly

Even

Le 21/06/2023 à 19:34, Barry DeZonia a écrit :
Thanks Even. I will try to throw that together later. But I think my question is much more simple. I will show a small blurb below from swig/include/java/typemaps_java.i

Code I have now follows right here. This code might conflict with current code because I am wanting GUInt64s to go to longs and not BigIntegers throughout the Java api. Note the code I am at a loss as to how to write would be " Typemaps for GUInt64 * ". In other words a C array of GUInt64's which I'd like to translate back and forth to long[]'s. Any example code would be appreciated.

/***************************************************
 * Typemaps for GUInt64
 ***************************************************/

%typemap(in) (GUInt64) "$1 = $input;"
%typemap(out) (GUInt64) {
    /* %typemap(out) (GUInt64) */
    $result = result;
}
%typemap(jni) (GUInt64) "jlong"
%typemap(jtype) (GUInt64) "long"
%typemap(jstype) (GUInt64) "long"
%typemap(javain) (GUInt64) "$javainput"
%typemap(javaout) (GUInt64) {
    return $jnicall;
}

I tried a similar template for GUInt64* and made "jlong" into "jlongArray" and "long" into "long[]" in those three places above but I have no idea how to write the (javain) and (javaout) cases.

For the direction Java Array -> C Array, I guess taking inspiration from DEFINE_REGULAR_ARRAY_OUT(int64_t, jlong, SetLongArrayRegion); should work



On Wed, Jun 21, 2023 at 3:35 AM Even Rouault <[email protected]> wrote:

    Barry,

    it could help if you could point to a public branch in your github
    fork
    with your pending work

    Even

    Le 21/06/2023 à 07:58, Barry DeZonia a écrit :
    > Hello,
    >
    > I am trying to work on the swig java api. I've made a lot of
    progress
    > and am running into one last error before my code completely
    compiles.
    > I am getting a swig complaint when passing a java long[] to a C/C++
    > call that is expecting GUInt64*.
    >
    > Basically the error message is "long[] cannot be converted to
    > SWIGTYPE_p_GUInt64". I've been reading and googling and I can't
    figure
    > out how to modify typemaps_java.i to accomplish this. I think it
    is a
    > simple thing but I am at a loss. Does anyone have any tips?
    >
    > _______________________________________________
    > gdal-dev mailing list
    > [email protected]
    > https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- http://www.spatialys.com
    My software is free, but my time generally not.

--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to