Skip to content

Commit 41ceb86

Browse files
committed
- replaced RAPIDJSON_NEW with C++98 compatible version
1 parent 3f120ca commit 41ceb86

File tree

8 files changed

+24
-21
lines changed

8 files changed

+24
-21
lines changed

include/rapidjson/allocators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class MemoryPoolAllocator {
236236
*/
237237
bool AddChunk(size_t capacity) {
238238
if (!baseAllocator_)
239-
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator);
239+
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator)();
240240
if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) {
241241
chunk->capacity = capacity;
242242
chunk->size = 0;

include/rapidjson/document.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
20882088
GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
20892089
{
20902090
if (!allocator_)
2091-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
2091+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
20922092
}
20932093

20942094
//! Constructor
@@ -2101,7 +2101,7 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
21012101
allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
21022102
{
21032103
if (!allocator_)
2104-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
2104+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
21052105
}
21062106

21072107
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS

include/rapidjson/internal/regex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ class GenericRegexSearch {
606606
{
607607
RAPIDJSON_ASSERT(regex_.IsValid());
608608
if (!allocator_)
609-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
609+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
610610
stateSet_ = static_cast<unsigned*>(allocator_->Malloc(GetStateSetSize()));
611611
state0_.template Reserve<SizeType>(regex_.stateCount_);
612612
state1_.template Reserve<SizeType>(regex_.stateCount_);

include/rapidjson/internal/stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Stack {
183183
size_t newCapacity;
184184
if (stack_ == 0) {
185185
if (!allocator_)
186-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
186+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
187187
newCapacity = initialCapacity_;
188188
} else {
189189
newCapacity = GetCapacity();

include/rapidjson/pointer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ class GenericPointer {
758758
*/
759759
Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) {
760760
if (!allocator_) // allocator is independently owned.
761-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
761+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
762762

763763
size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens
764764
for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t)
@@ -806,7 +806,7 @@ class GenericPointer {
806806

807807
// Create own allocator if user did not supply.
808808
if (!allocator_)
809-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
809+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
810810

811811
// Count number of '/' as tokenCount
812812
tokenCount_ = 0;

include/rapidjson/rapidjson.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ RAPIDJSON_NAMESPACE_END
583583

584584
#ifndef RAPIDJSON_NEW
585585
///! customization point for global \c new
586-
#define RAPIDJSON_NEW(type, ...) new type(__VA_ARGS__)
586+
#define RAPIDJSON_NEW(TypeName) new TypeName
587587
#endif
588588
#ifndef RAPIDJSON_DELETE
589589
///! customization point for global \c delete

include/rapidjson/schema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ class GenericSchemaDocument {
13441344
schemaRef_(allocator, kInitialSchemaRefSize)
13451345
{
13461346
if (!allocator_)
1347-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
1347+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
13481348

13491349
typeless_ = static_cast<SchemaType*>(allocator_->Malloc(sizeof(SchemaType)));
13501350
new (typeless_) SchemaType(this, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), 0);
@@ -1823,7 +1823,7 @@ RAPIDJSON_MULTILINEMACRO_END
18231823

18241824
StateAllocator& GetStateAllocator() {
18251825
if (!stateAllocator_)
1826-
stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator);
1826+
stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator)();
18271827
return *stateAllocator_;
18281828
}
18291829

test/unittest/fwdtest.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ struct Foo {
100100
#include "rapidjson/prettywriter.h"
101101
#include "rapidjson/schema.h" // -> pointer.h
102102

103+
typedef Transcoder<UTF8<>, UTF8<> > TranscoderUtf8ToUtf8;
104+
typedef BaseReaderHandler<UTF8<>, void> BaseReaderHandlerUtf8Void;
105+
103106
Foo::Foo() :
104107
// encodings.h
105108
utf8(RAPIDJSON_NEW(UTF8<>)),
@@ -111,40 +114,40 @@ Foo::Foo() :
111114
utf32le(RAPIDJSON_NEW(UTF32LE<>)),
112115
ascii(RAPIDJSON_NEW(ASCII<>)),
113116
autoutf(RAPIDJSON_NEW(AutoUTF<unsigned>)),
114-
transcoder(RAPIDJSON_NEW((Transcoder<UTF8<>, UTF8<> >))),
117+
transcoder(RAPIDJSON_NEW(TranscoderUtf8ToUtf8)),
115118

116119
// allocators.h
117120
crtallocator(RAPIDJSON_NEW(CrtAllocator)),
118121
memorypoolallocator(RAPIDJSON_NEW(MemoryPoolAllocator<>)),
119122

120123
// stream.h
121-
stringstream(RAPIDJSON_NEW(StringStream, NULL)),
122-
insitustringstream(RAPIDJSON_NEW(InsituStringStream, NULL)),
124+
stringstream(RAPIDJSON_NEW(StringStream)(NULL)),
125+
insitustringstream(RAPIDJSON_NEW(InsituStringStream)(NULL)),
123126

124127
// stringbuffer.h
125128
stringbuffer(RAPIDJSON_NEW(StringBuffer)),
126129

127130
// // filereadstream.h
128-
// filereadstream(RAPIDJSON_NEW(FileReadStream, stdout, buffer, sizeof(buffer))),
131+
// filereadstream(RAPIDJSON_NEW(FileReadStream)(stdout, buffer, sizeof(buffer))),
129132

130133
// // filewritestream.h
131-
// filewritestream(RAPIDJSON_NEW(FileWriteStream, stdout, buffer, sizeof(buffer))),
134+
// filewritestream(RAPIDJSON_NEW(FileWriteStream)(stdout, buffer, sizeof(buffer))),
132135

133136
// memorybuffer.h
134137
memorybuffer(RAPIDJSON_NEW(MemoryBuffer)),
135138

136139
// memorystream.h
137-
memorystream(RAPIDJSON_NEW(MemoryStream, NULL, 0)),
140+
memorystream(RAPIDJSON_NEW(MemoryStream)(NULL, 0)),
138141

139142
// reader.h
140-
basereaderhandler(RAPIDJSON_NEW((BaseReaderHandler<UTF8<>, void>))),
143+
basereaderhandler(RAPIDJSON_NEW(BaseReaderHandlerUtf8Void)),
141144
reader(RAPIDJSON_NEW(Reader)),
142145

143146
// writer.h
144-
writer(RAPIDJSON_NEW((Writer<StringBuffer>))),
147+
writer(RAPIDJSON_NEW(Writer<StringBuffer>)),
145148

146149
// prettywriter.h
147-
prettywriter(RAPIDJSON_NEW((PrettyWriter<StringBuffer>))),
150+
prettywriter(RAPIDJSON_NEW(PrettyWriter<StringBuffer>)),
148151

149152
// document.h
150153
value(RAPIDJSON_NEW(Value)),
@@ -154,8 +157,8 @@ Foo::Foo() :
154157
pointer(RAPIDJSON_NEW(Pointer)),
155158

156159
// schema.h
157-
schemadocument(RAPIDJSON_NEW(SchemaDocument, *document)),
158-
schemavalidator(RAPIDJSON_NEW(SchemaValidator, *schemadocument))
160+
schemadocument(RAPIDJSON_NEW(SchemaDocument)(*document)),
161+
schemavalidator(RAPIDJSON_NEW(SchemaValidator)(*schemadocument))
159162
{
160163

161164
}

0 commit comments

Comments
 (0)