public emit()

in packages/jsii-pacmak/lib/targets/go/types/interface.ts [80:140]


  public emit(context: EmitContext) {
    this.emitDocs(context);

    const { code } = context;
    code.openBlock(`type ${this.name} interface`);

    // embed extended interfaces
    for (const iface of this.extends) {
      code.line(
        new GoTypeRef(this.pkg.root, iface.type.reference).scopedName(this.pkg),
      );
    }

    for (const method of this.methods) {
      method.emitDecl(context);
    }

    for (const prop of this.properties) {
      prop.emit(context);
    }

    code.closeBlock();
    code.line();

    code.line(`// The jsii proxy for ${this.name}`);
    code.openBlock(`type ${this.proxyName} struct`);
    if (this.extends.length === 0) {
      // Ensure this is not 0-width
      code.line('_ byte // padding');
    } else {
      for (const base of this.extends) {
        code.line(this.pkg.resolveEmbeddedType(base).embed);
      }
    }
    code.closeBlock();
    code.line();

    for (const method of this.methods) {
      method.emit(context);
    }

    for (const method of this.reimplementedMethods) {
      method.emit(context);
    }

    for (const prop of this.properties) {
      prop.emitGetterProxy(context);

      if (!prop.immutable) {
        prop.emitSetterProxy(context);
      }
    }

    for (const prop of this.reimplementedProperties) {
      prop.emitGetterProxy(context);

      if (!prop.immutable) {
        prop.emitSetterProxy(context);
      }
    }
  }