Beatmup
wrapper.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #include "objectpool.h"
21 
22 #include "log.h"
23 
24 #include <mutex>
25 #include <string>
26 
27 
28 #define JNIMETHOD(R,N,C,O) JNIEXPORT R JNICALL C##_##O
29 
30 
31 // locking the mutex
32 #ifdef DEBUG_LOGGING
33 #define BEATMUP_ENTER LOG_I("Entering %s : %d", __FILE__, __LINE__)
34 #else
35 #define BEATMUP_ENTER
36 #endif
37 
38 // catches and rethrows an exception to Java
39 #define BEATMUP_CATCH(expr) try expr catch (std::exception& ex) { $pool.rethrowToJava(jenv, ex); }
40 
41 // retrieving Beatmup object by its handle
42 #define BEATMUP_OBJ(type,ptr,handle) \
43  type* ptr = $pool.getObject<type>(jenv, handle)
44 
45 #define BEATMUP_STRING(var) \
46  const char* javaChar = jenv->GetStringUTFChars(var, 0); \
47  const std::string var##Str(javaChar); \
48  jenv->ReleaseStringUTFChars(var, javaChar)
49 
50 
51 #define BEATMUP_OBJ_OR_NULL(t,p,h) BEATMUP_OBJ(t,p,h)
52 
53 // creating a new dependency on a Java object
54 #define BEATMUP_REFERENCE(jobj,obj) $pool.addJavaReference(jenv, jobj, obj)
55 
56 // removing a dependency on Java object
57 #define BEATMUP_DELETE_REFERENCE(obj) if (obj) $pool.removeJavaReference(jenv, obj)
58 
59 
Handles all Java binding-related static data.
Definition: objectpool.h:34
BeatmupJavaObjectPool $pool