Changeset 108321 in vbox
- Timestamp:
- Feb 21, 2025 11:24:09 AM (3 weeks ago)
- svn:sync-xref-src-repo-rev:
- 167667
- Location:
- trunk/src/libs/xpcom18a4/xpcom/typelib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl-new/xpidl.c
r108320 r108321 242 242 * multiply. 243 243 */ 244 if (xpidl_process_idl(argv[i], &LstIncludePaths, file_basename, mode)) 244 int rc = xpidl_process_idl(argv[i], &LstIncludePaths, file_basename, mode); 245 if (RT_SUCCESS(rc)) 245 246 return 0; 246 247 247 248 /** @todo Free include paths. */ 248 249 250 printf("Failed to process IDL file\n"); 249 251 return 1; 250 252 } -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl-new/xpidl.h
r108320 r108321 396 396 DECLHIDDEN(bool) verify_interface_declaration(PCXPIDLNODE pNd); 397 397 398 #if 0399 398 /* 400 399 * Find the underlying type of an identifier typedef. Returns NULL 401 400 * (and doesn't complain) on failure. 402 401 */ 403 IDL_tree /* IDL_TYPE_DCL */ 404 find_underlying_type(IDL_tree typedef_ident); 405 402 DECLHIDDEN(PCXPIDLNODE) find_underlying_type(PCXPIDLNODE pNd); 403 404 #if 0 406 405 /* 407 406 * Check that const declarations match their stated sign and are of the … … 422 421 gboolean 423 422 verify_method_declaration(IDL_tree method_tree); 423 #endif 424 424 425 425 /* … … 427 427 * it's of the form native <idl-name>(<c++-name>) 428 428 */ 429 gboolean 430 check_native(TreeState *state); 431 432 void 433 printlist(FILE *outfile, GSList *slist); 434 #endif 429 DECLHIDDEN(bool) check_native(PCXPIDLNODE pNd); 435 430 436 431 #endif /* __xpidl_h */ -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl-new/xpidl_idl.c
r108320 r108321 898 898 if (RT_FAILURE(rc)) 899 899 return rc; 900 pNdTypeSpec->pParent = pNdParam; 900 901 pNdParam->u.Param.pNdTypeSpec = pNdTypeSpec; 901 902 -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl-new/xpidl_typelib.c
r108320 r108321 126 126 } 127 127 128 129 static XPTInterfaceDirectoryEntry *FindInterfaceByName(XPTInterfaceDirectoryEntry *ides, uint16 num_interfaces, 130 const char *name, uint16_t *pu16Id) 131 { 132 for (uint16_t i = 0; i < num_interfaces; i++) { 133 if (!strcmp(ides[i].name, name)) 134 { 135 if (pu16Id) 136 *pu16Id = i + 1; 137 return &ides[i]; 138 } 139 } 140 return NULL; 141 } 142 143 128 144 /* 129 145 * If p is an ident for an interface, and we don't have an entry in the … … 168 184 RTListNodeRemove(&old_holder->NdInterfaces); 169 185 DeleteNewInterfaceHolder(old_holder); 186 IFACES(pThis)--; 170 187 old_holder = NULL; 171 188 } … … 174 191 { 175 192 /* XXX should we parse here and store a struct nsID *? */ 176 char *iid = (char *)xpidlNodeAttrFind(pNd, "uuid"); 177 char *name_space = (char *)xpidlNodeAttrFind(pNd, "namespace"); 193 PCXPIDLATTR pAttr = xpidlNodeAttrFind(pNd, "uuid"); 194 char *iid = NULL; 195 if (pAttr) 196 { 197 if (pAttr->pszVal) 198 iid = (char *)pAttr->pszVal; 199 else 200 return false; /* uuid requires an argument. */ 201 } 202 203 pAttr = xpidlNodeAttrFind(pNd, "namespace"); 204 char *name_space = NULL; 205 if (pAttr) 206 { 207 if (pAttr->pszVal) 208 name_space = (char *)pAttr->pszVal; 209 else 210 return false; /* uuid requires an argument. */ 211 } 212 178 213 NewInterfaceHolder *holder = CreateNewInterfaceHolder(pszIfName, name_space, iid, pNd->enmType == kXpidlNdType_Interface_Forward_Decl); 179 214 if (!holder) … … 184 219 #ifdef DEBUG_shaver_ifaces 185 220 fprintf(stderr, "adding interface #%d: %s/%s\n", IFACES(pThis), 186 pszIfName, iid [0]? iid : "<unresolved>");221 pszIfName, iid ? iid : "<unresolved>"); 187 222 #endif 188 223 } … … 210 245 break; 211 246 case kXpidlNdType_Interface_Def: 212 if (pIt->u.Attribute.pNdTypeSpec) 213 add_interface_maybe(pThis, pIt->u.Attribute.pNdTypeSpec); 247 if (pIt->pInput != pInput) /* Skip anything not top level. */ 248 continue; 249 250 if (pIt->pNdTypeRef) 251 add_interface_maybe(pThis, pIt->pNdTypeRef); 214 252 add_interface_maybe(pThis, pIt); 215 253 if (!find_interfaces(pThis, pInput, &pIt->u.If.LstBody)) … … 347 385 } 348 386 #endif 349 350 #if 0 351 for (i = 0; i < IFACES(pThis); i++) { 352 ide = HEADER(pThis)->interface_directory + i; 353 g_hash_table_insert(IFACE_MAP(pThis), ide->name, (void *)(i + 1)); 354 } 355 #endif 356 } 357 358 #if 0 359 static gboolean 360 typelib_list(TreeState *state) 361 { 362 IDL_tree iter; 363 for (iter = state->tree; iter; iter = IDL_LIST(iter).next) { 364 state->tree = IDL_LIST(iter).data; 365 if (!xpidl_process_node(state)) 366 return FALSE; 367 } 368 return TRUE; 369 } 370 #endif 387 } 388 371 389 372 390 static int typelib_prolog(PXPIDLTYPELIBSTATE pThis, PCXPIDLINPUT pInput, PCXPIDLPARSE pParse) … … 500 518 } 501 519 502 #if 0 503 static XPTInterfaceDirectoryEntry * 504 FindInterfaceByName(XPTInterfaceDirectoryEntry *ides, uint16 num_interfaces, 505 const char *name) 506 { 507 uint16 i; 508 for (i = 0; i < num_interfaces; i++) { 509 if (!strcmp(ides[i].name, name)) 510 return &ides[i]; 511 } 512 return NULL; 513 } 514 515 static gboolean 516 typelib_interface(TreeState *state) 517 { 518 IDL_tree iface = state->tree, iter; 519 char *name = IDL_IDENT(IDL_INTERFACE(iface).ident).str; 520 XPTInterfaceDirectoryEntry *ide; 521 XPTInterfaceDescriptor *id; 522 uint16 parent_id = 0; 523 PRUint8 interface_flags = 0; 524 525 if (!verify_interface_declaration(iface)) 526 return FALSE; 527 528 if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable")) 529 interface_flags |= XPT_ID_SCRIPTABLE; 530 531 if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "function")) 532 interface_flags |= XPT_ID_FUNCTION; 533 534 ide = FindInterfaceByName(HEADER(state)->interface_directory, 535 HEADER(state)->num_interfaces, name); 536 if (!ide) { 537 IDL_tree_error(iface, "ERROR: didn't find interface %s in " 538 "IDE block. Giving up.\n", name); 539 return FALSE; 540 } 541 542 if ((iter = IDL_INTERFACE(iface).inheritance_spec)) { 543 char *parent; 544 if (IDL_LIST(iter).next) { 545 IDL_tree_error(iface, 546 "ERROR: more than one parent interface for %s\n", 547 name); 548 return FALSE; 549 } 550 parent = IDL_IDENT(IDL_LIST(iter).data).str; 551 parent_id = (uint16)(uint32)g_hash_table_lookup(IFACE_MAP(state), 552 parent); 553 if (!parent_id) { 554 IDL_tree_error(iface, 555 "ERROR: no index found for %s. Giving up.\n", 556 parent); 557 return FALSE; 558 } 559 } 560 561 id = XPT_NewInterfaceDescriptor(ARENA(state), parent_id, 0, 0, 562 interface_flags); 563 if (!id) 564 return FALSE; 565 566 CURRENT(state) = ide->interface_descriptor = id; 567 #ifdef DEBUG_shaver_ifaces 568 fprintf(stderr, "DBG: starting interface %s @ %p\n", name, id); 569 #endif 570 571 NEXT_METH(state) = 0; 572 NEXT_CONST(state) = 0; 573 NEXT_TYPE(state) = 0; 574 575 state->tree = IDL_INTERFACE(iface).body; 576 if (state->tree && !xpidl_process_node(state)) 577 return FALSE; 578 #ifdef DEBUG_shaver_ifaces 579 fprintf(stderr, "DBG: ending interface %s\n", name); 580 #endif 581 return TRUE; 582 } 583 584 static gboolean 585 find_arg_with_name(TreeState *state, const char *name, int16 *argnum) 586 { 587 int16 count; 588 IDL_tree params; 589 590 XPT_ASSERT(state); 520 static bool find_arg_with_name(PCXPIDLNODE pNd, const char *name, int16 *argnum) 521 { 591 522 XPT_ASSERT(name); 592 523 XPT_ASSERT(argnum); 593 524 594 params = IDL_OP_DCL(IDL_NODE_UP(IDL_NODE_UP(state->tree))).parameter_dcls; 595 for (count = 0; 596 params != NULL && IDL_LIST(params).data != NULL; 597 params = IDL_LIST(params).next, count++) 598 { 599 const char *cur_name = IDL_IDENT( 600 IDL_PARAM_DCL(IDL_LIST(params).data).simple_declarator).str; 601 if (!strcmp(cur_name, name)) { 525 Assert(pNd->enmType == kXpidlNdType_Parameter); 526 pNd = pNd->pParent; 527 Assert(pNd->enmType == kXpidlNdType_Method); 528 529 uint16_t idxArgNum = 0; 530 PCXPIDLNODE pIt; 531 RTListForEach(&pNd->u.Method.LstParams, pIt, XPIDLNODE, NdLst) 532 { 533 Assert(pIt->enmType == kXpidlNdType_Parameter); 534 if (!strcmp(pIt->u.Param.pszName, name)) 535 { 602 536 /* XXX ought to verify that this is the right type here */ 603 537 /* XXX for iid_is this must be an iid */ 604 538 /* XXX for size_is and length_is this must be a uint32 */ 605 *argnum = count; 606 return TRUE; 607 } 608 } 609 return FALSE; 610 } 539 *argnum = idxArgNum; 540 return true; 541 } 542 idxArgNum++; 543 } 544 return false; 545 } 546 611 547 612 548 /* return value is for success or failure */ 613 static gboolean 614 get_size_and_length(TreeState *state, IDL_tree type, 615 int16 *size_is_argnum, int16 *length_is_argnum, 616 gboolean *has_size_is, gboolean *has_length_is) 617 { 618 *has_size_is = FALSE; 619 *has_length_is = FALSE; 620 621 if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) { 622 IDL_tree sd = IDL_PARAM_DCL(state->tree).simple_declarator; 549 static bool get_size_and_length(PCXPIDLNODE pNdType, 550 int16 *size_is_argnum, int16 *length_is_argnum, 551 bool *has_size_is, bool *has_length_is) 552 { 553 *has_size_is = false; 554 *has_length_is = false; 555 556 if (pNdType->enmType == kXpidlNdType_Parameter) 557 { 623 558 const char *size_is; 624 559 const char *length_is; 625 560 626 561 /* only if size_is is found does any of this matter */ 627 size_is = IDL_tree_property_get(sd, "size_is"); 628 if (!size_is) 629 return TRUE; 630 631 if (!find_arg_with_name(state, size_is, size_is_argnum)) { 632 IDL_tree_error(state->tree, "can't find matching argument for " 633 "[size_is(%s)]\n", size_is); 634 return FALSE; 635 } 636 *has_size_is = TRUE; 562 PCXPIDLATTR pAttr = xpidlNodeAttrFind(pNdType, "size_is"); 563 if (!pAttr) 564 return true; 565 if (!pAttr->pszVal) /* Attribute needs a value. */ 566 return false; 567 568 if (!find_arg_with_name(pNdType, pAttr->pszVal, size_is_argnum)) { 569 //IDL_tree_error(state->tree, "can't find matching argument for " 570 // "[size_is(%s)]\n", size_is); 571 return false; 572 } 573 *has_size_is = true; 637 574 638 575 /* length_is is optional */ 639 length_is = IDL_tree_property_get(sd, "length_is"); 640 if (length_is) { 641 *has_length_is = TRUE; 642 if (!find_arg_with_name(state, length_is, length_is_argnum)) { 643 IDL_tree_error(state->tree, "can't find matching argument for " 644 "[length_is(%s)]\n", length_is); 645 return FALSE; 646 } 647 } 648 } 649 return TRUE; 650 } 651 652 static gboolean 653 fill_td_from_type(TreeState *state, XPTTypeDescriptor *td, IDL_tree type) 654 { 655 IDL_tree up; 576 pAttr = xpidlNodeAttrFind(pNdType, "length_is"); 577 if (!pAttr) 578 return true; 579 if (!pAttr->pszVal) /* Attribute needs a value. */ 580 return false; 581 582 if (!find_arg_with_name(pNdType, pAttr->pszVal, length_is_argnum)) { 583 //IDL_tree_error(state->tree, "can't find matching argument for " 584 // "[length_is(%s)]\n", length_is); 585 return false; 586 } 587 *has_length_is = true; 588 } 589 return true; 590 } 591 592 593 static bool fill_td_from_type(PXPIDLTYPELIBSTATE pThis, XPTTypeDescriptor *td, PCXPIDLNODE pNdType) 594 { 656 595 int16 size_is_argnum; 657 596 int16 length_is_argnum; 658 gboolean has_size_is; 659 gboolean has_length_is; 660 gboolean is_array = FALSE; 661 662 if (type) { 663 664 /* deal with array */ 665 666 if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) { 667 IDL_tree sd = IDL_PARAM_DCL(state->tree).simple_declarator; 668 if (IDL_tree_property_get(sd, "array")) { 669 670 is_array = TRUE; 671 672 /* size_is is required! */ 673 if (!get_size_and_length(state, type, 674 &size_is_argnum, &length_is_argnum, 675 &has_size_is, &has_length_is)) { 676 /* error was reported by helper function */ 677 return FALSE; 597 bool has_size_is; 598 bool has_length_is; 599 bool is_array = false; 600 601 if ( pNdType->enmType == kXpidlNdType_BaseType 602 && pNdType->u.enmBaseType == kXpidlType_Void) 603 td->prefix.flags = TD_VOID; 604 else 605 { 606 PCXPIDLNODE pNdParam = NULL; 607 if ( pNdType->pParent 608 && pNdType->pParent->enmType == kXpidlNdType_Parameter) 609 pNdParam = pNdType->pParent; 610 611 if ( pNdParam 612 && xpidlNodeAttrFind(pNdParam, "array")) 613 { 614 is_array = true; 615 616 /* size_is is required! */ 617 if (!get_size_and_length(pNdParam, 618 &size_is_argnum, &length_is_argnum, 619 &has_size_is, &has_length_is)) { 620 /* error was reported by helper function */ 621 return false; 622 } 623 624 if (!has_size_is) 625 { 626 //IDL_tree_error(pThis->tree, "[array] requires [size_is()]\n"); 627 return false; 628 } 629 630 td->prefix.flags = TD_ARRAY | XPT_TDP_POINTER; 631 td->argnum = size_is_argnum; 632 633 if (has_length_is) 634 td->argnum2 = length_is_argnum; 635 else 636 td->argnum2 = size_is_argnum; 637 638 /* 639 * XXX - NOTE - this will be broken for multidimensional 640 * arrays because of the realloc XPT_InterfaceDescriptorAddTypes 641 * uses. The underlying 'td' can change as we recurse in to get 642 * additional dimensions. Luckily, we don't yet support more 643 * than on dimension in the arrays 644 */ 645 /* setup the additional_type */ 646 if (!XPT_InterfaceDescriptorAddTypes(ARENA(pThis), CURRENT(pThis), 1)) 647 return false; 648 649 td->type.additional_type = NEXT_TYPE(pThis); 650 td = &CURRENT(pThis)->additional_types[NEXT_TYPE(pThis)]; 651 NEXT_TYPE(pThis)++ ; 652 } 653 654 handle_typedef: 655 if (pNdType->enmType == kXpidlNdType_BaseType) 656 { 657 switch (pNdType->u.enmBaseType) 658 { 659 case kXpidlType_Boolean: 660 td->prefix.flags = TD_BOOL; 661 break; 662 case kXpidlType_Octet: 663 td->prefix.flags = TD_UINT8; 664 break; 665 case kXpidlType_Char: 666 td->prefix.flags = TD_CHAR; 667 break; 668 case kXpidlType_Wide_Char: 669 td->prefix.flags = TD_WCHAR; 670 break; 671 case kXpidlType_Short: 672 td->prefix.flags = TD_INT16; 673 break; 674 case kXpidlType_Long: 675 td->prefix.flags = TD_INT32; 676 break; 677 case kXpidlType_Long_Long: 678 td->prefix.flags = TD_INT64; 679 break; 680 case kXpidlType_Unsigned_Short: 681 td->prefix.flags = TD_UINT16; 682 break; 683 case kXpidlType_Unsigned_Long: 684 td->prefix.flags = TD_UINT32; 685 break; 686 case kXpidlType_Unsigned_Long_Long: 687 td->prefix.flags = TD_UINT64; 688 break; 689 case kXpidlType_String: 690 if (is_array) 691 td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER; 692 else 693 { 694 if (!get_size_and_length(pNdType, 695 &size_is_argnum, &length_is_argnum, 696 &has_size_is, &has_length_is)) 697 { 698 /* error was reported by helper function */ 699 return false; 700 } 701 if (has_size_is) 702 { 703 td->prefix.flags = TD_PSTRING_SIZE_IS | XPT_TDP_POINTER; 704 td->argnum = size_is_argnum; 705 if (has_length_is) 706 td->argnum2 = length_is_argnum; 707 else 708 td->argnum2 = size_is_argnum; 709 } 710 else 711 td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER; 712 } 713 break; 714 case kXpidlType_Wide_String: 715 if (is_array) 716 td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER; 717 else 718 { 719 if (!get_size_and_length(pNdType, 720 &size_is_argnum, &length_is_argnum, 721 &has_size_is, &has_length_is)) 722 { 723 /* error was reported by helper function */ 724 return false; 725 } 726 if (has_size_is) 727 { 728 td->prefix.flags = TD_PWSTRING_SIZE_IS | XPT_TDP_POINTER; 729 td->argnum = size_is_argnum; 730 if (has_length_is) 731 td->argnum2 = length_is_argnum; 732 else 733 td->argnum2 = size_is_argnum; 734 } 735 else 736 td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER; 737 } 738 break; 739 case kXpidlType_Double: 740 td->prefix.flags = TD_DOUBLE; 741 break; 742 case kXpidlType_Float: 743 td->prefix.flags = TD_FLOAT; 744 break; 745 default: 746 AssertReleaseFailed(); 747 } 748 } 749 else if (pNdType->enmType == kXpidlNdType_Identifier) 750 { 751 if (!pNdType->pNdTypeRef) 752 { 753 //IDL_tree_error(state->tree, 754 // "ERROR: orphan ident %s in param list\n", 755 // IDL_IDENT(type).str); 756 return false; 757 } 758 759 /* This whole section is abominably ugly */ 760 PCXPIDLNODE pNdTypeRef = pNdType->pNdTypeRef; 761 switch (pNdTypeRef->enmType) 762 { 763 case kXpidlNdType_Interface_Forward_Decl: 764 case kXpidlNdType_Interface_Def: 765 { 766 XPTInterfaceDirectoryEntry *ide, *ides; 767 uint16 num_ifaces; 768 const char *className; 769 const char *iid_is; 770 handle_iid_is: 771 ides = HEADER(pThis)->interface_directory; 772 num_ifaces = HEADER(pThis)->num_interfaces; 773 /* might get here via the goto, so re-check type */ 774 if (pNdTypeRef->enmType == kXpidlNdType_Interface_Def) 775 className = pNdTypeRef->u.If.pszIfName; 776 else if (pNdTypeRef->enmType == kXpidlNdType_Interface_Forward_Decl) 777 className = pNdTypeRef->u.pszIfFwdName; 778 else 779 Assert( pNdParam 780 && xpidlNodeAttrFind(pNdParam, "iid_is")); //className = IDL_IDENT(IDL_NATIVE(up).ident).str; 781 iid_is = NULL; 782 783 if (pNdParam) 784 { 785 PCXPIDLATTR pAttr = xpidlNodeAttrFind(pNdParam, "iid_is"); 786 if (pAttr) 787 { 788 if (!pAttr->pszVal) /* iid_is requires a value */ 789 return false; 790 iid_is = pAttr->pszVal; 791 } 792 } 793 794 if (iid_is) { 795 int16 argnum; 796 if (!find_arg_with_name(pNdParam, iid_is, &argnum)) { 797 //IDL_tree_error(state->tree, 798 // "can't find matching argument for " 799 // "[iid_is(%s)]\n", iid_is); 800 return false; 801 } 802 td->prefix.flags = TD_INTERFACE_IS_TYPE | XPT_TDP_POINTER; 803 td->argnum = argnum; 804 } else { 805 td->prefix.flags = TD_INTERFACE_TYPE | XPT_TDP_POINTER; 806 ide = FindInterfaceByName(ides, num_ifaces, className, NULL); 807 if (!ide || ide < ides || ide > ides + num_ifaces) 808 { 809 //IDL_tree_error(state->tree, 810 // "unknown iface %s in param\n", 811 // className); 812 return false; 813 } 814 td->type.iface = ide - ides + 1; 815 #ifdef DEBUG_shaver_index 816 fprintf(stderr, "DBG: index %d for %s\n", 817 td->type.iface, className); 818 #endif 819 } 820 break; 678 821 } 679 680 if (!has_size_is) { 681 IDL_tree_error(state->tree, "[array] requires [size_is()]\n"); 682 return FALSE; 822 case kXpidlNdType_Native: 823 { 824 /* jband - adding goto for iid_is when type is native */ 825 if ( pNdParam 826 && xpidlNodeAttrFind(pNdParam, "iid_is")) 827 goto handle_iid_is; 828 829 if (xpidlNodeAttrFind(pNdTypeRef, "nsid")) { 830 td->prefix.flags = TD_PNSIID; 831 if (xpidlNodeAttrFind(pNdTypeRef, "ref")) 832 td->prefix.flags |= XPT_TDP_POINTER | XPT_TDP_REFERENCE; 833 else if (xpidlNodeAttrFind(pNdTypeRef,"ptr")) 834 td->prefix.flags |= XPT_TDP_POINTER; 835 } else if (xpidlNodeAttrFind(pNdTypeRef, "domstring")) { 836 td->prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER; 837 if (xpidlNodeAttrFind(pNdTypeRef, "ref")) 838 td->prefix.flags |= XPT_TDP_REFERENCE; 839 } else if (xpidlNodeAttrFind(pNdTypeRef, "astring")) { 840 td->prefix.flags = TD_ASTRING | XPT_TDP_POINTER; 841 if (xpidlNodeAttrFind(pNdTypeRef, "ref")) 842 td->prefix.flags |= XPT_TDP_REFERENCE; 843 } else if (xpidlNodeAttrFind(pNdTypeRef, "utf8string")) { 844 td->prefix.flags = TD_UTF8STRING | XPT_TDP_POINTER; 845 if (xpidlNodeAttrFind(pNdTypeRef, "ref")) 846 td->prefix.flags |= XPT_TDP_REFERENCE; 847 } else if (xpidlNodeAttrFind(pNdTypeRef, "cstring")) { 848 td->prefix.flags = TD_CSTRING | XPT_TDP_POINTER; 849 if (xpidlNodeAttrFind(pNdTypeRef, "ref")) 850 td->prefix.flags |= XPT_TDP_REFERENCE; 851 } else { 852 td->prefix.flags = TD_VOID | XPT_TDP_POINTER; 853 } 854 break; 683 855 } 684 685 td->prefix.flags = TD_ARRAY | XPT_TDP_POINTER; 686 td->argnum = size_is_argnum; 687 688 if (has_length_is) 689 td->argnum2 = length_is_argnum; 690 else 691 td->argnum2 = size_is_argnum; 692 693 /* 694 * XXX - NOTE - this will be broken for multidimensional 695 * arrays because of the realloc XPT_InterfaceDescriptorAddTypes 696 * uses. The underlying 'td' can change as we recurse in to get 697 * additional dimensions. Luckily, we don't yet support more 698 * than on dimension in the arrays 699 */ 700 /* setup the additional_type */ 701 if (!XPT_InterfaceDescriptorAddTypes(ARENA(state), 702 CURRENT(state), 1)) { 703 g_error("out of memory\n"); 704 return FALSE; 705 } 706 td->type.additional_type = NEXT_TYPE(state); 707 td = &CURRENT(state)->additional_types[NEXT_TYPE(state)]; 708 NEXT_TYPE(state)++ ; 709 } 710 } 711 712 handle_typedef: 713 switch (IDL_NODE_TYPE(type)) { 714 case IDLN_TYPE_INTEGER: { 715 gboolean sign = IDL_TYPE_INTEGER(type).f_signed; 716 switch(IDL_TYPE_INTEGER(type).f_type) { 717 case IDL_INTEGER_TYPE_SHORT: 718 td->prefix.flags = sign ? TD_INT16 : TD_UINT16; 719 break; 720 case IDL_INTEGER_TYPE_LONG: 721 td->prefix.flags = sign ? TD_INT32 : TD_UINT32; 722 break; 723 case IDL_INTEGER_TYPE_LONGLONG: 724 td->prefix.flags = sign ? TD_INT64 : TD_UINT64; 725 break; 726 } 727 break; 728 } 729 case IDLN_TYPE_CHAR: 730 td->prefix.flags = TD_CHAR; 731 break; 732 case IDLN_TYPE_WIDE_CHAR: 733 td->prefix.flags = TD_WCHAR; 734 break; 735 case IDLN_TYPE_STRING: 736 if (is_array) { 737 td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER; 738 } else { 739 if (!get_size_and_length(state, type, 740 &size_is_argnum, &length_is_argnum, 741 &has_size_is, &has_length_is)) { 742 /* error was reported by helper function */ 743 return FALSE; 744 } 745 if (has_size_is) { 746 td->prefix.flags = TD_PSTRING_SIZE_IS | XPT_TDP_POINTER; 747 td->argnum = size_is_argnum; 748 if (has_length_is) 749 td->argnum2 = length_is_argnum; 750 else 751 td->argnum2 = size_is_argnum; 752 } else { 753 td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER; 754 } 755 } 756 break; 757 case IDLN_TYPE_WIDE_STRING: 758 if (is_array) { 759 td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER; 760 } else { 761 if (!get_size_and_length(state, type, 762 &size_is_argnum, &length_is_argnum, 763 &has_size_is, &has_length_is)) { 764 /* error was reported by helper function */ 765 return FALSE; 766 } 767 if (has_size_is) { 768 td->prefix.flags = TD_PWSTRING_SIZE_IS | XPT_TDP_POINTER; 769 td->argnum = size_is_argnum; 770 if (has_length_is) 771 td->argnum2 = length_is_argnum; 772 else 773 td->argnum2 = size_is_argnum; 774 } else { 775 td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER; 776 } 777 } 778 break; 779 case IDLN_TYPE_BOOLEAN: 780 td->prefix.flags = TD_BOOL; 781 break; 782 case IDLN_TYPE_OCTET: 783 td->prefix.flags = TD_UINT8; 784 break; 785 case IDLN_TYPE_FLOAT: 786 switch (IDL_TYPE_FLOAT (type).f_type) { 787 case IDL_FLOAT_TYPE_FLOAT: 788 td->prefix.flags = TD_FLOAT; 789 break; 790 case IDL_FLOAT_TYPE_DOUBLE: 791 td->prefix.flags = TD_DOUBLE; 792 break; 793 /* XXX 'long double' just ignored, or what? */ 794 default: break; 795 } 796 break; 797 case IDLN_IDENT: 798 if (!(up = IDL_NODE_UP(type))) { 799 IDL_tree_error(state->tree, 800 "ERROR: orphan ident %s in param list\n", 801 IDL_IDENT(type).str); 802 return FALSE; 803 } 804 switch (IDL_NODE_TYPE(up)) { 805 /* This whole section is abominably ugly */ 806 case IDLN_FORWARD_DCL: 807 case IDLN_INTERFACE: { 808 XPTInterfaceDirectoryEntry *ide, *ides; 809 uint16 num_ifaces; 810 char *className; 811 const char *iid_is; 812 handle_iid_is: 813 ides = HEADER(state)->interface_directory; 814 num_ifaces = HEADER(state)->num_interfaces; 815 /* might get here via the goto, so re-check type */ 816 if (IDL_NODE_TYPE(up) == IDLN_INTERFACE) 817 className = IDL_IDENT(IDL_INTERFACE(up).ident).str; 818 else if (IDL_NODE_TYPE(up) == IDLN_FORWARD_DCL) 819 className = IDL_IDENT(IDL_FORWARD_DCL(up).ident).str; 820 else 821 className = IDL_IDENT(IDL_NATIVE(up).ident).str; 822 iid_is = NULL; 823 824 if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) { 825 iid_is = 826 IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator, 827 "iid_is"); 828 } 829 if (iid_is) { 830 int16 argnum; 831 if (!find_arg_with_name(state, iid_is, &argnum)) { 832 IDL_tree_error(state->tree, 833 "can't find matching argument for " 834 "[iid_is(%s)]\n", iid_is); 835 return FALSE; 836 } 837 td->prefix.flags = TD_INTERFACE_IS_TYPE | XPT_TDP_POINTER; 838 td->argnum = argnum; 839 } else { 840 td->prefix.flags = TD_INTERFACE_TYPE | XPT_TDP_POINTER; 841 ide = FindInterfaceByName(ides, num_ifaces, className); 842 if (!ide || ide < ides || ide > ides + num_ifaces) { 843 IDL_tree_error(state->tree, 844 "unknown iface %s in param\n", 845 className); 846 return FALSE; 847 } 848 td->type.iface = ide - ides + 1; 849 #ifdef DEBUG_shaver_index 850 fprintf(stderr, "DBG: index %d for %s\n", 851 td->type.iface, className); 852 #endif 853 } 854 break; 855 } 856 case IDLN_NATIVE: 857 { 858 859 /* jband - adding goto for iid_is when type is native */ 860 if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL && 861 IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator, 862 "iid_is")) 863 goto handle_iid_is; 864 865 if (IDL_tree_property_get(type, "nsid")) { 866 td->prefix.flags = TD_PNSIID; 867 if (IDL_tree_property_get(type, "ref")) 868 td->prefix.flags |= XPT_TDP_POINTER | XPT_TDP_REFERENCE; 869 else if (IDL_tree_property_get(type,"ptr")) 870 td->prefix.flags |= XPT_TDP_POINTER; 871 } else if (IDL_tree_property_get(type, "domstring")) { 872 td->prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER; 873 if (IDL_tree_property_get(type, "ref")) 874 td->prefix.flags |= XPT_TDP_REFERENCE; 875 } else if (IDL_tree_property_get(type, "astring")) { 876 td->prefix.flags = TD_ASTRING | XPT_TDP_POINTER; 877 if (IDL_tree_property_get(type, "ref")) 878 td->prefix.flags |= XPT_TDP_REFERENCE; 879 } else if (IDL_tree_property_get(type, "utf8string")) { 880 td->prefix.flags = TD_UTF8STRING | XPT_TDP_POINTER; 881 if (IDL_tree_property_get(type, "ref")) 882 td->prefix.flags |= XPT_TDP_REFERENCE; 883 } else if (IDL_tree_property_get(type, "cstring")) { 884 td->prefix.flags = TD_CSTRING | XPT_TDP_POINTER; 885 if (IDL_tree_property_get(type, "ref")) 886 td->prefix.flags |= XPT_TDP_REFERENCE; 887 } else { 888 td->prefix.flags = TD_VOID | XPT_TDP_POINTER; 889 } 890 break; 891 } 892 default: 893 if (IDL_NODE_TYPE(IDL_NODE_UP(up)) == IDLN_TYPE_DCL) { 856 case kXpidlNdType_Typedef: 857 { 894 858 /* restart with the underlying type */ 895 IDL_tree new_type; 896 new_type = IDL_TYPE_DCL(IDL_NODE_UP(up)).type_spec; 859 897 860 #ifdef DEBUG_shaver_misc 898 fprintf(stderr, "following %s typedef to % s\n",899 IDL_IDENT(type).str, IDL_NODE_TYPE_NAME(new_type));861 fprintf(stderr, "following %s typedef to %u\n", 862 pNdType->u.Typedef.pszName, pNdType->u.Typedef.pNodeTypeSpec); 900 863 #endif 901 864 /* … … 903 866 * we can avoid screwing up the *array* information. 904 867 */ 905 /* return fill_td_from_type(state, td, new_type); */ 906 if (new_type){907 type = new_type;868 if (pNdTypeRef->u.Typedef.pNodeTypeSpec) 869 { 870 pNdType = pNdTypeRef->u.Typedef.pNodeTypeSpec; 908 871 goto handle_typedef; 909 } else { 872 } 873 else 874 { 910 875 /* do what we would do in recursion if !type */ 911 876 td->prefix.flags = TD_VOID; 912 return TRUE;877 return true; 913 878 } 914 879 } 915 IDL_tree_error(state->tree, 916 "can't handle %s ident in param list\n", 917 #ifdef DEBUG_shaver 918 /* XXX is this safe to use on Win now? */ 919 IDL_NODE_TYPE_NAME(IDL_NODE_UP(type)) 920 #else 921 "that type of" 922 #endif 923 ); 924 #ifdef DEBUG_shaver 925 XPT_ASSERT(0); 926 #endif 927 return FALSE; 928 } 880 default: 881 //IDL_tree_error(state->tree, 882 // "can't handle %s ident in param list\n", 883 // /* XXX is this safe to use on Win now? */ 884 // IDL_NODE_TYPE_NAME(IDL_NODE_UP(type)) 885 // ); 886 AssertFailedReturn(false); 887 } 888 } 889 else 890 AssertFailedReturn(false); 891 } 892 893 return true; 894 } 895 896 897 static bool fill_pd_from_type(PXPIDLTYPELIBSTATE pThis, XPTParamDescriptor *pd, uint8 flags, PCXPIDLNODE pNd) 898 { 899 pd->flags = flags; 900 return fill_td_from_type(pThis, &pd->type, pNd); 901 } 902 903 static bool fill_pd_from_param(PXPIDLTYPELIBSTATE pThis, XPTParamDescriptor *pd, PCXPIDLNODE pNd) 904 { 905 uint8 flags = 0; 906 bool is_dipper_type = DIPPER_TYPE(pNd->u.Param.pNdTypeSpec); 907 908 switch (pNd->u.Param.enmDir) 909 { 910 case kXpidlDirection_In: 911 flags = XPT_PD_IN; 929 912 break; 930 default: 931 IDL_tree_error(state->tree, "can't handle %s in param list\n", 932 #ifdef DEBUG_shaver 933 /* XXX is this safe to use on Win now? */ 934 IDL_NODE_TYPE_NAME(IDL_NODE_UP(type)) 935 #else 936 "that type" 937 #endif 938 ); 939 return FALSE; 940 } 941 } else { 942 td->prefix.flags = TD_VOID; 943 } 944 945 return TRUE; 946 } 947 948 static gboolean 949 fill_pd_from_type(TreeState *state, XPTParamDescriptor *pd, uint8 flags, 950 IDL_tree type) 951 { 952 pd->flags = flags; 953 return fill_td_from_type(state, &pd->type, type); 954 } 955 956 static gboolean 957 fill_pd_from_param(TreeState *state, XPTParamDescriptor *pd, IDL_tree tree) 958 { 959 uint8 flags = 0; 960 gboolean is_dipper_type = DIPPER_TYPE(IDL_PARAM_DCL(tree).param_type_spec); 961 962 switch (IDL_PARAM_DCL(tree).attr) { 963 case IDL_PARAM_IN: 964 flags = XPT_PD_IN; 965 break; 966 case IDL_PARAM_OUT: 967 flags = XPT_PD_OUT; 968 break; 969 case IDL_PARAM_INOUT: 970 flags = XPT_PD_IN | XPT_PD_OUT; 971 break; 972 } 973 974 if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator, 975 "retval")) { 976 if (flags != XPT_PD_OUT) { 977 IDL_tree_error(tree, "can't have [retval] with in%s param " 978 "(only out)\n", 979 flags & XPT_PD_OUT ? "out" : ""); 980 return FALSE; 913 case kXpidlDirection_Out: 914 flags = XPT_PD_OUT; 915 break; 916 case kXpidlDirection_InOut: 917 flags = XPT_PD_IN | XPT_PD_OUT; 918 break; 919 default: 920 AssertReleaseFailed(); 921 } 922 923 if (xpidlNodeAttrFind(pNd, "retval")) 924 { 925 if (flags != XPT_PD_OUT) 926 { 927 //IDL_tree_error(tree, "can't have [retval] with in%s param " 928 // "(only out)\n", 929 // flags & XPT_PD_OUT ? "out" : ""); 930 return false; 981 931 } 982 932 flags |= XPT_PD_RETVAL; 983 933 } 984 934 985 if (is_dipper_type && (flags & XPT_PD_OUT)) { 935 if (is_dipper_type && (flags & XPT_PD_OUT)) 936 { 986 937 flags &= ~XPT_PD_OUT; 987 938 flags |= XPT_PD_IN | XPT_PD_DIPPER; 988 939 } 989 940 990 if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator, 991 "shared")) { 992 if (flags & XPT_PD_IN) { 993 IDL_tree_error(tree, "can't have [shared] with in%s param " 994 "(only out)\n", 995 flags & XPT_PD_OUT ? "out" : ""); 996 return FALSE; 941 if (xpidlNodeAttrFind(pNd, "shared")) 942 { 943 if (flags & XPT_PD_IN) 944 { 945 //IDL_tree_error(tree, "can't have [shared] with in%s param " 946 // "(only out)\n", 947 // flags & XPT_PD_OUT ? "out" : ""); 948 return false; 997 949 } 998 950 flags |= XPT_PD_SHARED; 999 951 } 1000 952 1001 /* stick param where we can see it later */ 1002 state->tree = tree; 1003 return fill_pd_from_type(state, pd, flags, 1004 IDL_PARAM_DCL(tree).param_type_spec); 1005 } 1006 1007 /* XXXshaver common with xpidl_header.c */ 1008 #define ATTR_IDENT(tree) (IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(tree).simple_declarations).data)) 1009 #define ATTR_TYPE_DECL(tree) (IDL_ATTR_DCL(tree).param_type_spec) 1010 #define ATTR_TYPE(tree) (IDL_NODE_TYPE(ATTR_TYPE_DECL(tree))) 1011 1012 static gboolean 1013 fill_pd_as_nsresult(XPTParamDescriptor *pd) 953 return fill_pd_from_type(pThis, pd, flags, pNd->u.Param.pNdTypeSpec); 954 } 955 956 957 static bool fill_pd_as_nsresult(XPTParamDescriptor *pd) 1014 958 { 1015 959 pd->type.prefix.flags = TD_UINT32; /* TD_NSRESULT */ 1016 return TRUE; 1017 } 1018 1019 static gboolean 1020 typelib_attr_accessor(TreeState *state, XPTMethodDescriptor *meth, 1021 gboolean getter, gboolean hidden) 960 return true; 961 } 962 963 static bool typelib_attr_accessor(PXPIDLTYPELIBSTATE pThis, PCXPIDLNODE pNd, 964 XPTMethodDescriptor *meth, bool getter, bool hidden) 1022 965 { 1023 966 uint8 methflags = 0; … … 1026 969 methflags |= getter ? XPT_MD_GETTER : XPT_MD_SETTER; 1027 970 methflags |= hidden ? XPT_MD_HIDDEN : 0; 1028 if (!XPT_FillMethodDescriptor(ARENA(state), meth, methflags, 1029 ATTR_IDENT(state->tree).str, 1)) 1030 return FALSE; 1031 1032 if (getter) { 1033 if (DIPPER_TYPE(ATTR_TYPE_DECL(state->tree))) { 971 if (!XPT_FillMethodDescriptor(ARENA(pThis), meth, methflags, 972 (char *)pNd->u.Attribute.pszName, 1)) 973 return false; 974 975 if (getter) 976 { 977 if (DIPPER_TYPE(pNd->u.Attribute.pNdTypeSpec)) 1034 978 pdflags |= (XPT_PD_RETVAL | XPT_PD_IN | XPT_PD_DIPPER); 1035 } else {979 else 1036 980 pdflags |= (XPT_PD_RETVAL | XPT_PD_OUT); 1037 } 1038 } else { 981 982 } 983 else 1039 984 pdflags |= XPT_PD_IN; 1040 } 1041 1042 if (!fill_pd_from_type(state, meth->params, pdflags, 1043 ATTR_TYPE_DECL(state->tree))) 1044 return FALSE; 985 986 if (!fill_pd_from_type(pThis, meth->params, pdflags, pNd->u.Attribute.pNdTypeSpec)) 987 return false; 1045 988 1046 989 fill_pd_as_nsresult(meth->result); 1047 NEXT_METH( state)++;1048 return TRUE;1049 } 1050 1051 static gboolean 1052 typelib_attr_dcl(TreeState *state)1053 { 1054 XPTInterfaceDescriptor *id = CURRENT( state);990 NEXT_METH(pThis)++; 991 return true; 992 } 993 994 995 static int xpidlTypelibProcessAttr(PXPIDLTYPELIBSTATE pThis, PCXPIDLNODE pNd) 996 { 997 XPTInterfaceDescriptor *id = CURRENT(pThis); 1055 998 XPTMethodDescriptor *meth; 1056 gboolean read_only = IDL_ATTR_DCL(state->tree).f_readonly;1057 1058 /* XXX this only handles the first ident; elsewhere too... */1059 IDL_tree ident =1060 IDL_LIST(IDL_ATTR_DCL(state->tree).simple_declarations).data;1061 999 1062 1000 /* If it's marked [noscript], mark it as hidden in the typelib. */ 1063 gboolean hidden = (IDL_tree_property_get(ident, "noscript") != NULL); 1064 1065 if (!verify_attribute_declaration(state->tree)) 1066 return FALSE; 1067 1068 if (!XPT_InterfaceDescriptorAddMethods(ARENA(state), id, 1069 (PRUint16) (read_only ? 1 : 2))) 1070 return FALSE; 1071 1072 meth = &id->method_descriptors[NEXT_METH(state)]; 1073 1074 return typelib_attr_accessor(state, meth, TRUE, hidden) && 1075 (read_only || typelib_attr_accessor(state, meth + 1, FALSE, hidden)); 1076 } 1077 1078 static gboolean 1079 typelib_op_dcl(TreeState *state) 1080 { 1081 XPTInterfaceDescriptor *id = CURRENT(state); 1001 bool hidden = (xpidlNodeAttrFind(pNd, "noscript") != NULL); 1002 1003 //if (!verify_attribute_declaration(state->tree)) 1004 // return VERR_NO_MEMORY; 1005 1006 if (!XPT_InterfaceDescriptorAddMethods(ARENA(pThis), id, 1007 (PRUint16) (pNd->u.Attribute.fReadonly ? 1 : 2))) 1008 return VERR_NO_MEMORY; 1009 1010 meth = &id->method_descriptors[NEXT_METH(pThis)]; 1011 1012 bool fOk = typelib_attr_accessor(pThis, pNd, meth, true, hidden) 1013 && ( pNd->u.Attribute.fReadonly 1014 || typelib_attr_accessor(pThis, pNd, meth + 1, false, hidden)); 1015 return fOk ? VINF_SUCCESS : VERR_INVALID_PARAMETER; 1016 } 1017 1018 1019 static int xpidlTypelibProcessMethod(PXPIDLTYPELIBSTATE pThis, PCXPIDLNODE pNd) 1020 { 1021 XPTInterfaceDescriptor *id = CURRENT(pThis); 1082 1022 XPTMethodDescriptor *meth; 1083 struct _IDL_OP_DCL *op = &IDL_OP_DCL(state->tree);1084 IDL_tree iter;1085 1023 uint16 num_args = 0; 1086 1024 uint8 op_flags = 0; 1087 gboolean op_notxpcom = (IDL_tree_property_get(op->ident, "notxpcom") 1088 != NULL); 1089 gboolean op_noscript = (IDL_tree_property_get(op->ident, "noscript") 1090 != NULL); 1091 1092 if (!verify_method_declaration(state->tree)) 1093 return FALSE; 1094 1095 if (!XPT_InterfaceDescriptorAddMethods(ARENA(state), id, 1)) 1096 return FALSE; 1097 1098 meth = &id->method_descriptors[NEXT_METH(state)]; 1099 1100 for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) 1101 num_args++; /* count params */ 1102 if (op->op_type_spec && !op_notxpcom) 1103 num_args++; /* fake param for _retval */ 1025 bool op_notxpcom = (xpidlNodeAttrFind(pNd, "notxpcom") != NULL); 1026 bool op_noscript = (xpidlNodeAttrFind(pNd, "noscript") != NULL); 1027 1028 //if (!verify_method_declaration(pNd)) 1029 // return FALSE; 1030 1031 if (!XPT_InterfaceDescriptorAddMethods(ARENA(pThis), id, 1)) 1032 return VERR_NO_MEMORY; 1033 1034 meth = &id->method_descriptors[NEXT_METH(pThis)]; 1035 1036 /* count params */ 1037 PCXPIDLNODE pIt; 1038 RTListForEach(&pNd->u.Method.LstParams, pIt, XPIDLNODE, NdLst) 1039 { 1040 num_args++; 1041 } 1042 //if (op->op_type_spec && !op_notxpcom) 1043 // num_args++; /* fake param for _retval */ 1104 1044 1105 1045 if (op_noscript) … … 1112 1052 #ifdef DEBUG_shaver_method 1113 1053 fprintf(stdout, "DBG: adding method %s (nargs %d)\n", 1114 IDL_IDENT(op->ident).str, num_args);1115 #endif 1116 if (!XPT_FillMethodDescriptor(ARENA( state), meth, op_flags,1117 IDL_IDENT(op->ident).str,1054 pNd->u.Method.pszName, num_args); 1055 #endif 1056 if (!XPT_FillMethodDescriptor(ARENA(pThis), meth, op_flags, 1057 (char *)pNd->u.Method.pszName, 1118 1058 (uint8) num_args)) 1119 return FALSE; 1120 1121 for (num_args = 0, iter = op->parameter_dcls; iter; 1122 iter = IDL_LIST(iter).next, num_args++) { 1123 XPTParamDescriptor *pd = &meth->params[num_args]; 1124 if (!fill_pd_from_param(state, pd, IDL_LIST(iter).data)) 1125 return FALSE; 1126 } 1127 1128 /* stick retval param where we can see it later */ 1129 state->tree = op->op_type_spec; 1059 return VERR_INVALID_PARAMETER; 1060 1061 num_args = 0; 1062 RTListForEach(&pNd->u.Method.LstParams, pIt, XPIDLNODE, NdLst) 1063 { 1064 XPTParamDescriptor *pd = &meth->params[num_args++]; 1065 if (!fill_pd_from_param(pThis, pd, pIt)) 1066 return VERR_INVALID_PARAMETER; 1067 } 1130 1068 1131 1069 /* XXX unless [notxpcom] */ 1132 if (!op_notxpcom) { 1070 if (!op_notxpcom) 1071 { 1072 #if 0 1133 1073 if (op->op_type_spec) { 1134 1074 uint8 pdflags = DIPPER_TYPE(op->op_type_spec) ? … … 1136 1076 (XPT_PD_RETVAL | XPT_PD_OUT); 1137 1077 1138 if (!fill_pd_from_type( state, &meth->params[num_args],1078 if (!fill_pd_from_type(pThis, &meth->params[num_args], 1139 1079 pdflags, op->op_type_spec)) 1140 return FALSE; 1141 } 1080 return VERR_INVALID_PARAMETER; 1081 } 1082 #endif 1142 1083 1143 1084 if (!fill_pd_as_nsresult(meth->result)) 1144 return FALSE; 1145 } else { 1085 return VERR_INVALID_PARAMETER; 1086 } 1087 else 1088 { 1146 1089 #ifdef DEBUG_shaver_notxpcom 1147 fprintf(stderr, "%s is notxpcom\n", IDL_IDENT(op->ident).str); 1148 #endif 1149 if (!fill_pd_from_type(state, meth->result, XPT_PD_RETVAL, 1150 op->op_type_spec)) 1151 return FALSE; 1152 } 1153 NEXT_METH(state)++; 1154 return TRUE; 1155 } 1156 1157 static gboolean 1158 typelib_const_dcl(TreeState *state) 1159 { 1160 struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); 1161 gboolean is_long; 1162 gboolean sign; 1163 IDL_tree real_type; 1090 fprintf(stderr, "%s is notxpcom\n", pNd->u.Method.pszName); 1091 #endif 1092 if (!fill_pd_from_type(pThis, meth->result, XPT_PD_RETVAL, 1093 pNd->u.Method.pNdTypeSpecRet)) 1094 return VERR_INVALID_PARAMETER; 1095 } 1096 NEXT_METH(pThis)++; 1097 return VINF_SUCCESS; 1098 } 1099 1100 1101 static int xpidlTypelibProcessConst(PXPIDLTYPELIBSTATE pThis, PCXPIDLNODE pNd) 1102 { 1103 bool is_long; 1164 1104 XPTInterfaceDescriptor *id; 1165 1105 XPTConstDescriptor *cd; 1166 IDL_longlong_t value; 1167 1168 if (!verify_const_declaration(state->tree)) 1169 return FALSE; 1106 1107 //if (!verify_const_declaration(state->tree)) 1108 // return FALSE; 1170 1109 1171 1110 /* Could be a typedef; try to map it to the real type. */ 1172 real_type = find_underlying_type(dcl->const_type); 1173 real_type = real_type ? real_type : dcl->const_type; 1174 is_long = (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG); 1175 1176 id = CURRENT(state); 1177 if (!XPT_InterfaceDescriptorAddConsts(ARENA(state), id, 1)) 1178 return FALSE; 1179 cd = &id->const_descriptors[NEXT_CONST(state)]; 1111 PCXPIDLNODE pNdRealType = find_underlying_type(pNd->u.Const.pNdTypeSpec); 1112 Assert(pNdRealType->enmType == kXpidlNdType_BaseType); 1113 pNdRealType = pNdRealType ? pNdRealType : pNd->u.Const.pNdTypeSpec; 1114 Assert( pNdRealType->u.enmBaseType == kXpidlType_Long 1115 || pNdRealType->u.enmBaseType == kXpidlType_Short 1116 || pNdRealType->u.enmBaseType == kXpidlType_Unsigned_Long 1117 || pNdRealType->u.enmBaseType == kXpidlType_Unsigned_Short); 1118 is_long = pNdRealType->u.enmBaseType == kXpidlType_Long 1119 || pNdRealType->u.enmBaseType == kXpidlType_Unsigned_Long; 1120 1121 id = CURRENT(pThis); 1122 if (!XPT_InterfaceDescriptorAddConsts(ARENA(pThis), id, 1)) 1123 return VERR_NO_MEMORY; 1124 cd = &id->const_descriptors[NEXT_CONST(pThis)]; 1180 1125 1181 cd->name = IDL_IDENT(dcl->ident).str;1126 cd->name = (char *)pNd->u.Const.pszName; 1182 1127 #ifdef DEBUG_shaver_const 1183 1128 fprintf(stderr, "DBG: adding const %s\n", cd->name); 1184 1129 #endif 1185 if (!fill_td_from_type( state, &cd->type, dcl->const_type))1186 return FALSE;1130 if (!fill_td_from_type(pThis, &cd->type, pNd->u.Const.pNdTypeSpec)) 1131 return VERR_INVALID_PARAMETER; 1187 1132 1188 value = IDL_INTEGER(dcl->const_exp).value; 1189 sign = IDL_TYPE_INTEGER(dcl->const_type).f_signed; 1190 if (is_long) { 1191 if (sign) 1192 cd->value.i32 = value; 1193 else 1194 cd->value.ui32 = value; 1195 } else { 1196 if (sign) 1197 cd->value.i16 = value; 1198 else 1199 cd->value.ui16 = value; 1200 } 1201 NEXT_CONST(state)++; 1202 return TRUE; 1203 } 1204 1205 static gboolean 1206 typelib_enum(TreeState *state) 1207 { 1208 XPIDL_WARNING((state->tree, IDL_WARNING1, 1209 "enums not supported, enum \'%s\' ignored", 1210 IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str)); 1211 return TRUE; 1212 } 1213 #endif 1133 if (is_long) 1134 cd->value.ui32 = (uint32_t)pNd->u.Const.u64Const; 1135 else 1136 cd->value.ui16 = (uint16_t)pNd->u.Const.u64Const; 1137 1138 NEXT_CONST(pThis)++; 1139 return VINF_SUCCESS; 1140 } 1141 1142 1143 static int xpidlTypelibProcessIf(PXPIDLTYPELIBSTATE pThis, PCXPIDLNODE pNd) 1144 { 1145 char *name = (char *)pNd->u.If.pszIfName; 1146 XPTInterfaceDirectoryEntry *ide; 1147 XPTInterfaceDescriptor *id; 1148 uint16_t parent_id = 0; 1149 PRUint8 interface_flags = 0; 1150 1151 //if (!verify_interface_declaration(iface)) 1152 // return FALSE; 1153 1154 if (xpidlNodeAttrFind(pNd, "scriptable")) 1155 interface_flags |= XPT_ID_SCRIPTABLE; 1156 1157 if (xpidlNodeAttrFind(pNd, "function")) 1158 interface_flags |= XPT_ID_FUNCTION; 1159 1160 uint16_t u16Id = 0; 1161 ide = FindInterfaceByName(HEADER(pThis)->interface_directory, 1162 HEADER(pThis)->num_interfaces, name, 1163 NULL); 1164 if (!ide) { 1165 //IDL_tree_error(iface, "ERROR: didn't find interface %s in " 1166 // "IDE block. Giving up.\n", name); 1167 return VERR_NOT_FOUND; 1168 } 1169 1170 if (pNd->u.If.pszIfInherit) 1171 { 1172 if (!FindInterfaceByName(HEADER(pThis)->interface_directory, 1173 HEADER(pThis)->num_interfaces, pNd->u.If.pszIfInherit, 1174 &parent_id)) 1175 { 1176 //IDL_tree_error(iface, 1177 // "ERROR: no index found for %s. Giving up.\n", 1178 // parent); 1179 return VERR_NOT_FOUND; 1180 } 1181 } 1182 1183 id = XPT_NewInterfaceDescriptor(ARENA(pThis), parent_id, 0, 0, 1184 interface_flags); 1185 if (!id) 1186 return VERR_NO_MEMORY; 1187 1188 CURRENT(pThis) = ide->interface_descriptor = id; 1189 #ifdef DEBUG_shaver_ifaces 1190 fprintf(stderr, "DBG: starting interface %s @ %p\n", name, id); 1191 #endif 1192 1193 NEXT_METH(pThis) = 0; 1194 NEXT_CONST(pThis) = 0; 1195 NEXT_TYPE(pThis) = 0; 1196 1197 /* Walk the children and process. */ 1198 PCXPIDLNODE pIt; 1199 int rc = VINF_SUCCESS; 1200 RTListForEach(&pNd->u.If.LstBody, pIt, XPIDLNODE, NdLst) 1201 { 1202 switch (pIt->enmType) 1203 { 1204 case kXpidlNdType_Attribute: 1205 rc = xpidlTypelibProcessAttr(pThis, pIt); 1206 break; 1207 case kXpidlNdType_Method: 1208 rc = xpidlTypelibProcessMethod(pThis, pIt); 1209 break; 1210 case kXpidlNdType_Const: 1211 rc = xpidlTypelibProcessConst(pThis, pIt); 1212 break; 1213 default: 1214 AssertReleaseFailed(); 1215 break; 1216 } 1217 if (RT_FAILURE(rc)) 1218 return rc; 1219 } 1220 1221 #ifdef DEBUG_shaver_ifaces 1222 fprintf(stderr, "DBG: ending interface %s\n", name); 1223 #endif 1224 return VINF_SUCCESS; 1225 } 1226 1214 1227 1215 1228 DECL_HIDDEN_CALLBACK(int) xpidl_typelib_dispatch(FILE *pFile, PCXPIDLINPUT pInput, PCXPIDLPARSE pParse) … … 1217 1230 XPIDLTYPELIBSTATE This; RT_ZERO(This); 1218 1231 int rc = typelib_prolog(&This, pInput, pParse); 1232 AssertRC(rc); 1233 1219 1234 if (RT_SUCCESS(rc)) 1220 1235 { 1221 /** @todo */ 1222 rc = typelib_epilog(&This, pFile, pInput); 1223 } 1224 1236 PCXPIDLNODE pIt; 1237 RTListForEach(&pParse->LstNodes, pIt, XPIDLNODE, NdLst) 1238 { 1239 if (pIt->pInput != pInput) 1240 continue; 1241 1242 switch (pIt->enmType) 1243 { 1244 case kXpidlNdType_Native: 1245 if (!check_native(pIt)) 1246 rc = VERR_INVALID_PARAMETER; 1247 break; 1248 case kXpidlNdType_Interface_Def: 1249 rc = xpidlTypelibProcessIf(&This, pIt); 1250 break; 1251 case kXpidlNdType_Interface_Forward_Decl: /* Ignored */ 1252 case kXpidlNdType_Typedef: 1253 case kXpidlNdType_RawBlock: 1254 break; 1255 default: 1256 AssertReleaseFailed(); 1257 break; 1258 } 1259 AssertRC(rc); 1260 if (RT_FAILURE(rc)) 1261 break; 1262 } 1263 1264 if (RT_SUCCESS(rc)) 1265 rc = typelib_epilog(&This, pFile, pInput); 1266 } 1267 1268 AssertRC(rc); 1225 1269 return rc; 1226 1270 } 1227 1228 1229 -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl-new/xpidl_util.c
r108320 r108321 39 39 * Utility functions called by various backends. 40 40 */ 41 #include <iprt/assert.h> 41 42 42 43 #include "xpidl.h" … … 344 345 return TRUE; 345 346 } 347 #endif 346 348 347 349 /* 348 350 * Find the underlying type of an identifier typedef. 349 *350 * All the needed tree-walking seems pretty shaky; isn't there something in351 * libIDL to automate this?352 351 */ 353 IDL_tree /* IDL_TYPE_DCL */ 354 find_underlying_type(IDL_tree typedef_ident) 355 { 356 IDL_tree up; 357 358 if (typedef_ident == NULL || IDL_NODE_TYPE(typedef_ident) != IDLN_IDENT) 352 DECLHIDDEN(PCXPIDLNODE) find_underlying_type(PCXPIDLNODE pNd) 353 { 354 if (pNd == NULL || pNd->enmType != kXpidlNdType_Identifier) 359 355 return NULL; 360 356 361 up = IDL_NODE_UP(typedef_ident); 362 if (up == NULL || IDL_NODE_TYPE(up) != IDLN_LIST) 363 return NULL; 364 up = IDL_NODE_UP(up); 365 if (up == NULL || IDL_NODE_TYPE(up) != IDLN_TYPE_DCL) 366 return NULL; 367 368 return IDL_TYPE_DCL(up).type_spec; 369 } 370 357 AssertPtr(pNd->pNdTypeRef); 358 pNd = pNd->pNdTypeRef; 359 if (pNd->enmType == kXpidlNdType_Typedef) 360 pNd = pNd->u.Typedef.pNodeTypeSpec; 361 return pNd; 362 } 363 364 365 #if 0 371 366 static IDL_tree /* IDL_PARAM_DCL */ 372 367 find_named_parameter(IDL_tree method_tree, const char *param_name) … … 742 737 return TRUE; 743 738 } 739 #endif 744 740 745 741 /* … … 747 743 * it's of the form native <idl-name>(<c++-name>) 748 744 */ 749 gboolean 750 check_native(TreeState *state) 751 { 752 char *native_name; 745 DECLHIDDEN(bool) check_native(PCXPIDLNODE pNd) 746 { 747 Assert(pNd->enmType == kXpidlNdType_Native); 748 753 749 /* require that native declarations give a native type */ 754 if ( IDL_NATIVE(state->tree).user_type)755 return TRUE;756 native_name = IDL_IDENT(IDL_NATIVE(state->tree).ident).str; 757 IDL_tree_error(state->tree,758 "``native %s;'' needs C++ type: ``native %s(<C++ type>);''",759 native_name, native_name);760 return FALSE;761 } 762 #endif 750 if (pNd->u.Native.pszNative) 751 return true; 752 753 //IDL_tree_error(state->tree, 754 // "``native %s;'' needs C++ type: ``native %s(<C++ type>);''", 755 // pNd->u.Native.pszName, pNd->u.Native.pszName); 756 return false; 757 } 758 763 759 764 760 /* -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpt/tools/xpt_dump.c
r102348 r108321 829 829 char *const_type; 830 830 /* char *out; */ 831 PRUint32 uintout;832 PRInt32 intout;833 831 834 832 if (verbose_mode) { … … 859 857 /* fputs(out, stdout); */ 860 858 /* PR_smprintf_free(out); */ 861 LL_L2I(intout, cd->value.i64); 862 fprintf(stdout, "%d", intout); 859 fprintf(stdout, "%ld", cd->value.i64); 863 860 break; 864 861 case TD_INT32: … … 876 873 /* PR_smprintf_free(out); */ 877 874 /* XXX punt for now to remove NSPR linkage. */ 878 LL_L2UI(uintout, cd->value.ui64); 879 fprintf(stdout, "%u", uintout); 875 fprintf(stdout, "%lu", cd->value.ui64); 880 876 break; 881 877 case TD_UINT32:
Note:
See TracChangeset
for help on using the changeset viewer.