Skip to content

Commit d9a789d

Browse files
Guy BedfordJakeChampion
authored andcommitted
wit bindgen C guest updates
1 parent 1e84124 commit d9a789d

File tree

5 files changed

+264
-255
lines changed

5 files changed

+264
-255
lines changed

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,32 +1540,30 @@ bool apply_cache_override(JSContext *cx, HandleObject self) {
15401540

15411541
uint8_t tag = builtins::CacheOverride::abi_tag(override);
15421542

1543-
fastly_option_u32_t ttl_option;
1543+
bool has_ttl = true;
1544+
uint32_t ttl;
15441545
RootedValue val(cx, builtins::CacheOverride::ttl(override));
15451546
if (val.isUndefined()) {
1546-
ttl_option.is_some = false;
1547+
has_ttl = false;
15471548
} else {
1548-
ttl_option.is_some = true;
1549-
ttl_option.val = val.toInt32();
1549+
ttl = val.toInt32();
15501550
}
15511551

1552-
fastly_option_u32_t swr_option;
1552+
bool has_swr = true;
1553+
uint32_t swr;
15531554
val = builtins::CacheOverride::swr(override);
15541555
if (val.isUndefined()) {
1555-
swr_option.is_some = false;
1556+
has_swr = false;
15561557
} else {
1557-
swr_option.is_some = true;
1558-
swr_option.val = val.toInt32();
1558+
swr = val.toInt32();
15591559
}
15601560

15611561
xqd_world_string_t sk_str;
1562-
fastly_option_string_t sk_opt;
15631562
val = builtins::CacheOverride::surrogate_key(override);
15641563
if (val.isUndefined()) {
1565-
sk_opt.is_some = false;
1564+
sk_str.len = 0;
15661565
} else {
15671566
UniqueChars sk_chars;
1568-
sk_opt.is_some = true;
15691567
sk_chars = encode(cx, val, &sk_str.len);
15701568
if (!sk_chars)
15711569
return false;
@@ -1575,7 +1573,8 @@ bool apply_cache_override(JSContext *cx, HandleObject self) {
15751573
fastly_error_t err;
15761574
return HANDLE_RESULT(cx,
15771575
xqd_fastly_http_req_cache_override_set(
1578-
request_handle(self), tag, &ttl_option, &swr_option, &sk_opt, &err),
1576+
request_handle(self), tag, has_ttl ? &ttl : NULL, has_swr ? &swr : NULL,
1577+
sk_str.len ? &sk_str : NULL, &err),
15791578
err);
15801579
}
15811580

0 commit comments

Comments
 (0)