123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 |
- /* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.4
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
- #define SWIGJAVA
- #define SWIG_DIRECTORS
- #ifdef __cplusplus
- /* SwigValueWrapper is described in swig.swg */
- template<typename T> class SwigValueWrapper
- {
- struct SwigMovePointer {
- T *ptr;
- SwigMovePointer(T *p) : ptr(p) { }
- ~SwigMovePointer() {
- delete ptr;
- }
- SwigMovePointer& operator=(SwigMovePointer& rhs) {
- T* oldptr = ptr;
- ptr = 0;
- delete oldptr;
- ptr = rhs.ptr;
- rhs.ptr = 0;
- return *this;
- }
- } pointer;
- SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
- SwigValueWrapper(const SwigValueWrapper<T>& rhs);
- public:
- SwigValueWrapper() : pointer(0) { }
- SwigValueWrapper& operator=(const T& t) {
- SwigMovePointer tmp(new T(t));
- pointer = tmp;
- return *this;
- }
- operator T&() const {
- return *pointer.ptr;
- }
- T *operator&() {
- return pointer.ptr;
- }
- };
- template <typename T> T SwigValueInit()
- {
- return T();
- }
- #endif
- /* -----------------------------------------------------------------------------
- * This section contains generic SWIG labels for method/variable
- * declarations/attributes, and other compiler dependent labels.
- * ----------------------------------------------------------------------------- */
- /* template workaround for compilers that cannot correctly implement the C++ standard */
- #ifndef SWIGTEMPLATEDISAMBIGUATOR
- # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
- # define SWIGTEMPLATEDISAMBIGUATOR template
- # elif defined(__HP_aCC)
- /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
- /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
- # define SWIGTEMPLATEDISAMBIGUATOR template
- # else
- # define SWIGTEMPLATEDISAMBIGUATOR
- # endif
- #endif
- /* inline attribute */
- #ifndef SWIGINLINE
- # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
- # define SWIGINLINE inline
- # else
- # define SWIGINLINE
- # endif
- #endif
- /* attribute recognised by some compilers to avoid 'unused' warnings */
- #ifndef SWIGUNUSED
- # if defined(__GNUC__)
- # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
- # define SWIGUNUSED __attribute__ ((__unused__))
- # else
- # define SWIGUNUSED
- # endif
- # elif defined(__ICC)
- # define SWIGUNUSED __attribute__ ((__unused__))
- # else
- # define SWIGUNUSED
- # endif
- #endif
- #ifndef SWIG_MSC_UNSUPPRESS_4505
- # if defined(_MSC_VER)
- # pragma warning(disable : 4505) /* unreferenced local function has been removed */
- # endif
- #endif
- #ifndef SWIGUNUSEDPARM
- # ifdef __cplusplus
- # define SWIGUNUSEDPARM(p)
- # else
- # define SWIGUNUSEDPARM(p) p SWIGUNUSED
- # endif
- #endif
- /* internal SWIG method */
- #ifndef SWIGINTERN
- # define SWIGINTERN static SWIGUNUSED
- #endif
- /* internal inline SWIG method */
- #ifndef SWIGINTERNINLINE
- # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
- #endif
- /* exporting methods */
- #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
- # ifndef GCC_HASCLASSVISIBILITY
- # define GCC_HASCLASSVISIBILITY
- # endif
- #endif
- #ifndef SWIGEXPORT
- # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
- # if defined(STATIC_LINKED)
- # define SWIGEXPORT
- # else
- # define SWIGEXPORT __declspec(dllexport)
- # endif
- # else
- # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
- # define SWIGEXPORT __attribute__ ((visibility("default")))
- # else
- # define SWIGEXPORT
- # endif
- # endif
- #endif
- /* calling conventions for Windows */
- #ifndef SWIGSTDCALL
- # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
- # define SWIGSTDCALL __stdcall
- # else
- # define SWIGSTDCALL
- # endif
- #endif
- /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
- #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
- # define _CRT_SECURE_NO_DEPRECATE
- #endif
- /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
- #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
- # define _SCL_SECURE_NO_DEPRECATE
- #endif
- /* Fix for jlong on some versions of gcc on Windows */
- #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
- typedef long long __int64;
- #endif
- /* Fix for jlong on 64-bit x86 Solaris */
- #if defined(__x86_64)
- # ifdef _LP64
- # undef _LP64
- # endif
- #endif
- #include <jni.h>
- #include <stdlib.h>
- #include <string.h>
- /* Support for throwing Java exceptions */
- typedef enum {
- SWIG_JavaOutOfMemoryError = 1,
- SWIG_JavaIOException,
- SWIG_JavaRuntimeException,
- SWIG_JavaIndexOutOfBoundsException,
- SWIG_JavaArithmeticException,
- SWIG_JavaIllegalArgumentException,
- SWIG_JavaNullPointerException,
- SWIG_JavaDirectorPureVirtual,
- SWIG_JavaUnknownError
- } SWIG_JavaExceptionCodes;
- typedef struct {
- SWIG_JavaExceptionCodes code;
- const char *java_exception;
- } SWIG_JavaExceptions_t;
- static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg)
- {
- jclass excep;
- static const SWIG_JavaExceptions_t java_exceptions[] = {
- { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
- { SWIG_JavaIOException, "java/io/IOException" },
- { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
- { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
- { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
- { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
- { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
- { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
- { SWIG_JavaUnknownError, "java/lang/UnknownError" },
- { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" }
- };
- const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
- while (except_ptr->code != code && except_ptr->code) {
- except_ptr++;
- }
- jenv->ExceptionClear();
- excep = jenv->FindClass(except_ptr->java_exception);
- if (excep) {
- jenv->ThrowNew(excep, msg);
- }
- }
- /* Contract support */
- #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else
- /* -----------------------------------------------------------------------------
- * director.swg
- *
- * This file contains support for director classes that proxy
- * method calls from C++ to Java extensions.
- * ----------------------------------------------------------------------------- */
- #ifdef __cplusplus
- #if defined(DEBUG_DIRECTOR_OWNED)
- #include <iostream>
- #endif
- namespace Swig
- {
- /* Java object wrapper */
- class JObjectWrapper
- {
- public:
- JObjectWrapper() : jthis_(NULL), weak_global_(true) {
- }
- ~JObjectWrapper() {
- jthis_ = NULL;
- weak_global_ = true;
- }
- bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) {
- if (!jthis_) {
- weak_global_ = weak_global;
- if (jobj) {
- jthis_ = ((weak_global_ || !mem_own) ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj));
- }
- #if defined(DEBUG_DIRECTOR_OWNED)
- std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl;
- #endif
- return true;
- }
- else {
- #if defined(DEBUG_DIRECTOR_OWNED)
- std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> already set" << std::endl;
- #endif
- return false;
- }
- }
- jobject get(JNIEnv *jenv) const {
- #if defined(DEBUG_DIRECTOR_OWNED)
- std::cout << "JObjectWrapper::get(";
- if (jthis_) {
- std::cout << jthis_;
- }
- else {
- std::cout << "null";
- }
- std::cout << ") -> return new local ref" << std::endl;
- #endif
- return (jthis_ ? jenv->NewLocalRef(jthis_) : jthis_);
- }
- void release(JNIEnv *jenv) {
- #if defined(DEBUG_DIRECTOR_OWNED)
- std::cout << "JObjectWrapper::release(" << jthis_ << "): " << (weak_global_ ? "weak global ref" : "global ref") << std::endl;
- #endif
- if (jthis_) {
- if (weak_global_) {
- if (jenv->IsSameObject(jthis_, NULL) == JNI_FALSE) {
- jenv->DeleteWeakGlobalRef((jweak)jthis_);
- }
- }
- else {
- jenv->DeleteGlobalRef(jthis_);
- }
- }
- jthis_ = NULL;
- weak_global_ = true;
- }
- jobject peek() {
- return jthis_;
- }
- /* Java proxy releases ownership of C++ object, C++ object is now
- responsible for destruction (creates NewGlobalRef to pin Java
- proxy) */
- void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
- if (take_or_release) { /* Java takes ownership of C++ object's lifetime. */
- if (!weak_global_) {
- jenv->DeleteGlobalRef(jthis_);
- jthis_ = jenv->NewWeakGlobalRef(jself);
- weak_global_ = true;
- }
- }
- else { /* Java releases ownership of C++ object's lifetime */
- if (weak_global_) {
- jenv->DeleteWeakGlobalRef((jweak)jthis_);
- jthis_ = jenv->NewGlobalRef(jself);
- weak_global_ = false;
- }
- }
- }
- private:
- /* pointer to Java object */
- jobject jthis_;
- /* Local or global reference flag */
- bool weak_global_;
- };
- /* director base class */
- class Director
- {
- /* pointer to Java virtual machine */
- JavaVM *swig_jvm_;
- protected:
- #if defined (_MSC_VER) && (_MSC_VER<1300)
- class JNIEnvWrapper;
- friend class JNIEnvWrapper;
- #endif
- /* Utility class for managing the JNI environment */
- class JNIEnvWrapper
- {
- const Director *director_;
- JNIEnv *jenv_;
- public:
- JNIEnvWrapper(const Director *director) : director_(director), jenv_(0) {
- #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON)
- // Attach a daemon thread to the JVM. Useful when the JVM should not wait for
- // the thread to exit upon shutdown. Only for jdk-1.4 and later.
- director_->swig_jvm_->AttachCurrentThreadAsDaemon((JNIEnv **) &jenv_, NULL);
- #else
- director_->swig_jvm_->AttachCurrentThread((JNIEnv **) &jenv_, NULL);
- #endif
- }
- ~JNIEnvWrapper() {
- #if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD)
- // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call.
- // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak.
- director_->swig_jvm_->DetachCurrentThread();
- #endif
- }
- JNIEnv *getJNIEnv() const {
- return jenv_;
- }
- };
- /* Java object wrapper */
- JObjectWrapper swig_self_;
- /* Disconnect director from Java object */
- void swig_disconnect_director_self(const char *disconn_method) {
- JNIEnvWrapper jnienv(this) ;
- JNIEnv *jenv = jnienv.getJNIEnv() ;
- jobject jobj = swig_self_.peek();
- #if defined(DEBUG_DIRECTOR_OWNED)
- std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl;
- #endif
- if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) {
- jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(jobj), disconn_method, "()V");
- if (disconn_meth) {
- #if defined(DEBUG_DIRECTOR_OWNED)
- std::cout << "Swig::Director::disconnect_director_self upcall to " << disconn_method << std::endl;
- #endif
- jenv->CallVoidMethod(jobj, disconn_meth);
- }
- }
- }
- public:
- Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() {
- /* Acquire the Java VM pointer */
- jenv->GetJavaVM(&swig_jvm_);
- }
- virtual ~Director() {
- JNIEnvWrapper jnienv(this) ;
- JNIEnv *jenv = jnienv.getJNIEnv() ;
- swig_self_.release(jenv);
- }
- bool swig_set_self(JNIEnv *jenv, jobject jself, bool mem_own, bool weak_global) {
- return swig_self_.set(jenv, jself, mem_own, weak_global);
- }
- jobject swig_get_self(JNIEnv *jenv) const {
- return swig_self_.get(jenv);
- }
- // Change C++ object's ownership, relative to Java
- void swig_java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
- swig_self_.java_change_ownership(jenv, jself, take_or_release);
- }
- };
- }
- #endif /* __cplusplus */
- #include <stdint.h> // Use the C99 official header
- #include "api.h"
- /* ---------------------------------------------------
- * C++ director class methods
- * --------------------------------------------------- */
- #include "utils_wrap.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- SWIGEXPORT jlong JNICALL Java_org_doubango_utils_utilsJNI_new_1AndroidUtils(JNIEnv *jenv, jclass jcls)
- {
- jlong jresult = 0 ;
- AndroidUtils *result = 0 ;
- (void)jenv;
- (void)jcls;
- result = (AndroidUtils *)new AndroidUtils();
- *(AndroidUtils **)&jresult = result;
- return jresult;
- }
- SWIGEXPORT void JNICALL Java_org_doubango_utils_utilsJNI_delete_1AndroidUtils(JNIEnv *jenv, jclass jcls, jlong jarg1)
- {
- AndroidUtils *arg1 = (AndroidUtils *) 0 ;
- (void)jenv;
- (void)jcls;
- arg1 = *(AndroidUtils **)&jarg1;
- delete arg1;
- }
- SWIGEXPORT jobject JNICALL Java_org_doubango_utils_utilsJNI_AndroidUtils_1getCpuFamily(JNIEnv *jenv, jclass jcls)
- {
- jobject jresult = 0 ;
- uint64_t result;
- (void)jenv;
- (void)jcls;
- result = (uint64_t)AndroidUtils::getCpuFamily();
- {
- jbyteArray ba = jenv->NewByteArray(9);
- jbyte* bae = jenv->GetByteArrayElements(ba, 0);
- jclass clazz = jenv->FindClass("java/math/BigInteger");
- jmethodID mid = jenv->GetMethodID(clazz, "<init>", "([B)V");
- jobject bigint;
- int i;
- bae[0] = 0;
- for(i=1; i<9; i++ ) {
- bae[i] = (jbyte)(result>>8*(8-i));
- }
- jenv->ReleaseByteArrayElements(ba, bae, 0);
- bigint = jenv->NewObject(clazz, mid, ba);
- jresult = bigint;
- }
- return jresult;
- }
- SWIGEXPORT jobject JNICALL Java_org_doubango_utils_utilsJNI_AndroidUtils_1getCpuFeatures(JNIEnv *jenv, jclass jcls)
- {
- jobject jresult = 0 ;
- uint64_t result;
- (void)jenv;
- (void)jcls;
- result = (uint64_t)AndroidUtils::getCpuFeatures();
- {
- jbyteArray ba = jenv->NewByteArray(9);
- jbyte* bae = jenv->GetByteArrayElements(ba, 0);
- jclass clazz = jenv->FindClass("java/math/BigInteger");
- jmethodID mid = jenv->GetMethodID(clazz, "<init>", "([B)V");
- jobject bigint;
- int i;
- bae[0] = 0;
- for(i=1; i<9; i++ ) {
- bae[i] = (jbyte)(result>>8*(8-i));
- }
- jenv->ReleaseByteArrayElements(ba, bae, 0);
- bigint = jenv->NewObject(clazz, mid, ba);
- jresult = bigint;
- }
- return jresult;
- }
- #ifdef __cplusplus
- }
- #endif
|