Skip to content

fix a few missing includes and ::proxy_wasm namespace pollution with std {} #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ cc_library(
name = "wasm_vm_headers",
hdrs = [
"include/proxy-wasm/limits.h",
"include/proxy-wasm/sdk.h",
"include/proxy-wasm/wasm_vm.h",
"include/proxy-wasm/word.h",
],
Expand Down
4 changes: 1 addition & 3 deletions include/proxy-wasm/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
#include <string_view>
#include <vector>

#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/context_interface.h"

namespace proxy_wasm {

#include "proxy_wasm_common.h"
#include "proxy_wasm_enums.h"

class PluginHandleBase;
class WasmBase;
class WasmVm;
Expand Down
5 changes: 2 additions & 3 deletions include/proxy-wasm/context_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
#include <memory>
#include <vector>

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

#include "proxy_wasm_common.h"
#include "proxy_wasm_enums.h"
namespace proxy_wasm {

using Pairs = std::vector<std::pair<std::string_view, std::string_view>>;
using PairsWithStringValues = std::vector<std::pair<std::string_view, std::string>>;
Expand Down
1 change: 1 addition & 0 deletions include/proxy-wasm/pairs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#include <cstddef>
#include <string>
#include <string_view>
#include <vector>
Expand Down
50 changes: 50 additions & 0 deletions include/proxy-wasm/sdk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2016-2019 Envoy Project Authors
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <string>
#include <cstdint>

namespace proxy_wasm {

namespace internal {

// isolate those includes to prevent ::proxy_wasm namespace pollution with std
// namespace definitions.
#include "proxy_wasm_common.h"
#include "proxy_wasm_enums.h"

} // namespace internal

// proxy_wasm_common.h
using WasmResult = internal::WasmResult;
using WasmHeaderMapType = internal::WasmHeaderMapType;
using WasmBufferType = internal::WasmBufferType;
using WasmBufferFlags = internal::WasmBufferFlags;
using WasmStreamType = internal::WasmStreamType;

// proxy_wasm_enums.h
using LogLevel = internal::LogLevel;
using FilterStatus = internal::FilterStatus;
using FilterHeadersStatus = internal::FilterHeadersStatus;
using FilterMetadataStatus = internal::FilterMetadataStatus;
using FilterTrailersStatus = internal::FilterTrailersStatus;
using FilterDataStatus = internal::FilterDataStatus;
using GrpcStatus = internal::GrpcStatus;
using MetricType = internal::MetricType;
using CloseType = internal::CloseType;

} // namespace proxy_wasm
4 changes: 3 additions & 1 deletion include/proxy-wasm/vm_id_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#pragma once

#include <functional>
#include <mutex>
#include <memory>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

namespace proxy_wasm {
Expand Down
3 changes: 1 addition & 2 deletions include/proxy-wasm/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
#include <unordered_map>
#include <unordered_set>

#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/context.h"
#include "include/proxy-wasm/exports.h"
#include "include/proxy-wasm/wasm_vm.h"
#include "include/proxy-wasm/vm_id_handle.h"

namespace proxy_wasm {

#include "proxy_wasm_common.h"

class ContextBase;
class WasmHandleBase;

Expand Down
4 changes: 1 addition & 3 deletions include/proxy-wasm/wasm_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
#include <utility>
#include <vector>

#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/exports.h"
#include "include/proxy-wasm/word.h"

namespace proxy_wasm {
namespace null_plugin {

#include "proxy_wasm_enums.h"
#include "proxy_wasm_common.h"

#define WS(_x) Word(static_cast<uint64_t>(_x))
#define WR(_x) Word(reinterpret_cast<uint64_t>(_x))

Expand Down
4 changes: 2 additions & 2 deletions include/proxy-wasm/wasm_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/word.h"

namespace proxy_wasm {

#include "proxy_wasm_enums.h"

class ContextBase;

// These are templates and its helper for constructing signatures of functions calling into Wasm
Expand Down
4 changes: 2 additions & 2 deletions include/proxy-wasm/word.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

#include <iostream>

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

#include "proxy_wasm_common.h"
namespace proxy_wasm {

// Use byteswap functions only when compiling for big-endian platforms.
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
Expand Down
1 change: 1 addition & 0 deletions test/fuzz/pairs_util_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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

#include <cstdint>
#include <cstring>

namespace proxy_wasm {
Expand Down