Skip to content

Commit 115055a

Browse files
authored
chore: Name the fastly interface, and import it by name (#585)
1 parent 6438db1 commit 115055a

20 files changed

+1910
-1700
lines changed

runtime/js-compute-runtime/builtins/cache-override.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,23 @@ void CacheOverride::set_pci(JSObject *self, bool pci) {
7474
JS::SetReservedSlot(self, CacheOverride::Slots::PCI, JS::BooleanValue(pci));
7575
}
7676

77-
fastly_http_cache_override_tag_t CacheOverride::abi_tag(JSObject *self) {
77+
fastly_compute_at_edge_fastly_http_cache_override_tag_t CacheOverride::abi_tag(JSObject *self) {
7878
MOZ_ASSERT(is_instance(self));
7979
switch (CacheOverride::mode(self)) {
8080
case CacheOverride::CacheOverrideMode::None:
8181
return 0;
8282
case CacheOverride::CacheOverrideMode::Pass:
83-
return FASTLY_HTTP_CACHE_OVERRIDE_TAG_PASS;
83+
return FASTLY_COMPUTE_AT_EDGE_FASTLY_HTTP_CACHE_OVERRIDE_TAG_PASS;
8484
default:;
8585
}
8686

87-
fastly_http_cache_override_tag_t tag = 0;
87+
fastly_compute_at_edge_fastly_http_cache_override_tag_t tag = 0;
8888
if (!ttl(self).isUndefined())
89-
tag |= FASTLY_HTTP_CACHE_OVERRIDE_TAG_TTL;
89+
tag |= FASTLY_COMPUTE_AT_EDGE_FASTLY_HTTP_CACHE_OVERRIDE_TAG_TTL;
9090
if (!swr(self).isUndefined())
91-
tag |= FASTLY_HTTP_CACHE_OVERRIDE_TAG_STALE_WHILE_REVALIDATE;
91+
tag |= FASTLY_COMPUTE_AT_EDGE_FASTLY_HTTP_CACHE_OVERRIDE_TAG_STALE_WHILE_REVALIDATE;
9292
if (!pci(self).isUndefined())
93-
tag |= FASTLY_HTTP_CACHE_OVERRIDE_TAG_PCI;
93+
tag |= FASTLY_COMPUTE_AT_EDGE_FASTLY_HTTP_CACHE_OVERRIDE_TAG_PCI;
9494

9595
return tag;
9696
}

runtime/js-compute-runtime/builtins/cache-simple.cpp

Lines changed: 68 additions & 66 deletions
Large diffs are not rendered by default.

runtime/js-compute-runtime/builtins/cache-simple.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SimpleCacheEntry final : public BuiltinImpl<SimpleCacheEntry> {
2626

2727
static bool init_class(JSContext *cx, JS::HandleObject global);
2828
static bool constructor(JSContext *cx, unsigned argc, JS::Value *vp);
29-
static JSObject *create(JSContext *cx, fastly_body_handle_t body_handle);
29+
static JSObject *create(JSContext *cx, fastly_compute_at_edge_fastly_body_handle_t body_handle);
3030
};
3131

3232
class SimpleCache : public BuiltinImpl<SimpleCache> {

runtime/js-compute-runtime/builtins/config-store.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace builtins {
55

66
Dict ConfigStore::config_store_handle(JSObject *obj) {
77
JS::Value val = JS::GetReservedSlot(obj, ConfigStore::Slots::Handle);
8-
return Dict{static_cast<fastly_dictionary_handle_t>(val.toInt32())};
8+
return Dict{static_cast<fastly_compute_at_edge_fastly_dictionary_handle_t>(val.toInt32())};
99
}
1010

1111
bool ConfigStore::get(JSContext *cx, unsigned argc, JS::Value *vp) {
@@ -105,7 +105,7 @@ bool ConfigStore::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
105105
JS::RootedObject config_store(cx, JS_NewObjectForConstructor(cx, &class_, args));
106106
auto open_res = Dict::open(name);
107107
if (auto *err = open_res.to_err()) {
108-
if (*err == FASTLY_ERROR_BAD_HANDLE) {
108+
if (*err == FASTLY_COMPUTE_AT_EDGE_FASTLY_ERROR_BAD_HANDLE) {
109109
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CONFIG_STORE_DOES_NOT_EXIST,
110110
name.data());
111111
return false;

runtime/js-compute-runtime/builtins/dictionary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace builtins {
55

66
Dict Dictionary::dictionary_handle(JSObject *obj) {
77
JS::Value val = JS::GetReservedSlot(obj, Dictionary::Slots::Handle);
8-
return Dict{static_cast<fastly_dictionary_handle_t>(val.toInt32())};
8+
return Dict{static_cast<fastly_compute_at_edge_fastly_dictionary_handle_t>(val.toInt32())};
99
}
1010

1111
bool Dictionary::get(JSContext *cx, unsigned argc, JS::Value *vp) {
@@ -116,7 +116,7 @@ bool Dictionary::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
116116

117117
auto res = Dict::open(name_view);
118118
if (auto *err = res.to_err()) {
119-
if (*err == FASTLY_ERROR_BAD_HANDLE) {
119+
if (*err == FASTLY_COMPUTE_AT_EDGE_FASTLY_ERROR_BAD_HANDLE) {
120120
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DICTIONARY_DOES_NOT_EXIST,
121121
name_view.data());
122122
return false;

runtime/js-compute-runtime/builtins/headers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool lazy_values(JSObject *self) {
7373
.toBoolean();
7474
}
7575

76-
fastly_request_handle_t get_handle(JSObject *self) {
76+
fastly_compute_at_edge_fastly_request_handle_t get_handle(JSObject *self) {
7777
MOZ_ASSERT(Headers::is_instance(self));
7878
return static_cast<uint32_t>(
7979
JS::GetReservedSlot(self, static_cast<uint32_t>(Headers::Slots::Handle)).toInt32());

runtime/js-compute-runtime/builtins/kv-store.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ namespace {
116116

117117
ObjectStore kv_store_handle(JSObject *obj) {
118118
JS::Value val = JS::GetReservedSlot(obj, static_cast<uint32_t>(KVStore::Slots::KVStore));
119-
return ObjectStore(static_cast<fastly_object_store_handle_t>(val.toInt32()));
119+
return ObjectStore(
120+
static_cast<fastly_compute_at_edge_fastly_object_store_handle_t>(val.toInt32()));
120121
}
121122

122123
bool parse_and_validate_key(JSContext *cx, const char *key, size_t len) {
@@ -433,7 +434,7 @@ bool KVStore::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
433434

434435
auto res = ObjectStore::open(name_str);
435436
if (auto *err = res.to_err()) {
436-
if (*err == FASTLY_ERROR_INVALID_ARGUMENT) {
437+
if (*err == FASTLY_COMPUTE_AT_EDGE_FASTLY_ERROR_INVALID_ARGUMENT) {
437438
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_KV_STORE_DOES_NOT_EXIST,
438439
name_str.data());
439440
return false;

runtime/js-compute-runtime/builtins/request-response.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,9 @@ bool RequestOrResponse::bodyAll(JSContext *cx, JS::CallArgs args, JS::HandleObje
740740

741741
JS::RootedValue body_parser(cx, JS::PrivateValue((void *)parse_body<result_type>));
742742

743-
// If the body is a ReadableStream that's not backed by a fastly_body_handle_t,
744-
// we need to manually read all chunks from the stream.
743+
// If the body is a ReadableStream that's not backed by a
744+
// fastly_compute_at_edge_fastly_body_handle_t, we need to manually read all chunks from the
745+
// stream.
745746
// TODO(performance): ensure that we're properly shortcutting reads from TransformStream
746747
// readables.
747748
// https://github.com/fastly/js-compute-runtime/issues/218

runtime/js-compute-runtime/builtins/secret-store.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ namespace builtins {
55

66
host_api::Secret SecretStoreEntry::secret_handle(JSObject *obj) {
77
JS::Value val = JS::GetReservedSlot(obj, SecretStoreEntry::Slots::Handle);
8-
return host_api::Secret{static_cast<fastly_secret_handle_t>(val.toInt32())};
8+
return host_api::Secret{
9+
static_cast<fastly_compute_at_edge_fastly_secret_handle_t>(val.toInt32())};
910
}
1011

1112
bool SecretStoreEntry::plaintext(JSContext *cx, unsigned argc, JS::Value *vp) {
@@ -68,7 +69,8 @@ bool SecretStoreEntry::init_class(JSContext *cx, JS::HandleObject global) {
6869

6970
host_api::SecretStore SecretStore::secret_store_handle(JSObject *obj) {
7071
JS::Value val = JS::GetReservedSlot(obj, SecretStore::Slots::Handle);
71-
return host_api::SecretStore{static_cast<fastly_secret_store_handle_t>(val.toInt32())};
72+
return host_api::SecretStore{
73+
static_cast<fastly_compute_at_edge_fastly_secret_store_handle_t>(val.toInt32())};
7274
}
7375

7476
bool SecretStore::get(JSContext *cx, unsigned argc, JS::Value *vp) {
@@ -194,7 +196,7 @@ bool SecretStore::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
194196

195197
auto res = host_api::SecretStore::open(name);
196198
if (auto *err = res.to_err()) {
197-
if (*err == FASTLY_ERROR_OPTIONAL_NONE) {
199+
if (*err == FASTLY_COMPUTE_AT_EDGE_FASTLY_ERROR_OPTIONAL_NONE) {
198200
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_SECRET_STORE_DOES_NOT_EXIST,
199201
name.data());
200202
return false;

0 commit comments

Comments
 (0)