SWIG/Examples/java/pointer/

Simple Pointer Handling

This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

void add(int *x, int *y, int *r) { 
    *r = *x + *y;
}
By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. SWIG wraps a C pointer with a type wrapper class, for example, SWIGTYPE_p_int for an int*. The only problem is how does one go about creating these objects from a Java program?

Possible Solutions

Example

The following example illustrates the use of these features for pointer extraction.

Notes