%{
/* java/local_extra.i: CLucene scripting java interface additional code.
 */
 
//no easy support for arrays, so add our own support in
#include "clucene_arrays.h"
#include "local_arrays.h"
%}
//no easy support for arrays, so add our own support in
%include "clucene_arrays.h"
%include "local_arrays.h"

////////////////////////////////////////////////////////////////////////
//CLUCENEARRAY typemap - java array handling...
////////////////////////////////////////////////////////////////////////
%typemap(ctype) CLUCENEARRAY "jlong"
%typemap(jtype) CLUCENEARRAY "longx"
%typemap(jstype) CLUCENEARRAY "longxx"
%typemap(in) CLUCENEARRAY %{
  _CL$1_mangleArray* _obj_$1 =($symname Array)$input;xxx
  $1 = _obj_$1->array;
%}
%typemap(out) CLUCENEARRAY %{
  _CL$1_mangleArray* _obj_$1 = _CLNEW _CL$1_mangleArray(result);
  jresult=(jlong)_obj_$1;
%}
%typemap(javaout) CLUCENEARRAY { return new _CL$1_mangleArray($jnicall,true).toArray(); };
%typemap(javain) CLUCENEARRAY "_CL$1_mangleArray.getCPtr(new _CL$1_mangleArray($javainput))"


%typemap(jstype) uint8_t*,uint8_t* const "byte[]"
%typemap(jstype) int32_t*,int32_t* const "int[]"
%typemap(jstype) lucene::index::IndexReader**,lucene::index::IndexReader** const "IndexReader[]"
%typemap(jstype) lucene::index::TermFreqVector**,lucene::index::TermFreqVector** const "TermFreqVector[]"
%typemap(jstype) lucene::search::SortField**,lucene::search::SortField** const "SortField[]"
%typemap(jstype) lucene::search::Searchable**,lucene::search::Searchable** const "Searchable[]"

//specific types
%apply CLUCENEARRAY{ uint8_t*,uint8_t* const }; //todo: this is broken... can never know length of array
%apply CLUCENEARRAY{ int32_t*,int32_t* const }; //todo: this is broken... can never know length of array
%apply CLUCENEARRAY{ lucene::index::IndexReader** };
%apply CLUCENEARRAY{ lucene::index::TermFreqVector** };
%apply CLUCENEARRAY{ lucene::search::SortField** };
%apply CLUCENEARRAY{ lucene::search::Searchable** };

//
////////////////////////////////////////////////////////////////////////

