- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
// https://github.com/mailru/confetti/blob/63ed82c65a7fbcd2baf8a67f1b7410e044dfd1dd/h_dump.c#L44
static void
dumpParamDef(FILE *fh, char* name, ParamDef *def) {
dumpComment(fh, def, 1);
switch(def->paramType) {
case int32Type:
fprintf(fh, "\tint32_t\t%s;\n", def->name);
break;
case uint32Type:
fprintf(fh, "\tu_int32_t\t%s;\n", def->name);
break;
case int64Type:
fprintf(fh, "\tint64_t\t%s;\n", def->name);
break;
case uint64Type:
fprintf(fh, "\tu_int64_t\t%s;\n", def->name);
break;
case doubleType:
fprintf(fh, "\tdouble\t%s;\n", def->name);
break;
case stringType:
fprintf(fh, "\tchar*\t%s;\n", def->name);
break;
case boolType:
fprintf(fh, "\tconfetti_bool_t\t%s;\n", def->name);
break;
case commentType:
fprintf(stderr, "Unexpected comment");
break;
case structType:
fprintf(fh, "\t%s", name);
dumpStructName(fh, def->paramValue.structval, "_");
fprintf(fh, "*\t%s;\n", def->name);
break;
case arrayType:
fprintf(fh, "\t%s", name);
dumpStructName(fh, def->paramValue.arrayval->paramValue.structval, "_");
fprintf(fh, "**\t%s;\n", def->name);
break;
case builtinType:
break;
default:
fprintf(stderr,"Unknown paramType (%d)\n", def->paramType);
exit(1);
}
}
Какое же говно эта ваша сишка. А в крестоговне эта задача легко и элегантно решается, правда ведь?