%{
		#include "native/resource.h"
		#include "gen/CLcom.h"
		
		#include "CLucene.h"
		//#include "bindings.h"
		
		#include "native/CLcomHeader.h"
		#include "CLcomImpl.h"
		#pragma warning (disable : 4101)
		
		#define COM_CATCHALL catch(CLuceneError& err){ return ::AtlReportError(GetObjectCLSID(), err.what()); }catch(...){return ::AtlReportError(GetObjectCLSID(), "UNKNOWN ERROR"); }	
%}

//some global ignores
%ignore *::clone; //ignore all object clone methods
%ignore *::hashCode; //todo: decide on this...ignore all object hashCode methods

%exception {
  try {
		$function
  }COM_CATCHALL;
}

#undef LUCENE_ADDINREF1
#undef LUCENE_ADDINREF1_CONSTRUCTOR
#undef LUCENE_ADDINREFOBJARR1
#undef LUCENE_ADDINREFOBJARR1_CONSTRUCTOR
#undef LUCENE_ADDINTCS1
#undef LUCENE_ADDINTCS1_CONSTRUCTOR

//this is a bit of a hack, we override the exception of the function
//when we want to add an reference to an input or output
#define LUCENE_ADDINREF1(func,arg0base,argplus1z) %exception func { \
  try {\
    arg##arg0base##->__cl_addref(); \
	$function \
  }COM_CATCHALL; \
 }
//the same thing, except when used in a constructor... differnet because of naming in csharp&java
#define LUCENE_ADDINREF1_CONSTRUCTOR(func,arg0base,argplus1) LUCENE_ADDINREF1(func,arg0base,arg0base)

#define LUCENE_ADDINREFOBJARR1(func,arg0base,argplus1,type) %exception func { \
  try{ int i=0; \
  	int32_t arg##arg0base##plen=0; \
  	while(arg##arg0base##[arg##arg0base##plen]!=NULL) arg##arg0base##plen++; \
  		type* arg##arg0base##argp = _CL_NEWARRAY(type,arg##arg0base##plen+1); \
  	for ( int i=0;i<arg##arg0base##plen;i++ )arg##arg0base##argp[i]=_CL_POINTER(arg##arg0base[i]);\
  		arg##arg0base##argp[arg##arg0base##plen]=NULL; arg##arg0base##=arg##arg0base##argp; \
	  $function \
  }COM_CATCHALL; \
 }
//the same thing, except when used in a constructor... differnet because of naming in csharp&java
#define LUCENE_ADDINREFOBJARR1_CONSTRUCTOR(func,arg0base,argplus1,type) LUCENE_ADDINREFOBJARR1(func,arg0base,arg0base,type)
  
#define LUCENE_ADDINTCS1(func,arg0base,argplus1) %exception func { \
  try { \
    arg##arg0base## = STRDUP_TtoT(arg##arg0base##); \
	  $function \
  }COM_CATCHALL; \
 }
//the same thing, except when used in a constructor... differnet because of naming in csharp&java
#define LUCENE_ADDINTCS1_CONSTRUCTOR(func,arg0base,argplus1) LUCENE_ADDINTCS1(func,arg0base,arg0base)
