/* * 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 CreateSortedExports(JSThread *thread, const JSHandle &exports); static void SetModuleDeregisterProcession(JSThread *thread, const JSHandle &nameSpace, const NativePointerCallback &callback); // 9.4.6.11ModuleNamespaceCreate ( module, exports ) static JSHandle ModuleNamespaceCreate(JSThread *thread, const JSHandle &module, const JSHandle &exports); // 9.4.6.1[[SetPrototypeOf]] static bool SetPrototype(const JSHandle &obj, const JSHandle &proto); // 9.4.6.3[[PreventExtensions]] static bool PreventExtensions(); // 9.4.6.4[[GetOwnProperty]] static bool GetOwnProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, PropertyDescriptor &desc); // 9.4.6.5[[DefineOwnProperty]] ( P, Desc ) static bool DefineOwnProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, PropertyDescriptor desc); // 9.4.6.6[[HasProperty]] static bool HasProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key); // 9.4.6.7[[Get]] ( P, Receiver ) static OperationResult GetProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key); // 9.4.6.8[[Set]] ( P, V, Receiver ) static bool SetProperty(JSThread *thread, bool mayThrow); // 9.4.6.9[[Delete]] ( P ) static bool DeleteProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key); // 9.4.6.10[[OwnPropertyKeys]] static JSHandle OwnPropertyKeys(JSThread *thread, const JSHandle &proxy); static JSHandle OwnEnumPropertyKeys(JSThread *thread, const JSHandle &obj); bool ValidateKeysAvailable(JSThread *thread, const JSHandle &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) }; } // namespace panda::ecmascript #endif // ECMASCRIPT_MODULE_JS_MODULE_NAMESPACE_H