blob: 8945de58b00f9f3da35e75055283b00c8d9e8af0 [file] [log] [blame]
// Copyright 2017 The Cobalt Authors. All Rights Reserved.
//
// 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.
#ifndef COBALT_SCRIPT_V8C_V8C_VALUE_HANDLE_H_
#define COBALT_SCRIPT_V8C_V8C_VALUE_HANDLE_H_
#include "base/optional.h"
#include "cobalt/script/v8c/scoped_persistent.h"
#include "cobalt/script/v8c/type_traits.h"
#include "cobalt/script/v8c/v8c_user_object_holder.h"
#include "cobalt/script/value_handle.h"
#include "v8/include/v8.h"
namespace cobalt {
namespace script {
namespace v8c {
// A wrapper around a v8::Value that can be passed into Cobalt as a script
// value object.
//
// An ValueHandle is never passed into Cobalt as-is, but only when wrapped as a
// ScriptValue<ValueHandle>.
class V8cValueHandle : public ScopedPersistent<v8::Value>, public ValueHandle {
public:
typedef ValueHandle BaseType;
private:
using ScopedPersistent::ScopedPersistent;
friend class V8cUserObjectHolder<V8cValueHandle>;
};
typedef V8cUserObjectHolder<V8cValueHandle> V8cValueHandleHolder;
template <>
struct TypeTraits<ValueHandle> {
typedef V8cValueHandleHolder ConversionType;
typedef const ScriptValue<ValueHandle>* ReturnType;
};
} // namespace v8c
} // namespace script
} // namespace cobalt
#endif // COBALT_SCRIPT_V8C_V8C_VALUE_HANDLE_H_