C++ compiles

reviewable/pr8842/r1
Craig Tiller 8 years ago
parent cca7589333
commit 73ee7dc559
  1. 5
      include/grpc++/impl/codegen/slice.h
  2. 5
      include/grpc/impl/codegen/compression_types.h
  3. 5
      src/cpp/common/channel_filter.cc
  4. 2
      src/cpp/common/channel_filter.h
  5. 3
      src/cpp/common/core_codegen.cc
  6. 15
      src/cpp/server/server_cc.cc
  7. 4
      src/cpp/server/server_context.cc
  8. 2
      test/cpp/common/channel_arguments_test.cc

@ -44,6 +44,11 @@ inline grpc::string_ref StringRefFromSlice(grpc_slice slice) {
GRPC_SLICE_LENGTH(slice));
}
inline grpc::string StringFromCopiedSlice(grpc_slice slice) {
return grpc::string(reinterpret_cast<char*>(GRPC_SLICE_START_PTR(slice)),
GRPC_SLICE_LENGTH(slice));
}
inline grpc_slice SliceReferencingString(const grpc::string& str) {
return g_core_codegen_interface->grpc_slice_from_static_buffer(str.data(),
str.length());

@ -41,6 +41,11 @@
extern "C" {
#endif
/** To be used as initial metadata key for the request of a concrete compression
* algorithm */
#define GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \
"grpc-internal-encoding-request"
/** To be used in channel arguments.
*
* \addtogroup grpc_arg_keys

@ -36,6 +36,8 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/cpp/common/channel_filter.h"
#include <grpc++/impl/codegen/slice.h>
namespace grpc {
// MetadataBatch
@ -45,7 +47,8 @@ grpc_linked_mdelem *MetadataBatch::AddMetadata(grpc_exec_ctx *exec_ctx,
const string &value) {
grpc_linked_mdelem *storage = new grpc_linked_mdelem;
memset(storage, 0, sizeof(grpc_linked_mdelem));
storage->md = grpc_mdelem_from_strings(exec_ctx, key.c_str(), value.c_str());
storage->md = grpc_mdelem_from_slices(exec_ctx, SliceFromCopiedString(key),
SliceFromCopiedString(value));
grpc_metadata_batch_link_head(batch_, storage);
return storage;
}

@ -76,7 +76,7 @@ class MetadataBatch {
class const_iterator : public std::iterator<std::bidirectional_iterator_tag,
const grpc_mdelem> {
public:
const grpc_mdelem &operator*() const { return *elem_->md; }
const grpc_mdelem &operator*() const { return elem_->md; }
const grpc_mdelem operator->() const { return elem_->md; }
const_iterator &operator++() {

@ -130,7 +130,8 @@ grpc_slice CoreCodegen::grpc_slice_from_static_buffer(const void* buffer,
grpc_slice CoreCodegen::grpc_slice_from_copied_buffer(const void* buffer,
size_t length) {
return ::grpc_slice_from_copied_buffer(buffer, length);
return ::grpc_slice_from_copied_buffer(static_cast<const char*>(buffer),
length);
}
void CoreCodegen::grpc_slice_buffer_add(grpc_slice_buffer* sb,

@ -584,10 +584,8 @@ bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag,
for (size_t i = 0; i < initial_metadata_array_.count; i++) {
context_->client_metadata_.insert(
std::pair<grpc::string_ref, grpc::string_ref>(
initial_metadata_array_.metadata[i].key,
grpc::string_ref(
initial_metadata_array_.metadata[i].value,
initial_metadata_array_.metadata[i].value_length)));
StringRefFromSlice(initial_metadata_array_.metadata[i].key),
StringRefFromSlice(initial_metadata_array_.metadata[i].value)));
}
}
grpc_metadata_array_destroy(&initial_metadata_array_);
@ -639,11 +637,12 @@ bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag,
// TODO(yangg) remove the copy here.
if (*status) {
static_cast<GenericServerContext*>(context_)->method_ =
call_details_.method;
static_cast<GenericServerContext*>(context_)->host_ = call_details_.host;
StringFromCopiedSlice(call_details_.method);
static_cast<GenericServerContext*>(context_)->host_ =
StringFromCopiedSlice(call_details_.host);
}
gpr_free(call_details_.method);
gpr_free(call_details_.host);
grpc_slice_unref(call_details_.method);
grpc_slice_unref(call_details_.host);
return BaseAsyncRequest::FinalizeResult(tag, status);
}

@ -145,8 +145,8 @@ ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
compression_level_set_(false) {
for (size_t i = 0; i < metadata_count; i++) {
client_metadata_.insert(std::pair<grpc::string_ref, grpc::string_ref>(
metadata[i].key,
grpc::string_ref(metadata[i].value, metadata[i].value_length)));
StringRefFromSlice(metadata[i].key),
StringRefFromSlice(metadata[i].value)));
}
}

@ -228,7 +228,7 @@ TEST_F(ChannelArgumentsTest, SetSocketMutator) {
EXPECT_FALSE(HasArg(arg0));
// arg0 is destroyed by grpc_socket_mutator_to_arg(mutator1)
arg1.value.pointer.vtable->destroy(arg1.value.pointer.p);
arg1.value.pointer.vtable->destroy(nullptr, arg1.value.pointer.p);
}
TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) {

Loading…
Cancel
Save