chromium/third_party/blink/renderer/bindings/core/v8/pass_as_span.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_PASS_AS_SPAN_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_PASS_AS_SPAN_H_

#include "base/containers/span.h"
#include "base/memory/stack_allocated.h"
#include "third_party/blink/renderer/core/core_export.h"

namespace blink {

namespace bindingsinternal  // namespace bindings::internal

// This is a marker class for differentiating [PassAsSpan] argument conversions.
// The actual type returned is `SpanWithInlineStorage`, however, unlike the
// returned type, the marker carries additional information for conversion
// (whether shared array buffers should be allowed, whether a typed array
// is expected etc).
struct PassAsSpanMarkerBase {};

constexpr PassAsSpanMarkerBase::Flags operator|(PassAsSpanMarkerBase::Flags a,
                                                PassAsSpanMarkerBase::Flags b) {}

template <PassAsSpanMarkerBase::Flags flags =
              PassAsSpanMarkerBase::Flags::kNone,
          typename T = void>
struct PassAsSpan : public PassAsSpanMarkerBase {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_PASS_AS_SPAN_H_