Skip to content

Commit 860a1b2

Browse files
committed
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 Signed-off-by: Ivan Prisyazhnyy <[email protected]>
1 parent db6ee3a commit 860a1b2

File tree

8 files changed

+68
-15
lines changed

8 files changed

+68
-15
lines changed

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ filegroup(
3737
cc_library(
3838
name = "wasm_vm_headers",
3939
hdrs = [
40+
"include/proxy-wasm/sdk.h",
4041
"include/proxy-wasm/limits.h",
4142
"include/proxy-wasm/wasm_vm.h",
4243
"include/proxy-wasm/word.h",

include/proxy-wasm/context.h

Lines changed: 1 addition & 3 deletions
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

Lines changed: 2 additions & 3 deletions
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/sdk.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
namespace proxy_wasm {
28+
29+
// FIXME: remove when <proxy_wasm_common.h> will fix std::string namespace ref.
30+
namespace std {
31+
using string = ::std::string;
32+
}
33+
34+
#include "proxy_wasm_common.h"
35+
#include "proxy_wasm_enums.h"
36+
37+
}
38+
39+
}
40+
41+
// proxy_wasm_common.h
42+
using WasmResult = internal::proxy_wasm::WasmResult;
43+
using WasmHeaderMapType = internal::proxy_wasm::WasmHeaderMapType;
44+
using WasmBufferType = internal::proxy_wasm::WasmBufferType;
45+
using WasmBufferFlags = internal::proxy_wasm::WasmBufferFlags;
46+
using WasmStreamType = internal::proxy_wasm::WasmStreamType;
47+
48+
// proxy_wasm_enums.h
49+
using LogLevel = internal::proxy_wasm::LogLevel;
50+
using FilterStatus = internal::proxy_wasm::FilterStatus;
51+
using FilterHeadersStatus = internal::proxy_wasm::FilterHeadersStatus;
52+
using FilterMetadataStatus = internal::proxy_wasm::FilterMetadataStatus;
53+
using FilterTrailersStatus = internal::proxy_wasm::FilterTrailersStatus;
54+
using FilterDataStatus = internal::proxy_wasm::FilterDataStatus;
55+
using GrpcStatus = internal::proxy_wasm::GrpcStatus;
56+
using MetricType = internal::proxy_wasm::MetricType;
57+
using CloseType = internal::proxy_wasm::CloseType;
58+
59+
}

include/proxy-wasm/wasm.h

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
#include <unordered_set>
2525
#include <vector>
2626

27+
#include "include/proxy-wasm/sdk.h"
2728
#include "include/proxy-wasm/word.h"
2829

2930
namespace proxy_wasm {
3031

31-
#include "proxy_wasm_enums.h"
32-
3332
class ContextBase;
3433

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

include/proxy-wasm/word.h

Lines changed: 2 additions & 2 deletions
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__) && \

0 commit comments

Comments
 (0)