enumerate interfaces change needed for pyxpcom

NEW
Assigned to

Status

--
major
5 years ago
5 years ago

People

(Reporter: twhitema, Assigned: twhitema)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
The "nsIInterfaceInfoManager.EnumerateInterfacesWhoseNamesStartWith()" method requires a prefix string of at least one character, otherwise it does not match any interfaces.

Will need to call EnumerateInterfacesWhoseNamesStartWith() for each variation of alphabet character (i.e. A-Za-z).
(Assignee)

Comment 1

5 years ago
Created attachment 758766 [details] [diff] [review]
Update pyxpcom's interface manager calls

This changes a few things:
 1) uses "EnumerateInterfacesWhoseNamesStartWith()" with a 1-char prefix
 2) changes python API to replace "EnumerateInterfaces()" with two new methods:
      "GetScriptableInterfaces()"
      "GetFunctionInterfaces()"
    both of which return a dictionary (name > iid), instead of a full nsIInterfaceInfo
 3) drops the Py_(BEGIN|END)_ALLOW_THREADS around calls to EnumerateInterfacesWhoseNamesStartWith() - as I don't think it's really necessary and it will just end up slowing things down
Attachment #758766 - Flags: review?(marky)

Comment 2

5 years ago
Comment on attachment 758766 [details] [diff] [review]
Update pyxpcom's interface manager calls

(from review of attachment 758766 [details] [diff] [review])
>diff --git a/xpcom/components.py b/xpcom/components.py
>+        name_to_iid_dict = interfaceInfoManager.GetScriptableInterfaces()
Hmm, I thought we cheated somewhere and used a non-[scriptable] interface from python. I guess we'll have to see if anything breaks :D

>diff --git a/xpcom/src/PyIInterfaceInfoManager.cpp b/xpcom/src/PyIInterfaceInfoManager.cpp
>+		// Add all returned interfaces to the python dict.
>+		for ( ; interfaces_enum->IsDone() == static_cast<nsresult>(NS_ENUMERATOR_FALSE); interfaces_enum->Next()) {
This line's kinda long. (I'd probably just use a do/while loop instead...)

>+			nsCOMPtr<nsIInterfaceInfo> iinfo(do_QueryInterface(entry));
>+			if (fn_scripables_only && (NS_FAILED(iinfo->IsFunction(&isFunction)) || !isFunction)) {
Should probably just split this into multiple lines for clarity

-----
Given discussions with tbsaunde on IRC:
I'd see if we can just static_cast the nsIInterfaceInfoManager to XPTInterfaceInfoManager and use GetScriptableInterfaces... It's pretty horrible as things go, but it's not like it will make much of a difference in terms of mismatched gecko versions...
Attachment #758766 - Flags: review?(marky) → review+
You need to log in before you can comment on or make changes to this bug.