Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
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
rapidjson
Commits
369e07d1
Commit
369e07d1
authored
Dec 23, 2016
by
Milo Yip
Committed by
GitHub
Dec 23, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #811 from glebov-andrey/improved_new_macro
Improved customization of RAPIDJSON_NEW macro
parents
014097e5
41ceb862
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
21 deletions
+24
-21
allocators.h
include/rapidjson/allocators.h
+1
-1
document.h
include/rapidjson/document.h
+2
-2
regex.h
include/rapidjson/internal/regex.h
+1
-1
stack.h
include/rapidjson/internal/stack.h
+1
-1
pointer.h
include/rapidjson/pointer.h
+2
-2
rapidjson.h
include/rapidjson/rapidjson.h
+1
-1
schema.h
include/rapidjson/schema.h
+2
-2
fwdtest.cpp
test/unittest/fwdtest.cpp
+14
-11
No files found.
include/rapidjson/allocators.h
View file @
369e07d1
...
...
@@ -236,7 +236,7 @@ private:
*/
bool
AddChunk
(
size_t
capacity
)
{
if
(
!
baseAllocator_
)
ownBaseAllocator_
=
baseAllocator_
=
RAPIDJSON_NEW
(
BaseAllocator
()
);
ownBaseAllocator_
=
baseAllocator_
=
RAPIDJSON_NEW
(
BaseAllocator
)(
);
if
(
ChunkHeader
*
chunk
=
reinterpret_cast
<
ChunkHeader
*>
(
baseAllocator_
->
Malloc
(
RAPIDJSON_ALIGN
(
sizeof
(
ChunkHeader
))
+
capacity
)))
{
chunk
->
capacity
=
capacity
;
chunk
->
size
=
0
;
...
...
include/rapidjson/document.h
View file @
369e07d1
...
...
@@ -2088,7 +2088,7 @@ public:
GenericValue
<
Encoding
,
Allocator
>
(
type
),
allocator_
(
allocator
),
ownAllocator_
(
0
),
stack_
(
stackAllocator
,
stackCapacity
),
parseResult_
()
{
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
}
//! Constructor
...
...
@@ -2101,7 +2101,7 @@ public:
allocator_
(
allocator
),
ownAllocator_
(
0
),
stack_
(
stackAllocator
,
stackCapacity
),
parseResult_
()
{
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
...
...
include/rapidjson/internal/regex.h
View file @
369e07d1
...
...
@@ -606,7 +606,7 @@ public:
{
RAPIDJSON_ASSERT
(
regex_
.
IsValid
());
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
stateSet_
=
static_cast
<
unsigned
*>
(
allocator_
->
Malloc
(
GetStateSetSize
()));
state0_
.
template
Reserve
<
SizeType
>
(
regex_
.
stateCount_
);
state1_
.
template
Reserve
<
SizeType
>
(
regex_
.
stateCount_
);
...
...
include/rapidjson/internal/stack.h
View file @
369e07d1
...
...
@@ -183,7 +183,7 @@ private:
size_t
newCapacity
;
if
(
stack_
==
0
)
{
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
newCapacity
=
initialCapacity_
;
}
else
{
newCapacity
=
GetCapacity
();
...
...
include/rapidjson/pointer.h
View file @
369e07d1
...
...
@@ -758,7 +758,7 @@ private:
*/
Ch
*
CopyFromRaw
(
const
GenericPointer
&
rhs
,
size_t
extraToken
=
0
,
size_t
extraNameBufferSize
=
0
)
{
if
(
!
allocator_
)
// allocator is independently owned.
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
size_t
nameBufferSize
=
rhs
.
tokenCount_
;
// null terminators for tokens
for
(
Token
*
t
=
rhs
.
tokens_
;
t
!=
rhs
.
tokens_
+
rhs
.
tokenCount_
;
++
t
)
...
...
@@ -806,7 +806,7 @@ private:
// Create own allocator if user did not supply.
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
// Count number of '/' as tokenCount
tokenCount_
=
0
;
...
...
include/rapidjson/rapidjson.h
View file @
369e07d1
...
...
@@ -583,7 +583,7 @@ RAPIDJSON_NAMESPACE_END
#ifndef RAPIDJSON_NEW
///! customization point for global \c new
#define RAPIDJSON_NEW(
x) new x
#define RAPIDJSON_NEW(
TypeName) new TypeName
#endif
#ifndef RAPIDJSON_DELETE
///! customization point for global \c delete
...
...
include/rapidjson/schema.h
View file @
369e07d1
...
...
@@ -1344,7 +1344,7 @@ public:
schemaRef_
(
allocator
,
kInitialSchemaRefSize
)
{
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
)(
);
typeless_
=
static_cast
<
SchemaType
*>
(
allocator_
->
Malloc
(
sizeof
(
SchemaType
)));
new
(
typeless_
)
SchemaType
(
this
,
PointerType
(),
ValueType
(
kObjectType
).
Move
(),
ValueType
(
kObjectType
).
Move
(),
0
);
...
...
@@ -1823,7 +1823,7 @@ private:
StateAllocator
&
GetStateAllocator
()
{
if
(
!
stateAllocator_
)
stateAllocator_
=
ownStateAllocator_
=
RAPIDJSON_NEW
(
StateAllocator
()
);
stateAllocator_
=
ownStateAllocator_
=
RAPIDJSON_NEW
(
StateAllocator
)(
);
return
*
stateAllocator_
;
}
...
...
test/unittest/fwdtest.cpp
View file @
369e07d1
...
...
@@ -100,6 +100,9 @@ struct Foo {
#include "rapidjson/prettywriter.h"
#include "rapidjson/schema.h" // -> pointer.h
typedef
Transcoder
<
UTF8
<>
,
UTF8
<>
>
TranscoderUtf8ToUtf8
;
typedef
BaseReaderHandler
<
UTF8
<>
,
void
>
BaseReaderHandlerUtf8Void
;
Foo
::
Foo
()
:
// encodings.h
utf8
(
RAPIDJSON_NEW
(
UTF8
<>
)),
...
...
@@ -111,40 +114,40 @@ Foo::Foo() :
utf32le
(
RAPIDJSON_NEW
(
UTF32LE
<>
)),
ascii
(
RAPIDJSON_NEW
(
ASCII
<>
)),
autoutf
(
RAPIDJSON_NEW
(
AutoUTF
<
unsigned
>
)),
transcoder
(
RAPIDJSON_NEW
(
(
Transcoder
<
UTF8
<>
,
UTF8
<>
>
)
)),
transcoder
(
RAPIDJSON_NEW
(
TranscoderUtf8ToUtf8
)),
// allocators.h
crtallocator
(
RAPIDJSON_NEW
(
CrtAllocator
)),
memorypoolallocator
(
RAPIDJSON_NEW
(
MemoryPoolAllocator
<>
)),
// stream.h
stringstream
(
RAPIDJSON_NEW
(
StringStream
(
0
)
)),
insitustringstream
(
RAPIDJSON_NEW
(
InsituStringStream
(
0
)
)),
stringstream
(
RAPIDJSON_NEW
(
StringStream
)(
NULL
)),
insitustringstream
(
RAPIDJSON_NEW
(
InsituStringStream
)(
NULL
)),
// stringbuffer.h
stringbuffer
(
RAPIDJSON_NEW
(
StringBuffer
)),
// // filereadstream.h
// filereadstream(RAPIDJSON_NEW(FileReadStream
(stdout, buffer, sizeof(buffer)
))),
// filereadstream(RAPIDJSON_NEW(FileReadStream
)(stdout, buffer, sizeof(buffer
))),
// // filewritestream.h
// filewritestream(RAPIDJSON_NEW(FileWriteStream
(stdout, buffer, sizeof(buffer)
))),
// filewritestream(RAPIDJSON_NEW(FileWriteStream
)(stdout, buffer, sizeof(buffer
))),
// memorybuffer.h
memorybuffer
(
RAPIDJSON_NEW
(
MemoryBuffer
)),
// memorystream.h
memorystream
(
RAPIDJSON_NEW
(
MemoryStream
(
0
,
0
)
)),
memorystream
(
RAPIDJSON_NEW
(
MemoryStream
)(
NULL
,
0
)),
// reader.h
basereaderhandler
(
RAPIDJSON_NEW
(
(
BaseReaderHandler
<
UTF8
<>
,
void
>
)
)),
basereaderhandler
(
RAPIDJSON_NEW
(
BaseReaderHandlerUtf8Void
)),
reader
(
RAPIDJSON_NEW
(
Reader
)),
// writer.h
writer
(
RAPIDJSON_NEW
(
(
Writer
<
StringBuffer
>
)
)),
writer
(
RAPIDJSON_NEW
(
Writer
<
StringBuffer
>
)),
// prettywriter.h
prettywriter
(
RAPIDJSON_NEW
(
(
PrettyWriter
<
StringBuffer
>
)
)),
prettywriter
(
RAPIDJSON_NEW
(
PrettyWriter
<
StringBuffer
>
)),
// document.h
value
(
RAPIDJSON_NEW
(
Value
)),
...
...
@@ -154,8 +157,8 @@ Foo::Foo() :
pointer
(
RAPIDJSON_NEW
(
Pointer
)),
// schema.h
schemadocument
(
RAPIDJSON_NEW
(
SchemaDocument
(
*
document
)
)),
schemavalidator
(
RAPIDJSON_NEW
(
SchemaValidator
(
*
schemadocument
)
))
schemadocument
(
RAPIDJSON_NEW
(
SchemaDocument
)(
*
document
)),
schemavalidator
(
RAPIDJSON_NEW
(
SchemaValidator
)(
*
schemadocument
))
{
}
...
...
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