* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 ECMASCRIPT_MODULE_JS_MODULE_NAMESPACE_H
#define ECMASCRIPT_MODULE_JS_MODULE_NAMESPACE_H
#include "ecmascript/js_object.h"
#include "ecmascript/js_tagged_value.h"
namespace panda::ecmascript {
class ModuleNamespace final : public JSObject {
public:
CAST_CHECK(ModuleNamespace, IsModuleNamespace);
static JSHandle<JSTaggedValue> CreateSortedExports(JSThread *thread, const JSHandle<TaggedArray> &exports);
static void SetModuleDeregisterProcession(JSThread *thread, const JSHandle<ModuleNamespace> &nameSpace,
const NativePointerCallback &callback);
static JSHandle<ModuleNamespace> ModuleNamespaceCreate(JSThread *thread, const JSHandle<JSTaggedValue> &module,
const JSHandle<TaggedArray> &exports);
static bool SetPrototype(const JSHandle<JSTaggedValue> &obj,
const JSHandle<JSTaggedValue> &proto);
static bool PreventExtensions();
static bool GetOwnProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, const JSHandle<JSTaggedValue> &key,
PropertyDescriptor &desc);
static bool DefineOwnProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
const JSHandle<JSTaggedValue> &key, PropertyDescriptor desc);
static bool HasProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj, const JSHandle<JSTaggedValue> &key);
static OperationResult GetProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
const JSHandle<JSTaggedValue> &key);
static bool SetProperty(JSThread *thread, bool mayThrow);
static bool DeleteProperty(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
const JSHandle<JSTaggedValue> &key);
static JSHandle<TaggedArray> OwnPropertyKeys(JSThread *thread, const JSHandle<JSTaggedValue> &proxy);
static JSHandle<TaggedArray> OwnEnumPropertyKeys(JSThread *thread, const JSHandle<JSTaggedValue> &obj);
static bool ValidateKeysAvailable(JSThread *thread, const JSHandle<ModuleNamespace> &moduleNamespace,
const JSHandle<TaggedArray> &exports);
static constexpr size_t MODULE_OFFSET = JSObject::SIZE;
ACCESSORS(Module, MODULE_OFFSET, EXPORTS_OFFSET)
ACCESSORS(Exports, EXPORTS_OFFSET, DEREGISTER_PROCESSION_OFFSET)
ACCESSORS(DeregisterProcession, DEREGISTER_PROCESSION_OFFSET, SIZE)
DECL_DUMP()
DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, MODULE_OFFSET, SIZE)
};
}
#endif