本文整理汇总了C++中nsIID类的典型用法代码示例。如果您正苦于以下问题:C++ nsIID类的具体用法?C++ nsIID怎么用?C++ nsIID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsIID类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
nsIncrementalDownload::GetInterface(const nsIID &iid, void **result)
{
if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
NS_ADDREF_THIS();
*result = static_cast<nsIChannelEventSink *>(this);
return NS_OK;
}
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(mObserver);
if (ir)
return ir->GetInterface(iid, result);
return NS_ERROR_NO_INTERFACE;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:15,代码来源:nsIncrementalDownload.cpp
示例2: if
/*static*/ nsresult
PyG_Base::CreateNew(PyObject *pPyInstance, const nsIID &iid, void **ppResult)
{
NS_PRECONDITION(ppResult && *ppResult==NULL, "NULL or uninitialized pointer");
if (ppResult==nsnull)
return NS_ERROR_NULL_POINTER;
PyG_Base *ret;
// Hack for few extra gateways we support.
if (iid.Equals(NS_GET_IID(nsIModule)))
ret = MakePyG_nsIModule(pPyInstance);
else if (iid.Equals(NS_GET_IID(nsIComponentLoader)))
ret = MakePyG_nsIComponentLoader(pPyInstance);
else if (iid.Equals(NS_GET_IID(nsIInputStream)))
ret = MakePyG_nsIInputStream(pPyInstance);
else
ret = new PyXPCOM_XPTStub(pPyInstance, iid);
if (ret==nsnull)
return NS_ERROR_OUT_OF_MEMORY;
ret->AddRef(); // The first reference for the caller.
*ppResult = ret->ThisAsIID(iid);
NS_ABORT_IF_FALSE(*ppResult != NULL, "ThisAsIID() gave NULL, but we know it supports it!");
return *ppResult ? NS_OK : NS_ERROR_FAILURE;
}
开发者ID:bringhurst,项目名称:vbox,代码行数:24,代码来源:PyGBase.cpp
示例3:
nsresult
IFoo::QueryInterface( const nsIID& aIID, void** aResult )
{
total_queries_++;
nsISupports* rawPtr = 0;
nsresult status = NS_OK;
if ( aIID.Equals(NS_GET_IID(IFoo)) )
rawPtr = this;
else
{
nsID iid_of_ISupports = NS_ISUPPORTS_IID;
if ( aIID.Equals(iid_of_ISupports) )
rawPtr = static_cast<nsISupports*>(this);
else
status = NS_ERROR_NO_INTERFACE;
}
NS_IF_ADDREF(rawPtr);
*aResult = rawPtr;
return status;
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:24,代码来源:TestCOMPtr.cpp
示例4:
NS_IMETHODIMP
nsBaseCommandController::GetInterface(const nsIID & aIID, void * *result)
{
NS_ENSURE_ARG_POINTER(result);
if (NS_SUCCEEDED(QueryInterface(aIID, result)))
return NS_OK;
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable)))
{
if (mCommandTable)
return mCommandTable->QueryInterface(aIID, result);
return NS_ERROR_NOT_INITIALIZED;
}
return NS_NOINTERFACE;
}
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:17,代码来源:nsBaseCommandController.cpp
示例5: GetInterface
// NS_INTERFACE_MAP_ENTRY(nsITooltipTextProvider) // de: added 7/26/01
NS_INTERFACE_MAP_END
//*****************************************************************************
// CBrowserImpl::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mWebBrowser)
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, aInstancePtr);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:18,代码来源:BrowserImpl.cpp
示例6: QueryInterface
NS_INTERFACE_MAP_END
////////////////////////////////////////////////////////////////////////////////
/* void getInterface (in nsIIDRef uuid, [iid_is (uuid), retval] out nsQIResult result); */
NS_IMETHODIMP
BrowserWindow::GetInterface(const nsIID & aIID, void * *aInstancePtr)
{
if ( aIID.Equals( NS_GET_IID( nsIDOMWindow ) ) ) {
if ( webBrowser ) {
return webBrowser->GetContentDOMWindow( ( nsIDOMWindow** )aInstancePtr );
};
return NS_ERROR_NOT_INITIALIZED;
};
return QueryInterface( aIID, aInstancePtr );
}
开发者ID:noqisofon,项目名称:gluezilla,代码行数:19,代码来源:BrowserWindow.cpp
示例7:
NS_IMETHODIMP
PipUIContext::GetInterface(const nsIID& uuid, void** result)
{
NS_ENSURE_ARG_POINTER(result);
*result = nullptr;
if (!NS_IsMainThread()) {
NS_ERROR("PipUIContext::GetInterface called off the main thread");
return NS_ERROR_NOT_SAME_THREAD;
}
if (!uuid.Equals(NS_GET_IID(nsIPrompt)))
return NS_ERROR_NO_INTERFACE;
nsIPrompt* prompt = nullptr;
nsresult rv = nsNSSComponent::GetNewPrompter(&prompt);
*result = prompt;
return rv;
}
开发者ID:nebulak,项目名称:gecko-dev,代码行数:19,代码来源:nsNSSComponent.cpp
示例8: GetInterface
NS_INTERFACE_MAP_END
///////////////////////////////////////////////////////////////////////////////
// nsIInterfaceRequestor
NS_IMETHODIMP CWebBrowserContainer::GetInterface(const nsIID & aIID, void * *result)
{
*result = 0;
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mOwner && mOwner->mWebBrowser)
{
return mOwner->mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) result);
}
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, result);
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:19,代码来源:WebBrowserContainer.cpp
示例9: CSecurityContext
// Create the CSecurityContext object for creating object, invoking method,
// getting/setting field in JNI with security context.
NS_METHOD
CSecurityContext::Create(nsISupports* outer,
const char* lpszURL,PRBool isAllPermission,
const nsIID& aIID, void* *aInstancePtr)
{
/* If this is an aggregated object creation (i.e. outer exists)
then we expect to return the special object Internal, which
provides the nondelegating functions */
if (outer && !aIID.Equals(kISupportsIID))
return NS_NOINTERFACE; // XXX right error?
CSecurityContext* context = new CSecurityContext(outer, lpszURL, isAllPermission);
if (context == NULL)
return NS_ERROR_OUT_OF_MEMORY;
context->AddRef();
*aInstancePtr = (outer != NULL)
?(void *)context->GetInner()
:(void *)context;
return NS_OK;
}
开发者ID:FredChap,项目名称:myforthprocessor,代码行数:22,代码来源:CSecurityContext.cpp
示例10:
NS_IMETHODIMP
nsBaseCommandController::GetInterface(const nsIID& aIID, void** aResult) {
NS_ENSURE_ARG_POINTER(aResult);
if (NS_SUCCEEDED(QueryInterface(aIID, aResult))) {
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable))) {
if (mCommandTable) {
*aResult =
do_AddRef(static_cast<nsIControllerCommandTable*>(mCommandTable))
.take();
return NS_OK;
}
return NS_ERROR_NOT_INITIALIZED;
}
return NS_NOINTERFACE;
}
开发者ID:jld,项目名称:gecko-dev,代码行数:20,代码来源:nsBaseCommandController.cpp
示例11: GetInterface
NS_INTERFACE_MAP_END
//*****************************************************************************
// WebBrowserChrome::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
NS_ENSURE_ARG_POINTER(aInstancePtr);
*aInstancePtr = 0;
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mWebBrowser)
{
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
}
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, aInstancePtr);
}
开发者ID:adamroach,项目名称:gecko-dev,代码行数:21,代码来源:WebBrowserChrome.cpp
示例12: lock
nsresult
NativeToJavaProxyMap::Find(JNIEnv* env, nsISupports* aNativeObject,
const nsIID& aIID, jobject* aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (!aResult)
return NS_ERROR_FAILURE;
nsAutoLock lock(gJavaXPCOMLock);
*aResult = nsnull;
Entry* e = static_cast<Entry*>(PL_DHashTableOperate(mHashTable,
aNativeObject,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_FREE(e))
return NS_OK;
ProxyList* item = e->list;
while (item != nsnull && *aResult == nsnull) {
if (item->iid.Equals(aIID)) {
jobject referentObj = env->CallObjectMethod(item->javaObject,
getReferentMID);
if (!env->IsSameObject(referentObj, NULL)) {
*aResult = referentObj;
#ifdef DEBUG_JAVAXPCOM
char* iid_str = aIID.ToString();
LOG(("< NativeToJavaProxyMap (Java=%08x | XPCOM=%08x | IID=%s)\n",
(PRUint32) env->CallStaticIntMethod(systemClass, hashCodeMID,
*aResult),
(PRUint32) aNativeObject, iid_str));
NS_Free(iid_str);
#endif
}
}
item = item->next;
}
return NS_OK;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:40,代码来源:nsJavaXPCOMBindingUtils.cpp
示例13: GetInterface
NS_INTERFACE_MAP_END
//*****************************************************************************
// nsChromeTreeOwner::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
{
NS_ENSURE_ARG_POINTER(aSink);
if(aIID.Equals(NS_GET_IID(nsIPrompt))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow2))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->QueryInterface(aIID, aSink);
}
return QueryInterface(aIID, aSink);
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:37,代码来源:nsChromeTreeOwner.cpp
示例14: SetComplexValue
NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID & aType, nsISupports *aValue)
{
ENSURE_MAIN_PROCESS("Cannot SetComplexValue from content process:", aPrefName);
NS_ENSURE_ARG(aPrefName);
nsresult rv = NS_NOINTERFACE;
// also check nsILocalFile, for backwards compatibility
if (aType.Equals(NS_GET_IID(nsIFile)) || aType.Equals(NS_GET_IID(nsILocalFile))) {
nsCOMPtr<nsIFile> file = do_QueryInterface(aValue);
if (!file)
return NS_NOINTERFACE;
nsAutoCString descriptorString;
rv = file->GetPersistentDescriptor(descriptorString);
if (NS_SUCCEEDED(rv)) {
rv = SetCharPrefInternal(aPrefName, descriptorString.get());
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIRelativeFilePref))) {
nsCOMPtr<nsIRelativeFilePref> relFilePref = do_QueryInterface(aValue);
if (!relFilePref)
return NS_NOINTERFACE;
nsCOMPtr<nsIFile> file;
relFilePref->GetFile(getter_AddRefs(file));
if (!file)
return NS_NOINTERFACE;
nsAutoCString relativeToKey;
(void) relFilePref->GetRelativeToKey(relativeToKey);
nsCOMPtr<nsIFile> relativeToFile;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = directoryService->Get(relativeToKey.get(), NS_GET_IID(nsIFile), getter_AddRefs(relativeToFile));
if (NS_FAILED(rv))
return rv;
nsAutoCString relDescriptor;
rv = file->GetRelativeDescriptor(relativeToFile, relDescriptor);
if (NS_FAILED(rv))
return rv;
nsAutoCString descriptorString;
descriptorString.Append('[');
descriptorString.Append(relativeToKey);
descriptorString.Append(']');
descriptorString.Append(relDescriptor);
return SetCharPrefInternal(aPrefName, descriptorString.get());
}
if (aType.Equals(NS_GET_IID(nsISupportsString))) {
nsCOMPtr<nsISupportsString> theString = do_QueryInterface(aValue);
if (theString) {
nsString wideString;
rv = theString->GetData(wideString);
if (NS_SUCCEEDED(rv)) {
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength(aPrefName, wideString);
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
nsCOMPtr<nsIPrefLocalizedString> theString = do_QueryInterface(aValue);
if (theString) {
nsXPIDLString wideString;
rv = theString->GetData(getter_Copies(wideString));
if (NS_SUCCEEDED(rv)) {
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength(aPrefName, wideString);
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;
}
NS_WARNING("nsPrefBranch::SetComplexValue - Unsupported interface type");
return NS_NOINTERFACE;
}
开发者ID:dadaa,项目名称:gecko-dev,代码行数:95,代码来源:nsPrefBranch.cpp
示例15: GetComplexValue
NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID & aType, void **_retval)
{
NS_ENSURE_ARG(aPrefName);
nsresult rv;
nsXPIDLCString utf8String;
// we have to do this one first because it's different than all the rest
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
nsCOMPtr<nsIPrefLocalizedString> theString(do_CreateInstance(NS_PREFLOCALIZEDSTRING_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
const char *pref = getPrefName(aPrefName);
bool bNeedDefault = false;
if (mIsDefault) {
bNeedDefault = true;
} else {
// if there is no user (or locked) value
if (!PREF_HasUserPref(pref) && !PREF_PrefIsLocked(pref)) {
bNeedDefault = true;
}
}
// if we need to fetch the default value, do that instead, otherwise use the
// value we pulled in at the top of this function
if (bNeedDefault) {
nsXPIDLString utf16String;
rv = GetDefaultFromPropertiesFile(pref, getter_Copies(utf16String));
if (NS_SUCCEEDED(rv)) {
theString->SetData(utf16String.get());
}
} else {
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_SUCCEEDED(rv)) {
theString->SetData(NS_ConvertUTF8toUTF16(utf8String).get());
}
}
if (NS_SUCCEEDED(rv)) {
theString.forget(reinterpret_cast<nsIPrefLocalizedString**>(_retval));
}
return rv;
}
// if we can't get the pref, there's no point in being here
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_FAILED(rv)) {
return rv;
}
// also check nsILocalFile, for backwards compatibility
if (aType.Equals(NS_GET_IID(nsIFile)) || aType.Equals(NS_GET_IID(nsILocalFile))) {
if (GetContentChild()) {
NS_ERROR("cannot get nsIFile pref from content process");
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIFile> file(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
rv = file->SetPersistentDescriptor(utf8String);
if (NS_SUCCEEDED(rv)) {
file.forget(reinterpret_cast<nsIFile**>(_retval));
return NS_OK;
}
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIRelativeFilePref))) {
if (GetContentChild()) {
NS_ERROR("cannot get nsIRelativeFilePref from content process");
return NS_ERROR_NOT_AVAILABLE;
}
nsACString::const_iterator keyBegin, strEnd;
utf8String.BeginReading(keyBegin);
utf8String.EndReading(strEnd);
// The pref has the format: [fromKey]a/b/c
if (*keyBegin++ != '[')
return NS_ERROR_FAILURE;
nsACString::const_iterator keyEnd(keyBegin);
if (!FindCharInReadable(']', keyEnd, strEnd))
return NS_ERROR_FAILURE;
nsAutoCString key(Substring(keyBegin, keyEnd));
nsCOMPtr<nsIFile> fromFile;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = directoryService->Get(key.get(), NS_GET_IID(nsIFile), getter_AddRefs(fromFile));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIFile> theFile;
rv = NS_NewNativeLocalFile(EmptyCString(), true, getter_AddRefs(theFile));
if (NS_FAILED(rv))
//.........这里部分代码省略.........
开发者ID:dadaa,项目名称:gecko-dev,代码行数:101,代码来源:nsPrefBranch.cpp
示例16: Equals
bool Equals(const nsHashKey *aKey) const {
return mKey.Equals( ((nsIIDKey*) aKey)->mKey);
}
开发者ID:arun1778,项目名称:gecko,代码行数:3,代码来源:nsXBLPrototypeBinding.cpp
示例17: GetDefaultGateway
PyG_Base::PyG_Base(PyObject *instance, const nsIID &iid)
{
// Note that "instance" is the _policy_ instance!!
PR_AtomicIncrement(&cGateways);
m_pBaseObject = GetDefaultGateway(instance);
// m_pWeakRef is an nsCOMPtr and needs no init.
NS_ABORT_IF_FALSE(!(iid.Equals(NS_GET_IID(nsISupportsWeakReference)) || iid.Equals(NS_GET_IID(nsIWeakReference))),"Should not be creating gateways with weak-ref interfaces");
m_iid = iid;
m_pPyObject = instance;
NS_PRECONDITION(instance, "NULL PyObject for PyXPCOM_XPTStub!");
#ifdef NS_BUILD_REFCNT_LOGGING
// If XPCOM reference count logging is enabled, then allow us to give the Python class.
PyObject *realInstance = PyObject_GetAttrString(instance, "_obj_");
PyObject *r = PyObject_Repr(realInstance);
const char *szRepr;
if (r==NULL) {
PyXPCOM_LogError("Getting the __repr__ of the object failed");
PyErr_Clear();
szRepr = "(repr failed!)";
}
else
szRepr = PyString_AsString(r);
if (szRepr==NULL) szRepr = "";
int reprOffset = *szRepr=='<' ? 1 : 0;
static const char *reprPrefix = "component:";
if (strncmp(reprPrefix, szRepr+reprOffset, strlen(reprPrefix)) == 0)
reprOffset += strlen(reprPrefix);
strncpy(refcntLogRepr, szRepr + reprOffset, sizeof(refcntLogRepr)-1);
refcntLogRepr[sizeof(refcntLogRepr)-1] = '\0';
// See if we should get rid of the " at 0x12345" portion.
char *lastPos = strstr(refcntLogRepr, " at ");
if (lastPos) *lastPos = '\0';
Py_XDECREF(realInstance);
Py_XDECREF(r);
#endif // NS_BUILD_REFCNT_LOGGING
#ifdef DEBUG_LIFETIMES
{
char *iid_repr;
nsCOMPtr<nsIInterfaceInfoManager> iim = XPTI_GetInterfaceInfoManager();
if (iim!=nsnull)
iim->GetNameForIID(&iid, &iid_repr);
PyObject *real_instance = PyObject_GetAttrString(instance, "_obj_");
PyObject *real_repr = PyObject_Repr(real_instance);
PYXPCOM_LOG_DEBUG("PyG_Base created at %p\n instance_repr=%s\n IID=%s\n", this, PyString_AsString(real_repr), iid_repr);
nsMemory::Free(iid_repr);
Py_XDECREF(real_instance);
Py_XDECREF(real_repr);
}
#endif // DEBUG_LIFETIMES
Py_XINCREF(instance); // instance should never be NULL - but whats an X between friends!
PyXPCOM_DLLAddRef();
#ifdef DEBUG_FULL
LogF("PyGatewayBase: created %s", m_pPyObject ? m_pPyObject->ob_type->tp_name : "<NULL>");
#endif
}
开发者ID:bringhurst,项目名称:vbox,代码行数:61,代码来源:PyGBase.cpp
示例18: GetInterface
NS_IMETHOD GetInterface(const nsIID &iid, void **result) {
if (iid.Equals(NS_GET_IID(nsIProgressEventSink)))
return QueryInterface(iid, result);
return NS_ERROR_NO_INTERFACE;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:5,代码来源:TestFileTransport.cpp
示例19: AutoWrapPythonInstance
PRBool
Py_nsISupports::InterfaceFromPyObject(PyObject *ob,
const nsIID &iid,
nsISupports **ppv,
PRBool bNoneOK,
PRBool bTryAutoWrap /* = PR_TRUE */)
{
if ( ob == NULL )
{
// don't overwrite an error message
if ( !PyErr_Occurred() )
PyErr_SetString(PyExc_TypeError, "The Python object is invalid");
return PR_FALSE;
}
if ( ob == Py_None )
{
if ( bNoneOK )
{
*ppv = NULL;
return PR_TRUE;
}
else
{
PyErr_SetString(PyExc_TypeError, "None is not a invalid interface object in this context");
return PR_FALSE;
}
}
// support nsIVariant
if (iid.Equals(NS_GET_IID(nsIVariant)) || iid.Equals(NS_GET_IID(nsIWritableVariant))) {
// Check it is not already nsIVariant
if (PyInstance_Check(ob)) {
PyObject *sub_ob = PyObject_GetAttrString(ob, "_comobj_");
if (sub_ob==NULL) {
PyErr_Clear();
} else {
if (InterfaceFromPyISupports(sub_ob, iid, ppv)) {
Py_DECREF(sub_ob);
return PR_TRUE;
}
PyErr_Clear();
Py_DECREF(sub_ob);
}
}
nsresult nr = PyObject_AsVariant(ob, (nsIVariant **)ppv);
if (NS_FAILED(nr)) {
PyXPCOM_BuildPyException(nr);
return PR_FALSE;
}
NS_ASSERTION(ppv != nsnull, "PyObject_AsVariant worked but gave null!");
return PR_TRUE;
}
// end of variant support.
if (PyInstance_Check(ob)) {
// Get the _comobj_ attribute
PyObject *use_ob = PyObject_GetAttrString(ob, "_comobj_");
if (use_ob==NULL) {
PyErr_Clear();
if (bTryAutoWrap)
// Try and auto-wrap it - errors will leave Py exception set,
return PyXPCOM_XPTStub::AutoWrapPythonInstance(ob, iid, ppv);
PyErr_SetString(PyExc_TypeError, "The Python instance can not be converted to an XPCOM object");
return PR_FALSE;
} else
ob = use_ob;
} else {
Py_INCREF(ob);
}
PRBool rc = InterfaceFromPyISupports(ob, iid, ppv);
Py_DECREF(ob);
return rc;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:74,代码来源:PyISupports.cpp
示例20: GetComplexValue
NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID & aType, void * *_retval)
{
nsresult rv;
nsXPIDLCString utf8String;
// we have to do this one first because it's different than all the rest
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
nsCOMPtr<nsIPrefLocalizedString> theString(do_CreateInstance(NS_PREFLOCALIZEDSTRING_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
const char *pref;
PRBool bNeedDefault = PR_FALSE;
rv = getValidatedPrefName(aPrefName, &pref);
if (NS_FAILED(rv))
return rv;
if (mIsDefault) {
bNeedDefault = PR_TRUE;
} else {
// if there is no user (or locked) value
if (!PREF_HasUserPref(pref) && !PREF_PrefIsLocked(pref)) {
bNeedDefault = PR_TRUE;
}
}
// if we need to fetch the default value, do that instead, otherwise use the
// value we pulled in at the top of this function
if (bNeedDefault) {
nsXPIDLString utf16String;
rv = GetDefaultFromPropertiesFile(pref, getter_Copies(utf16String));
if (NS_SUCCEEDED(rv)) {
rv = theString->SetData(utf16String.get());
}
} else {
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_SUCCEEDED(rv)) {
rv = theString->SetData(NS_ConvertUTF8toUCS2(utf8String).get());
}
}
if (NS_SUCCEEDED(rv)) {
nsIPrefLocalizedString *temp = theString;
NS_ADDREF(temp);
*_retval = (void *)temp;
}
}
return rv;
}
// if we can't get the pref, there's no point in being here
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_FAILED(rv)) {
return rv;
}
if (aType.Equals(NS_GET_IID(nsILocalFile))) {
nsCOMPtr<nsILocalFile> file(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
rv = file->SetPersistentDescriptor(utf8String);
if (NS_SUCCEEDED(rv)) {
nsILocalFile *temp = file;
NS_ADDREF(temp);
*_retval = (void *)temp;
return NS_OK;
}
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIRelativeFilePref))) {
nsACString::const_iterator keyBegin, strEnd;
utf8String.BeginReading(keyBegin);
utf8String.EndReading(strEnd);
// The pref has the format: [fromKey]a/b/c
if (*keyBegin++ != '[')
return NS_ERROR_FAILURE;
nsACString::const_iterator keyEnd(keyBegin);
if (!FindCharInReadable(']', keyEnd, strEnd))
return NS_ERROR_FAILURE;
nsCAutoString key(Substring(keyBegin, keyEnd));
nsCOMPtr<nsILocalFile> fromFile;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = directoryService->Get(key.get(), NS_GET_IID(nsILocalFile), getter_AddRefs(fromFile));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsILocalFile> theFile;
rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(theFile));
if (NS_FAILED(rv))
return rv;
rv = theFile->SetRelativeDescriptor(fromFile, Substring(++keyEnd, strEnd));
if (NS_FAILED(rv))
//.........这里部分代码省略.........
开发者ID:rn10950,项目名称:RetroZilla,代码行数:101,代码来源:nsPrefBranch.cpp
注:本文中的nsIID类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论