1

I have a C function like so.

void useData(char* buf) {
   // TODO.....
}

With swig I've managed to get this generated.

public static void useData(SWIGTYPE_p_char buf) {
    // SWIG stuff....
}

Now this worked but sometimes I want to pass a ByteBuffer instead of SWIGTYPE_p_char. With another typemap, I've managed to generate this.

public static void useData(ByteBuffer buf) {
    // SWIG stuff....
}

This works but my new typemap overrides the old typemap and I can't call the function with SWIGTYPE_p_char anymore.

My goal is to generate two entry points to my useData function, one that takes a ByteBuffer and one that takes a SWIGTYPE_p_char.

I've been googling and reading through the docs for days now and I can't find anything.

Is this something I can even achieve with SWIG? Or is there something I'm missing? I would highly appreciate pointers, specific docs or alternative search terms.

EDIT: With the ByteBuffer typemap, SWIG only generates ByteBuffer but doesn't generate SWIGTYPE_p_char. I'm trying to make it generate both.

Dominic Fischer
  • 1,695
  • 10
  • 14
  • *my new typemap overrides the old typemap* - what makes you think that? Java supports overloading, so it is perfectly valid to reuse method names with different arguments. – tevemadar Jan 18 '20 at 21:41
  • Java supports it but SWIG only generates one, using the "latest" typemap. – Dominic Fischer Jan 18 '20 at 23:27

1 Answers1

0

You can just keep the both generated functions. That's perfectly valid from java side.

Anton Malyshev
  • 8,686
  • 2
  • 27
  • 45