lots of cleanup

git-svn-id: svn://10.0.0.236/trunk@21418 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jband%netscape.com 1999-02-21 00:20:40 +00:00
parent f4ebc31945
commit 83081501e5
17 changed files with 145 additions and 105 deletions

View File

@ -0,0 +1,37 @@
/* jband - 02/20/99 - TODO and issues list */
**** ISSUES ****
- convert some assertions to LOG warnings
- Ports!
- proto object per class?
- Param gc rooting?
- safe use of jsdoubles?
- Write Docs!
- improve nsID JS class
- add xpcom JS object and util functions
- reflect IID and CID trees.
- ProgIDs? (mixed in with CID tree or separate?)
- errors
- throw exceptions into JS?
- loosen restrictions re. current cx when calling wrappers across cx boundaries
**** ISSUES ****
- Contexts\Runtimes\ScopeChain problems
- Constants fo WrappedJS objects?
- Even for WrappedNatives the constants should (perhaps) be in the
(as yet not created) class proto object rather than props of each object?
This makes then overwritable?
- Ref counting for contexts?
- JSContext and JSRuntime life times and how that impacts XPConnect stuff
- wrappedJS stub stuff can't handle (non-xpcom) natives passed by value -
we need to know the object size to cleanup the stack!
- Listener interface for class and instance create/destroy?

View File

@ -21,11 +21,7 @@
#ifndef nsIInterfaceInfo_h___
#define nsIInterfaceInfo_h___
#ifndef NS_DEFINE_STATIC_IID_ACCESSOR
#define NS_DEFINE_STATIC_IID_ACCESSOR(the_iid) \
public: \
static const nsIID& IID() {static nsIID iid = the_iid; return iid;}
#endif
#include "nsISupports.h"
// forward declaration of non-XPCOM types
class nsXPTMethodInfo;
@ -138,6 +134,7 @@ public:
nsID** p14,
char** p15,
uint16** p16) = 0;
NS_IMETHOD MethodWithNative(int p1, void* p2) = 0;
};
/***************************************************************************/

View File

@ -21,6 +21,8 @@
#ifndef nsIInterfaceInfoManager_h___
#define nsIInterfaceInfoManager_h___
#include "nsIInterfaceInfo.h"
// This should be implemented as a Service
// {8B161900-BE2B-11d2-9831-006008962422}
@ -38,6 +40,7 @@ public:
NS_IMETHOD GetInfoForName(const char* name, nsIInterfaceInfo** info) = 0;
// name <-> IID mapping services
// NOTE: these return IAllocatator alloc'd copies of the data
NS_IMETHOD GetIIDForName(const char* name, nsIID** iid) = 0;
NS_IMETHOD GetNameForIID(const nsIID* iid, char** name) = 0;
@ -46,7 +49,7 @@ public:
};
/***************************************************************************/
// XXX XXX Removed this block and switch XPC_PUBLIC_API to XPT_PUBLIC_API
// XXX XXX Remove this block and switch XPC_PUBLIC_API to XPT_PUBLIC_API
// when this code is moved to libxpt
#include "jsapi.h"
#ifdef EXPORT_XPC_API

View File

@ -21,7 +21,6 @@
#ifndef nsIXPCScriptable_h___
#define nsIXPCScriptable_h___
#include "nsISupports.h"
#include "nsIXPConnect.h"
#include "jsapi.h"

View File

@ -43,13 +43,7 @@
#define XPC_FRIEND_API(t) XPC_PUBLIC_API(t)
#define XPC_FRIEND_DATA(t) XPC_PUBLIC_DATA(t)
#ifndef NS_DEFINE_STATIC_IID_ACCESSOR
#define NS_DEFINE_STATIC_IID_ACCESSOR(the_iid) \
public: \
static const nsIID& IID() {static nsIID iid = the_iid; return iid;}
#endif
// XXX break these up into separate files...
// XXX break these up into separate files?
// XXX declare them in XPIDL :)
/***************************************************************************/
@ -67,15 +61,14 @@ class nsIXPConnectWrappedNative : public nsISupports
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXPCONNECT_WRAPPED_NATIVE_IID)
// XXX add the rest of the fun methods
NS_IMETHOD GetDynamicScriptable(nsIXPCScriptable** p) = 0;
NS_IMETHOD GetArbitraryScriptable(nsIXPCScriptable** p) = 0;
NS_IMETHOD GetJSObject(JSObject** aJSObj) = 0;
NS_IMETHOD GetNative(nsISupports** aObj) = 0;
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info) = 0;
NS_IMETHOD GetIID(nsIID** iid) = 0; // returns IAllocatator alloc'd copy
NS_IMETHOD DebugDump(int depth) = 0;
// XXX other methods?
};
/***************************************************************************/
@ -91,8 +84,9 @@ class nsIXPConnectWrappedJS : public nsISupports
//
// To manipulate this wrapper (as opposed to manipulating the wrapped
// JSObject via this wrapper) do a QueryInterface for the
// nsIXPConnectWrappedJSMethods interface and use the methods on that
// interface. (see below)
// nsIXPConnectWrappedJSMethods interface
// i.e. 'nsIXPConnectWrappedJSMethods::IID()'
// and use the methods on that interface. (see below)
};
/******************************************/
@ -107,11 +101,11 @@ class nsIXPConnectWrappedJSMethods : public nsISupports
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXPCONNECT_WRAPPED_JS_METHODS_IID)
// XXX add the rest of the fun methods
NS_IMETHOD GetJSObject(JSObject** aJSObj) = 0;
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info) = 0;
NS_IMETHOD GetIID(nsIID** iid) = 0; // returns IAllocatator alloc'd copy
NS_IMETHOD DebugDump(int depth) = 0;
// XXX other methods?
};
/***************************************************************************/
@ -133,6 +127,8 @@ public:
REFNSIID aIID,
nsIXPConnectWrappedNative** aWrapper) = 0;
// XXX add 'AbandonJSContext' method and all that implies?
NS_IMETHOD WrapNative(JSContext* aJSContext,
nsISupports* aCOMObj,
REFNSIID aIID,
@ -148,12 +144,11 @@ public:
nsIXPConnectWrappedNative** aWrapper) = 0;
NS_IMETHOD DebugDump(int depth) = 0;
// other stuff...
// XXX other methods?
};
JS_BEGIN_EXTERN_C
// XXX remove this and use ServiceManager instead
// XXX Add support for this to be a service?
XPC_PUBLIC_API(nsIXPConnect*)
XPC_GetXPConnect();

View File

@ -38,9 +38,9 @@ static NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
nsXPConnect*
nsXPConnect::GetXPConnect()
{
if(mSelf)
NS_ADDREF(mSelf);
else
// XXX This pattern causes us to retain an extra ref on the singleton.
// XXX Should the singleton nsXpConnect object *ever* be deleted?
if(!mSelf)
{
mSelf = new nsXPConnect();
if(mSelf && (!mSelf->mContextMap ||
@ -49,6 +49,8 @@ nsXPConnect::GetXPConnect()
!mSelf->mInterfaceInfoManager))
NS_RELEASE(mSelf);
}
if(mSelf)
NS_ADDREF(mSelf);
return mSelf;
}
@ -154,7 +156,7 @@ nsXPConnect::InitJSContext(JSContext* aJSContext,
return NS_OK;
}
}
NS_ASSERTION(0,"nsXPConnect::InitJSContext failed");
XPC_LOG_ERROR(("nsXPConnect::InitJSContext failed"));
return NS_ERROR_FAILURE;
}
@ -187,6 +189,7 @@ nsXPConnect::InitJSContextWithNewWrappedGlobal(JSContext* aJSContext,
mContextMap->Remove(xpcc);
delete xpcc;
}
XPC_LOG_ERROR(("nsXPConnect::InitJSContextWithNewWrappedGlobal failed"));
*aWrapper = NULL;
return NS_ERROR_FAILURE;
}
@ -206,6 +209,7 @@ nsXPConnect::NewContext(JSContext* cx, JSObject* global,
NATIVE_CLASS_MAP_SIZE);
if(doInit && xpcc && !xpcc->Init())
{
XPC_LOG_ERROR(("nsXPConnect::NewContext failed"));
delete xpcc;
xpcc = NULL;
}
@ -224,20 +228,20 @@ nsXPConnect::WrapNative(JSContext* aJSContext,
NS_PRECONDITION(aCOMObj,"bad param");
NS_PRECONDITION(aWrapper,"bad param");
*aWrapper = NULL;
XPCContext* xpcc = nsXPConnect::GetContext(aJSContext, this);
if(!xpcc)
return NS_ERROR_FAILURE;
nsXPCWrappedNative* wrapper =
nsXPCWrappedNative::GetNewOrUsedWrapper(xpcc, aCOMObj, aIID);
if(!wrapper)
return NS_ERROR_FAILURE;
*aWrapper = wrapper;
return NS_OK;
if(xpcc)
{
nsXPCWrappedNative* wrapper =
nsXPCWrappedNative::GetNewOrUsedWrapper(xpcc, aCOMObj, aIID);
if(wrapper)
{
*aWrapper = wrapper;
return NS_OK;
}
}
XPC_LOG_ERROR(("nsXPConnect::WrapNative failed"));
*aWrapper = NULL;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -250,20 +254,21 @@ nsXPConnect::WrapJS(JSContext* aJSContext,
NS_PRECONDITION(aJSObj,"bad param");
NS_PRECONDITION(aWrapper,"bad param");
*aWrapper = NULL;
XPCContext* xpcc = nsXPConnect::GetContext(aJSContext, this);
if(!xpcc)
return NS_ERROR_FAILURE;
nsXPCWrappedJS* wrapper =
nsXPCWrappedJS::GetNewOrUsedWrapper(xpcc, aJSObj, aIID);
if(!wrapper)
return NS_ERROR_FAILURE;
*aWrapper = wrapper;
return NS_OK;
if(xpcc)
{
nsXPCWrappedJS* wrapper =
nsXPCWrappedJS::GetNewOrUsedWrapper(xpcc, aJSObj, aIID);
if(wrapper)
{
*aWrapper = wrapper;
return NS_OK;
}
}
XPC_LOG_ERROR(("nsXPConnect::WrapJS failed"));
*aWrapper = NULL;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -280,6 +285,13 @@ nsXPConnect::GetWrappedNativeOfJSObject(JSContext* aJSContext,
return NS_OK;
}
// has to go somewhere...
nsXPCArbitraryScriptable::nsXPCArbitraryScriptable()
{
NS_INIT_REFCNT();
NS_ADDREF_THIS();
}
#ifdef DEBUG
ContextMapDumpEnumerator(JSHashEntry *he, intN i, void *arg)
{

View File

@ -289,6 +289,8 @@ public:
nsID** p14,
char** p15,
uint16** p16);
NS_IMETHOD MethodWithNative(int p1, void* p2);
MyEcho();
private:
nsIEcho* mReciever;
@ -411,6 +413,11 @@ MyEcho::SendInOutManyTypes(int8* p1,
return NS_OK;
}
NS_IMETHODIMP
MyEcho::MethodWithNative(int p1, void* p2)
{
return NS_OK;
}
/***************************************************************************/

View File

@ -36,7 +36,6 @@ nsXPCArbitraryScriptable::Create(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
return NS_OK;
}
@ -52,7 +51,6 @@ nsXPCArbitraryScriptable::LookupProperty(JSContext *cx, JSObject *obj, jsid id,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.lookupProperty(cx, obj, id, objp, propp
#if defined JS_THREADSAFE && defined DEBUG
, "unknown file", 1
@ -75,7 +73,6 @@ nsXPCArbitraryScriptable::DefineProperty(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.defineProperty(cx, obj, id, value, getter, setter,
attrs, propp);
return NS_OK;
@ -93,7 +90,6 @@ nsXPCArbitraryScriptable::GetProperty(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.getProperty(cx, obj, id, vp);
return NS_OK;
}
@ -110,7 +106,6 @@ nsXPCArbitraryScriptable::SetProperty(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.setProperty(cx, obj, id, vp);
return NS_OK;
}
@ -127,7 +122,6 @@ nsXPCArbitraryScriptable::GetAttributes(JSContext *cx, JSObject *obj, jsid id,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.getAttributes(cx, obj, id, prop, attrsp);
return NS_OK;
}
@ -144,7 +138,6 @@ nsXPCArbitraryScriptable::SetAttributes(JSContext *cx, JSObject *obj, jsid id,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.setAttributes(cx, obj, id, prop, attrsp);
return NS_OK;
}
@ -161,7 +154,6 @@ nsXPCArbitraryScriptable::DeleteProperty(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.deleteProperty(cx, obj, id, vp);
return NS_OK;
}
@ -178,7 +170,6 @@ nsXPCArbitraryScriptable::DefaultValue(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.defaultValue(cx, obj, type, vp);
return NS_OK;
}
@ -196,7 +187,6 @@ nsXPCArbitraryScriptable::Enumerate(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.enumerate(cx, obj, enum_op, statep, idp);
return NS_OK;
}
@ -213,7 +203,6 @@ nsXPCArbitraryScriptable::CheckAccess(JSContext *cx, JSObject *obj, jsid id,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.checkAccess(cx, obj, id, mode, vp, attrsp);
return NS_OK;
}
@ -231,7 +220,6 @@ nsXPCArbitraryScriptable::Call(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.call(cx, obj, argc, argv, rval);
return NS_OK;
}
@ -249,7 +237,6 @@ nsXPCArbitraryScriptable::Construct(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
*retval = js_ObjectOps.construct(cx, obj, argc, argv, rval);
return NS_OK;
}
@ -263,7 +250,6 @@ nsXPCArbitraryScriptable::Finalize(JSContext *cx, JSObject *obj,
NS_PRECONDITION(cx, "bad param");
NS_PRECONDITION(obj, "bad param");
NS_PRECONDITION(obj==REAL_WRAPPER(wrapper)->GetJSObject(), "bad param");
NS_PRECONDITION(cx==REAL_WRAPPER(wrapper)->GetClass()->GetJSContext(), "bad param");
JS_FinalizeStub(cx, obj);
return NS_OK;
}

View File

@ -168,11 +168,6 @@ XPCConvert::IsMethodReflectable(const nsXPTMethodInfo& info)
return JS_TRUE;
}
// XXX these conversion functions need to be finished.
// XXX conversion functions may still need paramInfo to handle the additional
// types
#define JAM_DOUBLE(cx,v,d) (d=JS_NewDouble(cx,(jsdouble)v),DOUBLE_TO_JSVAL(d))
#define FIT_32(cx,i,d) (INT_FITS_IN_JSVAL(i)?INT_TO_JSVAL(i):JAM_DOUBLE(cx,i,d))
// Win32 can't handle uint64 to double conversion
@ -226,7 +221,7 @@ XPCConvert::NativeData2JS(JSContext* cx, jsval* d, const void* s,
default:
if(!type.IsPointer())
{
NS_ASSERTION(0,"unsupported type");
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : unsupported type"));
return JS_FALSE;
}
@ -237,7 +232,7 @@ XPCConvert::NativeData2JS(JSContext* cx, jsval* d, const void* s,
{
case nsXPTType::T_VOID:
// XXX implement void* ?
NS_ASSERTION(0,"void* params not supported");
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : void* params not supported"));
return JS_FALSE;
case nsXPTType::T_IID:
@ -254,7 +249,7 @@ XPCConvert::NativeData2JS(JSContext* cx, jsval* d, const void* s,
case nsXPTType::T_BSTR:
// XXX implement BSTR ?
NS_ASSERTION(0,"'BSTR' string params not supported");
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : BSTR params not supported"));
return JS_FALSE;
case nsXPTType::T_CHAR_STR:
@ -438,6 +433,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
{
case nsXPTType::T_VOID:
// XXX implement void* ?
XPC_LOG_ERROR(("XPCConvert::JSData2Native : void* params not supported"));
NS_ASSERTION(0,"void* params not supported");
return JS_FALSE;
case nsXPTType::T_IID:
@ -468,7 +464,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
case nsXPTType::T_BSTR:
// XXX implement BSTR
NS_ASSERTION(0,"'BSTR' string params not supported");
XPC_LOG_ERROR(("XPCConvert::JSData2Native : BSTR params not supported"));
return JS_FALSE;
case nsXPTType::T_CHAR_STR:

View File

@ -33,12 +33,11 @@
* SET NSPR_LOG_MODULES=xpclog:5
* SET NSPR_LOG_FILE=logfile.txt
*
* use:
* usage:
* XPC_LOG_ERROR(("my comment number %d", 5)) // note the double parens
*
*/
#ifdef DEBUG
#define XPC_LOG_INTERNAL(number,_args) \
do{if(XPC_Log_Check(number)){XPC_Log_print _args;}}while(0)
@ -68,7 +67,6 @@ JS_END_EXTERN_C
#define XPC_LOG_ERROR(_args) ((void)0)
#define XPC_LOG_WARNING(_args) ((void)0)
#define XPC_LOG_DEBUG(_args) ((void)0)
#define XPC_LOG(_args) ((void)0)
#define XPC_LOG_FLUSH() ((void)0)
#define XPC_LOG_INDENT() ((void)0)
#define XPC_LOG_OUTDENT() ((void)0)

View File

@ -166,8 +166,8 @@ public:
static nsXPCWrappedJSClass* GetNewOrUsedClass(XPCContext* xpcc,
REFNSIID aIID);
REFNSIID GetIID(){return mIID;}
XPCContext* GetXPCContext() {return mXPCContext;}
REFNSIID GetIID() const {return mIID;}
XPCContext* GetXPCContext() const {return mXPCContext;}
nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo;}
static JSBool InitForContext(XPCContext* xpcc);
@ -188,7 +188,7 @@ private:
nsXPCWrappedJSClass(XPCContext* xpcc, REFNSIID aIID,
nsIInterfaceInfo* aInfo);
JSContext* GetJSContext() {return mXPCContext->GetJSContext();}
JSContext* GetJSContext() const {return mXPCContext->GetJSContext();}
JSObject* CreateIIDJSObject(REFNSIID aIID);
JSObject* NewOutObject();
@ -220,10 +220,10 @@ public:
JSObject* aJSObj,
REFNSIID aIID);
JSObject* GetJSObject() {return mJSObj;}
nsXPCWrappedJSClass* GetClass() {return mClass;}
REFNSIID GetIID() {return GetClass()->GetIID();}
nsXPCWrappedJS* GetRootWrapper() {return mRoot;}
JSObject* GetJSObject() const {return mJSObj;}
nsXPCWrappedJSClass* GetClass() const {return mClass;}
REFNSIID GetIID() const {return GetClass()->GetIID();}
nsXPCWrappedJS* GetRootWrapper() const {return mRoot;}
void DebugDump(int depth);
virtual ~nsXPCWrappedJS();
@ -255,7 +255,7 @@ public:
nsXPCWrappedJSMethods(nsXPCWrappedJS* aWrapper);
virtual ~nsXPCWrappedJSMethods();
// used in nsXPCWrappedJS::DebugDump
int GetRefCnt() {return mRefCnt;}
int GetRefCnt() const {return mRefCnt;}
private:
nsXPCWrappedJSMethods(); // not implemented
@ -285,6 +285,9 @@ public:
jsid id; /* hashed name for quick JS property lookup */
uintN index; /* in InterfaceInfo for const, method, and get */
uintN index2; /* in InterfaceInfo for set */
private:
uint16 flags;
public:
JSBool IsConstant() const {return (flags & NMD_CAT_MASK) == NMD_CONSTANT;}
JSBool IsMethod() const {return (flags & NMD_CAT_MASK) == NMD_METHOD;}
@ -298,8 +301,6 @@ public:
void SetWritableAttribute() {flags=(flags&~NMD_CAT_MASK)|NMD_ATTRIB_RW;}
XPCNativeMemberDescriptor();
private:
uint16 flags;
};
/*************************/
@ -331,8 +332,8 @@ public:
const char* GetInterfaceName();
nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo;}
XPCContext* GetXPCContext() const {return mXPCContext;}
JSContext* GetJSContext() {return mXPCContext->GetJSContext();}
nsIXPCScriptable* GetArbitraryScriptable()
JSContext* GetJSContext() const {return mXPCContext->GetJSContext();}
nsIXPCScriptable* GetArbitraryScriptable() const
{return GetXPCContext()->GetXPConnect()->GetArbitraryScriptable();}
static JSBool InitForContext(XPCContext* xpcc);
@ -432,10 +433,10 @@ public:
nsXPCWrappedNativeClass* GetClass() const {return mClass;}
REFNSIID GetIID() const {return GetClass()->GetIID();}
nsIXPCScriptable* GetDynamicScriptable()
nsIXPCScriptable* GetDynamicScriptable() const
{return mRoot->mDynamicScriptable;}
nsIXPCScriptable* GetArbitraryScriptable()
nsIXPCScriptable* GetArbitraryScriptable() const
{return GetClass()->GetArbitraryScriptable();}
void JSObjectFinalized();
@ -466,7 +467,9 @@ public:
// all the interface method declarations...
NS_DECL_ISUPPORTS;
XPC_DECLARE_IXPCSCRIPTABLE;
nsXPCArbitraryScriptable() {NS_INIT_REFCNT();NS_ADDREF_THIS();}
public:
nsXPCArbitraryScriptable();
};
/***************************************************************************/

View File

@ -21,7 +21,6 @@
#ifndef xpcvariant_h___
#define xpcvariant_h___
// this is used only for WrappedJS stub param repackaging
struct nsXPCMiniVariant
{
// No ctors or dtors so that we can use arrays of these on the stack

View File

@ -34,7 +34,10 @@ nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
if(aIID.Equals(nsIXPConnectWrappedJSMethods::IID()))
{
if(!mMethods && !(mMethods = new nsXPCWrappedJSMethods(this)))
{
*aInstancePtr = NULL;
return NS_ERROR_OUT_OF_MEMORY;
}
// intentional second addref
NS_ADDREF(mMethods);
*aInstancePtr = (void*) mMethods;

View File

@ -302,7 +302,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
// build the args
for(i = 0; i < argc; i++)
{
nsID* conditional_iid = NULL;
const nsID* conditional_iid = NULL;
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
jsval val;
@ -421,7 +421,7 @@ pre_call_clean_up:
{
jsval val;
nsIAllocator* conditional_al = NULL;
nsID* conditional_iid = NULL;
const nsID* conditional_iid = NULL;
const nsXPTType& type = param.GetType();
nsXPCMiniVariant* pv;

View File

@ -423,7 +423,7 @@ nsXPCWrappedNativeClass::CallWrappedMethod(nsXPCWrappedNative* wrapper,
for(i = 0; i < paramCount; i++)
{
nsIAllocator* conditional_al = NULL;
nsID* conditional_iid = NULL;
const nsID* conditional_iid = NULL;
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
@ -515,7 +515,7 @@ nsXPCWrappedNativeClass::CallWrappedMethod(nsXPCWrappedNative* wrapper,
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsID* conditional_iid = NULL;
const nsID* conditional_iid = NULL;
nsXPCVariant* dp = &dispatchParams[i];
if(param.IsOut())
@ -1106,7 +1106,6 @@ WrappedNative_Finalize(JSContext *cx, JSObject *obj)
if(!wrapper)
return;
NS_ASSERTION(obj == wrapper->GetJSObject(),"bad obj");
NS_ASSERTION(cx == wrapper->GetClass()->GetXPCContext()->GetJSContext(),"bad obj");
// wrapper is responsible for calling DynamicScriptable->Finalize
wrapper->JSObjectFinalized();
}

View File

@ -206,7 +206,12 @@ XPTParamDescriptor nsIEcho_SendInOutManyTypesParams[16] = {
{XPT_PD_IN|XPT_PD_OUT, {XPT_TDP_POINTER|TD_PWSTRING ,0}}
};
XPTMethodDescriptor nsIEchoMethods[8] = {
XPTParamDescriptor nsIEcho_MethodWithNativeParams[2] = {
{XPT_PD_IN, {TD_INT32,0}},
{XPT_PD_IN, {XPT_TDP_POINTER|TD_VOID,0}}
};
XPTMethodDescriptor nsIEchoMethods[9] = {
{0, "SetReciever", 1, nsIEcho_SetRecieverParams, ResultParam},
{0, "SendOneString", 1, nsIEcho_SendOneStringParams, ResultParam},
{0, "In2OutOneInt", 2, nsIEcho_In2OutOneIntParams, ResultParam},
@ -214,11 +219,12 @@ XPTMethodDescriptor nsIEchoMethods[8] = {
{0, "In2OutOneString", 2, nsIEcho_In2OutOneStringParams, ResultParam},
{0, "SimpleCallNoEcho", 0, NULL, ResultParam},
{0, "SendManyTypes", 16, nsIEcho_SendManyTypesParams, ResultParam},
{0, "SendInOutManyTypes", 16, nsIEcho_SendInOutManyTypesParams, ResultParam}
{0, "SendInOutManyTypes", 16, nsIEcho_SendInOutManyTypesParams, ResultParam},
{0, "MethodWithNative", 2, nsIEcho_MethodWithNativeParams, ResultParam}
};
XPTInterfaceDescriptor nsIEchoInterfaceDescriptor =
{NULL, 8, nsIEchoMethods, 0, NULL};
{NULL, 9, nsIEchoMethods, 0, NULL};
/***************/
@ -268,7 +274,7 @@ nsXPTParamInfo::GetInterface() const
return info;
}
nsIID*
const nsIID*
nsXPTParamInfo::GetInterfaceIID() const
{
NS_PRECONDITION(GetType().TagPart() == nsXPTType::T_INTERFACE,"not an interface");

View File

@ -18,11 +18,11 @@
/* The InterfaceInfo support public stuff. */
#include "xpt_struct.h"
#ifndef xpt_cpp_h___
#define xpt_cpp_h___
#include "xpt_struct.h"
// Everything here is dependent upon - and sensitive to changes in -
// xpcom/libxpt/xpt_struct.h!
@ -118,7 +118,7 @@ public:
nsIInterfaceInfo* GetInterface() const ;
// a *little* simpler than the above
nsIID* GetInterfaceIID() const ;
const nsIID* GetInterfaceIID() const ;
private:
nsXPTParamInfo(); // no implementation