How to use the capnp-ts/lib/std/schema.capnp.Type_Which function in capnp-ts

To help you get started, we’ve selected a few capnp-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jdiaz5513 / capnp-ts / packages / capnpc-ts / src / generators.ts View on Github external
case s.Type_Which.BOOL:
      initializer = ts.createCall(ts.createPropertyAccess(CAPNP, p.mask), __, [
        createValueExpression(slot.getDefaultValue()),
        ts.createNumericLiteral((slot.getOffset() % 8).toString())
      ]);

      break;

    case s.Type_Which.ENUM:
    case s.Type_Which.FLOAT32:
    case s.Type_Which.FLOAT64:
    case s.Type_Which.INT16:
    case s.Type_Which.INT32:
    case s.Type_Which.INT64:
    case s.Type_Which.INT8:
    case s.Type_Which.UINT16:
    case s.Type_Which.UINT32:
    case s.Type_Which.UINT64:
    case s.Type_Which.UINT8:
      initializer = ts.createCall(ts.createPropertyAccess(CAPNP, p.mask), __, [
        createValueExpression(slot.getDefaultValue())
      ]);

      break;

    default:
      throw new Error(
        format(E.GEN_UNKNOWN_DEFAULT, s.Type_Which[whichSlotType])
      );
  }

  return ts.createPropertyAssignment(`default${util.c2t(name)}`, initializer);