diff --git a/BUILD b/BUILD index 8b3301990..66c3371d6 100644 --- a/BUILD +++ b/BUILD @@ -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", ], diff --git a/include/proxy-wasm/context.h b/include/proxy-wasm/context.h index ab99cad70..12937041f 100644 --- a/include/proxy-wasm/context.h +++ b/include/proxy-wasm/context.h @@ -26,13 +26,11 @@ #include #include +#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; diff --git a/include/proxy-wasm/context_interface.h b/include/proxy-wasm/context_interface.h index 81973eed2..48fce76d9 100644 --- a/include/proxy-wasm/context_interface.h +++ b/include/proxy-wasm/context_interface.h @@ -25,10 +25,9 @@ #include #include -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>; using PairsWithStringValues = std::vector>; diff --git a/include/proxy-wasm/pairs_util.h b/include/proxy-wasm/pairs_util.h index 54df2fd88..019c970ba 100644 --- a/include/proxy-wasm/pairs_util.h +++ b/include/proxy-wasm/pairs_util.h @@ -15,6 +15,7 @@ #pragma once +#include #include #include #include diff --git a/include/proxy-wasm/sdk.h b/include/proxy-wasm/sdk.h new file mode 100644 index 000000000..105854373 --- /dev/null +++ b/include/proxy-wasm/sdk.h @@ -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 +#include + +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 diff --git a/include/proxy-wasm/vm_id_handle.h b/include/proxy-wasm/vm_id_handle.h index 547eca229..16ebb4bf0 100644 --- a/include/proxy-wasm/vm_id_handle.h +++ b/include/proxy-wasm/vm_id_handle.h @@ -15,8 +15,10 @@ #pragma once #include -#include #include +#include +#include +#include #include namespace proxy_wasm { diff --git a/include/proxy-wasm/wasm.h b/include/proxy-wasm/wasm.h index 1a785a8f9..9fa2bda1f 100644 --- a/include/proxy-wasm/wasm.h +++ b/include/proxy-wasm/wasm.h @@ -24,6 +24,7 @@ #include #include +#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" @@ -31,8 +32,6 @@ namespace proxy_wasm { -#include "proxy_wasm_common.h" - class ContextBase; class WasmHandleBase; diff --git a/include/proxy-wasm/wasm_api_impl.h b/include/proxy-wasm/wasm_api_impl.h index 8bd9626ff..899af7e41 100644 --- a/include/proxy-wasm/wasm_api_impl.h +++ b/include/proxy-wasm/wasm_api_impl.h @@ -30,15 +30,13 @@ #include #include +#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(_x)) #define WR(_x) Word(reinterpret_cast(_x)) diff --git a/include/proxy-wasm/wasm_vm.h b/include/proxy-wasm/wasm_vm.h index acf0ccf3b..a573212e0 100644 --- a/include/proxy-wasm/wasm_vm.h +++ b/include/proxy-wasm/wasm_vm.h @@ -19,16 +19,16 @@ #include #include #include +#include #include #include #include +#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 diff --git a/include/proxy-wasm/word.h b/include/proxy-wasm/word.h index 90ea932df..bc0d23a8c 100644 --- a/include/proxy-wasm/word.h +++ b/include/proxy-wasm/word.h @@ -17,9 +17,9 @@ #include -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__) && \ diff --git a/test/fuzz/pairs_util_fuzzer.cc b/test/fuzz/pairs_util_fuzzer.cc index aaef0d099..84e7ca0f1 100644 --- a/test/fuzz/pairs_util_fuzzer.cc +++ b/test/fuzz/pairs_util_fuzzer.cc @@ -14,6 +14,7 @@ #include "include/proxy-wasm/pairs_util.h" +#include #include namespace proxy_wasm {