Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
c57ab92e
Commit
c57ab92e
authored
Feb 08, 2017
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for Windows compiler errors.
Change-Id: I909ea6866089f36f9cb79d435bbecd29623fd8f7
parent
f878024d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
flexbuffers.h
include/flatbuffers/flexbuffers.h
+8
-6
test.cpp
tests/test.cpp
+2
-2
No files found.
include/flatbuffers/flexbuffers.h
View file @
c57ab92e
...
...
@@ -141,8 +141,8 @@ inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) {
// the conditionals in ReadSizedScalar. Can also use inline asm.
#ifdef _MSC_VER
uint64_t
u
=
0
;
__movsb
(
reinterpret_cast
<
int8_t
*>
(
&
u
),
reinterpret_cast
<
const
int8_t
*>
(
data
),
byte_width
);
__movsb
(
reinterpret_cast
<
u
int8_t
*>
(
&
u
),
reinterpret_cast
<
const
u
int8_t
*>
(
data
),
byte_width
);
return
flatbuffers
::
EndianScalar
(
u
);
#else
return
ReadSizedScalar
<
uint64_t
,
uint8_t
,
uint16_t
,
uint32_t
,
uint64_t
>
(
...
...
@@ -307,7 +307,8 @@ class Map : public Vector {
const
size_t
num_prefixed_fields
=
3
;
auto
keys_offset
=
data_
-
byte_width_
*
num_prefixed_fields
;
return
TypedVector
(
Indirect
(
keys_offset
,
byte_width_
),
ReadUInt64
(
keys_offset
+
byte_width_
,
byte_width_
),
static_cast
<
uint8_t
>
(
ReadUInt64
(
keys_offset
+
byte_width_
,
byte_width_
)),
TYPE_KEY
);
}
...
...
@@ -878,7 +879,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
// Remove temp elements and return vector.
stack_
.
resize
(
start
);
stack_
.
push_back
(
vec
);
return
vec
.
u_
;
return
static_cast
<
size_t
>
(
vec
.
u_
)
;
}
size_t
EndMap
(
size_t
start
)
{
...
...
@@ -904,7 +905,8 @@ class Builder FLATBUFFERS_FINAL_CLASS {
// sorted fashion.
// std::sort is typically already a lot faster on sorted data though.
auto
dict
=
reinterpret_cast
<
TwoValue
*>
(
stack_
.
data
()
+
start
);
std
::
sort
(
dict
,
dict
+
len
,
[
&
](
const
TwoValue
&
a
,
const
TwoValue
&
b
)
{
std
::
sort
(
dict
,
dict
+
len
,
[
&
](
const
TwoValue
&
a
,
const
TwoValue
&
b
)
->
bool
{
auto
as
=
reinterpret_cast
<
const
char
*>
(
buf_
.
data
()
+
a
.
key
.
u_
);
auto
bs
=
reinterpret_cast
<
const
char
*>
(
buf_
.
data
()
+
b
.
key
.
u_
);
auto
comp
=
strcmp
(
as
,
bs
);
...
...
@@ -921,7 +923,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
// Remove temp elements and return map.
stack_
.
resize
(
start
);
stack_
.
push_back
(
vec
);
return
vec
.
u_
;
return
static_cast
<
size_t
>
(
vec
.
u_
)
;
}
template
<
typename
F
>
size_t
Vector
(
F
f
)
{
...
...
tests/test.cpp
View file @
c57ab92e
...
...
@@ -1372,9 +1372,9 @@ void FlexBuffersTest() {
slb
+=
"Fred"
;
slb
.
IndirectFloat
(
4.0
f
);
});
std
::
vector
<
int
>
ints
=
{
1
,
2
,
3
};
int
ints
[]
=
{
1
,
2
,
3
};
slb
.
Add
(
"bar"
,
ints
);
slb
.
FixedTypedVector
(
"bar3"
,
ints
.
data
(),
ints
.
size
());
// Static size.
slb
.
FixedTypedVector
(
"bar3"
,
ints
,
sizeof
(
ints
)
/
sizeof
(
int
));
slb
.
Double
(
"foo"
,
100
);
slb
.
Map
(
"mymap"
,
[
&
]()
{
slb
.
String
(
"foo"
,
"Fred"
);
// Testing key and string reuse.
...
...
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