-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from badsyntax/feature/android
Add initial support for android
- Loading branch information
Showing
13 changed files
with
128 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[submodule "lmdb"] | ||
path = lmdb | ||
url = https://git.openldap.org/openldap/openldap.git | ||
url = https://github.com/LMDB/lmdb.git | ||
branch = mdb.master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,39 @@ | ||
#include <jni.h> | ||
#include "react-native-lmdb.h" | ||
|
||
std::string getString(JNIEnv *env, jstring jStr) { | ||
const char *cstr = env->GetStringUTFChars(jStr, NULL); | ||
std::string str = std::string(cstr); | ||
env->ReleaseStringUTFChars(jStr, cstr); | ||
return str; | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT void JNICALL | ||
Java_com_lmdb_LmdbModule_nativeOpen(JNIEnv *env, jclass type, jstring dbPath, jdouble mapSize) { | ||
std::string dbPathStr = getString(env, dbPath); | ||
rnlmdb::open(dbPathStr, mapSize); | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT void JNICALL | ||
Java_com_lmdb_LmdbModule_nativePut(JNIEnv *env, jclass type, jstring key, jstring value) { | ||
std::string keyStr = getString(env, key); | ||
std::string valueStr = getString(env, value); | ||
rnlmdb::put(keyStr, valueStr); | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT jstring JNICALL | ||
Java_com_lmdb_LmdbModule_nativeGet(JNIEnv *env, jclass type, jstring key) { | ||
std::string keyStr = getString(env, key); | ||
std::string result = rnlmdb::get(keyStr); | ||
return (env)->NewStringUTF(result.c_str()); | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT jdouble JNICALL | ||
Java_com_lmdb_LmdbModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) { | ||
return lmdb::multiply(a, b); | ||
JNIEXPORT void JNICALL | ||
Java_com_lmdb_LmdbModule_nativeDel(JNIEnv *env, jclass type, jstring key) { | ||
std::string keyStr = getString(env, key); | ||
rnlmdb::del(keyStr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.