File
Blob: src/workerd/io/frankenvalue.capnp
| 1 | @0xcc3b225cb3101aba; |
| 2 | |
| 3 | using Cxx = import "/capnp/c++.capnp"; |
| 4 | $Cxx.namespace("workerd::rpc"); |
| 5 | $Cxx.allowCancellation; |
| 6 | |
| 7 | struct Frankenvalue { |
| 8 | # Represents a JavaScript value that has been stitched together from multiple sources outside of |
| 9 | # a JavaScript evaluation context. The Frankevalue can be evaluated down to a JS value as soon |
| 10 | # as it has a JS execution environment in which to be evaluated. |
| 11 | # |
| 12 | # This is used in particular to represent `ctx.props`. |
| 13 | |
| 14 | union { |
| 15 | emptyObject @0 :Void; |
| 16 | # Just an object with no properties. |
| 17 | |
| 18 | json @1 :Text; |
| 19 | # Parse this JSON-formatted text to compute the value. |
| 20 | |
| 21 | v8Serialized @2 :Data; |
| 22 | # Parse these V8-serialized bytes to compute the value. |
| 23 | } |
| 24 | |
| 25 | properties @3 :List(Frankenvalue); |
| 26 | # Additional properties to add to the value. The base value (specified by the union above) must |
| 27 | # be an object. Each property in this list must have a `name`. They will be added as properties |
| 28 | # of the object. |
| 29 | # |
| 30 | # If a property in the list conflicts with a property that already exists in the base value, |
| 31 | # the property is overwritten with the value from the `properties` list. |
| 32 | |
| 33 | name @4 :Text; |
| 34 | # Property name. Used only when this `Frankenvalue` represents a property, that is, it is an |
| 35 | # element within the `properties` list of some other `Frankenvalue`. If this is the root value, |
| 36 | # then `name` must be null. |
| 37 | |
| 38 | capTableSize @5 :UInt32 = 0; |
| 39 | # How large is this value's cap table, not counting `properties`. |
| 40 | # |
| 41 | # The final cap table contains this many base caps (referenced by the union above), followed by |
| 42 | # the caps for each property, in order. |
| 43 | |
| 44 | capTable @6 :AnyPointer; |
| 45 | # Some sort of representation of the cap table. The exact format is different for different |
| 46 | # contexts. Frankenvalue::toCapnp() and fromCapnp() don't handle this at all -- the caller is |
| 47 | # expected to deal with it. |
| 48 | # |
| 49 | # TODO(cleanup): Consider making `Frankenvalue` a generic over the capTable type? Maybe even make |
| 50 | # the C++ class a template over the CapTableEntry type? |
| 51 | } |