📄 symbol2.c
字号:
semwarn(errbuf); } } if (is_volatile(typ)) fprintf(fd, "\n#endif"); else if (typ->ref) fprintf(fd, "\n#endif"); fflush(fd);}voidgenerate_header(Table *t){ Entry *p, *q; banner(fheader, "Enumerations"); fflush(fheader); if (enumtable) for (p = enumtable->list; p; p = p->next) { char *x; if (is_imported(p->info.typ)) continue; x = xsi_type(p->info.typ); if (!x || !*x) x = wsdl_type(p->info.typ, ""); if (is_volatile(p->info.typ)) fprintf(fheader, "\n\n#if 0 /* volatile type: do no redeclare */\n"); fprintf(fheader, "\n\n#ifndef %s", soap_type(p->info.typ)); fprintf(fheader, "\n#define %s (%d)",soap_type(p->info.typ),p->info.typ->num); if (is_mask(p->info.typ)) fprintf(fheader, "\n/* Bitmask %s */", x); else fprintf(fheader, "\n/* %s */", x); fprintf(fheader, "\nenum %s {", p->info.typ->id->name); if ((Table*)p->info.typ->ref) { q = ((Table*)p->info.typ->ref)->list; if (q) { fprintf(fheader, "%s = "SOAP_LONG_FORMAT, q->sym->name, q->info.val.i); for (q = q->next; q; q = q->next) fprintf(fheader, ", %s = "SOAP_LONG_FORMAT, q->sym->name, q->info.val.i); } } fprintf(fheader, "};\n#endif"); if (is_volatile(p->info.typ)) fprintf(fheader, "\n#endif"); } banner(fheader, "Classes and Structs"); fflush(fheader); /* Obsolete: moved unions in classtable if (uniontable) for (p = uniontable->list; p; p = p->next) if (!is_imported(p->info.typ)) gen_union(fheader, p->info.typ); */ if (classtable) for (p = classtable->list; p; p = p->next) if (!is_imported(p->info.typ)) gen_class(fheader, p->info.typ); banner(fheader, "Types with Custom Serializers"); fflush(fheader); if (typetable) for (p = typetable->list; p; p = p->next) { if (is_external(p->info.typ) && !is_volatile(p->info.typ) && !is_imported(p->info.typ)) { fprintf(fheader, "\n#ifndef %s", soap_type(p->info.typ)); fprintf(fheader, "\n#define %s (%d)",soap_type(p->info.typ),p->info.typ->num); fprintf(fheader, "\n%s%s;", c_storage(p->info.sto), c_type_id(p->info.typ, p->sym->name)); fprintf(fheader, "\n#endif"); } } banner(fheader, "Typedefs"); fflush(fheader); if (typetable) for (p = typetable->list; p; p = p->next) { if (!is_primitive_or_string(p->info.typ) && !is_external(p->info.typ) && !is_XML(p->info.typ) && !is_transient(p->info.typ) && !has_ns_t(p->info.typ) && !is_imported(p->info.typ) && !is_template(p->info.typ)) { sprintf(errbuf, "typedef '%s' is not namespace qualified: schema definition for '%s' in WSDL file output may be invalid", p->sym->name, p->sym->name); semwarn(errbuf); } if (!is_external(p->info.typ) && !is_imported(p->info.typ)) { fprintf(fheader, "\n#ifndef %s", soap_type(p->info.typ)); fprintf(fheader, "\n#define %s (%d)",soap_type(p->info.typ),p->info.typ->num); fprintf(fheader,"\n%s%s;", c_storage(p->info.sto), c_type_id(p->info.typ, p->sym->name)); fprintf(fheader, "\n#endif\n"); } } banner(fheader, "Typedef Synonyms"); if (enumtable) for (p = enumtable->list; p; p = p->next) if (p->sym->token == TYPE) fprintf(fheader, "\ntypedef %s %s;", c_type(p->info.typ), p->sym->name); if (classtable) for (p = classtable->list; p; p = p->next) if ((p->info.typ->type == Tstruct || p->info.typ->type == Tunion) && p->sym->token == TYPE) fprintf(fheader, "\ntypedef %s %s;", c_type(p->info.typ), p->sym->name); banner(fheader, "Externals"); fflush(fheader); if (t) for (p = t->list; p; p = p->next) if (p->info.typ->type != Tfun || p->info.sto & Sextern) { fprintf(fheader,"\n\nextern %s", c_storage(p->info.sto)); fprintf(fheader,"%s;", c_type_id(p->info.typ, p->sym->name)); } fflush(fheader);}voidget_namespace_prefixes(){ Symbol *p, *q; int i, n; char *s, buf[256]; if (nslist) return; for (p = symlist; p; p = p->next) { if (*p->name != '~') { s = p->name; while (*s == '_') s++; n = strlen(s) - 2; for (i = 1; i < n; i++) { if (s[i] == '_' && s[i+1] == '_' && s[i+2] && s[i+2] != '_') { strncpy(buf, s, i); buf[i] = '\0'; if (!strcmp(buf, "SOAP_ENV") || !strcmp(buf, "SOAP_ENC") || !strcmp(buf, "xsd") || !strcmp(buf, "xsi") || !strcmp(buf, "xml") || !strncmp(buf, "soap_", 5)) goto nsnext; for (q = nslist; q; q = q->next) if (!strcmp(q->name, buf)) goto nsnext; q = (Symbol*)emalloc(sizeof(Symbol)); q->name = (char*)emalloc(i+1); strcpy(q->name, buf); q->name[i] = '\0'; q->next = nslist; nslist = q; break; } } }nsnext: ; } q = (Symbol*)emalloc(sizeof(Symbol)); q->name = "xsd"; q->next = nslist; nslist = q; q = (Symbol*)emalloc(sizeof(Symbol)); q->name = "xsi"; q->next = nslist; nslist = q; q = (Symbol*)emalloc(sizeof(Symbol)); q->name = "SOAP-ENC"; q->next = nslist; nslist = q; q = (Symbol*)emalloc(sizeof(Symbol)); q->name = "SOAP-ENV"; q->next = nslist; nslist = q;}voidgenerate_schema(Table *t){ Entry *p; Symbol *ns, *ns1; char *name = NULL; char *URL = NULL; char *executable = NULL; char *URI = NULL; char *style = NULL; char *encoding = NULL; char *import = NULL; Service *sp; char buf[1024]; FILE *fd; get_namespace_prefixes(); for (ns = nslist; ns; ns = ns->next) { if (!strcmp(ns->name, "SOAP-ENV") || !strcmp(ns->name, "SOAP-ENC") || !strcmp(ns->name, "xsi") || !strcmp(ns->name, "xsd")) continue; name = NULL; URL = NULL; executable = NULL; URI = NULL; style = NULL; encoding = NULL; import = NULL; for (sp = services; sp; sp = sp->next) { if (!strcmp(sp->ns, ns->name)) { name = ns_cname(sp->name, NULL); URL = sp->URL; executable = sp->executable; URI = sp->URI; style = sp->style; encoding = sp->encoding; import = sp->import; break; } } if (!URI) { URI = emalloc(strlen(tmpURI) + strlen(ns->name) + 6); sprintf(URI, "%s/%s.xsd", tmpURI, ns_convert(ns->name)); } if (is_document(style) && encoding && !*encoding) { semwarn("Cannot use document style with SOAP encoding"); encoding = NULL; } if (!name) name = "Service"; if (!URL) URL = "http://localhost:80"; if (t) { int flag = 0; for (p = t->list; p; p = p->next) { if (p->info.typ->type == Tfun && !(p->info.sto & Sextern) && has_ns_eq(ns->name, p->sym->name)) { flag = 1; if (name) fprintf(fmsg, "Using %s service name: %s\n", ns->name, name); if (style) fprintf(fmsg, "Using %s service style: %s\n", ns->name, style); else if (!eflag) fprintf(fmsg, "Using %s service style: document\n", ns->name); if (encoding && *encoding) fprintf(fmsg, "Using %s service encoding: %s\n", ns->name, encoding); else if (encoding && !*encoding) fprintf(fmsg, "Using %s service encoding: encoded\n", ns->name); else if (!eflag) fprintf(fmsg, "Using %s service encoding: literal\n", ns->name); if (URL) fprintf(fmsg, "Using %s service location: %s\n", ns->name, URL); if (executable) fprintf(fmsg, "Using %s service executable: %s\n", ns->name, executable); if (import) fprintf(fmsg, "Using %s schema import: %s\n", ns->name, import); else if (URI) fprintf(fmsg, "Using %s schema namespace: %s\n", ns->name, URI); if (sp && sp->name) sprintf(buf, "%s%s.wsdl", dirpath, ns_cname(name, NULL)); else sprintf(buf, "%s%s.wsdl", dirpath, ns_cname(ns->name, NULL)); if (!wflag) { fprintf(fmsg, "Saving %s Web Service description\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write WSDL file"); gen_wsdl(fd, t, ns->name, name, URL, executable, URI, style, encoding); fclose(fd); } if (!cflag) { if (iflag) { if (!Sflag && sp && sp->name) { char *name1 = ns_cname(sp->name, "Proxy"); sprintf(buf, "%s%s%s.h", dirpath, prefix, name1); fprintf(fmsg, "Saving %s client proxy class\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write proxy class file"); sprintf(buf, "%s%s.h", prefix, name1); copyrightnote(fd, buf); gen_proxy_header(fd, t, ns, name1, URL, executable, URI, encoding); fclose(fd); sprintf(buf, "%s%s%s.cpp", dirpath, prefix, name1); fprintf(fmsg, "Saving %s client proxy class\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write proxy class file"); sprintf(buf, "%s%s.cpp", prefix, name1); copyrightnote(fd, buf); gen_proxy_code(fd, t, ns, name1, URL, executable, URI, encoding); fclose(fd); } if (!Cflag && sp && sp->name) { char *name1 = ns_cname(sp->name, "Service"); sprintf(buf, "%s%s%s.h", dirpath, prefix, name1); fprintf(fmsg, "Saving %s service class\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write service class file"); sprintf(buf, "%s%s.h", prefix, name1); copyrightnote(fd, buf); gen_object_header(fd, t, ns, name1, URL, executable, URI, encoding); fclose(fd); sprintf(buf, "%s%s%s.cpp", dirpath, prefix, name1); fprintf(fmsg, "Saving %s service class\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write service class file"); sprintf(buf, "%s%s.cpp", prefix, name1); copyrightnote(fd, buf); gen_object_code(fd, t, ns, name1, URL, executable, URI, encoding); fclose(fd); } } else { if (!Sflag && sp && sp->name) { sprintf(buf, "%s%s%s.h", dirpath, prefix, ns_cname(name, "Proxy")); fprintf(fmsg, "Saving %s client proxy\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write proxy file"); sprintf(buf, "%s%s.h", prefix, ns_cname(name, "Proxy")); copyrightnote(fd, buf); gen_proxy(fd, t, ns, name, URL, executable, URI, encoding); fclose(fd); } else if (!Sflag) { sprintf(buf, "%s%s.h", dirpath, ns_cname(prefix, "Proxy")); fprintf(fmsg, "Saving %s client proxy\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write proxy file"); sprintf(buf, "%s.h", ns_cname(prefix, "Proxy")); copyrightnote(fd, buf); gen_proxy(fd, t, ns, "Service", URL, executable, URI, encoding); fclose(fd); } if (!Cflag && sp && sp->name) { sprintf(buf, "%s%s%s.h", dirpath, prefix, ns_cname(name, "Object")); fprintf(fmsg, "Saving %s server object\n", buf); fd = fopen(buf, "w"); if (!fd) execerror("Cannot write server object file"); sprintf(buf, "%s%s.h", prefix, ns_cname(name, "Object"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -