forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
com_google_protoconverter.patch
2220 lines (1991 loc) · 87.6 KB
/
com_google_protoconverter.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/src/google/protobuf/stubs/BUILD.bazel b/src/google/protobuf/stubs/BUILD.bazel
index a7b8c82..4f66827 100644
--- a/src/google/protobuf/stubs/BUILD.bazel
+++ b/src/google/protobuf/stubs/BUILD.bazel
@@ -27,13 +27,11 @@ cc_library(
name = "lite",
srcs = [
"bytestream.cc",
- "common.cc",
"strutil.cc",
],
hdrs = [
"bytestream.h",
"callback.h",
- "common.h",
"platform_macros.h",
"port.h",
"status_macros.h",
@@ -43,7 +41,7 @@ cc_library(
include_prefix = "google/protobuf/stubs",
linkopts = LINK_OPTS,
deps = [
- "//src/google/protobuf/util/converter:port_def",
+ "@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
@@ -62,14 +60,12 @@ cc_library(
include_prefix = "google/protobuf/stubs",
textual_hdrs = [
"callback.h",
- "common.h",
"platform_macros.h",
"port.h",
"status_macros.h",
],
deps = [
":lite",
- "//src/google/protobuf/util/converter:port_def",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
@@ -80,7 +76,6 @@ cc_test(
name = "stubs_test",
srcs = [
"bytestream_unittest.cc",
- "common_unittest.cc",
"strutil_unittest.cc",
],
copts = COPTS + select({
diff --git a/src/google/protobuf/stubs/bytestream.h b/src/google/protobuf/stubs/bytestream.h
index 9d08463..e3372cb 100644
--- a/src/google/protobuf/stubs/bytestream.h
+++ b/src/google/protobuf/stubs/bytestream.h
@@ -43,10 +43,6 @@
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/strings/string_view.h"
-#include "google/protobuf/stubs/common.h"
-
-// Must be last.
-#include "google/protobuf/util/converter/port_def.inc" // NOLINT
class CordByteSink;
@@ -65,7 +61,7 @@ namespace strings {
// sink->Append(my_data.data(), my_data.size());
// sink->Flush();
//
-class PROTOBUF_EXPORT ByteSink {
+class ByteSink {
public:
ByteSink() {}
ByteSink(const ByteSink&) = delete;
@@ -93,7 +89,7 @@ class PROTOBUF_EXPORT ByteSink {
// source->Skip(data.length());
// }
//
-class PROTOBUF_EXPORT ByteSource {
+class ByteSource {
public:
ByteSource() {}
ByteSource(const ByteSource&) = delete;
@@ -149,7 +145,7 @@ class PROTOBUF_EXPORT ByteSource {
// sink.Append("hi", 2); // OK
// sink.Append(data, 100); // WOOPS! Overflows buf[10].
//
-class PROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
+class UncheckedArrayByteSink : public ByteSink {
public:
UncheckedArrayByteSink(const UncheckedArrayByteSink&) = delete;
UncheckedArrayByteSink& operator=(const UncheckedArrayByteSink&) = delete;
@@ -178,7 +174,7 @@ class PROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
// sink.Append("hi", 2); // OK
// sink.Append(data, 100); // Will only write 8 more bytes
//
-class PROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
+class CheckedArrayByteSink : public ByteSink {
public:
CheckedArrayByteSink(char* outbuf, size_t capacity);
CheckedArrayByteSink(const CheckedArrayByteSink&) = delete;
@@ -215,7 +211,7 @@ class PROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
// const char* buf = sink.GetBuffer(); // Ownership transferred
// delete[] buf;
//
-class PROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
+class GrowingArrayByteSink : public strings::ByteSink {
public:
explicit GrowingArrayByteSink(size_t estimated_size);
GrowingArrayByteSink(const GrowingArrayByteSink&) = delete;
@@ -246,7 +242,7 @@ class PROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
// sink.Append("World", 5);
// assert(dest == "Hello World");
//
-class PROTOBUF_EXPORT StringByteSink : public ByteSink {
+class StringByteSink : public ByteSink {
public:
explicit StringByteSink(std::string* dest) : dest_(dest) {}
StringByteSink(const StringByteSink&) = delete;
@@ -264,7 +260,7 @@ class PROTOBUF_EXPORT StringByteSink : public ByteSink {
// NullByteSink sink;
// sink.Append(data, data.size()); // All data ignored.
//
-class PROTOBUF_EXPORT NullByteSink : public ByteSink {
+class NullByteSink : public ByteSink {
public:
NullByteSink() {}
NullByteSink(const NullByteSink&) = delete;
@@ -285,7 +281,7 @@ class PROTOBUF_EXPORT NullByteSink : public ByteSink {
// assert(source.Available() == 5);
// assert(source.Peek() == "Hello");
//
-class PROTOBUF_EXPORT ArrayByteSource : public ByteSource {
+class ArrayByteSource : public ByteSource {
public:
explicit ArrayByteSource(absl::string_view s) : input_(s) {}
ArrayByteSource(const ArrayByteSource&) = delete;
@@ -317,7 +313,7 @@ class PROTOBUF_EXPORT ArrayByteSource : public ByteSource {
// assert(limit.Available() == 5);
// assert(limit.Peek() == "Hello");
//
-class PROTOBUF_EXPORT LimitByteSource : public ByteSource {
+class LimitByteSource : public ByteSource {
public:
// Returns at most "limit" bytes from "source".
LimitByteSource(ByteSource* source, size_t limit);
@@ -339,6 +335,4 @@ class PROTOBUF_EXPORT LimitByteSource : public ByteSource {
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc" // NOLINT
-
#endif // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_
\ No newline at end of file
diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h
index 112dfca..daa6901 100644
--- a/src/google/protobuf/stubs/callback.h
+++ b/src/google/protobuf/stubs/callback.h
@@ -19,8 +19,6 @@
#include <type_traits>
-#include "google/protobuf/util/converter/port_def.inc"
-
// ===================================================================
// emulates google3/base/callback.h
@@ -84,7 +82,7 @@ namespace protobuf {
// std::string my_str;
// NewCallback(&Foo, my_str); // WON'T WORK: Can't use references.
// However, correctly-typed pointers will work just fine.
-class PROTOBUF_EXPORT Closure {
+class Closure {
public:
Closure() {}
Closure(const Closure&) = delete;
@@ -106,7 +104,7 @@ class ResultCallback {
};
template <typename R, typename A1>
-class PROTOBUF_EXPORT ResultCallback1 {
+class ResultCallback1 {
public:
ResultCallback1() {}
ResultCallback1(const ResultCallback1&) = delete;
@@ -117,7 +115,7 @@ class PROTOBUF_EXPORT ResultCallback1 {
};
template <typename R, typename A1, typename A2>
-class PROTOBUF_EXPORT ResultCallback2 {
+class ResultCallback2 {
public:
ResultCallback2() {}
ResultCallback2(const ResultCallback2&) = delete;
@@ -129,7 +127,7 @@ class PROTOBUF_EXPORT ResultCallback2 {
namespace internal {
-class PROTOBUF_EXPORT FunctionClosure0 : public Closure {
+class FunctionClosure0 : public Closure {
public:
typedef void (*FunctionType)();
@@ -583,11 +581,9 @@ inline ResultCallback2<R, A1, A2>* NewPermanentCallback(
// A function which does nothing. Useful for creating no-op callbacks, e.g.:
// Closure* nothing = NewCallback(&DoNothing);
-void PROTOBUF_EXPORT DoNothing();
+void DoNothing();
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc"
-
#endif // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index ad033a1..88690fa 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -27,9 +27,6 @@
#include "google/protobuf/stubs/platform_macros.h"
-// Must be last.
-#include "google/protobuf/util/converter/port_def.inc" // NOLINT
-
#undef PROTOBUF_LITTLE_ENDIAN
#ifdef _WIN32
// Assuming windows is always little-endian.
@@ -217,7 +214,7 @@ static inline uint64_t bswap_64(uint64_t x) {
// ===================================================================
// from google3/util/endian/endian.h
-PROTOBUF_EXPORT uint32_t ghtonl(uint32_t x);
+uint32_t ghtonl(uint32_t x);
class BigEndian {
public:
@@ -278,6 +275,4 @@ class BigEndian {
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc"
-
#endif // GOOGLE_PROTOBUF_STUBS_PORT_H_
diff --git a/src/google/protobuf/stubs/status_macros.h b/src/google/protobuf/stubs/status_macros.h
index 46e65eb..5faaf5c 100644
--- a/src/google/protobuf/stubs/status_macros.h
+++ b/src/google/protobuf/stubs/status_macros.h
@@ -19,12 +19,9 @@
#ifndef GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_
#define GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_
+#include "absl/base/optimization.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
-#include "google/protobuf/stubs/common.h"
-
-// Needs to be last.
-#include "google/protobuf/util/converter/port_def.inc" // NOLINT
namespace google {
namespace protobuf {
@@ -39,7 +36,7 @@ namespace util {
do { \
/* Using _status below to avoid capture problems if expr is "status". */ \
const absl::Status _status = (expr); \
- if (PROTOBUF_PREDICT_FALSE(!_status.ok())) return _status; \
+ if (ABSL_PREDICT_FALSE(!_status.ok())) return _status; \
} while (0)
// Internal helper for concatenating macro values.
@@ -56,7 +53,7 @@ absl::Status DoAssignOrReturn(T& lhs, absl::StatusOr<T> result) {
#define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \
absl::Status status = DoAssignOrReturn(lhs, (rexpr)); \
- if (PROTOBUF_PREDICT_FALSE(!status.ok())) return status;
+ if (ABSL_PREDICT_FALSE(!status.ok())) return status;
// Executes an expression that returns a util::StatusOr, extracting its value
// into the variable defined by lhs (or returning on error).
@@ -75,6 +72,4 @@ absl::Status DoAssignOrReturn(T& lhs, absl::StatusOr<T> result) {
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc" // NOLINT
-
#endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_
diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h
index 82882f4..4d09bad 100644
--- a/src/google/protobuf/stubs/strutil.h
+++ b/src/google/protobuf/stubs/strutil.h
@@ -17,15 +17,13 @@
#ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
#define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
-#include <google/protobuf/stubs/common.h>
-#include <stdlib.h>
-
+#include <cstdlib>
#include <cstring>
-#include <google/protobuf/util/converter/port_def.inc>
#include <vector>
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
+#include "google/protobuf/stubs/port.h"
namespace google {
namespace protobuf {
@@ -138,10 +136,9 @@ inline std::string StripSuffixString(const std::string& str,
// StripWhitespace
// Removes whitespaces from both ends of the given string.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT void ReplaceCharacters(std::string* s, const char* remove,
- char replacewith);
+void ReplaceCharacters(std::string* s, const char* remove, char replacewith);
-PROTOBUF_EXPORT void StripWhitespace(std::string* s);
+void StripWhitespace(std::string* s);
// ----------------------------------------------------------------------
// LowerString()
@@ -185,10 +182,8 @@ inline std::string ToUpper(const std::string& s) {
// happened or not.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT std::string StringReplace(const std::string& s,
- const std::string& oldsub,
- const std::string& newsub,
- bool replace_all);
+std::string StringReplace(const std::string& s, const std::string& oldsub,
+ const std::string& newsub, bool replace_all);
// ----------------------------------------------------------------------
// SplitStringUsing()
@@ -196,8 +191,8 @@ PROTOBUF_EXPORT std::string StringReplace(const std::string& s,
// to 'result'. If there are consecutive delimiters, this function skips
// over all of them.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT void SplitStringUsing(absl::string_view full, const char* delim,
- std::vector<std::string>* res);
+void SplitStringUsing(absl::string_view full, const char* delim,
+ std::vector<std::string>* res);
// Split a string using one or more byte delimiters, presented
// as a nul-terminated c string. Append the components to 'result'.
@@ -207,9 +202,8 @@ PROTOBUF_EXPORT void SplitStringUsing(absl::string_view full, const char* delim,
//
// If "full" is the empty string, yields an empty string as the only value.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT void SplitStringAllowEmpty(absl::string_view full,
- const char* delim,
- std::vector<std::string>* result);
+void SplitStringAllowEmpty(absl::string_view full, const char* delim,
+ std::vector<std::string>* result);
// ----------------------------------------------------------------------
// Split()
@@ -234,8 +228,8 @@ inline std::vector<std::string> Split(absl::string_view full, const char* delim,
// another takes a pointer to the target string. In the latter case the
// target string is cleared and overwritten.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT void JoinStrings(const std::vector<std::string>& components,
- const char* delim, std::string* result);
+void JoinStrings(const std::vector<std::string>& components, const char* delim,
+ std::string* result);
inline std::string JoinStrings(const std::vector<std::string>& components,
const char* delim) {
@@ -275,9 +269,9 @@ inline std::string JoinStrings(const std::vector<std::string>& components,
// processed.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest);
-PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
- std::vector<std::string>* errors);
+int UnescapeCEscapeSequences(const char* source, char* dest);
+int UnescapeCEscapeSequences(const char* source, char* dest,
+ std::vector<std::string>* errors);
// ----------------------------------------------------------------------
// UnescapeCEscapeString()
@@ -294,12 +288,10 @@ PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
// the third call, the new string is returned.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int UnescapeCEscapeString(const std::string& src,
- std::string* dest);
-PROTOBUF_EXPORT int UnescapeCEscapeString(const std::string& src,
- std::string* dest,
- std::vector<std::string>* errors);
-PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src);
+int UnescapeCEscapeString(const std::string& src, std::string* dest);
+int UnescapeCEscapeString(const std::string& src, std::string* dest,
+ std::vector<std::string>* errors);
+std::string UnescapeCEscapeString(const std::string& src);
// ----------------------------------------------------------------------
// CEscape()
@@ -308,21 +300,21 @@ PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src);
//
// Escaped chars: \n, \r, \t, ", ', \, and !isprint().
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT std::string CEscape(const std::string& src);
+std::string CEscape(const std::string& src);
// ----------------------------------------------------------------------
// CEscapeAndAppend()
// Escapes 'src' using C-style escape sequences, and appends the escaped
// string to 'dest'.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT void CEscapeAndAppend(absl::string_view src, std::string* dest);
+void CEscapeAndAppend(absl::string_view src, std::string* dest);
namespace strings {
// Like CEscape() but does not escape bytes with the upper bit set.
-PROTOBUF_EXPORT std::string Utf8SafeCEscape(const std::string& src);
+std::string Utf8SafeCEscape(const std::string& src);
// Like CEscape() but uses hex (\x) escapes instead of octals.
-PROTOBUF_EXPORT std::string CHexEscape(const std::string& src);
+std::string CHexEscape(const std::string& src);
} // namespace strings
// ----------------------------------------------------------------------
@@ -335,10 +327,8 @@ PROTOBUF_EXPORT std::string CHexEscape(const std::string& src);
// platforms, so using these is safer, from the point of view of
// overflow behavior, than using the standard libc functions.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int32_t strto32_adaptor(const char* nptr, char** endptr,
- int base);
-PROTOBUF_EXPORT uint32_t strtou32_adaptor(const char* nptr, char** endptr,
- int base);
+int32_t strto32_adaptor(const char* nptr, char** endptr, int base);
+uint32_t strtou32_adaptor(const char* nptr, char** endptr, int base);
inline int32_t strto32(const char* nptr, char** endptr, int base) {
if (sizeof(int32_t) == sizeof(long))
@@ -377,10 +367,10 @@ inline uint64_t strtou64(const char* nptr, char** endptr, int base) {
// safe_strtof()
// safe_strtod()
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT bool safe_strtob(absl::string_view str, bool* value);
+bool safe_strtob(absl::string_view str, bool* value);
-PROTOBUF_EXPORT bool safe_strto32(const std::string& str, int32_t* value);
-PROTOBUF_EXPORT bool safe_strtou32(const std::string& str, uint32_t* value);
+bool safe_strto32(const std::string& str, int32_t* value);
+bool safe_strtou32(const std::string& str, uint32_t* value);
inline bool safe_strto32(const char* str, int32_t* value) {
return safe_strto32(std::string(str), value);
}
@@ -394,8 +384,8 @@ inline bool safe_strtou32(absl::string_view str, uint32_t* value) {
return safe_strtou32(std::string(str), value);
}
-PROTOBUF_EXPORT bool safe_strto64(const std::string& str, int64_t* value);
-PROTOBUF_EXPORT bool safe_strtou64(const std::string& str, uint64_t* value);
+bool safe_strto64(const std::string& str, int64_t* value);
+bool safe_strtou64(const std::string& str, uint64_t* value);
inline bool safe_strto64(const char* str, int64_t* value) {
return safe_strto64(std::string(str), value);
}
@@ -409,8 +399,8 @@ inline bool safe_strtou64(absl::string_view str, uint64_t* value) {
return safe_strtou64(std::string(str), value);
}
-PROTOBUF_EXPORT bool safe_strtof(const char* str, float* value);
-PROTOBUF_EXPORT bool safe_strtod(const char* str, double* value);
+bool safe_strtof(const char* str, float* value);
+bool safe_strtod(const char* str, double* value);
inline bool safe_strtof(const std::string& str, float* value) {
return safe_strtof(str.c_str(), value);
}
@@ -450,13 +440,13 @@ inline bool safe_strtod(absl::string_view str, double* value) {
// DoubleToBuffer() and FloatToBuffer().
static const int kFastToBufferSize = 32;
-PROTOBUF_EXPORT char* FastInt32ToBuffer(int32_t i, char* buffer);
-PROTOBUF_EXPORT char* FastInt64ToBuffer(int64_t i, char* buffer);
+char* FastInt32ToBuffer(int32_t i, char* buffer);
+char* FastInt64ToBuffer(int64_t i, char* buffer);
char* FastUInt32ToBuffer(uint32_t i, char* buffer); // inline below
char* FastUInt64ToBuffer(uint64_t i, char* buffer); // inline below
-PROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer);
-PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64_t i, char* buffer);
-PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32_t i, char* buffer);
+char* FastHexToBuffer(int i, char* buffer);
+char* FastHex64ToBuffer(uint64_t i, char* buffer);
+char* FastHex32ToBuffer(uint32_t i, char* buffer);
// at least 22 bytes long
inline char* FastIntToBuffer(int i, char* buffer) {
@@ -492,10 +482,10 @@ inline char* FastULongToBuffer(unsigned long i, char* buffer) {
// terminating the string).
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32_t i, char* buffer);
-PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32_t i, char* buffer);
-PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64_t i, char* buffer);
-PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64_t i, char* buffer);
+char* FastInt32ToBufferLeft(int32_t i, char* buffer);
+char* FastUInt32ToBufferLeft(uint32_t i, char* buffer);
+char* FastInt64ToBufferLeft(int64_t i, char* buffer);
+char* FastUInt64ToBufferLeft(uint64_t i, char* buffer);
// Just define these in terms of the above.
inline char* FastUInt32ToBuffer(uint32_t i, char* buffer) {
@@ -515,12 +505,12 @@ inline std::string SimpleBtoa(bool value) { return value ? "true" : "false"; }
//
// Return value: string
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT std::string SimpleItoa(int i);
-PROTOBUF_EXPORT std::string SimpleItoa(unsigned int i);
-PROTOBUF_EXPORT std::string SimpleItoa(long i);
-PROTOBUF_EXPORT std::string SimpleItoa(unsigned long i);
-PROTOBUF_EXPORT std::string SimpleItoa(long long i);
-PROTOBUF_EXPORT std::string SimpleItoa(unsigned long long i);
+std::string SimpleItoa(int i);
+std::string SimpleItoa(unsigned int i);
+std::string SimpleItoa(long i);
+std::string SimpleItoa(unsigned long i);
+std::string SimpleItoa(long long i);
+std::string SimpleItoa(unsigned long long i);
// ----------------------------------------------------------------------
// SimpleDtoa()
@@ -541,11 +531,11 @@ PROTOBUF_EXPORT std::string SimpleItoa(unsigned long long i);
//
// Return value: string
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT std::string SimpleDtoa(double value);
-PROTOBUF_EXPORT std::string SimpleFtoa(float value);
+std::string SimpleDtoa(double value);
+std::string SimpleFtoa(float value);
-PROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer);
-PROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer);
+char* DoubleToBuffer(double i, char* buffer);
+char* FloatToBuffer(float i, char* buffer);
// In practice, doubles should never need more than 24 bytes and floats
// should never need more than 14 (including null terminators), but we
@@ -563,7 +553,7 @@ using Hex = absl::Hex;
// ToHex()
// Return a lower-case hex string representation of the given integer.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT std::string ToHex(uint64_t num);
+std::string ToHex(uint64_t num);
// ----------------------------------------------------------------------
// GlobalReplaceSubstring()
@@ -572,9 +562,8 @@ PROTOBUF_EXPORT std::string ToHex(uint64_t num);
//
// NOTE: The string pieces must not overlap s.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int GlobalReplaceSubstring(const std::string& substring,
- const std::string& replacement,
- std::string* s);
+int GlobalReplaceSubstring(const std::string& substring,
+ const std::string& replacement, std::string* s);
// ----------------------------------------------------------------------
// Base64Unescape()
@@ -582,7 +571,7 @@ PROTOBUF_EXPORT int GlobalReplaceSubstring(const std::string& substring,
// writes it to "dest". If src contains invalid characters, dest is cleared
// and the function returns false. Returns true on success.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT bool Base64Unescape(absl::string_view src, std::string* dest);
+bool Base64Unescape(absl::string_view src, std::string* dest);
// ----------------------------------------------------------------------
// WebSafeBase64Unescape()
@@ -595,18 +584,16 @@ PROTOBUF_EXPORT bool Base64Unescape(absl::string_view src, std::string* dest);
// returns false (with dest empty) if src contains invalid chars; for
// this version src and dest must be different strings.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int WebSafeBase64Unescape(const char* src, int slen, char* dest,
- int szdest);
-PROTOBUF_EXPORT bool WebSafeBase64Unescape(absl::string_view src,
- std::string* dest);
+int WebSafeBase64Unescape(const char* src, int slen, char* dest, int szdest);
+bool WebSafeBase64Unescape(absl::string_view src, std::string* dest);
// Return the length to use for the output buffer given to the base64 escape
// routines. Make sure to use the same value for do_padding in both.
// This function may return incorrect results if given input_len values that
// are extremely high, which should happen rarely.
-PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len, bool do_padding);
+int CalculateBase64EscapedLen(int input_len, bool do_padding);
// Use this version when calling Base64Escape without a do_padding arg.
-PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);
+int CalculateBase64EscapedLen(int input_len);
// ----------------------------------------------------------------------
// Base64Escape()
@@ -620,24 +607,20 @@ PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);
// to escape them. It also has an extra parameter "do_padding",
// which when set to false will prevent padding with "=".
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int Base64Escape(const unsigned char* src, int slen, char* dest,
- int szdest);
-PROTOBUF_EXPORT int WebSafeBase64Escape(const unsigned char* src, int slen,
- char* dest, int szdest,
- bool do_padding);
+int Base64Escape(const unsigned char* src, int slen, char* dest, int szdest);
+int WebSafeBase64Escape(const unsigned char* src, int slen, char* dest,
+ int szdest, bool do_padding);
// Encode src into dest with padding.
-PROTOBUF_EXPORT void Base64Escape(absl::string_view src, std::string* dest);
+void Base64Escape(absl::string_view src, std::string* dest);
// Encode src into dest web-safely without padding.
-PROTOBUF_EXPORT void WebSafeBase64Escape(absl::string_view src,
- std::string* dest);
+void WebSafeBase64Escape(absl::string_view src, std::string* dest);
// Encode src into dest web-safely with padding.
-PROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(absl::string_view src,
- std::string* dest);
+void WebSafeBase64EscapeWithPadding(absl::string_view src, std::string* dest);
-PROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc,
- std::string* dest, bool do_padding);
-PROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc,
- std::string* dest, bool do_padding);
+void Base64Escape(const unsigned char* src, int szsrc, std::string* dest,
+ bool do_padding);
+void WebSafeBase64Escape(const unsigned char* src, int szsrc, std::string* dest,
+ bool do_padding);
inline bool IsValidCodePoint(uint32_t code_point) {
return code_point < 0xD800 ||
@@ -651,13 +634,13 @@ static const int UTFmax = 4;
// in any external dependencies. The output buffer must be as least 4 bytes
// large.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32_t code_point, char* output);
+int EncodeAsUTF8Char(uint32_t code_point, char* output);
// ----------------------------------------------------------------------
// UTF8FirstLetterNumBytes()
// Length of the first UTF-8 character.
// ----------------------------------------------------------------------
-PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len);
+int UTF8FirstLetterNumBytes(const char* src, int len);
// From google3/third_party/absl/strings/escaping.h
@@ -693,13 +676,11 @@ PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len);
//
// (1) determines the presence of LF (first one is ok)
// (2) if yes, removes any CR, else convert every CR to LF
-PROTOBUF_EXPORT void CleanStringLineEndings(const std::string& src,
- std::string* dst,
- bool auto_end_last_line);
+void CleanStringLineEndings(const std::string& src, std::string* dst,
+ bool auto_end_last_line);
// Same as above, but transforms the argument in place.
-PROTOBUF_EXPORT void CleanStringLineEndings(std::string* str,
- bool auto_end_last_line);
+void CleanStringLineEndings(std::string* str, bool auto_end_last_line);
namespace strings {
inline bool EndsWith(absl::string_view text, absl::string_view suffix) {
@@ -720,6 +701,5 @@ double NoLocaleStrtod(const char* str, char** endptr);
} // namespace protobuf
} // namespace google
-#include <google/protobuf/util/converter/port_undef.inc>
#endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
\ No newline at end of file
diff --git a/src/google/protobuf/util/converter/BUILD.bazel b/src/google/protobuf/util/converter/BUILD.bazel
index bff9574..bcfa7ea 100644
--- a/src/google/protobuf/util/converter/BUILD.bazel
+++ b/src/google/protobuf/util/converter/BUILD.bazel
@@ -28,8 +28,7 @@ cc_library(
hdrs = ["constants.h"],
strip_include_prefix = "/src",
deps = [
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/util/converter:port_def",
+ "//src/google/protobuf/util/converter:port",
],
)
@@ -42,19 +41,16 @@ cc_library(
deps = [
":constants",
":utility",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/util/converter:port_def",
+ "//src/google/protobuf/util/converter:port",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
],
)
cc_library(
- name = "port_def",
+ name = "port",
hdrs = [
"port.h",
- "port_def.inc",
- "port_undef.inc",
],
strip_include_prefix = "/src",
visibility = [
@@ -78,7 +74,7 @@ cc_library(
":type_info",
":utility",
"//src/google/protobuf/stubs",
- "//src/google/protobuf/util/converter:port_def",
+ "//src/google/protobuf/util/converter:port",
],
)
@@ -133,7 +129,7 @@ cc_library(
":object_writer",
":utility",
"//src/google/protobuf/stubs",
- "//src/google/protobuf/util/converter:port_def",
+ "//src/google/protobuf/util/converter:port",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
diff --git a/src/google/protobuf/util/converter/constants.h b/src/google/protobuf/util/converter/constants.h
index ff75f92..3843aa2 100644
--- a/src/google/protobuf/util/converter/constants.h
+++ b/src/google/protobuf/util/converter/constants.h
@@ -19,8 +19,6 @@
#include <cstdint>
-#include "google/protobuf/stubs/common.h"
-
// This file contains constants used by //net/proto2/util/converter.
namespace google {
diff --git a/src/google/protobuf/util/converter/datapiece.cc b/src/google/protobuf/util/converter/datapiece.cc
index 3acd35d..c7c12ef 100644
--- a/src/google/protobuf/util/converter/datapiece.cc
+++ b/src/google/protobuf/util/converter/datapiece.cc
@@ -18,18 +18,17 @@
#include <cstdint>
#include <limits>
-#include "google/protobuf/struct.pb.h"
-#include "google/protobuf/type.pb.h"
-#include "google/protobuf/descriptor.h"
#include "absl/status/status.h"
#include "absl/strings/ascii.h"
#include "absl/strings/cord.h"
#include "absl/strings/escaping.h"
+#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
-#include "google/protobuf/util/converter/utility.h"
-#include "google/protobuf/stubs/strutil.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/struct.pb.h"
#include "google/protobuf/stubs/strutil.h"
-#include "absl/strings/match.h"
+#include "google/protobuf/type.pb.h"
+#include "google/protobuf/util/converter/utility.h"
namespace google {
namespace protobuf {
diff --git a/src/google/protobuf/util/converter/datapiece.h b/src/google/protobuf/util/converter/datapiece.h
index 68b6b0e..fc25a7a 100644
--- a/src/google/protobuf/util/converter/datapiece.h
+++ b/src/google/protobuf/util/converter/datapiece.h
@@ -20,15 +20,10 @@
#include <cstdint>
#include <string>
-#include "google/protobuf/stubs/common.h"
-#include "google/protobuf/type.pb.h"
#include "absl/log/absl_log.h"
-
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
-
-// Must be included last.
-#include "google/protobuf/util/converter/port_def.inc"
+#include "google/protobuf/type.pb.h"
namespace google {
namespace protobuf {
@@ -46,7 +41,7 @@ class ProtoWriter;
// storage for the actual string or Cord, so it is the user's responsibility to
// guarantee that the underlying storage is still valid when the DataPiece is
// accessed.
-class PROTOBUF_EXPORT DataPiece {
+class DataPiece {
public:
// Identifies data type of the value.
// These are the types supported by DataPiece.
@@ -107,8 +102,7 @@ class PROTOBUF_EXPORT DataPiece {
static DataPiece NullData() { return DataPiece(TYPE_NULL, 0); }
- virtual ~DataPiece() {
- }
+ virtual ~DataPiece() {}
// Accessors
Type type() const { return type_; }
@@ -120,7 +114,6 @@ class PROTOBUF_EXPORT DataPiece {
return str_;
}
-
// Parses, casts or converts the value stored in the DataPiece into an int32.
absl::StatusOr<int32_t> ToInt32() const;
@@ -206,6 +199,4 @@ class PROTOBUF_EXPORT DataPiece {
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc"
-
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H_
diff --git a/src/google/protobuf/util/converter/default_value_objectwriter.h b/src/google/protobuf/util/converter/default_value_objectwriter.h
index 0b253c8..4538fc7 100644
--- a/src/google/protobuf/util/converter/default_value_objectwriter.h
+++ b/src/google/protobuf/util/converter/default_value_objectwriter.h
@@ -31,9 +31,6 @@
#include "google/protobuf/util/converter/utility.h"
#include "google/protobuf/util/type_resolver.h"
-// Must be included last.
-#include "google/protobuf/util/converter/port_def.inc"
-
namespace google {
namespace protobuf {
namespace util {
@@ -45,7 +42,7 @@ namespace converter {
// ObjectWriter when EndObject() is called on the root object. It also writes
// out all non-repeated primitive fields that haven't been explicitly rendered
// with their default values (0 for numbers, "" for strings, etc).
-class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
+class DefaultValueObjectWriter : public ObjectWriter {
public:
// A Callback function to check whether a field needs to be scrubbed.
//
@@ -134,7 +131,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// "Node" represents a node in the tree that holds the input of
// DefaultValueObjectWriter.
- class PROTOBUF_EXPORT Node {
+ class Node {
public:
Node(const std::string& name, const google::protobuf::Type* type,
NodeKind kind, const DataPiece& data, bool is_placeholder,
@@ -312,6 +309,4 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc"
-
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H_
diff --git a/src/google/protobuf/util/converter/error_listener.h b/src/google/protobuf/util/converter/error_listener.h
index 2d671a5..04c4df6 100644
--- a/src/google/protobuf/util/converter/error_listener.h
+++ b/src/google/protobuf/util/converter/error_listener.h
@@ -22,21 +22,17 @@
#include <string>
#include <vector>
-#include "google/protobuf/stubs/callback.h"
-#include "google/protobuf/stubs/common.h"
#include "absl/strings/string_view.h"
+#include "google/protobuf/stubs/callback.h"
#include "google/protobuf/util/converter/location_tracker.h"
-// Must be included last.
-#include "google/protobuf/util/converter/port_def.inc"
-
namespace google {
namespace protobuf {
namespace util {
namespace converter {
// Interface for error listener.
-class PROTOBUF_EXPORT ErrorListener {
+class ErrorListener {
public:
ErrorListener(const ErrorListener&) = delete;
ErrorListener& operator=(const ErrorListener&) = delete;
@@ -61,7 +57,7 @@ class PROTOBUF_EXPORT ErrorListener {
};
// An error listener that ignores all errors.
-class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
+class NoopErrorListener : public ErrorListener {
public:
NoopErrorListener() {}
NoopErrorListener(const NoopErrorListener&) = delete;
@@ -80,12 +76,9 @@ class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
absl::string_view /* missing_name */) override {}
};
-
} // namespace converter
} // namespace util
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc"
-
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H_
diff --git a/src/google/protobuf/util/converter/field_mask_utility.cc b/src/google/protobuf/util/converter/field_mask_utility.cc
index 03736d7..c3a8ec2 100644
--- a/src/google/protobuf/util/converter/field_mask_utility.cc
+++ b/src/google/protobuf/util/converter/field_mask_utility.cc
@@ -17,11 +17,8 @@
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
-#include "google/protobuf/util/converter/utility.h"
#include "google/protobuf/stubs/status_macros.h"
-
-// Must be included last.
-#include "google/protobuf/util/converter/port_def.inc"
+#include "google/protobuf/util/converter/utility.h"
namespace google {
namespace protobuf {
diff --git a/src/google/protobuf/util/converter/json_objectwriter.h b/src/google/protobuf/util/converter/json_objectwriter.h
index e3caf4d..4069682 100644
--- a/src/google/protobuf/util/converter/json_objectwriter.h
+++ b/src/google/protobuf/util/converter/json_objectwriter.h
@@ -21,20 +21,15 @@
#include <memory>
#include <string>
+#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/stubs/bytestream.h"
#include "google/protobuf/util/converter/structured_objectwriter.h"
-#include "google/protobuf/io/coded_stream.h"
-
-// clang-format off
-#include "google/protobuf/util/converter/port_def.inc"
-// clang-format on
namespace google {
namespace protobuf {
namespace util {
namespace converter {
-
// An ObjectWriter implementation that outputs JSON. This ObjectWriter
// supports writing a compact form or a pretty printed form.
//
@@ -74,7 +69,7 @@ namespace converter {
// uint64 would lose precision if rendered as numbers.
//
// JsonObjectWriter is thread-unsafe.
-class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
+class JsonObjectWriter : public StructuredObjectWriter {
public:
JsonObjectWriter(absl::string_view indent_string, io::CodedOutputStream* out)
: element_(new Element(/*parent=*/nullptr, /*is_json_object=*/false)),
@@ -127,7 +122,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
}
protected:
- class PROTOBUF_EXPORT Element : public BaseElement {
+ class Element : public BaseElement {
public:
Element(Element* parent, bool is_json_object)
: BaseElement(parent),
@@ -158,7 +153,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
Element* element() override { return element_.get(); }
private:
- class PROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
+ class ByteSinkWrapper : public strings::ByteSink {
public:
explicit ByteSinkWrapper(io::CodedOutputStream* stream) : stream_(stream) {}
ByteSinkWrapper(const ByteSinkWrapper&) = delete;
@@ -260,6 +255,4 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
} // namespace protobuf
} // namespace google
-#include "google/protobuf/util/converter/port_undef.inc"
-
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H_
diff --git a/src/google/protobuf/util/converter/json_stream_parser.h b/src/google/protobuf/util/converter/json_stream_parser.h
index ed30e3a..3cc40a4 100644
--- a/src/google/protobuf/util/converter/json_stream_parser.h
+++ b/src/google/protobuf/util/converter/json_stream_parser.h
@@ -21,22 +21,15 @@
#include <stack>
#include <string>
-#include "google/protobuf/stubs/common.h"
#include "absl/status/status.h"