Hi,

I'm trying to understand typemaps and java typemaps but I couldn't yet realize what should I do to achieve my goal, so I'm asking for help.

First, I've a typedef that I massively use in the project:

typedef unsigned char u8;

I have a "observer/caller" implementation that I want to extend to Java and call from c++:

class JavaSerialPortListener
{
public:
††† JavaSerialPortListener(){};
††† virtual ~JavaSerialPortListener(){};
††† virtual void ReceivedBytes(u8* data, int size){return;};
};


class SerialPortEngine
{
protected:
††† std::set<JavaSerialPortListener *> _serialPortListeners;

public:
††† // *** CONSTRUCTORS & DESTRUCTOR ***†††
††† SerialPortEngine();†††
††† virtual ~SerialPortEngine();

††† // *** METHODS ***
††† void addSerialPortListener(JavaSerialPortListener & listener) {_serialPortListeners.insert(&listener);};
††† void removeSerialPortListener(JavaSerialPortListener& listener){_serialPortListeners.erase(&listener);};
††† void Process()
††† {
††††††† ...
††††††† u8* data = ...somedata
††††††† int readedData = ...data size
††††††† for(std::set<ISerialPortListener*>::iterator it=_serialPortListeners.begin();it!=_serialPortListeners.end();it++)
††† ††† {
††† ††† ††† (*it)->ReceivedBytes(data,readedData);
††† ††† }
††† };
};


Now, my module interface file:

%module(directors="1") SerialPort
%{
#include "JavaSerialPortListener.h"
#include "SerialPortEngine.h"
%}

/* turn on director wrapping JavaSerialPortListener */
%feature("director") JavaSerialPortListener;

%include "JavaSerialPortListener.h"


and I would like that Java's ReceivedBytes method looked like this:

public class SerialPort extends JavaSerialPortListener
{
††† static
††† {
††† ††† System.loadLibrary("SerialPort");
††† }
†††
††† @Override
††† public void ReceivedBytes(byte[] data)
††† {
††††† ...
††† }
}


So, how can I typemap u8*(unsigned char *) to java byte[] (jbyteArray) in a director like this?

Thanks!

--
Josť Santos