Skip to content

Allow to manually call QueryInterface from windows #2657

@pie-flavor

Description

@pie-flavor

Suggestion

Consider the function IActiveScript::GetScriptSite:

HRESULT GetScriptSite(  
    REFIID iid,           // interface identifier  
    void **ppvSiteObject  // address of host site interface  
);  

The natural way to implement this function is, given some variable site, site.QueryInterface(iid, ppvSiteObject). And the function is (by my understanding) designed to make that the natural way, as the IActiveScriptSite is provided via a parallel SetScriptSite function and the implementor of GetScriptSite doesn't necessarily know all the interfaces it implements, and therefore all the interfaces the caller of GetScriptSite might be wanting.

However windows does not allow you to call QueryInterface directly. This means I can't implement it that way, and can only cast to interfaces I do know about. If the caller wants IActiveScriptSiteTraceInfo, and I forgot to include it, then the function fails, where a C implementation would not have to fail.

The generic wrappers around QueryInterface to encapsulate its quirks are great, but it would be good to be able to call it directly when you need to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions