VirtualBox

Changeset 108326 in vbox


Ignore:
Timestamp:
Feb 21, 2025 1:52:50 PM (2 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167676
Message:

libs/xpcom18a4: Replace xpidl with xpidl-new which enables us to drop the dreaded libIDL dependency (library is dead for well over a decade), bugref:10321 [bug fixes]

Location:
trunk/src/libs/xpcom18a4/xpcom
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/components/nsIClassInfo.idl

    r1 r108326  
    101101     * Bitflags for 'flags' attribute.
    102102     */
    103     const PRUint32 SINGLETON            = 1 << 0;
    104     const PRUint32 THREADSAFE           = 1 << 1;
    105     const PRUint32 MAIN_THREAD_ONLY     = 1 << 2;
    106     const PRUint32 DOM_OBJECT           = 1 << 3;
    107     const PRUint32 PLUGIN_OBJECT        = 1 << 4;
    108     const PRUint32 EAGER_CLASSINFO      = 1 << 5;
     103    const PRUint32 SINGLETON            = 0x01;
     104    const PRUint32 THREADSAFE           = 0x02;
     105    const PRUint32 MAIN_THREAD_ONLY     = 0x04;
     106    const PRUint32 DOM_OBJECT           = 0x08;
     107    const PRUint32 PLUGIN_OBJECT        = 0x10;
     108    const PRUint32 EAGER_CLASSINFO      = 0x20;
    109109    /**
    110110     * 'flags' attribute bitflag: whether objects of this type implement
    111111     * nsIContent.
    112112     */
    113     const PRUint32 CONTENT_NODE         = 1 << 6;
     113    const PRUint32 CONTENT_NODE         = 0x40;
    114114   
    115115    // The high order bit is RESERVED for consumers of these flags.
    116116    // No implementor of this interface should ever return flags
    117117    // with this bit set.
    118     const PRUint32 RESERVED             = 1 << 31;
     118    const PRUint32 RESERVED             = 0x80000000;
    119119
    120120
  • trunk/src/libs/xpcom18a4/xpcom/components/nsIComponentManager.idl

    r1 r108326  
    109109#include "nsComponentManagerObsolete.h"
    110110#endif
    111 %} C++
     111%}
  • trunk/src/libs/xpcom18a4/xpcom/components/nsIComponentManagerObsolete.idl

    r1 r108326  
    348348/* include after the class def'n, because it needs to see it. */
    349349#include "nsComponentManagerUtils.h"
    350 %} C++
    351 
     350%}
     351
  • trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_header.c

    r108324 r108326  
    231231static int write_param(PCXPIDLNODE pNd, FILE *pFile)
    232232{
    233     PCXPIDLNODE pNdTypeSpec = pNd->u.Param.pNdTypeSpec;
     233    PCXPIDLNODE pNdTypeSpec = find_underlying_type(pNd->u.Param.pNdTypeSpec);
    234234    bool is_in = pNd->u.Param.enmDir == kXpidlDirection_In;
    235235    /* in string, wstring, nsid, domstring, utf8string, cstring and
     
    239239    if (is_in &&
    240240        (xpidlNdIsStringType(pNdTypeSpec) ||
    241 //         IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator,
    242 //                               "const") ||
     241         xpidlNodeAttrFind(pNd, "const") ||
    243242         xpidlNodeAttrFind(pNdTypeSpec, "nsid") ||
    244243         xpidlNodeAttrFind(pNdTypeSpec, "domstring")  ||
     
    253252    }
    254253
    255     int rc = xpidlHdrWriteType(pNdTypeSpec, pFile);
     254    int rc = xpidlHdrWriteType(pNd->u.Param.pNdTypeSpec, pFile);
     255    AssertRC(rc);
    256256    if (RT_FAILURE(rc))
    257257        return rc;
     
    321321    }
    322322
    323 #if 0
    324323    /* make IDL return value into trailing out argument */
    325     if (op->op_type_spec && !op_notxpcom) {
    326         IDL_tree fake_param = IDL_param_dcl_new(IDL_PARAM_OUT,
    327                                                 op->op_type_spec,
    328                                                 IDL_ident_new("_retval"));
    329         if (!fake_param)
    330             return FALSE;
    331         if (!write_param(fake_param, pFile))
    332             return FALSE;
     324    if (   pNd->u.Method.pNdTypeSpecRet
     325        && (   pNd->u.Method.pNdTypeSpecRet->enmType != kXpidlNdType_BaseType
     326            || pNd->u.Method.pNdTypeSpecRet->u.enmBaseType != kXpidlType_Void)
     327        && !op_notxpcom)
     328    {
     329        if (!no_generated_args)
     330            fputs(", ", pFile);
     331        XPIDLNODE Nd;
     332        Nd.enmType = kXpidlNdType_Parameter;
     333        Nd.u.Param.pszName = "_retval";
     334        Nd.u.Param.enmDir = kXpidlDirection_Out;
     335        Nd.u.Param.pNdTypeSpec = pNd->u.Method.pNdTypeSpecRet;
     336        int rc = write_param(&Nd, pFile);
     337        if (RT_FAILURE(rc))
     338        {
     339            AssertFailed();
     340            return VERR_INVALID_PARAMETER;
     341        }
    333342
    334343#if 0
     
    338347        no_generated_args = false;
    339348    }
    340 #endif
    341349
    342350#if 0 /** @todo No varargs allowed. */
     
    443451         * cstring and astring get const.
    444452         */
     453        PCXPIDLNODE pNdTypeSpec = find_underlying_type(pNd->u.Attribute.pNdTypeSpec);
     454
    445455        if (!getter &&
    446             (xpidlNdIsStringType(pNd->u.Attribute.pNdTypeSpec) ||
    447              xpidlNodeAttrFind(pNd, "nsid") ||
    448              xpidlNodeAttrFind(pNd, "domstring")  ||
    449              xpidlNodeAttrFind(pNd, "utf8string") ||
    450              xpidlNodeAttrFind(pNd, "cstring")    ||
    451              xpidlNodeAttrFind(pNd, "astring")))
     456            (xpidlNdIsStringType(pNdTypeSpec) ||
     457             xpidlNodeAttrFind(pNdTypeSpec, "nsid") ||
     458             xpidlNodeAttrFind(pNdTypeSpec, "domstring")  ||
     459             xpidlNodeAttrFind(pNdTypeSpec, "utf8string") ||
     460             xpidlNodeAttrFind(pNdTypeSpec, "cstring")    ||
     461             xpidlNodeAttrFind(pNdTypeSpec, "astring")))
    452462            fputs("const ", pFile);
    453463
     
    456466            return rc;
    457467        fprintf(pFile, "%s%s",
    458                 (STARRED_TYPE(pNd->u.Attribute.pNdTypeSpec) ? "" : " "),
    459                 (getter && !DIPPER_TYPE(pNd->u.Attribute.pNdTypeSpec) ? "*" : ""));
     468                (STARRED_TYPE(pNdTypeSpec) ? "" : " "),
     469                (getter && !DIPPER_TYPE(pNdTypeSpec) ? "*" : ""));
    460470    }
    461471    fprintf(pFile, "a%c%s)", toupper(pszName[0]), pszName + 1);
     
    525535        return VERR_INVALID_PARAMETER;
    526536
    527 #define FAIL    do {rc = VERR_INVALID_PARAMETER; goto out;} while(0)
     537#define FAIL    do {AssertFailed(); rc = VERR_INVALID_PARAMETER; goto out;} while(0)
    528538
    529539    fprintf(pFile, "\n/* starting interface:    %s */\n", pNd->u.If.pszIfName);
     
    587597     */
    588598    bool keepvtable = false;
    589 #if 0 /* We don't allow code fragments in interface definitions. */
    590     for (iter = IDL_INTERFACE(state->tree).body;
    591          iter != NULL;
    592          iter = IDL_LIST(iter).next)
    593     {
    594         IDL_tree data = IDL_LIST(iter).data;
    595         if (IDL_NODE_TYPE(data) == IDLN_CODEFRAG)
    596             keepvtable = TRUE;
    597     }
    598 #endif
     599    PCXPIDLNODE pIt;
     600    RTListForEach(&pNd->u.If.LstBody, pIt, XPIDLNODE, NdLst)
     601    {
     602        if (pIt->enmType == kXpidlNdType_RawBlock)
     603        {
     604            keepvtable = true;
     605            break;
     606        }
     607    }
     608
    599609
    600610    /* The interface declaration itself. */
     
    614624    fputs(")\n\n", pFile);
    615625
    616     PCXPIDLNODE pIt;
    617626    RTListForEach(&pNd->u.If.LstBody, pIt, XPIDLNODE, NdLst)
    618627    {
     
    633642                if (RT_FAILURE(rc))
    634643                    FAIL;
     644                break;
     645            case kXpidlNdType_RawBlock:
     646                fprintf(pFile, "%.*s", (int)pIt->u.RawBlock.cchRaw, pIt->u.RawBlock.pszRaw);
    635647                break;
    636648            default:
     
    670682        {
    671683            case kXpidlNdType_Const:
     684            case kXpidlNdType_RawBlock:
    672685                /* ignore it here; it doesn't contribute to the macro. */
    673686                continue;
     
    728741        {
    729742            case kXpidlNdType_Const:
     743            case kXpidlNdType_RawBlock:
    730744                continue;
    731745            case kXpidlNdType_Attribute:
     
    798812        {
    799813            case kXpidlNdType_Const:
     814            case kXpidlNdType_RawBlock:
    800815                continue;
    801816            case kXpidlNdType_Attribute:
  • trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_idl.c

    r108321 r108326  
    8080    "/*",
    8181    "%{C++",
     82    "%{ C++",
    8283    NULL
    8384};
     
    8788{
    8889    "*/",
     90    "%}",
    8991    "%}",
    9092    NULL
     
    246248
    247249
    248 static int xpidlParseSkipComments(PXPIDLPARSE pThis, PXPIDLINPUT pInput)
     250static int xpidlParseSkipComments(PXPIDLPARSE pThis, PXPIDLINPUT pInput, bool *pfRawBlock)
    249251{
    250252    for (;;)
     
    260262
    261263        /* Make sure we don't miss any %{C++ %} blocks. */
    262         if (!strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{C++")))
    263             return xpidlParseError(pThis, pInput, pTok, VERR_INVALID_PARAMETER, "Parser: Encountered unexpected raw code block comment");
     264        if (   !strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{C++"))
     265            || !strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{ C++")))
     266        {
     267            if (pfRawBlock)
     268                *pfRawBlock = true;
     269            return VINF_SUCCESS;
     270        }
    264271
    265272        RTScriptLexConsumeToken(pInput->hIdlLex);
     
    636643        const char *pszVal = NULL;
    637644
    638         XPIDL_PARSE_IDENTIFIER(pszAttr);
     645        XPIDL_PARSE_IDENTIFIER_ALLOW_KEYWORDS(pszAttr); /* For const for example. */
    639646        XPIDL_PARSE_OPTIONAL_PUNCTUATOR(fConsumed, '(');
    640647        if (fConsumed)
     
    839846{
    840847    int rc;
    841     PXPIDLNODE pNdConst = xpidlNodeCreate(pThis, pNdIf, pInput, kXpidlNdType_Attribute);
     848    PXPIDLNODE pNdConst = xpidlNodeCreateWithAttrs(pThis, pNdIf, pInput, kXpidlNdType_Attribute,
     849                                                   &pThis->aAttrs[0], pThis->cAttrs);
    842850    if (pNdConst)
    843851    {
     852        pThis->cAttrs = 0;
    844853        RTListAppend(&pNdIf->u.If.LstBody, &pNdConst->NdLst);
    845854
     
    936945    for (;;)
    937946    {
    938         int rc = xpidlParseSkipComments(pThis, pInput);
     947        bool fRawBlock = false;
     948        int rc = xpidlParseSkipComments(pThis, pInput, &fRawBlock);
    939949        if (RT_FAILURE(rc))
    940950            return rc;
     951
     952        if (fRawBlock)
     953        {
     954            PCRTSCRIPTLEXTOKEN pTok;
     955            int rc = RTScriptLexQueryToken(pInput->hIdlLex, &pTok);
     956            if (RT_FAILURE(rc))
     957                return xpidlParseError(pThis, pInput, NULL, rc, "Lexer: Failed to query punctuator token with %Rrc", rc);
     958
     959            size_t cchIntro =   !strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{C++"))
     960                              ? 6  /* Assumes a newline after %{C++ */
     961                              : 7; /* Assumes a newline after %{C++ */
     962            /* Create a new raw block node. */
     963            PXPIDLNODE pNode = xpidlNodeCreate(pThis, NULL, pInput, kXpidlNdType_RawBlock);
     964            if (pNode)
     965            {
     966                pNode->u.RawBlock.pszRaw = pTok->Type.Comment.pszComment + cchIntro;
     967                pNode->u.RawBlock.cchRaw = pTok->Type.Comment.cchComment - (cchIntro + 2 + 1); /* Start + end + zero terminator. */
     968                RTScriptLexConsumeToken(pInput->hIdlLex);
     969                RTListAppend(&pNdIf->u.If.LstBody, &pNode->NdLst);
     970            }
     971            else
     972            {
     973                rc = VERR_NO_MEMORY;
     974                break;
     975            }
     976        }
    941977
    942978        /* A closing '}' means we reached the end of the interface body. */
     
    944980        XPIDL_PARSE_OPTIONAL_PUNCTUATOR(fConsumed, '}');
    945981        if (fConsumed)
     982            break;
     983
     984        XPIDL_PARSE_OPTIONAL_PUNCTUATOR(fConsumed, '[');
     985        if (fConsumed)
     986        {
     987            if (pThis->cAttrs)
     988                return xpidlParseError(pThis, pInput, NULL, VERR_INVALID_PARAMETER,
     989                                       "Start of attribute list directly after an existing attribute list");
     990
     991            rc = xpidlParseAttributes(pThis, pInput, &pThis->aAttrs[0], RT_ELEMENTS(pThis->aAttrs), &pThis->cAttrs);
     992        }
     993        if (RT_FAILURE(rc))
    946994            break;
    947995
     
    9811029            /* We need to parse a type spec. */
    9821030            PXPIDLNODE pNdRetType = NULL;
    983             XPIDLATTR aAttrs[32];
    984             uint32_t cAttrs = 0;
    985 
    986             /* A list of attributes for this method?. */
    987             XPIDL_PARSE_OPTIONAL_PUNCTUATOR(fConsumed, '[');
    988             if (fConsumed)
    989             {
    990                 rc = xpidlParseAttributes(pThis, pInput, &aAttrs[0], RT_ELEMENTS(aAttrs), &cAttrs);
    991                 if (RT_FAILURE(rc))
    992                     return rc;
    993             }
    9941031
    9951032            rc = xpidlParseTypeSpec(pThis, pInput, &pNdRetType);
     
    9981035
    9991036            PXPIDLNODE pNdMethod = xpidlNodeCreateWithAttrs(pThis, pNdIf, pInput, kXpidlNdType_Method,
    1000                                                             &aAttrs[0], cAttrs);
     1037                                                            &pThis->aAttrs[0], pThis->cAttrs);
    10011038            if (pNdMethod)
    10021039            {
     1040                pThis->cAttrs = 0;
    10031041                RTListAppend(&pNdIf->u.If.LstBody, &pNdMethod->NdLst);
    10041042
     
    12031241            {
    12041242                /* Could be a raw block, check that the string starts with %{C++. */
    1205                 if (!strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{C++")))
     1243                if (   !strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{C++"))
     1244                    || !strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{ C++")))
    12061245                {
     1246                    size_t cchIntro =   !strncmp(pTok->Type.Comment.pszComment, RT_STR_TUPLE("%{C++"))
     1247                                      ? 6  /* Assumes a newline after %{C++ */
     1248                                      : 7; /* Assumes a newline after %{C++ */
    12071249                    /* Create a new raw block node. */
    12081250                    PXPIDLNODE pNode = xpidlNodeCreate(pThis, NULL, pInput, kXpidlNdType_RawBlock);
    12091251                    if (pNode)
    12101252                    {
    1211                         pNode->u.RawBlock.pszRaw = pTok->Type.Comment.pszComment + 6; /* Assumes a newline after %{C++ */
    1212                         pNode->u.RawBlock.cchRaw = pTok->Type.Comment.cchComment - (6 + 2 + 1); /* Start + end + zero terminator. */
     1253                        pNode->u.RawBlock.pszRaw = pTok->Type.Comment.pszComment + cchIntro;
     1254                        pNode->u.RawBlock.cchRaw = pTok->Type.Comment.cchComment - (cchIntro + 2 + 1); /* Start + end + zero terminator. */
    12131255                        RTListAppend(&pThis->LstNodes, &pNode->NdLst);
    12141256                    }
  • trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_typelib.c

    r108321 r108326  
    12111211                rc = xpidlTypelibProcessConst(pThis, pIt);
    12121212                break;
     1213            case kXpidlNdType_RawBlock:
     1214                break;
    12131215            default:
    12141216                AssertReleaseFailed();
  • trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_util.c

    r108321 r108326  
    352352DECLHIDDEN(PCXPIDLNODE) find_underlying_type(PCXPIDLNODE pNd)
    353353{
     354    if (pNd->enmType == kXpidlNdType_BaseType)
     355        return pNd;
    354356    if (pNd == NULL || pNd->enmType != kXpidlNdType_Identifier)
    355357        return NULL;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette