"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StructVisitor = void 0;
const ast_1 = require("@wapc/widl/ast");
const helpers_1 = require("./helpers");
const utils_1 = require("../utils");
class StructVisitor extends ast_1.BaseVisitor {
    constructor(writer) {
        super(writer);
    }
    visitObjectBefore(context) {
        super.triggerObjectBefore(context);
        this.write(utils_1.formatComment("// ", context.object.description));
        this.write(`type ${context.object.name.value} struct {\n`);
    }
    visitObjectField(context) {
        const field = context.field;
        this.write(utils_1.formatComment("// ", field.description));
        this.write(`\t${helpers_1.fieldName(field.name.value)} ${helpers_1.expandType(field.type, undefined, true, helpers_1.isReference(field.annotations))} \`json:"${field.name.value}" msgpack:"${field.name.value}"\`\n`);
        super.triggerObjectField(context);
    }
    visitObjectAfter(context) {
        this.write(`}\n\n`);
        super.triggerObjectAfter(context);
    }
}
exports.StructVisitor = StructVisitor;
//# sourceMappingURL=struct_visitor.js.map