📄 symbol2.c
字号:
if (classflag || Tptr[Ttemplate]) { if (cflag) semwarn("Option -c conflicts with the use of classes"); } if (!cflag) { fprintf(fhead,"\n\nSOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);"); if (!lflag) { fprintf(fout,"\n\nSOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n)\n{\n\tswitch (t)\n\t{"); if (classtable) for (p = classtable->list; p; p = p->next) if ((p->info.typ->type == Tclass || p->info.typ->type == Tstruct) && !is_transient(p->info.typ)) { if (is_header_or_fault(p->info.typ) || is_body(p->info.typ)) fprintf(fout,"\n#ifndef WITH_NOGLOBAL"); fprintf(fout,"\n\tcase %s:\n\t\treturn (void*)soap_instantiate_%s(soap, -1, type, arrayType, n);", soap_type(p->info.typ), c_ident(p->info.typ)); if (is_header_or_fault(p->info.typ) || is_body(p->info.typ)) fprintf(fout,"\n#endif"); } if (typetable) for (p = typetable->list; p; p = p->next) if ((p->info.typ->type == Tclass || p->info.typ->type == Tstruct) && !is_transient(p->info.typ)) { if (is_header_or_fault(p->info.typ) || is_body(p->info.typ)) fprintf(fout,"\n#ifndef WITH_NOGLOBAL"); fprintf(fout,"\n\tcase %s:\n\t\treturn (void*)soap_instantiate_%s(soap, -1, type, arrayType, n);", soap_type(p->info.typ), c_ident(p->info.typ)); if (is_header_or_fault(p->info.typ) || is_body(p->info.typ)) fprintf(fout,"\n#endif"); } for (typ = Tptr[Ttemplate]; typ; typ = typ->next) if (typ->ref && !is_transient(typ)) fprintf(fout,"\n\tcase %s:\n\t\treturn (void*)soap_instantiate_%s(soap, -1, type, arrayType, n);", soap_type(typ), c_ident(typ)); fprintf(fout,"\n\t}\n\treturn NULL;\n}"); } fprintf(fhead,"\nSOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);"); if (!lflag) { fprintf(fout,"\n\nSOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p)"); fprintf(fout,"\n{\tswitch (p->type)\n\t{"); if (classtable) { for (p = classtable->list; p; p = p->next) if ((p->info.typ->type == Tclass || p->info.typ->type == Tstruct) && !is_transient(p->info.typ)) { fprintf(fout,"\n\tcase %s:", soap_type(p->info.typ)); fprintf(fout,"\n\t\tif (p->size < 0)\n\t\t\tdelete (%s*)p->ptr;\n\t\telse\n\t\t\tdelete[] (%s*)p->ptr;\n\t\tbreak;", c_type(p->info.typ), c_type(p->info.typ)); } } if (typetable) { for (p = typetable->list; p; p = p->next) if (p->info.typ->type == Tclass || p->info.typ->type == Tstruct) /* && is_external(p->info.typ)) */ { fprintf(fout,"\n\tcase %s:", soap_type(p->info.typ)); fprintf(fout,"\n\t\tif (p->size < 0)\n\t\t\tdelete (%s*)p->ptr;\n\t\telse\n\t\t\tdelete[] (%s*)p->ptr;\n\t\tbreak;", c_type(p->info.typ), c_type(p->info.typ)); } } for (typ = Tptr[Ttemplate]; typ; typ = typ->next) { if (typ->ref && !is_transient(typ)) { fprintf(fout,"\n\tcase %s:", soap_type(typ)); fprintf(fout,"\n\t\tif (p->size < 0)\n\t\t\tdelete (%s*)p->ptr;\n\t\telse\n\t\t\tdelete[] (%s*)p->ptr;\n\t\tbreak;", c_type(typ), c_type(typ)); } } fprintf(fout,"\n\tdefault:\treturn SOAP_ERR;"); fprintf(fout,"\n\t}\n\treturn SOAP_OK;"); fprintf(fout,"\n}"); } fprintf(fhead,"\nSOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);"); if (!lflag) { fprintf(fout,"\n\nSOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType)"); fprintf(fout, "\n{\treturn soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate);\n}"); } if (Tptr[Ttemplate]) { fprintf(fhead, "\n\nSOAP_FMAC3 void* SOAP_FMAC4 soap_container_id_forward(struct soap*, const char*, void*, size_t, int, int, size_t, unsigned int);"); if (!lflag) { fprintf(fout, "\n\nSOAP_FMAC3 void* SOAP_FMAC4 soap_container_id_forward(struct soap *soap, const char *href, void *p, size_t len, int st, int tt, size_t n, unsigned int k)"); fprintf(fout, "\n{\treturn soap_id_forward(soap, href, p, len, st, tt, n, k, soap_container_insert);\n}"); } fprintf(fhead, "\n\nSOAP_FMAC3 void SOAP_FMAC4 soap_container_insert(struct soap*, int, int, void*, size_t, const void*, size_t);"); if (!lflag) { fprintf(fout, "\n\nSOAP_FMAC3 void SOAP_FMAC4 soap_container_insert(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)"); fprintf(fout, "\n{\tswitch (tt)\n\t{"); for (typ = Tptr[Ttemplate]; typ; typ = typ->next) { if (typ->ref && !is_transient(typ)) { fprintf(fout, "\n\tcase %s:", soap_type(typ)); fprintf(fout, "\n\t\tDBGLOG(TEST, SOAP_MESSAGE(fdebug, \"Container insert type=%%d in %%d location=%%p object=%%p len=%%lu\\n\", st, tt, p, q, (unsigned long)len));"); if (!strcmp(typ->id->name, "std::vector") || !strcmp(typ->id->name, "std::deque")) fprintf(fout, "\n\t\t(*(%s)p)[len] = *(%s)q;", c_type_id(typ, "*"), c_type_id(typ->ref, "*")); else fprintf(fout, "\n\t\t((%s)p)->insert(((%s)p)->end(), *(%s)q);", c_type_id(typ, "*"), c_type_id(typ, "*"), c_type_id(typ->ref, "*")); fprintf(fout, "\n\t\tbreak;"); } } fprintf(fout, "\n\tdefault:\n\t\tDBGLOG(TEST, SOAP_MESSAGE(fdebug, \"Could not insert type=%%d in %%d\\n\", st, tt));"); fprintf(fout, "\n\t}"); fprintf(fout, "\n}"); } } } DBGLOG(fprintf(stderr,"\n Calling def_table( ).")); def_table(table); DBGLOG(fprintf(stderr,"\n Completed def_table( ).")); if (mflag) { DBGLOG(fprintf(stderr,"\n Calling matlab_def_table( ).")); matlab_def_table(table); DBGLOG(fprintf(stderr,"\n Completed matlab_def_table( ).")); fclose(fmatlab); fclose(fmheader); } if (namespaceid) fprintf(fout,"\n\n} // namespace %s\n", namespaceid); if (cflag) fprintf(fout,"\n\n#ifdef __cplusplus\n}\n#endif"); fprintf(fout, "\n\n/* End of %s */\n", soapC); fclose(fout); if (namespaceid) fprintf(fhead,"\n\n} // namespace %s\n", namespaceid); if (cflag) fprintf(fhead,"\n\n#ifdef __cplusplus\n}\n#endif"); fprintf(fhead, "\n\n#endif"); fprintf(fhead, "\n\n/* End of %s */\n", soapH); fclose(fhead); if (namespaceid) fprintf(fheader,"\n\n} // namespace %s\n", namespaceid); if (cflag) fprintf(fheader,"\n\n#ifdef __cplusplus\n}\n#endif"); fprintf(fheader, "\n\n#endif"); fprintf(fheader, "\n\n/* End of %s */\n", soapStub); fclose(fheader); if (!Sflag && !iflag) { if (namespaceid) fprintf(fclient,"\n\n} // namespace %s\n", namespaceid); if (cflag) fprintf(fclient,"\n\n#ifdef __cplusplus\n}\n#endif"); fprintf(fclient, "\n\n/* End of %s */\n", soapClient); fclose(fclient); } if (!Cflag && !iflag) { if (namespaceid) fprintf(fserver,"\n\n} // namespace %s\n", namespaceid); if (cflag) fprintf(fserver,"\n\n#ifdef __cplusplus\n}\n#endif"); fprintf(fserver, "\n\n/* End of %s */\n", soapServer); fclose(fserver); }}voidgen_class(FILE *fd, Tnode *typ){ Entry *Eptr; char *x; x = xsi_type(typ); if (!x || !*x) x = wsdl_type(typ, ""); typ->generated = True; if (typ->ref) { fprintf(fheader, "\n\n#ifndef %s", soap_type(typ)); fprintf(fheader, "\n#define %s (%d)\n",soap_type(typ),typ->num); } else fprintf(fd, "\n\n"); if (is_volatile(typ)) fprintf(fd, "#if 0 /* volatile type: do not redeclare */\n"); else if (is_transient(typ) && typ->ref) fprintf(fd, "/* Transient type: */\n"); else if (is_invisible(typ->id->name) && typ->ref) fprintf(fd, "/* Operation wrapper: */\n"); else if (is_hexBinary(typ)) fprintf(fd, "/* hexBinary schema type: */\n"); else if (is_binary(typ)) fprintf(fd, "/* Base64 schema type: */\n"); else if (is_discriminant(typ)) fprintf(fd, "/* Choice: */\n"); else if (is_dynamic_array(typ)) { Eptr = ((Table*)typ->ref)->list; if (Eptr) { if (!is_untyped(Eptr->info.typ) && ((is_external(Eptr->info.typ->ref) && ((Tnode*)Eptr->info.typ->ref)->type == Tclass) || has_external(Eptr->info.typ->ref))) { sprintf(errbuf, "Field '%s' must be a pointer to an array of pointers to %s to prevent id-ref copying of %s instances containting an external object (declared at line %d)", Eptr->sym->name, c_type(Eptr->info.typ->ref), c_type(Eptr->info.typ->ref), Eptr->lineno); semwarn(errbuf); } else if (!is_untyped(Eptr->info.typ) && ((is_volatile(Eptr->info.typ->ref) && ((Tnode*)Eptr->info.typ->ref)->type == Tclass) || has_volatile(Eptr->info.typ->ref))) { sprintf(errbuf, "Field '%s' must be a pointer to an array of pointers to %s to prevent id-ref copying of %s instances containting a volatile object (declared at line %d)", Eptr->sym->name, c_type(Eptr->info.typ->ref), c_type(Eptr->info.typ->ref), Eptr->lineno); semwarn(errbuf); } } if (has_ns(typ) || is_untyped(typ)) fprintf(fd, "/* Sequence of %s schema type: */\n", x); else { if (!eflag) { sprintf(errbuf, "array '%s' is not compliant with WS-I Basic Profile 1.0a, reason: SOAP encoded array", c_type(typ)); compliancewarn(errbuf); } fprintf(fd, "/* SOAP encoded array of %s schema type: */\n", x); } } else if (is_primclass(typ)) fprintf(fd, "/* Primitive %s schema type: */\n", x); else if (!strcmp(typ->id->name, "SOAP_ENV__Header")) fprintf(fd, "/* SOAP Header: */\n"); else if (!strcmp(typ->id->name, "SOAP_ENV__Fault")) fprintf(fd, "/* SOAP Fault: */\n"); else if (!strcmp(typ->id->name, "SOAP_ENV__Code")) fprintf(fd, "/* SOAP Fault Code: */\n"); else if (x && *x && typ->ref) fprintf(fd, "/* %s */\n", x); fflush(fd); if (typ->type == Tstruct) { DBGLOG(fprintf(stderr,"\nstruct %s\n", typ->id->name)); if (typ->ref) { int permission = -1; fprintf(fd, "struct %s\n{", ident(typ->id->name)); for (Eptr = ((Table*)typ->ref)->list; Eptr; Eptr = Eptr->next) { if (!cflag && permission != (Eptr->info.sto & (Sprivate | Sprotected))) { if (Eptr->info.sto & Sprivate) fprintf(fd, "\nprivate:"); else if (Eptr->info.sto & Sprotected) fprintf(fd, "\nprotected:"); else fprintf(fd, "\npublic:"); permission = (Eptr->info.sto & (Sprivate | Sprotected)); } if (cflag && Eptr->info.typ->type == Tfun) continue; if (cflag && (Eptr->info.sto & Stypedef)) continue; fprintf(fd, "\n\t%s", c_storage(Eptr->info.sto)); /*if (Eptr->info.typ->type == Tclass && !is_external(Eptr->info.typ) && Eptr->info.typ->generated == False || (Eptr->info.typ->type == Tpointer || Eptr->info.typ->type == Treference) && Eptr->info.typ->ref && ((Tnode*)Eptr->info.typ->ref)->type == Tclass && !is_external(Eptr->info.typ->ref) && ((Tnode*)Eptr->info.typ->ref)->generated == False) fprintf(fd, "class "); */ if (Eptr->sym == typ->id) /* a hack to emit constructor in a struct */ ((FNinfo*)Eptr->info.typ->ref)->ret = mknone(); fprintf(fd, "%s", c_type_id(Eptr->info.typ,Eptr->sym->name)); if (Eptr->info.sto & Sconstobj) fprintf(fd, " const;"); else fprintf(fd, ";"); if (Eptr->info.sto & Sreturn) fprintf(fd, "\t/* SOAP 1.2 RPC return element (when namespace qualified) */"); if (is_external(Eptr->info.typ)) fprintf(fd, "\t/* external */"); if (is_transient(Eptr->info.typ)) fprintf(fd, "\t/* transient */"); if (is_imported(Eptr->info.typ)) fprintf(fd, "\t/* type imported from %s */", Eptr->info.typ->imported); if (Eptr->info.sto & Sattribute) { if (Eptr->info.minOccurs >= 1) fprintf(fd, "\t/* required attribute of type %s */", wsdl_type(Eptr->info.typ, "")); else fprintf(fd, "\t/* optional attribute of type %s */", wsdl_type(Eptr->info.typ, "")); } if (Eptr->info.sto & (Sconst | Sprivate | Sprotected)) fprintf(fd, "\t/* not serialized */"); else if (Eptr->info.sto & SmustUnderstand) fprintf(fd, "\t/* mustUnderstand */"); else if (!is_dynamic_array(typ) && is_repetition(Eptr)) { if (!is_untyped(Eptr->next->info.typ) && has_ns(Eptr->next->info.typ->ref) && ((is_external(Eptr->next->info.typ->ref) && ((Tnode*)Eptr->next->info.typ->ref)->type == Tclass) || has_external(Eptr->next->info.typ->ref))) { sprintf(errbuf, "Field '%s' must be a pointer to an array of pointers to %s to prevent id-ref copying of %s instances containing an external object (declared at line %d)", Eptr->next->sym->name, c_type(Eptr->next->info.typ->ref), c_type(Eptr->next->info.typ->ref), Eptr->next->lineno); semwarn(errbuf); } else if (!is_untyped(Eptr->next->info.typ) && has_ns(Eptr->next->info.typ->ref) && ((is_volatile(Eptr->next->info.typ->ref) && ((Tnode*)Eptr->next->info.typ->ref)->type == Tclass) || has_volatile(Eptr->next->info.typ->ref))) { sprintf(errbuf, "Field '%s' must be a pointer to an array of pointers to %s to prevent id-ref copying of %s instances containing a volatile object (declared at line %d)", Eptr->next->sym->name, c_type(Eptr->next->info.typ->ref), c_type(Eptr->next->info.typ->ref), Eptr->next->lineno); semwarn(errbuf); } if (Eptr->info.maxOccurs > 1) fprintf(fd, "\t/* sequence of %ld to %ld elements <%s> */", Eptr->info.minOccurs, Eptr->info.maxOccurs, ns_convert(Eptr->next->sym->name)); else fprintf(fd, "\t/* sequence of elements <%s> */", ns_convert(Eptr->next->sym->name)); } else if (is_anytype(Eptr)) fprintf(fd, "\t/* any type of element <%s> (defined below) */", ns_convert(Eptr->next->sym->name)); else if (is_choice(Eptr)) fprintf(fd, "\t/* union discriminant (of union defined below) */"); else if (Eptr->info.typ->type != Tfun && !(Eptr->info.sto & (Sconst | Sprivate | Sprotected)) && !(Eptr->info.sto & Sattribute) && !is_transient(Eptr->info.typ) && !is_external(Eptr->info.typ) && strncmp(Eptr->sym->name, "__", 2)) { if (Eptr->info.maxOccurs > 1) fprintf(fd, "\t/* sequence of %ld to %ld elements of type %s */", Eptr->info.minOccurs, Eptr->info.maxOccurs, wsdl_type(Eptr->info.typ, "")); else if (Eptr->info.minOccurs >= 1) fprintf(fd, "\t/* required element of type %s */", wsdl_type(Eptr->info.typ, "")); else fprintf(fd, "\t/* optional element of type %s */", wsdl_type(Eptr->info.typ, "")); } if (!is_dynamic_array(typ) && !is_primclass(typ)) { if (!strncmp(Eptr->sym->name, "__size", 6)) { if (!Eptr->next || Eptr->next->info.typ->type != Tpointer) { sprintf(errbuf, "Field '%s' is not followed by a pointer field in struct '%s'", Eptr->sym->name, typ->id->name); semwarn(errbuf); } } else if (!strncmp(Eptr->sym->name, "__type", 6)) { if (!Eptr->next || ((Eptr->next->info.typ->type != Tpointer || ((Tnode*)Eptr->next->info.typ->ref)->type != Tvoid))) { sprintf(errbuf, "Field '%s' is not followed by a void pointer or union field in struct '%s'", Eptr->sym->name, typ->id->name); semwarn(errbuf); } } } } if (!((Table*)typ->ref)->list) { if (cflag) fprintf(fd, "\n#ifdef WITH_NOEMPTYSTRUCT\n\tchar dummy;\t/* dummy member to enable compilation */\n#endif"); else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -