Oxygine  1
2g game engine
jniHelper.h
1 #pragma once
2 #include <jni.h>
3 #include <android/log.h>
4 #include <string>
5 #include <vector>
6 
7 namespace oxygine
8 {
9  using namespace std;
10 
11 #define STRINGIZE_DETAIL(x) #x
12 #define STRINGIZE(x) STRINGIZE_DETAIL(x)
13 
14  template <bool D>
16  {
17  public:
18  LocalReferenceHolder(JNIEnv* env, const char* func, const char* line): _env(env), _func(func), _line(line)
19  {
20  if (D)
21  __android_log_print(ANDROID_LOG_DEBUG, "SDL", "LocalReferenceHolder enter: %s %s", _func, _line);
22  _env->PushLocalFrame(16);
23  }
24 
25 
27  {
28  _env->PopLocalFrame(0);
29 
30  if (D)
31  __android_log_print(ANDROID_LOG_DEBUG, "SDL", "LocalReferenceHolder left: %s %s", _func, _line);
32  }
33 
34  JNIEnv* _env;
35  const char* _func;
36  const char* _line;
37  };
38 
39 #define LOCAL_REF_HOLDER(env) LocalReferenceHolder<false> _lr_(env, __func__, STRINGIZE(__LINE__));
40 #define LOCAL_REF_HOLDER_D(env) LocalReferenceHolder<true> _lr_(env, __func__, STRINGIZE(__LINE__));
41 
42  class notFound {};
43 
44 #define JNI_NOT_NULL(v) if (!v) { __android_log_print(ANDROID_LOG_DEBUG, "SDL", "NOTNULL! %d %s", __LINE__, __FILE__); throw notFound();}
45 
46 
47  JNIEnv* jniGetEnv(void);
48 
49  std::string jniGetString(JNIEnv* env, jstring jstr);
50  void jniGetStringArray(vector<std::string>& res, JNIEnv* env, jobjectArray jarray);
51  jobjectArray jniGetObjectStringArray(const vector<std::string>& src, JNIEnv* env);
52 
53 }
Definition: json.h:1353
Definition: jniHelper.h:15
–oxgl-end–!
Definition: Actor.h:14
Definition: jniHelper.h:42