Skip to content

Commit e200fee

Browse files
authored
fix a few missing includes and ::proxy_wasm namespace pollution with std {} (#365)
* include: add missing dependencies Signed-off-by: Ivan Prisyazhnyy <[email protected]> * fix: proxy_wasm namespace polution with std defs fixes: In file included from external/proxy_wasm_cpp_host/src/null/null.cc:17: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/null_vm.h:22: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/null_vm_plugin.h:18: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/wasm_vm.h:26: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/word.h:22: external/proxy_wasm_cpp_sdk/proxy_wasm_common.h:59:8: error: no type named 'string' in namespace 'proxy_wasm::std'; did you mean '::std::string'? inline std::string toString(WasmResult r) { ^~~~~~~~~~~ ::std::string The headers from https://github.com/proxy-wasm/proxy-wasm-cpp-sdk include C++ headers that pollute the current namespace with a partial definition of std{} namespace that then interferes with the names resolution inside of proxy_wasm as well as duplicates ::std defs. Signed-off-by: Ivan Prisyazhnyy <[email protected]> * include: add missing includes to pairs_util and the test Signed-off-by: Ivan Prisyazhnyy <[email protected]> * sdk.h/change: drop one redundant namespace hierarchy level to have +using WasmResult = internal::WasmResult; instead of -using WasmResult = internal::proxy_wasm::WasmResult; the patchset fixes: In file included from external/proxy_wasm_cpp_host/src/null/null.cc:17: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/null_vm.h:22: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/null_vm_plugin.h:18: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/wasm_vm.h:26: In file included from external/proxy_wasm_cpp_host/include/proxy-wasm/word.h:22: external/proxy_wasm_cpp_sdk/proxy_wasm_common.h:59:8: error: no type named 'string' in namespace 'proxy_wasm::std'; did you mean '::std::string'? inline std::string toString(WasmResult r) { ^~~~~~~~~~~ ::std::string The headers from https://github.com/proxy-wasm/proxy-wasm-cpp-sdk include C++ headers that pollute the current namespace with a partial definition of std{} namespace that then interferes with the names resolution inside of proxy_wasm as well as duplicates ::std defs. Signed-off-by: Ivan Prisyazhnyy <[email protected]> --------- Signed-off-by: Ivan Prisyazhnyy <[email protected]>
1 parent b7e6907 commit e200fee

11 files changed

+65
-16
lines changed

BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cc_library(
3838
name = "wasm_vm_headers",
3939
hdrs = [
4040
"include/proxy-wasm/limits.h",
41+
"include/proxy-wasm/sdk.h",
4142
"include/proxy-wasm/wasm_vm.h",
4243
"include/proxy-wasm/word.h",
4344
],

include/proxy-wasm/context.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
#include <string_view>
2727
#include <vector>
2828

29+
#include "include/proxy-wasm/sdk.h"
2930
#include "include/proxy-wasm/context_interface.h"
3031

3132
namespace proxy_wasm {
3233

33-
#include "proxy_wasm_common.h"
34-
#include "proxy_wasm_enums.h"
35-
3634
class PluginHandleBase;
3735
class WasmBase;
3836
class WasmVm;

include/proxy-wasm/context_interface.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
#include <memory>
2626
#include <vector>
2727

28-
namespace proxy_wasm {
28+
#include "include/proxy-wasm/sdk.h"
2929

30-
#include "proxy_wasm_common.h"
31-
#include "proxy_wasm_enums.h"
30+
namespace proxy_wasm {
3231

3332
using Pairs = std::vector<std::pair<std::string_view, std::string_view>>;
3433
using PairsWithStringValues = std::vector<std::pair<std::string_view, std::string>>;

include/proxy-wasm/pairs_util.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#pragma once
1717

18+
#include <cstddef>
1819
#include <string>
1920
#include <string_view>
2021
#include <vector>

include/proxy-wasm/sdk.h

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2016-2019 Envoy Project Authors
2+
// Copyright 2020 Google LLC
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
#pragma once
17+
18+
#include <string>
19+
#include <cstdint>
20+
21+
namespace proxy_wasm {
22+
23+
namespace internal {
24+
25+
// isolate those includes to prevent ::proxy_wasm namespace pollution with std
26+
// namespace definitions.
27+
#include "proxy_wasm_common.h"
28+
#include "proxy_wasm_enums.h"
29+
30+
} // namespace internal
31+
32+
// proxy_wasm_common.h
33+
using WasmResult = internal::WasmResult;
34+
using WasmHeaderMapType = internal::WasmHeaderMapType;
35+
using WasmBufferType = internal::WasmBufferType;
36+
using WasmBufferFlags = internal::WasmBufferFlags;
37+
using WasmStreamType = internal::WasmStreamType;
38+
39+
// proxy_wasm_enums.h
40+
using LogLevel = internal::LogLevel;
41+
using FilterStatus = internal::FilterStatus;
42+
using FilterHeadersStatus = internal::FilterHeadersStatus;
43+
using FilterMetadataStatus = internal::FilterMetadataStatus;
44+
using FilterTrailersStatus = internal::FilterTrailersStatus;
45+
using FilterDataStatus = internal::FilterDataStatus;
46+
using GrpcStatus = internal::GrpcStatus;
47+
using MetricType = internal::MetricType;
48+
using CloseType = internal::CloseType;
49+
50+
} // namespace proxy_wasm

include/proxy-wasm/vm_id_handle.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#pragma once
1616

1717
#include <functional>
18-
#include <mutex>
1918
#include <memory>
19+
#include <mutex>
20+
#include <string>
21+
#include <string_view>
2022
#include <unordered_map>
2123

2224
namespace proxy_wasm {

include/proxy-wasm/wasm.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
#include <unordered_map>
2525
#include <unordered_set>
2626

27+
#include "include/proxy-wasm/sdk.h"
2728
#include "include/proxy-wasm/context.h"
2829
#include "include/proxy-wasm/exports.h"
2930
#include "include/proxy-wasm/wasm_vm.h"
3031
#include "include/proxy-wasm/vm_id_handle.h"
3132

3233
namespace proxy_wasm {
3334

34-
#include "proxy_wasm_common.h"
35-
3635
class ContextBase;
3736
class WasmHandleBase;
3837

include/proxy-wasm/wasm_api_impl.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@
3030
#include <utility>
3131
#include <vector>
3232

33+
#include "include/proxy-wasm/sdk.h"
3334
#include "include/proxy-wasm/exports.h"
3435
#include "include/proxy-wasm/word.h"
3536

3637
namespace proxy_wasm {
3738
namespace null_plugin {
3839

39-
#include "proxy_wasm_enums.h"
40-
#include "proxy_wasm_common.h"
41-
4240
#define WS(_x) Word(static_cast<uint64_t>(_x))
4341
#define WR(_x) Word(reinterpret_cast<uint64_t>(_x))
4442

include/proxy-wasm/wasm_vm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
#include <memory>
2020
#include <optional>
2121
#include <string>
22+
#include <string_view>
2223
#include <unordered_map>
2324
#include <unordered_set>
2425
#include <vector>
2526

27+
#include "include/proxy-wasm/sdk.h"
2628
#include "include/proxy-wasm/word.h"
2729

2830
namespace proxy_wasm {
2931

30-
#include "proxy_wasm_enums.h"
31-
3232
class ContextBase;
3333

3434
// These are templates and its helper for constructing signatures of functions calling into Wasm

include/proxy-wasm/word.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#include <iostream>
1919

20-
namespace proxy_wasm {
20+
#include "include/proxy-wasm/sdk.h"
2121

22-
#include "proxy_wasm_common.h"
22+
namespace proxy_wasm {
2323

2424
// Use byteswap functions only when compiling for big-endian platforms.
2525
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \

test/fuzz/pairs_util_fuzzer.cc

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "include/proxy-wasm/pairs_util.h"
1616

17+
#include <cstdint>
1718
#include <cstring>
1819

1920
namespace proxy_wasm {

0 commit comments

Comments
 (0)