mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
use nsAllocator instead of local wrapper. added Components.lastResult with tests
This commit is contained in:
parent
b459733e17
commit
540e024aae
@ -28,9 +28,35 @@ interface nsIXPCClasses : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
[uuid(42624f80-d26c-11d2-9842-006008962422)]
|
||||
interface nsIXPCComponents : nsISupports
|
||||
{
|
||||
readonly attribute nsIXPCInterfaces interfaces;
|
||||
readonly attribute nsIXPCClasses classes;
|
||||
|
||||
/* 'lastResult' is accessable via JavaScript only */
|
||||
|
||||
/* Some result codes are well known and defined by value in nsError.h.
|
||||
* Other codes will either have to be added by hand, at runtime (?),
|
||||
* or otherwise declared in idl (somehow).
|
||||
*/
|
||||
|
||||
const long RESULT_NS_OK = 0;
|
||||
const long RESULT_NS_COMFALSE = 1;
|
||||
const long RESULT_NS_ERROR_NOT_IMPLEMENTED = 0x80004001;
|
||||
const long RESULT_NS_NOINTERFACE = 0x80004002;
|
||||
const long RESULT_NS_ERROR_NO_INTERFACE = RESULT_NS_NOINTERFACE;
|
||||
const long RESULT_NS_ERROR_INVALID_POINTER = 0x80004003;
|
||||
const long RESULT_NS_ERROR_NULL_POINTER = RESULT_NS_ERROR_INVALID_POINTER;
|
||||
const long RESULT_NS_ERROR_ABORT = 0x80004004;
|
||||
const long RESULT_NS_ERROR_FAILURE = 0x80004005;
|
||||
const long RESULT_NS_ERROR_UNEXPECTED = 0x8000ffff;
|
||||
const long RESULT_NS_ERROR_OUT_OF_MEMORY = 0x8007000e;
|
||||
const long RESULT_NS_ERROR_ILLEGAL_VALUE = 0x80070057;
|
||||
const long RESULT_NS_ERROR_INVALID_ARG = RESULT_NS_ERROR_ILLEGAL_VALUE;
|
||||
const long RESULT_NS_ERROR_NO_AGGREGATION = 0x80040110;
|
||||
const long RESULT_NS_ERROR_NOT_AVAILABLE = 0x80040111;
|
||||
const long RESULT_NS_ERROR_FACTORY_NOT_REGISTERED = 0x80040154;
|
||||
const long RESULT_NS_ERROR_FACTORY_NOT_LOADED = 0x800401f8;
|
||||
};
|
||||
|
@ -69,5 +69,11 @@ interface nsIEcho : nsISupports {
|
||||
void ReturnCode(in long code);
|
||||
void FailInJSTest(in long fail);
|
||||
void SharedString([retval, shared] out string str);
|
||||
|
||||
void ReturnCode_NS_OK();
|
||||
void ReturnCode_NS_COMFALSE();
|
||||
void ReturnCode_NS_ERROR_NULL_POINTER();
|
||||
void ReturnCode_NS_ERROR_UNEXPECTED();
|
||||
void ReturnCode_NS_ERROR_OUT_OF_MEMORY();
|
||||
};
|
||||
|
||||
|
@ -74,6 +74,23 @@ class nsIXPCComponents : public nsISupports {
|
||||
|
||||
/* readonly attribute nsIXPCClasses classes; */
|
||||
NS_IMETHOD GetClasses(nsIXPCClasses * *aClasses) = 0;
|
||||
enum { RESULT_NS_OK = 0 };
|
||||
enum { RESULT_NS_COMFALSE = 1 };
|
||||
enum { RESULT_NS_ERROR_NOT_IMPLEMENTED = -2147467263 };
|
||||
enum { RESULT_NS_NOINTERFACE = -2147467262 };
|
||||
enum { RESULT_NS_ERROR_NO_INTERFACE = -2147467262 };
|
||||
enum { RESULT_NS_ERROR_INVALID_POINTER = -2147467261 };
|
||||
enum { RESULT_NS_ERROR_NULL_POINTER = -2147467261 };
|
||||
enum { RESULT_NS_ERROR_ABORT = -2147467260 };
|
||||
enum { RESULT_NS_ERROR_FAILURE = -2147467259 };
|
||||
enum { RESULT_NS_ERROR_UNEXPECTED = -2147418113 };
|
||||
enum { RESULT_NS_ERROR_OUT_OF_MEMORY = -2147024882 };
|
||||
enum { RESULT_NS_ERROR_ILLEGAL_VALUE = -2147024809 };
|
||||
enum { RESULT_NS_ERROR_INVALID_ARG = -2147024809 };
|
||||
enum { RESULT_NS_ERROR_NO_AGGREGATION = -2147221232 };
|
||||
enum { RESULT_NS_ERROR_NOT_AVAILABLE = -2147221231 };
|
||||
enum { RESULT_NS_ERROR_FACTORY_NOT_REGISTERED = -2147221164 };
|
||||
enum { RESULT_NS_ERROR_FACTORY_NOT_LOADED = -2147221000 };
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
|
@ -42,7 +42,6 @@ CPPSRCS= \
|
||||
xpcmaps.cpp \
|
||||
xpcmodule.cpp \
|
||||
xpcthrower.cpp \
|
||||
xpcutil.cpp \
|
||||
xpcwrappedjs.cpp \
|
||||
xpcwrappedjsclass.cpp \
|
||||
xpcwrappednative.cpp \
|
||||
|
@ -41,7 +41,6 @@ OBJS= \
|
||||
.\$(OBJDIR)\xpcmaps.obj \
|
||||
.\$(OBJDIR)\xpcmodule.obj \
|
||||
.\$(OBJDIR)\xpcthrower.obj \
|
||||
.\$(OBJDIR)\xpcutil.obj \
|
||||
.\$(OBJDIR)\xpcwrappedjs.obj \
|
||||
.\$(OBJDIR)\xpcwrappedjsclass.obj \
|
||||
.\$(OBJDIR)\xpcwrappednative.obj \
|
||||
|
@ -143,7 +143,7 @@ nsXPConnect::IsISupportsDescendent(nsIInterfaceInfo* info)
|
||||
if(NS_SUCCEEDED(oldest->GetIID(&iid)))
|
||||
{
|
||||
retval = iid->Equals(nsISupports::GetIID());
|
||||
XPCMem::Free(iid);
|
||||
nsAllocator::Free(iid);
|
||||
}
|
||||
NS_RELEASE(oldest);
|
||||
return retval;
|
||||
|
@ -191,7 +191,7 @@ ClassesScriptable::ClassesScriptable()
|
||||
|
||||
ClassesScriptable::~ClassesScriptable() {}
|
||||
|
||||
static NS_DEFINE_IID(kClassesScriptableIID, NS_IXPCCLASSES_IID);
|
||||
static NS_DEFINE_IID(kClassesScriptableIID, NS_IXPCSCRIPTABLE_IID);
|
||||
NS_IMPL_ISUPPORTS(ClassesScriptable, kClassesScriptableIID);
|
||||
|
||||
XPC_IMPLEMENT_FORWARD_CREATE(ClassesScriptable);
|
||||
@ -312,9 +312,66 @@ NS_IMPL_RELEASE(nsXPCClasses)
|
||||
NS_IMPL_QUERY_INTERFACE_SCRIPTABLE(nsXPCClasses, mScriptable)
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
class ComponentsScriptable : public nsIXPCScriptable
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
XPC_DECLARE_IXPCSCRIPTABLE
|
||||
ComponentsScriptable();
|
||||
virtual ~ComponentsScriptable();
|
||||
};
|
||||
|
||||
/**********************************************/
|
||||
|
||||
ComponentsScriptable::ComponentsScriptable()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
ComponentsScriptable::~ComponentsScriptable() {}
|
||||
|
||||
static NS_DEFINE_IID(kComponentsScriptableIID, NS_IXPCSCRIPTABLE_IID);
|
||||
NS_IMPL_ISUPPORTS(ComponentsScriptable, kComponentsScriptableIID)
|
||||
|
||||
XPC_IMPLEMENT_FORWARD_CREATE(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_FORWARD_LOOKUPPROPERTY(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_IGNORE_DEFINEPROPERTY(ComponentsScriptable);
|
||||
// XPC_IMPLEMENT_FORWARD_GETPROPERTY(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_IGNORE_SETPROPERTY(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_FORWARD_GETATTRIBUTES(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_IGNORE_SETATTRIBUTES(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_IGNORE_DELETEPROPERTY(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_FORWARD_DEFAULTVALUE(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_FORWARD_ENUMERATE(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_FORWARD_CHECKACCESS(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_IGNORE_CALL(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_IGNORE_CONSTRUCT(ComponentsScriptable);
|
||||
XPC_IMPLEMENT_FORWARD_FINALIZE(ComponentsScriptable);
|
||||
|
||||
NS_IMETHODIMP
|
||||
ComponentsScriptable::GetProperty(JSContext *cx, JSObject *obj,
|
||||
jsid id, jsval *vp,
|
||||
nsIXPConnectWrappedNative* wrapper,
|
||||
nsIXPCScriptable* arbitrary,
|
||||
JSBool* retval)
|
||||
{
|
||||
*retval = JS_TRUE;
|
||||
|
||||
XPCContext* xpcc = nsXPConnect::GetContext(cx);
|
||||
if(xpcc && xpcc->GetLastResultStrID() == id)
|
||||
{
|
||||
if(JS_NewDoubleValue(cx, (jsdouble) (PRInt32)xpcc->GetLastResult(), vp))
|
||||
return NS_OK;
|
||||
}
|
||||
*vp = JSVAL_VOID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
static NS_DEFINE_IID(kComponentsIID, NS_IXPCCOMPONENTS_IID);
|
||||
NS_IMPL_QUERY_INTERFACE(nsXPCComponents, kComponentsIID)
|
||||
NS_IMPL_QUERY_INTERFACE_SCRIPTABLE(nsXPCComponents, mScriptable)
|
||||
NS_IMPL_ADDREF(nsXPCComponents)
|
||||
NS_IMPL_RELEASE(nsXPCComponents)
|
||||
|
||||
@ -324,6 +381,7 @@ nsXPCComponents::nsXPCComponents()
|
||||
NS_ADDREF_THIS();
|
||||
mInterfaces = new nsXPCInterfaces();
|
||||
mClasses = new nsXPCClasses();
|
||||
mScriptable = new ComponentsScriptable();
|
||||
}
|
||||
|
||||
nsXPCComponents::~nsXPCComponents()
|
||||
@ -332,6 +390,8 @@ nsXPCComponents::~nsXPCComponents()
|
||||
NS_RELEASE(mInterfaces);
|
||||
if(mClasses)
|
||||
NS_RELEASE(mClasses);
|
||||
if(mScriptable)
|
||||
NS_RELEASE(mScriptable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -79,6 +79,10 @@ XPCContext::XPCContext(JSContext* aJSContext,
|
||||
JS_ValueToId(aJSContext,
|
||||
STRING_TO_JSVAL(JS_InternString(aJSContext, "toString")),
|
||||
&mToStringStrID);
|
||||
JS_ValueToId(aJSContext,
|
||||
STRING_TO_JSVAL(JS_InternString(aJSContext, "lastResult")),
|
||||
&mLastResultStrID);
|
||||
mLastResult = NS_OK;
|
||||
}
|
||||
|
||||
XPCContext::~XPCContext()
|
||||
|
@ -453,7 +453,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
|
||||
if(useAllocator)
|
||||
{
|
||||
int len = strlen(bytes)+1;
|
||||
if(!(*((void**)d) = XPCMem::Alloc(len)))
|
||||
if(!(*((void**)d) = nsAllocator::Alloc(len)))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -478,7 +478,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
|
||||
if(useAllocator)
|
||||
{
|
||||
int byte_len = (JS_GetStringLength(str)+1)*sizeof(jschar);
|
||||
if(!(*((void**)d) = XPCMem::Alloc(byte_len)))
|
||||
if(!(*((void**)d) = nsAllocator::Alloc(byte_len)))
|
||||
{
|
||||
// XXX should report error
|
||||
return JS_FALSE;
|
||||
|
@ -122,7 +122,7 @@ nsJSIID::GetName(char * *aName)
|
||||
if(NS_SUCCEEDED(iim->GetNameForIID(&mID, &name)) && name)
|
||||
{
|
||||
setName(name);
|
||||
XPCMem::Free(name);
|
||||
nsAllocator::Free(name);
|
||||
}
|
||||
NS_RELEASE(iim);
|
||||
}
|
||||
@ -130,7 +130,7 @@ nsJSIID::GetName(char * *aName)
|
||||
mName = gNoString;
|
||||
}
|
||||
|
||||
*aName = (char*) XPCMem::Clone(mName, strlen(mName)+1);
|
||||
*aName = (char*) nsAllocator::Clone(mName, strlen(mName)+1);
|
||||
return *aName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ nsJSIID::GetNumber(char * *aNumber)
|
||||
mNumber = gNoString;
|
||||
}
|
||||
|
||||
*aNumber = (char*) XPCMem::Clone(mNumber, strlen(mNumber)+1);
|
||||
*aNumber = (char*) nsAllocator::Clone(mNumber, strlen(mNumber)+1);
|
||||
return *aNumber ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ nsJSIID::GetNumber(char * *aNumber)
|
||||
NS_IMETHODIMP
|
||||
nsJSIID::GetId(nsID* *aId)
|
||||
{
|
||||
*aId = (nsID*) XPCMem::Clone(&mID, sizeof(nsID));
|
||||
*aId = (nsID*) nsAllocator::Clone(&mID, sizeof(nsID));
|
||||
return *aId ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ nsJSIID::equals(nsIJSID *other, PRBool *_retval)
|
||||
if(NS_SUCCEEDED(other->GetId(&otherID)))
|
||||
{
|
||||
*_retval = mID.Equals(*otherID);
|
||||
XPCMem::Free(otherID);
|
||||
nsAllocator::Free(otherID);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -214,7 +214,7 @@ nsJSIID::init(const char *idString, PRBool *_retval)
|
||||
mID = *pid;
|
||||
setName(idString);
|
||||
success = PR_TRUE;
|
||||
XPCMem::Free(pid);
|
||||
nsAllocator::Free(pid);
|
||||
}
|
||||
NS_RELEASE(iim);
|
||||
}
|
||||
@ -313,7 +313,7 @@ nsJSCID::GetName(char * *aName)
|
||||
{
|
||||
if(!mName)
|
||||
mName = gNoString;
|
||||
*aName = (char*) XPCMem::Clone(mName, strlen(mName)+1);
|
||||
*aName = (char*) nsAllocator::Clone(mName, strlen(mName)+1);
|
||||
return *aName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ nsJSCID::GetNumber(char * *aNumber)
|
||||
mNumber = gNoString;
|
||||
}
|
||||
|
||||
*aNumber = (char*) XPCMem::Clone(mNumber, strlen(mNumber)+1);
|
||||
*aNumber = (char*) nsAllocator::Clone(mNumber, strlen(mNumber)+1);
|
||||
return *aNumber ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ nsJSCID::GetNumber(char * *aNumber)
|
||||
NS_IMETHODIMP
|
||||
nsJSCID::GetId(nsID* *aId)
|
||||
{
|
||||
*aId = (nsID*) XPCMem::Clone(&mID, sizeof(nsID));
|
||||
*aId = (nsID*) nsAllocator::Clone(&mID, sizeof(nsID));
|
||||
return *aId ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ nsJSCID::equals(nsIJSID *other, PRBool *_retval)
|
||||
if(NS_SUCCEEDED(other->GetId(&otherID)))
|
||||
{
|
||||
*_retval = mID.Equals(*otherID);
|
||||
XPCMem::Free(otherID);
|
||||
nsAllocator::Free(otherID);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -134,6 +134,10 @@ public:
|
||||
|
||||
jsid GetConstructorStrID() const {return mConstuctorStrID;}
|
||||
jsid GetToStringStrID() const {return mToStringStrID;}
|
||||
jsid GetLastResultStrID() const {return mLastResultStrID;}
|
||||
|
||||
nsresult GetLastResult() {return mLastResult;}
|
||||
void SetLastResult(nsresult rc) {mLastResult = rc;}
|
||||
|
||||
JSBool Init(JSObject* aGlobalObj = NULL);
|
||||
void DebugDump(int depth);
|
||||
@ -157,6 +161,8 @@ private:
|
||||
IID2WrappedNativeClassMap* mWrappedNativeClassMap;
|
||||
jsid mConstuctorStrID;
|
||||
jsid mToStringStrID;
|
||||
jsid mLastResultStrID;
|
||||
nsresult mLastResult;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
@ -594,23 +600,6 @@ private:
|
||||
XPCConvert(); // not implemented
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
// allocator access methods
|
||||
|
||||
// class here just for static methods
|
||||
class XPCMem
|
||||
{
|
||||
public:
|
||||
static void* Alloc(PRUint32 size);
|
||||
static void* Realloc(void* ptr, PRUint32 size);
|
||||
static void Free(void* ptr);
|
||||
static void HeapMinimize();
|
||||
static void* Clone(const void* ptr, PRUint32 size);
|
||||
private:
|
||||
XPCMem(); // not implemented
|
||||
static nsIAllocator* Allocator();
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
// nsJSIID
|
||||
|
||||
@ -713,6 +702,7 @@ xpc_JSObjectToID(JSContext *cx, JSObject* obj);
|
||||
|
||||
class nsXPCInterfaces;
|
||||
class nsXPCClasses;
|
||||
class ComponentsScriptable;
|
||||
|
||||
class nsXPCComponents : public nsIXPCComponents
|
||||
{
|
||||
@ -730,6 +720,7 @@ public:
|
||||
private:
|
||||
nsXPCInterfaces* mInterfaces;
|
||||
nsXPCClasses* mClasses;
|
||||
ComponentsScriptable* mScriptable;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -330,7 +330,7 @@ nsXPCWrappedJSMethods::GetIID(nsIID** iid)
|
||||
NS_PRECONDITION(mWrapper, "bad state");
|
||||
NS_PRECONDITION(iid, "bad param");
|
||||
|
||||
*iid = (nsIID*) XPCMem::Clone(&mWrapper->GetIID(), sizeof(nsIID));
|
||||
*iid = (nsIID*) nsAllocator::Clone(&mWrapper->GetIID(), sizeof(nsIID));
|
||||
return *iid ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ nsXPCWrappedJS::DebugDump(int depth)
|
||||
GetClass()->GetInterfaceInfo()->GetName(&name);
|
||||
XPC_LOG_ALWAYS(("interface name is %s", name));
|
||||
if(name)
|
||||
XPCMem::Free(name);
|
||||
nsAllocator::Free(name);
|
||||
char * iid = GetClass()->GetIID().ToString();
|
||||
XPC_LOG_ALWAYS(("IID number is %s", iid));
|
||||
delete iid;
|
||||
|
@ -356,7 +356,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
||||
{
|
||||
if(iidIsOwned)
|
||||
{
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
iidIsOwned = JS_FALSE;
|
||||
}
|
||||
conditional_iid = NULL;
|
||||
@ -412,7 +412,7 @@ pre_call_clean_up:
|
||||
if((NULL != (pp = (void**) params[i].val.p)) && NULL != *pp)
|
||||
{
|
||||
if(param.IsIn())
|
||||
XPCMem::Free(*pp);
|
||||
nsAllocator::Free(*pp);
|
||||
*pp = NULL;
|
||||
}
|
||||
}
|
||||
@ -422,7 +422,7 @@ pre_call_clean_up:
|
||||
{
|
||||
if(iidIsOwned)
|
||||
{
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
iidIsOwned = JS_FALSE;
|
||||
}
|
||||
conditional_iid = NULL;
|
||||
@ -497,7 +497,7 @@ pre_call_clean_up:
|
||||
{
|
||||
if(iidIsOwned)
|
||||
{
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
iidIsOwned = JS_FALSE;
|
||||
}
|
||||
conditional_iid = NULL;
|
||||
@ -521,7 +521,7 @@ done:
|
||||
delete [] argv;
|
||||
|
||||
if(conditional_iid && iidIsOwned)
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -562,7 +562,7 @@ nsXPCWrappedJSClass::DebugDump(int depth)
|
||||
mInfo->GetName(&name);
|
||||
XPC_LOG_ALWAYS(("interface name is %s", name));
|
||||
if(name)
|
||||
XPCMem::Free(name);
|
||||
nsAllocator::Free(name);
|
||||
char * iid = mIID.ToString();
|
||||
XPC_LOG_ALWAYS(("IID number is %s", iid));
|
||||
delete iid;
|
||||
|
@ -365,7 +365,7 @@ nsXPCWrappedNative::GetIID(nsIID** iid)
|
||||
{
|
||||
NS_PRECONDITION(iid, "bad param");
|
||||
|
||||
*iid = (nsIID*) XPCMem::Clone(&GetIID(), sizeof(nsIID));
|
||||
*iid = (nsIID*) nsAllocator::Clone(&GetIID(), sizeof(nsIID));
|
||||
return *iid ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ nsXPCWrappedNativeClass::~nsXPCWrappedNativeClass()
|
||||
mXPCContext->GetWrappedNativeClassMap()->Remove(this);
|
||||
DestroyMemberDescriptors();
|
||||
if(mName)
|
||||
XPCMem::Free(mName);
|
||||
nsAllocator::Free(mName);
|
||||
NS_RELEASE(mInfo);
|
||||
}
|
||||
|
||||
@ -385,9 +385,15 @@ nsXPCWrappedNativeClass::CallWrappedMethod(JSContext* cx,
|
||||
nsresult invokeResult;
|
||||
nsID* conditional_iid = NULL;
|
||||
uintN err;
|
||||
XPCContext* xpcc = nsXPConnect::GetContext(cx);
|
||||
|
||||
*vp = JSVAL_NULL;
|
||||
|
||||
if(!xpcc)
|
||||
goto done;
|
||||
|
||||
xpcc->SetLastResult(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// make sure we have what we need
|
||||
|
||||
if(isAttributeSet)
|
||||
@ -514,7 +520,7 @@ nsXPCWrappedNativeClass::CallWrappedMethod(JSContext* cx,
|
||||
}
|
||||
if(conditional_iid)
|
||||
{
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
conditional_iid = NULL;
|
||||
}
|
||||
}
|
||||
@ -522,7 +528,7 @@ nsXPCWrappedNativeClass::CallWrappedMethod(JSContext* cx,
|
||||
// do the invoke
|
||||
invokeResult = XPTC_InvokeByIndex(wrapper->GetNative(), vtblIndex,
|
||||
paramCount, dispatchParams);
|
||||
|
||||
xpcc->SetLastResult(invokeResult);
|
||||
if(NS_FAILED(invokeResult))
|
||||
{
|
||||
ThrowBadResultException(cx, desc, invokeResult);
|
||||
@ -557,8 +563,8 @@ nsXPCWrappedNativeClass::CallWrappedMethod(JSContext* cx,
|
||||
const nsXPTType& type = param.GetType();
|
||||
if(!type.IsPointer() || type.TagPart() != nsXPTType::T_IID ||
|
||||
!(conditional_iid = (nsID*)
|
||||
XPCMem::Clone(dispatchParams[arg_num].val.p,
|
||||
sizeof(nsID))))
|
||||
nsAllocator::Clone(dispatchParams[arg_num].val.p,
|
||||
sizeof(nsID))))
|
||||
{
|
||||
ThrowBadParamException(XPCJSError::CANT_GET_PARAM_IFACE_INFO,
|
||||
cx, desc, i);
|
||||
@ -588,7 +594,7 @@ nsXPCWrappedNativeClass::CallWrappedMethod(JSContext* cx,
|
||||
}
|
||||
if(conditional_iid)
|
||||
{
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
conditional_iid = NULL;
|
||||
}
|
||||
}
|
||||
@ -605,12 +611,12 @@ done:
|
||||
if(!p)
|
||||
continue;
|
||||
if(dp->IsValOwned())
|
||||
XPCMem::Free(p);
|
||||
nsAllocator::Free(p);
|
||||
if(dp->IsValInterface())
|
||||
((nsISupports*)p)->Release();
|
||||
}
|
||||
if(conditional_iid)
|
||||
XPCMem::Free((void*)conditional_iid);
|
||||
nsAllocator::Free((void*)conditional_iid);
|
||||
|
||||
if(dispatchParams && dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
@ -51,9 +51,9 @@ static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
|
||||
|
||||
static void RegAllocator()
|
||||
{
|
||||
nsComponentManager::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL,
|
||||
nsComponentManager::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
@ -68,7 +68,7 @@ MyScriptable::MyScriptable()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kMyScriptableIID, NS_IXPCSCRIPTABLE_IID);
|
||||
NS_IMPL_ISUPPORTS(MyScriptable, kMyScriptableIID);
|
||||
@ -90,10 +90,10 @@ NS_IMPL_ISUPPORTS(MyScriptable, kMyScriptableIID);
|
||||
XPC_IMPLEMENT_FORWARD_FINALIZE(MyScriptable);
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyScriptable::DefaultValue(JSContext *cx, JSObject *obj,
|
||||
JSType type, jsval *vp,
|
||||
nsIXPConnectWrappedNative* wrapper,
|
||||
nsIXPCScriptable* arbitrary,
|
||||
MyScriptable::DefaultValue(JSContext *cx, JSObject *obj,
|
||||
JSType type, jsval *vp,
|
||||
nsIXPConnectWrappedNative* wrapper,
|
||||
nsIXPCScriptable* arbitrary,
|
||||
JSBool* retval)
|
||||
{
|
||||
if(type == JSTYPE_STRING || type == JSTYPE_VOID)
|
||||
@ -103,7 +103,7 @@ MyScriptable::DefaultValue(JSContext *cx, JSObject *obj,
|
||||
return NS_OK;
|
||||
}
|
||||
return arbitrary->DefaultValue(cx, obj, type, vp, wrapper, NULL, retval);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -123,7 +123,7 @@ NS_IMETHODIMP nsTestXPCFoo::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(nsITestXPCFoo::GetIID()) ||
|
||||
if (aIID.Equals(nsITestXPCFoo::GetIID()) ||
|
||||
aIID.Equals(nsITestXPCFoo2::GetIID()) ||
|
||||
aIID.Equals(nsISupports::GetIID())) {
|
||||
*aInstancePtr = (void*) this;
|
||||
@ -169,7 +169,7 @@ public:
|
||||
NS_IMETHOD SetReceiver(nsIEcho* aReceiver);
|
||||
NS_IMETHOD SendOneString(const char* str);
|
||||
NS_IMETHOD In2OutOneInt(int input, int* output);
|
||||
NS_IMETHOD In2OutAddTwoInts(int input1,
|
||||
NS_IMETHOD In2OutAddTwoInts(int input1,
|
||||
int input2,
|
||||
int* output1,
|
||||
int* output2,
|
||||
@ -217,8 +217,25 @@ public:
|
||||
/* void SharedTest ([shared, retval] out string str); */
|
||||
NS_IMETHOD SharedString(char **str);
|
||||
|
||||
/* void ReturnCode_NS_OK (); */
|
||||
NS_IMETHOD ReturnCode_NS_OK();
|
||||
|
||||
/* void ReturnCode_NS_COMFALSE (); */
|
||||
NS_IMETHOD ReturnCode_NS_COMFALSE();
|
||||
|
||||
/* void ReturnCode_NS_ERROR_NULL_POINTER (); */
|
||||
NS_IMETHOD ReturnCode_NS_ERROR_NULL_POINTER();
|
||||
|
||||
/* void ReturnCode_NS_ERROR_UNEXPECTED (); */
|
||||
NS_IMETHOD ReturnCode_NS_ERROR_UNEXPECTED();
|
||||
|
||||
/* void ReturnCode_NS_ERROR_OUT_OF_MEMORY (); */
|
||||
NS_IMETHOD ReturnCode_NS_ERROR_OUT_OF_MEMORY();
|
||||
|
||||
|
||||
|
||||
MyEcho();
|
||||
private:
|
||||
private:
|
||||
nsIEcho* mReceiver;
|
||||
nsIAllocator* mAllocator;
|
||||
};
|
||||
@ -226,7 +243,7 @@ private:
|
||||
static NS_DEFINE_IID(kMyEchoIID, NS_IECHO_IID);
|
||||
NS_IMPL_ISUPPORTS(MyEcho, kMyEchoIID);
|
||||
|
||||
MyEcho::MyEcho()
|
||||
MyEcho::MyEcho()
|
||||
: mReceiver(NULL)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@ -257,9 +274,9 @@ NS_IMETHODIMP MyEcho::In2OutOneInt(int input, int* output)
|
||||
{
|
||||
*output = input;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MyEcho::In2OutAddTwoInts(int input1,
|
||||
NS_IMETHODIMP MyEcho::In2OutAddTwoInts(int input1,
|
||||
int input2,
|
||||
int* output1,
|
||||
int* output2,
|
||||
@ -285,14 +302,14 @@ NS_IMETHODIMP MyEcho::In2OutOneString(const char* input, char** output)
|
||||
if(output)
|
||||
*output = NULL;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MyEcho::SimpleCallNoEcho()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
MyEcho::SendManyTypes(PRUint8 p1,
|
||||
PRInt16 p2,
|
||||
PRInt32 p3,
|
||||
@ -314,9 +331,9 @@ MyEcho::SendManyTypes(PRUint8 p1,
|
||||
return mReceiver->SendManyTypes(p1, p2, p3, p4, p5, p6, p7, p8, p9,
|
||||
p10, p11, p12, p13, p14, p15, p16);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
MyEcho::SendInOutManyTypes(PRUint8* p1,
|
||||
PRInt16* p2,
|
||||
PRInt32* p3,
|
||||
@ -340,31 +357,31 @@ MyEcho::SendInOutManyTypes(PRUint8* p1,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
MyEcho::MethodWithNative(int p1, void* p2)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode(int code)
|
||||
{
|
||||
return (nsresult) code;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode(int code)
|
||||
{
|
||||
return (nsresult) code;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::FailInJSTest(int fail)
|
||||
{
|
||||
if(mReceiver)
|
||||
return mReceiver->FailInJSTest(fail);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
MyEcho::SharedString(char **str)
|
||||
{
|
||||
*str = "a static string";
|
||||
/*
|
||||
/*
|
||||
// to do non-shared we clone the string:
|
||||
char buf[] = "a static string";
|
||||
int len;
|
||||
@ -372,7 +389,27 @@ MyEcho::SharedString(char **str)
|
||||
memcpy(*str, buf, len);
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode_NS_OK()
|
||||
{return NS_OK;}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode_NS_COMFALSE()
|
||||
{return NS_COMFALSE;}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode_NS_ERROR_NULL_POINTER()
|
||||
{return NS_ERROR_NULL_POINTER;}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode_NS_ERROR_UNEXPECTED()
|
||||
{return NS_ERROR_UNEXPECTED;}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::ReturnCode_NS_ERROR_OUT_OF_MEMORY()
|
||||
{return NS_ERROR_OUT_OF_MEMORY;}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -494,7 +531,7 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
nsIXPConnectWrappedNative* comp_wrapper;
|
||||
if(NS_FAILED(xpc->WrapNative(jscontext, comp,
|
||||
if(NS_FAILED(xpc->WrapNative(jscontext, comp,
|
||||
nsIXPCComponents::GetIID(), &comp_wrapper)))
|
||||
{
|
||||
printf("failed to build wrapper for Components native object");
|
||||
@ -546,7 +583,7 @@ int main()
|
||||
wrapper->GetJSObject(&glob);
|
||||
JS_DefineFunctions(jscontext, glob, glob_functions);
|
||||
|
||||
|
||||
|
||||
nsIXPCComponents* comp = XPC_GetXPConnectComponentsObject();
|
||||
if(!comp)
|
||||
{
|
||||
@ -554,7 +591,7 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
nsIXPConnectWrappedNative* comp_wrapper;
|
||||
if(NS_FAILED(xpc->WrapNative(jscontext, comp,
|
||||
if(NS_FAILED(xpc->WrapNative(jscontext, comp,
|
||||
nsIXPCComponents::GetIID(), &comp_wrapper)))
|
||||
{
|
||||
printf("failed to build wrapper for Components native object");
|
||||
@ -615,14 +652,14 @@ int main()
|
||||
JSObject* test_js_obj;
|
||||
ptr->Test(11, 13, &result);
|
||||
printf("call to ptr->Test returned %d\n", result);
|
||||
|
||||
|
||||
nsIXPConnectWrappedJSMethods* methods;
|
||||
|
||||
wrapper3->QueryInterface(nsIXPConnectWrappedJSMethods::GetIID(),
|
||||
wrapper3->QueryInterface(nsIXPConnectWrappedJSMethods::GetIID(),
|
||||
(void**) &methods);
|
||||
methods->GetJSObject(&test_js_obj);
|
||||
|
||||
printf("call to methods->GetJSObject() returned: %s\n",
|
||||
printf("call to methods->GetJSObject() returned: %s\n",
|
||||
test_js_obj == JSVAL_TO_OBJECT(v) ?
|
||||
"expected result" : "WRONG RESULT" );
|
||||
|
||||
|
@ -6,7 +6,7 @@ function nsID(str)
|
||||
id = id.QueryInterface(Components.interfaces.nsIJSIID);
|
||||
id.init(str);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
var NS_ISUPPORTS_IID = new nsID("{00000000-0000-0000-c000-000000000046}");
|
||||
var NS_ITESTXPC_FOO_IID = new nsID("{159E36D0-991E-11d2-AC3F-00C09300144B}");
|
||||
@ -17,9 +17,9 @@ print("baz = "+baz);
|
||||
print("distinct wrapper test "+ (foo != baz ? "passed" : "failed"));
|
||||
var baz2 = foo.QueryInterface(NS_ITESTXPC_FOO_IID);
|
||||
print("shared wrapper test "+ (baz == baz2 ? "passed" : "failed"));
|
||||
print("root wrapper identity test "+
|
||||
(foo.QueryInterface(NS_ISUPPORTS_IID) ==
|
||||
baz.QueryInterface(NS_ISUPPORTS_IID) ?
|
||||
print("root wrapper identity test "+
|
||||
(foo.QueryInterface(NS_ISUPPORTS_IID) ==
|
||||
baz.QueryInterface(NS_ISUPPORTS_IID) ?
|
||||
"passed" : "failed"));
|
||||
|
||||
print("foo = "+foo);
|
||||
@ -44,7 +44,7 @@ function _Test(p1, p2)
|
||||
|
||||
function _QI(iid)
|
||||
{
|
||||
print("QueryInterface called in JS with iid = "+iid);
|
||||
print("QueryInterface called in JS with iid = "+iid);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -58,6 +58,12 @@ print("foo properties:");
|
||||
for(i in foo)
|
||||
print(" foo."+i+" = "+foo[i]);
|
||||
|
||||
print("Components = "+Components);
|
||||
print("Components properties:");
|
||||
for(i in Components)
|
||||
print(" Components."+i+" = "+Components[i]);
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
print(".......................................");
|
||||
print("echo tests...");
|
||||
@ -65,7 +71,7 @@ print("echo tests...");
|
||||
var receiver = new Object();
|
||||
receiver.SetReceiver = function() {};
|
||||
receiver.SendOneString = function(str) {receiver_results[0] = str;};
|
||||
receiver.SendManyTypes = function()
|
||||
receiver.SendManyTypes = function()
|
||||
{
|
||||
for(var i = 0; i < arguments.length; i++)
|
||||
receiver_results[i] = arguments[i];
|
||||
@ -95,18 +101,18 @@ print("In2OutOneInt - "+(
|
||||
|
||||
var in_out_results1 = new Object();
|
||||
var in_out_results2 = new Object();
|
||||
var in_out_results =
|
||||
var in_out_results =
|
||||
echo.In2OutAddTwoInts(123, 55, in_out_results1, in_out_results2);
|
||||
print("In2OutAddTwoInts - "+(
|
||||
in_out_results1.value == 123 &&
|
||||
in_out_results2.value == 55 &&
|
||||
in_out_results == 178
|
||||
in_out_results == 178
|
||||
? "passed" : "failed"));
|
||||
|
||||
var test_string2 = "some other string";
|
||||
print("In2OutOneString - "+(
|
||||
echo.In2OutOneString(test_string2) == test_string2 &&
|
||||
echo.In2OutOneString(echo.In2OutOneString(test_string2)) == test_string2
|
||||
echo.In2OutOneString(echo.In2OutOneString(test_string2)) == test_string2
|
||||
? "passed" : "failed"));
|
||||
|
||||
|
||||
@ -116,25 +122,25 @@ print("In2OutOneString - "+(
|
||||
var receiver_results = new Object();
|
||||
var send_params = [1,-2,-3,-102020,2,4,6,1023,1.5,2.000008,true,'a','b',NS_ITESTXPC_FOO_IID,"a string","another string"];
|
||||
echo.SendManyTypes(send_params[0],
|
||||
send_params[1],
|
||||
send_params[2],
|
||||
send_params[3],
|
||||
send_params[4],
|
||||
send_params[5],
|
||||
send_params[6],
|
||||
send_params[7],
|
||||
send_params[8],
|
||||
send_params[9],
|
||||
send_params[10],
|
||||
send_params[11],
|
||||
send_params[12],
|
||||
send_params[13],
|
||||
send_params[14],
|
||||
send_params[1],
|
||||
send_params[2],
|
||||
send_params[3],
|
||||
send_params[4],
|
||||
send_params[5],
|
||||
send_params[6],
|
||||
send_params[7],
|
||||
send_params[8],
|
||||
send_params[9],
|
||||
send_params[10],
|
||||
send_params[11],
|
||||
send_params[12],
|
||||
send_params[13],
|
||||
send_params[14],
|
||||
send_params[15]);
|
||||
|
||||
var all_ok = true;
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(((""+receiver_results[i]).toLowerCase()) !=
|
||||
if(((""+receiver_results[i]).toLowerCase()) !=
|
||||
((""+send_params[i]).toLowerCase())) {
|
||||
if(all_ok)
|
||||
print("SendManyTypes - failed...");
|
||||
@ -152,7 +158,7 @@ var receiver_results = new Object();
|
||||
var send_params = [1,-2,-3,-102020,2,4,6,1023,1.5,2.000008,true,'a','b',NS_ITESTXPC_FOO_IID,"a string","another string"];
|
||||
var resend_params = [2,-3,-7,-10220,18,14,16,123,2.5,8.000008,false,'z','l',NS_ISUPPORTS_IID,"foo string","yet another string"];
|
||||
|
||||
receiver.SendInOutManyTypes = function()
|
||||
receiver.SendInOutManyTypes = function()
|
||||
{
|
||||
for(var i = 0; i < arguments.length; i++) {
|
||||
receiver_results[i] = arguments[i].value;
|
||||
@ -178,25 +184,25 @@ var inout_params = [{value:send_params[0] },
|
||||
{value:send_params[15]}];
|
||||
|
||||
echo.SendInOutManyTypes(inout_params[0] ,
|
||||
inout_params[1] ,
|
||||
inout_params[2] ,
|
||||
inout_params[3] ,
|
||||
inout_params[4] ,
|
||||
inout_params[5] ,
|
||||
inout_params[6] ,
|
||||
inout_params[7] ,
|
||||
inout_params[8] ,
|
||||
inout_params[9] ,
|
||||
inout_params[10],
|
||||
inout_params[11],
|
||||
inout_params[12],
|
||||
inout_params[13],
|
||||
inout_params[14],
|
||||
inout_params[1] ,
|
||||
inout_params[2] ,
|
||||
inout_params[3] ,
|
||||
inout_params[4] ,
|
||||
inout_params[5] ,
|
||||
inout_params[6] ,
|
||||
inout_params[7] ,
|
||||
inout_params[8] ,
|
||||
inout_params[9] ,
|
||||
inout_params[10],
|
||||
inout_params[11],
|
||||
inout_params[12],
|
||||
inout_params[13],
|
||||
inout_params[14],
|
||||
inout_params[15]);
|
||||
|
||||
var all_ok = true;
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(((""+receiver_results[i]).toLowerCase()) !=
|
||||
if(((""+receiver_results[i]).toLowerCase()) !=
|
||||
((""+send_params[i]).toLowerCase())) {
|
||||
if(all_ok)
|
||||
print("SendInOutManyTypes - failed...");
|
||||
@ -206,7 +212,7 @@ for(i = 0; i < 16; i++) {
|
||||
}
|
||||
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(((""+resend_params[i]).toLowerCase()) !=
|
||||
if(((""+resend_params[i]).toLowerCase()) !=
|
||||
((""+inout_params[i].value).toLowerCase())) {
|
||||
if(all_ok)
|
||||
print("SendInOutManyTypes - failed...");
|
||||
@ -227,7 +233,7 @@ try {
|
||||
}
|
||||
catch(e) {
|
||||
print("ReturnCode(0) exception text: "+e+" - failed");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
echo.ReturnCode(-1);
|
||||
@ -236,7 +242,54 @@ try {
|
||||
catch(e) {
|
||||
// print("ReturnCode(-1) exception text: "+e+" - passed");
|
||||
print("ReturnCode(-1) - passed");
|
||||
}
|
||||
}
|
||||
|
||||
var all_ok = true;
|
||||
|
||||
echo.ReturnCode_NS_OK()
|
||||
if(Components.RESULT_NS_OK != Components.lastResult) {
|
||||
all_ok = false;
|
||||
print("expected: RESULT_NS_OK = "+Components.RESULT_NS_OK+" got: "+Components.lastResult);
|
||||
print(Components.lastResult);
|
||||
}
|
||||
|
||||
echo.ReturnCode_NS_COMFALSE()
|
||||
if(Components.RESULT_NS_COMFALSE != Components.lastResult) {
|
||||
all_ok = false;
|
||||
print("expected: RESULT_NS_COMFALSE = "+Components.RESULT_NS_COMFALSE+" got: "+Components.lastResult);
|
||||
}
|
||||
|
||||
try {
|
||||
echo.ReturnCode_NS_ERROR_NULL_POINTER()
|
||||
all_ok = false;
|
||||
} catch(e) {
|
||||
if(Components.RESULT_NS_ERROR_NULL_POINTER != Components.lastResult) {
|
||||
all_ok = false;
|
||||
print("expected: RESULT_NS_ERROR_NULL_POINTER = "+Components.RESULT_NS_ERROR_NULL_POINTER+" got: "+Components.lastResult);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
echo.ReturnCode_NS_ERROR_UNEXPECTED()
|
||||
all_ok = false;
|
||||
} catch(e) {
|
||||
if(Components.RESULT_NS_ERROR_UNEXPECTED != Components.lastResult) {
|
||||
all_ok = false;
|
||||
print("expected: RESULT_NS_ERROR_UNEXPECTED = "+Components.RESULT_NS_ERROR_UNEXPECTED+" got: "+Components.lastResult);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
echo.ReturnCode_NS_ERROR_OUT_OF_MEMORY()
|
||||
all_ok = false;
|
||||
} catch(e) {
|
||||
if(Components.RESULT_NS_ERROR_OUT_OF_MEMORY != Components.lastResult) {
|
||||
all_ok = false;
|
||||
print("expected: RESULT_NS_ERROR_OUT_OF_MEMORY = "+Components.RESULT_NS_ERROR_OUT_OF_MEMORY+" got: "+Components.lastResult);
|
||||
}
|
||||
}
|
||||
|
||||
print("Components.lastResult test - "+ (all_ok ? "passed" : "failed") );
|
||||
|
||||
////////////////////
|
||||
// check exceptions on too few args
|
||||
@ -248,7 +301,7 @@ try {
|
||||
catch(e) {
|
||||
// print("Too few args test -- exception text: "+e+" - passed");
|
||||
print("Too few args test - passed");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// check exceptions on can't convert
|
||||
@ -263,7 +316,7 @@ try {
|
||||
catch(e) {
|
||||
// print("Can't convert arg to Native ("+e+") - passed");
|
||||
print("Can't convert arg to Native - passed");
|
||||
}
|
||||
}
|
||||
*/
|
||||
////////////////////
|
||||
// FailInJSTest
|
||||
@ -316,19 +369,19 @@ function idTest(name, iid, same)
|
||||
nameNormalized = name.toLowerCase();
|
||||
iidNormalized = iid.toLowerCase();
|
||||
|
||||
idFromName_NameNormalized = idFromName.name ?
|
||||
idFromName_NameNormalized = idFromName.name ?
|
||||
idFromName.name.toLowerCase() :
|
||||
idFromName.name;
|
||||
|
||||
idFromIID_NameNormalized = idFromIID.name ?
|
||||
idFromIID_NameNormalized = idFromIID.name ?
|
||||
idFromIID.name.toLowerCase() :
|
||||
idFromIID.name;
|
||||
|
||||
idFromName_StringNormalized = idFromName.number ?
|
||||
idFromName_StringNormalized = idFromName.number ?
|
||||
idFromName.number.toLowerCase() :
|
||||
idFromName.number;
|
||||
|
||||
idFromIID_StringNormalized = idFromIID.number ?
|
||||
idFromIID_StringNormalized = idFromIID.number ?
|
||||
idFromIID.number.toLowerCase() :
|
||||
idFromIID.number;
|
||||
|
||||
@ -343,15 +396,15 @@ function idTest(name, iid, same)
|
||||
print("iid toString test failed for "+name+" "+iid);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if(!idFromName.equals(new nsID(idFromName)) ||
|
||||
|
||||
if(!idFromName.equals(new nsID(idFromName)) ||
|
||||
!idFromIID.equals(new nsID(idFromIID))) {
|
||||
print("new id from id test failed for "+name+" "+iid);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var all_ok = true;
|
||||
// these 4 should be valid and the same
|
||||
@ -385,11 +438,11 @@ print("[shared] test - "+(all_ok ? "passed" : "failed"));
|
||||
// print("Components.interfaces.nsISupports = "+Components.interfaces.nsISupports);
|
||||
// print("Components.interfaces.nsISupports.name = "+Components.interfaces.nsISupports.name);
|
||||
// print("Components.interfaces.nsISupports.number = "+Components.interfaces.nsISupports.number);
|
||||
//
|
||||
//
|
||||
// print("Components.interfaces.nsIEcho.number = "+Components.interfaces.nsIEcho.number);
|
||||
// print("Components.interfaces['{CD2F2F40-C5D9-11d2-9838-006008962422}'] = "+Components.interfaces['{CD2F2F40-C5D9-11d2-9838-006008962422}']);
|
||||
// print("Components.interfaces['{CD2F2F40-C5D9-11d2-9838-006008962422}'].name = "+Components.interfaces['{CD2F2F40-C5D9-11d2-9838-006008962422}'].name);
|
||||
//
|
||||
//
|
||||
// print("Components.classes = "+Components.classes);
|
||||
// print("Components.classes.nsIID = "+Components.classes.nsIID);
|
||||
// print("Components.classes.nsCID = "+Components.classes.nsCID);
|
||||
|
@ -114,6 +114,21 @@ class nsIEcho : public nsISupports {
|
||||
/* void SharedString ([shared, retval] out string str); */
|
||||
NS_IMETHOD SharedString(char **str) = 0;
|
||||
|
||||
/* void ReturnCode_NS_OK (); */
|
||||
NS_IMETHOD ReturnCode_NS_OK() = 0;
|
||||
|
||||
/* void ReturnCode_NS_COMFALSE (); */
|
||||
NS_IMETHOD ReturnCode_NS_COMFALSE() = 0;
|
||||
|
||||
/* void ReturnCode_NS_ERROR_NULL_POINTER (); */
|
||||
NS_IMETHOD ReturnCode_NS_ERROR_NULL_POINTER() = 0;
|
||||
|
||||
/* void ReturnCode_NS_ERROR_UNEXPECTED (); */
|
||||
NS_IMETHOD ReturnCode_NS_ERROR_UNEXPECTED() = 0;
|
||||
|
||||
/* void ReturnCode_NS_ERROR_OUT_OF_MEMORY (); */
|
||||
NS_IMETHOD ReturnCode_NS_ERROR_OUT_OF_MEMORY() = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIEcho *priv);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user