//==================================================================================================
// J a v a                                                                                Interface
// J n i
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU Library General Public License for more details (http://www.gnu.org).

/*DESCRIPTION*/
/* This module provides elements from the Java Native Interface (JNI). */

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "java/jni.hpp"

// Guardian //--------------------------------------------------------------------------------------
#ifndef guJavaJni
#define guJavaJni

// Headers //---------------------------------------------------------------------------------------
#include <bpp/standard.hpp> /*INCLUDE*/

#ifdef JAVA_NATIVE_INTERFACE_YES
 #include <jni.h> /*INCLUDE*/
#endif

namespace bpp {

// Importation/Exportation //-----------------------------------------------------------------------
#ifdef JAVA_DLL
 #define dll_export DLL_EXPORT
#else
 #define dll_export DLL_IMPORT
#endif

// Namespaces //------------------------------------------------------------------------------------
#define public_area  javaJni
#define private_area javaJni_private

namespace public_area  { /*NAMESPACE*/ using namespace standard; }
namespace private_area { using namespace public_area; }

extern_module_name;

// Initialization //--------------------------------------------------------------------------------

// Dummy Definitions //-----------------------------------------------------------------------------
#ifndef JAVA_NATIVE_INTERFACE_YES
 #define JNICALL
 #define JNIEXPORT

 #define JNI_FALSE 0
 #define JNI_TRUE  1

 #define JNI_OK  0
 #define JNI_ERR (-1)

 #define JNI_COMMIT 1
 #define JNI_ABORT  2

 #define JNI_EDETACHED (-2)
 #define JNI_EVERSION  (-3)

 typedef bool          jboolean;
 typedef char          jbyte;
 typedef unsigned char jchar;
 typedef short         jshort;
 typedef int           jint;
 typedef long          jlong;
 typedef float         jfloat;
 typedef double        jdouble;

 typedef jint jsize;

 class _jobject { private: int dummy; };

 class _jclass     : public _jobject {};
 class _jstring    : public _jobject {};
 class _jarray     : public _jobject {};
 class _jthrowable : public _jobject {};

 class _jobjectArray  : public _jarray {};
 class _jbooleanArray : public _jarray {};
 class _jbyteArray    : public _jarray {};
 class _jcharArray    : public _jarray {};
 class _jshortArray   : public _jarray {};
 class _jintArray     : public _jarray {};
 class _jlongArray    : public _jarray {};
 class _jfloatArray   : public _jarray {};
 class _jdoubleArray  : public _jarray {};

 typedef _jobject *    jobject;
 typedef _jclass *     jclass;
 typedef _jstring *    jstring;
 typedef _jarray *     jarray;
 typedef _jthrowable * jthrowable;

 typedef _jobjectArray *  jobjectArray;
 typedef _jbooleanArray * jbooleanArray;
 typedef _jbyteArray *    jbyteArray;
 typedef _jcharArray *    jcharArray;
 typedef _jshortArray *   jshortArray;
 typedef _jintArray *     jintArray;
 typedef _jlongArray *    jlongArray;
 typedef _jfloatArray *   jfloatArray;
 typedef _jdoubleArray *  jdoubleArray;

 typedef union _jvalue {
  jboolean z;
  jbyte    b;
  jchar    c;
  jshort   s;
  jint     i;
  jlong    j;
  jfloat   f;
  jdouble  d;
  jobject  l;
 } jvalue;

 class _jfieldID { private: int dummy; };
 class _jmethodID { private: int dummy; };

 typedef _jfieldID *  jfieldID;
 typedef _jmethodID * jmethodID;

 class _JavaVM { private: int dummy; };
 class _JDK1_1InitArgs { private: int dummy; };
 class _JNIEnv { private: int dummy; };

 typedef _JavaVM *       JavaVM;
 typedef _JDK1_1InitArgs JDK1_1InitArgs;
 typedef _JNIEnv *       JNIEnv;
#endif

#ifndef JNI_VERSION_1_1
 #define JNI_VERSION_1_1 0x00010001
#endif

// Macrocommands //---------------------------------------------------------------------------------
#ifdef JAVA_NATIVE_INTERFACE_YES
 /*MACROCOMMAND*/
 /* The expression <CODE>prLine</CODE> is integrated into the source code if
    <CODE>JAVA_NATIVE_INTERFACE_YES</CODE> is defined. */
 #define jni_yes(prLine) prLine

 #define jni_no(prLine)
#else
 #define jni_yes(prLine)

 /*MACROCOMMAND*/
 /* The expression <CODE>prLine</CODE> is integrated into the source code if
    <CODE>JAVA_NATIVE_INTERFACE_YES</CODE> is not defined. */
 #define jni_no(prLine) prLine
#endif

/*MACROCOMMAND*/ /* <CODE>false</CODE> value for the JNI boolean type. */
#define java_false ((javaJni::jyBoolean)JNI_FALSE)

/*MACROCOMMAND*/ /* <CODE>true</CODE> value for the JNI boolean type. */
#define java_true ((javaJni::jyBoolean)JNI_TRUE)

/*MACROCOMMAND*/ /* Command to declare and define a native Java method. */
#define java_method(prReturn,prClass,prMethod)          \
 JNIEXPORT prReturn JNICALL Java_##prClass##_##prMethod \

/*MACROCOMMAND*/ /* Scope where Java native methods are declared. */
#define java_zone extern "C"

// Types & Classes //-------------------------------------------------------------------------------
namespace public_area {
 //-----------------------------------------------------------------------------------Variable Types
 /*TYPE*/ /* JNI boolean type (<CODE>java_false</CODE> or <CODE>java_true</CODE>). */
 typedef jboolean jyBoolean;

 /*TYPE*/ /* JNI byte type (signed 8 bits integer). */
 typedef jbyte jyByte;

 /*TYPE*/ /* JNI character type (unsigned 16 bits integer). */
 typedef jchar jyCharacter;

 /*TYPE*/ /* JNI short integer type (signed 16 bits integer). */
 typedef jshort jyShort;

 /*TYPE*/ /* JNI integer type (signed 32 bits integer). */
 typedef jint jyInteger;

 /*TYPE*/ /* JNI long integer type (signed 64 bits integer). */
 typedef jlong jyLong;

 /*TYPE*/ /* JNI floating point number type (signed 32 bits number). */
 typedef jfloat jyFloat;

 /*TYPE*/ /* JNI long floating point number type (signed 64 bits number). */
 typedef jdouble jyDouble;

 /*TYPE*/ /* JNI cardinal type (positive integer used to count elements in the memory). */
 typedef jsize jyCardinal;

 /*TYPE*/ /* JNI reference to a Java object. */
 typedef jobject jyObject;

 /*TYPE*/ /* JNI reference to a Java class. */
 typedef jclass jyClass;

 /*TYPE*/ /* JNI reference to a Java string. */
 typedef jstring jyString;

 /*TYPE*/ /* JNI reference to a Java array. */
 typedef jarray jyArray;

 /*TYPE*/ /* JNI reference to a Java exception. */
 typedef jthrowable jyException;

 /*TYPE*/ /* JNI reference to a Java array of objects. */
 typedef jobjectArray jyObjectS;

 /*TYPE*/ /* JNI reference to a Java array of booleans. */
 typedef jbooleanArray jyBooleanS;

 /*TYPE*/ /* JNI reference to a Java array of bytes. */
 typedef jbyteArray jyByteS;

 /*TYPE*/ /* JNI reference to a Java array of characters. */
 typedef jcharArray jyCharacterS;

 /*TYPE*/ /* JNI reference to a Java array of short integers. */
 typedef jshortArray jyShortS;

 /*TYPE*/ /* JNI reference to a Java array of integers. */
 typedef jintArray jyIntegerS;

 /*TYPE*/ /* JNI reference to a Java array of long integers. */
 typedef jlongArray jyLongS;

 /*TYPE*/ /* JNI reference to a Java array of floating point numbers. */
 typedef jfloatArray jyFloatS;

 /*TYPE*/ /* JNI reference to a Java array of long floating point numbers. */
 typedef jdoubleArray jyDoubleS;

 /*TYPE*/ /* Type of a JNI value (object reference or value of a primitive type). */
 enumeration { java_object, java_boolean, java_byte, java_character, java_short,
               java_integer, java_long, java_float, java_double } jyType;

 /*TYPE*/ /* JNI reference to an attribute of a Java class. */
 typedef jfieldID jyAttribute;

 /*TYPE*/ /* JNI reference to a method of a Java class. */
 typedef jmethodID jyMethod;

 /*TYPE*/ /* Pointer to a Java Virtual Machine. */
 typedef JavaVM * jyVirtualMachine;

 /*TYPE*/ /* Pointer to a Java context. */
 typedef JNIEnv * jyContext;

 /*TYPE*/ /* JNI value (object reference or value of a primitive type). */
 type_union {
  jyObject    _object;
  jyBoolean   _boolean;
  jyByte      _byte;
  jyCharacter _character;
  jyShort     _short;
  jyInteger   _integer;
  jyLong      _long;
  jyFloat     _float;
  jyDouble    _double;
 }
 jyValue; //
}

namespace private_area {}

// Functions Interface //---------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Errors //----------------------------------------------------------------------------------------
namespace public_area {}

// Constants & Variables //-------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// X X X  Interface //------------------------------------------------------------------------------
namespace {}

// Functions Inline //------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// X X X  Inline //---------------------------------------------------------------------------------
namespace {}

// End //-------------------------------------------------------------------------------------------
}
#undef dll_export
#undef public_area
#undef private_area
#endif
 
//==================================================================================================
// J a v a                                                                           Implementation
// J n i
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU Library General Public License for more details (http://www.gnu.org).

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "java/jni.cpp"

// DLL Belonging //---------------------------------------------------------------------------------
#define JAVA_DLL

// Headers //---------------------------------------------------------------------------------------
#include <bpp/java/jni.hpp> /*INTERFACE*/

namespace bpp {

// Namespaces //------------------------------------------------------------------------------------
#define public_area  javaJni
#define private_area javaJni_private
#define dll_export   DLL_EXPORT

namespace public_area  {}
namespace private_area {}

static_module_name("Java/Jni");

// Initialization //--------------------------------------------------------------------------------

// Errors //----------------------------------------------------------------------------------------
namespace public_area {}

// Constants & Variables //-------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Static Members //--------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Functions Implementation //----------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// X X X  Implementation //-------------------------------------------------------------------------
namespace {}

// End //-------------------------------------------------------------------------------------------
}