5e3861eee1c29f858d854b601d6d51e85de8b9dc kent Mon Apr 22 18:45:23 2013 -0700 Adding xxxCommaSepFieldNames output. diff --git src/hg/autoSql/autoSql.c src/hg/autoSql/autoSql.c index 5a412cf..86b5116 100644 --- src/hg/autoSql/autoSql.c +++ src/hg/autoSql/autoSql.c @@ -338,30 +338,32 @@ else cOtherColumn(col, f); fprintf(f, ";\t/* %s */\n", col->comment); } void cTable(struct asObject *dbObj, FILE *f) /* Print out structure of dbObj in C. */ { struct asColumn *col; char defineName[256]; splitPath(dbObj->name, NULL, defineName, NULL); touppers(defineName); fprintf(f, "#define %s_NUM_COLS %d\n\n", defineName, slCount(dbObj->columnList)); +fprintf(f, "extern char *%sCommaSepFieldNames;\n\n", dbObj->name); + for (col = dbObj->columnList; col != NULL; col = col->next) { if ((col->lowType->type == t_enum) || (col->lowType->type == t_set)) cSymTypeDef(dbObj, col, f); } fprintf(f, "struct %s\n", dbObj->name); fprintf(f, "/* %s */\n", dbObj->comment); fprintf(f, " {\n"); if (!dbObj->isSimple) fprintf(f, " struct %s *next; /* Next in singly linked list. */\n", dbObj->name); for (col = dbObj->columnList; col != NULL; col = col->next) cColumn(dbObj, col, f); fprintf(f, " };\n\n"); @@ -1855,30 +1857,40 @@ /* output definition used for parsing and formating a symbolic column field */ { struct slName *val; fprintf(cFile, "/* definitions for %s column */\n", col->name); fprintf(cFile, "static char *values_%s[] = {", col->name); for (val = col->values; val != NULL; val = val->next) fprintf(cFile, "\"%s\", ", val->name); fprintf(cFile, "NULL};\n"); fprintf(cFile, "static struct hash *valhash_%s = NULL;\n\n", col->name); } void cSymColumnDefs(struct asObject *obj, FILE *cFile) /* output definitions used for parsing and formating a symbolic column fields */ { struct asColumn *col; +/* Print out comma separated list of names */ +fprintf(cFile, "\nchar *%sCommaSepFieldNames = \"", obj->name); +for (col = obj->columnList; col != NULL; col = col->next) + { + if (col != obj->columnList) // not first time? + fprintf(cFile, ","); + fprintf(cFile, "%s", col->name); + } +fprintf(cFile, "\";\n\n"); + for (col = obj->columnList; col != NULL; col = col->next) { if ((col->lowType->type == t_enum) || (col->lowType->type == t_set)) cSymColumnDef(col, cFile); } } void genObjectCode(struct asObject *obj, boolean doDbLoadAndSave, FILE *cFile, FILE *hFile, FILE *sqlFile, FILE *djangoFile) /* output code for one object */ { cTable(obj, hFile); cSymColumnDefs(obj, cFile); if (obj->isTable)