Skip to content

Commit

Permalink
fixup! bijection define retired
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Apr 28, 2024
1 parent 39f0d44 commit 00faa72
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/async-flow/src/async-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const prepareAsyncFlowTools = (outerZone, outerOptions = {}) => {
// async IFFE ensures guestResultP is a fresh promise
guestAsyncFunc(...guestArgs))();

bijection.define(guestResultP, outcomeKit.vow);
bijection.init(guestResultP, outcomeKit.vow);
// log is driven at first by guestAyncFunc interaction through the
// membrane with the host activationArgs. At the end of its first
// turn, it returns a promise for its eventual guest result.
Expand Down
4 changes: 2 additions & 2 deletions packages/async-flow/src/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ export const makeConvertKit = (
return bijection.hostToGuest(hRem);
}
const gRem = makeGuestForHostRemotable(hRem);
bijection.define(gRem, hRem);
bijection.init(gRem, hRem);
return gRem;
},
hVow => {
if (bijection.hasHost(hVow)) {
return bijection.hostToGuest(hVow);
}
const gP = makeGuestForHostVow(hVow);
bijection.define(gP, hVow);
bijection.init(gP, hVow);
return gP;
},
hErr => {
Expand Down
12 changes: 6 additions & 6 deletions packages/async-flow/src/equate.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export const makeEquate = bijection => {
// We *do* support passing a guest wrapper of a hostVow back
// to the host, but that would be cause by `bijection.has` above.
throw Fail`guest promises not yet passable`;
// define does not yet do enough checking anyway. For this case,
// `init` does not yet do enough checking anyway. For this case,
// we should ensure that h is a host wrapper of a guest promise,
// which is a wrapping we don't yet support.
// bijection.define(g, h);
// bijection.init(g, h);
// return;
}
const hPassStyle = passStyleOf(h);
Expand Down Expand Up @@ -95,10 +95,10 @@ export const makeEquate = bijection => {
// but that should have already been taken care of by the
// `bijection.has` above.
throw Fail`cannot yet send guest remotables to host ${g} vs ${h}`;
// define does not yet do enough checking anyway. For this case,
// `init` does not yet do enough checking anyway. For this case,
// we should ensure that h is a host wrapper of a guest remotable,
// which is a wrapping we don't yet support.
// bijection.define(g, h);
// bijection.init(g, h);
// return;
}
case 'promise': {
Expand All @@ -107,10 +107,10 @@ export const makeEquate = bijection => {
// but that should have already been taken care of by the
// `bijection.has` above.
throw Fail`cannot yet send guest promises to host ${g} vs ${h}`;
// define does not yet do enough checking anyway. For this case,
// `init` does not yet do enough checking anyway. For this case,
// we should ensure that h is a host wrapper of a guest promise,
// which is a wrapping we don't yet support.
// bijection.define(g, h);
// bijection.init(g, h);
// return;
}
default: {
Expand Down
10 changes: 2 additions & 8 deletions packages/async-flow/src/weak-bijection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const WeakBijectionI = M.interface('WeakBijection', {
has: M.call(M.any(), M.any()).returns(M.boolean()),
guestToHost: M.call(M.any()).returns(M.any()),
hostToGuest: M.call(M.any()).returns(M.any()),
define: M.call(M.any(), M.any()).returns(),
});

/**
Expand Down Expand Up @@ -70,19 +69,14 @@ export const prepareWeakBijection = zone => {
const guestToHost = g2h.for(self);
const hostToGuest = h2g.for(self);

!hostToGuest.has(h) ||
Fail`key already bound: ${h} -> ${hostToGuest.get(h)} vs ${g}`;
guestToHost.init(g, h);
hostToGuest.init(h, g);
self.has(g, h) ||
// separate line so I can set a breakpoint
Fail`internal: ${g} <-> ${h}`;
},
define(g, h) {
const { self } = this;

if (!self.has(g, h)) {
self.init(g, h);
}
},
hasGuest(g) {
const { self } = this;
const guestToHost = g2h.for(self);
Expand Down
13 changes: 7 additions & 6 deletions packages/async-flow/test/test-weak-bijection.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ const testBijection = (t, zone, { makeVowKit }) => {
const g3 = harden(Promise.resolve('g3'));

t.false(bij.has(g1, h1));
bij.define(g1, h1);
bij.init(g1, h1);
t.true(bij.has(g1, h1));
t.throws(() => bij.define(g1, h2), {
t.throws(() => bij.init(g1, h2), {
message:
'internal: g->h "[Alleged: g1]" -> "[Alleged: h2]" vs "[Alleged: h1]"',
'key already bound: "[Alleged: g1]" -> "[Alleged: h1]" vs "[Alleged: h2]"',
});
t.throws(() => bij.define(g2, h1), {
message: 'key not found: "[Alleged: h1]"',
t.throws(() => bij.init(g2, h1), {
message:
'key already bound: "[Alleged: h1]" -> "[Alleged: g1]" vs "[Alleged: g2]"',
});
t.throws(() => bij.has(g1, h2), {
message:
'internal: g->h "[Alleged: g1]" -> "[Alleged: h2]" vs "[Alleged: h1]"',
});
t.false(bij.has(g2, h2));
bij.define(g2, h2);
bij.init(g2, h2);
t.true(bij.has(g2, h2));

t.false(bij.has(g3, h3));
Expand Down

0 comments on commit 00faa72

Please sign in to comment.