1
+ #include "common-prelude.h"
2
+
1
3
#ifndef BSON_BSON_DSL_H_INCLUDED
2
4
#define BSON_BSON_DSL_H_INCLUDED
3
5
@@ -22,10 +24,10 @@ enum {
22
24
};
23
25
24
26
#define _bson_thread_local \
25
- BSON_IF_GNU_LIKE (__thread) BSON_IF_MSVC (__declspec(thread))
27
+ BSON_IF_GNU_LIKE (__thread) BSON_IF_MSVC (__declspec (thread))
26
28
27
- #define _bson_comdat \
28
- BSON_IF_WINDOWS (__declspec(selectany)) \
29
+ #define _bson_comdat \
30
+ BSON_IF_WINDOWS (__declspec (selectany)) \
29
31
BSON_IF_POSIX (__attribute__ ((weak)))
30
32
31
33
#ifdef __GNUC__
@@ -89,7 +91,7 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
89
91
#define _bsonDSL_end \
90
92
--_bson_dsl_indent; \
91
93
} \
92
- else((void) 0)
94
+ else ((void) 0)
93
95
94
96
/**
95
97
* @brief Expands to a call to bson_append_{Kind}, with the three first
@@ -286,7 +288,7 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
286
288
const bool _bvHalt = false; /* Required for _bsonVisitEach() */ \
287
289
_bsonVisitEach ( \
288
290
OtherBSON , \
289
- if (Pred , then (do (_bsonDocOperation_iterElement (bsonVisitIter ))))); \
291
+ if (Pred , then (do (_bsonDocOperation_iterElement (bsonVisitIter ))))); \
290
292
_bsonDSL_end
291
293
292
294
#define _bsonDocOperation_insertFromIter (Iter , Pred ) \
@@ -312,16 +314,16 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
312
314
313
315
/// Insert the given BSON document into the parent array. Keys of the given
314
316
/// document are discarded and it is treated as an array of values.
315
- #define _bsonArrayOperation_insert (OtherArr , Pred ) \
316
- _bsonDSL_begin ("Insert other array: [%s]", _bsonDSL_str (OtherArr)); \
317
- _bsonVisitEach ( \
318
- OtherArr, \
319
- if (Pred, then (do(_bsonArrayOperation_iterValue (bsonVisitIter))))); \
317
+ #define _bsonArrayOperation_insert (OtherArr , Pred ) \
318
+ _bsonDSL_begin ("Insert other array: [%s]", _bsonDSL_str (OtherArr)); \
319
+ _bsonVisitEach ( \
320
+ OtherArr, \
321
+ if (Pred, then (do (_bsonArrayOperation_iterValue (bsonVisitIter))))); \
320
322
_bsonDSL_end
321
323
322
324
#define _bsonArrayAppendValue (ValueOperation ) \
323
325
_bsonDSL_begin ("[%d] => [%s]", \
324
- (int) bsonBuildContext.index, \
326
+ (int) bsonBuildContext.index, \
325
327
_bsonDSL_strElide (30, ValueOperation)); \
326
328
/* Set the doc key to the array index as a string: */ \
327
329
_bsonBuild_setKeyToArrayIndex (bsonBuildContext .index ); \
@@ -396,9 +398,11 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
396
398
_bsonValueOperationIf_##Else; \
397
399
}
398
400
399
- #define _bsonBuild_setKeyToArrayIndex (Idx ) \
400
- _bbCtx.key_len = bson_snprintf ( \
401
- _bbCtx.index_key_str, sizeof _bbCtx.index_key_str, "%d",(int) _bbCtx.index); \
401
+ #define _bsonBuild_setKeyToArrayIndex (Idx ) \
402
+ _bbCtx.key_len = bson_snprintf (_bbCtx.index_key_str, \
403
+ sizeof _bbCtx.index_key_str, \
404
+ "%d", \
405
+ (int) _bbCtx.index); \
402
406
_bbCtx.key = _bbCtx.index_key_str
403
407
404
408
/// Handle an element of array()
@@ -716,19 +720,19 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
716
720
(NthInt < _bpNumVisitBitInts && \
717
721
(_bpVisitBits[NthInt] & (UINT64_C (1) << NthBit)))
718
722
719
- #define _bsonParseOperation_find (Predicate , ...) \
720
- _bsonDSL_begin ("find(%s)", _bsonDSL_str (Predicate)); \
721
- _bpFoundElement = false; \
722
- _bsonVisitEach ( \
723
- *_bpDoc, \
724
- if (Predicate, \
725
- then (do(_bsonParseMarkVisited (bsonVisitContext.index); \
726
- _bpFoundElement = true), \
727
- __VA_ARGS__, \
728
- break))); \
729
- if (!_bpFoundElement && !bsonParseError) { \
730
- _bsonDSLDebug ("[not found]"); \
731
- } \
723
+ #define _bsonParseOperation_find (Predicate , ...) \
724
+ _bsonDSL_begin ("find(%s)", _bsonDSL_str (Predicate)); \
725
+ _bpFoundElement = false; \
726
+ _bsonVisitEach ( \
727
+ *_bpDoc, \
728
+ if (Predicate, \
729
+ then (do (_bsonParseMarkVisited (bsonVisitContext.index); \
730
+ _bpFoundElement = true), \
731
+ __VA_ARGS__, \
732
+ break))); \
733
+ if (!_bpFoundElement && !bsonParseError) { \
734
+ _bsonDSLDebug ("[not found]"); \
735
+ } \
732
736
_bsonDSL_end
733
737
734
738
#define _bsonParseOperation_require (Predicate , ...) \
@@ -737,8 +741,8 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
737
741
_bsonVisitEach ( \
738
742
*_bpDoc, \
739
743
if (Predicate, \
740
- then (do(_bsonParseMarkVisited (bsonVisitContext.index); \
741
- _bpFoundElement = true), \
744
+ then (do (_bsonParseMarkVisited (bsonVisitContext.index); \
745
+ _bpFoundElement = true), \
742
746
__VA_ARGS__, \
743
747
break))); \
744
748
if (!_bpFoundElement && !bsonParseError) { \
@@ -1140,7 +1144,7 @@ _bson_dsl_dupPath (char **into)
1140
1144
char * prev = acc ;
1141
1145
if (ctx -> parent && BSON_ITER_HOLDS_ARRAY (& ctx -> parent -> iter )) {
1142
1146
// We're an array element
1143
- acc = bson_strdup_printf ("[%d]%s" , (int )ctx -> index , prev );
1147
+ acc = bson_strdup_printf ("[%d]%s" , (int ) ctx -> index , prev );
1144
1148
} else {
1145
1149
// We're a document element
1146
1150
acc = bson_strdup_printf (".%s%s" , bson_iter_key (& ctx -> iter ), prev );
0 commit comments