Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: jni/Utils.cpp

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Patch Set: Adressed first batch of review issues. Created April 16, 2014, 5:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « jni/Utils.h ('k') | src/com/github/rjeschke/neetutils/Charsets.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <string> 18 #include <string>
19 19
20 #include "Utils.h" 20 #include "Utils.h"
21 #include "Debug.h"
22
23 const std::string GetString(JNIEnv *pEnv, jstring str)
24 {
25 D(D_WARN, "getString()");
26
27 if (str == NULL)
28 return std::string();
29
30 jboolean iscopy;
31
32 const char *s = pEnv->GetStringUTFChars(str, &iscopy);
33 jsize len = pEnv->GetStringUTFLength(str);
34
35 const std::string value(s, len);
36
37 pEnv->ReleaseStringUTFChars(str, s);
38
39 return value;
40 }
41 21
42 std::string JniJavaToStdString(JNIEnv* env, jstring str) 22 std::string JniJavaToStdString(JNIEnv* env, jstring str)
43 { 23 {
44 if (!str) 24 if (!str)
45 { 25 {
46 return std::string(); 26 return std::string();
47 } 27 }
48 28
49 const char* cStr = env->GetStringUTFChars(str, 0); 29 const char* cStr = env->GetStringUTFChars(str, 0);
50 std::string ret(cStr); 30 std::string ret(cStr);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 77 }
98 } 78 }
99 79
100 JNIEnvAcquire::~JNIEnvAcquire() 80 JNIEnvAcquire::~JNIEnvAcquire()
101 { 81 {
102 if (attachmentStatus == JNI_EDETACHED) 82 if (attachmentStatus == JNI_EDETACHED)
103 { 83 {
104 javaVM->DetachCurrentThread(); 84 javaVM->DetachCurrentThread();
105 } 85 }
106 } 86 }
OLDNEW
« no previous file with comments | « jni/Utils.h ('k') | src/com/github/rjeschke/neetutils/Charsets.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld