Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
djinni
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
djinni
Commits
c12d6c05
Commit
c12d6c05
authored
Jul 28, 2016
by
Aleksey Konovalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with processing \U+0000 symbol. Added tests
parent
e12862a9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
7 deletions
+8
-7
support-lib/jni/Marshal.hpp
support-lib/jni/Marshal.hpp
+1
-1
support-lib/jni/djinni_support.cpp
support-lib/jni/djinni_support.cpp
+3
-3
test-suite/handwritten-src/cpp/wchar_test_helpers.cpp
test-suite/handwritten-src/cpp/wchar_test_helpers.cpp
+2
-1
test-suite/handwritten-src/java/com/dropbox/djinni/test/WcharTest.java
...ndwritten-src/java/com/dropbox/djinni/test/WcharTest.java
+1
-1
test-suite/handwritten-src/objc/tests/DBWcharTests.m
test-suite/handwritten-src/objc/tests/DBWcharTests.m
+1
-1
No files found.
support-lib/jni/Marshal.hpp
View file @
c12d6c05
...
@@ -193,7 +193,7 @@ namespace djinni
...
@@ -193,7 +193,7 @@ namespace djinni
static
LocalRef
<
JniType
>
fromCpp
(
JNIEnv
*
jniEnv
,
const
CppType
&
c
)
static
LocalRef
<
JniType
>
fromCpp
(
JNIEnv
*
jniEnv
,
const
CppType
&
c
)
{
{
return
{
jniEnv
,
jniStringFromWString
(
jniEnv
,
c
.
c_str
()
)};
return
{
jniEnv
,
jniStringFromWString
(
jniEnv
,
c
)};
}
}
};
};
...
...
support-lib/jni/djinni_support.cpp
View file @
c12d6c05
...
@@ -413,7 +413,7 @@ static inline bool is_low_surrogate(char16_t c) { return (c >= 0xDC00) && (c <
...
@@ -413,7 +413,7 @@ static inline bool is_low_surrogate(char16_t c) { return (c >= 0xDC00) && (c <
/*
/*
* Like utf8_decode_check, but for UTF-16.
* Like utf8_decode_check, but for UTF-16.
*/
*/
static
offset_pt
utf16_decode_check
(
const
std
::
u16string
&
str
,
std
::
u16string
::
size_type
i
)
{
static
offset_pt
utf16_decode_check
(
const
char16_t
*
str
,
std
::
u16string
::
size_type
i
)
{
if
(
is_high_surrogate
(
str
[
i
])
&&
is_low_surrogate
(
str
[
i
+
1
]))
{
if
(
is_high_surrogate
(
str
[
i
])
&&
is_low_surrogate
(
str
[
i
+
1
]))
{
// High surrogate followed by low surrogate
// High surrogate followed by low surrogate
char32_t
pt
=
(((
str
[
i
]
-
0xD800
)
<<
10
)
|
(
str
[
i
+
1
]
-
0xDC00
))
+
0x10000
;
char32_t
pt
=
(((
str
[
i
]
-
0xD800
)
<<
10
)
|
(
str
[
i
+
1
]
-
0xDC00
))
+
0x10000
;
...
@@ -426,7 +426,7 @@ static offset_pt utf16_decode_check(const std::u16string & str, std::u16string::
...
@@ -426,7 +426,7 @@ static offset_pt utf16_decode_check(const std::u16string & str, std::u16string::
}
}
}
}
static
char32_t
utf16_decode
(
const
std
::
u16string
&
str
,
std
::
u16string
::
size_type
&
i
)
{
static
char32_t
utf16_decode
(
const
char16_t
*
str
,
std
::
u16string
::
size_type
&
i
)
{
offset_pt
res
=
utf16_decode_check
(
str
,
i
);
offset_pt
res
=
utf16_decode_check
(
str
,
i
);
if
(
res
.
offset
<
0
)
{
if
(
res
.
offset
<
0
)
{
i
+=
1
;
i
+=
1
;
...
@@ -472,7 +472,7 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) {
...
@@ -472,7 +472,7 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) {
std
::
string
out
;
std
::
string
out
;
out
.
reserve
(
str
.
length
()
*
3
/
2
);
// estimate
out
.
reserve
(
str
.
length
()
*
3
/
2
);
// estimate
for
(
std
::
u16string
::
size_type
i
=
0
;
i
<
str
.
length
();
)
for
(
std
::
u16string
::
size_type
i
=
0
;
i
<
str
.
length
();
)
utf8_encode
(
utf16_decode
(
str
,
i
),
out
);
utf8_encode
(
utf16_decode
(
str
.
data
()
,
i
),
out
);
return
out
;
return
out
;
}
}
...
...
test-suite/handwritten-src/cpp/wchar_test_helpers.cpp
View file @
c12d6c05
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
namespace
testsuite
{
namespace
testsuite
{
static
const
std
::
wstring
str1
=
L"some string with unicode \u263A, \U0001F4A9 symbols"
;
static
const
wchar_t
s1
[]
=
L"some string with unicode \u0000, \u263A, \U0001F4A9 symbols"
;
static
const
std
::
wstring
str1
(
s1
,
sizeof
(
s1
)
/
sizeof
(
*
s1
)
-
1
);
static
const
std
::
wstring
str2
=
L"another string with unicode \u263B, \U0001F4A8 symbols"
;
static
const
std
::
wstring
str2
=
L"another string with unicode \u263B, \U0001F4A8 symbols"
;
WcharTestRec
WcharTestHelpers
::
get_record
()
WcharTestRec
WcharTestHelpers
::
get_record
()
...
...
test-suite/handwritten-src/java/com/dropbox/djinni/test/WcharTest.java
View file @
c12d6c05
...
@@ -4,7 +4,7 @@ import junit.framework.TestCase;
...
@@ -4,7 +4,7 @@ import junit.framework.TestCase;
public
class
WcharTest
extends
TestCase
{
public
class
WcharTest
extends
TestCase
{
private
static
final
String
STR1
=
"some string with unicode \u263A, \uD83D\uDCA9 symbols"
;
private
static
final
String
STR1
=
"some string with unicode \u
0000, \u
263A, \uD83D\uDCA9 symbols"
;
private
static
final
String
STR2
=
"another string with unicode \u263B, \uD83D\uDCA8 symbols"
;
private
static
final
String
STR2
=
"another string with unicode \u263B, \uD83D\uDCA8 symbols"
;
public
void
test
()
{
public
void
test
()
{
...
...
test-suite/handwritten-src/objc/tests/DBWcharTests.m
View file @
c12d6c05
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
-
(
void
)
test
-
(
void
)
test
{
{
NSString
*
str1
=
@"some string with unicode \u263A, \U0001F4A9 symbols"
;
NSString
*
str1
=
@"some string with unicode \u
0000, \u
263A, \U0001F4A9 symbols"
;
NSString
*
str2
=
@"another string with unicode \u263B, \U0001F4A8 symbols"
;
NSString
*
str2
=
@"another string with unicode \u263B, \U0001F4A8 symbols"
;
XCTAssertEqualObjects
([[
DBWcharTestHelpers
getRecord
]
s
],
str1
);
XCTAssertEqualObjects
([[
DBWcharTestHelpers
getRecord
]
s
],
str1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment