- //copy struct, sequence and string to buffer
- seqCount = 0;
- strCount = 0;
- flag = 0;
- structCount = 0;
- if(ev->type != 0)
- for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
- fld = (field *)ev->type->fields.array[pos1];
- td = fld->type;
- // if(td->type != STRING && td->type != SEQUENCE && td->type != ARRAY){
- // if(flag == 0) structCount++;
- // flag++;
- // if((structCount > 1 || whichTypeFirst == 2) && flag == 1){
- // assert(0); // MD : disabled !
- // fprintf(fp,"\t//copy struct to buffer\n");
- // fprintf(fp,"\tmemcpy(ptr, &__%d, sizeof(struct %s_%s_%d));\n",
- // structCount, ev->name, facName,structCount);
- // fprintf(fp,"\tptr += sizeof(struct %s_%s_%d);\n\n",
- // ev->name, facName,structCount);
- // }
- // }
- //else if(td->type == SEQUENCE){
- if(td->type == SEQUENCE){
- flag = 0;
- fprintf(fp,"\t\t//copy sequence length and sequence to buffer\n");
-
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\t\t*ptr = seqlength_%d;\n",++seqCount);
- fprintf(fp,"\t\tptr += sizeof(%s);\n",uintOutputTypes[td->size]);
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\t\tmemcpy(ptr, %s, sizeof(%s) * seqlength_%d);\n",
- fld->name, getTypeStr(td), seqCount);
- fprintf(fp,"\t\tptr += sizeof(%s) * seqlength_%d;\n\n",
- getTypeStr(td), seqCount);
- }
- else if(td->type==STRING){
- flag = 0;
- fprintf(fp,"\t\t//copy string to buffer\n");
- fprintf(fp,"\t\tif(strlength_%d > 0){\n",++strCount);
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\t\t\tmemcpy(ptr, %s, strlength_%d + 1);\n",
- fld->name, strCount);
- fprintf(fp,"\t\t\tptr += strlength_%d + 1;\n",strCount);
- fprintf(fp,"\t\t}else{\n");
- fprintf(fp,"\t\t\t*ptr = '\\0';\n");
- fprintf(fp,"\t\t\tptr += 1;\n");
- fprintf(fp,"\t\t}\n\n");
- }else if(td->type==ARRAY){
- flag = 0;
- fprintf(fp,"\t//copy array to buffer\n");
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\tmemcpy(ptr, %s, sizeof(%s) * %d);\n",
- fld->name, getTypeStr(td), td->size);
- fprintf(fp,"\tptr += sizeof(%s) * %d;\n\n", getTypeStr(td), td->size);
- }
- }
- if(structCount + seqCount > 1) fprintf(fp,"\n");
-