OK, I've done it with my own patch, indeed, I just want to calling C APIs with XPCOM pointers. So I implemented the following function to deal with my situation:
512020db461367413e46bfeb3af8b70ed45e01f8 xpcom/components/nsComponentManager.cpp | 14 ++++++++++++++ xpcom/components/nsIComponentManager.idl | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index c5bcd92..bef39e2 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -21,6 +21,7 @@ #include "nsISupports.h" #include "nspr.h" #include "nsCRT.h" // for atoll +#include "nsPrintfCString.h" // Arena used by component manager for storing contractid string, dll // location strings and small objects @@ -1868,6 +1869,19 @@ nsComponentManagerImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) return n; } +NS_IMETHODIMP nsComponentManagerImpl::GetPointerForInterface(nsISupports *aInstance, const nsIID & aIID, nsACString & _retval) +{ + nsQueryInterface queryInterface(aInstance); + void* result = nullptr; + nsresult rc = queryInterface(aIID, &result); + if (rc != NS_OK) { + _retval = ""; + return NS_OK; + } + _retval = nsPrintfCString("0x%p", result); + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // nsFactoryEntry //////////////////////////////////////////////////////////////////////////////// diff --git a/xpcom/components/nsIComponentManager.idl b/xpcom/components/nsIComponentManager.idl index 1e5693a..912e11f 100644 --- a/xpcom/components/nsIComponentManager.idl +++ b/xpcom/components/nsIComponentManager.idl @@ -40,6 +40,17 @@ interface nsIComponentManager : nsISupports in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result); + /** + * getPointerForInterface + * + * Returns string representation of the pointer for a instance of the interface + * + * @param aInstance - The instance of the interface + * @param aIID - IID of interface requested + * @return ACString in hex format with "0x" prepended, or empty if the instance have no aIID + */ + ACString getPointerForInterface(in nsISupports aInstance, + in nsIIDRef aIID); /** * createInstance On Wed, Dec 23, 2015 at 11:02 PM, Ted Mielczarek <t...@mielczarek.org> wrote: > No, js-ctypes does not have any support for calling methods on C++ > classes. In fact, that functionality was WONTFIXed a while back: > https://bugzilla.mozilla.org/show_bug.cgi?id=505907. > > -Ted > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > -- 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform