File
Blob: src/workerd/api/rtti.h
| 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #include <workerd/jsg/jsg.h> |
| 8 | #include <workerd/jsg/modules-new.h> |
| 9 | #include <workerd/jsg/url.h> |
| 10 | |
| 11 | #include <kj/array.h> |
| 12 | #include <kj/string.h> |
| 13 | |
| 14 | namespace workerd::api { |
| 15 | |
| 16 | class RTTIModule final: public jsg::Object { |
| 17 | public: |
| 18 | RTTIModule() = default; |
| 19 | RTTIModule(jsg::Lock&, const jsg::Url&) {} |
| 20 | |
| 21 | kj::Array<byte> exportTypes(kj::String compatDate, kj::Array<kj::String> compatFlags); |
| 22 | kj::Array<byte> exportExperimentalTypes(); |
| 23 | |
| 24 | JSG_RESOURCE_TYPE(RTTIModule) { |
| 25 | JSG_METHOD(exportTypes); |
| 26 | JSG_METHOD(exportExperimentalTypes); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | template <class Registry> |
| 31 | void registerRTTIModule(Registry& registry) { |
| 32 | registry.template addBuiltinModule<RTTIModule>( |
| 33 | "workerd:rtti", workerd::jsg::ModuleRegistry::Type::BUILTIN); |
| 34 | } |
| 35 | |
| 36 | template <typename TypeWrapper> |
| 37 | kj::Own<jsg::modules::ModuleBundle> getExternalRttiModuleBundle(auto featureFlags) { |
| 38 | jsg::modules::ModuleBundle::BuiltinBuilder builder( |
| 39 | jsg::modules::ModuleBundle::BuiltinBuilder::Type::BUILTIN); |
| 40 | static const auto kSpecifier = "workerd:rtti"_url; |
| 41 | builder.addObject<RTTIModule, TypeWrapper>(kSpecifier); |
| 42 | return builder.finish(); |
| 43 | } |
| 44 | |
| 45 | #define EW_RTTI_ISOLATE_TYPES api::RTTIModule |
| 46 | |
| 47 | } // namespace workerd::api |