visitPointerType()

in lib/generator.js [1405:1455]


  visitPointerType(ast, level) {
    if (ast.type === 'moduleModel') {
      this.emit('*');
      this.visitModuleName(ast.path[0]);
      for (let i = 1; i < ast.path.length; i++) {
        if (i === 1) {
          this.emit(`.`);
        }
        this.emit(`${_format(_name(ast.path[i]))}`);
      }
    } else if (ast.type === 'moduleTypedef') {
      this.emit(`*`);
      for (let i = 1; i < ast.path.length; i++) {
        this.emit(`${this.typeRelover(ast.path[i], ast.path[0])}`);
      }
    } else if (ast.type === 'subModel') {
      this.emit(`*${_format(_name(ast.path[0]))}`);
      for (let i = 1; i < ast.path.length; i++) {
        this.emit(`${_format(_name(ast.path[i]))}`);
      }
    } else if ((ast.type === 'map' || ast.fieldType === 'map') && _name(ast.keyType)) {
      this.emit(`map[${this.getType(_name(ast.keyType), false)}]`);
      this.visitPointerType(ast.valueType, level);
    } else if (ast.type === 'asyncIterator' || ast.type === 'iterator') {
      this.visitPointerType(ast.valueType, level);
    }else if (ast.fieldType === 'array' || ast.type === 'array') {
      this.emit(`[]`);
      this.visitPointerType(ast.subType || ast.itemType, level);
    } else if (ast.idType === 'module' || this.clientName[_name(ast)]) {
      this.emit(`${this.clientName[_name(ast)]}`);
    } else if (ast.idType === 'builtin_model') {
      this.emit(`${this.getType(_name(ast), false)}`);
    } else if (ast.type === 'model') {
      this.emit(`*`);
      if (ast.moduleName) {
        this.emit(`${ast.moduleName.replace(/-/g, '_').toLowerCase()}.`);
      }
      let strs = _format(_name(ast)).split('.');
      strs.forEach(str => {
        this.emit(`${_modelName(_format(str))}`);
      });
    } else if (_name(ast)) {
      this.emit(this.getType(this.typeRelover(ast)));
    } else if (ast.fieldType && DSL.util.isBasicType(ast.fieldType)) {
      this.emit(this.getType(ast.fieldType));
    } else if (ast.fieldType && this.typeRelover(ast.fieldTyp)) {
      this.emit(this.getType(this.typeRelover(ast.fieldType)));
    } else {
      this.emit(this.getType(ast));
    }
  }