| 1 | /* | |
| 2 | * Copyright 1999-2006 University of Chicago | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | ||
| 18 | #include "globus_common.h" | |
| 19 | #include "libxml/xmlschemas.h" | |
| 20 | #include "libxml/schemasInternals.h" | |
| 21 | #include "libxml/uri.h" | |
| 22 | ||
| 23 | #include "wsdl.h" | |
| 24 | ||
| 25 | #include "globus_wsdl_template.h" | |
| 26 | #include "globus_i_wsdl_parser.h" | |
| 27 | #include "globus_wsdl_config.h" | |
| 28 | ||
| 29 | #include "js/jsstddef.h" | |
| 30 | #include <errno.h> | |
| 31 | #include <stdio.h> | |
| 32 | #include <stdlib.h> | |
| 33 | #include <string.h> | |
| 34 | #include "js/jstypes.h" | |
| 35 | #include "js/jsarena.h" | |
| 36 | #include "js/jsutil.h" | |
| 37 | #include "js/jsprf.h" | |
| 38 | #include "js/jsapi.h" | |
| 39 | #include "js/jsatom.h" | |
| 40 | #include "js/jscntxt.h" | |
| 41 | #include "js/jsdbgapi.h" | |
| 42 | #include "js/jsemit.h" | |
| 43 | #include "js/jsfun.h" | |
| 44 | #include "js/jsgc.h" | |
| 45 | #include "js/jslock.h" | |
| 46 | #include "js/jsobj.h" | |
| 47 | #include "js/jsparse.h" | |
| 48 | #include "js/jsscope.h" | |
| 49 | #include "js/jsscript.h" | |
| 50 | ||
| 51 | #include <sys/types.h> | |
| 52 | #include <sys/stat.h> | |
| 53 | #include <errno.h> | |
| 54 | ||
| 55 | #ifdef WIN32 | |
| 56 | #define FILE_SEPARATOR "\\" | |
| 57 | #else | |
| 58 | #define FILE_SEPARATOR "/" | |
| 59 | #endif | |
| 60 | ||
| 61 | #define GLOBUS_L_WSDL_JSCRIPT_UNBOUNDED (1 << 30) | |
| 62 | ||
| 63 | size_t gStackChunkSize = 8192; | |
| 64 | ||
| 65 | typedef struct _StreamContext StreamContext; | |
| 66 | struct _StreamContext | |
| 67 | { | |
| 68 | FILE * error_stream; | |
| 69 | FILE * out_stream; | |
| 70 | StreamContext * next; | |
| 71 | }; | |
| 72 | ||
| 73 | typedef struct _Template Template; | |
| 74 | struct _Template | |
| 75 | { | |
| 76 | char * filename; | |
| 77 | char * buffer; | |
| 78 | size_t length; | |
| 79 | }; | |
| 80 | ||
| 81 | typedef struct _PrivateContext PrivateContext; | |
| 82 | struct _PrivateContext | |
| 83 | { | |
| 84 | StreamContext * streams; | |
| 85 | globus_result_t result; | |
| 86 | globus_hashtable_t nsmap; | |
| 87 | int free_nsmap; | |
| 88 | globus_hashtable_t templates; | |
| 89 | char * outdir; | |
| 90 | globus_list_t * template_paths; | |
| 91 | }; | |
| 92 | ||
| 93 | static | |
| 94 | void TemplateFree( | |
| 95 | void * template); | |
| 96 | ||
| 97 | static JSBool | |
| 98 | LoadTemplate( | |
| 99 | JSContext * ctx, | |
| 100 | JSObject * obj, | |
| 101 | uintN argc, | |
| 102 | jsval * argv, | |
| 103 | jsval * rval); | |
| 104 | ||
| 105 | static JSBool | |
| 106 | FileExists( | |
| 107 | JSContext * ctx, | |
| 108 | JSObject * obj, | |
| 109 | uintN argc, | |
| 110 | jsval * argv, | |
| 111 | jsval * rval); | |
| 112 | ||
| 113 | static JSBool | |
| 114 | CreateSubDir( | |
| 115 | JSContext * ctx, | |
| 116 | JSObject * obj, | |
| 117 | uintN argc, | |
| 118 | jsval * argv, | |
| 119 | jsval * rval); | |
| 120 | ||
| 121 | static JSBool | |
| 122 | URIBasePath( | |
| 123 | JSContext * ctx, | |
| 124 | JSObject * obj, | |
| 125 | uintN argc, | |
| 126 | jsval * argv, | |
| 127 | jsval * rval); | |
| 128 | ||
| 129 | static JSBool | |
| 130 | NamespaceToPrefix( | |
| 131 | JSContext * cx, | |
| 132 | JSObject * obj, | |
| 133 | uintN argc, | |
| 134 | jsval * argv, | |
| 135 | jsval * rval); | |
| 136 | ||
| 137 | static JSBool | |
| 138 | Debug( | |
| 139 | JSContext * cx, | |
| 140 | JSObject * obj, | |
| 141 | uintN argc, | |
| 142 | jsval * argv, | |
| 143 | jsval * rval); | |
| 144 | ||
| 145 | static JSBool | |
| 146 | Abort( | |
| 147 | JSContext * cx, | |
| 148 | JSObject * obj, | |
| 149 | uintN argc, | |
| 150 | jsval * argv, | |
| 151 | jsval * rval); | |
| 152 | ||
| 153 | static JSBool | |
| 154 | Print( | |
| 155 | JSContext * cx, | |
| 156 | JSObject * obj, | |
| 157 | uintN argc, | |
| 158 | jsval * argv, | |
| 159 | jsval * rval); | |
| 160 | ||
| 161 | static JSBool | |
| 162 | Error( | |
| 163 | JSContext * cx, | |
| 164 | JSObject * obj, | |
| 165 | uintN argc, | |
| 166 | jsval * argv, | |
| 167 | jsval * rval); | |
| 168 | ||
| 169 | static JSBool | |
| 170 | CanonicalizeString( | |
| 171 | JSContext * cx, | |
| 172 | JSObject * obj, | |
| 173 | uintN argc, | |
| 174 | jsval * argv, | |
| 175 | jsval * rval); | |
| 176 | ||
| 177 | #define DEF_GET_PROP(_PREFIX_) \ | |
| 178 | static JSBool \ | |
| 179 | _PREFIX_ ## Getter( \ | |
| 180 | JSContext * cx, \ | |
| 181 | JSObject * obj, \ | |
| 182 | jsval id, \ | |
| 183 | jsval * vp) | |
| 184 | ||
| 185 | #define DEF_ENUM_PROP(_PREFIX_) \ | |
| 186 | static JSBool \ | |
| 187 | _PREFIX_ ## Enumerate( \ | |
| 188 | JSContext * cx, \ | |
| 189 | JSObject * obj, \ | |
| 190 | JSIterateOp enum_op, \ | |
| 191 | jsval * statep, \ | |
| 192 | jsid * idp) | |
| 193 | ||
| 194 | #define DEF_CLASS(_PREFIX_) \ | |
| 195 | static JSClass _PREFIX_ ## _class = \ | |
| 196 | { \ | |
| 197 | #_PREFIX_, JSCLASS_HAS_PRIVATE|JSCLASS_NEW_RESOLVE, \ | |
| 198 | JS_PropertyStub, JS_PropertyStub, \ | |
| 199 | _PREFIX_ ## Getter, JS_PropertyStub, \ | |
| 200 | JS_EnumerateStub, JS_ResolveStub, \ | |
| 201 | JS_ConvertStub, JS_FinalizeStub \ | |
| 202 | }; \ | |
| 203 | static JSObject * _PREFIX_ ## Class | |
| 204 | ||
| 205 | #define DEF_LISTCLASS(_PREFIX_) \ | |
| 206 | static JSClass _PREFIX_ ## _class = \ | |
| 207 | { \ | |
| 208 | #_PREFIX_, JSCLASS_NEW_ENUMERATE|JSCLASS_HAS_PRIVATE, \ | |
| 209 | JS_PropertyStub, JS_PropertyStub, \ | |
| 210 | _PREFIX_ ## Getter, JS_PropertyStub, \ | |
| 211 | (JSEnumerateOp) _PREFIX_ ## Enumerate, \ | |
| 212 | JS_ResolveStub, \ | |
| 213 | JS_ConvertStub, JS_FinalizeStub \ | |
| 214 | } | |
| 215 | ||
| 216 | #define DEF_PROPS(_PREFIX_) \ | |
| 217 | extern JSPropertySpec _PREFIX_ ## _properties[] | |
| 218 | ||
| 219 | #define DEF_LIST(_PREFIX_) \ | |
| 220 | DEF_ENUM_PROP(_PREFIX_); \ | |
| 221 | DEF_GET_PROP(_PREFIX_); \ | |
| 222 | DEF_LISTCLASS(_PREFIX_) | |
| 223 | ||
| 224 | #define DEF_OBJECT(_PREFIX_) \ | |
| 225 | DEF_GET_PROP(_PREFIX_); \ | |
| 226 | DEF_PROPS(_PREFIX_); \ | |
| 227 | DEF_CLASS(_PREFIX_) | |
| 228 | ||
| 229 | DEF_OBJECT(xsdType); | |
| 230 | DEF_OBJECT(xsdAttr); | |
| 231 | DEF_OBJECT(xsdElement); | |
| 232 | DEF_OBJECT(xsdWildcard); | |
| 233 | DEF_OBJECT(xsdFacet); | |
| 234 | ||
| 235 | DEF_OBJECT(xsdQName); | |
| 236 | DEF_OBJECT(part); | |
| 237 | DEF_OBJECT(operation); | |
| 238 | DEF_OBJECT(binding); | |
| 239 | DEF_OBJECT(portType); | |
| 240 | DEF_OBJECT(message); | |
| 241 | DEF_OBJECT(param); | |
| 242 | DEF_OBJECT(fault); | |
| 243 | DEF_OBJECT(port); | |
| 244 | DEF_OBJECT(service); | |
| 245 | DEF_OBJECT(bindingOperation); | |
| 246 | DEF_OBJECT(bindingOperationFault); | |
| 247 | ||
| 248 | DEF_OBJECT(soapBinding); | |
| 249 | DEF_OBJECT(soapOperation); | |
| 250 | DEF_OBJECT(soapBindingParam); | |
| 251 | DEF_OBJECT(soapBody); | |
| 252 | DEF_OBJECT(soapFault); | |
| 253 | DEF_OBJECT(soapHeader); | |
| 254 | DEF_OBJECT(soapAddress); | |
| 255 | ||
| 256 | DEF_GET_PROP(xsdEnum); | |
| 257 | DEF_CLASS(xsdEnum); | |
| 258 | ||
| 259 | DEF_PROPS(xsdTypeEnum); | |
| 260 | DEF_PROPS(xsdContentTypeEnum); | |
| 261 | DEF_PROPS(xsdAttrEnum); | |
| 262 | DEF_PROPS(operationTypeEnum); | |
| 263 | DEF_PROPS(bindingType); | |
| 264 | DEF_PROPS(soapOperationStyleType); | |
| 265 | DEF_PROPS(soapUseType); | |
| 266 | ||
| 267 | DEF_LIST(xsdSubTypes); | |
| 268 | DEF_LIST(xsdAttrs); | |
| 269 | DEF_LIST(xsdQNames); | |
| 270 | DEF_LIST(parts); | |
| 271 | DEF_LIST(operations); | |
| 272 | DEF_LIST(faults); | |
| 273 | DEF_LIST(ports); | |
| 274 | DEF_LIST(bindingOperations); | |
| 275 | DEF_LIST(bindingOperationFaults); | |
| 276 | DEF_LIST(xsdFacets); | |
| 277 | ||
| 278 | static void | |
| 279 | internal_ErrorReporter( | |
| 280 | JSContext * cx, | |
| 281 | const char * message, | |
| 282 | JSErrorReport * report); | |
| 283 | ||
| 284 | static JSFunctionSpec functions_defs[] = | |
| 285 | { | |
| 286 | {"load", LoadTemplate, 0}, | |
| 287 | {"file_exists", FileExists, 0}, | |
| 288 | {"uri_base_path", URIBasePath, 0}, | |
| 289 | {"create_subdir", CreateSubDir, 0}, | |
| 290 | {"debug", Debug, 0}, | |
| 291 | {"abort", Abort, 0}, | |
| 292 | {"error", Error, 0}, | |
| 293 | {"print", Print, 0}, | |
| 294 | {"canonical", CanonicalizeString, 0}, | |
| 295 | {"NStoP", NamespaceToPrefix, 0}, | |
| 296 | {0} | |
| 297 | }; | |
| 298 | ||
| 299 | static JSClass global_class = | |
| 300 | { | |
| 301 | "global", JSCLASS_NEW_RESOLVE, | |
| 302 | JS_PropertyStub, JS_PropertyStub, | |
| 303 | JS_PropertyStub, JS_PropertyStub, | |
| 304 | JS_EnumerateStub, JS_ResolveStub, | |
| 305 | JS_ConvertStub, JS_FinalizeStub | |
| 306 | }; | |
| 307 | ||
| 308 | static JSClass basic_class = | |
| 309 | { | |
| 310 | "basic", JSCLASS_NEW_RESOLVE, | |
| 311 | JS_PropertyStub, JS_PropertyStub, | |
| 312 | JS_PropertyStub, JS_PropertyStub, | |
| 313 | JS_EnumerateStub, JS_ResolveStub, | |
| 314 | JS_ConvertStub, JS_FinalizeStub | |
| 315 | }; | |
| 316 | ||
| 317 | typedef struct _ScannerData ScannerData; | |
| 318 | struct _ScannerData | |
| 319 | { | |
| 320 | wsdlSchemaPtr schema; | |
| 321 | xmlSchemaPtr xsdSchema; | |
| 322 | JSContext * context; | |
| 323 | JSObject * global; | |
| 324 | JSObject * types; | |
| 325 | JSObject * elements; | |
| 326 | JSObject * local_elements; | |
| 327 | JSObject * attributes; | |
| 328 | JSObject * local_attributes; | |
| 329 | JSObject * messages; | |
| 330 | JSObject * portTypes; | |
| 331 | JSObject * bindings; | |
| 332 | JSObject * services; | |
| 333 | globus_result_t result; | |
| 334 | }; | |
| 335 | ||
| 336 | static | |
| 337 | void | |
| 338 | globus_i_wsdl_parser_import_scanner( | |
| 339 | void * payload, | |
| 340 | void * data, | |
| 341 | xmlChar * name); | |
| 342 | ||
| 343 | static | |
| 344 | void | |
| 345 | globus_i_wsdl_parser_type_scanner( | |
| 346 | void * payload, | |
| 347 | void * data, | |
| 348 | xmlChar * name); | |
| 349 | ||
| 350 | static | |
| 351 | void | |
| 352 | globus_i_wsdl_parser_element_scanner( | |
| 353 | void * payload, | |
| 354 | void * data, | |
| 355 | xmlChar * name); | |
| 356 | ||
| 357 | static | |
| 358 | void | |
| 359 | globus_i_wsdl_parser_attribute_scanner( | |
| 360 | void * payload, | |
| 361 | void * data, | |
| 362 | xmlChar * name); | |
| 363 | ||
| 364 | static | |
| 365 | void | |
| 366 | globus_i_wsdl_parser_message_scanner( | |
| 367 | void * payload, | |
| 368 | void * data, | |
| 369 | xmlChar * name); | |
| 370 | ||
| 371 | static | |
| 372 | void | |
| 373 | globus_i_wsdl_parser_portType_scanner( | |
| 374 | void * payload, | |
| 375 | void * data, | |
| 376 | xmlChar * name); | |
| 377 | ||
| 378 | static | |
| 379 | void | |
| 380 | globus_i_wsdl_parser_binding_scanner( | |
| 381 | void * payload, | |
| 382 | void * data, | |
| 383 | xmlChar * name); | |
| 384 | ||
| 385 | static | |
| 386 | void | |
| 387 | globus_i_wsdl_parser_service_scanner( | |
| 388 | void * payload, | |
| 389 | void * data, | |
| 390 | xmlChar * name); | |
| 391 | ||
| 392 | static | |
| 393 | void | |
| 394 | globus_i_wsdl_parser_wsdl_imports_scanner( | |
| 395 | void * payload, | |
| 396 | void * data, | |
| 397 | xmlChar * name); | |
| 398 | ||
| 399 | static | |
| 400 | globus_result_t | |
| 401 | globus_i_wsdl_js_load_schema( | |
| 402 | JSContext * cx, | |
| 403 | wsdlSchemaPtr schema); | |
| 404 | ||
| 405 | static | |
| 406 | globus_result_t | |
| 407 | globus_i_wsdl_execute_script( | |
| 408 | JSContext * ctx, | |
| 409 | JSObject * glob, | |
| 410 | const char * tmpl_filename, | |
| 411 | const char * out_filename, | |
| 412 | const char * out_dir, | |
| 413 | globus_hashtable_t nsmap, | |
| 414 | globus_list_t * template_paths); | |
| 415 | ||
| 416 | static | |
| 417 | JSString * | |
| 418 | globus_l_wsdl_jscript_qname_string( | |
| 419 | JSContext * ctx, | |
| 420 | const xmlChar * href, | |
| 421 | const xmlChar * local); | |
| 422 | ||
| 423 | static | |
| 424 | void | |
| 425 | globus_i_wsdl_parser_classes_init( | |
| 426 | JSContext * cx, | |
| 427 | JSObject * glob) | |
| 428 | 0 | { |
| 429 | 0 | xsdTypeClass = JS_InitClass(cx, glob, NULL, &xsdType_class, NULL, 0, |
| 430 | xsdType_properties, NULL, NULL, NULL); | |
| 431 | ||
| 432 | 0 | xsdElementClass = JS_InitClass(cx, glob, NULL, &xsdElement_class, NULL, 0, |
| 433 | xsdElement_properties, NULL, NULL, NULL); | |
| 434 | ||
| 435 | 0 | xsdAttrClass = JS_InitClass(cx, glob, NULL, &xsdAttr_class, NULL, 0, |
| 436 | xsdAttr_properties, NULL, NULL, NULL); | |
| 437 | ||
| 438 | 0 | xsdWildcardClass = JS_InitClass(cx, glob, NULL, &xsdWildcard_class, NULL, 0, |
| 439 | xsdWildcard_properties, NULL, NULL, NULL); | |
| 440 | ||
| 441 | 0 | xsdFacetClass = JS_InitClass(cx, glob, NULL, &xsdFacet_class, NULL, 0, |
| 442 | xsdFacet_properties, NULL, NULL, NULL); | |
| 443 | ||
| 444 | 0 | messageClass = JS_InitClass(cx, glob, NULL, &message_class, NULL, 0, |
| 445 | message_properties, NULL, NULL, NULL); | |
| 446 | ||
| 447 | 0 | portTypeClass = JS_InitClass(cx, glob, NULL, &portType_class, NULL, 0, |
| 448 | portType_properties, NULL, NULL, NULL); | |
| 449 | ||
| 450 | 0 | operationClass = JS_InitClass(cx, glob, NULL, &operation_class, NULL, 0, |
| 451 | operation_properties, NULL, NULL, NULL); | |
| 452 | ||
| 453 | 0 | bindingClass = JS_InitClass(cx, glob, NULL, &binding_class, NULL, 0, |
| 454 | binding_properties, NULL, NULL, NULL); | |
| 455 | ||
| 456 | 0 | serviceClass = JS_InitClass(cx, glob, NULL, &service_class, NULL, 0, |
| 457 | service_properties, NULL, NULL, NULL); | |
| 458 | ||
| 459 | 0 | bindingOperationClass = JS_InitClass(cx, glob, NULL, |
| 460 | &bindingOperation_class, NULL, 0, | |
| 461 | bindingOperation_properties, | |
| 462 | NULL, NULL, NULL); | |
| 463 | ||
| 464 | 0 | soapBindingClass = JS_InitClass(cx, glob, NULL, &soapBinding_class, NULL, 0, |
| 465 | soapBinding_properties, NULL, NULL, NULL); | |
| 466 | ||
| 467 | 0 | soapOperationClass = JS_InitClass(cx, glob, NULL, &soapOperation_class, |
| 468 | NULL, 0, soapOperation_properties, | |
| 469 | NULL, NULL, NULL); | |
| 470 | ||
| 471 | } | |
| 472 | ||
| 473 | static JSBool | |
| 474 | URIBasePath( | |
| 475 | JSContext * cx, | |
| 476 | JSObject * obj, | |
| 477 | uintN argc, | |
| 478 | jsval * argv, | |
| 479 | jsval * rval) | |
| 480 | 0 | { |
| 481 | 0 | char * uri_base_path; |
| 482 | 0 | JSString * str; |
| 483 | 0 | char * uri_string; |
| 484 | 0 | xmlURIPtr uri_handle; |
| 485 | 0 | JSBool res = JS_TRUE; |
| 486 | 0 | GlobusFuncName(URIBasePath); |
| 487 | 0 | GlobusWSDLDebugEnter(); |
| 488 | ||
| 489 | 0 | if(argc < 1) |
| 490 | { | |
| 491 | 0 | JS_ReportError(cx, |
| 492 | "Wrong number of arguments " | |
| 493 | "passed to function: %s", | |
| 494 | argc, 2, "load(template, outfile)"); | |
| 495 | 0 | res = JS_FALSE; |
| 496 | 0 | goto exit; |
| 497 | } | |
| 498 | ||
| 499 | 0 | str = JS_ValueToString(cx, argv[0]); |
| 500 | 0 | if(!str) |
| 501 | { | |
| 502 | 0 | JS_ReportError(cx, |
| 503 | "Failed to load template"); | |
| 504 | 0 | res = JS_FALSE; |
| 505 | 0 | goto exit; |
| 506 | } | |
| 507 | ||
| 508 | 0 | uri_string = globus_common_create_string("%*s", |
| 509 | JS_GetStringLength(str), | |
| 510 | JS_GetStringBytes(str)); | |
| 511 | ||
| 512 | 0 | uri_handle = xmlParseURI(uri_string); |
| 513 | 0 | if(!uri_handle) |
| 514 | { | |
| 515 | 0 | JS_ReportError(cx, "Failed to parse uri: %s", uri_string); |
| 516 | 0 | res = JS_FALSE; |
| 517 | 0 | goto exit; |
| 518 | } | |
| 519 | ||
| 520 | 0 | uri_base_path = uri_handle->path; |
| 521 | 0 | while((*uri_base_path) == '/') |
| 522 | { | |
| 523 | 0 | ++uri_base_path; |
| 524 | } | |
| 525 | ||
| 526 | 0 | str = JS_InternString(cx, (const char *) uri_base_path); |
| 527 | 0 | *rval = STRING_TO_JSVAL(str); |
| 528 | ||
| 529 | exit: | |
| 530 | 0 | GlobusWSDLDebugExit(); |
| 531 | 0 | return res; |
| 532 | } | |
| 533 | ||
| 534 | static JSBool | |
| 535 | CreateSubDir( | |
| 536 | JSContext * cx, | |
| 537 | JSObject * obj, | |
| 538 | uintN argc, | |
| 539 | jsval * argv, | |
| 540 | jsval * rval) | |
| 541 | 0 | { |
| 542 | 0 | JSString * str; |
| 543 | 0 | char * dir_string; |
| 544 | 0 | JSBool res = JS_TRUE; |
| 545 | 0 | PrivateContext * private = NULL; |
| 546 | 0 | GlobusFuncName(CreateSubDir); |
| 547 | 0 | GlobusWSDLDebugEnter(); |
| 548 | ||
| 549 | 0 | if(argc < 1) |
| 550 | { | |
| 551 | 0 | JS_ReportError(cx, |
| 552 | "Wrong number of arguments " | |
| 553 | "passed to function: %s", | |
| 554 | argc, 2, "load(template, outfile)"); | |
| 555 | 0 | res = JS_FALSE; |
| 556 | 0 | goto exit; |
| 557 | } | |
| 558 | ||
| 559 | 0 | private = (PrivateContext *) JS_GetContextPrivate(cx); |
| 560 | ||
| 561 | 0 | str = JS_ValueToString(cx, argv[0]); |
| 562 | 0 | if(!str) |
| 563 | { | |
| 564 | 0 | JS_ReportError(cx, |
| 565 | "Failed to load template"); | |
| 566 | 0 | res = JS_FALSE; |
| 567 | 0 | goto exit; |
| 568 | } | |
| 569 | ||
| 570 | 0 | dir_string = globus_common_create_string( |
| 571 | "%s%s%*s", | |
| 572 | (private->outdir ? private->outdir : ""), | |
| 573 | (private->outdir ? FILE_SEPARATOR : ""), | |
| 574 | (int) JS_GetStringLength(str), | |
| 575 | JS_GetStringBytes(str)); | |
| 576 | ||
| 577 | 0 | if(mkdir(dir_string, 00770) < 0) |
| 578 | { | |
| 579 | 0 | if(errno != EEXIST) |
| 580 | { | |
| 581 | 0 | globus_object_t * errobj; |
| 582 | 0 | char * errstr; |
| 583 | ||
| 584 | 0 | errobj = globus_error_wrap_errno_error( |
| 585 | GLOBUS_WSDL_PARSER_MODULE, | |
| 586 | errno, | |
| 587 | GLOBUS_WSDL_ERROR_JSRUNTIME, | |
| 588 | __FILE__, | |
| 589 | _globus_func_name, | |
| 590 | __LINE__, | |
| 591 | "Failed to create directory: %s", | |
| 592 | dir_string); | |
| 593 | 0 | errstr = globus_error_print_friendly(errobj); |
| 594 | 0 | globus_object_free(errobj); |
| 595 | 0 | JS_ReportError(cx, "subdir %s creation failed:%d:%s", |
| 596 | dir_string, errno, errstr); | |
| 597 | 0 | globus_free(errstr); |
| 598 | 0 | free(dir_string); |
| 599 | 0 | res = JS_FALSE; |
| 600 | 0 | goto exit; |
| 601 | } | |
| 602 | } | |
| 603 | ||
| 604 | 0 | free(dir_string); |
| 605 | ||
| 606 | 0 | *rval = JSVAL_NULL; |
| 607 | ||
| 608 | exit: | |
| 609 | 0 | GlobusWSDLDebugExit(); |
| 610 | 0 | return res; |
| 611 | } | |
| 612 | ||
| 613 | static JSBool | |
| 614 | LoadTemplate( | |
| 615 | JSContext * cx, | |
| 616 | JSObject * obj, | |
| 617 | uintN argc, | |
| 618 | jsval * argv, | |
| 619 | jsval * rval) | |
| 620 | 0 | { |
| 621 | 0 | char * script_buffer = NULL; |
| 622 | 0 | size_t script_length = 0; |
| 623 | 0 | jsval result; |
| 624 | 0 | JSBool res = JS_TRUE; |
| 625 | 0 | char * error = NULL; |
| 626 | 0 | char * path = NULL; |
| 627 | 0 | JSString * str; |
| 628 | 0 | char filename[500]; |
| 629 | 0 | char out_filename[500]; |
| 630 | 0 | FILE * out_stream = NULL; |
| 631 | 0 | PrivateContext * private = NULL; |
| 632 | 0 | Template * template = NULL; |
| 633 | 0 | StreamContext * new_streams = NULL; |
| 634 | 0 | StreamContext * tmp_streams = NULL; |
| 635 | 0 | globus_list_t * paths = NULL; |
| 636 | 0 | struct stat statbuf; |
| 637 | 0 | int filename_found = 0; |
| 638 | 0 | GlobusFuncName(LoadTemplate); |
| 639 | 0 | GlobusWSDLDebugEnter(); |
| 640 | ||
| 641 | 0 | if(argc < 1) |
| 642 | { | |
| 643 | 0 | JS_ReportError(cx, |
| 644 | "Wrong number of arguments " | |
| 645 | "passed to function: %s", | |
| 646 | argc, 2, "load(template, outfile)"); | |
| 647 | 0 | res = JS_FALSE; |
| 648 | 0 | goto exit; |
| 649 | } | |
| 650 | ||
| 651 | 0 | str = JS_ValueToString(cx, argv[0]); |
| 652 | 0 | if(!str) |
| 653 | { | |
| 654 | 0 | JS_ReportError(cx, |
| 655 | "Failed to load template"); | |
| 656 | 0 | res = JS_FALSE; |
| 657 | 0 | goto exit; |
| 658 | } | |
| 659 | ||
| 660 | 0 | private = (PrivateContext *) JS_GetContextPrivate(cx); |
| 661 | 0 | paths = private->template_paths; |
| 662 | ||
| 663 | 0 | while(paths) |
| 664 | { | |
| 665 | 0 | path = globus_list_first(paths); |
| 666 | 0 | sprintf(filename, "%s/%*s", |
| 667 | path, (int) JS_GetStringLength(str), | |
| 668 | JS_GetStringBytes(str)); | |
| 669 | ||
| 670 | 0 | if(private->templates) |
| 671 | { | |
| 672 | 0 | template = globus_hashtable_lookup(&private->templates, filename); |
| 673 | 0 | if(template) |
| 674 | { | |
| 675 | 0 | filename_found = 1; |
| 676 | 0 | break; |
| 677 | } | |
| 678 | } | |
| 679 | ||
| 680 | 0 | if(stat(filename, &statbuf)) |
| 681 | { | |
| 682 | 0 | if(errno != ENOENT) |
| 683 | { | |
| 684 | 0 | char * errstr; |
| 685 | 0 | result = GlobusWSDLErrorAccessingTemplateFile(errno, filename); |
| 686 | 0 | errstr = globus_error_print_chain(globus_error_get(result)); |
| 687 | ||
| 688 | 0 | JS_ReportError(cx, errstr); |
| 689 | 0 | res = JS_FALSE; |
| 690 | 0 | goto exit; |
| 691 | } | |
| 692 | } | |
| 693 | else | |
| 694 | { | |
| 695 | 0 | filename_found = 1; |
| 696 | 0 | break; |
| 697 | } | |
| 698 | ||
| 699 | 0 | paths = globus_list_rest(paths); |
| 700 | } | |
| 701 | ||
| 702 | 0 | if(!filename_found) |
| 703 | { | |
| 704 | 0 | sprintf(filename, "%*s", (int) JS_GetStringLength(str), JS_GetStringBytes(str)); |
| 705 | 0 | if(private->templates) |
| 706 | { | |
| 707 | 0 | template = globus_hashtable_lookup(&private->templates, filename); |
| 708 | } | |
| 709 | } | |
| 710 | ||
| 711 | 0 | if(!template) |
| 712 | { | |
| 713 | 0 | if(stat(filename, &statbuf)) |
| 714 | { | |
| 715 | 0 | char * errstr; |
| 716 | 0 | result = GlobusWSDLErrorAccessingTemplateFile(errno, filename); |
| 717 | 0 | errstr = globus_error_print_chain(globus_error_get(result)); |
| 718 | ||
| 719 | 0 | JS_ReportError(cx, errstr); |
| 720 | 0 | res = JS_FALSE; |
| 721 | 0 | goto exit; |
| 722 | } | |
| 723 | ||
| 724 | 0 | res = globus_wsdl_template_get_jsbuf( |
| 725 | (const char *) filename, &script_buffer, &script_length, &error, | |
| 726 | '@', '$'); | |
| 727 | 0 | if(res != 0) |
| 728 | { | |
| 729 | 0 | if(error) |
| 730 | { | |
| 731 | 0 | JS_ReportError(cx, "%s", error); |
| 732 | 0 | free(error); |
| 733 | } | |
| 734 | 0 | res = JS_FALSE; |
| 735 | 0 | goto exit; |
| 736 | } | |
| 737 | ||
| 738 | 0 | GlobusWSDLDebugPrintf(GLOBUS_WSDL_DEBUG_TEMPLATE, |
| 739 | ("TEMPLATE BUFFER:" | |
| 740 | "\n----------------------\n")); | |
| 741 | 0 | GlobusWSDLDebugWrite(GLOBUS_WSDL_DEBUG_TEMPLATE, |
| 742 | script_length, script_buffer); | |
| 743 | 0 | GlobusWSDLDebugPrintf(GLOBUS_WSDL_DEBUG_TEMPLATE, |
| 744 | ("\n----------------------\n")); | |
| 745 | ||
| 746 | 0 | template = globus_malloc(sizeof(Template)); |
| 747 | 0 | if(!template) |
| 748 | { | |
| 749 | 0 | JS_ReportError(cx, |
| 750 | "Memory allocation failed."); | |
| 751 | 0 | res = JS_FALSE; |
| 752 | 0 | goto exit; |
| 753 | } | |
| 754 | 0 | template->filename = globus_libc_strdup(filename); |
| 755 | 0 | template->buffer = script_buffer; |
| 756 | 0 | template->length = script_length; |
| 757 | ||
| 758 | 0 | if(!private->templates) |
| 759 | { | |
| 760 | 0 | globus_hashtable_init(&private->templates, 10, |
| 761 | globus_hashtable_string_hash, | |
| 762 | globus_hashtable_string_keyeq); | |
| 763 | } | |
| 764 | ||
| 765 | 0 | globus_hashtable_insert(&private->templates, template->filename, template); |
| 766 | } | |
| 767 | else | |
| 768 | { | |
| 769 | 0 | script_buffer = template->buffer; |
| 770 | 0 | script_length = template->length; |
| 771 | } | |
| 772 | ||
| 773 | 0 | if(argc > 1 && (argv[1] != JSVAL_NULL)) |
| 774 | { | |
| 775 | 0 | str = JS_ValueToString(cx, argv[1]); |
| 776 | 0 | if(!str) |
| 777 | { | |
| 778 | 0 | JS_ReportError(cx, |
| 779 | "Failed to load template %s. " | |
| 780 | "Second argument to load function should " | |
| 781 | "be output filename but is not of type string.", | |
| 782 | filename); | |
| 783 | 0 | res = JS_FALSE; |
| 784 | 0 | goto exit; |
| 785 | } | |
| 786 | ||
| 787 | 0 | sprintf(out_filename, "%s%s%*s", |
| 788 | (private->outdir ? private->outdir : ""), | |
| 789 | (private->outdir ? FILE_SEPARATOR : ""), | |
| 790 | (int) JS_GetStringLength(str), | |
| 791 | JS_GetStringBytes(str)); | |
| 792 | ||
| 793 | 0 | out_stream = fopen(out_filename, "w+"); |
| 794 | 0 | if(!out_stream) |
| 795 | { | |
| 796 | 0 | JS_ReportError(cx, "Failed to open output file %s for writing", |
| 797 | out_filename); | |
| 798 | 0 | res = JS_FALSE; |
| 799 | 0 | goto exit; |
| 800 | } | |
| 801 | } | |
| 802 | ||
| 803 | 0 | globus_assert(private && private->streams); |
| 804 | ||
| 805 | 0 | new_streams = (StreamContext *) malloc(sizeof(StreamContext)); |
| 806 | 0 | if(!new_streams) |
| 807 | { | |
| 808 | 0 | JS_ReportOutOfMemory(cx); |
| 809 | 0 | res = JS_FALSE; |
| 810 | 0 | goto exit; |
| 811 | } | |
| 812 | ||
| 813 | 0 | memset(new_streams, 0, sizeof(StreamContext)); |
| 814 | ||
| 815 | 0 | new_streams->next = private->streams; |
| 816 | 0 | new_streams->error_stream = private->streams->error_stream; |
| 817 | 0 | new_streams->out_stream = out_stream; |
| 818 | 0 | private->streams = new_streams; |
| 819 | ||
| 820 | 0 | JS_SetContextPrivate(cx, (void *) private); |
| 821 | ||
| 822 | 0 | res = JS_EvaluateScript(cx, obj, script_buffer, |
| 823 | script_length, filename, 0, &result); | |
| 824 | 0 | if(!res) |
| 825 | { | |
| 826 | 0 | JS_ReportError(cx, "Failed to evaluate script: %s", filename); |
| 827 | } | |
| 828 | ||
| 829 | 0 | private = JS_GetContextPrivate(cx); |
| 830 | 0 | globus_assert(private); |
| 831 | ||
| 832 | 0 | if(private->streams->out_stream) |
| 833 | { | |
| 834 | 0 | fclose(private->streams->out_stream); |
| 835 | } | |
| 836 | ||
| 837 | 0 | tmp_streams = private->streams; |
| 838 | 0 | if(tmp_streams) |
| 839 | { | |
| 840 | 0 | private->streams = private->streams->next; |
| 841 | 0 | free(tmp_streams); |
| 842 | } | |
| 843 | ||
| 844 | 0 | JS_SetContextPrivate(cx, (void *) private); |
| 845 | ||
| 846 | exit: | |
| 847 | 0 | GlobusWSDLDebugExit(); |
| 848 | 0 | return res; |
| 849 | } | |
| 850 | ||
| 851 | static JSBool | |
| 852 | FileExists( | |
| 853 | JSContext * cx, | |
| 854 | JSObject * obj, | |
| 855 | uintN argc, | |
| 856 | jsval * argv, | |
| 857 | jsval * rval) | |
| 858 | 0 | { |
| 859 | 0 | JSBool res = JS_TRUE; |
| 860 | 0 | JSString * str; |
| 861 | 0 | char filename[500]; |
| 862 | 0 | PrivateContext * private = NULL; |
| 863 | 0 | struct stat statbuf; |
| 864 | 0 | GlobusFuncName(FileExists); |
| 865 | 0 | GlobusWSDLDebugEnter(); |
| 866 | ||
| 867 | 0 | if(argc < 1) |
| 868 | { | |
| 869 | 0 | JS_ReportError(cx, |
| 870 | "Wrong number of arguments " | |
| 871 | "passed to function: %s", | |
| 872 | argc, 2, "file_exists(filename)"); | |
| 873 | 0 | res = JS_FALSE; |
| 874 | 0 | goto exit; |
| 875 | } | |
| 876 | ||
| 877 | 0 | str = JS_ValueToString(cx, argv[0]); |
| 878 | 0 | if(!str) |
| 879 | { | |
| 880 | 0 | JS_ReportError(cx, |
| 881 | "Failed to load filename"); | |
| 882 | 0 | res = JS_FALSE; |
| 883 | 0 | goto exit; |
| 884 | } | |
| 885 | ||
| 886 | 0 | private = (PrivateContext *) JS_GetContextPrivate(cx); |
| 887 | ||
| 888 | 0 | sprintf(filename, "%s%s%*s", |
| 889 | (private->outdir ? private->outdir : ""), | |
| 890 | (private->outdir ? FILE_SEPARATOR : ""), | |
| 891 | (int) JS_GetStringLength(str), | |
| 892 | JS_GetStringBytes(str)); | |
| 893 | ||
| 894 | 0 | if(!stat(filename, &statbuf)) |
| 895 | { | |
| 896 | 0 | *rval = BOOLEAN_TO_JSVAL(JS_TRUE); |
| 897 | } | |
| 898 | else | |
| 899 | { | |
| 900 | 0 | *rval = BOOLEAN_TO_JSVAL(JS_FALSE); |
| 901 | } | |
| 902 | ||
| 903 | ||
| 904 | exit: | |
| 905 | 0 | GlobusWSDLDebugExit(); |
| 906 | 0 | return res; |
| 907 | } | |
| 908 | ||
| 909 | static JSBool | |
| 910 | CanonicalizeString( | |
| 911 | JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) | |
| 912 | 0 | { |
| 913 | 0 | uintN i, n; |
| 914 | 0 | JSString *str; |
| 915 | 0 | char *s, *news; |
| 916 | ||
| 917 | 0 | if(argc < 1) |
| 918 | { | |
| 919 | 0 | JS_ReportError(cx, "function canonical called with no parameters"); |
| 920 | 0 | return JS_FALSE; |
| 921 | } | |
| 922 | ||
| 923 | 0 | if(JSVAL_IS_NULL(argv[0]) || JSVAL_IS_VOID(argv[0])) |
| 924 | { | |
| 925 | 0 | str = JS_InternString(cx, "NULL"); |
| 926 | 0 | *rval = STRING_TO_JSVAL(str); |
| 927 | 0 | return JS_TRUE; |
| 928 | } | |
| 929 | ||
| 930 | 0 | if(!JSVAL_IS_STRING(argv[0])) |
| 931 | { | |
| 932 | 0 | JS_ReportError(cx, "parameter passed to canonical is not a string"); |
| 933 | 0 | return JS_FALSE; |
| 934 | } | |
| 935 | ||
| 936 | 0 | str = JSVAL_TO_STRING(argv[0]); |
| 937 | 0 | n = JSSTRING_LENGTH(str); |
| 938 | 0 | news = (char *) JS_malloc(cx, (n + 1) * sizeof(char)); |
| 939 | 0 | if(!news) |
| 940 | { | |
| 941 | 0 | JS_ReportOutOfMemory(cx); |
| 942 | 0 | return JS_FALSE; |
| 943 | } | |
| 944 | ||
| 945 | 0 | s = JS_GetStringBytes(str); |
| 946 | 0 | for(i = 0; i < n; ++i) |
| 947 | { | |
| 948 | 0 | switch(s[i]) |
| 949 | { | |
| 950 | case '-': | |
| 951 | 0 | news[i] = '_'; |
| 952 | 0 | break; |
| 953 | case ' ': | |
| 954 | 0 | news[i] = '_'; |
| 955 | 0 | break; |
| 956 | default: | |
| 957 | 0 | news[i] = s[i]; |
| 958 | 0 | break; |
| 959 | } | |
| 960 | } | |
| 961 | ||
| 962 | 0 | news[n] = 0; |
| 963 | 0 | str = JS_InternString(cx, news); |
| 964 | 0 | JS_free(cx, news); |
| 965 | 0 | if(!str) |
| 966 | { | |
| 967 | 0 | JS_ReportError(cx, "Failed to internalize string in canonical function"); |
| 968 | 0 | return JS_FALSE; |
| 969 | } | |
| 970 | ||
| 971 | 0 | *rval = STRING_TO_JSVAL(str); |
| 972 | 0 | return JS_TRUE; |
| 973 | } | |
| 974 | ||
| 975 | static JSBool | |
| 976 | NamespaceToPrefix(JSContext *cx, JSObject *obj, | |
| 977 | uintN argc, jsval *argv, jsval *rval) | |
| 978 | 0 | { |
| 979 | 0 | globus_hashtable_t nsmap; |
| 980 | 0 | PrivateContext * ctx; |
| 981 | 0 | JSString * str; |
| 982 | 0 | char * prefix; |
| 983 | ||
| 984 | 0 | ctx = (PrivateContext *) JS_GetContextPrivate(cx); |
| 985 | ||
| 986 | 0 | nsmap = (globus_hashtable_t) ctx->nsmap; |
| 987 | 0 | if(!nsmap) |
| 988 | { | |
| 989 | 0 | str = JS_InternString(cx, ""); |
| 990 | 0 | if(!str) |
| 991 | { | |
| 992 | 0 | JS_ReportError(cx, |
| 993 | "Failed to access namespace mapping table in NStoP"); | |
| 994 | 0 | return JS_FALSE; |
| 995 | } | |
| 996 | ||
| 997 | 0 | *rval = STRING_TO_JSVAL(str); |
| 998 | 0 | return JS_TRUE; |
| 999 | } | |
| 1000 | ||
| 1001 | 0 | str = JS_ValueToString(cx, argv[0]); |
| 1002 | 0 | if (!str) |
| 1003 | { | |
| 1004 | 0 | JS_ReportError(cx, "Parameter passed to NStoP is not a string"); |
| 1005 | 0 | return JS_FALSE; |
| 1006 | } | |
| 1007 | ||
| 1008 | 0 | prefix = globus_wsdl_config_get_property(nsmap, |
| 1009 | (const char *)JS_GetStringBytes(str)); | |
| 1010 | 0 | if(!prefix) |
| 1011 | { | |
| 1012 | 0 | str = JS_InternString(cx, ""); |
| 1013 | 0 | if(!str) |
| 1014 | { | |
| 1015 | 0 | JS_ReportError(cx, "NStoP failed: could not internalize string"); |
| 1016 | 0 | return JS_FALSE; |
| 1017 | } | |
| 1018 | ||
| 1019 | 0 | *rval = STRING_TO_JSVAL(str); |
| 1020 | 0 | return JS_TRUE; |
| 1021 | } | |
| 1022 | ||
| 1023 | 0 | str = JS_InternString(cx, prefix); |
| 1024 | 0 | *rval = STRING_TO_JSVAL(str); |
| 1025 | 0 | return JS_TRUE; |
| 1026 | } | |
| 1027 | ||
| 1028 | ||
| 1029 | static JSBool | |
| 1030 | Debug(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) | |
| 1031 | 0 | { |
| 1032 | 0 | uintN i, n; |
| 1033 | 0 | JSString *str; |
| 1034 | ||
| 1035 | 0 | for (i = n = 0; i < argc; i++) { |
| 1036 | 0 | str = JS_ValueToString(cx, argv[i]); |
| 1037 | 0 | if (!str) |
| 1038 | { | |
| 1039 | 0 | JS_ReportError( |
| 1040 | cx, | |
| 1041 | "Argument %d to debug function is not a string", i); | |
| 1042 | 0 | return JS_FALSE; |
| 1043 | } | |
| 1044 | ||
| 1045 | 0 | fprintf(stdout, "%s%s", i ? " " : "", JS_GetStringBytes(str)); |
| 1046 | } | |
| 1047 | ||
| 1048 | 0 | n++; |
| 1049 | 0 | return JS_TRUE; |
| 1050 | } | |
| 1051 | ||
| 1052 | static JSBool | |
| 1053 | Error(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) | |
| 1054 | 0 | { |
| 1055 | 0 | uintN i, n; |
| 1056 | 0 | JSString *str; |
| 1057 | 0 | char error_string[5000]; |
| 1058 | 0 | int len = 0; |
| 1059 | 0 | PrivateContext * ctx_handle; |
| 1060 | ||
| 1061 | 0 | ctx_handle = (PrivateContext *) JS_GetContextPrivate(cx); |
| 1062 | ||
| 1063 | 0 | for (i = n = 0; i < argc; i++) { |
| 1064 | 0 | str = JS_ValueToString(cx, argv[i]); |
| 1065 | 0 | if (!str) |
| 1066 | { | |
| 1067 | 0 | JS_ReportError( |
| 1068 | cx, | |
| 1069 | "Argument %d to debug function is not a string", i); | |
| 1070 | 0 | return JS_FALSE; |
| 1071 | } | |
| 1072 | ||
| 1073 | 0 | len += sprintf(error_string + len, |
| 1074 | "%s%s", i ? " " : "", JS_GetStringBytes(str)); | |
| 1075 | } | |
| 1076 | ||
| 1077 | 0 | JS_ReportError( |
| 1078 | cx, "ERROR: %s", error_string); | |
| 1079 | 0 | return JS_FALSE; |
| 1080 | } | |
| 1081 | ||
| 1082 | static JSBool | |
| 1083 | Abort(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) | |
| 1084 | 0 | { |
| 1085 | 0 | abort(); |
| 1086 | } | |
| 1087 | ||
| 1088 | static JSBool | |
| 1089 | Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) | |
| 1090 | 0 | { |
| 1091 | 0 | uintN i, n; |
| 1092 | 0 | JSString *str; |
| 1093 | 0 | PrivateContext * ctx_handle; |
| 1094 | 0 | FILE * ostream; |
| 1095 | ||
| 1096 | 0 | ctx_handle = (PrivateContext *) JS_GetContextPrivate(cx); |
| 1097 | 0 | if(!ctx_handle || !ctx_handle->streams || !ctx_handle->streams->out_stream) |
| 1098 | { | |
| 1099 | 0 | ostream = stdout; |
| 1100 | } | |
| 1101 | else | |
| 1102 | { | |
| 1103 | 0 | ostream = ctx_handle->streams->out_stream; |
| 1104 | } | |
| 1105 | ||
| 1106 | 0 | for (i = n = 0; i < argc; i++) { |
| 1107 | 0 | str = JS_ValueToString(cx, argv[i]); |
| 1108 | 0 | if (!str) |
| 1109 | { | |
| 1110 | 0 | JS_ReportError(cx, "Argument %d to print function is not a string", i); |
| 1111 | 0 | return JS_FALSE; |
| 1112 | } | |
| 1113 | ||
| 1114 | 0 | fprintf(ostream, "%s%s", i ? " " : "", JS_GetStringBytes(str)); |
| 1115 | } | |
| 1116 | ||
| 1117 | 0 | n++; |
| 1118 | 0 | return JS_TRUE; |
| 1119 | } | |
| 1120 | ||
| 1121 | ||
| 1122 | static void | |
| 1123 | internal_ErrorReporter( | |
| 1124 | JSContext * cx, | |
| 1125 | const char * message, | |
| 1126 | JSErrorReport * report) | |
| 1127 | 0 | { |
| 1128 | 0 | char *prefix, *tmp, *linebuf; |
| 1129 | 0 | PrivateContext * ctx_handle; |
| 1130 | 0 | GlobusFuncName(internal_ErrorReporting); |
| 1131 | 0 | GlobusWSDLDebugEnter(); |
| 1132 | ||
| 1133 | 0 | ctx_handle = (PrivateContext *) JS_GetContextPrivate(cx); |
| 1134 | 0 | if(!ctx_handle) |
| 1135 | { | |
| 1136 | 0 | goto exit; |
| 1137 | } | |
| 1138 | ||
| 1139 | 0 | if (!report) { |
| 1140 | 0 | ctx_handle->result = globus_error_put( |
| 1141 | globus_error_construct_error( | |
| 1142 | GLOBUS_WSDL_PARSER_MODULE, | |
| 1143 | (ctx_handle->result != GLOBUS_NULL) | |
| 1144 | ? globus_error_get(ctx_handle->result) | |
| 1145 | : NULL, | |
| 1146 | GLOBUS_WSDL_ERROR_JAVASCRIPT, | |
| 1147 | __FILE__, | |
| 1148 | _globus_func_name, | |
| 1149 | __LINE__, | |
| 1150 | "%s\n", | |
| 1151 | message)); | |
| 1152 | 0 | goto exit; |
| 1153 | } | |
| 1154 | ||
| 1155 | /* Conditionally ignore reported warnings. */ | |
| 1156 | 0 | if (JSREPORT_IS_WARNING(report->flags) && |
| 1157 | !GlobusWSDLDebug(GLOBUS_WSDL_DEBUG_WARN)) | |
| 1158 | { | |
| 1159 | 0 | goto exit; |
| 1160 | } | |
| 1161 | ||
| 1162 | 0 | prefix = NULL; |
| 1163 | 0 | if (report->filename) |
| 1164 | { | |
| 1165 | 0 | prefix = JS_smprintf("%s:", report->filename); |
| 1166 | } | |
| 1167 | ||
| 1168 | 0 | if (JSREPORT_IS_WARNING(report->flags)) { |
| 1169 | 0 | tmp = prefix; |
| 1170 | 0 | prefix = JS_smprintf("%s%swarning: ", |
| 1171 | tmp ? tmp : "", | |
| 1172 | JSREPORT_IS_STRICT(report->flags) ? "strict " : ""); | |
| 1173 | 0 | JS_free(cx, tmp); |
| 1174 | } | |
| 1175 | ||
| 1176 | 0 | linebuf = NULL; |
| 1177 | 0 | if(report->linebuf) |
| 1178 | { | |
| 1179 | 0 | linebuf = JS_smprintf("%s", report->linebuf); |
| 1180 | } | |
| 1181 | ||
| 1182 | 0 | ctx_handle->result = globus_error_put( |
| 1183 | globus_error_construct_error( | |
| 1184 | GLOBUS_WSDL_PARSER_MODULE, | |
| 1185 | (ctx_handle->result != GLOBUS_NULL) | |
| 1186 | ? globus_error_get(ctx_handle->result) | |
| 1187 | : NULL, | |
| 1188 | GLOBUS_WSDL_ERROR_JAVASCRIPT, | |
| 1189 | __FILE__, | |
| 1190 | _globus_func_name, | |
| 1191 | __LINE__, | |
| 1192 | (linebuf ? "%s%s at line:\n\t%s" : "%s%s%s"), | |
| 1193 | (prefix ? prefix : ""), | |
| 1194 | (message ? message : ""), | |
| 1195 | (linebuf ? linebuf : ""))); | |
| 1196 | ||
| 1197 | 0 | if(prefix) |
| 1198 | { | |
| 1199 | 0 | JS_free(cx, prefix); |
| 1200 | } | |
| 1201 | ||
| 1202 | 0 | if(linebuf) |
| 1203 | { | |
| 1204 | 0 | JS_free(cx, linebuf); |
| 1205 | } | |
| 1206 | ||
| 1207 | 0 | if(JSREPORT_IS_WARNING(report->flags)) |
| 1208 | { | |
| 1209 | 0 | globus_object_t * warn_obj; |
| 1210 | 0 | warn_obj = globus_error_get(ctx_handle->result); |
| 1211 | ||
| 1212 | 0 | if(GlobusWSDLDebug(GLOBUS_WSDL_DEBUG_WARN)) |
| 1213 | { | |
| 1214 | 0 | char * warn_str; |
| 1215 | ||
| 1216 | 0 | warn_str = globus_error_print_chain(warn_obj); |
| 1217 | ||
| 1218 | 0 | GlobusWSDLDebugPrintf(GLOBUS_WSDL_DEBUG_WARN, |
| 1219 | ("%s", warn_str)); | |
| 1220 | ||
| 1221 | 0 | if(warn_str) |
| 1222 | { | |
| 1223 | 0 | globus_free(warn_str); |
| 1224 | } | |
| 1225 | } | |
| 1226 | ||
| 1227 | 0 | if(warn_obj) |
| 1228 | { | |
| 1229 | 0 | globus_object_free(warn_obj); |
| 1230 | } | |
| 1231 | ||
| 1232 | 0 | ctx_handle->result = GLOBUS_SUCCESS; |
| 1233 | } | |
| 1234 | ||
| 1235 | exit: | |
| 1236 | ||
| 1237 | 0 | GlobusWSDLDebugExit(); |
| 1238 | } | |
| 1239 | ||
| 1240 | static | |
| 1241 | JSString * | |
| 1242 | globus_l_wsdl_jscript_qname_string( | |
| 1243 | JSContext * ctx, | |
| 1244 | const xmlChar * href, | |
| 1245 | const xmlChar * local) | |
| 1246 | 0 | { |
| 1247 | 0 | JSString * str; |
| 1248 | 0 | char * qname; |
| 1249 | 0 | size_t href_length = 0; |
| 1250 | 0 | size_t local_length = 0; |
| 1251 | ||
| 1252 | 0 | href_length = href ? strlen((const char *) href) : 0; |
| 1253 | 0 | local_length = local ? strlen((const char *) local) : 0; |
| 1254 | ||
| 1255 | 0 | qname = malloc(href_length + local_length + 2); |
| 1256 | 0 | if(href) |
| 1257 | { | |
| 1258 | 0 | memcpy(qname, href, href_length); |
| 1259 | 0 | qname[href_length] = '#'; |
| 1260 | 0 | href_length++; |
| 1261 | } | |
| 1262 | ||
| 1263 | 0 | memcpy(qname + href_length, local, local_length); |
| 1264 | 0 | qname[href_length + local_length] = 0; |
| 1265 | ||
| 1266 | 0 | str = JS_InternString(ctx, qname); |
| 1267 | ||
| 1268 | 0 | return str; |
| 1269 | } | |
| 1270 | ||
| 1271 | globus_result_t | |
| 1272 | globus_wsdl_execute( | |
| 1273 | globus_list_t * schema_files, | |
| 1274 | const char * tmpl_filename, | |
| 1275 | const char * out_filename, | |
| 1276 | const char * out_dir, | |
| 1277 | globus_hashtable_t nsmap, | |
| 1278 | globus_hashtable_t vars, | |
| 1279 | globus_list_t * template_paths, | |
| 1280 | globus_hashtable_t ignorable_namespaces, | |
| 1281 | globus_hashtable_t include_namespaces, | |
| 1282 | const int rt_size) | |
| 1283 | 0 | { |
| 1284 | 0 | JSRuntime * rt = NULL; |
| 1285 | 0 | JSContext * ctx = NULL; |
| 1286 | 0 | JSObject * glob = NULL; |
| 1287 | 0 | JSObject * ignore = NULL; |
| 1288 | 0 | char * ignore_entry = NULL; |
| 1289 | 0 | JSObject * include = NULL; |
| 1290 | 0 | char * include_entry = NULL; |
| 1291 | 0 | char ** var_entry; |
| 1292 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 1293 | 0 | char * sfile = NULL; |
| 1294 | 0 | globus_list_t * sfiles = NULL; |
| 1295 | 0 | globus_list_t * schemas = NULL; |
| 1296 | 0 | wsdlSchemaPtr schema = NULL; |
| 1297 | 0 | GlobusFuncName(globus_wsdl_execute); |
| 1298 | 0 | GlobusWSDLDebugEnter(); |
| 1299 | ||
| 1300 | 0 | rt = JS_NewRuntime((rt_size <= 0) ? (64L * 1024L * 1024L) : rt_size); |
| 1301 | 0 | if(!rt) |
| 1302 | { | |
| 1303 | 0 | result = GlobusWSDLErrorJSRuntime(GLOBUS_NULL); |
| 1304 | 0 | goto exit; |
| 1305 | } | |
| 1306 | ||
| 1307 | 0 | ctx = JS_NewContext(rt, gStackChunkSize); |
| 1308 | 0 | if(!ctx) |
| 1309 | { | |
| 1310 | 0 | result = GlobusWSDLErrorJSContext(GLOBUS_NULL); |
| 1311 | 0 | goto exit; |
| 1312 | } | |
| 1313 | ||
| 1314 | 0 | JS_SetErrorReporter(ctx, internal_ErrorReporter); |
| 1315 | ||
| 1316 | 0 | glob = JS_NewObject(ctx, &global_class, NULL, NULL); |
| 1317 | 0 | if(!glob) |
| 1318 | { | |
| 1319 | 0 | result = GlobusWSDLErrorJSContext(GLOBUS_NULL); |
| 1320 | 0 | goto exit; |
| 1321 | } | |
| 1322 | ||
| 1323 | 0 | if(!JS_InitStandardClasses(ctx, glob)) |
| 1324 | { | |
| 1325 | 0 | result = GlobusWSDLErrorJSContext(GLOBUS_NULL); |
| 1326 | 0 | goto exit; |
| 1327 | } | |
| 1328 | ||
| 1329 | 0 | globus_i_wsdl_parser_classes_init(ctx, glob); |
| 1330 | ||
| 1331 | 0 | if(!JS_DefineFunctions(ctx, glob, functions_defs)) |
| 1332 | { | |
| 1333 | 0 | result = GlobusWSDLErrorJSContext(GLOBUS_NULL); |
| 1334 | 0 | goto exit; |
| 1335 | } | |
| 1336 | ||
| 1337 | 0 | sfiles = schema_files; |
| 1338 | 0 | while(sfiles) |
| 1339 | { | |
| 1340 | 0 | sfile = globus_list_first(sfiles); |
| 1341 | ||
| 1342 | 0 | result = globus_i_wsdl_parse_schema(sfile, &schema); |
| 1343 | 0 | if(result != GLOBUS_SUCCESS) |
| 1344 | { | |
| 1345 | 0 | result = GlobusWSDLErrorParsingSchema(result, sfile); |
| 1346 | 0 | goto exit; |
| 1347 | } | |
| 1348 | ||
| 1349 | 0 | result = globus_list_insert(&schemas, schema); |
| 1350 | 0 | if(result != GLOBUS_SUCCESS) |
| 1351 | { | |
| 1352 | 0 | result = GlobusWSDLErrorParsingSchema(result, sfile); |
| 1353 | 0 | goto exit; |
| 1354 | } | |
| 1355 | ||
| 1356 | 0 | result = globus_i_wsdl_js_load_schema(ctx, schema); |
| 1357 | 0 | if(result != GLOBUS_SUCCESS) |
| 1358 | { | |
| 1359 | 0 | result = GlobusWSDLErrorLoadingSchema(result); |
| 1360 | 0 | goto exit; |
| 1361 | } | |
| 1362 | ||
| 1363 | 0 | sfiles = globus_list_rest(sfiles); |
| 1364 | } | |
| 1365 | ||
| 1366 | 0 | var_entry = globus_hashtable_first(&vars); |
| 1367 | 0 | while(var_entry) |
| 1368 | { | |
| 1369 | 0 | if(!JS_DefineProperty( |
| 1370 | ctx, glob, var_entry[0], | |
| 1371 | STRING_TO_JSVAL(JS_InternString(ctx, var_entry[1])), | |
| 1372 | NULL, NULL, | |
| 1373 | JSPROP_PERMANENT)) | |
| 1374 | { | |
| 1375 | 0 | result = GlobusWSDLErrorLoadingSchema(GLOBUS_NULL); |
| 1376 | 0 | goto exit; |
| 1377 | } | |
| 1378 | ||
| 1379 | 0 | var_entry = globus_hashtable_next(&vars); |
| 1380 | } | |
| 1381 | ||
| 1382 | 0 | ignore = JS_NewObject(ctx, &basic_class, NULL, glob); |
| 1383 | 0 | if(!ignore) |
| 1384 | { | |
| 1385 | 0 | result = GlobusWSDLErrorJSContext(GLOBUS_NULL); |
| 1386 | 0 | goto exit; |
| 1387 | } | |
| 1388 | ||
| 1389 | 0 | if(!JS_DefineProperty( |
| 1390 | ctx, glob, "ignore_namespaces", | |
| 1391 | OBJECT_TO_JSVAL(ignore), NULL, | |
| 1392 | NULL, JSPROP_READONLY|JSPROP_PERMANENT|JSPROP_ENUMERATE)) | |
| 1393 | { | |
| 1394 | 0 | result = GlobusWSDLErrorLoadingSchema(GLOBUS_NULL); |
| 1395 | 0 | goto exit; |
| 1396 | } | |
| 1397 | ||
| 1398 | 0 | ignore_entry = globus_hashtable_first(&ignorable_namespaces); |
| 1399 | 0 | while(ignore_entry) |
| 1400 | { | |
| 1401 | 0 | if(!JS_DefineProperty( |
| 1402 | ctx, ignore, ignore_entry, | |
| 1403 | STRING_TO_JSVAL(JS_InternString(ctx, ignore_entry)), | |
| 1404 | NULL, NULL, JSPROP_PERMANENT|JSPROP_READONLY|JSPROP_ENUMERATE)) | |
| 1405 | { | |
| 1406 | 0 | result = GlobusWSDLErrorLoadingSchema(GLOBUS_NULL); |
| 1407 | 0 | goto exit; |
| 1408 | } | |
| 1409 | ||
| 1410 | 0 | ignore_entry = globus_hashtable_next(&ignorable_namespaces); |
| 1411 | } | |
| 1412 | ||
| 1413 | ||
| 1414 | 0 | if(!include_namespaces) |
| 1415 | { | |
| 1416 | 0 | if(!JS_DefineProperty( |
| 1417 | ctx, glob, "include_namespaces", | |
| 1418 | JSVAL_NULL, NULL, | |
| 1419 | NULL, JSPROP_READONLY|JSPROP_PERMANENT|JSPROP_ENUMERATE)) | |
| 1420 | { | |
| 1421 | 0 | result = GlobusWSDLErrorLoadingSchema(GLOBUS_NULL); |
| 1422 | 0 | goto exit; |
| 1423 | } | |
| 1424 | } | |
| 1425 | else | |
| 1426 | { | |
| 1427 | ||
| 1428 | 0 | include = JS_NewObject(ctx, &basic_class, NULL, glob); |
| 1429 | 0 | if(!include) |
| 1430 | { | |
| 1431 | 0 | result = GlobusWSDLErrorJSContext(GLOBUS_NULL); |
| 1432 | 0 | goto exit; |
| 1433 | } | |
| 1434 | ||
| 1435 | 0 | if(!JS_DefineProperty( |
| 1436 | ctx, glob, "include_namespaces", | |
| 1437 | OBJECT_TO_JSVAL(include), NULL, | |
| 1438 | NULL, JSPROP_READONLY|JSPROP_PERMANENT|JSPROP_ENUMERATE)) | |
| 1439 | { | |
| 1440 | 0 | result = GlobusWSDLErrorLoadingSchema(GLOBUS_NULL); |
| 1441 | 0 | goto exit; |
| 1442 | } | |
| 1443 | ||
| 1444 | 0 | include_entry = globus_hashtable_first(&include_namespaces); |
| 1445 | 0 | while(include_entry) |
| 1446 | { | |
| 1447 | 0 | if(!JS_DefineProperty( |
| 1448 | ctx, include, include_entry, | |
| 1449 | STRING_TO_JSVAL(JS_InternString(ctx, include_entry)), | |
| 1450 | NULL, NULL, | |
| 1451 | JSPROP_PERMANENT|JSPROP_READONLY|JSPROP_ENUMERATE)) | |
| 1452 | { | |
| 1453 | 0 | result = GlobusWSDLErrorLoadingSchema(GLOBUS_NULL); |
| 1454 | 0 | goto exit; |
| 1455 | } | |
| 1456 | ||
| 1457 | 0 | include_entry = globus_hashtable_next(&include_namespaces); |
| 1458 | } | |
| 1459 | } | |
| 1460 | ||
| 1461 | 0 | result = globus_i_wsdl_execute_script(ctx, glob, |
| 1462 | tmpl_filename, | |
| 1463 | out_filename, | |
| 1464 | out_dir, | |
| 1465 | nsmap, | |
| 1466 | template_paths); | |
| 1467 | 0 | if(result != GLOBUS_SUCCESS) |
| 1468 | { | |
| 1469 | 0 | result = GlobusWSDLErrorExecutingScript(result, tmpl_filename); |
| 1470 | goto exit; | |
| 1471 | } | |
| 1472 | ||
| 1473 | exit: | |
| 1474 | ||
| 1475 | 0 | if(result != GLOBUS_SUCCESS) |
| 1476 | { | |
| 1477 | 0 | if(GlobusWSDLDebug(GLOBUS_WSDL_DEBUG_WARN)) |
| 1478 | { | |
| 1479 | 0 | globus_object_t * error_obj; |
| 1480 | 0 | char * error_str; |
| 1481 | ||
| 1482 | 0 | error_obj = globus_error_get(result); |
| 1483 | 0 | if(error_obj) |
| 1484 | { | |
| 1485 | 0 | error_str = globus_error_print_chain( |
| 1486 | error_obj); | |
| 1487 | ||
| 1488 | 0 | GlobusWSDLDebugPrintf(GLOBUS_WSDL_DEBUG_WARN, |
| 1489 | ("[DEBUG::WSDL] %s:%d: %s", | |
| 1490 | _globus_func_name, | |
| 1491 | __LINE__, | |
| 1492 | error_str)); | |
| 1493 | 0 | globus_free(error_str); |
| 1494 | ||
| 1495 | 0 | result = globus_error_put(error_obj); |
| 1496 | } | |
| 1497 | } | |
| 1498 | } | |
| 1499 | ||
| 1500 | 0 | if(schemas) |
| 1501 | { | |
| 1502 | 0 | globus_list_destroy_all(schemas, (void(*)(void *))wsdlSchemaFree); |
| 1503 | } | |
| 1504 | ||
| 1505 | 0 | if(ctx) |
| 1506 | { | |
| 1507 | 0 | JS_DestroyContext(ctx); |
| 1508 | } | |
| 1509 | ||
| 1510 | 0 | if(rt) |
| 1511 | { | |
| 1512 | 0 | JS_DestroyRuntime(rt); |
| 1513 | } | |
| 1514 | ||
| 1515 | 0 | GlobusWSDLDebugExit(); |
| 1516 | 0 | return result; |
| 1517 | } | |
| 1518 | ||
| 1519 | static | |
| 1520 | globus_result_t | |
| 1521 | globus_i_wsdl_js_load_schema( | |
| 1522 | JSContext * cx, | |
| 1523 | wsdlSchemaPtr schema) | |
| 1524 | 0 | { |
| 1525 | 0 | JSObject * glob = NULL; |
| 1526 | 0 | JSObject * wsdl = NULL; |
| 1527 | 0 | JSObject * types = NULL; |
| 1528 | 0 | JSObject * elements = NULL; |
| 1529 | 0 | JSObject * local_elements = NULL; |
| 1530 | 0 | JSObject * attributes = NULL; |
| 1531 | 0 | JSObject * local_attributes = NULL; |
| 1532 | 0 | JSObject * messages = NULL; |
| 1533 | 0 | JSObject * portTypes = NULL; |
| 1534 | 0 | JSObject * bindings = NULL; |
| 1535 | 0 | JSObject * services = NULL; |
| 1536 | 0 | JSObject * typeEnum = NULL; |
| 1537 | 0 | JSObject * attrEnum = NULL; |
| 1538 | 0 | JSObject * contentTypeEnum = NULL; |
| 1539 | 0 | JSObject * operationTypeEnum = NULL; |
| 1540 | 0 | JSObject * bindingType = NULL; |
| 1541 | 0 | JSObject * soapOperationStyleType = NULL; |
| 1542 | 0 | JSObject * soapUseType = NULL; |
| 1543 | 0 | ScannerData * data = NULL; |
| 1544 | 0 | jsval val; |
| 1545 | 0 | JSString * str; |
| 1546 | 0 | JSBool res = JS_TRUE; |
| 1547 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 1548 | 0 | GlobusFuncName(globus_i_wsdl_js_load_schema); |
| 1549 | 0 | GlobusWSDLDebugEnter(); |
| 1550 | ||
| 1551 | 0 | glob = JS_GetGlobalObject(cx); |
| 1552 | 0 | if(!glob) |
| 1553 | { | |
| 1554 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1555 | 0 | goto exit; |
| 1556 | } | |
| 1557 | ||
| 1558 | 0 | res = JS_GetProperty(cx, glob, "wsdl", &val); |
| 1559 | 0 | if(val == JSVAL_VOID) |
| 1560 | { | |
| 1561 | 0 | wsdl = JS_NewObject(cx, &basic_class, NULL, glob); |
| 1562 | 0 | if(!wsdl) |
| 1563 | { | |
| 1564 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1565 | 0 | goto exit; |
| 1566 | } | |
| 1567 | ||
| 1568 | 0 | val = OBJECT_TO_JSVAL(wsdl); |
| 1569 | 0 | if(!JS_DefineProperty(cx, glob, "wsdl", val, NULL, NULL, |
| 1570 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1571 | { | |
| 1572 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1573 | 0 | goto exit; |
| 1574 | } | |
| 1575 | } | |
| 1576 | else | |
| 1577 | { | |
| 1578 | 0 | wsdl = JSVAL_TO_OBJECT(val); |
| 1579 | 0 | if(!wsdl) |
| 1580 | { | |
| 1581 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1582 | 0 | goto exit; |
| 1583 | } | |
| 1584 | } | |
| 1585 | ||
| 1586 | 0 | res = JS_GetProperty(cx, wsdl, "types", &val); |
| 1587 | 0 | if(val == JSVAL_VOID) |
| 1588 | { | |
| 1589 | 0 | types = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1590 | 0 | if(!types) |
| 1591 | { | |
| 1592 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1593 | 0 | goto exit; |
| 1594 | } | |
| 1595 | ||
| 1596 | 0 | val = OBJECT_TO_JSVAL(types); |
| 1597 | 0 | if(!JS_DefineProperty(cx, wsdl, "types", val, NULL, NULL, |
| 1598 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1599 | { | |
| 1600 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1601 | 0 | goto exit; |
| 1602 | } | |
| 1603 | } | |
| 1604 | else | |
| 1605 | { | |
| 1606 | 0 | types = JSVAL_TO_OBJECT(val); |
| 1607 | 0 | if(!types) |
| 1608 | { | |
| 1609 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1610 | 0 | goto exit; |
| 1611 | } | |
| 1612 | } | |
| 1613 | ||
| 1614 | 0 | res = JS_GetProperty(cx, wsdl, "elements", &val); |
| 1615 | 0 | if(val == JSVAL_VOID) |
| 1616 | { | |
| 1617 | 0 | elements = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1618 | 0 | if(!elements) |
| 1619 | { | |
| 1620 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1621 | 0 | goto exit; |
| 1622 | } | |
| 1623 | ||
| 1624 | 0 | val = OBJECT_TO_JSVAL(elements); |
| 1625 | 0 | if(!JS_DefineProperty(cx, wsdl, "elements", val, NULL, NULL, |
| 1626 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1627 | { | |
| 1628 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1629 | 0 | goto exit; |
| 1630 | } | |
| 1631 | } | |
| 1632 | else | |
| 1633 | { | |
| 1634 | 0 | elements = JSVAL_TO_OBJECT(val); |
| 1635 | 0 | if(!elements) |
| 1636 | { | |
| 1637 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1638 | 0 | goto exit; |
| 1639 | } | |
| 1640 | } | |
| 1641 | ||
| 1642 | 0 | res = JS_GetProperty(cx, wsdl, "local_elements", &val); |
| 1643 | 0 | if(val == JSVAL_VOID) |
| 1644 | { | |
| 1645 | 0 | local_elements = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1646 | 0 | if(!local_elements) |
| 1647 | { | |
| 1648 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1649 | 0 | goto exit; |
| 1650 | } | |
| 1651 | ||
| 1652 | 0 | val = OBJECT_TO_JSVAL(local_elements); |
| 1653 | 0 | if(!JS_DefineProperty(cx, wsdl, "local_elements", val, NULL, NULL, |
| 1654 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1655 | { | |
| 1656 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1657 | 0 | goto exit; |
| 1658 | } | |
| 1659 | } | |
| 1660 | else | |
| 1661 | { | |
| 1662 | 0 | local_elements = JSVAL_TO_OBJECT(val); |
| 1663 | 0 | if(!local_elements) |
| 1664 | { | |
| 1665 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1666 | 0 | goto exit; |
| 1667 | } | |
| 1668 | } | |
| 1669 | ||
| 1670 | 0 | res = JS_GetProperty(cx, wsdl, "attributes", &val); |
| 1671 | 0 | if(val == JSVAL_VOID) |
| 1672 | { | |
| 1673 | 0 | attributes = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1674 | 0 | if(!attributes) |
| 1675 | { | |
| 1676 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1677 | 0 | goto exit; |
| 1678 | } | |
| 1679 | ||
| 1680 | 0 | val = OBJECT_TO_JSVAL(attributes); |
| 1681 | 0 | if(!JS_DefineProperty(cx, wsdl, "attributes", val, NULL, NULL, |
| 1682 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1683 | { | |
| 1684 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1685 | 0 | goto exit; |
| 1686 | } | |
| 1687 | } | |
| 1688 | else | |
| 1689 | { | |
| 1690 | 0 | attributes = JSVAL_TO_OBJECT(val); |
| 1691 | 0 | if(!attributes) |
| 1692 | { | |
| 1693 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1694 | 0 | goto exit; |
| 1695 | } | |
| 1696 | } | |
| 1697 | ||
| 1698 | 0 | res = JS_GetProperty(cx, wsdl, "local_attributes", &val); |
| 1699 | 0 | if(val == JSVAL_VOID) |
| 1700 | { | |
| 1701 | 0 | local_attributes = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1702 | 0 | if(!local_attributes) |
| 1703 | { | |
| 1704 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1705 | 0 | goto exit; |
| 1706 | } | |
| 1707 | ||
| 1708 | 0 | val = OBJECT_TO_JSVAL(local_attributes); |
| 1709 | 0 | if(!JS_DefineProperty(cx, wsdl, "local_attributes", val, NULL, NULL, |
| 1710 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1711 | { | |
| 1712 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1713 | 0 | goto exit; |
| 1714 | } | |
| 1715 | } | |
| 1716 | else | |
| 1717 | { | |
| 1718 | 0 | local_attributes = JSVAL_TO_OBJECT(val); |
| 1719 | 0 | if(!local_attributes) |
| 1720 | { | |
| 1721 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1722 | 0 | goto exit; |
| 1723 | } | |
| 1724 | } | |
| 1725 | ||
| 1726 | 0 | res = JS_GetProperty(cx, wsdl, "messages", &val); |
| 1727 | 0 | if(val == JSVAL_VOID) |
| 1728 | { | |
| 1729 | 0 | messages = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1730 | 0 | if(!messages) |
| 1731 | { | |
| 1732 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1733 | 0 | goto exit; |
| 1734 | } | |
| 1735 | ||
| 1736 | 0 | val = OBJECT_TO_JSVAL(messages); |
| 1737 | 0 | if(!JS_DefineProperty(cx, wsdl, "messages", val, NULL, NULL, |
| 1738 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1739 | { | |
| 1740 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1741 | 0 | goto exit; |
| 1742 | } | |
| 1743 | } | |
| 1744 | else | |
| 1745 | { | |
| 1746 | 0 | messages = JSVAL_TO_OBJECT(val); |
| 1747 | 0 | if(!messages) |
| 1748 | { | |
| 1749 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1750 | 0 | goto exit; |
| 1751 | } | |
| 1752 | } | |
| 1753 | ||
| 1754 | 0 | res = JS_GetProperty(cx, wsdl, "portTypes", &val); |
| 1755 | 0 | if(val == JSVAL_VOID) |
| 1756 | { | |
| 1757 | 0 | portTypes = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1758 | 0 | if(!portTypes) |
| 1759 | { | |
| 1760 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1761 | 0 | goto exit; |
| 1762 | } | |
| 1763 | ||
| 1764 | 0 | val = OBJECT_TO_JSVAL(portTypes); |
| 1765 | 0 | if(!JS_DefineProperty(cx, wsdl, "portTypes", val, NULL, NULL, |
| 1766 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1767 | { | |
| 1768 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1769 | 0 | goto exit; |
| 1770 | } | |
| 1771 | } | |
| 1772 | else | |
| 1773 | { | |
| 1774 | 0 | portTypes = JSVAL_TO_OBJECT(val); |
| 1775 | 0 | if(!portTypes) |
| 1776 | { | |
| 1777 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1778 | 0 | goto exit; |
| 1779 | } | |
| 1780 | } | |
| 1781 | ||
| 1782 | 0 | res = JS_GetProperty(cx, wsdl, "bindings", &val); |
| 1783 | 0 | if(val == JSVAL_VOID) |
| 1784 | { | |
| 1785 | 0 | bindings = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1786 | 0 | if(!bindings) |
| 1787 | { | |
| 1788 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1789 | 0 | goto exit; |
| 1790 | } | |
| 1791 | ||
| 1792 | 0 | val = OBJECT_TO_JSVAL(bindings); |
| 1793 | 0 | if(!JS_DefineProperty(cx, wsdl, "bindings", val, NULL, NULL, |
| 1794 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1795 | { | |
| 1796 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1797 | 0 | goto exit; |
| 1798 | } | |
| 1799 | } | |
| 1800 | else | |
| 1801 | { | |
| 1802 | 0 | bindings = JSVAL_TO_OBJECT(val); |
| 1803 | 0 | if(!bindings) |
| 1804 | { | |
| 1805 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1806 | 0 | goto exit; |
| 1807 | } | |
| 1808 | } | |
| 1809 | ||
| 1810 | 0 | res = JS_GetProperty(cx, wsdl, "services", &val); |
| 1811 | 0 | if(val == JSVAL_VOID) |
| 1812 | { | |
| 1813 | 0 | services = JS_NewObject(cx, &basic_class, NULL, wsdl); |
| 1814 | 0 | if(!services) |
| 1815 | { | |
| 1816 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1817 | 0 | goto exit; |
| 1818 | } | |
| 1819 | ||
| 1820 | 0 | val = OBJECT_TO_JSVAL(services); |
| 1821 | 0 | if(!JS_DefineProperty(cx, wsdl, "services", val, NULL, NULL, |
| 1822 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1823 | { | |
| 1824 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1825 | 0 | goto exit; |
| 1826 | } | |
| 1827 | } | |
| 1828 | else | |
| 1829 | { | |
| 1830 | 0 | services = JSVAL_TO_OBJECT(val); |
| 1831 | 0 | if(!services) |
| 1832 | { | |
| 1833 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1834 | 0 | goto exit; |
| 1835 | } | |
| 1836 | } | |
| 1837 | ||
| 1838 | 0 | data = (ScannerData *) malloc(sizeof(ScannerData)); |
| 1839 | 0 | data->schema = schema; |
| 1840 | 0 | data->context = cx; |
| 1841 | 0 | data->global = glob; |
| 1842 | 0 | data->types = (void *)types; |
| 1843 | 0 | data->elements = (void *)elements; |
| 1844 | 0 | data->local_elements = (void *)local_elements; |
| 1845 | 0 | data->attributes = (void *)attributes; |
| 1846 | 0 | data->local_attributes = (void *)local_attributes; |
| 1847 | 0 | data->messages = (void *)messages; |
| 1848 | 0 | data->attributes = (void *)attributes; |
| 1849 | 0 | data->portTypes = (void *)portTypes; |
| 1850 | 0 | data->bindings = (void *)bindings; |
| 1851 | 0 | data->services = (void *)services; |
| 1852 | 0 | data->result = GLOBUS_SUCCESS; |
| 1853 | ||
| 1854 | 0 | if(schema->schemaTypes) |
| 1855 | { | |
| 1856 | 0 | data->xsdSchema = schema->schemaTypes; |
| 1857 | 0 | xmlHashScan(schema->schemaTypes->schemasImports, |
| 1858 | globus_i_wsdl_parser_import_scanner, data); | |
| 1859 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1860 | { | |
| 1861 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1862 | 0 | goto exit; |
| 1863 | } | |
| 1864 | ||
| 1865 | 0 | data->xsdSchema = schema->schemaTypes; |
| 1866 | 0 | xmlHashScan(schema->schemaTypes->typeDecl, |
| 1867 | globus_i_wsdl_parser_type_scanner, data); | |
| 1868 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1869 | { | |
| 1870 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1871 | 0 | goto exit; |
| 1872 | } | |
| 1873 | ||
| 1874 | 0 | xmlHashScan(schema->schemaTypes->groupDecl, |
| 1875 | globus_i_wsdl_parser_type_scanner, data); | |
| 1876 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1877 | { | |
| 1878 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1879 | 0 | goto exit; |
| 1880 | } | |
| 1881 | ||
| 1882 | 0 | xmlHashScan(schema->schemaTypes->elemDecl, |
| 1883 | globus_i_wsdl_parser_element_scanner, data); | |
| 1884 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1885 | { | |
| 1886 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1887 | 0 | goto exit; |
| 1888 | } | |
| 1889 | ||
| 1890 | 0 | xmlHashScan(schema->schemaTypes->attrDecl, |
| 1891 | globus_i_wsdl_parser_attribute_scanner, | |
| 1892 | data); | |
| 1893 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1894 | { | |
| 1895 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1896 | 0 | goto exit; |
| 1897 | } | |
| 1898 | } | |
| 1899 | ||
| 1900 | 0 | typeEnum = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1901 | 0 | if(!typeEnum) |
| 1902 | { | |
| 1903 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1904 | 0 | goto exit; |
| 1905 | } | |
| 1906 | ||
| 1907 | 0 | if(!JS_DefineProperties(cx, typeEnum, xsdTypeEnum_properties)) |
| 1908 | { | |
| 1909 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1910 | 0 | goto exit; |
| 1911 | } | |
| 1912 | ||
| 1913 | 0 | val = OBJECT_TO_JSVAL(typeEnum); |
| 1914 | 0 | if(!JS_DefineProperty(cx, wsdl, "xsdType", val, NULL, NULL, |
| 1915 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1916 | { | |
| 1917 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1918 | 0 | goto exit; |
| 1919 | } | |
| 1920 | ||
| 1921 | 0 | attrEnum = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1922 | 0 | if(!attrEnum) |
| 1923 | { | |
| 1924 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1925 | 0 | goto exit; |
| 1926 | } | |
| 1927 | ||
| 1928 | 0 | if(!JS_DefineProperties(cx, attrEnum, xsdAttrEnum_properties)) |
| 1929 | { | |
| 1930 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1931 | 0 | goto exit; |
| 1932 | } | |
| 1933 | ||
| 1934 | 0 | val = OBJECT_TO_JSVAL(attrEnum); |
| 1935 | 0 | if(!JS_DefineProperty(cx, wsdl, "xsdAttr", val, NULL, NULL, |
| 1936 | JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 1937 | { | |
| 1938 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1939 | 0 | goto exit; |
| 1940 | } | |
| 1941 | ||
| 1942 | 0 | contentTypeEnum = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1943 | 0 | if(!contentTypeEnum) |
| 1944 | { | |
| 1945 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1946 | 0 | goto exit; |
| 1947 | } | |
| 1948 | ||
| 1949 | 0 | if(!JS_DefineProperties(cx, contentTypeEnum, |
| 1950 | xsdContentTypeEnum_properties)) | |
| 1951 | { | |
| 1952 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1953 | 0 | goto exit; |
| 1954 | } | |
| 1955 | ||
| 1956 | 0 | val = OBJECT_TO_JSVAL(contentTypeEnum); |
| 1957 | 0 | if(!JS_SetProperty(cx, wsdl, "xsdContentType", &val)) |
| 1958 | { | |
| 1959 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 1960 | 0 | goto exit; |
| 1961 | } | |
| 1962 | ||
| 1963 | 0 | operationTypeEnum = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1964 | 0 | JS_DefineProperties(cx, operationTypeEnum, operationTypeEnum_properties); |
| 1965 | 0 | val = OBJECT_TO_JSVAL(operationTypeEnum); |
| 1966 | 0 | JS_SetProperty(cx, wsdl, "operationType", &val); |
| 1967 | ||
| 1968 | 0 | bindingType = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1969 | 0 | JS_DefineProperties(cx, bindingType, bindingType_properties); |
| 1970 | 0 | val = OBJECT_TO_JSVAL(bindingType); |
| 1971 | 0 | JS_SetProperty(cx, wsdl, "bindingType", &val); |
| 1972 | ||
| 1973 | 0 | soapOperationStyleType = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1974 | 0 | JS_DefineProperties(cx, soapOperationStyleType, |
| 1975 | soapOperationStyleType_properties); | |
| 1976 | 0 | val = OBJECT_TO_JSVAL(soapOperationStyleType); |
| 1977 | 0 | JS_SetProperty(cx, wsdl, "soapOperationStyleType", &val); |
| 1978 | ||
| 1979 | 0 | soapUseType = JS_NewObject(cx, &xsdEnum_class, NULL, wsdl); |
| 1980 | 0 | JS_DefineProperties(cx, soapUseType, |
| 1981 | soapUseType_properties); | |
| 1982 | 0 | val = OBJECT_TO_JSVAL(soapUseType); |
| 1983 | 0 | JS_SetProperty(cx, wsdl, "soapUseType", &val); |
| 1984 | ||
| 1985 | 0 | xmlHashScan(schema->messagesDecl, |
| 1986 | globus_i_wsdl_parser_message_scanner, | |
| 1987 | data); | |
| 1988 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1989 | { | |
| 1990 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1991 | 0 | goto exit; |
| 1992 | } | |
| 1993 | ||
| 1994 | 0 | xmlHashScan(schema->portTypesDecl, |
| 1995 | globus_i_wsdl_parser_portType_scanner, data); | |
| 1996 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 1997 | { | |
| 1998 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 1999 | 0 | goto exit; |
| 2000 | } | |
| 2001 | ||
| 2002 | 0 | xmlHashScan(schema->bindingsDecl, |
| 2003 | globus_i_wsdl_parser_binding_scanner, | |
| 2004 | data); | |
| 2005 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2006 | { | |
| 2007 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2008 | 0 | goto exit; |
| 2009 | } | |
| 2010 | ||
| 2011 | 0 | xmlHashScan(schema->servicesDecl, |
| 2012 | globus_i_wsdl_parser_service_scanner, | |
| 2013 | data); | |
| 2014 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2015 | { | |
| 2016 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2017 | 0 | goto exit; |
| 2018 | } | |
| 2019 | ||
| 2020 | 0 | xmlHashScan(schema->importsDecl, |
| 2021 | globus_i_wsdl_parser_wsdl_imports_scanner, | |
| 2022 | data); | |
| 2023 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2024 | { | |
| 2025 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2026 | 0 | goto exit; |
| 2027 | } | |
| 2028 | ||
| 2029 | 0 | if(!schema->targetNamespace) |
| 2030 | { | |
| 2031 | 0 | val = JSVAL_NULL; |
| 2032 | } | |
| 2033 | else | |
| 2034 | { | |
| 2035 | 0 | str = JS_InternString(cx, (const char *) schema->targetNamespace); |
| 2036 | 0 | if(!str) |
| 2037 | { | |
| 2038 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2039 | 0 | goto exit; |
| 2040 | } | |
| 2041 | 0 | val = STRING_TO_JSVAL(str); |
| 2042 | } | |
| 2043 | ||
| 2044 | 0 | if(!JS_SetProperty(cx, wsdl, "targetNamespace", &val)) |
| 2045 | { | |
| 2046 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2047 | goto exit; | |
| 2048 | } | |
| 2049 | ||
| 2050 | exit: | |
| 2051 | ||
| 2052 | 0 | GlobusWSDLDebugExit(); |
| 2053 | 0 | return result; |
| 2054 | } | |
| 2055 | ||
| 2056 | static | |
| 2057 | globus_result_t | |
| 2058 | globus_i_wsdl_js_load_imported_schema( | |
| 2059 | JSContext * cx, | |
| 2060 | wsdlSchemaPtr schema) | |
| 2061 | 0 | { |
| 2062 | 0 | JSObject * glob = NULL; |
| 2063 | 0 | JSObject * wsdl = NULL; |
| 2064 | 0 | JSObject * types = NULL; |
| 2065 | 0 | JSObject * elements = NULL; |
| 2066 | 0 | JSObject * local_elements = NULL; |
| 2067 | 0 | JSObject * attributes = NULL; |
| 2068 | 0 | JSObject * local_attributes = NULL; |
| 2069 | 0 | JSObject * messages = NULL; |
| 2070 | 0 | JSObject * portTypes = NULL; |
| 2071 | 0 | JSObject * bindings = NULL; |
| 2072 | 0 | JSObject * services = NULL; |
| 2073 | 0 | ScannerData * data = NULL; |
| 2074 | 0 | jsval val; |
| 2075 | 0 | JSBool res = JS_TRUE; |
| 2076 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 2077 | 0 | GlobusFuncName(globus_i_wsdl_js_load_imported_schema); |
| 2078 | 0 | GlobusWSDLDebugEnter(); |
| 2079 | ||
| 2080 | 0 | glob = JS_GetGlobalObject(cx); |
| 2081 | 0 | if(!glob) |
| 2082 | { | |
| 2083 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2084 | 0 | goto exit; |
| 2085 | } | |
| 2086 | ||
| 2087 | 0 | res = JS_GetProperty(cx, glob, "wsdl", &val); |
| 2088 | 0 | globus_assert(res); |
| 2089 | ||
| 2090 | 0 | wsdl = JSVAL_TO_OBJECT(val); |
| 2091 | 0 | if(!wsdl) |
| 2092 | { | |
| 2093 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2094 | 0 | goto exit; |
| 2095 | } | |
| 2096 | ||
| 2097 | 0 | res = JS_GetProperty(cx, wsdl, "types", &val); |
| 2098 | 0 | globus_assert(res); |
| 2099 | ||
| 2100 | 0 | types = JSVAL_TO_OBJECT(val); |
| 2101 | 0 | if(!types) |
| 2102 | { | |
| 2103 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2104 | 0 | goto exit; |
| 2105 | } | |
| 2106 | ||
| 2107 | 0 | res = JS_GetProperty(cx, wsdl, "elements", &val); |
| 2108 | 0 | globus_assert(res); |
| 2109 | ||
| 2110 | 0 | elements = JSVAL_TO_OBJECT(val); |
| 2111 | 0 | if(!elements) |
| 2112 | { | |
| 2113 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2114 | 0 | goto exit; |
| 2115 | } | |
| 2116 | ||
| 2117 | 0 | res = JS_GetProperty(cx, wsdl, "local_elements", &val); |
| 2118 | 0 | globus_assert(res); |
| 2119 | ||
| 2120 | 0 | local_elements = JSVAL_TO_OBJECT(val); |
| 2121 | 0 | if(!local_elements) |
| 2122 | { | |
| 2123 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2124 | 0 | goto exit; |
| 2125 | } | |
| 2126 | ||
| 2127 | 0 | res = JS_GetProperty(cx, wsdl, "attributes", &val); |
| 2128 | 0 | globus_assert(res); |
| 2129 | ||
| 2130 | 0 | attributes = JSVAL_TO_OBJECT(val); |
| 2131 | 0 | if(!attributes) |
| 2132 | { | |
| 2133 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2134 | 0 | goto exit; |
| 2135 | } | |
| 2136 | ||
| 2137 | 0 | res = JS_GetProperty(cx, wsdl, "local_attributes", &val); |
| 2138 | 0 | globus_assert(res); |
| 2139 | ||
| 2140 | 0 | local_attributes = JSVAL_TO_OBJECT(val); |
| 2141 | 0 | if(!local_attributes) |
| 2142 | { | |
| 2143 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2144 | 0 | goto exit; |
| 2145 | } | |
| 2146 | ||
| 2147 | 0 | res = JS_GetProperty(cx, wsdl, "messages", &val); |
| 2148 | 0 | globus_assert(res); |
| 2149 | ||
| 2150 | 0 | messages = JSVAL_TO_OBJECT(val); |
| 2151 | 0 | if(!messages) |
| 2152 | { | |
| 2153 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2154 | 0 | goto exit; |
| 2155 | } | |
| 2156 | ||
| 2157 | 0 | res = JS_GetProperty(cx, wsdl, "portTypes", &val); |
| 2158 | 0 | globus_assert(res); |
| 2159 | ||
| 2160 | 0 | portTypes = JSVAL_TO_OBJECT(val); |
| 2161 | 0 | if(!portTypes) |
| 2162 | { | |
| 2163 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2164 | 0 | goto exit; |
| 2165 | } | |
| 2166 | ||
| 2167 | 0 | res = JS_GetProperty(cx, wsdl, "bindings", &val); |
| 2168 | 0 | globus_assert(res); |
| 2169 | ||
| 2170 | 0 | bindings = JSVAL_TO_OBJECT(val); |
| 2171 | 0 | if(!bindings) |
| 2172 | { | |
| 2173 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2174 | 0 | goto exit; |
| 2175 | } | |
| 2176 | ||
| 2177 | 0 | res = JS_GetProperty(cx, wsdl, "services", &val); |
| 2178 | 0 | globus_assert(res); |
| 2179 | ||
| 2180 | 0 | services = JSVAL_TO_OBJECT(val); |
| 2181 | 0 | if(!services) |
| 2182 | { | |
| 2183 | 0 | result = GlobusWSDLErrorJSLoadSchema(GLOBUS_NULL); |
| 2184 | 0 | goto exit; |
| 2185 | } | |
| 2186 | ||
| 2187 | 0 | data = (ScannerData *) malloc(sizeof(ScannerData)); |
| 2188 | 0 | data->schema = schema; |
| 2189 | 0 | data->context = cx; |
| 2190 | 0 | data->global = glob; |
| 2191 | 0 | data->types = (void *)types; |
| 2192 | 0 | data->elements = (void *)elements; |
| 2193 | 0 | data->attributes = (void *)attributes; |
| 2194 | 0 | data->local_elements = (void *)local_elements; |
| 2195 | 0 | data->local_attributes = (void *)local_attributes; |
| 2196 | 0 | data->messages = (void *)messages; |
| 2197 | 0 | data->portTypes = (void *)portTypes; |
| 2198 | 0 | data->bindings = (void *)bindings; |
| 2199 | 0 | data->services = (void *)services; |
| 2200 | 0 | data->result = GLOBUS_SUCCESS; |
| 2201 | ||
| 2202 | 0 | if(schema->schemaTypes) |
| 2203 | { | |
| 2204 | 0 | data->xsdSchema = schema->schemaTypes; |
| 2205 | 0 | xmlHashScan(schema->schemaTypes->schemasImports, |
| 2206 | globus_i_wsdl_parser_import_scanner, | |
| 2207 | data); | |
| 2208 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2209 | { | |
| 2210 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2211 | 0 | goto exit; |
| 2212 | } | |
| 2213 | ||
| 2214 | 0 | data->xsdSchema = schema->schemaTypes; |
| 2215 | 0 | xmlHashScan(schema->schemaTypes->typeDecl, |
| 2216 | globus_i_wsdl_parser_type_scanner, data); | |
| 2217 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2218 | { | |
| 2219 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2220 | 0 | goto exit; |
| 2221 | } | |
| 2222 | ||
| 2223 | 0 | xmlHashScan(schema->schemaTypes->groupDecl, |
| 2224 | globus_i_wsdl_parser_type_scanner, data); | |
| 2225 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2226 | { | |
| 2227 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2228 | 0 | goto exit; |
| 2229 | } | |
| 2230 | ||
| 2231 | 0 | xmlHashScan(schema->schemaTypes->elemDecl, |
| 2232 | globus_i_wsdl_parser_element_scanner, data); | |
| 2233 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2234 | { | |
| 2235 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2236 | 0 | goto exit; |
| 2237 | } | |
| 2238 | ||
| 2239 | 0 | xmlHashScan(schema->schemaTypes->attrDecl, |
| 2240 | globus_i_wsdl_parser_attribute_scanner, | |
| 2241 | data); | |
| 2242 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2243 | { | |
| 2244 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2245 | 0 | goto exit; |
| 2246 | } | |
| 2247 | } | |
| 2248 | ||
| 2249 | 0 | xmlHashScan(schema->messagesDecl, |
| 2250 | globus_i_wsdl_parser_message_scanner, data); | |
| 2251 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2252 | { | |
| 2253 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2254 | 0 | goto exit; |
| 2255 | } | |
| 2256 | ||
| 2257 | 0 | xmlHashScan(schema->portTypesDecl, |
| 2258 | globus_i_wsdl_parser_portType_scanner, data); | |
| 2259 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2260 | { | |
| 2261 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2262 | 0 | goto exit; |
| 2263 | } | |
| 2264 | ||
| 2265 | 0 | xmlHashScan(schema->bindingsDecl, |
| 2266 | globus_i_wsdl_parser_binding_scanner, data); | |
| 2267 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2268 | { | |
| 2269 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2270 | 0 | goto exit; |
| 2271 | } | |
| 2272 | ||
| 2273 | 0 | xmlHashScan(schema->servicesDecl, |
| 2274 | globus_i_wsdl_parser_service_scanner, data); | |
| 2275 | 0 | if(data->result != GLOBUS_SUCCESS) |
| 2276 | { | |
| 2277 | 0 | result = GlobusWSDLErrorJSLoadSchema(data->result); |
| 2278 | 0 | goto exit; |
| 2279 | } | |
| 2280 | ||
| 2281 | 0 | xmlHashScan(schema->importsDecl, |
| 2282 | globus_i_wsdl_parser_wsdl_imports_scanner, data); | |
| 2283 | ||
| 2284 | exit: | |
| 2285 | ||
| 2286 | 0 | GlobusWSDLDebugExit(); |
| 2287 | 0 | return result; |
| 2288 | } | |
| 2289 | ||
| 2290 | static | |
| 2291 | globus_result_t | |
| 2292 | globus_i_wsdl_execute_script( | |
| 2293 | JSContext * ctx, | |
| 2294 | JSObject * glob, | |
| 2295 | const char * tmpl_filename, | |
| 2296 | const char * out_filename, | |
| 2297 | const char * out_dir, | |
| 2298 | globus_hashtable_t nsmap, | |
| 2299 | globus_list_t * template_paths) | |
| 2300 | 0 | { |
| 2301 | 0 | PrivateContext * data; |
| 2302 | 0 | JSString * argString; |
| 2303 | 0 | jsval resval; |
| 2304 | 0 | jsval load_args[2]; |
| 2305 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 2306 | 0 | int argcount = 0; |
| 2307 | ||
| 2308 | 0 | GlobusFuncName(globus_i_wsdl_execute_script); |
| 2309 | 0 | GlobusWSDLDebugEnter(); |
| 2310 | ||
| 2311 | 0 | data = (PrivateContext *) globus_malloc(sizeof(PrivateContext)); |
| 2312 | 0 | if(!data) |
| 2313 | { | |
| 2314 | 0 | result = GlobusWSDLErrorOutOfMemory; |
| 2315 | 0 | goto exit; |
| 2316 | } | |
| 2317 | 0 | memset(data, 0, sizeof(PrivateContext)); |
| 2318 | 0 | if(out_dir) |
| 2319 | { | |
| 2320 | 0 | data->outdir = globus_libc_strdup(out_dir); |
| 2321 | 0 | if(mkdir(data->outdir, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)) |
| 2322 | { | |
| 2323 | 0 | if(errno != EEXIST) |
| 2324 | { | |
| 2325 | 0 | result = GlobusWSDLErrorDirCreate(data->outdir); |
| 2326 | 0 | goto exit; |
| 2327 | } | |
| 2328 | } | |
| 2329 | } | |
| 2330 | ||
| 2331 | 0 | data->streams = (StreamContext *) malloc(sizeof(StreamContext)); |
| 2332 | 0 | globus_assert_string(data->streams, "Memory allocation failed."); |
| 2333 | 0 | memset(data->streams, 0, sizeof(StreamContext)); |
| 2334 | ||
| 2335 | 0 | if(!nsmap) |
| 2336 | { | |
| 2337 | 0 | globus_hashtable_init(&data->nsmap, 10, |
| 2338 | globus_hashtable_string_hash, | |
| 2339 | globus_hashtable_string_keyeq); | |
| 2340 | 0 | data->free_nsmap = 0; |
| 2341 | } | |
| 2342 | else | |
| 2343 | { | |
| 2344 | 0 | data->nsmap = nsmap; |
| 2345 | 0 | data->free_nsmap = 0; |
| 2346 | } | |
| 2347 | ||
| 2348 | 0 | data->template_paths = template_paths; |
| 2349 | 0 | JS_SetContextPrivate(ctx, (void *)data); |
| 2350 | ||
| 2351 | 0 | memset(load_args, 0, 2); |
| 2352 | ||
| 2353 | 0 | argString = JS_InternString(ctx, tmpl_filename); |
| 2354 | 0 | load_args[0] = STRING_TO_JSVAL(argString); |
| 2355 | 0 | argcount++; |
| 2356 | ||
| 2357 | 0 | if(out_filename) |
| 2358 | { | |
| 2359 | 0 | argString = JS_InternString(ctx, out_filename); |
| 2360 | 0 | load_args[1] = STRING_TO_JSVAL(argString); |
| 2361 | 0 | argcount++; |
| 2362 | } | |
| 2363 | else | |
| 2364 | { | |
| 2365 | 0 | load_args[1] = JSVAL_NULL; |
| 2366 | 0 | argcount++; |
| 2367 | } | |
| 2368 | ||
| 2369 | 0 | if(JS_CallFunctionName( |
| 2370 | ctx, glob, "load", argcount, load_args, &resval) != JS_TRUE) | |
| 2371 | { | |
| 2372 | 0 | result = GlobusWSDLErrorTemplateLoad(data->result, tmpl_filename); |
| 2373 | 0 | data->result = result; |
| 2374 | goto exit; | |
| 2375 | } | |
| 2376 | ||
| 2377 | exit: | |
| 2378 | ||
| 2379 | 0 | data = (PrivateContext *) JS_GetContextPrivate(ctx); |
| 2380 | 0 | if(data) |
| 2381 | { | |
| 2382 | 0 | if(data->streams) |
| 2383 | { | |
| 2384 | 0 | free(data->streams); |
| 2385 | } | |
| 2386 | ||
| 2387 | 0 | if(data->nsmap && data->free_nsmap) |
| 2388 | { | |
| 2389 | 0 | globus_wsdl_config_properties_destroy(data->nsmap); |
| 2390 | } | |
| 2391 | ||
| 2392 | 0 | if(data->templates) |
| 2393 | { | |
| 2394 | 0 | globus_hashtable_destroy_all(&data->templates, TemplateFree); |
| 2395 | } | |
| 2396 | ||
| 2397 | 0 | if(data->outdir) |
| 2398 | { | |
| 2399 | 0 | free(data->outdir); |
| 2400 | } | |
| 2401 | ||
| 2402 | 0 | free(data); |
| 2403 | } | |
| 2404 | ||
| 2405 | 0 | GlobusWSDLDebugExit(); |
| 2406 | 0 | return result; |
| 2407 | } | |
| 2408 | ||
| 2409 | static | |
| 2410 | JSBool | |
| 2411 | xsdEnumGetter( | |
| 2412 | JSContext * cx, | |
| 2413 | JSObject * obj, | |
| 2414 | jsval id, | |
| 2415 | jsval * vp) | |
| 2416 | 0 | { |
| 2417 | 0 | jsval res = JS_TRUE; |
| 2418 | 0 | GlobusFuncName(xsdEnumGetter); |
| 2419 | 0 | GlobusWSDLDebugEnter(); |
| 2420 | ||
| 2421 | 0 | if(JSVAL_IS_INT(id)) |
| 2422 | { | |
| 2423 | 0 | *vp = id; |
| 2424 | } | |
| 2425 | else | |
| 2426 | { | |
| 2427 | 0 | res = JS_FALSE; |
| 2428 | } | |
| 2429 | ||
| 2430 | 0 | GlobusWSDLDebugExit(); |
| 2431 | 0 | return res; |
| 2432 | } | |
| 2433 | ||
| 2434 | static | |
| 2435 | JSBool | |
| 2436 | xsdAttrsGetter( | |
| 2437 | JSContext * cx, | |
| 2438 | JSObject * obj, | |
| 2439 | jsval id, | |
| 2440 | jsval * vp) | |
| 2441 | 0 | { |
| 2442 | 0 | xmlSchemaAttributePtr attr; |
| 2443 | 0 | JSBool res = JS_TRUE; |
| 2444 | 0 | JSObject * attrObj; |
| 2445 | 0 | int i = 0; |
| 2446 | 0 | GlobusFuncName(xsdAttrsGetter); |
| 2447 | 0 | GlobusWSDLDebugEnter(); |
| 2448 | ||
| 2449 | 0 | attr = (xmlSchemaAttributePtr) JS_GetPrivate(cx, obj); |
| 2450 | 0 | globus_assert(attr); |
| 2451 | ||
| 2452 | 0 | if(JSVAL_IS_STRING(id)) |
| 2453 | { | |
| 2454 | 0 | while(attr) |
| 2455 | { | |
| 2456 | 0 | JSString * name; |
| 2457 | ||
| 2458 | 0 | name = JS_InternString(cx, (const char *) attr->name); |
| 2459 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 2460 | { | |
| 2461 | 0 | break; |
| 2462 | } | |
| 2463 | ||
| 2464 | 0 | attr = attr->next; |
| 2465 | } | |
| 2466 | } | |
| 2467 | 0 | else if(JSVAL_IS_INT(id)) |
| 2468 | { | |
| 2469 | 0 | for(; i < JSVAL_TO_INT(id) && attr; ++i) |
| 2470 | { | |
| 2471 | 0 | attr = attr->next; |
| 2472 | } | |
| 2473 | 0 | globus_assert(attr); |
| 2474 | } | |
| 2475 | else | |
| 2476 | { | |
| 2477 | 0 | attr = (xmlSchemaAttributePtr) JSVAL_TO_PRIVATE(id); |
| 2478 | 0 | globus_assert(attr); |
| 2479 | } | |
| 2480 | ||
| 2481 | 0 | attrObj = JS_NewObject(cx, &xsdAttr_class, xsdAttrClass, obj); |
| 2482 | 0 | globus_assert(attrObj); |
| 2483 | 0 | JS_SetPrivate(cx, attrObj, (void *)attr); |
| 2484 | 0 | JS_DefineProperties(cx, attrObj, xsdAttr_properties); |
| 2485 | ||
| 2486 | 0 | *vp = OBJECT_TO_JSVAL(attrObj); |
| 2487 | ||
| 2488 | 0 | GlobusWSDLDebugExit(); |
| 2489 | 0 | return res; |
| 2490 | } | |
| 2491 | ||
| 2492 | static | |
| 2493 | JSBool | |
| 2494 | xsdFacetsGetter( | |
| 2495 | JSContext * cx, | |
| 2496 | JSObject * obj, | |
| 2497 | jsval id, | |
| 2498 | jsval * vp) | |
| 2499 | 0 | { |
| 2500 | 0 | xmlSchemaFacetPtr facet; |
| 2501 | 0 | JSObject * facetObj; |
| 2502 | 0 | int i = 0; |
| 2503 | 0 | JSBool res = JS_TRUE; |
| 2504 | 0 | GlobusFuncName(xsdFacetsGetter); |
| 2505 | 0 | GlobusWSDLDebugEnter(); |
| 2506 | ||
| 2507 | 0 | facet = (xmlSchemaFacetPtr) JS_GetPrivate(cx, obj); |
| 2508 | 0 | globus_assert(facet); |
| 2509 | ||
| 2510 | 0 | if(JSVAL_IS_STRING(id)) |
| 2511 | { | |
| 2512 | 0 | *vp = JSVAL_ZERO; |
| 2513 | } | |
| 2514 | 0 | else if(JSVAL_IS_INT(id)) |
| 2515 | { | |
| 2516 | 0 | for(; i < JSVAL_TO_INT(id) && facet; ++i) |
| 2517 | { | |
| 2518 | 0 | facet = facet->next; |
| 2519 | } | |
| 2520 | 0 | globus_assert(facet); |
| 2521 | } | |
| 2522 | else | |
| 2523 | { | |
| 2524 | 0 | facet = (xmlSchemaFacetPtr) JSVAL_TO_PRIVATE(id); |
| 2525 | 0 | globus_assert(facet); |
| 2526 | } | |
| 2527 | ||
| 2528 | 0 | facetObj = JS_NewObject(cx, &xsdFacet_class, xsdFacetClass, obj); |
| 2529 | 0 | globus_assert(facetObj); |
| 2530 | 0 | JS_SetPrivate(cx, facetObj, (void *)facet); |
| 2531 | 0 | JS_DefineProperties(cx, facetObj, xsdFacet_properties); |
| 2532 | 0 | *vp = OBJECT_TO_JSVAL(facetObj); |
| 2533 | ||
| 2534 | 0 | GlobusWSDLDebugExit(); |
| 2535 | 0 | return res; |
| 2536 | } | |
| 2537 | ||
| 2538 | static | |
| 2539 | JSBool | |
| 2540 | xsdFacetsEnumerate( | |
| 2541 | JSContext * cx, | |
| 2542 | JSObject * obj, | |
| 2543 | JSIterateOp enum_op, | |
| 2544 | jsval * statep, | |
| 2545 | jsid * idp) | |
| 2546 | 0 | { |
| 2547 | 0 | JSBool res = JS_TRUE; |
| 2548 | 0 | xmlSchemaFacetPtr facet; |
| 2549 | 0 | int index; |
| 2550 | 0 | int i = 0; |
| 2551 | 0 | GlobusFuncName(xsdFacetsEnumerate); |
| 2552 | 0 | GlobusWSDLDebugEnter(); |
| 2553 | ||
| 2554 | 0 | facet = (xmlSchemaFacetPtr) JS_GetPrivate(cx, obj); |
| 2555 | 0 | globus_assert(facet); |
| 2556 | ||
| 2557 | 0 | switch(enum_op) |
| 2558 | { | |
| 2559 | case JSENUMERATE_INIT: | |
| 2560 | ||
| 2561 | 0 | *statep = INT_TO_JSVAL(0); |
| 2562 | 0 | break; |
| 2563 | ||
| 2564 | case JSENUMERATE_NEXT: | |
| 2565 | ||
| 2566 | 0 | index = JSVAL_TO_INT(*statep); |
| 2567 | ||
| 2568 | 0 | for(; i < index && facet; ++i) |
| 2569 | { | |
| 2570 | 0 | facet = facet->next; |
| 2571 | } | |
| 2572 | ||
| 2573 | 0 | if(!facet) |
| 2574 | { | |
| 2575 | 0 | *statep = JSVAL_NULL; |
| 2576 | 0 | *idp = JSVAL_ZERO; |
| 2577 | 0 | break; |
| 2578 | } | |
| 2579 | ||
| 2580 | 0 | *idp = *statep; |
| 2581 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 2582 | ||
| 2583 | break; | |
| 2584 | ||
| 2585 | case JSENUMERATE_DESTROY: | |
| 2586 | ||
| 2587 | 0 | break; |
| 2588 | } | |
| 2589 | ||
| 2590 | 0 | GlobusWSDLDebugExit(); |
| 2591 | 0 | return res; |
| 2592 | } | |
| 2593 | ||
| 2594 | static | |
| 2595 | JSBool | |
| 2596 | xsdSubTypesGetter( | |
| 2597 | JSContext * cx, | |
| 2598 | JSObject * obj, | |
| 2599 | jsval id, | |
| 2600 | jsval * vp) | |
| 2601 | 0 | { |
| 2602 | 0 | xmlSchemaTypePtr type; |
| 2603 | 0 | JSObject * typeObj; |
| 2604 | 0 | int i = 0; |
| 2605 | 0 | JSBool res = JS_TRUE; |
| 2606 | 0 | GlobusFuncName(xsdSubTypesGetter); |
| 2607 | 0 | GlobusWSDLDebugEnter(); |
| 2608 | ||
| 2609 | 0 | type = (xmlSchemaTypePtr) JS_GetPrivate(cx, obj); |
| 2610 | 0 | globus_assert(type); |
| 2611 | ||
| 2612 | 0 | if(JSVAL_IS_STRING(id)) |
| 2613 | { | |
| 2614 | 0 | while(type) |
| 2615 | { | |
| 2616 | 0 | JSString * name; |
| 2617 | ||
| 2618 | 0 | name = JS_InternString(cx, (const char *) type->name); |
| 2619 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 2620 | { | |
| 2621 | 0 | break; |
| 2622 | } | |
| 2623 | ||
| 2624 | 0 | type = type->next; |
| 2625 | } | |
| 2626 | } | |
| 2627 | 0 | else if(JSVAL_IS_INT(id)) |
| 2628 | { | |
| 2629 | 0 | for(; i < JSVAL_TO_INT(id) && type; ++i) |
| 2630 | { | |
| 2631 | 0 | type = type->next; |
| 2632 | } | |
| 2633 | 0 | globus_assert(type); |
| 2634 | } | |
| 2635 | else | |
| 2636 | { | |
| 2637 | 0 | type = (xmlSchemaTypePtr) JSVAL_TO_PRIVATE(id); |
| 2638 | 0 | globus_assert(type); |
| 2639 | } | |
| 2640 | ||
| 2641 | 0 | typeObj = JS_NewObject(cx, &xsdType_class, xsdTypeClass, obj); |
| 2642 | 0 | globus_assert(typeObj); |
| 2643 | 0 | JS_SetPrivate(cx, typeObj, (void *)type); |
| 2644 | 0 | JS_DefineProperties(cx, typeObj, xsdType_properties); |
| 2645 | 0 | *vp = OBJECT_TO_JSVAL(typeObj); |
| 2646 | ||
| 2647 | 0 | GlobusWSDLDebugExit(); |
| 2648 | 0 | return res; |
| 2649 | } | |
| 2650 | ||
| 2651 | static | |
| 2652 | JSBool | |
| 2653 | xsdSubTypesEnumerate( | |
| 2654 | JSContext * cx, | |
| 2655 | JSObject * obj, | |
| 2656 | JSIterateOp enum_op, | |
| 2657 | jsval * statep, | |
| 2658 | jsid * idp) | |
| 2659 | 0 | { |
| 2660 | 0 | JSBool res = JS_TRUE; |
| 2661 | 0 | xmlSchemaTypePtr schemaType; |
| 2662 | 0 | int index; |
| 2663 | 0 | int i = 0; |
| 2664 | 0 | GlobusFuncName(xsdSubTypesEnumerate); |
| 2665 | 0 | GlobusWSDLDebugEnter(); |
| 2666 | ||
| 2667 | 0 | schemaType = (xmlSchemaTypePtr) JS_GetPrivate(cx, obj); |
| 2668 | 0 | globus_assert(schemaType); |
| 2669 | ||
| 2670 | 0 | switch(enum_op) |
| 2671 | { | |
| 2672 | case JSENUMERATE_INIT: | |
| 2673 | ||
| 2674 | 0 | *statep = INT_TO_JSVAL(i); |
| 2675 | 0 | if(idp) |
| 2676 | { | |
| 2677 | 0 | *idp = JSVAL_ZERO; |
| 2678 | } | |
| 2679 | 0 | break; |
| 2680 | ||
| 2681 | case JSENUMERATE_NEXT: | |
| 2682 | ||
| 2683 | 0 | index = JSVAL_TO_INT(*statep); |
| 2684 | 0 | for(; i < index && schemaType; ++i) |
| 2685 | { | |
| 2686 | 0 | schemaType = schemaType->next; |
| 2687 | } | |
| 2688 | ||
| 2689 | 0 | if(!schemaType) |
| 2690 | { | |
| 2691 | 0 | *statep = JSVAL_NULL; |
| 2692 | 0 | *idp = JSVAL_ZERO; |
| 2693 | 0 | break; |
| 2694 | } | |
| 2695 | ||
| 2696 | 0 | *idp = *statep; |
| 2697 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 2698 | ||
| 2699 | break; | |
| 2700 | ||
| 2701 | case JSENUMERATE_DESTROY: | |
| 2702 | ||
| 2703 | 0 | break; |
| 2704 | } | |
| 2705 | ||
| 2706 | 0 | GlobusWSDLDebugExit(); |
| 2707 | 0 | return res; |
| 2708 | } | |
| 2709 | ||
| 2710 | static | |
| 2711 | JSBool | |
| 2712 | xsdAttrsEnumerate( | |
| 2713 | JSContext * cx, | |
| 2714 | JSObject * obj, | |
| 2715 | JSIterateOp enum_op, | |
| 2716 | jsval * statep, | |
| 2717 | jsid * idp) | |
| 2718 | 0 | { |
| 2719 | 0 | JSBool res = JS_TRUE; |
| 2720 | 0 | xmlSchemaAttributePtr schemaAttribute; |
| 2721 | 0 | int i = 0; |
| 2722 | 0 | int index; |
| 2723 | 0 | GlobusFuncName(xsdAttrsEnumerate); |
| 2724 | 0 | GlobusWSDLDebugEnter(); |
| 2725 | ||
| 2726 | 0 | schemaAttribute = (xmlSchemaAttributePtr) JS_GetPrivate(cx, obj); |
| 2727 | 0 | globus_assert(schemaAttribute); |
| 2728 | ||
| 2729 | 0 | switch(enum_op) |
| 2730 | { | |
| 2731 | case JSENUMERATE_INIT: | |
| 2732 | ||
| 2733 | 0 | *statep = INT_TO_JSVAL(0); |
| 2734 | 0 | break; |
| 2735 | ||
| 2736 | case JSENUMERATE_NEXT: | |
| 2737 | ||
| 2738 | 0 | index = JSVAL_TO_INT(*statep); |
| 2739 | 0 | for(; i < index && schemaAttribute; ++i) |
| 2740 | { | |
| 2741 | 0 | schemaAttribute = schemaAttribute->next; |
| 2742 | } | |
| 2743 | ||
| 2744 | 0 | if(!schemaAttribute) |
| 2745 | { | |
| 2746 | 0 | *statep = JSVAL_NULL; |
| 2747 | 0 | *idp = JSVAL_ZERO; |
| 2748 | 0 | break; |
| 2749 | } | |
| 2750 | ||
| 2751 | 0 | *idp = *statep; |
| 2752 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 2753 | ||
| 2754 | break; | |
| 2755 | ||
| 2756 | case JSENUMERATE_DESTROY: | |
| 2757 | ||
| 2758 | 0 | break; |
| 2759 | } | |
| 2760 | ||
| 2761 | 0 | GlobusWSDLDebugExit(); |
| 2762 | 0 | return res; |
| 2763 | } | |
| 2764 | ||
| 2765 | static | |
| 2766 | JSBool | |
| 2767 | xsdFacetGetter( | |
| 2768 | JSContext * cx, | |
| 2769 | JSObject * obj, | |
| 2770 | jsval jid, | |
| 2771 | jsval * vp) | |
| 2772 | 0 | { |
| 2773 | 0 | int idval; |
| 2774 | 0 | JSString * str; |
| 2775 | 0 | xmlSchemaFacetPtr facet; |
| 2776 | 0 | JSBool res = JS_TRUE; |
| 2777 | 0 | GlobusFuncName(xsdFacetGetter); |
| 2778 | 0 | GlobusWSDLDebugEnter(); |
| 2779 | ||
| 2780 | 0 | facet = (xmlSchemaFacetPtr) JS_GetPrivate(cx, obj); |
| 2781 | 0 | globus_assert(facet); |
| 2782 | ||
| 2783 | 0 | if(!JSVAL_IS_INT(jid)) |
| 2784 | { | |
| 2785 | 0 | char * prop_name; |
| 2786 | ||
| 2787 | 0 | prop_name = JS_GetStringBytes(JSVAL_TO_STRING(jid)); |
| 2788 | 0 | JS_ReportError(cx, |
| 2789 | "Unknown property: .%s for facet", prop_name); | |
| 2790 | 0 | res = JS_FALSE; |
| 2791 | 0 | goto exit; |
| 2792 | } | |
| 2793 | ||
| 2794 | 0 | idval = JSVAL_TO_INT(jid); |
| 2795 | 0 | switch(idval) |
| 2796 | { | |
| 2797 | case type: | |
| 2798 | ||
| 2799 | 0 | *vp = INT_TO_JSVAL(facet->type); |
| 2800 | 0 | break; |
| 2801 | ||
| 2802 | case value: | |
| 2803 | 0 | str = NULL; |
| 2804 | ||
| 2805 | 0 | if(!facet->value) |
| 2806 | { | |
| 2807 | 0 | *vp = JSVAL_VOID; |
| 2808 | 0 | break; |
| 2809 | } | |
| 2810 | ||
| 2811 | 0 | if(facet->val != NULL && facet->val->type == XML_SCHEMAS_QNAME) |
| 2812 | { | |
| 2813 | 0 | xmlChar * local; |
| 2814 | 0 | xmlChar * prefix; |
| 2815 | 0 | xmlNsPtr ns; |
| 2816 | 0 | char * qn; |
| 2817 | ||
| 2818 | 0 | local = xmlSplitQName2(facet->val->value.qname.name, &prefix); |
| 2819 | ||
| 2820 | 0 | if (local != NULL) |
| 2821 | { | |
| 2822 | 0 | ns = xmlSearchNs(facet->node->doc, facet->node, prefix); |
| 2823 | 0 | qn = globus_common_create_string("%s#%s", |
| 2824 | (const char *) ns->href, | |
| 2825 | local); | |
| 2826 | ||
| 2827 | 0 | str = JS_InternString(cx, (const char *) qn); |
| 2828 | ||
| 2829 | 0 | xmlFree(local); |
| 2830 | 0 | xmlFree(prefix); |
| 2831 | } | |
| 2832 | } | |
| 2833 | ||
| 2834 | 0 | if (str == NULL) |
| 2835 | { | |
| 2836 | 0 | str = JS_InternString(cx, (const char *) facet->value); |
| 2837 | } | |
| 2838 | 0 | *vp = STRING_TO_JSVAL(str); |
| 2839 | 0 | break; |
| 2840 | ||
| 2841 | case id: | |
| 2842 | ||
| 2843 | 0 | *vp = INT_TO_JSVAL(facet->id); |
| 2844 | 0 | break; |
| 2845 | ||
| 2846 | case fixed: | |
| 2847 | ||
| 2848 | 0 | *vp = INT_TO_JSVAL(facet->fixed); |
| 2849 | 0 | break; |
| 2850 | ||
| 2851 | default: | |
| 2852 | ||
| 2853 | 0 | *vp = JSVAL_VOID; |
| 2854 | 0 | JS_ReportError(cx, "Unknown property for facet with id: %d", idval); |
| 2855 | 0 | res = JS_FALSE; |
| 2856 | } | |
| 2857 | ||
| 2858 | exit: | |
| 2859 | ||
| 2860 | 0 | GlobusWSDLDebugExit(); |
| 2861 | 0 | return res; |
| 2862 | } | |
| 2863 | ||
| 2864 | static | |
| 2865 | JSBool | |
| 2866 | xsdTypeGetter( | |
| 2867 | JSContext * cx, | |
| 2868 | JSObject * obj, | |
| 2869 | jsval jid, | |
| 2870 | jsval * vp) | |
| 2871 | 0 | { |
| 2872 | 0 | int idval; |
| 2873 | 0 | JSObject * subTypesObj; |
| 2874 | 0 | JSObject * attribObj; |
| 2875 | 0 | JSObject * typeObj; |
| 2876 | 0 | JSObject * wildcardObj; |
| 2877 | 0 | JSObject * facetsObj; |
| 2878 | 0 | JSString * str; |
| 2879 | 0 | xmlSchemaTypePtr xsdType; |
| 2880 | 0 | JSBool res = JS_TRUE; |
| 2881 | 0 | GlobusFuncName(xsdTypeGetter); |
| 2882 | 0 | GlobusWSDLDebugEnter(); |
| 2883 | ||
| 2884 | 0 | xsdType = (xmlSchemaTypePtr) JS_GetPrivate(cx, obj); |
| 2885 | 0 | globus_assert(xsdType); |
| 2886 | ||
| 2887 | 0 | if(!JSVAL_IS_INT(jid)) |
| 2888 | { | |
| 2889 | 0 | char * prop_name; |
| 2890 | ||
| 2891 | 0 | prop_name = JS_GetStringBytes(JSVAL_TO_STRING(jid)); |
| 2892 | 0 | JS_ReportError( |
| 2893 | cx, | |
| 2894 | "Unknown property: .%s for xsd:type element", prop_name); | |
| 2895 | 0 | res = JS_FALSE; |
| 2896 | 0 | goto exit; |
| 2897 | } | |
| 2898 | ||
| 2899 | 0 | idval = JSVAL_TO_INT(jid); |
| 2900 | 0 | switch(idval) |
| 2901 | { | |
| 2902 | case type: | |
| 2903 | ||
| 2904 | 0 | *vp = INT_TO_JSVAL(xsdType->type); |
| 2905 | 0 | break; |
| 2906 | ||
| 2907 | case name: | |
| 2908 | ||
| 2909 | 0 | if(!xsdType->name) |
| 2910 | { | |
| 2911 | 0 | *vp = JSVAL_VOID; |
| 2912 | 0 | break; |
| 2913 | } | |
| 2914 | ||
| 2915 | 0 | str = JS_InternString(cx, (const char *) xsdType->name); |
| 2916 | 0 | *vp = STRING_TO_JSVAL(str); |
| 2917 | 0 | break; |
| 2918 | ||
| 2919 | case id: | |
| 2920 | ||
| 2921 | 0 | *vp = INT_TO_JSVAL(xsdType->id); |
| 2922 | 0 | break; |
| 2923 | ||
| 2924 | case subtypes: | |
| 2925 | ||
| 2926 | 0 | if(!xsdType->subtypes) |
| 2927 | { | |
| 2928 | 0 | *vp = JSVAL_VOID; |
| 2929 | 0 | break; |
| 2930 | } | |
| 2931 | ||
| 2932 | 0 | subTypesObj = JS_NewObject(cx, &xsdSubTypes_class, NULL, obj); |
| 2933 | 0 | globus_assert(subTypesObj); |
| 2934 | 0 | JS_SetPrivate(cx, subTypesObj, xsdType->subtypes); |
| 2935 | ||
| 2936 | 0 | *vp = OBJECT_TO_JSVAL(subTypesObj); |
| 2937 | 0 | break; |
| 2938 | ||
| 2939 | case attributes: | |
| 2940 | ||
| 2941 | 0 | if(!xsdType->attributes) |
| 2942 | { | |
| 2943 | 0 | *vp = JSVAL_VOID; |
| 2944 | 0 | break; |
| 2945 | } | |
| 2946 | ||
| 2947 | 0 | attribObj = JS_NewObject(cx, &xsdAttrs_class, NULL, obj); |
| 2948 | 0 | globus_assert(attribObj); |
| 2949 | 0 | JS_SetPrivate(cx, attribObj, xsdType->attributes); |
| 2950 | ||
| 2951 | 0 | *vp = OBJECT_TO_JSVAL(attribObj); |
| 2952 | 0 | break; |
| 2953 | ||
| 2954 | case minOccurs: | |
| 2955 | ||
| 2956 | 0 | *vp = INT_TO_JSVAL(xsdType->minOccurs); |
| 2957 | 0 | break; |
| 2958 | ||
| 2959 | case maxOccurs: | |
| 2960 | ||
| 2961 | 0 | *vp = |
| 2962 | (xsdType->maxOccurs == GLOBUS_L_WSDL_JSCRIPT_UNBOUNDED) ? | |
| 2963 | JS_GetPositiveInfinityValue(cx) : | |
| 2964 | INT_TO_JSVAL(xsdType->maxOccurs); | |
| 2965 | 0 | break; |
| 2966 | ||
| 2967 | case ref: | |
| 2968 | ||
| 2969 | 0 | if(!xsdType->ref) |
| 2970 | { | |
| 2971 | 0 | *vp = JSVAL_VOID; |
| 2972 | 0 | break; |
| 2973 | } | |
| 2974 | ||
| 2975 | 0 | str = JS_InternString(cx, (const char *) xsdType->ref); |
| 2976 | 0 | *vp = STRING_TO_JSVAL(str); |
| 2977 | 0 | break; |
| 2978 | ||
| 2979 | case refNs: | |
| 2980 | ||
| 2981 | 0 | if(!xsdType->refNs) |
| 2982 | { | |
| 2983 | 0 | *vp = JSVAL_VOID; |
| 2984 | 0 | break; |
| 2985 | } | |
| 2986 | ||
| 2987 | 0 | str = JS_InternString(cx, (const char *) xsdType->refNs); |
| 2988 | 0 | *vp = STRING_TO_JSVAL(str); |
| 2989 | 0 | break; |
| 2990 | ||
| 2991 | case refQname: | |
| 2992 | ||
| 2993 | 0 | if(!xsdType->ref) |
| 2994 | { | |
| 2995 | 0 | *vp = JSVAL_VOID; |
| 2996 | 0 | break; |
| 2997 | } | |
| 2998 | 0 | else if(!xsdType->refNs) |
| 2999 | { | |
| 3000 | 0 | str = JS_InternString(cx, (const char *) xsdType->ref); |
| 3001 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3002 | 0 | break; |
| 3003 | } | |
| 3004 | else | |
| 3005 | { | |
| 3006 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3007 | cx, xsdType->refNs, xsdType->ref); | |
| 3008 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3009 | 0 | break; |
| 3010 | } | |
| 3011 | ||
| 3012 | case base: | |
| 3013 | ||
| 3014 | 0 | if(!xsdType->base) |
| 3015 | { | |
| 3016 | 0 | *vp = JSVAL_VOID; |
| 3017 | 0 | break; |
| 3018 | } | |
| 3019 | ||
| 3020 | 0 | if(xsdType->type == XML_SCHEMA_TYPE_UNION) |
| 3021 | { | |
| 3022 | 0 | char * memberTypes = NULL; |
| 3023 | 0 | int len = 0; |
| 3024 | 0 | int memberTypes_length = 1; |
| 3025 | 0 | xsdQNamePtr qnames, qn; |
| 3026 | ||
| 3027 | 0 | globus_i_wsdl_split_qnames(NULL, xsdType->node, xsdType->base, &qnames); |
| 3028 | 0 | qn = qnames; |
| 3029 | 0 | while(qn) |
| 3030 | { | |
| 3031 | 0 | len = strlen((const char *) qn->Namespace) + |
| 3032 | strlen((const char *) qn->name) + 2; | |
| 3033 | 0 | memberTypes = realloc(memberTypes, |
| 3034 | (sizeof(char) * len) + | |
| 3035 | memberTypes_length); | |
| 3036 | 0 | sprintf(memberTypes + memberTypes_length - 1, "%s#%s ", |
| 3037 | qn->Namespace, qn->name); | |
| 3038 | 0 | memberTypes_length += len; |
| 3039 | ||
| 3040 | 0 | qn = qn->next; |
| 3041 | } | |
| 3042 | ||
| 3043 | 0 | xsdQNameFree(qnames); |
| 3044 | ||
| 3045 | 0 | str = JS_InternString(cx, memberTypes); |
| 3046 | } | |
| 3047 | else | |
| 3048 | { | |
| 3049 | 0 | str = JS_InternString(cx, (const char *) xsdType->base); |
| 3050 | } | |
| 3051 | ||
| 3052 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3053 | 0 | break; |
| 3054 | ||
| 3055 | case baseNs: | |
| 3056 | ||
| 3057 | 0 | if(!xsdType->baseNs) |
| 3058 | { | |
| 3059 | 0 | *vp = JSVAL_VOID; |
| 3060 | 0 | break; |
| 3061 | } | |
| 3062 | ||
| 3063 | 0 | str = JS_InternString(cx, (const char *) xsdType->baseNs); |
| 3064 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3065 | 0 | break; |
| 3066 | ||
| 3067 | case baseQName: | |
| 3068 | ||
| 3069 | 0 | if(!xsdType->base) |
| 3070 | { | |
| 3071 | 0 | *vp = JSVAL_VOID; |
| 3072 | 0 | break; |
| 3073 | } | |
| 3074 | ||
| 3075 | 0 | if(!xsdType->baseNs) |
| 3076 | { | |
| 3077 | 0 | str = JS_InternString(cx, (const char *) xsdType->base); |
| 3078 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3079 | 0 | break; |
| 3080 | } | |
| 3081 | ||
| 3082 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3083 | cx, xsdType->baseNs, xsdType->base); | |
| 3084 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3085 | 0 | break; |
| 3086 | ||
| 3087 | case baseType: | |
| 3088 | ||
| 3089 | 0 | if(!xsdType->baseType) |
| 3090 | { | |
| 3091 | 0 | *vp = JSVAL_VOID; |
| 3092 | 0 | break; |
| 3093 | } | |
| 3094 | ||
| 3095 | 0 | typeObj = JS_NewObject(cx, &xsdType_class, xsdTypeClass, obj); |
| 3096 | 0 | globus_assert(typeObj); |
| 3097 | 0 | JS_SetPrivate(cx, typeObj, (void *)xsdType->baseType); |
| 3098 | 0 | JS_DefineProperties(cx, typeObj, xsdType_properties); |
| 3099 | 0 | *vp = OBJECT_TO_JSVAL(typeObj); |
| 3100 | 0 | break; |
| 3101 | ||
| 3102 | case targetNamespace: | |
| 3103 | ||
| 3104 | 0 | if(!xsdType->targetNamespace) |
| 3105 | { | |
| 3106 | 0 | *vp = JSVAL_VOID; |
| 3107 | 0 | break; |
| 3108 | } | |
| 3109 | ||
| 3110 | 0 | str = JS_InternString(cx, (const char *) xsdType->targetNamespace); |
| 3111 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3112 | 0 | break; |
| 3113 | ||
| 3114 | case qname: | |
| 3115 | ||
| 3116 | 0 | if(!xsdType->name) |
| 3117 | { | |
| 3118 | 0 | *vp = JSVAL_VOID; |
| 3119 | 0 | break; |
| 3120 | } | |
| 3121 | 0 | else if(!xsdType->targetNamespace) |
| 3122 | { | |
| 3123 | 0 | str = JS_InternString(cx, (const char *) xsdType->name); |
| 3124 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3125 | 0 | break; |
| 3126 | } | |
| 3127 | else | |
| 3128 | { | |
| 3129 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3130 | cx, xsdType->targetNamespace, xsdType->name); | |
| 3131 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3132 | 0 | break; |
| 3133 | } | |
| 3134 | ||
| 3135 | case attributeWildcard: | |
| 3136 | ||
| 3137 | 0 | if(!xsdType->attributeWildcard) |
| 3138 | { | |
| 3139 | 0 | *vp = JSVAL_VOID; |
| 3140 | 0 | break; |
| 3141 | } | |
| 3142 | ||
| 3143 | 0 | wildcardObj = JS_NewObject(cx, |
| 3144 | &xsdWildcard_class, | |
| 3145 | xsdWildcardClass, obj); | |
| 3146 | 0 | globus_assert(wildcardObj); |
| 3147 | 0 | JS_SetPrivate(cx, wildcardObj, (void *)xsdType->attributeWildcard); |
| 3148 | 0 | JS_DefineProperties(cx, wildcardObj, xsdWildcard_properties); |
| 3149 | 0 | *vp = OBJECT_TO_JSVAL(wildcardObj); |
| 3150 | 0 | break; |
| 3151 | ||
| 3152 | case facets: | |
| 3153 | ||
| 3154 | 0 | if(!xsdType->facets) |
| 3155 | { | |
| 3156 | 0 | *vp = JSVAL_VOID; |
| 3157 | 0 | break; |
| 3158 | } | |
| 3159 | ||
| 3160 | 0 | facetsObj = JS_NewObject(cx, &xsdFacets_class, NULL, obj); |
| 3161 | 0 | globus_assert(facets); |
| 3162 | 0 | JS_SetPrivate(cx, facetsObj, xsdType->facets); |
| 3163 | ||
| 3164 | 0 | *vp = OBJECT_TO_JSVAL(facetsObj); |
| 3165 | 0 | break; |
| 3166 | ||
| 3167 | case namedType: | |
| 3168 | ||
| 3169 | 0 | if(xsdType->type != XML_SCHEMA_TYPE_ELEMENT || |
| 3170 | !((xmlSchemaElementPtr)xsdType)->namedType) | |
| 3171 | { | |
| 3172 | 0 | *vp = JSVAL_VOID; |
| 3173 | 0 | break; |
| 3174 | } | |
| 3175 | ||
| 3176 | 0 | str = JS_InternString(cx, (const char *) ((xmlSchemaElementPtr)xsdType)->namedType); |
| 3177 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3178 | 0 | break; |
| 3179 | ||
| 3180 | case namedTypeNs: | |
| 3181 | ||
| 3182 | 0 | if(((xmlSchemaElementPtr)xsdType)->type != XML_SCHEMA_TYPE_ELEMENT || |
| 3183 | !((xmlSchemaElementPtr)xsdType)->namedTypeNs) | |
| 3184 | { | |
| 3185 | 0 | *vp = JSVAL_VOID; |
| 3186 | 0 | break; |
| 3187 | } | |
| 3188 | ||
| 3189 | 0 | str = JS_InternString(cx, |
| 3190 | (const char *) ((xmlSchemaElementPtr)xsdType)->namedTypeNs); | |
| 3191 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3192 | 0 | break; |
| 3193 | ||
| 3194 | case nillable: | |
| 3195 | 0 | if(((xmlSchemaElementPtr)xsdType)->flags & XML_SCHEMAS_ELEM_NILLABLE) |
| 3196 | { | |
| 3197 | 0 | *vp = JSVAL_TRUE; |
| 3198 | 0 | break; |
| 3199 | } | |
| 3200 | else | |
| 3201 | { | |
| 3202 | 0 | *vp = JSVAL_FALSE; |
| 3203 | } | |
| 3204 | 0 | break; |
| 3205 | ||
| 3206 | default: | |
| 3207 | ||
| 3208 | 0 | *vp = JSVAL_VOID; |
| 3209 | 0 | JS_ReportError(cx, "Unknown property for xsd type with id: %d", idval); |
| 3210 | 0 | res = JS_FALSE; |
| 3211 | } | |
| 3212 | ||
| 3213 | exit: | |
| 3214 | ||
| 3215 | 0 | GlobusWSDLDebugExit(); |
| 3216 | 0 | return res; |
| 3217 | } | |
| 3218 | ||
| 3219 | static | |
| 3220 | JSBool | |
| 3221 | xsdWildcardGetter( | |
| 3222 | JSContext * cx, | |
| 3223 | JSObject * obj, | |
| 3224 | jsval jid, | |
| 3225 | jsval * vp) | |
| 3226 | 0 | { |
| 3227 | 0 | int idval; |
| 3228 | 0 | xmlSchemaWildcardPtr xsdWildcard; |
| 3229 | 0 | JSBool res = JS_TRUE; |
| 3230 | 0 | GlobusFuncName(xsdWildcardGetter); |
| 3231 | 0 | GlobusWSDLDebugEnter(); |
| 3232 | ||
| 3233 | 0 | xsdWildcard = (xmlSchemaWildcardPtr) JS_GetPrivate(cx, obj); |
| 3234 | 0 | globus_assert(xsdWildcard); |
| 3235 | ||
| 3236 | 0 | if(!JSVAL_IS_INT(jid)) |
| 3237 | { | |
| 3238 | 0 | char * prop_name; |
| 3239 | ||
| 3240 | 0 | prop_name = JS_GetStringBytes(JSVAL_TO_STRING(jid)); |
| 3241 | 0 | JS_ReportError(cx, |
| 3242 | "Unknown property: .%s for wildcard", prop_name); | |
| 3243 | 0 | res = JS_FALSE; |
| 3244 | 0 | goto exit; |
| 3245 | } | |
| 3246 | ||
| 3247 | 0 | idval = JSVAL_TO_INT(jid); |
| 3248 | 0 | switch(idval) |
| 3249 | { | |
| 3250 | case type: | |
| 3251 | ||
| 3252 | 0 | *vp = INT_TO_JSVAL(xsdWildcard->type); |
| 3253 | 0 | break; |
| 3254 | ||
| 3255 | case id: | |
| 3256 | ||
| 3257 | 0 | *vp = INT_TO_JSVAL(xsdWildcard->id); |
| 3258 | 0 | break; |
| 3259 | ||
| 3260 | case minOccurs: | |
| 3261 | ||
| 3262 | 0 | *vp = INT_TO_JSVAL(xsdWildcard->minOccurs); |
| 3263 | 0 | break; |
| 3264 | ||
| 3265 | case maxOccurs: | |
| 3266 | ||
| 3267 | 0 | *vp = |
| 3268 | (xsdWildcard->maxOccurs == GLOBUS_L_WSDL_JSCRIPT_UNBOUNDED) ? | |
| 3269 | JS_GetPositiveInfinityValue(cx) : | |
| 3270 | INT_TO_JSVAL(xsdWildcard->maxOccurs); | |
| 3271 | 0 | break; |
| 3272 | ||
| 3273 | case any: | |
| 3274 | ||
| 3275 | 0 | *vp = INT_TO_JSVAL(xsdWildcard->any); |
| 3276 | 0 | break; |
| 3277 | ||
| 3278 | default: | |
| 3279 | ||
| 3280 | 0 | *vp = JSVAL_VOID; |
| 3281 | 0 | JS_ReportError(cx, |
| 3282 | "Unknown property for xsd " | |
| 3283 | "wildcard with id: %d", idval); | |
| 3284 | 0 | res = JS_FALSE; |
| 3285 | } | |
| 3286 | ||
| 3287 | exit: | |
| 3288 | ||
| 3289 | 0 | GlobusWSDLDebugExit(); |
| 3290 | 0 | return res; |
| 3291 | } | |
| 3292 | ||
| 3293 | static | |
| 3294 | JSBool | |
| 3295 | xsdAttrGetter( | |
| 3296 | JSContext * cx, | |
| 3297 | JSObject * obj, | |
| 3298 | jsval jid, | |
| 3299 | jsval * vp) | |
| 3300 | 0 | { |
| 3301 | 0 | int idval; |
| 3302 | 0 | xmlSchemaAttributePtr attr; |
| 3303 | 0 | JSBool res = JS_TRUE; |
| 3304 | 0 | JSObject * subTypesObj; |
| 3305 | 0 | JSObject * attribObj; |
| 3306 | 0 | JSString * str; |
| 3307 | 0 | JSObject * typeObj; |
| 3308 | 0 | GlobusFuncName(xsdAttrGetter); |
| 3309 | 0 | GlobusWSDLDebugEnter(); |
| 3310 | ||
| 3311 | 0 | attr = (xmlSchemaAttributePtr) JS_GetPrivate(cx, obj); |
| 3312 | 0 | globus_assert(attr); |
| 3313 | ||
| 3314 | 0 | if(!JSVAL_IS_INT(jid)) |
| 3315 | { | |
| 3316 | 0 | JS_ReportError(cx, |
| 3317 | "Invalid id for xsd attribute property, " | |
| 3318 | "expected int not string"); | |
| 3319 | 0 | res = JS_FALSE; |
| 3320 | 0 | goto exit; |
| 3321 | } | |
| 3322 | ||
| 3323 | ||
| 3324 | 0 | idval = JSVAL_TO_INT(jid); |
| 3325 | 0 | switch(idval) |
| 3326 | { | |
| 3327 | case type: | |
| 3328 | ||
| 3329 | 0 | *vp = INT_TO_JSVAL(attr->type); |
| 3330 | 0 | break; |
| 3331 | ||
| 3332 | case name: | |
| 3333 | ||
| 3334 | 0 | if(!attr->name) |
| 3335 | { | |
| 3336 | 0 | *vp = JSVAL_VOID; |
| 3337 | 0 | break; |
| 3338 | } | |
| 3339 | ||
| 3340 | 0 | str = JS_InternString(cx, (const char *) attr->name); |
| 3341 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3342 | 0 | break; |
| 3343 | ||
| 3344 | case id: | |
| 3345 | ||
| 3346 | 0 | *vp = INT_TO_JSVAL(attr->id); |
| 3347 | 0 | break; |
| 3348 | ||
| 3349 | case ref: | |
| 3350 | ||
| 3351 | 0 | if(!attr->ref) |
| 3352 | { | |
| 3353 | 0 | *vp = JSVAL_VOID; |
| 3354 | 0 | break; |
| 3355 | } | |
| 3356 | ||
| 3357 | 0 | str = JS_InternString(cx, (const char *) attr->ref); |
| 3358 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3359 | 0 | break; |
| 3360 | ||
| 3361 | case refNs: | |
| 3362 | ||
| 3363 | 0 | if(!attr->refNs) |
| 3364 | { | |
| 3365 | 0 | *vp = JSVAL_VOID; |
| 3366 | 0 | break; |
| 3367 | } | |
| 3368 | ||
| 3369 | 0 | str = JS_InternString(cx, (const char *) attr->refNs); |
| 3370 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3371 | 0 | break; |
| 3372 | ||
| 3373 | case refQname: | |
| 3374 | ||
| 3375 | 0 | if(!attr->ref) |
| 3376 | { | |
| 3377 | 0 | *vp = JSVAL_VOID; |
| 3378 | 0 | break; |
| 3379 | } | |
| 3380 | 0 | else if(!attr->refNs) |
| 3381 | { | |
| 3382 | 0 | str = JS_InternString(cx, (const char *) attr->ref); |
| 3383 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3384 | 0 | break; |
| 3385 | } | |
| 3386 | else | |
| 3387 | { | |
| 3388 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3389 | cx, attr->refNs, attr->ref); | |
| 3390 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3391 | 0 | break; |
| 3392 | } | |
| 3393 | ||
| 3394 | case typeName: | |
| 3395 | ||
| 3396 | 0 | if(!attr->typeName) |
| 3397 | { | |
| 3398 | 0 | *vp = JSVAL_VOID; |
| 3399 | 0 | break; |
| 3400 | } | |
| 3401 | ||
| 3402 | 0 | str = JS_InternString(cx, (const char *) attr->typeName); |
| 3403 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3404 | 0 | break; |
| 3405 | ||
| 3406 | case typeNs: | |
| 3407 | ||
| 3408 | 0 | if(!attr->typeNs) |
| 3409 | { | |
| 3410 | 0 | *vp = JSVAL_VOID; |
| 3411 | 0 | break; |
| 3412 | } | |
| 3413 | ||
| 3414 | 0 | str = JS_InternString(cx, (const char *) attr->typeNs); |
| 3415 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3416 | 0 | break; |
| 3417 | ||
| 3418 | case typeQname: | |
| 3419 | ||
| 3420 | 0 | if(!attr->typeName) |
| 3421 | { | |
| 3422 | 0 | *vp = JSVAL_VOID; |
| 3423 | 0 | break; |
| 3424 | } | |
| 3425 | ||
| 3426 | 0 | if(!attr->typeNs) |
| 3427 | { | |
| 3428 | 0 | str = JS_InternString(cx, (const char *) attr->typeNs); |
| 3429 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3430 | 0 | break; |
| 3431 | } | |
| 3432 | ||
| 3433 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3434 | cx, attr->typeNs, attr->typeName); | |
| 3435 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3436 | 0 | break; |
| 3437 | ||
| 3438 | case subtypes: | |
| 3439 | ||
| 3440 | 0 | if(!attr->subtypes) |
| 3441 | { | |
| 3442 | 0 | *vp = JSVAL_VOID; |
| 3443 | 0 | break; |
| 3444 | } | |
| 3445 | ||
| 3446 | 0 | subTypesObj = JS_NewObject(cx, &xsdSubTypes_class, NULL, obj); |
| 3447 | 0 | globus_assert(subTypesObj); |
| 3448 | 0 | JS_SetPrivate(cx, subTypesObj, attr->subtypes); |
| 3449 | ||
| 3450 | 0 | *vp = OBJECT_TO_JSVAL(subTypesObj); |
| 3451 | 0 | break; |
| 3452 | ||
| 3453 | case occurs: | |
| 3454 | ||
| 3455 | 0 | *vp = INT_TO_JSVAL(attr->occurs); |
| 3456 | 0 | break; |
| 3457 | ||
| 3458 | case base: | |
| 3459 | ||
| 3460 | 0 | if(!attr->base) |
| 3461 | { | |
| 3462 | 0 | *vp = JSVAL_VOID; |
| 3463 | 0 | break; |
| 3464 | } | |
| 3465 | ||
| 3466 | 0 | typeObj = JS_NewObject(cx, &xsdType_class, xsdTypeClass, obj); |
| 3467 | 0 | globus_assert(typeObj); |
| 3468 | 0 | JS_SetPrivate(cx, typeObj, (void *)attr->base); |
| 3469 | 0 | JS_DefineProperties(cx, typeObj, xsdType_properties); |
| 3470 | 0 | *vp = OBJECT_TO_JSVAL(typeObj); |
| 3471 | 0 | break; |
| 3472 | ||
| 3473 | case defValue: | |
| 3474 | ||
| 3475 | 0 | if(!attr->defValue) |
| 3476 | { | |
| 3477 | 0 | *vp = JSVAL_VOID; |
| 3478 | 0 | break; |
| 3479 | } | |
| 3480 | ||
| 3481 | 0 | str = JS_InternString(cx, (const char *) attr->defValue); |
| 3482 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3483 | 0 | break; |
| 3484 | ||
| 3485 | case targetNamespace: | |
| 3486 | ||
| 3487 | 0 | if(!attr->targetNamespace) |
| 3488 | { | |
| 3489 | 0 | str = JS_InternString(cx, (const char *) ""); |
| 3490 | } | |
| 3491 | else | |
| 3492 | { | |
| 3493 | 0 | str = JS_InternString(cx, (const char *) attr->targetNamespace); |
| 3494 | } | |
| 3495 | ||
| 3496 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3497 | 0 | break; |
| 3498 | ||
| 3499 | case qname: | |
| 3500 | ||
| 3501 | 0 | if(!attr->name) |
| 3502 | { | |
| 3503 | 0 | *vp = JSVAL_VOID; |
| 3504 | 0 | break; |
| 3505 | } | |
| 3506 | 0 | else if(!attr->targetNamespace) |
| 3507 | { | |
| 3508 | 0 | str = JS_InternString(cx, (const char *) attr->name); |
| 3509 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3510 | 0 | break; |
| 3511 | } | |
| 3512 | else | |
| 3513 | { | |
| 3514 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3515 | cx, attr->targetNamespace, attr->name); | |
| 3516 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3517 | 0 | break; |
| 3518 | } | |
| 3519 | ||
| 3520 | case attributes: | |
| 3521 | ||
| 3522 | 0 | if(attr->type != XML_SCHEMA_TYPE_ATTRIBUTEGROUP) |
| 3523 | { | |
| 3524 | 0 | *vp = JSVAL_VOID; |
| 3525 | 0 | break; |
| 3526 | } | |
| 3527 | ||
| 3528 | 0 | attribObj = JS_NewObject(cx, &xsdAttrs_class, NULL, obj); |
| 3529 | 0 | globus_assert(attribObj); |
| 3530 | ||
| 3531 | 0 | JS_SetPrivate(cx, attribObj, |
| 3532 | ((xmlSchemaAttributeGroupPtr)attr)->attributes); | |
| 3533 | ||
| 3534 | 0 | *vp = OBJECT_TO_JSVAL(attribObj); |
| 3535 | 0 | break; |
| 3536 | ||
| 3537 | default: | |
| 3538 | ||
| 3539 | 0 | *vp = JSVAL_VOID; |
| 3540 | 0 | JS_ReportError(cx, |
| 3541 | "Unknown property for xsd " | |
| 3542 | "attribute with id: %d", idval); | |
| 3543 | 0 | res = JS_FALSE; |
| 3544 | } | |
| 3545 | ||
| 3546 | exit: | |
| 3547 | ||
| 3548 | 0 | GlobusWSDLDebugExit(); |
| 3549 | 0 | return res; |
| 3550 | } | |
| 3551 | ||
| 3552 | static | |
| 3553 | JSBool | |
| 3554 | xsdElementGetter( | |
| 3555 | JSContext * cx, | |
| 3556 | JSObject * obj, | |
| 3557 | jsval jid, | |
| 3558 | jsval * vp) | |
| 3559 | 0 | { |
| 3560 | 0 | int idval; |
| 3561 | 0 | xmlSchemaElementPtr element; |
| 3562 | 0 | JSString * str; |
| 3563 | 0 | JSObject * attribObj; |
| 3564 | 0 | JSBool res = JS_TRUE; |
| 3565 | 0 | JSObject * subTypesObj; |
| 3566 | ||
| 3567 | 0 | GlobusFuncName(xsdElementGetter); |
| 3568 | 0 | GlobusWSDLDebugEnter(); |
| 3569 | ||
| 3570 | 0 | element = (xmlSchemaElementPtr) JS_GetPrivate(cx, obj); |
| 3571 | 0 | globus_assert(element); |
| 3572 | ||
| 3573 | 0 | if(!JSVAL_IS_INT(jid)) |
| 3574 | { | |
| 3575 | 0 | JS_ReportError(cx, |
| 3576 | "Invalid id type (expected int) for " | |
| 3577 | "xsd element property"); | |
| 3578 | 0 | res = JS_FALSE; |
| 3579 | 0 | goto exit; |
| 3580 | } | |
| 3581 | ||
| 3582 | ||
| 3583 | 0 | idval = JSVAL_TO_INT(jid); |
| 3584 | 0 | switch(idval) |
| 3585 | { | |
| 3586 | case type: | |
| 3587 | ||
| 3588 | 0 | *vp = INT_TO_JSVAL(element->type); |
| 3589 | 0 | break; |
| 3590 | ||
| 3591 | case name: | |
| 3592 | ||
| 3593 | 0 | if(!element->name) |
| 3594 | { | |
| 3595 | 0 | *vp = JSVAL_VOID; |
| 3596 | 0 | break; |
| 3597 | } | |
| 3598 | ||
| 3599 | 0 | str = JS_InternString(cx, (const char *) element->name); |
| 3600 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3601 | 0 | break; |
| 3602 | ||
| 3603 | case id: | |
| 3604 | ||
| 3605 | 0 | *vp = INT_TO_JSVAL(element->id); |
| 3606 | 0 | break; |
| 3607 | ||
| 3608 | case subtypes: | |
| 3609 | ||
| 3610 | 0 | if(!element->subtypes) |
| 3611 | { | |
| 3612 | 0 | *vp = JSVAL_VOID; |
| 3613 | 0 | break; |
| 3614 | } | |
| 3615 | ||
| 3616 | 0 | subTypesObj = JS_NewObject(cx, &xsdSubTypes_class, NULL, obj); |
| 3617 | 0 | globus_assert(subTypesObj); |
| 3618 | ||
| 3619 | 0 | JS_SetPrivate(cx, subTypesObj, element->subtypes); |
| 3620 | ||
| 3621 | 0 | *vp = OBJECT_TO_JSVAL(subTypesObj); |
| 3622 | 0 | break; |
| 3623 | ||
| 3624 | case attributes: | |
| 3625 | ||
| 3626 | 0 | if(!element->attributes) |
| 3627 | { | |
| 3628 | 0 | *vp = JSVAL_VOID; |
| 3629 | 0 | break; |
| 3630 | } | |
| 3631 | ||
| 3632 | 0 | attribObj = JS_NewObject(cx, &xsdAttrs_class, NULL, obj); |
| 3633 | 0 | globus_assert(attribObj); |
| 3634 | ||
| 3635 | 0 | JS_SetPrivate(cx, attribObj, element->attributes); |
| 3636 | ||
| 3637 | 0 | *vp = OBJECT_TO_JSVAL(attribObj); |
| 3638 | 0 | break; |
| 3639 | ||
| 3640 | case minOccurs: | |
| 3641 | ||
| 3642 | 0 | *vp = INT_TO_JSVAL(element->minOccurs); |
| 3643 | 0 | break; |
| 3644 | ||
| 3645 | case maxOccurs: | |
| 3646 | ||
| 3647 | 0 | *vp = |
| 3648 | (element->maxOccurs == GLOBUS_L_WSDL_JSCRIPT_UNBOUNDED) ? | |
| 3649 | JS_GetPositiveInfinityValue(cx) : | |
| 3650 | INT_TO_JSVAL(element->maxOccurs); | |
| 3651 | 0 | break; |
| 3652 | ||
| 3653 | case ref: | |
| 3654 | ||
| 3655 | 0 | if(!element->ref) |
| 3656 | { | |
| 3657 | 0 | *vp = JSVAL_VOID; |
| 3658 | 0 | break; |
| 3659 | } | |
| 3660 | ||
| 3661 | 0 | str = JS_InternString(cx, (const char *) element->ref); |
| 3662 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3663 | 0 | break; |
| 3664 | ||
| 3665 | case refNs: | |
| 3666 | ||
| 3667 | 0 | if(!element->refNs) |
| 3668 | { | |
| 3669 | 0 | *vp = JSVAL_VOID; |
| 3670 | 0 | break; |
| 3671 | } | |
| 3672 | ||
| 3673 | 0 | str = JS_InternString(cx, (const char *) element->refNs); |
| 3674 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3675 | 0 | break; |
| 3676 | ||
| 3677 | case refQname: | |
| 3678 | ||
| 3679 | 0 | if(!element->ref) |
| 3680 | { | |
| 3681 | 0 | *vp = JSVAL_VOID; |
| 3682 | 0 | break; |
| 3683 | } | |
| 3684 | 0 | else if(!element->refNs) |
| 3685 | { | |
| 3686 | 0 | str = JS_InternString(cx, (const char *) element->ref); |
| 3687 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3688 | 0 | break; |
| 3689 | } | |
| 3690 | else | |
| 3691 | { | |
| 3692 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3693 | cx, element->refNs, element->ref); | |
| 3694 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3695 | 0 | break; |
| 3696 | } | |
| 3697 | ||
| 3698 | case targetNamespace: | |
| 3699 | ||
| 3700 | 0 | if(!element->targetNamespace) |
| 3701 | { | |
| 3702 | 0 | str = JS_InternString(cx, (const char *) ""); |
| 3703 | } | |
| 3704 | else | |
| 3705 | { | |
| 3706 | 0 | str = JS_InternString(cx, (const char *) element->targetNamespace); |
| 3707 | } | |
| 3708 | ||
| 3709 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3710 | 0 | break; |
| 3711 | ||
| 3712 | case namedType: | |
| 3713 | ||
| 3714 | 0 | if(!element->namedType) |
| 3715 | { | |
| 3716 | 0 | *vp = JSVAL_VOID; |
| 3717 | 0 | break; |
| 3718 | } | |
| 3719 | ||
| 3720 | 0 | str = JS_InternString(cx, (const char *) element->namedType); |
| 3721 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3722 | 0 | break; |
| 3723 | ||
| 3724 | case namedTypeNs: | |
| 3725 | ||
| 3726 | 0 | if(!element->namedTypeNs) |
| 3727 | { | |
| 3728 | 0 | *vp = JSVAL_VOID; |
| 3729 | 0 | break; |
| 3730 | } | |
| 3731 | ||
| 3732 | 0 | str = JS_InternString(cx, (const char *) element->namedTypeNs); |
| 3733 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3734 | 0 | break; |
| 3735 | ||
| 3736 | case substGroup: | |
| 3737 | ||
| 3738 | 0 | if(!element->substGroup) |
| 3739 | { | |
| 3740 | 0 | *vp = JSVAL_VOID; |
| 3741 | 0 | break; |
| 3742 | } | |
| 3743 | ||
| 3744 | 0 | str = JS_InternString(cx, (const char *) element->substGroup); |
| 3745 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3746 | 0 | break; |
| 3747 | ||
| 3748 | case substGroupNs: | |
| 3749 | ||
| 3750 | 0 | if(!element->substGroupNs) |
| 3751 | { | |
| 3752 | 0 | *vp = JSVAL_VOID; |
| 3753 | 0 | break; |
| 3754 | } | |
| 3755 | ||
| 3756 | 0 | str = JS_InternString(cx, (const char *) element->substGroupNs); |
| 3757 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3758 | 0 | break; |
| 3759 | ||
| 3760 | case contentType: | |
| 3761 | ||
| 3762 | 0 | *vp = INT_TO_JSVAL(element->contentType); |
| 3763 | 0 | break; |
| 3764 | ||
| 3765 | case qname: | |
| 3766 | ||
| 3767 | 0 | if(!element->name) |
| 3768 | { | |
| 3769 | 0 | *vp = JSVAL_VOID; |
| 3770 | 0 | break; |
| 3771 | } | |
| 3772 | 0 | else if(!element->targetNamespace) |
| 3773 | { | |
| 3774 | 0 | str = JS_InternString(cx, (const char *) element->name); |
| 3775 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3776 | 0 | break; |
| 3777 | } | |
| 3778 | else | |
| 3779 | { | |
| 3780 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3781 | cx, element->targetNamespace, element->name); | |
| 3782 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3783 | 0 | break; |
| 3784 | } | |
| 3785 | ||
| 3786 | default: | |
| 3787 | ||
| 3788 | 0 | *vp = JSVAL_VOID; |
| 3789 | 0 | JS_ReportError(cx, "Unknown property with id %d for element", idval); |
| 3790 | 0 | res = JS_FALSE; |
| 3791 | goto exit; | |
| 3792 | } | |
| 3793 | ||
| 3794 | exit: | |
| 3795 | ||
| 3796 | 0 | GlobusWSDLDebugExit(); |
| 3797 | 0 | return res; |
| 3798 | } | |
| 3799 | ||
| 3800 | static | |
| 3801 | JSBool | |
| 3802 | messageGetter( | |
| 3803 | JSContext * cx, | |
| 3804 | JSObject * obj, | |
| 3805 | jsval jid, | |
| 3806 | jsval * vp) | |
| 3807 | 0 | { |
| 3808 | 0 | JSBool res = JS_TRUE; |
| 3809 | 0 | int idval; |
| 3810 | 0 | JSString * str = NULL; |
| 3811 | 0 | JSObject * partsObj = NULL; |
| 3812 | 0 | wsdlMessagePtr message = NULL; |
| 3813 | 0 | GlobusFuncName(messageGetter); |
| 3814 | 0 | GlobusWSDLDebugEnter(); |
| 3815 | ||
| 3816 | 0 | message = (wsdlMessagePtr) JS_GetPrivate(cx, obj); |
| 3817 | 0 | globus_assert(message); |
| 3818 | ||
| 3819 | 0 | if(!JSVAL_IS_INT(jid)) |
| 3820 | { | |
| 3821 | 0 | JS_ReportError(cx, |
| 3822 | "Invalid id type (expected int) for " | |
| 3823 | "wsdl element property"); | |
| 3824 | 0 | res = JS_FALSE; |
| 3825 | 0 | goto exit; |
| 3826 | } | |
| 3827 | ||
| 3828 | ||
| 3829 | 0 | idval = JSVAL_TO_INT(jid); |
| 3830 | 0 | switch(idval) |
| 3831 | { | |
| 3832 | ||
| 3833 | case name: | |
| 3834 | ||
| 3835 | 0 | if(!message->name) |
| 3836 | { | |
| 3837 | 0 | *vp = JSVAL_VOID; |
| 3838 | 0 | break; |
| 3839 | } | |
| 3840 | ||
| 3841 | 0 | str = JS_InternString(cx, (const char *) message->name); |
| 3842 | 0 | globus_assert(str); |
| 3843 | ||
| 3844 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3845 | 0 | break; |
| 3846 | ||
| 3847 | case parts: | |
| 3848 | ||
| 3849 | 0 | if(!message->parts) |
| 3850 | { | |
| 3851 | 0 | *vp = JSVAL_VOID; |
| 3852 | 0 | break; |
| 3853 | } | |
| 3854 | ||
| 3855 | 0 | partsObj = JS_NewObject(cx, &parts_class, NULL, obj); |
| 3856 | 0 | globus_assert(partsObj); |
| 3857 | ||
| 3858 | 0 | JS_SetPrivate(cx, partsObj, (void *) message->parts); |
| 3859 | ||
| 3860 | 0 | *vp = OBJECT_TO_JSVAL(partsObj); |
| 3861 | 0 | break; |
| 3862 | ||
| 3863 | case targetNamespace: | |
| 3864 | ||
| 3865 | 0 | if(!message->schema || !message->schema->targetNamespace) |
| 3866 | { | |
| 3867 | 0 | *vp = JSVAL_VOID; |
| 3868 | 0 | break; |
| 3869 | } | |
| 3870 | ||
| 3871 | 0 | str = JS_InternString(cx, |
| 3872 | (const char *) message->schema->targetNamespace); | |
| 3873 | 0 | globus_assert(str); |
| 3874 | ||
| 3875 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3876 | 0 | break; |
| 3877 | ||
| 3878 | default: | |
| 3879 | ||
| 3880 | 0 | *vp = JSVAL_VOID; |
| 3881 | 0 | JS_ReportError(cx, |
| 3882 | "Unknown message property with " | |
| 3883 | "id %d for element", idval); | |
| 3884 | 0 | res = JS_FALSE; |
| 3885 | goto exit; | |
| 3886 | } | |
| 3887 | ||
| 3888 | exit: | |
| 3889 | ||
| 3890 | 0 | GlobusWSDLDebugExit(); |
| 3891 | 0 | return res; |
| 3892 | } | |
| 3893 | ||
| 3894 | #include "wsdlInternals.h" | |
| 3895 | ||
| 3896 | static | |
| 3897 | JSBool | |
| 3898 | xsdQNamesGetter( | |
| 3899 | JSContext * cx, | |
| 3900 | JSObject * obj, | |
| 3901 | jsval id, | |
| 3902 | jsval * vp) | |
| 3903 | 0 | { |
| 3904 | 0 | xsdQNamePtr qn; |
| 3905 | 0 | JSObject * qnObj; |
| 3906 | 0 | JSBool res = JS_TRUE; |
| 3907 | 0 | JSString * str; |
| 3908 | 0 | int i = 0; |
| 3909 | 0 | GlobusFuncName(xsdQNamesGetter); |
| 3910 | 0 | GlobusWSDLDebugEnter(); |
| 3911 | ||
| 3912 | 0 | qn = (xsdQNamePtr) JS_GetPrivate(cx, obj); |
| 3913 | 0 | globus_assert(qn); |
| 3914 | ||
| 3915 | 0 | if(JSVAL_IS_STRING(id)) |
| 3916 | { | |
| 3917 | 0 | while(qn) |
| 3918 | { | |
| 3919 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 3920 | cx, qn->Namespace, qn->name); | |
| 3921 | 0 | *vp = STRING_TO_JSVAL(str); |
| 3922 | 0 | if(JS_CompareStrings(str, JSVAL_TO_STRING(id))) |
| 3923 | { | |
| 3924 | 0 | break; |
| 3925 | } | |
| 3926 | ||
| 3927 | 0 | qn = qn->next; |
| 3928 | } | |
| 3929 | } | |
| 3930 | 0 | else if(JSVAL_IS_INT(id)) |
| 3931 | { | |
| 3932 | 0 | for(; i < JSVAL_TO_INT(id) && type; ++i) |
| 3933 | { | |
| 3934 | 0 | qn = qn->next; |
| 3935 | } | |
| 3936 | 0 | globus_assert(qn); |
| 3937 | } | |
| 3938 | else | |
| 3939 | { | |
| 3940 | 0 | qn = (xsdQNamePtr) JSVAL_TO_PRIVATE(id); |
| 3941 | 0 | globus_assert(qn); |
| 3942 | } | |
| 3943 | ||
| 3944 | 0 | qnObj = JS_NewObject(cx, &xsdQName_class, |
| 3945 | xsdQNameClass, obj); | |
| 3946 | 0 | globus_assert(qnObj); |
| 3947 | 0 | JS_SetPrivate(cx, qnObj, (void *)qn); |
| 3948 | 0 | JS_DefineProperties(cx, qnObj, xsdQName_properties); |
| 3949 | 0 | *vp = OBJECT_TO_JSVAL(qnObj); |
| 3950 | ||
| 3951 | 0 | GlobusWSDLDebugExit(); |
| 3952 | 0 | return res; |
| 3953 | } | |
| 3954 | ||
| 3955 | static | |
| 3956 | JSBool | |
| 3957 | xsdQNamesEnumerate( | |
| 3958 | JSContext * cx, | |
| 3959 | JSObject * obj, | |
| 3960 | JSIterateOp enum_op, | |
| 3961 | jsval * statep, | |
| 3962 | jsid * idp) | |
| 3963 | 0 | { |
| 3964 | 0 | xsdQNamePtr qn = NULL; |
| 3965 | 0 | JSBool res = JS_TRUE; |
| 3966 | 0 | int i = 0; |
| 3967 | 0 | int index; |
| 3968 | 0 | GlobusFuncName(xsdQNameEnumerate); |
| 3969 | 0 | GlobusWSDLDebugEnter(); |
| 3970 | ||
| 3971 | 0 | qn = (xsdQNamePtr) JS_GetPrivate(cx, obj); |
| 3972 | 0 | globus_assert(qn); |
| 3973 | ||
| 3974 | 0 | switch(enum_op) |
| 3975 | { | |
| 3976 | case JSENUMERATE_INIT: | |
| 3977 | ||
| 3978 | 0 | *statep = INT_TO_JSVAL(0); |
| 3979 | 0 | if(idp) |
| 3980 | { | |
| 3981 | 0 | *idp = JSVAL_ZERO; |
| 3982 | } | |
| 3983 | 0 | break; |
| 3984 | ||
| 3985 | case JSENUMERATE_NEXT: | |
| 3986 | ||
| 3987 | 0 | index = JSVAL_TO_INT(*statep); |
| 3988 | 0 | for(; i < index && qn; ++i) |
| 3989 | { | |
| 3990 | 0 | qn = qn->next; |
| 3991 | } | |
| 3992 | ||
| 3993 | 0 | if(!qn) |
| 3994 | { | |
| 3995 | 0 | *statep = JSVAL_NULL; |
| 3996 | 0 | *idp = JSVAL_ZERO; |
| 3997 | 0 | break; |
| 3998 | } | |
| 3999 | ||
| 4000 | 0 | *idp = *statep; |
| 4001 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 4002 | ||
| 4003 | break; | |
| 4004 | ||
| 4005 | case JSENUMERATE_DESTROY: | |
| 4006 | ||
| 4007 | 0 | break; |
| 4008 | } | |
| 4009 | ||
| 4010 | 0 | GlobusWSDLDebugExit(); |
| 4011 | 0 | return res; |
| 4012 | } | |
| 4013 | ||
| 4014 | static | |
| 4015 | JSBool | |
| 4016 | xsdQNameGetter( | |
| 4017 | JSContext * cx, | |
| 4018 | JSObject * obj, | |
| 4019 | jsval jid, | |
| 4020 | jsval * vp) | |
| 4021 | 0 | { |
| 4022 | 0 | xsdQNamePtr qn; |
| 4023 | 0 | JSBool res = JS_TRUE; |
| 4024 | 0 | jsval idval; |
| 4025 | 0 | JSString * str; |
| 4026 | 0 | GlobusFuncName(portTypeGetter); |
| 4027 | 0 | GlobusWSDLDebugEnter(); |
| 4028 | ||
| 4029 | 0 | qn = (xsdQNamePtr) JS_GetPrivate(cx, obj); |
| 4030 | 0 | globus_assert(qn); |
| 4031 | ||
| 4032 | 0 | if(!JSVAL_IS_INT(jid)) |
| 4033 | { | |
| 4034 | 0 | JS_ReportError(cx, |
| 4035 | "Invalid id type (expected int) for " | |
| 4036 | "wsdl xsdQName property"); | |
| 4037 | 0 | res = JS_FALSE; |
| 4038 | 0 | goto exit; |
| 4039 | } | |
| 4040 | ||
| 4041 | 0 | idval = JSVAL_TO_INT(jid); |
| 4042 | 0 | switch(idval) |
| 4043 | { | |
| 4044 | case name: | |
| 4045 | ||
| 4046 | 0 | if(!qn->name) |
| 4047 | { | |
| 4048 | 0 | *vp = JSVAL_VOID; |
| 4049 | 0 | break; |
| 4050 | } | |
| 4051 | ||
| 4052 | 0 | str = JS_InternString(cx, (const char *) qn->name); |
| 4053 | 0 | if(!str) |
| 4054 | { | |
| 4055 | 0 | *vp = JSVAL_VOID; |
| 4056 | 0 | break; |
| 4057 | } | |
| 4058 | ||
| 4059 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4060 | 0 | break; |
| 4061 | ||
| 4062 | case Namespace: | |
| 4063 | ||
| 4064 | 0 | if(!qn->Namespace) |
| 4065 | { | |
| 4066 | 0 | *vp = JSVAL_VOID; |
| 4067 | 0 | break; |
| 4068 | } | |
| 4069 | ||
| 4070 | 0 | str = JS_InternString(cx, (const char *) qn->Namespace); |
| 4071 | 0 | if(!str) |
| 4072 | { | |
| 4073 | 0 | *vp = JSVAL_VOID; |
| 4074 | 0 | break; |
| 4075 | } | |
| 4076 | ||
| 4077 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4078 | 0 | break; |
| 4079 | ||
| 4080 | case qname: | |
| 4081 | ||
| 4082 | 0 | if(!qn->name) |
| 4083 | { | |
| 4084 | 0 | *vp = JSVAL_VOID; |
| 4085 | 0 | break; |
| 4086 | } | |
| 4087 | 0 | else if(!qn->Namespace) |
| 4088 | { | |
| 4089 | 0 | str = JS_InternString(cx, (const char *) qn->name); |
| 4090 | 0 | if(!str) |
| 4091 | { | |
| 4092 | 0 | *vp = JSVAL_VOID; |
| 4093 | 0 | break; |
| 4094 | } | |
| 4095 | ||
| 4096 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4097 | 0 | break; |
| 4098 | } | |
| 4099 | else | |
| 4100 | { | |
| 4101 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 4102 | cx, qn->Namespace, qn->name); | |
| 4103 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4104 | 0 | break; |
| 4105 | } | |
| 4106 | ||
| 4107 | default: | |
| 4108 | ||
| 4109 | 0 | *vp = JSVAL_VOID; |
| 4110 | 0 | JS_ReportError(cx, |
| 4111 | "Unknown xsdQName property " | |
| 4112 | "with id %d for element", idval); | |
| 4113 | 0 | res = JS_FALSE; |
| 4114 | goto exit; | |
| 4115 | } | |
| 4116 | ||
| 4117 | exit: | |
| 4118 | ||
| 4119 | 0 | GlobusWSDLDebugExit(); |
| 4120 | 0 | return res; |
| 4121 | } | |
| 4122 | ||
| 4123 | static | |
| 4124 | JSBool | |
| 4125 | portTypeGetter( | |
| 4126 | JSContext * cx, | |
| 4127 | JSObject * obj, | |
| 4128 | jsval jid, | |
| 4129 | jsval * vp) | |
| 4130 | 0 | { |
| 4131 | 0 | JSBool res = JS_TRUE; |
| 4132 | 0 | JSString * str = NULL; |
| 4133 | 0 | int idval; |
| 4134 | 0 | JSObject * operationsObj = NULL; |
| 4135 | 0 | JSObject * xsdQNamesObj = NULL; |
| 4136 | 0 | wsdlPortTypePtr portType = NULL; |
| 4137 | 0 | GlobusFuncName(portTypeGetter); |
| 4138 | 0 | GlobusWSDLDebugEnter(); |
| 4139 | ||
| 4140 | 0 | portType = (wsdlPortTypePtr) JS_GetPrivate(cx, obj); |
| 4141 | 0 | globus_assert(portType); |
| 4142 | ||
| 4143 | 0 | if(!JSVAL_IS_INT(jid)) |
| 4144 | { | |
| 4145 | 0 | JS_ReportError(cx, |
| 4146 | "Invalid id type (expected int) for " | |
| 4147 | "wsdl PortType property"); | |
| 4148 | 0 | res = JS_FALSE; |
| 4149 | 0 | goto exit; |
| 4150 | } | |
| 4151 | ||
| 4152 | 0 | idval = JSVAL_TO_INT(jid); |
| 4153 | 0 | switch(idval) |
| 4154 | { | |
| 4155 | case name: | |
| 4156 | ||
| 4157 | 0 | if(!portType->name) |
| 4158 | { | |
| 4159 | 0 | *vp = JSVAL_VOID; |
| 4160 | 0 | break; |
| 4161 | } | |
| 4162 | ||
| 4163 | 0 | str = JS_InternString(cx, (const char *) portType->name); |
| 4164 | 0 | if(!str) |
| 4165 | { | |
| 4166 | 0 | *vp = JSVAL_VOID; |
| 4167 | 0 | break; |
| 4168 | } | |
| 4169 | ||
| 4170 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4171 | 0 | break; |
| 4172 | ||
| 4173 | case operations: | |
| 4174 | ||
| 4175 | 0 | if(!portType->operations) |
| 4176 | { | |
| 4177 | 0 | *vp = JSVAL_VOID; |
| 4178 | 0 | break; |
| 4179 | } | |
| 4180 | ||
| 4181 | 0 | operationsObj = JS_NewObject(cx, &operations_class, NULL, obj); |
| 4182 | 0 | globus_assert(operationsObj); |
| 4183 | ||
| 4184 | 0 | JS_SetPrivate(cx, operationsObj, (void *) portType->operations); |
| 4185 | ||
| 4186 | 0 | *vp = OBJECT_TO_JSVAL(operationsObj); |
| 4187 | 0 | break; |
| 4188 | ||
| 4189 | case ResourceProperties: | |
| 4190 | ||
| 4191 | 0 | if(!portType->ResourceProperties) |
| 4192 | { | |
| 4193 | 0 | *vp = JSVAL_VOID; |
| 4194 | 0 | break; |
| 4195 | } | |
| 4196 | ||
| 4197 | 0 | xsdQNamesObj = JS_NewObject(cx, &xsdQNames_class, NULL, obj); |
| 4198 | 0 | globus_assert(xsdQNamesObj); |
| 4199 | ||
| 4200 | 0 | JS_SetPrivate(cx, xsdQNamesObj, (void *) portType->ResourceProperties); |
| 4201 | ||
| 4202 | 0 | *vp = OBJECT_TO_JSVAL(xsdQNamesObj); |
| 4203 | 0 | break; |
| 4204 | ||
| 4205 | case implements: | |
| 4206 | ||
| 4207 | 0 | if(!portType->implements) |
| 4208 | { | |
| 4209 | 0 | *vp = JSVAL_VOID; |
| 4210 | 0 | break; |
| 4211 | } | |
| 4212 | ||
| 4213 | 0 | xsdQNamesObj = JS_NewObject(cx, &xsdQNames_class, NULL, obj); |
| 4214 | 0 | globus_assert(xsdQNamesObj); |
| 4215 | ||
| 4216 | 0 | JS_SetPrivate(cx, xsdQNamesObj, (void *) portType->implements); |
| 4217 | ||
| 4218 | 0 | *vp = OBJECT_TO_JSVAL(xsdQNamesObj); |
| 4219 | 0 | break; |
| 4220 | ||
| 4221 | case targetNamespace: | |
| 4222 | ||
| 4223 | 0 | if(!portType->schema || !portType->schema->targetNamespace) |
| 4224 | { | |
| 4225 | 0 | *vp = JSVAL_VOID; |
| 4226 | 0 | break; |
| 4227 | } | |
| 4228 | ||
| 4229 | 0 | str = JS_InternString(cx, (const char *) portType->schema->targetNamespace); |
| 4230 | 0 | globus_assert(str); |
| 4231 | ||
| 4232 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4233 | 0 | break; |
| 4234 | ||
| 4235 | default: | |
| 4236 | ||
| 4237 | 0 | *vp = JSVAL_VOID; |
| 4238 | 0 | JS_ReportError(cx, |
| 4239 | "Unknown portType property " | |
| 4240 | "with id %d for element", idval); | |
| 4241 | 0 | res = JS_FALSE; |
| 4242 | goto exit; | |
| 4243 | } | |
| 4244 | ||
| 4245 | exit: | |
| 4246 | ||
| 4247 | 0 | GlobusWSDLDebugExit(); |
| 4248 | 0 | return res; |
| 4249 | } | |
| 4250 | ||
| 4251 | static | |
| 4252 | JSBool | |
| 4253 | bindingGetter( | |
| 4254 | JSContext * cx, | |
| 4255 | JSObject * obj, | |
| 4256 | jsval jid, | |
| 4257 | jsval * vp) | |
| 4258 | 0 | { |
| 4259 | 0 | JSBool res = JS_TRUE; |
| 4260 | 0 | int idval; |
| 4261 | 0 | JSString * str = NULL; |
| 4262 | 0 | JSObject * portTypeObj = NULL; |
| 4263 | 0 | JSObject * operationsObj = NULL; |
| 4264 | 0 | JSObject * soapBindingObj = NULL; |
| 4265 | 0 | wsdlBindingPtr binding = NULL; |
| 4266 | 0 | GlobusFuncName(bindingGetter); |
| 4267 | 0 | GlobusWSDLDebugEnter(); |
| 4268 | ||
| 4269 | 0 | binding = (wsdlBindingPtr) JS_GetPrivate(cx, obj); |
| 4270 | 0 | globus_assert(binding); |
| 4271 | ||
| 4272 | 0 | if(!JSVAL_IS_INT(jid)) |
| 4273 | { | |
| 4274 | 0 | JS_ReportError(cx, |
| 4275 | "Invalid id type (expected int) for " | |
| 4276 | "wsdl binding property"); | |
| 4277 | 0 | res = JS_FALSE; |
| 4278 | 0 | goto exit; |
| 4279 | } | |
| 4280 | ||
| 4281 | ||
| 4282 | 0 | idval = JSVAL_TO_INT(jid); |
| 4283 | 0 | switch(idval) |
| 4284 | { | |
| 4285 | case name: | |
| 4286 | ||
| 4287 | 0 | if(!binding->name) |
| 4288 | { | |
| 4289 | 0 | *vp = JSVAL_VOID; |
| 4290 | 0 | break; |
| 4291 | } | |
| 4292 | ||
| 4293 | 0 | str = JS_InternString(cx, (const char *) binding->name); |
| 4294 | 0 | if(!str) |
| 4295 | { | |
| 4296 | 0 | *vp = JSVAL_VOID; |
| 4297 | 0 | break; |
| 4298 | } | |
| 4299 | ||
| 4300 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4301 | 0 | break; |
| 4302 | ||
| 4303 | case type: | |
| 4304 | ||
| 4305 | 0 | if(!binding->type) |
| 4306 | { | |
| 4307 | 0 | *vp = JSVAL_VOID; |
| 4308 | 0 | break; |
| 4309 | } | |
| 4310 | ||
| 4311 | 0 | portTypeObj = JS_NewObject(cx, &portType_class, |
| 4312 | portTypeClass, obj); | |
| 4313 | 0 | globus_assert(portTypeObj); |
| 4314 | 0 | JS_SetPrivate(cx, portTypeObj, (void *)binding->type); |
| 4315 | 0 | JS_DefineProperties(cx, portTypeObj, portType_properties); |
| 4316 | 0 | *vp = OBJECT_TO_JSVAL(portTypeObj); |
| 4317 | 0 | break; |
| 4318 | ||
| 4319 | case operations: | |
| 4320 | ||
| 4321 | 0 | if(!binding->operations) |
| 4322 | { | |
| 4323 | 0 | *vp = JSVAL_VOID; |
| 4324 | 0 | break; |
| 4325 | } | |
| 4326 | ||
| 4327 | 0 | operationsObj = JS_NewObject(cx, &bindingOperations_class, |
| 4328 | NULL, obj); | |
| 4329 | 0 | globus_assert(operationsObj); |
| 4330 | 0 | JS_SetPrivate(cx, operationsObj, (void *)binding->operations); |
| 4331 | ||
| 4332 | 0 | *vp = OBJECT_TO_JSVAL(operationsObj); |
| 4333 | 0 | break; |
| 4334 | ||
| 4335 | case soap: | |
| 4336 | ||
| 4337 | 0 | if(!binding->extension || (binding->extensionType != SOAP_BINDING)) |
| 4338 | { | |
| 4339 | 0 | *vp = JSVAL_VOID; |
| 4340 | 0 | break; |
| 4341 | } | |
| 4342 | ||
| 4343 | 0 | soapBindingObj = JS_NewObject(cx, &soapBinding_class, |
| 4344 | soapBindingClass, obj); | |
| 4345 | 0 | globus_assert(soapBindingObj); |
| 4346 | 0 | JS_SetPrivate(cx, soapBindingObj, |
| 4347 | (void *)binding->extension); | |
| 4348 | 0 | JS_DefineProperties(cx, soapBindingObj, |
| 4349 | soapBinding_properties); | |
| 4350 | 0 | *vp = OBJECT_TO_JSVAL(soapBindingObj); |
| 4351 | 0 | break; |
| 4352 | ||
| 4353 | case extensionType: | |
| 4354 | ||
| 4355 | 0 | *vp = INT_TO_JSVAL(binding->extensionType); |
| 4356 | 0 | break; |
| 4357 | ||
| 4358 | case targetNamespace: | |
| 4359 | ||
| 4360 | 0 | if(!binding->schema || !binding->schema->targetNamespace) |
| 4361 | { | |
| 4362 | 0 | *vp = JSVAL_VOID; |
| 4363 | 0 | break; |
| 4364 | } | |
| 4365 | ||
| 4366 | 0 | str = JS_InternString(cx, (const char *) binding->schema->targetNamespace); |
| 4367 | 0 | globus_assert(str); |
| 4368 | ||
| 4369 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4370 | 0 | break; |
| 4371 | ||
| 4372 | default: | |
| 4373 | ||
| 4374 | 0 | *vp = JSVAL_VOID; |
| 4375 | 0 | JS_ReportError(cx, |
| 4376 | "Unknown property for binding " | |
| 4377 | "with id %d for element", idval); | |
| 4378 | 0 | res = JS_FALSE; |
| 4379 | goto exit; | |
| 4380 | } | |
| 4381 | ||
| 4382 | exit: | |
| 4383 | ||
| 4384 | 0 | GlobusWSDLDebugExit(); |
| 4385 | 0 | return res; |
| 4386 | } | |
| 4387 | ||
| 4388 | static | |
| 4389 | JSBool | |
| 4390 | bindingOperationsGetter( | |
| 4391 | JSContext * cx, | |
| 4392 | JSObject * obj, | |
| 4393 | jsval id, | |
| 4394 | jsval * vp) | |
| 4395 | 0 | { |
| 4396 | 0 | JSBool res = JS_TRUE; |
| 4397 | 0 | wsdlBindingOperationPtr bop; |
| 4398 | 0 | JSObject * bopObj; |
| 4399 | 0 | int i = 0; |
| 4400 | 0 | GlobusFuncName(bindingOperationsGetter); |
| 4401 | 0 | GlobusWSDLDebugEnter(); |
| 4402 | ||
| 4403 | 0 | bop = (wsdlBindingOperationPtr) JS_GetPrivate(cx, obj); |
| 4404 | 0 | globus_assert(bop); |
| 4405 | ||
| 4406 | 0 | if(JSVAL_IS_STRING(id)) |
| 4407 | { | |
| 4408 | 0 | while(bop) |
| 4409 | { | |
| 4410 | 0 | JSString * name; |
| 4411 | ||
| 4412 | 0 | name = JS_InternString(cx, (const char *) bop->name); |
| 4413 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 4414 | { | |
| 4415 | 0 | break; |
| 4416 | } | |
| 4417 | ||
| 4418 | 0 | bop = bop->next; |
| 4419 | } | |
| 4420 | } | |
| 4421 | 0 | else if(JSVAL_IS_INT(id)) |
| 4422 | { | |
| 4423 | 0 | for(; i < JSVAL_TO_INT(id) && bop; ++i) |
| 4424 | { | |
| 4425 | 0 | bop = bop->next; |
| 4426 | } | |
| 4427 | 0 | globus_assert(bop); |
| 4428 | } | |
| 4429 | else | |
| 4430 | { | |
| 4431 | 0 | bop = (wsdlBindingOperationPtr) JSVAL_TO_PRIVATE(id); |
| 4432 | 0 | globus_assert(bop); |
| 4433 | } | |
| 4434 | ||
| 4435 | 0 | bopObj = JS_NewObject(cx, &bindingOperation_class, |
| 4436 | bindingOperationClass, obj); | |
| 4437 | 0 | globus_assert(bopObj); |
| 4438 | 0 | JS_SetPrivate(cx, bopObj, (void *)bop); |
| 4439 | 0 | JS_DefineProperties(cx, bopObj, bindingOperation_properties); |
| 4440 | 0 | *vp = OBJECT_TO_JSVAL(bopObj); |
| 4441 | ||
| 4442 | 0 | GlobusWSDLDebugExit(); |
| 4443 | 0 | return res; |
| 4444 | } | |
| 4445 | ||
| 4446 | static | |
| 4447 | JSBool | |
| 4448 | bindingOperationsEnumerate( | |
| 4449 | JSContext * cx, | |
| 4450 | JSObject * obj, | |
| 4451 | JSIterateOp enum_op, | |
| 4452 | jsval * statep, | |
| 4453 | jsid * idp) | |
| 4454 | 0 | { |
| 4455 | 0 | JSBool res = JS_TRUE; |
| 4456 | 0 | wsdlBindingOperationPtr boperation; |
| 4457 | 0 | int i = 0; |
| 4458 | 0 | int index; |
| 4459 | 0 | GlobusFuncName(bindingOperationsEnumerate); |
| 4460 | 0 | GlobusWSDLDebugEnter(); |
| 4461 | ||
| 4462 | 0 | boperation = (wsdlBindingOperationPtr) JS_GetPrivate(cx, obj); |
| 4463 | 0 | globus_assert(boperation); |
| 4464 | ||
| 4465 | 0 | switch(enum_op) |
| 4466 | { | |
| 4467 | case JSENUMERATE_INIT: | |
| 4468 | ||
| 4469 | 0 | *statep = INT_TO_JSVAL(i); |
| 4470 | 0 | break; |
| 4471 | ||
| 4472 | case JSENUMERATE_NEXT: | |
| 4473 | ||
| 4474 | 0 | index = JSVAL_TO_INT(*statep); |
| 4475 | 0 | for(; i < index && boperation; ++i) |
| 4476 | { | |
| 4477 | 0 | boperation = boperation->next; |
| 4478 | } | |
| 4479 | ||
| 4480 | 0 | if(!boperation) |
| 4481 | { | |
| 4482 | 0 | *statep = JSVAL_NULL; |
| 4483 | 0 | *idp = JSVAL_ZERO; |
| 4484 | 0 | break; |
| 4485 | } | |
| 4486 | ||
| 4487 | 0 | *idp = *statep; |
| 4488 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 4489 | ||
| 4490 | break; | |
| 4491 | ||
| 4492 | case JSENUMERATE_DESTROY: | |
| 4493 | ||
| 4494 | 0 | break; |
| 4495 | } | |
| 4496 | ||
| 4497 | 0 | GlobusWSDLDebugExit(); |
| 4498 | 0 | return res; |
| 4499 | } | |
| 4500 | ||
| 4501 | static | |
| 4502 | JSBool | |
| 4503 | bindingOperationGetter( | |
| 4504 | JSContext * cx, | |
| 4505 | JSObject * obj, | |
| 4506 | jsval jid, | |
| 4507 | jsval * vp) | |
| 4508 | 0 | { |
| 4509 | 0 | int idval; |
| 4510 | 0 | JSString * str; |
| 4511 | 0 | JSBool res = JS_TRUE; |
| 4512 | 0 | JSObject * inObj = NULL; |
| 4513 | 0 | JSObject * outObj = NULL; |
| 4514 | 0 | JSObject * faultsObj = NULL; |
| 4515 | 0 | JSObject * soapObj = NULL; |
| 4516 | 0 | wsdlBindingOperationPtr bop = NULL; |
| 4517 | 0 | GlobusFuncName(bindingOperationGetter); |
| 4518 | 0 | GlobusWSDLDebugEnter(); |
| 4519 | ||
| 4520 | 0 | bop = (wsdlBindingOperationPtr) JS_GetPrivate(cx, obj); |
| 4521 | 0 | globus_assert(bop); |
| 4522 | ||
| 4523 | 0 | if(!JSVAL_IS_INT(jid)) |
| 4524 | { | |
| 4525 | 0 | JS_ReportError(cx, |
| 4526 | "Invalid id type (expected int) " | |
| 4527 | "for wsdl bindingOperation property"); | |
| 4528 | 0 | res = JS_FALSE; |
| 4529 | 0 | goto exit; |
| 4530 | } | |
| 4531 | ||
| 4532 | 0 | idval = JSVAL_TO_INT(jid); |
| 4533 | ||
| 4534 | 0 | switch(idval) |
| 4535 | { | |
| 4536 | case name: | |
| 4537 | ||
| 4538 | 0 | if(!bop->name) |
| 4539 | { | |
| 4540 | 0 | *vp = JSVAL_VOID; |
| 4541 | 0 | break; |
| 4542 | } | |
| 4543 | ||
| 4544 | 0 | str = JS_InternString(cx, (const char *) bop->name); |
| 4545 | 0 | globus_assert(str); |
| 4546 | ||
| 4547 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4548 | 0 | break; |
| 4549 | ||
| 4550 | case input: | |
| 4551 | ||
| 4552 | 0 | if(!bop->input || (bop->inputType != SOAP_BINDING)) |
| 4553 | { | |
| 4554 | 0 | *vp = JSVAL_VOID; |
| 4555 | 0 | break; |
| 4556 | } | |
| 4557 | ||
| 4558 | 0 | inObj = JS_NewObject(cx, &soapBindingParam_class, |
| 4559 | soapBindingParamClass, obj); | |
| 4560 | 0 | globus_assert(inObj); |
| 4561 | 0 | JS_SetPrivate(cx, inObj, (void *)bop->input); |
| 4562 | 0 | JS_DefineProperties(cx, inObj, soapBindingParam_properties); |
| 4563 | 0 | *vp = OBJECT_TO_JSVAL(inObj); |
| 4564 | 0 | break; |
| 4565 | ||
| 4566 | case output: | |
| 4567 | ||
| 4568 | 0 | if(!bop->output || (bop->outputType != SOAP_BINDING)) |
| 4569 | { | |
| 4570 | 0 | *vp = JSVAL_VOID; |
| 4571 | 0 | break; |
| 4572 | } | |
| 4573 | ||
| 4574 | 0 | outObj = JS_NewObject(cx, &soapBindingParam_class, |
| 4575 | soapBindingParamClass, obj); | |
| 4576 | 0 | globus_assert(outObj); |
| 4577 | 0 | JS_SetPrivate(cx, outObj, (void *)bop->output); |
| 4578 | 0 | JS_DefineProperties(cx, outObj, soapBindingParam_properties); |
| 4579 | 0 | *vp = OBJECT_TO_JSVAL(outObj); |
| 4580 | 0 | break; |
| 4581 | ||
| 4582 | case inputType: | |
| 4583 | ||
| 4584 | 0 | *vp = INT_TO_JSVAL(bop->inputType); |
| 4585 | 0 | break; |
| 4586 | ||
| 4587 | case outputType: | |
| 4588 | ||
| 4589 | 0 | *vp = INT_TO_JSVAL(bop->outputType); |
| 4590 | 0 | break; |
| 4591 | ||
| 4592 | case faults: | |
| 4593 | ||
| 4594 | 0 | if(!bop->faults) |
| 4595 | { | |
| 4596 | 0 | *vp = JSVAL_VOID; |
| 4597 | 0 | break; |
| 4598 | } | |
| 4599 | ||
| 4600 | 0 | faultsObj = JS_NewObject(cx, &bindingOperationFaults_class, |
| 4601 | NULL, obj); | |
| 4602 | 0 | globus_assert(faultsObj); |
| 4603 | 0 | JS_SetPrivate(cx, faultsObj, (void *) bop->faults); |
| 4604 | ||
| 4605 | 0 | *vp = OBJECT_TO_JSVAL(faultsObj); |
| 4606 | 0 | break; |
| 4607 | ||
| 4608 | case soap: | |
| 4609 | ||
| 4610 | 0 | if(!bop->extension || (bop->extensionType != SOAP_BINDING)) |
| 4611 | { | |
| 4612 | 0 | *vp = JSVAL_VOID; |
| 4613 | 0 | break; |
| 4614 | } | |
| 4615 | ||
| 4616 | 0 | soapObj = JS_NewObject(cx, &soapOperation_class, |
| 4617 | soapOperationClass, obj); | |
| 4618 | 0 | globus_assert(soapObj); |
| 4619 | 0 | JS_SetPrivate(cx, soapObj, (void *)bop->extension); |
| 4620 | 0 | JS_DefineProperties(cx, soapObj, soapOperation_properties); |
| 4621 | 0 | *vp = OBJECT_TO_JSVAL(soapObj); |
| 4622 | 0 | break; |
| 4623 | ||
| 4624 | default: | |
| 4625 | ||
| 4626 | 0 | *vp = JSVAL_VOID; |
| 4627 | 0 | JS_ReportError(cx, |
| 4628 | "Unknown binding operation property " | |
| 4629 | "with id %d for part", idval); | |
| 4630 | 0 | res = JS_FALSE; |
| 4631 | goto exit; | |
| 4632 | } | |
| 4633 | ||
| 4634 | exit: | |
| 4635 | ||
| 4636 | 0 | GlobusWSDLDebugExit(); |
| 4637 | 0 | return res; |
| 4638 | } | |
| 4639 | ||
| 4640 | static | |
| 4641 | JSBool | |
| 4642 | bindingOperationFaultsGetter( | |
| 4643 | JSContext * cx, | |
| 4644 | JSObject * obj, | |
| 4645 | jsval id, | |
| 4646 | jsval * vp) | |
| 4647 | 0 | { |
| 4648 | 0 | wsdlBindingOperationFaultPtr bopf; |
| 4649 | 0 | JSObject * bopfObj; |
| 4650 | 0 | JSBool res = JS_TRUE; |
| 4651 | 0 | int i = 0; |
| 4652 | 0 | GlobusFuncName(bindingOperationFaultsGetter); |
| 4653 | 0 | GlobusWSDLDebugEnter(); |
| 4654 | ||
| 4655 | 0 | bopf = (wsdlBindingOperationFaultPtr) JS_GetPrivate(cx, obj); |
| 4656 | 0 | globus_assert(bopf); |
| 4657 | ||
| 4658 | 0 | if(JSVAL_IS_STRING(id)) |
| 4659 | { | |
| 4660 | 0 | while(bopf) |
| 4661 | { | |
| 4662 | 0 | JSString * name; |
| 4663 | ||
| 4664 | 0 | name = JS_InternString(cx, (const char *) bopf->name); |
| 4665 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 4666 | { | |
| 4667 | 0 | break; |
| 4668 | } | |
| 4669 | ||
| 4670 | 0 | bopf = bopf->next; |
| 4671 | } | |
| 4672 | } | |
| 4673 | 0 | else if(JSVAL_IS_INT(id)) |
| 4674 | { | |
| 4675 | 0 | for(; i < JSVAL_TO_INT(id) && bopf; ++i) |
| 4676 | { | |
| 4677 | 0 | bopf = bopf->next; |
| 4678 | } | |
| 4679 | 0 | globus_assert(bopf); |
| 4680 | } | |
| 4681 | else | |
| 4682 | { | |
| 4683 | 0 | bopf = (wsdlBindingOperationFaultPtr) JSVAL_TO_PRIVATE(id); |
| 4684 | 0 | globus_assert(bopf); |
| 4685 | } | |
| 4686 | ||
| 4687 | 0 | bopfObj = JS_NewObject(cx, &bindingOperationFault_class, |
| 4688 | bindingOperationFaultClass, obj); | |
| 4689 | 0 | globus_assert(bopfObj); |
| 4690 | 0 | JS_SetPrivate(cx, bopfObj, (void *)bopf); |
| 4691 | 0 | JS_DefineProperties(cx, bopfObj, |
| 4692 | bindingOperationFault_properties); | |
| 4693 | ||
| 4694 | 0 | *vp = OBJECT_TO_JSVAL(bopfObj); |
| 4695 | ||
| 4696 | 0 | GlobusWSDLDebugExit(); |
| 4697 | 0 | return res; |
| 4698 | } | |
| 4699 | ||
| 4700 | static | |
| 4701 | JSBool | |
| 4702 | bindingOperationFaultsEnumerate( | |
| 4703 | JSContext * cx, | |
| 4704 | JSObject * obj, | |
| 4705 | JSIterateOp enum_op, | |
| 4706 | jsval * statep, | |
| 4707 | jsid * idp) | |
| 4708 | 0 | { |
| 4709 | 0 | JSBool res = JS_TRUE; |
| 4710 | 0 | wsdlBindingOperationFaultPtr bopf; |
| 4711 | 0 | int i = 0; |
| 4712 | 0 | int index; |
| 4713 | 0 | GlobusFuncName(bindingOperationFaultsEnumerate); |
| 4714 | 0 | GlobusWSDLDebugEnter(); |
| 4715 | ||
| 4716 | 0 | bopf = (wsdlBindingOperationFaultPtr) JS_GetPrivate(cx, obj); |
| 4717 | 0 | globus_assert(bopf); |
| 4718 | ||
| 4719 | 0 | switch(enum_op) |
| 4720 | { | |
| 4721 | case JSENUMERATE_INIT: | |
| 4722 | ||
| 4723 | 0 | *statep = INT_TO_JSVAL(i); |
| 4724 | 0 | break; |
| 4725 | ||
| 4726 | case JSENUMERATE_NEXT: | |
| 4727 | ||
| 4728 | 0 | index = JSVAL_TO_INT(*statep); |
| 4729 | 0 | for(; i < index && bopf; ++i) |
| 4730 | { | |
| 4731 | 0 | bopf = bopf->next; |
| 4732 | } | |
| 4733 | ||
| 4734 | 0 | if(!bopf) |
| 4735 | { | |
| 4736 | 0 | *statep = JSVAL_NULL; |
| 4737 | 0 | *idp = JSVAL_ZERO; |
| 4738 | 0 | break; |
| 4739 | } | |
| 4740 | ||
| 4741 | 0 | *idp = *statep; |
| 4742 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 4743 | ||
| 4744 | break; | |
| 4745 | ||
| 4746 | case JSENUMERATE_DESTROY: | |
| 4747 | ||
| 4748 | 0 | break; |
| 4749 | } | |
| 4750 | ||
| 4751 | 0 | GlobusWSDLDebugExit(); |
| 4752 | 0 | return res; |
| 4753 | } | |
| 4754 | ||
| 4755 | static | |
| 4756 | JSBool | |
| 4757 | bindingOperationFaultGetter( | |
| 4758 | JSContext * cx, | |
| 4759 | JSObject * obj, | |
| 4760 | jsval jid, | |
| 4761 | jsval * vp) | |
| 4762 | 0 | { |
| 4763 | 0 | int idval; |
| 4764 | 0 | JSString * str = NULL; |
| 4765 | 0 | JSBool res = JS_TRUE; |
| 4766 | 0 | wsdlBindingOperationFaultPtr bopf = NULL; |
| 4767 | 0 | JSObject * soapObj = NULL; |
| 4768 | 0 | GlobusFuncName(bindingOperationFaultGetter); |
| 4769 | 0 | GlobusWSDLDebugEnter(); |
| 4770 | ||
| 4771 | 0 | bopf = (wsdlBindingOperationFaultPtr) JS_GetPrivate(cx, obj); |
| 4772 | 0 | globus_assert(bopf); |
| 4773 | ||
| 4774 | 0 | if(!JSVAL_IS_INT(jid)) |
| 4775 | { | |
| 4776 | 0 | JS_ReportError(cx, |
| 4777 | "Invalid id type (expected int) " | |
| 4778 | "for wsdl bindingOperationFault property"); | |
| 4779 | 0 | res = JS_FALSE; |
| 4780 | 0 | goto exit; |
| 4781 | } | |
| 4782 | ||
| 4783 | 0 | idval = JSVAL_TO_INT(jid); |
| 4784 | ||
| 4785 | 0 | switch(idval) |
| 4786 | { | |
| 4787 | case name: | |
| 4788 | ||
| 4789 | 0 | if(!bopf->name) |
| 4790 | { | |
| 4791 | 0 | *vp = JSVAL_VOID; |
| 4792 | 0 | break; |
| 4793 | } | |
| 4794 | ||
| 4795 | 0 | str = JS_InternString(cx, (const char *) bopf->name); |
| 4796 | 0 | globus_assert(str); |
| 4797 | ||
| 4798 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4799 | 0 | break; |
| 4800 | ||
| 4801 | case soap: | |
| 4802 | ||
| 4803 | 0 | if(!bopf->extension || (bopf->extensionType != SOAP_BINDING)) |
| 4804 | { | |
| 4805 | 0 | *vp = JSVAL_VOID; |
| 4806 | 0 | break; |
| 4807 | } | |
| 4808 | ||
| 4809 | 0 | soapObj = JS_NewObject(cx, &soapFault_class, soapFaultClass, obj); |
| 4810 | 0 | globus_assert(soapObj); |
| 4811 | 0 | JS_SetPrivate(cx, soapObj, bopf->extension); |
| 4812 | 0 | JS_DefineProperties(cx, soapObj, soapFault_properties); |
| 4813 | 0 | *vp = OBJECT_TO_JSVAL(soapObj); |
| 4814 | 0 | break; |
| 4815 | ||
| 4816 | default: | |
| 4817 | ||
| 4818 | 0 | *vp = JSVAL_VOID; |
| 4819 | 0 | JS_ReportError(cx, "Unknown part property with id %d for part", idval); |
| 4820 | 0 | res = JS_FALSE; |
| 4821 | goto exit; | |
| 4822 | } | |
| 4823 | ||
| 4824 | exit: | |
| 4825 | ||
| 4826 | 0 | GlobusWSDLDebugExit(); |
| 4827 | 0 | return res; |
| 4828 | } | |
| 4829 | ||
| 4830 | static | |
| 4831 | JSBool | |
| 4832 | partsEnumerate( | |
| 4833 | JSContext * cx, | |
| 4834 | JSObject * obj, | |
| 4835 | JSIterateOp enum_op, | |
| 4836 | jsval * statep, | |
| 4837 | jsid * idp) | |
| 4838 | 0 | { |
| 4839 | 0 | JSBool res = JS_TRUE; |
| 4840 | 0 | wsdlPartPtr parts; |
| 4841 | 0 | int i = 0; |
| 4842 | 0 | int index; |
| 4843 | 0 | GlobusFuncName(partsEnumerate); |
| 4844 | 0 | GlobusWSDLDebugEnter(); |
| 4845 | ||
| 4846 | 0 | parts = (wsdlPartPtr) JS_GetPrivate(cx, obj); |
| 4847 | 0 | globus_assert(parts); |
| 4848 | ||
| 4849 | 0 | switch(enum_op) |
| 4850 | { | |
| 4851 | case JSENUMERATE_INIT: | |
| 4852 | ||
| 4853 | 0 | *statep = INT_TO_JSVAL(i); |
| 4854 | 0 | break; |
| 4855 | ||
| 4856 | case JSENUMERATE_NEXT: | |
| 4857 | ||
| 4858 | 0 | index = JSVAL_TO_INT(*statep); |
| 4859 | 0 | for(; i < index && parts; ++i) |
| 4860 | { | |
| 4861 | 0 | parts = parts->next; |
| 4862 | } | |
| 4863 | ||
| 4864 | 0 | if(!parts) |
| 4865 | { | |
| 4866 | 0 | *statep = JSVAL_NULL; |
| 4867 | 0 | *idp = JSVAL_ZERO; |
| 4868 | 0 | break; |
| 4869 | } | |
| 4870 | ||
| 4871 | 0 | *idp = *statep; |
| 4872 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 4873 | ||
| 4874 | break; | |
| 4875 | ||
| 4876 | case JSENUMERATE_DESTROY: | |
| 4877 | ||
| 4878 | 0 | break; |
| 4879 | } | |
| 4880 | ||
| 4881 | 0 | GlobusWSDLDebugExit(); |
| 4882 | 0 | return res; |
| 4883 | } | |
| 4884 | ||
| 4885 | static | |
| 4886 | JSBool | |
| 4887 | partsGetter( | |
| 4888 | JSContext * cx, | |
| 4889 | JSObject * obj, | |
| 4890 | jsval id, | |
| 4891 | jsval * vp) | |
| 4892 | 0 | { |
| 4893 | 0 | wsdlPartPtr part = NULL; |
| 4894 | 0 | JSObject * partObj = NULL; |
| 4895 | 0 | JSBool res = JS_TRUE; |
| 4896 | 0 | int i = 0; |
| 4897 | 0 | GlobusFuncName(partsGetter); |
| 4898 | 0 | GlobusWSDLDebugEnter(); |
| 4899 | ||
| 4900 | 0 | part = (wsdlPartPtr) JS_GetPrivate(cx, obj); |
| 4901 | 0 | globus_assert(part); |
| 4902 | ||
| 4903 | 0 | if(JSVAL_IS_STRING(id)) |
| 4904 | { | |
| 4905 | 0 | while(part) |
| 4906 | { | |
| 4907 | 0 | JSString * name; |
| 4908 | ||
| 4909 | 0 | name = JS_InternString(cx, (const char *) part->name); |
| 4910 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 4911 | { | |
| 4912 | 0 | break; |
| 4913 | } | |
| 4914 | ||
| 4915 | 0 | part = part->next; |
| 4916 | } | |
| 4917 | } | |
| 4918 | 0 | else if(JSVAL_IS_INT(id)) |
| 4919 | { | |
| 4920 | 0 | for(; i < JSVAL_TO_INT(id) && part; ++i) |
| 4921 | { | |
| 4922 | 0 | part = part->next; |
| 4923 | } | |
| 4924 | 0 | globus_assert(part); |
| 4925 | } | |
| 4926 | ||
| 4927 | 0 | partObj = JS_NewObject(cx, &part_class, |
| 4928 | partClass, obj); | |
| 4929 | 0 | globus_assert(partObj); |
| 4930 | 0 | JS_SetPrivate(cx, partObj, (void *)part); |
| 4931 | 0 | JS_DefineProperties(cx, partObj, part_properties); |
| 4932 | ||
| 4933 | 0 | *vp = OBJECT_TO_JSVAL(partObj); |
| 4934 | ||
| 4935 | 0 | GlobusWSDLDebugExit(); |
| 4936 | 0 | return res; |
| 4937 | } | |
| 4938 | ||
| 4939 | static | |
| 4940 | JSBool | |
| 4941 | partGetter( | |
| 4942 | JSContext * cx, | |
| 4943 | JSObject * obj, | |
| 4944 | jsval jid, | |
| 4945 | jsval * vp) | |
| 4946 | 0 | { |
| 4947 | 0 | int idval; |
| 4948 | 0 | JSString * str = NULL; |
| 4949 | 0 | JSObject * typeObj = NULL; |
| 4950 | 0 | JSObject * elementObj = NULL; |
| 4951 | 0 | JSBool res = JS_TRUE; |
| 4952 | 0 | wsdlPartPtr part = NULL; |
| 4953 | 0 | GlobusFuncName(partGetter); |
| 4954 | 0 | GlobusWSDLDebugEnter(); |
| 4955 | ||
| 4956 | 0 | part = (wsdlPartPtr) JS_GetPrivate(cx, obj); |
| 4957 | 0 | globus_assert(part); |
| 4958 | ||
| 4959 | 0 | if(!JSVAL_IS_INT(jid)) |
| 4960 | { | |
| 4961 | 0 | JS_ReportError(cx, |
| 4962 | "Invalid id type (expected int) " | |
| 4963 | "for wsdl part property"); | |
| 4964 | 0 | res = JS_FALSE; |
| 4965 | 0 | goto exit; |
| 4966 | } | |
| 4967 | ||
| 4968 | 0 | idval = JSVAL_TO_INT(jid); |
| 4969 | ||
| 4970 | 0 | switch(idval) |
| 4971 | { | |
| 4972 | case name: | |
| 4973 | ||
| 4974 | 0 | if(!part->name) |
| 4975 | { | |
| 4976 | 0 | *vp = JSVAL_VOID; |
| 4977 | 0 | break; |
| 4978 | } | |
| 4979 | ||
| 4980 | 0 | str = JS_InternString(cx, (const char *) part->name); |
| 4981 | 0 | globus_assert(str); |
| 4982 | ||
| 4983 | 0 | *vp = STRING_TO_JSVAL(str); |
| 4984 | 0 | break; |
| 4985 | ||
| 4986 | case type: | |
| 4987 | ||
| 4988 | 0 | if(!part->type) |
| 4989 | { | |
| 4990 | 0 | *vp = JSVAL_VOID; |
| 4991 | 0 | break; |
| 4992 | } | |
| 4993 | ||
| 4994 | 0 | typeObj = JS_NewObject(cx, &xsdType_class, xsdTypeClass, obj); |
| 4995 | 0 | globus_assert(typeObj); |
| 4996 | 0 | JS_SetPrivate(cx, typeObj, (void *)part->type); |
| 4997 | 0 | JS_DefineProperties(cx, typeObj, xsdType_properties); |
| 4998 | 0 | *vp = OBJECT_TO_JSVAL(typeObj); |
| 4999 | 0 | break; |
| 5000 | ||
| 5001 | case element: | |
| 5002 | ||
| 5003 | 0 | if(!part->element) |
| 5004 | { | |
| 5005 | 0 | *vp = JSVAL_VOID; |
| 5006 | 0 | break; |
| 5007 | } | |
| 5008 | ||
| 5009 | 0 | elementObj = JS_NewObject(cx, &xsdElement_class, xsdElementClass, obj); |
| 5010 | 0 | globus_assert(elementObj); |
| 5011 | 0 | JS_SetPrivate(cx, elementObj, (void *)part->element); |
| 5012 | 0 | JS_DefineProperties(cx, elementObj, xsdElement_properties); |
| 5013 | 0 | *vp = OBJECT_TO_JSVAL(elementObj); |
| 5014 | 0 | break; |
| 5015 | ||
| 5016 | default: | |
| 5017 | ||
| 5018 | 0 | *vp = JSVAL_VOID; |
| 5019 | 0 | JS_ReportError(cx, "Unknown part property with id %d for part", idval); |
| 5020 | 0 | res = JS_FALSE; |
| 5021 | goto exit; | |
| 5022 | } | |
| 5023 | ||
| 5024 | exit: | |
| 5025 | ||
| 5026 | 0 | GlobusWSDLDebugExit(); |
| 5027 | 0 | return res; |
| 5028 | } | |
| 5029 | ||
| 5030 | static | |
| 5031 | JSBool | |
| 5032 | operationsGetter( | |
| 5033 | JSContext * cx, | |
| 5034 | JSObject * obj, | |
| 5035 | jsval id, | |
| 5036 | jsval * vp) | |
| 5037 | 0 | { |
| 5038 | 0 | wsdlOperationPtr operation; |
| 5039 | 0 | JSObject * operationObj; |
| 5040 | 0 | JSBool res = JS_TRUE; |
| 5041 | 0 | int i = 0; |
| 5042 | 0 | GlobusFuncName(operationsGetter); |
| 5043 | 0 | GlobusWSDLDebugEnter(); |
| 5044 | ||
| 5045 | 0 | operation = (wsdlOperationPtr) JS_GetPrivate(cx, obj); |
| 5046 | 0 | globus_assert(operation); |
| 5047 | ||
| 5048 | 0 | if(JSVAL_IS_STRING(id)) |
| 5049 | { | |
| 5050 | 0 | while(operation) |
| 5051 | { | |
| 5052 | 0 | JSString * name; |
| 5053 | ||
| 5054 | 0 | name = JS_InternString(cx, (const char *) operation->name); |
| 5055 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 5056 | { | |
| 5057 | 0 | break; |
| 5058 | } | |
| 5059 | ||
| 5060 | 0 | operation = operation->next; |
| 5061 | } | |
| 5062 | } | |
| 5063 | 0 | else if(JSVAL_IS_INT(id)) |
| 5064 | { | |
| 5065 | 0 | for(; i < JSVAL_TO_INT(id) && operation; ++i) |
| 5066 | { | |
| 5067 | 0 | operation = operation->next; |
| 5068 | } | |
| 5069 | 0 | globus_assert(operation); |
| 5070 | } | |
| 5071 | else | |
| 5072 | { | |
| 5073 | 0 | operation = (wsdlOperationPtr) JSVAL_TO_PRIVATE(id); |
| 5074 | 0 | globus_assert(operation); |
| 5075 | } | |
| 5076 | ||
| 5077 | 0 | operationObj = JS_NewObject(cx, &operation_class, |
| 5078 | operationClass, obj); | |
| 5079 | 0 | globus_assert(operationObj); |
| 5080 | 0 | JS_SetPrivate(cx, operationObj, (void *)operation); |
| 5081 | 0 | JS_DefineProperties(cx, operationObj, operation_properties); |
| 5082 | 0 | *vp = OBJECT_TO_JSVAL(operationObj); |
| 5083 | ||
| 5084 | 0 | GlobusWSDLDebugExit(); |
| 5085 | 0 | return res; |
| 5086 | } | |
| 5087 | ||
| 5088 | static | |
| 5089 | JSBool | |
| 5090 | operationsEnumerate( | |
| 5091 | JSContext * cx, | |
| 5092 | JSObject * obj, | |
| 5093 | JSIterateOp enum_op, | |
| 5094 | jsval * statep, | |
| 5095 | jsid * idp) | |
| 5096 | 0 | { |
| 5097 | 0 | JSBool res = JS_TRUE; |
| 5098 | 0 | wsdlOperationPtr operations; |
| 5099 | 0 | int i = 0; |
| 5100 | 0 | int index; |
| 5101 | 0 | GlobusFuncName(operationsEnumerate); |
| 5102 | 0 | GlobusWSDLDebugEnter(); |
| 5103 | ||
| 5104 | 0 | operations = (wsdlOperationPtr) JS_GetPrivate(cx, obj); |
| 5105 | 0 | globus_assert(operations); |
| 5106 | ||
| 5107 | 0 | switch(enum_op) |
| 5108 | { | |
| 5109 | case JSENUMERATE_INIT: | |
| 5110 | ||
| 5111 | 0 | *statep = INT_TO_JSVAL(i); |
| 5112 | 0 | break; |
| 5113 | ||
| 5114 | case JSENUMERATE_NEXT: | |
| 5115 | ||
| 5116 | 0 | index = JSVAL_TO_INT(*statep); |
| 5117 | 0 | for(; i < index && operations; ++i) |
| 5118 | { | |
| 5119 | 0 | operations = operations->next; |
| 5120 | } | |
| 5121 | ||
| 5122 | 0 | if(!operations) |
| 5123 | { | |
| 5124 | 0 | *statep = JSVAL_NULL; |
| 5125 | 0 | *idp = JSVAL_ZERO; |
| 5126 | 0 | break; |
| 5127 | } | |
| 5128 | ||
| 5129 | 0 | *idp = *statep; |
| 5130 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 5131 | ||
| 5132 | break; | |
| 5133 | ||
| 5134 | case JSENUMERATE_DESTROY: | |
| 5135 | ||
| 5136 | 0 | break; |
| 5137 | } | |
| 5138 | ||
| 5139 | 0 | GlobusWSDLDebugExit(); |
| 5140 | 0 | return res; |
| 5141 | } | |
| 5142 | ||
| 5143 | static | |
| 5144 | JSBool | |
| 5145 | operationGetter( | |
| 5146 | JSContext * cx, | |
| 5147 | JSObject * obj, | |
| 5148 | jsval jid, | |
| 5149 | jsval * vp) | |
| 5150 | 0 | { |
| 5151 | 0 | JSString * str = NULL; |
| 5152 | 0 | JSObject * paramObj = NULL; |
| 5153 | 0 | JSObject * faultsObj = NULL; |
| 5154 | 0 | int idval; |
| 5155 | 0 | JSBool res = JS_TRUE; |
| 5156 | 0 | wsdlOperationPtr operation = NULL; |
| 5157 | 0 | GlobusFuncName(operationGetter); |
| 5158 | 0 | GlobusWSDLDebugEnter(); |
| 5159 | ||
| 5160 | 0 | operation = (wsdlOperationPtr) JS_GetPrivate(cx, obj); |
| 5161 | 0 | globus_assert(operation); |
| 5162 | ||
| 5163 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5164 | { | |
| 5165 | 0 | JS_ReportError(cx, |
| 5166 | "Invalid id type (expected int) " | |
| 5167 | "for wsdl operation property"); | |
| 5168 | 0 | res = JS_FALSE; |
| 5169 | 0 | goto exit; |
| 5170 | } | |
| 5171 | ||
| 5172 | 0 | idval = JSVAL_TO_INT(jid); |
| 5173 | ||
| 5174 | 0 | switch(idval) |
| 5175 | { | |
| 5176 | case name: | |
| 5177 | ||
| 5178 | 0 | if(!operation->name) |
| 5179 | { | |
| 5180 | 0 | *vp = JSVAL_VOID; |
| 5181 | 0 | break; |
| 5182 | } | |
| 5183 | ||
| 5184 | 0 | str = JS_InternString(cx, (const char *) operation->name); |
| 5185 | 0 | globus_assert(str); |
| 5186 | ||
| 5187 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5188 | 0 | break; |
| 5189 | ||
| 5190 | case type: | |
| 5191 | ||
| 5192 | 0 | *vp = INT_TO_JSVAL(operation->type); |
| 5193 | 0 | break; |
| 5194 | ||
| 5195 | case input: | |
| 5196 | ||
| 5197 | 0 | if(!operation->input) |
| 5198 | { | |
| 5199 | 0 | *vp = JSVAL_VOID; |
| 5200 | 0 | break; |
| 5201 | } | |
| 5202 | ||
| 5203 | 0 | paramObj = JS_NewObject(cx, ¶m_class, paramClass, obj); |
| 5204 | 0 | globus_assert(paramObj); |
| 5205 | 0 | JS_SetPrivate(cx, paramObj, (void *)operation->input); |
| 5206 | 0 | JS_DefineProperties(cx, paramObj, param_properties); |
| 5207 | 0 | *vp = OBJECT_TO_JSVAL(paramObj); |
| 5208 | 0 | break; |
| 5209 | ||
| 5210 | case output: | |
| 5211 | ||
| 5212 | 0 | if(!operation->output) |
| 5213 | { | |
| 5214 | 0 | *vp = JSVAL_VOID; |
| 5215 | 0 | break; |
| 5216 | } | |
| 5217 | ||
| 5218 | 0 | paramObj = JS_NewObject(cx, ¶m_class, paramClass, obj); |
| 5219 | 0 | globus_assert(paramObj); |
| 5220 | 0 | JS_SetPrivate(cx, paramObj, (void *)operation->output); |
| 5221 | 0 | JS_DefineProperties(cx, paramObj, param_properties); |
| 5222 | 0 | *vp = OBJECT_TO_JSVAL(paramObj); |
| 5223 | 0 | break; |
| 5224 | ||
| 5225 | case faults: | |
| 5226 | ||
| 5227 | 0 | if(!operation->faults) |
| 5228 | { | |
| 5229 | 0 | *vp = JSVAL_VOID; |
| 5230 | 0 | break; |
| 5231 | } | |
| 5232 | ||
| 5233 | 0 | faultsObj = JS_NewObject(cx, &faults_class, NULL, obj); |
| 5234 | 0 | globus_assert(faultsObj); |
| 5235 | ||
| 5236 | 0 | JS_SetPrivate(cx, faultsObj, (void *)operation->faults); |
| 5237 | 0 | *vp = OBJECT_TO_JSVAL(faultsObj); |
| 5238 | 0 | break; |
| 5239 | ||
| 5240 | default: | |
| 5241 | ||
| 5242 | 0 | *vp = JSVAL_VOID; |
| 5243 | 0 | JS_ReportError(cx, "Unknown property with id %d for part", idval); |
| 5244 | 0 | res = JS_FALSE; |
| 5245 | goto exit; | |
| 5246 | } | |
| 5247 | ||
| 5248 | exit: | |
| 5249 | ||
| 5250 | 0 | GlobusWSDLDebugExit(); |
| 5251 | 0 | return res; |
| 5252 | } | |
| 5253 | ||
| 5254 | ||
| 5255 | static | |
| 5256 | JSBool | |
| 5257 | faultsGetter( | |
| 5258 | JSContext * cx, | |
| 5259 | JSObject * obj, | |
| 5260 | jsval id, | |
| 5261 | jsval * vp) | |
| 5262 | 0 | { |
| 5263 | 0 | wsdlFaultPtr fault; |
| 5264 | 0 | JSObject * faultObj; |
| 5265 | 0 | JSBool res = JS_TRUE; |
| 5266 | 0 | int i = 0; |
| 5267 | 0 | GlobusFuncName(faultsGetter); |
| 5268 | 0 | GlobusWSDLDebugEnter(); |
| 5269 | ||
| 5270 | 0 | fault = (wsdlFaultPtr) JS_GetPrivate(cx, obj); |
| 5271 | 0 | globus_assert(fault); |
| 5272 | ||
| 5273 | 0 | if(JSVAL_IS_STRING(id)) |
| 5274 | { | |
| 5275 | 0 | while(fault) |
| 5276 | { | |
| 5277 | 0 | JSString * name; |
| 5278 | ||
| 5279 | 0 | name = JS_InternString(cx, (const char *) fault->name); |
| 5280 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 5281 | { | |
| 5282 | 0 | break; |
| 5283 | } | |
| 5284 | ||
| 5285 | 0 | fault = fault->next; |
| 5286 | } | |
| 5287 | } | |
| 5288 | 0 | else if(JSVAL_IS_INT(id)) |
| 5289 | { | |
| 5290 | 0 | for(; i < JSVAL_TO_INT(id) && fault; ++i) |
| 5291 | { | |
| 5292 | 0 | fault = fault->next; |
| 5293 | } | |
| 5294 | 0 | globus_assert(fault); |
| 5295 | } | |
| 5296 | else | |
| 5297 | { | |
| 5298 | 0 | fault = (wsdlFaultPtr) JSVAL_TO_PRIVATE(id); |
| 5299 | 0 | globus_assert(fault); |
| 5300 | } | |
| 5301 | ||
| 5302 | 0 | faultObj = JS_NewObject(cx, &fault_class, |
| 5303 | faultClass, obj); | |
| 5304 | 0 | globus_assert(faultObj); |
| 5305 | 0 | JS_SetPrivate(cx, faultObj, (void *)fault); |
| 5306 | 0 | JS_DefineProperties(cx, faultObj, fault_properties); |
| 5307 | 0 | *vp = OBJECT_TO_JSVAL(faultObj); |
| 5308 | ||
| 5309 | 0 | GlobusWSDLDebugExit(); |
| 5310 | 0 | return res; |
| 5311 | } | |
| 5312 | ||
| 5313 | static | |
| 5314 | JSBool | |
| 5315 | faultsEnumerate( | |
| 5316 | JSContext * cx, | |
| 5317 | JSObject * obj, | |
| 5318 | JSIterateOp enum_op, | |
| 5319 | jsval * statep, | |
| 5320 | jsid * idp) | |
| 5321 | 0 | { |
| 5322 | 0 | JSBool res = JS_TRUE; |
| 5323 | 0 | wsdlFaultPtr faults; |
| 5324 | 0 | int i = 0; |
| 5325 | 0 | int index; |
| 5326 | 0 | GlobusFuncName(faultsEnumerate); |
| 5327 | 0 | GlobusWSDLDebugEnter(); |
| 5328 | ||
| 5329 | 0 | faults = (wsdlFaultPtr) JS_GetPrivate(cx, obj); |
| 5330 | 0 | globus_assert(faults); |
| 5331 | ||
| 5332 | 0 | switch(enum_op) |
| 5333 | { | |
| 5334 | case JSENUMERATE_INIT: | |
| 5335 | ||
| 5336 | 0 | *statep = INT_TO_JSVAL(i); |
| 5337 | 0 | break; |
| 5338 | ||
| 5339 | case JSENUMERATE_NEXT: | |
| 5340 | ||
| 5341 | 0 | index = JSVAL_TO_INT(*statep); |
| 5342 | 0 | for(; i < index && faults; ++i) |
| 5343 | { | |
| 5344 | 0 | faults = faults->next; |
| 5345 | } | |
| 5346 | ||
| 5347 | 0 | if(!faults) |
| 5348 | { | |
| 5349 | 0 | *statep = JSVAL_NULL; |
| 5350 | 0 | *idp = JSVAL_ZERO; |
| 5351 | 0 | break; |
| 5352 | } | |
| 5353 | ||
| 5354 | 0 | *idp = *statep; |
| 5355 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 5356 | ||
| 5357 | break; | |
| 5358 | ||
| 5359 | case JSENUMERATE_DESTROY: | |
| 5360 | ||
| 5361 | 0 | break; |
| 5362 | } | |
| 5363 | ||
| 5364 | 0 | GlobusWSDLDebugExit(); |
| 5365 | 0 | return res; |
| 5366 | } | |
| 5367 | ||
| 5368 | static | |
| 5369 | JSBool | |
| 5370 | faultGetter( | |
| 5371 | JSContext * cx, | |
| 5372 | JSObject * obj, | |
| 5373 | jsval jid, | |
| 5374 | jsval * vp) | |
| 5375 | 0 | { |
| 5376 | 0 | int idval; |
| 5377 | 0 | JSString * str; |
| 5378 | 0 | JSObject * messageObj; |
| 5379 | 0 | JSBool res = JS_TRUE; |
| 5380 | 0 | wsdlFaultPtr fault = NULL; |
| 5381 | 0 | GlobusFuncName(faultGetter); |
| 5382 | 0 | GlobusWSDLDebugEnter(); |
| 5383 | ||
| 5384 | 0 | fault = (wsdlFaultPtr) JS_GetPrivate(cx, obj); |
| 5385 | 0 | globus_assert(fault); |
| 5386 | ||
| 5387 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5388 | { | |
| 5389 | 0 | JS_ReportError(cx, |
| 5390 | "Invalid id type (expected int) " | |
| 5391 | "for wsdl fault property"); | |
| 5392 | 0 | res = JS_FALSE; |
| 5393 | 0 | goto exit; |
| 5394 | } | |
| 5395 | ||
| 5396 | 0 | idval = JSVAL_TO_INT(jid); |
| 5397 | ||
| 5398 | 0 | switch(idval) |
| 5399 | { | |
| 5400 | case name: | |
| 5401 | ||
| 5402 | 0 | if(!fault->name) |
| 5403 | { | |
| 5404 | 0 | *vp = JSVAL_VOID; |
| 5405 | 0 | break; |
| 5406 | } | |
| 5407 | ||
| 5408 | 0 | str = JS_InternString(cx, (const char *) fault->name); |
| 5409 | 0 | globus_assert(str); |
| 5410 | ||
| 5411 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5412 | 0 | break; |
| 5413 | ||
| 5414 | case message: | |
| 5415 | ||
| 5416 | 0 | if(!fault->message) |
| 5417 | { | |
| 5418 | 0 | *vp = JSVAL_VOID; |
| 5419 | 0 | break; |
| 5420 | } | |
| 5421 | ||
| 5422 | 0 | messageObj = JS_NewObject(cx, &message_class, messageClass, obj); |
| 5423 | 0 | globus_assert(messageObj); |
| 5424 | 0 | JS_SetPrivate(cx, messageObj, (void *)fault->message); |
| 5425 | 0 | JS_DefineProperties(cx, messageObj, message_properties); |
| 5426 | 0 | *vp = OBJECT_TO_JSVAL(messageObj); |
| 5427 | 0 | break; |
| 5428 | ||
| 5429 | default: | |
| 5430 | ||
| 5431 | 0 | *vp = JSVAL_VOID; |
| 5432 | 0 | JS_ReportError(cx, "Unknown fault property with id %d for part", idval); |
| 5433 | 0 | res = JS_FALSE; |
| 5434 | goto exit; | |
| 5435 | } | |
| 5436 | ||
| 5437 | exit: | |
| 5438 | ||
| 5439 | 0 | GlobusWSDLDebugExit(); |
| 5440 | 0 | return res; |
| 5441 | } | |
| 5442 | ||
| 5443 | ||
| 5444 | static | |
| 5445 | JSBool | |
| 5446 | paramGetter( | |
| 5447 | JSContext * cx, | |
| 5448 | JSObject * obj, | |
| 5449 | jsval jid, | |
| 5450 | jsval * vp) | |
| 5451 | 0 | { |
| 5452 | 0 | int idval; |
| 5453 | 0 | JSString * str; |
| 5454 | 0 | JSObject * messageObj; |
| 5455 | 0 | JSBool res = JS_TRUE; |
| 5456 | 0 | wsdlParamPtr param = NULL; |
| 5457 | 0 | GlobusFuncName(paramGetter); |
| 5458 | 0 | GlobusWSDLDebugEnter(); |
| 5459 | ||
| 5460 | 0 | param = (wsdlParamPtr) JS_GetPrivate(cx, obj); |
| 5461 | 0 | globus_assert(param); |
| 5462 | ||
| 5463 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5464 | { | |
| 5465 | 0 | JS_ReportError(cx, |
| 5466 | "Invalid id type (expected int) " | |
| 5467 | "for wsdl param property"); | |
| 5468 | 0 | res = JS_FALSE; |
| 5469 | 0 | goto exit; |
| 5470 | } | |
| 5471 | ||
| 5472 | 0 | idval = JSVAL_TO_INT(jid); |
| 5473 | ||
| 5474 | 0 | switch(idval) |
| 5475 | { | |
| 5476 | case name: | |
| 5477 | ||
| 5478 | 0 | if(!param->name) |
| 5479 | { | |
| 5480 | 0 | *vp = JSVAL_VOID; |
| 5481 | 0 | break; |
| 5482 | } | |
| 5483 | ||
| 5484 | 0 | str = JS_InternString(cx, (const char *) param->name); |
| 5485 | 0 | globus_assert(str); |
| 5486 | ||
| 5487 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5488 | 0 | break; |
| 5489 | ||
| 5490 | case Action: | |
| 5491 | ||
| 5492 | 0 | if(!param->Action) |
| 5493 | { | |
| 5494 | 0 | *vp = JSVAL_VOID; |
| 5495 | 0 | break; |
| 5496 | } | |
| 5497 | ||
| 5498 | 0 | str = JS_InternString(cx, (const char *) param->Action); |
| 5499 | 0 | globus_assert(str); |
| 5500 | ||
| 5501 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5502 | 0 | break; |
| 5503 | ||
| 5504 | case message: | |
| 5505 | ||
| 5506 | 0 | if(!param->message) |
| 5507 | { | |
| 5508 | 0 | *vp = JSVAL_VOID; |
| 5509 | 0 | break; |
| 5510 | } | |
| 5511 | ||
| 5512 | 0 | messageObj = JS_NewObject(cx, &message_class, messageClass, obj); |
| 5513 | 0 | globus_assert(messageObj); |
| 5514 | 0 | JS_SetPrivate(cx, messageObj, (void *)param->message); |
| 5515 | 0 | JS_DefineProperties(cx, messageObj, message_properties); |
| 5516 | 0 | *vp = OBJECT_TO_JSVAL(messageObj); |
| 5517 | 0 | break; |
| 5518 | ||
| 5519 | default: | |
| 5520 | ||
| 5521 | 0 | *vp = JSVAL_VOID; |
| 5522 | 0 | JS_ReportError(cx, "Unknown param property with id %d for part", idval); |
| 5523 | 0 | res = JS_FALSE; |
| 5524 | goto exit; | |
| 5525 | } | |
| 5526 | ||
| 5527 | exit: | |
| 5528 | ||
| 5529 | 0 | GlobusWSDLDebugExit(); |
| 5530 | 0 | return res; |
| 5531 | } | |
| 5532 | ||
| 5533 | static | |
| 5534 | JSBool | |
| 5535 | portsGetter( | |
| 5536 | JSContext * cx, | |
| 5537 | JSObject * obj, | |
| 5538 | jsval id, | |
| 5539 | jsval * vp) | |
| 5540 | 0 | { |
| 5541 | 0 | wsdlPortPtr port; |
| 5542 | 0 | JSObject * portObj; |
| 5543 | 0 | JSBool res = JS_TRUE; |
| 5544 | 0 | int i = 0; |
| 5545 | 0 | GlobusFuncName(portsGetter); |
| 5546 | 0 | GlobusWSDLDebugEnter(); |
| 5547 | ||
| 5548 | 0 | port = (wsdlPortPtr) JS_GetPrivate(cx, obj); |
| 5549 | 0 | globus_assert(port); |
| 5550 | ||
| 5551 | 0 | if(JSVAL_IS_STRING(id)) |
| 5552 | { | |
| 5553 | 0 | while(port) |
| 5554 | { | |
| 5555 | 0 | JSString * name; |
| 5556 | ||
| 5557 | 0 | name = JS_InternString(cx, (const char *) port->name); |
| 5558 | 0 | if(JS_CompareStrings(name, JSVAL_TO_STRING(id))) |
| 5559 | { | |
| 5560 | 0 | break; |
| 5561 | } | |
| 5562 | ||
| 5563 | 0 | port = port->next; |
| 5564 | } | |
| 5565 | } | |
| 5566 | 0 | else if(JSVAL_IS_INT(id)) |
| 5567 | { | |
| 5568 | 0 | for(; i < JSVAL_TO_INT(id) && port; ++i) |
| 5569 | { | |
| 5570 | 0 | port = port->next; |
| 5571 | } | |
| 5572 | 0 | globus_assert(port); |
| 5573 | } | |
| 5574 | else | |
| 5575 | { | |
| 5576 | 0 | port = (wsdlPortPtr) JSVAL_TO_PRIVATE(id); |
| 5577 | 0 | globus_assert(port); |
| 5578 | } | |
| 5579 | ||
| 5580 | 0 | portObj = JS_NewObject(cx, &port_class, |
| 5581 | portClass, obj); | |
| 5582 | 0 | globus_assert(portObj); |
| 5583 | 0 | JS_SetPrivate(cx, portObj, (void *)port); |
| 5584 | 0 | JS_DefineProperties(cx, portObj, port_properties); |
| 5585 | 0 | *vp = OBJECT_TO_JSVAL(portObj); |
| 5586 | ||
| 5587 | 0 | GlobusWSDLDebugExit(); |
| 5588 | 0 | return res; |
| 5589 | } | |
| 5590 | ||
| 5591 | static | |
| 5592 | JSBool | |
| 5593 | portsEnumerate( | |
| 5594 | JSContext * cx, | |
| 5595 | JSObject * obj, | |
| 5596 | JSIterateOp enum_op, | |
| 5597 | jsval * statep, | |
| 5598 | jsid * idp) | |
| 5599 | 0 | { |
| 5600 | 0 | JSBool res = JS_TRUE; |
| 5601 | 0 | wsdlPortPtr ports; |
| 5602 | 0 | int i = 0; |
| 5603 | 0 | int index; |
| 5604 | 0 | GlobusFuncName(portsEnumerate); |
| 5605 | 0 | GlobusWSDLDebugEnter(); |
| 5606 | ||
| 5607 | 0 | ports = (wsdlPortPtr) JS_GetPrivate(cx, obj); |
| 5608 | 0 | globus_assert(ports); |
| 5609 | ||
| 5610 | 0 | switch(enum_op) |
| 5611 | { | |
| 5612 | case JSENUMERATE_INIT: | |
| 5613 | ||
| 5614 | 0 | *statep = INT_TO_JSVAL(i); |
| 5615 | 0 | break; |
| 5616 | ||
| 5617 | case JSENUMERATE_NEXT: | |
| 5618 | ||
| 5619 | 0 | index = JSVAL_TO_INT(*statep); |
| 5620 | 0 | for(; i < index && ports; ++i) |
| 5621 | { | |
| 5622 | 0 | ports = ports->next; |
| 5623 | } | |
| 5624 | ||
| 5625 | 0 | if(!ports) |
| 5626 | { | |
| 5627 | 0 | *statep = JSVAL_NULL; |
| 5628 | 0 | *idp = JSVAL_ZERO; |
| 5629 | 0 | break; |
| 5630 | } | |
| 5631 | ||
| 5632 | 0 | *idp = *statep; |
| 5633 | 0 | *statep = INT_TO_JSVAL(index + 1); |
| 5634 | ||
| 5635 | break; | |
| 5636 | ||
| 5637 | case JSENUMERATE_DESTROY: | |
| 5638 | ||
| 5639 | 0 | break; |
| 5640 | } | |
| 5641 | ||
| 5642 | 0 | GlobusWSDLDebugExit(); |
| 5643 | 0 | return res; |
| 5644 | } | |
| 5645 | ||
| 5646 | static | |
| 5647 | JSBool | |
| 5648 | portGetter( | |
| 5649 | JSContext * cx, | |
| 5650 | JSObject * obj, | |
| 5651 | jsval jid, | |
| 5652 | jsval * vp) | |
| 5653 | 0 | { |
| 5654 | 0 | int idval; |
| 5655 | 0 | JSString * str = NULL; |
| 5656 | 0 | JSObject * bindingObj = NULL; |
| 5657 | 0 | JSObject * soapObj = NULL; |
| 5658 | 0 | JSBool res = JS_TRUE; |
| 5659 | 0 | wsdlPortPtr port = NULL; |
| 5660 | 0 | GlobusFuncName(portGetter); |
| 5661 | 0 | GlobusWSDLDebugEnter(); |
| 5662 | ||
| 5663 | 0 | port = (wsdlPortPtr) JS_GetPrivate(cx, obj); |
| 5664 | 0 | globus_assert(port); |
| 5665 | ||
| 5666 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5667 | { | |
| 5668 | 0 | JS_ReportError(cx, |
| 5669 | "Invalid id type (expected int) " | |
| 5670 | "for wsdl port property"); | |
| 5671 | 0 | res = JS_FALSE; |
| 5672 | 0 | goto exit; |
| 5673 | } | |
| 5674 | ||
| 5675 | 0 | idval = JSVAL_TO_INT(jid); |
| 5676 | ||
| 5677 | 0 | switch(idval) |
| 5678 | { | |
| 5679 | case name: | |
| 5680 | ||
| 5681 | 0 | if(!port->name) |
| 5682 | { | |
| 5683 | 0 | *vp = JSVAL_VOID; |
| 5684 | 0 | break; |
| 5685 | } | |
| 5686 | ||
| 5687 | 0 | str = JS_InternString(cx, (const char *) port->name); |
| 5688 | 0 | globus_assert(str); |
| 5689 | ||
| 5690 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5691 | 0 | break; |
| 5692 | ||
| 5693 | case binding: | |
| 5694 | ||
| 5695 | 0 | if(!port->binding) |
| 5696 | { | |
| 5697 | 0 | *vp = JSVAL_VOID; |
| 5698 | 0 | break; |
| 5699 | } | |
| 5700 | ||
| 5701 | 0 | bindingObj = JS_NewObject(cx, &binding_class, bindingClass, obj); |
| 5702 | 0 | globus_assert(bindingObj); |
| 5703 | 0 | JS_SetPrivate(cx, bindingObj, (void *)port->binding); |
| 5704 | 0 | JS_DefineProperties(cx, bindingObj, binding_properties); |
| 5705 | ||
| 5706 | 0 | *vp = OBJECT_TO_JSVAL(bindingObj); |
| 5707 | 0 | break; |
| 5708 | ||
| 5709 | case soap: | |
| 5710 | ||
| 5711 | 0 | if(!port->extension || (port->extensionType != SOAP_BINDING)) |
| 5712 | { | |
| 5713 | 0 | *vp = JSVAL_VOID; |
| 5714 | 0 | break; |
| 5715 | } | |
| 5716 | ||
| 5717 | 0 | soapObj = JS_NewObject(cx, &soapAddress_class, soapAddressClass, obj); |
| 5718 | 0 | globus_assert(soapObj); |
| 5719 | 0 | JS_SetPrivate(cx, soapObj, (void *)port->extension); |
| 5720 | 0 | JS_DefineProperties(cx, soapObj, soapAddress_properties); |
| 5721 | 0 | *vp = OBJECT_TO_JSVAL(soapObj); |
| 5722 | 0 | break; |
| 5723 | ||
| 5724 | default: | |
| 5725 | ||
| 5726 | 0 | *vp = JSVAL_VOID; |
| 5727 | 0 | JS_ReportError(cx, "Unknown port property with id %d for part", idval); |
| 5728 | 0 | res = JS_FALSE; |
| 5729 | goto exit; | |
| 5730 | } | |
| 5731 | ||
| 5732 | exit: | |
| 5733 | ||
| 5734 | 0 | GlobusWSDLDebugExit(); |
| 5735 | 0 | return res; |
| 5736 | } | |
| 5737 | ||
| 5738 | static | |
| 5739 | JSBool | |
| 5740 | serviceGetter( | |
| 5741 | JSContext * cx, | |
| 5742 | JSObject * obj, | |
| 5743 | jsval jid, | |
| 5744 | jsval * vp) | |
| 5745 | 0 | { |
| 5746 | 0 | int idval; |
| 5747 | 0 | JSString * str = NULL; |
| 5748 | 0 | JSObject * portsObj = NULL; |
| 5749 | 0 | JSBool res = JS_TRUE; |
| 5750 | 0 | wsdlServicePtr service = NULL; |
| 5751 | 0 | GlobusFuncName(serviceGetter); |
| 5752 | 0 | GlobusWSDLDebugEnter(); |
| 5753 | ||
| 5754 | 0 | service = (wsdlServicePtr) JS_GetPrivate(cx, obj); |
| 5755 | 0 | globus_assert(service); |
| 5756 | ||
| 5757 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5758 | { | |
| 5759 | 0 | char * prop_name; |
| 5760 | ||
| 5761 | 0 | prop_name = JS_GetStringBytes(JSVAL_TO_STRING(jid)); |
| 5762 | 0 | JS_ReportError(cx, |
| 5763 | "Invalid property access .%s on wsdl service element", | |
| 5764 | prop_name); | |
| 5765 | 0 | res = JS_FALSE; |
| 5766 | 0 | goto exit; |
| 5767 | } | |
| 5768 | ||
| 5769 | 0 | idval = JSVAL_TO_INT(jid); |
| 5770 | ||
| 5771 | 0 | switch(idval) |
| 5772 | { | |
| 5773 | case name: | |
| 5774 | ||
| 5775 | 0 | if(!service->name) |
| 5776 | { | |
| 5777 | 0 | *vp = JSVAL_VOID; |
| 5778 | 0 | break; |
| 5779 | } | |
| 5780 | ||
| 5781 | 0 | str = JS_InternString(cx, (const char *) service->name); |
| 5782 | 0 | globus_assert(str); |
| 5783 | ||
| 5784 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5785 | 0 | break; |
| 5786 | ||
| 5787 | case ports: | |
| 5788 | ||
| 5789 | 0 | if(!service->ports) |
| 5790 | { | |
| 5791 | 0 | *vp = JSVAL_VOID; |
| 5792 | 0 | break; |
| 5793 | } | |
| 5794 | ||
| 5795 | 0 | portsObj = JS_NewObject(cx, &ports_class, NULL, obj); |
| 5796 | 0 | globus_assert(portsObj); |
| 5797 | 0 | JS_SetPrivate(cx, portsObj, (void *) service->ports); |
| 5798 | 0 | *vp = OBJECT_TO_JSVAL(portsObj); |
| 5799 | 0 | break; |
| 5800 | ||
| 5801 | case soap: | |
| 5802 | ||
| 5803 | 0 | *vp = JSVAL_VOID; |
| 5804 | 0 | break; |
| 5805 | ||
| 5806 | case targetNamespace: | |
| 5807 | ||
| 5808 | 0 | if(!service->schema || !service->schema->targetNamespace) |
| 5809 | { | |
| 5810 | 0 | *vp = JSVAL_VOID; |
| 5811 | 0 | break; |
| 5812 | } | |
| 5813 | ||
| 5814 | 0 | str = JS_InternString(cx, (const char *) service->schema->targetNamespace); |
| 5815 | 0 | globus_assert(str); |
| 5816 | ||
| 5817 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5818 | 0 | break; |
| 5819 | ||
| 5820 | default: | |
| 5821 | ||
| 5822 | 0 | *vp = JSVAL_VOID; |
| 5823 | 0 | JS_ReportError(cx, "Unknown service property with id %d for part", idval); |
| 5824 | 0 | res = JS_FALSE; |
| 5825 | goto exit; | |
| 5826 | } | |
| 5827 | ||
| 5828 | exit: | |
| 5829 | ||
| 5830 | 0 | GlobusWSDLDebugExit(); |
| 5831 | 0 | return res; |
| 5832 | } | |
| 5833 | ||
| 5834 | static | |
| 5835 | JSBool | |
| 5836 | soapBindingGetter( | |
| 5837 | JSContext * cx, | |
| 5838 | JSObject * obj, | |
| 5839 | jsval jid, | |
| 5840 | jsval * vp) | |
| 5841 | 0 | { |
| 5842 | 0 | JSString * str = NULL; |
| 5843 | 0 | int idval; |
| 5844 | 0 | JSBool res = JS_TRUE; |
| 5845 | 0 | soapBindingPtr binding = NULL; |
| 5846 | 0 | GlobusFuncName(soapBindingGetter); |
| 5847 | 0 | GlobusWSDLDebugEnter(); |
| 5848 | ||
| 5849 | 0 | binding = (soapBindingPtr) JS_GetPrivate(cx, obj); |
| 5850 | 0 | globus_assert(binding); |
| 5851 | ||
| 5852 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5853 | { | |
| 5854 | 0 | JS_ReportError(cx, |
| 5855 | "Invalid id type (expected int) " | |
| 5856 | "for soap binding property"); | |
| 5857 | 0 | res = JS_FALSE; |
| 5858 | 0 | goto exit; |
| 5859 | } | |
| 5860 | ||
| 5861 | 0 | idval = JSVAL_TO_INT(jid); |
| 5862 | ||
| 5863 | 0 | switch(idval) |
| 5864 | { | |
| 5865 | case style: | |
| 5866 | ||
| 5867 | 0 | *vp = INT_TO_JSVAL(binding->style); |
| 5868 | 0 | break; |
| 5869 | ||
| 5870 | case transport: | |
| 5871 | ||
| 5872 | 0 | if(!binding->transport) |
| 5873 | { | |
| 5874 | 0 | *vp = JSVAL_VOID; |
| 5875 | 0 | break; |
| 5876 | } | |
| 5877 | ||
| 5878 | 0 | str = JS_InternString(cx, (const char *) binding->transport); |
| 5879 | 0 | globus_assert(str); |
| 5880 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5881 | 0 | break; |
| 5882 | ||
| 5883 | default: | |
| 5884 | ||
| 5885 | 0 | *vp = JSVAL_VOID; |
| 5886 | 0 | JS_ReportError(cx, |
| 5887 | "Unknown soap binding property " | |
| 5888 | "with id %d for part", idval); | |
| 5889 | 0 | res = JS_FALSE; |
| 5890 | goto exit; | |
| 5891 | } | |
| 5892 | ||
| 5893 | exit: | |
| 5894 | ||
| 5895 | 0 | GlobusWSDLDebugExit(); |
| 5896 | 0 | return res; |
| 5897 | } | |
| 5898 | ||
| 5899 | static | |
| 5900 | JSBool | |
| 5901 | soapOperationGetter( | |
| 5902 | JSContext * cx, | |
| 5903 | JSObject * obj, | |
| 5904 | jsval jid, | |
| 5905 | jsval * vp) | |
| 5906 | 0 | { |
| 5907 | 0 | JSString * str = NULL; |
| 5908 | 0 | int idval; |
| 5909 | 0 | JSBool res = JS_TRUE; |
| 5910 | 0 | soapOperationPtr operation = NULL; |
| 5911 | 0 | GlobusFuncName(soapOperationGetter); |
| 5912 | 0 | GlobusWSDLDebugEnter(); |
| 5913 | ||
| 5914 | 0 | operation = (soapOperationPtr) JS_GetPrivate(cx, obj); |
| 5915 | 0 | globus_assert(operation); |
| 5916 | ||
| 5917 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5918 | { | |
| 5919 | 0 | JS_ReportError(cx, |
| 5920 | "Invalid id type (expected int) " | |
| 5921 | "for soap operation property"); | |
| 5922 | 0 | res = JS_FALSE; |
| 5923 | 0 | goto exit; |
| 5924 | } | |
| 5925 | ||
| 5926 | 0 | idval = JSVAL_TO_INT(jid); |
| 5927 | ||
| 5928 | 0 | switch(idval) |
| 5929 | { | |
| 5930 | case soapAction: | |
| 5931 | ||
| 5932 | 0 | if(!operation->soapAction) |
| 5933 | { | |
| 5934 | 0 | *vp = JSVAL_VOID; |
| 5935 | 0 | break; |
| 5936 | } | |
| 5937 | ||
| 5938 | 0 | str = JS_InternString(cx, (const char *) operation->soapAction); |
| 5939 | 0 | globus_assert(str); |
| 5940 | 0 | *vp = STRING_TO_JSVAL(str); |
| 5941 | 0 | break; |
| 5942 | ||
| 5943 | case style: | |
| 5944 | ||
| 5945 | 0 | *vp = INT_TO_JSVAL(operation->style); |
| 5946 | 0 | break; |
| 5947 | ||
| 5948 | ||
| 5949 | default: | |
| 5950 | ||
| 5951 | 0 | *vp = JSVAL_VOID; |
| 5952 | 0 | JS_ReportError(cx, |
| 5953 | "Unknown soap operation property " | |
| 5954 | "with id %d", idval); | |
| 5955 | 0 | res = JS_FALSE; |
| 5956 | goto exit; | |
| 5957 | } | |
| 5958 | ||
| 5959 | exit: | |
| 5960 | ||
| 5961 | 0 | GlobusWSDLDebugExit(); |
| 5962 | 0 | return res; |
| 5963 | } | |
| 5964 | ||
| 5965 | static | |
| 5966 | JSBool | |
| 5967 | soapHeaderGetter( | |
| 5968 | JSContext * cx, | |
| 5969 | JSObject * obj, | |
| 5970 | jsval jid, | |
| 5971 | jsval * vp) | |
| 5972 | 0 | { |
| 5973 | 0 | JSString * str = NULL; |
| 5974 | 0 | int idval; |
| 5975 | 0 | JSBool res = JS_TRUE; |
| 5976 | 0 | soapHeaderPtr header = NULL; |
| 5977 | 0 | GlobusFuncName(soapHeaderGetter); |
| 5978 | 0 | GlobusWSDLDebugEnter(); |
| 5979 | ||
| 5980 | 0 | header = (soapHeaderPtr) JS_GetPrivate(cx, obj); |
| 5981 | 0 | globus_assert(header); |
| 5982 | ||
| 5983 | 0 | if(!JSVAL_IS_INT(jid)) |
| 5984 | { | |
| 5985 | 0 | JS_ReportError(cx, |
| 5986 | "Invalid id type (expected int) " | |
| 5987 | "for soap header property"); | |
| 5988 | 0 | res = JS_FALSE; |
| 5989 | 0 | goto exit; |
| 5990 | } | |
| 5991 | ||
| 5992 | 0 | idval = JSVAL_TO_INT(jid); |
| 5993 | ||
| 5994 | 0 | switch(idval) |
| 5995 | { | |
| 5996 | case message: | |
| 5997 | ||
| 5998 | 0 | if(!header->message) |
| 5999 | { | |
| 6000 | 0 | *vp = JSVAL_VOID; |
| 6001 | 0 | break; |
| 6002 | } | |
| 6003 | ||
| 6004 | 0 | str = JS_InternString(cx, (const char *) header->message); |
| 6005 | 0 | globus_assert(str); |
| 6006 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6007 | 0 | break; |
| 6008 | ||
| 6009 | case parts: | |
| 6010 | ||
| 6011 | 0 | if(!header->parts) |
| 6012 | { | |
| 6013 | 0 | *vp = JSVAL_VOID; |
| 6014 | 0 | break; |
| 6015 | } | |
| 6016 | ||
| 6017 | 0 | str = JS_InternString(cx, (const char *) header->parts); |
| 6018 | 0 | globus_assert(str); |
| 6019 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6020 | 0 | break; |
| 6021 | ||
| 6022 | case use: | |
| 6023 | ||
| 6024 | 0 | *vp = INT_TO_JSVAL(header->use); |
| 6025 | 0 | break; |
| 6026 | ||
| 6027 | case encodingStyle: | |
| 6028 | ||
| 6029 | 0 | if(!header->encodingStyle) |
| 6030 | { | |
| 6031 | 0 | *vp = JSVAL_VOID; |
| 6032 | 0 | break; |
| 6033 | } | |
| 6034 | ||
| 6035 | 0 | str = JS_InternString(cx, (const char *) header->encodingStyle); |
| 6036 | 0 | globus_assert(str); |
| 6037 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6038 | 0 | break; |
| 6039 | ||
| 6040 | case Namespace: | |
| 6041 | ||
| 6042 | 0 | if(!header->Namespace) |
| 6043 | { | |
| 6044 | 0 | *vp = JSVAL_VOID; |
| 6045 | } | |
| 6046 | ||
| 6047 | 0 | str = JS_InternString(cx, (const char *) header->Namespace); |
| 6048 | 0 | globus_assert(str); |
| 6049 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6050 | 0 | break; |
| 6051 | ||
| 6052 | default: | |
| 6053 | ||
| 6054 | 0 | *vp = JSVAL_VOID; |
| 6055 | 0 | JS_ReportError(cx, |
| 6056 | "Unknown soap header property " | |
| 6057 | "with id %d", idval); | |
| 6058 | 0 | res = JS_FALSE; |
| 6059 | goto exit; | |
| 6060 | } | |
| 6061 | ||
| 6062 | exit: | |
| 6063 | ||
| 6064 | 0 | GlobusWSDLDebugExit(); |
| 6065 | 0 | return res; |
| 6066 | } | |
| 6067 | ||
| 6068 | static | |
| 6069 | JSBool | |
| 6070 | soapBodyGetter( | |
| 6071 | JSContext * cx, | |
| 6072 | JSObject * obj, | |
| 6073 | jsval jid, | |
| 6074 | jsval * vp) | |
| 6075 | 0 | { |
| 6076 | 0 | JSString * str = NULL; |
| 6077 | 0 | int idval; |
| 6078 | 0 | JSBool res = JS_TRUE; |
| 6079 | 0 | soapBodyPtr body = NULL; |
| 6080 | 0 | GlobusFuncName(soapBodyGetter); |
| 6081 | 0 | GlobusWSDLDebugEnter(); |
| 6082 | ||
| 6083 | 0 | body = (soapBodyPtr) JS_GetPrivate(cx, obj); |
| 6084 | 0 | globus_assert(body); |
| 6085 | ||
| 6086 | 0 | if(!JSVAL_IS_INT(jid)) |
| 6087 | { | |
| 6088 | 0 | JS_ReportError(cx, |
| 6089 | "Invalid id type (expected int) " | |
| 6090 | "for soap body property"); | |
| 6091 | 0 | res = JS_FALSE; |
| 6092 | 0 | goto exit; |
| 6093 | } | |
| 6094 | ||
| 6095 | 0 | idval = JSVAL_TO_INT(jid); |
| 6096 | ||
| 6097 | 0 | switch(idval) |
| 6098 | { | |
| 6099 | case parts: | |
| 6100 | ||
| 6101 | 0 | if(!body->parts) |
| 6102 | { | |
| 6103 | 0 | *vp = JSVAL_VOID; |
| 6104 | 0 | break; |
| 6105 | } | |
| 6106 | ||
| 6107 | 0 | str = JS_InternString(cx, (const char *) body->parts); |
| 6108 | 0 | globus_assert(str); |
| 6109 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6110 | 0 | break; |
| 6111 | ||
| 6112 | case use: | |
| 6113 | ||
| 6114 | 0 | *vp = INT_TO_JSVAL(body->use); |
| 6115 | 0 | break; |
| 6116 | ||
| 6117 | case encodingStyle: | |
| 6118 | ||
| 6119 | 0 | if(!body->encodingStyle) |
| 6120 | { | |
| 6121 | 0 | *vp = JSVAL_VOID; |
| 6122 | 0 | break; |
| 6123 | } | |
| 6124 | ||
| 6125 | 0 | str = JS_InternString(cx, (const char *) body->encodingStyle); |
| 6126 | 0 | globus_assert(str); |
| 6127 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6128 | 0 | break; |
| 6129 | ||
| 6130 | case Namespace: | |
| 6131 | ||
| 6132 | 0 | if(!body->Namespace) |
| 6133 | { | |
| 6134 | 0 | *vp = JSVAL_VOID; |
| 6135 | } | |
| 6136 | ||
| 6137 | 0 | str = JS_InternString(cx, (const char *) body->Namespace); |
| 6138 | 0 | globus_assert(str); |
| 6139 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6140 | 0 | break; |
| 6141 | ||
| 6142 | default: | |
| 6143 | ||
| 6144 | 0 | *vp = JSVAL_VOID; |
| 6145 | 0 | JS_ReportError(cx, |
| 6146 | "Unknown soap body property " | |
| 6147 | "with id %d", idval); | |
| 6148 | 0 | res = JS_FALSE; |
| 6149 | goto exit; | |
| 6150 | } | |
| 6151 | ||
| 6152 | exit: | |
| 6153 | ||
| 6154 | 0 | GlobusWSDLDebugExit(); |
| 6155 | 0 | return res; |
| 6156 | } | |
| 6157 | ||
| 6158 | static | |
| 6159 | JSBool | |
| 6160 | soapFaultGetter( | |
| 6161 | JSContext * cx, | |
| 6162 | JSObject * obj, | |
| 6163 | jsval jid, | |
| 6164 | jsval * vp) | |
| 6165 | 0 | { |
| 6166 | 0 | JSString * str = NULL; |
| 6167 | 0 | int idval; |
| 6168 | 0 | JSBool res = JS_TRUE; |
| 6169 | 0 | soapFaultPtr fault = NULL; |
| 6170 | 0 | GlobusFuncName(soapFaultGetter); |
| 6171 | 0 | GlobusWSDLDebugEnter(); |
| 6172 | ||
| 6173 | 0 | fault = (soapFaultPtr) JS_GetPrivate(cx, obj); |
| 6174 | 0 | globus_assert(fault); |
| 6175 | ||
| 6176 | 0 | if(!JSVAL_IS_INT(jid)) |
| 6177 | { | |
| 6178 | 0 | JS_ReportError(cx, |
| 6179 | "Invalid id type (expected int) " | |
| 6180 | "for soap fault property"); | |
| 6181 | 0 | res = JS_FALSE; |
| 6182 | 0 | goto exit; |
| 6183 | } | |
| 6184 | ||
| 6185 | 0 | idval = JSVAL_TO_INT(jid); |
| 6186 | ||
| 6187 | 0 | switch(idval) |
| 6188 | { | |
| 6189 | case use: | |
| 6190 | ||
| 6191 | 0 | *vp = INT_TO_JSVAL(fault->use); |
| 6192 | 0 | break; |
| 6193 | ||
| 6194 | case encodingStyle: | |
| 6195 | ||
| 6196 | 0 | if(!fault->encodingStyle) |
| 6197 | { | |
| 6198 | 0 | *vp = JSVAL_VOID; |
| 6199 | 0 | break; |
| 6200 | } | |
| 6201 | ||
| 6202 | 0 | str = JS_InternString(cx, (const char *) fault->encodingStyle); |
| 6203 | 0 | globus_assert(str); |
| 6204 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6205 | 0 | break; |
| 6206 | ||
| 6207 | case Namespace: | |
| 6208 | ||
| 6209 | 0 | if(!fault->Namespace) |
| 6210 | { | |
| 6211 | 0 | *vp = JSVAL_VOID; |
| 6212 | } | |
| 6213 | ||
| 6214 | 0 | str = JS_InternString(cx, (const char *) fault->Namespace); |
| 6215 | 0 | globus_assert(str); |
| 6216 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6217 | 0 | break; |
| 6218 | ||
| 6219 | default: | |
| 6220 | ||
| 6221 | 0 | *vp = JSVAL_VOID; |
| 6222 | 0 | JS_ReportError(cx, |
| 6223 | "Unknown soap fault property " | |
| 6224 | "with id %d", idval); | |
| 6225 | 0 | res = JS_FALSE; |
| 6226 | goto exit; | |
| 6227 | } | |
| 6228 | ||
| 6229 | exit: | |
| 6230 | ||
| 6231 | 0 | GlobusWSDLDebugExit(); |
| 6232 | 0 | return res; |
| 6233 | } | |
| 6234 | ||
| 6235 | static | |
| 6236 | JSBool | |
| 6237 | soapAddressGetter( | |
| 6238 | JSContext * cx, | |
| 6239 | JSObject * obj, | |
| 6240 | jsval jid, | |
| 6241 | jsval * vp) | |
| 6242 | 0 | { |
| 6243 | 0 | JSString * str = NULL; |
| 6244 | 0 | int idval; |
| 6245 | 0 | JSBool res = JS_TRUE; |
| 6246 | 0 | soapAddressPtr address = NULL; |
| 6247 | 0 | GlobusFuncName(soapAddressGetter); |
| 6248 | 0 | GlobusWSDLDebugEnter(); |
| 6249 | ||
| 6250 | 0 | address = (soapAddressPtr) JS_GetPrivate(cx, obj); |
| 6251 | 0 | globus_assert(address); |
| 6252 | ||
| 6253 | 0 | if(!JSVAL_IS_INT(jid)) |
| 6254 | { | |
| 6255 | 0 | JS_ReportError(cx, |
| 6256 | "Invalid id type (expected int) " | |
| 6257 | "for soap address property"); | |
| 6258 | 0 | res = JS_FALSE; |
| 6259 | 0 | goto exit; |
| 6260 | } | |
| 6261 | ||
| 6262 | 0 | idval = JSVAL_TO_INT(jid); |
| 6263 | ||
| 6264 | 0 | switch(idval) |
| 6265 | { | |
| 6266 | case location: | |
| 6267 | ||
| 6268 | 0 | if(!address->location) |
| 6269 | { | |
| 6270 | 0 | *vp = JSVAL_VOID; |
| 6271 | 0 | break; |
| 6272 | } | |
| 6273 | ||
| 6274 | 0 | str = JS_InternString(cx, (const char *) address->location); |
| 6275 | 0 | globus_assert(str); |
| 6276 | 0 | *vp = STRING_TO_JSVAL(str); |
| 6277 | 0 | break; |
| 6278 | ||
| 6279 | default: | |
| 6280 | ||
| 6281 | 0 | *vp = JSVAL_VOID; |
| 6282 | 0 | JS_ReportError(cx, |
| 6283 | "Unknown soap address property " | |
| 6284 | "with id %d", idval); | |
| 6285 | 0 | res = JS_FALSE; |
| 6286 | goto exit; | |
| 6287 | } | |
| 6288 | ||
| 6289 | exit: | |
| 6290 | ||
| 6291 | 0 | GlobusWSDLDebugExit(); |
| 6292 | 0 | return res; |
| 6293 | } | |
| 6294 | ||
| 6295 | static | |
| 6296 | JSBool | |
| 6297 | soapBindingParamGetter( | |
| 6298 | JSContext * cx, | |
| 6299 | JSObject * obj, | |
| 6300 | jsval jid, | |
| 6301 | jsval * vp) | |
| 6302 | 0 | { |
| 6303 | 0 | JSObject * newObj = NULL; |
| 6304 | 0 | int idval; |
| 6305 | 0 | JSBool res = JS_TRUE; |
| 6306 | 0 | soapBindingParamPtr param = NULL; |
| 6307 | 0 | GlobusFuncName(soapBindingParamGetter); |
| 6308 | 0 | GlobusWSDLDebugEnter(); |
| 6309 | ||
| 6310 | 0 | param = (soapBindingParamPtr) JS_GetPrivate(cx, obj); |
| 6311 | 0 | globus_assert(param); |
| 6312 | ||
| 6313 | 0 | if(!JSVAL_IS_INT(jid)) |
| 6314 | { | |
| 6315 | 0 | JS_ReportError(cx, |
| 6316 | "Invalid id type (expected int) " | |
| 6317 | "for soap binding param property"); | |
| 6318 | 0 | res = JS_FALSE; |
| 6319 | 0 | goto exit; |
| 6320 | } | |
| 6321 | ||
| 6322 | 0 | idval = JSVAL_TO_INT(jid); |
| 6323 | ||
| 6324 | 0 | switch(idval) |
| 6325 | { | |
| 6326 | case header: | |
| 6327 | ||
| 6328 | 0 | if(!param->header) |
| 6329 | { | |
| 6330 | 0 | *vp = JSVAL_VOID; |
| 6331 | 0 | break; |
| 6332 | } | |
| 6333 | ||
| 6334 | 0 | newObj = JS_NewObject(cx, &soapHeader_class, soapHeaderClass, obj); |
| 6335 | 0 | globus_assert(newObj); |
| 6336 | 0 | JS_SetPrivate(cx, newObj, (void *)param->header); |
| 6337 | 0 | JS_DefineProperties(cx, newObj, soapHeader_properties); |
| 6338 | 0 | *vp = OBJECT_TO_JSVAL(newObj); |
| 6339 | 0 | break; |
| 6340 | ||
| 6341 | case body: | |
| 6342 | ||
| 6343 | 0 | if(!param->body) |
| 6344 | { | |
| 6345 | 0 | *vp = JSVAL_VOID; |
| 6346 | 0 | break; |
| 6347 | } | |
| 6348 | ||
| 6349 | 0 | newObj = JS_NewObject(cx, &soapBody_class, soapBodyClass, obj); |
| 6350 | 0 | globus_assert(newObj); |
| 6351 | 0 | JS_SetPrivate(cx, newObj, (void *)param->body); |
| 6352 | 0 | JS_DefineProperties(cx, newObj, soapBody_properties); |
| 6353 | 0 | *vp = OBJECT_TO_JSVAL(newObj); |
| 6354 | 0 | break; |
| 6355 | ||
| 6356 | case fault: | |
| 6357 | ||
| 6358 | 0 | if(!param->fault) |
| 6359 | { | |
| 6360 | 0 | *vp = JSVAL_VOID; |
| 6361 | 0 | break; |
| 6362 | } | |
| 6363 | ||
| 6364 | 0 | newObj = JS_NewObject(cx, &soapFault_class, soapFaultClass, obj); |
| 6365 | 0 | globus_assert(newObj); |
| 6366 | 0 | JS_SetPrivate(cx, newObj, (void *)param->fault); |
| 6367 | 0 | JS_DefineProperties(cx, newObj, soapFault_properties); |
| 6368 | 0 | *vp = OBJECT_TO_JSVAL(newObj); |
| 6369 | 0 | break; |
| 6370 | ||
| 6371 | default: | |
| 6372 | ||
| 6373 | 0 | *vp = JSVAL_VOID; |
| 6374 | 0 | JS_ReportError(cx, |
| 6375 | "Unknown soap binding property " | |
| 6376 | "with id %d for part", idval); | |
| 6377 | 0 | res = JS_FALSE; |
| 6378 | goto exit; | |
| 6379 | } | |
| 6380 | ||
| 6381 | exit: | |
| 6382 | ||
| 6383 | 0 | GlobusWSDLDebugExit(); |
| 6384 | 0 | return res; |
| 6385 | } | |
| 6386 | ||
| 6387 | static | |
| 6388 | void | |
| 6389 | globus_i_wsdl_parser_import_scanner( | |
| 6390 | void * payload, | |
| 6391 | void * data, | |
| 6392 | xmlChar * name) | |
| 6393 | 0 | { |
| 6394 | 0 | xmlSchemaImportPtr import; |
| 6395 | 0 | xmlSchemaPtr schema; |
| 6396 | 0 | ScannerData * dt; |
| 6397 | 0 | GlobusFuncName(globus_i_wsdl_parser_import_scanner); |
| 6398 | 0 | GlobusWSDLDebugEnter(); |
| 6399 | ||
| 6400 | 0 | dt = (ScannerData *) data; |
| 6401 | 0 | import = (xmlSchemaImportPtr) payload; |
| 6402 | ||
| 6403 | 0 | if(dt->result != GLOBUS_SUCCESS) |
| 6404 | { | |
| 6405 | 0 | goto exit; |
| 6406 | } | |
| 6407 | ||
| 6408 | 0 | schema = import->schema; |
| 6409 | ||
| 6410 | 0 | if(schema) |
| 6411 | { | |
| 6412 | 0 | dt->xsdSchema = schema; |
| 6413 | 0 | xmlHashScan(schema->schemasImports, |
| 6414 | globus_i_wsdl_parser_import_scanner, data); | |
| 6415 | 0 | if(dt->result != GLOBUS_SUCCESS) |
| 6416 | { | |
| 6417 | 0 | dt->result = GlobusWSDLErrorJSLoadSchema(dt->result); |
| 6418 | 0 | goto exit; |
| 6419 | } | |
| 6420 | ||
| 6421 | 0 | dt->xsdSchema = schema; |
| 6422 | 0 | xmlHashScan(schema->typeDecl, globus_i_wsdl_parser_type_scanner, data); |
| 6423 | 0 | if(dt->result != GLOBUS_SUCCESS) |
| 6424 | { | |
| 6425 | 0 | dt->result = GlobusWSDLErrorJSLoadSchema(dt->result); |
| 6426 | 0 | goto exit; |
| 6427 | } | |
| 6428 | ||
| 6429 | 0 | xmlHashScan(schema->groupDecl, globus_i_wsdl_parser_type_scanner, data); |
| 6430 | 0 | if(dt->result != GLOBUS_SUCCESS) |
| 6431 | { | |
| 6432 | 0 | dt->result = GlobusWSDLErrorJSLoadSchema(dt->result); |
| 6433 | 0 | goto exit; |
| 6434 | } | |
| 6435 | ||
| 6436 | 0 | xmlHashScan(schema->elemDecl, |
| 6437 | globus_i_wsdl_parser_element_scanner, | |
| 6438 | data); | |
| 6439 | 0 | if(dt->result != GLOBUS_SUCCESS) |
| 6440 | { | |
| 6441 | 0 | dt->result = GlobusWSDLErrorJSLoadSchema(dt->result); |
| 6442 | 0 | goto exit; |
| 6443 | } | |
| 6444 | ||
| 6445 | 0 | xmlHashScan(schema->attrDecl, |
| 6446 | globus_i_wsdl_parser_attribute_scanner, | |
| 6447 | data); | |
| 6448 | 0 | if(dt->result != GLOBUS_SUCCESS) |
| 6449 | { | |
| 6450 | 0 | dt->result = GlobusWSDLErrorJSLoadSchema(dt->result); |
| 6451 | goto exit; | |
| 6452 | } | |
| 6453 | } | |
| 6454 | ||
| 6455 | exit: | |
| 6456 | ||
| 6457 | 0 | GlobusWSDLDebugExit(); |
| 6458 | } | |
| 6459 | ||
| 6460 | static | |
| 6461 | void | |
| 6462 | globus_i_wsdl_parser_type_scanner( | |
| 6463 | void * payload, | |
| 6464 | void * data, | |
| 6465 | xmlChar * name) | |
| 6466 | 0 | { |
| 6467 | 0 | xmlSchemaTypePtr xsdType; |
| 6468 | 0 | wsdlSchemaPtr schema; |
| 6469 | 0 | xmlSchemaPtr xsdSchema; |
| 6470 | 0 | JSContext * cx; |
| 6471 | 0 | jsval val; |
| 6472 | 0 | JSObject * typeObj; |
| 6473 | 0 | JSObject * types; |
| 6474 | 0 | JSObject * global; |
| 6475 | 0 | JSString * str; |
| 6476 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6477 | 0 | GlobusFuncName(globus_i_wsdl_parser_type_scanner); |
| 6478 | 0 | GlobusWSDLDebugEnter(); |
| 6479 | ||
| 6480 | 0 | xsdType = (xmlSchemaTypePtr) payload; |
| 6481 | 0 | schema = ((ScannerData *)data)->schema; |
| 6482 | 0 | xsdSchema = ((ScannerData *)data)->xsdSchema; |
| 6483 | 0 | cx = ((ScannerData *)data)->context; |
| 6484 | 0 | global = ((ScannerData *)data)->global; |
| 6485 | 0 | types = ((ScannerData *)data)->types; |
| 6486 | 0 | result = ((ScannerData *)data)->result; |
| 6487 | ||
| 6488 | 0 | if(result != GLOBUS_SUCCESS) |
| 6489 | { | |
| 6490 | 0 | goto exit; |
| 6491 | } | |
| 6492 | ||
| 6493 | 0 | if(xsdType->targetNamespace) |
| 6494 | { | |
| 6495 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 6496 | cx, xsdType->targetNamespace, xsdType->name); | |
| 6497 | } | |
| 6498 | 0 | else if(xsdSchema->targetNamespace) |
| 6499 | { | |
| 6500 | 0 | xsdType->targetNamespace = xsdSchema->targetNamespace; |
| 6501 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 6502 | cx, xsdSchema->targetNamespace, xsdType->name); | |
| 6503 | } | |
| 6504 | 0 | else if(schema->targetNamespace) |
| 6505 | { | |
| 6506 | 0 | xsdType->targetNamespace = schema->targetNamespace; |
| 6507 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 6508 | cx, schema->targetNamespace, xsdType->name); | |
| 6509 | } | |
| 6510 | else | |
| 6511 | { | |
| 6512 | 0 | JS_ReportError(cx, |
| 6513 | "Can't find namespace for type: %s", | |
| 6514 | xsdType->name); | |
| 6515 | 0 | result = GlobusWSDLErrorScanningTypes( |
| 6516 | GLOBUS_NULL, xsdType->name); | |
| 6517 | 0 | goto exit; |
| 6518 | } | |
| 6519 | ||
| 6520 | 0 | typeObj = JS_NewObject(cx, &xsdType_class, xsdTypeClass, types); |
| 6521 | 0 | globus_assert(typeObj); |
| 6522 | 0 | JS_SetPrivate(cx, typeObj, (void *)xsdType); |
| 6523 | 0 | JS_DefineProperties(cx, typeObj, xsdType_properties); |
| 6524 | ||
| 6525 | 0 | val = OBJECT_TO_JSVAL(typeObj); |
| 6526 | ||
| 6527 | 0 | if(!JS_DefineProperty( |
| 6528 | cx, types, (const char *)JS_GetStringBytes(str), | |
| 6529 | val, NULL, NULL, | |
| 6530 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6531 | { | |
| 6532 | 0 | JS_ReportError(cx, "Failed to define type from parsed WSDL"); |
| 6533 | 0 | result = GlobusWSDLErrorScanningTypes( |
| 6534 | GLOBUS_NULL, xsdType->name); | |
| 6535 | goto exit; | |
| 6536 | } | |
| 6537 | ||
| 6538 | exit: | |
| 6539 | ||
| 6540 | 0 | GlobusWSDLDebugExit(); |
| 6541 | 0 | ((ScannerData *)data)->result = result; |
| 6542 | } | |
| 6543 | ||
| 6544 | static | |
| 6545 | void | |
| 6546 | globus_i_wsdl_parser_element_scanner( | |
| 6547 | void * payload, | |
| 6548 | void * data, | |
| 6549 | xmlChar * name) | |
| 6550 | 0 | { |
| 6551 | 0 | xmlSchemaElementPtr element; |
| 6552 | 0 | wsdlSchemaPtr schema; |
| 6553 | 0 | xmlSchemaPtr xsdSchema; |
| 6554 | 0 | JSContext * cx; |
| 6555 | 0 | jsval val; |
| 6556 | 0 | JSObject * elements; |
| 6557 | 0 | JSObject * local_elements; |
| 6558 | 0 | JSObject * global; |
| 6559 | 0 | JSObject * elemObj; |
| 6560 | 0 | JSString * str; |
| 6561 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6562 | 0 | GlobusFuncName(globus_i_wsdl_parser_element_scanner); |
| 6563 | 0 | GlobusWSDLDebugEnter(); |
| 6564 | ||
| 6565 | 0 | element = (xmlSchemaElementPtr) payload; |
| 6566 | 0 | schema = ((ScannerData *)data)->schema; |
| 6567 | 0 | xsdSchema = ((ScannerData *)data)->xsdSchema; |
| 6568 | 0 | cx = ((ScannerData *)data)->context; |
| 6569 | 0 | global = ((ScannerData *)data)->global; |
| 6570 | 0 | elements = ((ScannerData *)data)->elements; |
| 6571 | 0 | local_elements = ((ScannerData *)data)->local_elements; |
| 6572 | 0 | result = ((ScannerData *)data)->result; |
| 6573 | ||
| 6574 | 0 | if(result != GLOBUS_SUCCESS) |
| 6575 | { | |
| 6576 | 0 | goto exit; |
| 6577 | } | |
| 6578 | ||
| 6579 | ||
| 6580 | 0 | if(!element->targetNamespace) |
| 6581 | { | |
| 6582 | 0 | if((element->flags & XML_SCHEMAS_ELEM_GLOBAL) || |
| 6583 | (xsdSchema->flags & XML_SCHEMAS_QUALIF_ELEM)) | |
| 6584 | { | |
| 6585 | 0 | element->targetNamespace = xsdSchema->targetNamespace; |
| 6586 | } | |
| 6587 | } | |
| 6588 | ||
| 6589 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 6590 | cx, element->targetNamespace, element->name); | |
| 6591 | ||
| 6592 | 0 | if(element->flags & XML_SCHEMAS_ELEM_GLOBAL) |
| 6593 | { | |
| 6594 | 0 | elemObj = JS_NewObject(cx, &xsdElement_class, |
| 6595 | xsdElementClass, elements); | |
| 6596 | 0 | globus_assert(elemObj); |
| 6597 | 0 | JS_SetPrivate(cx, elemObj, (void *)element); |
| 6598 | 0 | JS_DefineProperties(cx, elemObj, xsdElement_properties); |
| 6599 | ||
| 6600 | 0 | val = OBJECT_TO_JSVAL(elemObj); |
| 6601 | ||
| 6602 | 0 | if(!JS_DefineProperty( |
| 6603 | cx, elements, (const char *) JS_GetStringBytes(str), | |
| 6604 | val, NULL, NULL, | |
| 6605 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6606 | { | |
| 6607 | 0 | JS_ReportError(cx, "Failed to define element from parsed WSDL"); |
| 6608 | 0 | result = GlobusWSDLErrorScanningElements( |
| 6609 | GLOBUS_NULL, element->name); | |
| 6610 | 0 | goto exit; |
| 6611 | } | |
| 6612 | } | |
| 6613 | else | |
| 6614 | { | |
| 6615 | 0 | elemObj = JS_NewObject(cx, &xsdElement_class, |
| 6616 | xsdElementClass, local_elements); | |
| 6617 | 0 | globus_assert(elemObj); |
| 6618 | 0 | JS_SetPrivate(cx, elemObj, (void *)element); |
| 6619 | 0 | JS_DefineProperties(cx, elemObj, xsdElement_properties); |
| 6620 | ||
| 6621 | 0 | val = OBJECT_TO_JSVAL(elemObj); |
| 6622 | ||
| 6623 | 0 | if(!JS_DefineProperty( |
| 6624 | cx, local_elements, (const char *) JS_GetStringBytes(str), | |
| 6625 | val, NULL, NULL, | |
| 6626 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6627 | { | |
| 6628 | 0 | JS_ReportError(cx, "Failed to define element from parsed WSDL"); |
| 6629 | 0 | result = GlobusWSDLErrorScanningElements( |
| 6630 | GLOBUS_NULL, element->name); | |
| 6631 | goto exit; | |
| 6632 | } | |
| 6633 | } | |
| 6634 | ||
| 6635 | exit: | |
| 6636 | ||
| 6637 | 0 | GlobusWSDLDebugExit(); |
| 6638 | 0 | ((ScannerData *)data)->result = result; |
| 6639 | } | |
| 6640 | ||
| 6641 | static | |
| 6642 | void | |
| 6643 | globus_i_wsdl_parser_attribute_scanner( | |
| 6644 | void * payload, | |
| 6645 | void * data, | |
| 6646 | xmlChar * name) | |
| 6647 | 0 | { |
| 6648 | 0 | xmlSchemaAttributePtr attribute; |
| 6649 | 0 | wsdlSchemaPtr schema; |
| 6650 | 0 | xmlSchemaPtr xsdSchema; |
| 6651 | 0 | JSContext * cx; |
| 6652 | 0 | jsval val; |
| 6653 | 0 | JSObject * attributes; |
| 6654 | 0 | JSObject * local_attributes; |
| 6655 | 0 | JSObject * global; |
| 6656 | 0 | JSObject * attrObj; |
| 6657 | 0 | JSString * str; |
| 6658 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6659 | 0 | GlobusFuncName(globus_i_wsdl_parser_attribute_scanner); |
| 6660 | 0 | GlobusWSDLDebugEnter(); |
| 6661 | ||
| 6662 | 0 | attribute = (xmlSchemaAttributePtr) payload; |
| 6663 | 0 | schema = ((ScannerData *)data)->schema; |
| 6664 | 0 | xsdSchema = ((ScannerData *)data)->xsdSchema; |
| 6665 | 0 | cx = ((ScannerData *)data)->context; |
| 6666 | 0 | global = ((ScannerData *)data)->global; |
| 6667 | 0 | attributes = ((ScannerData *)data)->attributes; |
| 6668 | 0 | local_attributes = ((ScannerData *)data)->local_attributes; |
| 6669 | 0 | result = ((ScannerData *)data)->result; |
| 6670 | ||
| 6671 | 0 | if(result != GLOBUS_SUCCESS) |
| 6672 | { | |
| 6673 | 0 | goto exit; |
| 6674 | } | |
| 6675 | ||
| 6676 | 0 | if(!attribute->targetNamespace) |
| 6677 | { | |
| 6678 | 0 | if((attribute->flags & XML_SCHEMAS_ATTR_GLOBAL) || |
| 6679 | (xsdSchema->flags & XML_SCHEMAS_QUALIF_ATTR)) | |
| 6680 | { | |
| 6681 | 0 | attribute->targetNamespace = xsdSchema->targetNamespace; |
| 6682 | } | |
| 6683 | } | |
| 6684 | ||
| 6685 | 0 | str = globus_l_wsdl_jscript_qname_string( |
| 6686 | cx, attribute->targetNamespace, attribute->name); | |
| 6687 | ||
| 6688 | 0 | if(attribute->flags & XML_SCHEMAS_ATTR_GLOBAL) |
| 6689 | { | |
| 6690 | 0 | attrObj = JS_NewObject( |
| 6691 | cx, &xsdAttr_class, xsdAttrClass, attributes); | |
| 6692 | 0 | globus_assert(attrObj); |
| 6693 | 0 | JS_SetPrivate(cx, attrObj, (void *)attribute); |
| 6694 | 0 | JS_DefineProperties(cx, attrObj, xsdAttr_properties); |
| 6695 | ||
| 6696 | 0 | val = OBJECT_TO_JSVAL(attrObj); |
| 6697 | ||
| 6698 | 0 | JS_DefineProperty( |
| 6699 | cx, attributes, (const char *) JS_GetStringBytes(str), | |
| 6700 | val, NULL, NULL, | |
| 6701 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT); | |
| 6702 | } | |
| 6703 | else | |
| 6704 | { | |
| 6705 | 0 | attrObj = JS_NewObject( |
| 6706 | cx, &xsdAttr_class, xsdAttrClass, local_attributes); | |
| 6707 | 0 | globus_assert(attrObj); |
| 6708 | 0 | JS_SetPrivate(cx, attrObj, (void *)attribute); |
| 6709 | 0 | JS_DefineProperties(cx, attrObj, xsdAttr_properties); |
| 6710 | ||
| 6711 | 0 | val = OBJECT_TO_JSVAL(attrObj); |
| 6712 | ||
| 6713 | 0 | JS_DefineProperty( |
| 6714 | cx, local_attributes, (const char *) JS_GetStringBytes(str), | |
| 6715 | val, NULL, NULL, | |
| 6716 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT); | |
| 6717 | } | |
| 6718 | ||
| 6719 | exit: | |
| 6720 | ||
| 6721 | 0 | GlobusWSDLDebugExit(); |
| 6722 | 0 | ((ScannerData *)data)->result = result; |
| 6723 | } | |
| 6724 | ||
| 6725 | static | |
| 6726 | void | |
| 6727 | globus_i_wsdl_parser_message_scanner( | |
| 6728 | void * payload, | |
| 6729 | void * data, | |
| 6730 | xmlChar * name) | |
| 6731 | 0 | { |
| 6732 | 0 | wsdlMessagePtr message; |
| 6733 | 0 | JSContext * cx; |
| 6734 | 0 | jsval val; |
| 6735 | 0 | JSObject * messages; |
| 6736 | 0 | JSObject * messageObj; |
| 6737 | 0 | JSObject * global; |
| 6738 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6739 | 0 | GlobusFuncName(globus_i_wsdl_parser_message_scanner); |
| 6740 | 0 | GlobusWSDLDebugEnter(); |
| 6741 | ||
| 6742 | 0 | message = (wsdlMessagePtr) payload; |
| 6743 | 0 | cx = ((ScannerData *)data)->context; |
| 6744 | 0 | global = ((ScannerData *)data)->global; |
| 6745 | 0 | messages = ((ScannerData *)data)->messages; |
| 6746 | 0 | result = ((ScannerData *)data)->result; |
| 6747 | ||
| 6748 | 0 | if(result != GLOBUS_SUCCESS) |
| 6749 | { | |
| 6750 | 0 | goto exit; |
| 6751 | } | |
| 6752 | ||
| 6753 | 0 | messageObj = JS_NewObject(cx, &message_class, messageClass, messages); |
| 6754 | 0 | globus_assert(messageObj); |
| 6755 | 0 | JS_SetPrivate(cx, messageObj, (void *)message); |
| 6756 | 0 | JS_DefineProperties(cx, messageObj, message_properties); |
| 6757 | ||
| 6758 | 0 | val = OBJECT_TO_JSVAL(messageObj); |
| 6759 | ||
| 6760 | 0 | if(!JS_DefineProperty(cx, messages, (const char *)name, val, NULL, NULL, |
| 6761 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6762 | { | |
| 6763 | 0 | JS_ReportError(cx, "Failed to define message from parsed WSDL"); |
| 6764 | 0 | result = GlobusWSDLErrorScanningMessages(GLOBUS_NULL, message->name); |
| 6765 | goto exit; | |
| 6766 | } | |
| 6767 | ||
| 6768 | ||
| 6769 | exit: | |
| 6770 | ||
| 6771 | 0 | GlobusWSDLDebugExit(); |
| 6772 | 0 | ((ScannerData *)data)->result = result; |
| 6773 | } | |
| 6774 | ||
| 6775 | static | |
| 6776 | void | |
| 6777 | globus_i_wsdl_parser_portType_scanner( | |
| 6778 | void * payload, | |
| 6779 | void * data, | |
| 6780 | xmlChar * name) | |
| 6781 | 0 | { |
| 6782 | 0 | wsdlPortTypePtr portType; |
| 6783 | 0 | JSContext * cx; |
| 6784 | 0 | jsval val; |
| 6785 | 0 | JSObject * portTypes; |
| 6786 | 0 | JSObject * global; |
| 6787 | 0 | JSObject * portTypeObj; |
| 6788 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6789 | 0 | GlobusFuncName(globus_i_wsdl_parser_portType_scanner); |
| 6790 | 0 | GlobusWSDLDebugEnter(); |
| 6791 | ||
| 6792 | 0 | portType = (wsdlPortTypePtr) payload; |
| 6793 | 0 | cx = ((ScannerData *)data)->context; |
| 6794 | 0 | global = ((ScannerData *)data)->global; |
| 6795 | 0 | portTypes = ((ScannerData *)data)->portTypes; |
| 6796 | 0 | result = ((ScannerData *)data)->result; |
| 6797 | ||
| 6798 | 0 | if(result != GLOBUS_SUCCESS) |
| 6799 | { | |
| 6800 | 0 | goto exit; |
| 6801 | } | |
| 6802 | ||
| 6803 | 0 | portTypeObj = JS_NewObject(cx, &portType_class, portTypeClass, portTypes); |
| 6804 | 0 | globus_assert(portTypeObj); |
| 6805 | 0 | JS_SetPrivate(cx, portTypeObj, (void *)portType); |
| 6806 | 0 | JS_DefineProperties(cx, portTypeObj, portType_properties); |
| 6807 | ||
| 6808 | 0 | val = OBJECT_TO_JSVAL(portTypeObj); |
| 6809 | ||
| 6810 | 0 | if(!JS_DefineProperty(cx, portTypes, (const char *)name, val, NULL, NULL, |
| 6811 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6812 | { | |
| 6813 | 0 | JS_ReportError(cx, "Failed to define portType from parsed WSDL"); |
| 6814 | 0 | result = GlobusWSDLErrorScanningPortTypes(GLOBUS_NULL, portType->name); |
| 6815 | goto exit; | |
| 6816 | } | |
| 6817 | ||
| 6818 | ||
| 6819 | exit: | |
| 6820 | ||
| 6821 | 0 | GlobusWSDLDebugExit(); |
| 6822 | 0 | ((ScannerData *)data)->result = result; |
| 6823 | } | |
| 6824 | ||
| 6825 | static | |
| 6826 | void | |
| 6827 | globus_i_wsdl_parser_binding_scanner( | |
| 6828 | void * payload, | |
| 6829 | void * data, | |
| 6830 | xmlChar * name) | |
| 6831 | 0 | { |
| 6832 | 0 | wsdlBindingPtr binding; |
| 6833 | 0 | JSContext * cx; |
| 6834 | 0 | jsval val; |
| 6835 | 0 | JSObject * bindings; |
| 6836 | 0 | JSObject * global; |
| 6837 | 0 | JSObject * bindingObj; |
| 6838 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6839 | 0 | GlobusFuncName(globus_i_wsdl_parser_binding_scanner); |
| 6840 | 0 | GlobusWSDLDebugEnter(); |
| 6841 | ||
| 6842 | 0 | binding = (wsdlBindingPtr) payload; |
| 6843 | 0 | cx = ((ScannerData *)data)->context; |
| 6844 | 0 | global = ((ScannerData *)data)->global; |
| 6845 | 0 | bindings = ((ScannerData *)data)->bindings; |
| 6846 | 0 | result = ((ScannerData *)data)->result; |
| 6847 | ||
| 6848 | 0 | if(result != GLOBUS_SUCCESS) |
| 6849 | { | |
| 6850 | 0 | goto exit; |
| 6851 | } | |
| 6852 | ||
| 6853 | 0 | bindingObj = JS_NewObject(cx, &binding_class, bindingClass, bindings); |
| 6854 | 0 | globus_assert(bindingObj); |
| 6855 | 0 | JS_SetPrivate(cx, bindingObj, (void *)binding); |
| 6856 | ||
| 6857 | 0 | val = OBJECT_TO_JSVAL(bindingObj); |
| 6858 | ||
| 6859 | 0 | if(!JS_DefineProperty(cx, bindings, (const char *)name, val, NULL, NULL, |
| 6860 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6861 | { | |
| 6862 | 0 | JS_ReportError(cx, "Failed to define binding from parsed WSDL"); |
| 6863 | 0 | result = GlobusWSDLErrorScanningBindings(GLOBUS_NULL, binding->name); |
| 6864 | goto exit; | |
| 6865 | } | |
| 6866 | ||
| 6867 | ||
| 6868 | exit: | |
| 6869 | ||
| 6870 | 0 | GlobusWSDLDebugExit(); |
| 6871 | 0 | ((ScannerData *)data)->result = result; |
| 6872 | } | |
| 6873 | ||
| 6874 | static | |
| 6875 | void | |
| 6876 | globus_i_wsdl_parser_service_scanner( | |
| 6877 | void * payload, | |
| 6878 | void * data, | |
| 6879 | xmlChar * name) | |
| 6880 | 0 | { |
| 6881 | 0 | wsdlServicePtr service = NULL; |
| 6882 | 0 | JSContext * cx = NULL; |
| 6883 | 0 | jsval val; |
| 6884 | 0 | JSObject * services = NULL; |
| 6885 | 0 | JSObject * global = NULL; |
| 6886 | 0 | JSObject * serviceObj = NULL; |
| 6887 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6888 | 0 | GlobusFuncName(globus_i_wsdl_parser_service_scanner); |
| 6889 | 0 | GlobusWSDLDebugEnter(); |
| 6890 | ||
| 6891 | 0 | service = (wsdlServicePtr) payload; |
| 6892 | 0 | cx = ((ScannerData *)data)->context; |
| 6893 | 0 | global = ((ScannerData *)data)->global; |
| 6894 | 0 | services = ((ScannerData *)data)->services; |
| 6895 | 0 | result = ((ScannerData *)data)->result; |
| 6896 | ||
| 6897 | 0 | if(result != GLOBUS_SUCCESS) |
| 6898 | { | |
| 6899 | 0 | goto exit; |
| 6900 | } | |
| 6901 | ||
| 6902 | 0 | serviceObj = JS_NewObject(cx, &service_class, serviceClass, services); |
| 6903 | 0 | globus_assert(serviceObj); |
| 6904 | 0 | JS_SetPrivate(cx, serviceObj, (void *)service); |
| 6905 | 0 | JS_DefineProperties(cx, serviceObj, service_properties); |
| 6906 | ||
| 6907 | 0 | val = OBJECT_TO_JSVAL(serviceObj); |
| 6908 | ||
| 6909 | 0 | if(!JS_DefineProperty(cx, services, (const char *)name, val, NULL, NULL, |
| 6910 | JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)) | |
| 6911 | { | |
| 6912 | 0 | JS_ReportError(cx, "Failed to define service from parsed WSDL"); |
| 6913 | 0 | result = GlobusWSDLErrorScanningServices(GLOBUS_NULL, service->name); |
| 6914 | goto exit; | |
| 6915 | } | |
| 6916 | ||
| 6917 | exit: | |
| 6918 | ||
| 6919 | 0 | GlobusWSDLDebugExit(); |
| 6920 | 0 | ((ScannerData *)data)->result = result; |
| 6921 | } | |
| 6922 | ||
| 6923 | static | |
| 6924 | void | |
| 6925 | globus_i_wsdl_parser_wsdl_imports_scanner( | |
| 6926 | void * payload, | |
| 6927 | void * data, | |
| 6928 | xmlChar * name) | |
| 6929 | 0 | { |
| 6930 | 0 | wsdlImportPtr import = NULL; |
| 6931 | 0 | JSContext * cx = NULL; |
| 6932 | 0 | JSObject * global = NULL; |
| 6933 | 0 | globus_result_t result = GLOBUS_SUCCESS; |
| 6934 | 0 | GlobusFuncName(globus_i_wsdl_parser_wsdl_imports_scanner); |
| 6935 | 0 | GlobusWSDLDebugEnter(); |
| 6936 | ||
| 6937 | 0 | import = (wsdlImportPtr) payload; |
| 6938 | 0 | cx = ((ScannerData *)data)->context; |
| 6939 | 0 | global = ((ScannerData *)data)->global; |
| 6940 | 0 | result = ((ScannerData *)data)->result; |
| 6941 | ||
| 6942 | 0 | if(result != GLOBUS_SUCCESS) |
| 6943 | { | |
| 6944 | 0 | goto exit; |
| 6945 | } | |
| 6946 | ||
| 6947 | 0 | ((ScannerData *)data)->schema = import->schema; |
| 6948 | 0 | result = globus_i_wsdl_js_load_imported_schema(cx, import->schema); |
| 6949 | 0 | if(result != GLOBUS_SUCCESS) |
| 6950 | { | |
| 6951 | 0 | JS_ReportError(cx, "Failed to load WSDL schema"); |
| 6952 | 0 | result = GlobusWSDLErrorScanningImports( |
| 6953 | GLOBUS_NULL, import->wsdlLocation); | |
| 6954 | goto exit; | |
| 6955 | } | |
| 6956 | ||
| 6957 | exit: | |
| 6958 | ||
| 6959 | 0 | GlobusWSDLDebugExit(); |
| 6960 | 0 | ((ScannerData *)data)->result = result; |
| 6961 | } | |
| 6962 | ||
| 6963 | static void | |
| 6964 | TemplateFree( | |
| 6965 | void * template) | |
| 6966 | 0 | { |
| 6967 | 0 | Template * tmpl = (Template *) template; |
| 6968 | 0 | if(tmpl) |
| 6969 | { | |
| 6970 | 0 | if(tmpl->filename) |
| 6971 | { | |
| 6972 | 0 | free(tmpl->filename); |
| 6973 | } | |
| 6974 | ||
| 6975 | 0 | if(tmpl->buffer) |
| 6976 | { | |
| 6977 | 0 | free(tmpl->buffer); |
| 6978 | } | |
| 6979 | ||
| 6980 | 0 | free(tmpl); |
| 6981 | } |