// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//

#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
#include "libcef_dll/ctocpp/content_filter_ctocpp.h"


// VIRTUAL METHODS - Body may be edited by hand.

void CefContentFilterCToCpp::ProcessData(const void* data, int data_size,
    CefRefPtr<CefStreamReader>& substitute_data) {
  if (CEF_MEMBER_MISSING(struct_, process_data))
    return;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Verify param: data; type: simple_byaddr
  DCHECK(data);
  if (!data)
    return;

  // Translate param: substitute_data; type: refptr_diff_byref
  cef_stream_reader_t* substitute_dataStruct = NULL;
  if (substitute_data.get())
    substitute_dataStruct = CefStreamReaderCppToC::Wrap(substitute_data);
  cef_stream_reader_t* substitute_dataOrig = substitute_dataStruct;

  // Execute
  struct_->process_data(struct_,
      data,
      data_size,
      &substitute_dataStruct);

  // Restore param:substitute_data; type: refptr_diff_byref
  if (substitute_dataStruct) {
    if (substitute_dataStruct != substitute_dataOrig) {
      substitute_data = CefStreamReaderCppToC::Unwrap(substitute_dataStruct);
    }
  } else {
    substitute_data = NULL;
  }
}

void CefContentFilterCToCpp::Drain(CefRefPtr<CefStreamReader>& remainder) {
  if (CEF_MEMBER_MISSING(struct_, drain))
    return;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Translate param: remainder; type: refptr_diff_byref
  cef_stream_reader_t* remainderStruct = NULL;
  if (remainder.get())
    remainderStruct = CefStreamReaderCppToC::Wrap(remainder);
  cef_stream_reader_t* remainderOrig = remainderStruct;

  // Execute
  struct_->drain(struct_,
      &remainderStruct);

  // Restore param:remainder; type: refptr_diff_byref
  if (remainderStruct) {
    if (remainderStruct != remainderOrig) {
      remainder = CefStreamReaderCppToC::Unwrap(remainderStruct);
    }
  } else {
    remainder = NULL;
  }
}


#ifndef NDEBUG
template<> long CefCToCpp<CefContentFilterCToCpp, CefContentFilter,
    cef_content_filter_t>::DebugObjCt = 0;
#endif

