📄 gen-type.c
字号:
TypeDef *td _AND_ Type *parent _AND_ Type *t){ switch (t->basicType->a.macroType->choiceId) { // This switch case copied from do-macros.c case MACROTYPE_ASNABSTRACTOPERATION: case MACROTYPE_ROSOPERATION: PrintCMacroRosOperationElmts (f, r, m, td, parent, t, t->basicType->a.macroType->a.rosOperation); break; // Other Macro Types are not supported as for now as per changes done on 17/Apr/2003 // Add code for other macro types here default: // Unsupported Macro Type break; } parent=parent; /*AVOIDS warning.*/} /* PrintCMacroTypeElmts */static void // Deepak: 17/Apr/2003PrintCMacroRosOperationElmts PARAMS ((f, r, m, td, parent, t, op), FILE *f _AND_ CRules *r _AND_ Module *m _AND_ TypeDef *td _AND_ Type *parent _AND_ Type *t _AND_ RosOperationMacroType *op){ CTRI *ctri; NamedType *et; int digit = 1; if (op->arguments != NULL) { et = op->arguments; if(et->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) { ctri = et->type->cTypeRefInfo; fprintf (f,"\t"); /* cheap, fixed indent */ PrintCType (f, r, m, NULL, NULL, et->type); ctri->cFieldName = et->type->basicType->a.localTypeRef->typeName; ctri->cFieldName[0] = (char)tolower (ctri->cFieldName[0]); AppendDigit (ctri->cFieldName, digit++); fprintf (f, " %s;", ctri->cFieldName); // Deepak: identifier of the structure PrintTypeComment (f, td, et->type); // Deepak: actual asn code line is written in comments here fprintf (f, "\n"); } } if (op->result != NULL) { et = op->result; if(et->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) { ctri = et->type->cTypeRefInfo; fprintf (f,"\t"); /* cheap, fixed indent */ PrintCType (f, r, m, NULL, NULL, et->type); ctri->cFieldName = et->type->basicType->a.localTypeRef->typeName; ctri->cFieldName[0] = (char)tolower (ctri->cFieldName[0]); AppendDigit (ctri->cFieldName, digit++); fprintf (f, " %s;", ctri->cFieldName); // Deepak: identifier of the structure PrintTypeComment (f, td, et->type); // Deepak: actual asn code line is written in comments here fprintf (f, "\n"); } } parent=parent; t=t;} /* PrintCMacroRosOperationElmts */static void // Deepak: 11/Mar/2003PrintCObjectClassElmts PARAMS ((f, r, m, td, parent, t), FILE *f _AND_ CRules *r _AND_ Module *m _AND_ TypeDef *td _AND_ Type *parent _AND_ Type *t){ CTRI *ctri; NamedType *et; NamedTypeList *elmts; int bOptionalElmtsStructWritten = FALSE; elmts = t->basicType->a.objectclass->classdef; if ((elmts == NULL) || (LIST_EMPTY (elmts))) { fprintf (f, " char unused; /* empty ASN1 SET/SEQ - not used */\n"); } // for struct enum of optional variables // Deepak: 14/Mar/2003 FOR_EACH_LIST_ELMT (et, elmts) { if(et->type->optional) { if(!bOptionalElmtsStructWritten) { bOptionalElmtsStructWritten = TRUE; fprintf (f,"\tstruct {\n"); } fprintf (f,"\t\tunsigned int %sPresent : 1;\n", et->fieldName); } } if(bOptionalElmtsStructWritten) fprintf (f,"\t} m;\n\n"); FOR_EACH_LIST_ELMT (et, elmts) { ctri = et->type->cTypeRefInfo; /* ======== Deepak: 17/Mar/2003 Print Encode/Decode Functions for BASICTYPE_UNKNOWN ========*/ if(et->type->basicType->choiceId == BASICTYPE_UNKNOWN) { fprintf (f, "\n /* ========== %s: BASICTYPE_UNKNOWN ========== */\n", ctri->cFieldName); //fprintf (f, "\tchar* %sName;\n", ctri->cFieldName); fprintf (f, "\tvoid* %s;\n", ctri->cFieldName); fprintf (f, "\t%s %sSize;\n", returnTypeG, ctri->cFieldName); fprintf (f, "\t%s (*encode%s) (%s b, void *%s);\n", returnTypeG, ctri->cFieldName, bufTypeNameG, valueArgNameG); fprintf (f, "\t%s (*decode%s) (%s b, %s tagId0, %s elmtLen0, void *%s, %s *bytesDecoded);\n", returnTypeG, ctri->cFieldName, bufTypeNameG, tagTypeNameG, lenTypeNameG, valueArgNameG, lenTypeNameG); continue; } /* ======== Till here ======== */ fprintf (f,"\t"); /* cheap, fixed indent */ PrintCType (f, r, m, td, t, et->type); fprintf (f, " %s;", ctri->cFieldName); // Deepak: identifier of the structure PrintTypeComment (f, td, et->type); // Deepak: actual asn code line is written in comments here fprintf (f, "\n"); }// fprintf (f, "\tAsnInt tagId;\n"); parent=parent; /*AVOIDS warning.*/} /* PrintCObjectClassElmts */static voidPrintCChoiceIdEnum PARAMS ((f, r, m, td, parent, t), FILE *f _AND_ CRules *r _AND_ Module *m _AND_ TypeDef *td _AND_ Type *parent _AND_ Type *t){ NamedType *et; NamedType *last=NULL; CTRI *ctri; ctri = t->cTypeRefInfo; fprintf (f, " enum %s\n {\n", ctri->choiceIdEnumName); if ((t->basicType->a.choice != NULL) && !(LIST_EMPTY (t->basicType->a.choice))) last = (NamedType*)LAST_LIST_ELMT (t->basicType->a.choice); FOR_EACH_LIST_ELMT (et, t->basicType->a.choice) { ctri = et->type->cTypeRefInfo; fprintf (f," %s", ctri->choiceIdSymbol); if (et == last) fprintf (f, "\n"); else fprintf (f, ",\n"); } ctri = t->cTypeRefInfo; fprintf (f, " } %s;", ctri->choiceIdEnumFieldName); parent = parent;td = td;m = m;r = r; /*AVOIDS warning.*/} /* PrintCChoiceIdEnum */static voidPrintCChoiceUnion PARAMS ((f, r, m, td, parent, t), FILE *f _AND_ CRules *r _AND_ Module *m _AND_ TypeDef *td _AND_ Type *parent _AND_ Type *t){ CTRI *ctri; ctri = t->cTypeRefInfo; fprintf (f," union %s\n {\n", ctri->cTypeName); PrintCStructElmts (f, r, m, td, parent, t); fprintf (f, " }");} /* PrintCChoiceUnion */static voidPrintCChoiceTypeDef PARAMS ((f, r, m, td), FILE *f _AND_ CRules *r _AND_ Module *m _AND_ TypeDef *td){ CTRI *ctri; char *choiceName; Type *t; t = td->type; ctri = t->cTypeRefInfo; choiceName = td->cTypeDefInfo->cTypeName; fprintf (f, "typedef "); fprintf (f, "struct %s", choiceName); PrintTypeComment (f, td, t); fprintf (f,"\n{\n"); PrintCChoiceIdEnum (f, r, m, td, NULL, t); fprintf (f,"\n"); PrintCChoiceUnion (f, r, m, td, NULL, t); fprintf (f, " %s;", ctri->cFieldName); fprintf (f,"\n} %s;\n\n", choiceName);} /* PrintCChoiceDef *//* * used to print snippet of the defining ASN.1 after the * C type. */static voidPrintTypeComment PARAMS ((f, td, t), FILE *f _AND_ TypeDef *td _AND_ Type *t){ fprintf (f," /* "); SpecialPrintType (f, td, t); fprintf (f," */");}/* * print any #defines for integers/bits with named elements * (currenly only the first option will fire due to the * steps taken in normalize.c) */static voidPrintPreTypeDefStuff PARAMS ((f, r, m, td, parent, t), FILE *f _AND_ CRules *r _AND_ Module *m _AND_ TypeDef *td _AND_ Type *parent _AND_ Type *t){ CTRI *ctri; NamedType *et; CNamedElmt *n; ctri = td->type->cTypeRefInfo; /* * print defined stmts for non enumerated type with named elmts */ if ((ctri->cNamedElmts != NULL) && (t->basicType->choiceId != BASICTYPE_ENUMERATED)) { FOR_EACH_LIST_ELMT (n, ctri->cNamedElmts) { fprintf(f, "\n#define %s %d", n->name, n->value); } fprintf (f, "\n\n"); } else if ((t->basicType->choiceId == BASICTYPE_SET) || (t->basicType->choiceId == BASICTYPE_SEQUENCE) || (t->basicType->choiceId == BASICTYPE_CHOICE)) { FOR_EACH_LIST_ELMT (et, t->basicType->a.set) PrintPreTypeDefStuff (f, r, m, td, t, et->type); } else if ((t->basicType->choiceId == BASICTYPE_SETOF) || (t->basicType->choiceId == BASICTYPE_SEQUENCEOF)) { PrintPreTypeDefStuff (f, r, m, td, t, t->basicType->a.setOf); } parent = parent; /*AVOIDS warning.*/} /* PrintPreTypeDefStuff */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -