コード例 #1
0
  /**
   * Writes the data type definitions
   *
   * @param typeList the list of data types
   */
  private void writeTypeDefinitions(ArrayList<String> typeList) {
    for (String type : typeList) {
      DataType dt = mapTypeToDataType(type);
      if (dt != null) {
        // Normal parameters
        int size = mapParameterTypeToSize(type);
        String formatChar = SourceUtils.mapNormalTypeToFormat(type);
        if (formatChar != null && formatChar.length() > 1 && formatChar.charAt(0) == '%') {
          formatChar = formatChar.substring(1);
          TypeDefStore.writeTypeDef(type, size, formatChar, dt);

          // Write alternative format characters
          writeAlternativeFormatChars(formatChar, type, size, dt);

        } else {
          TypeDefStore.writeTypeDef(type, size, null, dt);
        }
      } else {
        // Enum parameters
        TraceModel model = dictionaryFile.getOwner().getModel();
        TraceConstantTable table = model.findConstantTableByName(type);
        if (table != null) {
          TypeDefStore.startTypeDef(
              table.getName(), mapParameterTypeToSize(table.getType()), null, DataType.ENUM);
          for (TraceConstantTableEntry entry : table) {
            TypeDef.writeTypeMember(entry.getID(), entry.getName(), null);
          }
          TypeDefStore.endTypeDef();
        }
      }
    }
  }
コード例 #2
0
 /**
  * Gets the parameter size from type
  *
  * @param type the type
  * @return the size in bytes
  */
 private int mapParameterTypeToSize(String type) {
   int size = SourceUtils.mapParameterTypeToSize(type);
   if (size == 0) {
     if (type.equals(TraceParameter.ASCII)) {
       size = 1;
     } else if (type.equals(TraceParameter.UNICODE)) {
       size = 2; // CodForChk_Dis_Magic
     }
   }
   return size;
 }