lots of cleanup
This commit is contained in:
Родитель
bc47e3124f
Коммит
6c1d7818fe
|
@ -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?
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* The nsIInterfaceInfoManager xpcom public declaration. */
|
||||
|
||||
#ifndef nsIInterfaceInfoManager_h___
|
||||
#define nsIInterfaceInfoManager_h___
|
||||
|
||||
// This should be implemented as a Service
|
||||
|
||||
// {8B161900-BE2B-11d2-9831-006008962422}
|
||||
#define NS_IINTERFACEINFO_MANAGER_IID \
|
||||
{ 0x8b161900, 0xbe2b, 0x11d2, \
|
||||
{ 0x98, 0x31, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
|
||||
|
||||
class nsIInterfaceInfoManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IINTERFACEINFO_MANAGER_IID)
|
||||
|
||||
// nsIInformationInfo management services
|
||||
NS_IMETHOD GetInfoForIID(const nsIID* iid, nsIInterfaceInfo** info) = 0;
|
||||
NS_IMETHOD GetInfoForName(const char* name, nsIInterfaceInfo** info) = 0;
|
||||
|
||||
// name <-> IID mapping services
|
||||
NS_IMETHOD GetIIDForName(const char* name, nsIID** iid) = 0;
|
||||
NS_IMETHOD GetNameForIID(const nsIID* iid, char** name) = 0;
|
||||
|
||||
// XXX other methods?
|
||||
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
// XXX XXX Removed 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
|
||||
#define XPC_PUBLIC_API(t) JS_EXPORT_API(t)
|
||||
#else
|
||||
#define XPC_PUBLIC_API(t) JS_IMPORT_API(t)
|
||||
#endif
|
||||
/***************************************************************************/
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
// XXX remove this and use ServiceManager instead
|
||||
XPC_PUBLIC_API(nsIInterfaceInfoManager*)
|
||||
XPT_GetInterfaceInfoManager();
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
#endif /* nsIInterfaceInfoManager_h___ */
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef nsIXPCScriptable_h___
|
||||
#define nsIXPCScriptable_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Debug Logging support. */
|
||||
|
||||
#ifndef xpclog_h___
|
||||
#define xpclog_h___
|
||||
|
||||
#include "nsIXPConnect.h"
|
||||
#include "prtypes.h"
|
||||
#include "prlog.h"
|
||||
|
||||
/*
|
||||
* This uses prlog.h See prlog.h for environment settings for output.
|
||||
* The module name used here is 'xpclog'. These environment settings
|
||||
* should work...
|
||||
*
|
||||
* SET NSPR_LOG_MODULES=xpclog:5
|
||||
* SET NSPR_LOG_FILE=logfile.txt
|
||||
*
|
||||
* use:
|
||||
* 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)
|
||||
|
||||
#define XPC_LOG_ALWAYS(_args) XPC_LOG_INTERNAL(1,_args)
|
||||
#define XPC_LOG_ERROR(_args) XPC_LOG_INTERNAL(2,_args)
|
||||
#define XPC_LOG_WARNING(_args) XPC_LOG_INTERNAL(3,_args)
|
||||
#define XPC_LOG_DEBUG(_args) XPC_LOG_INTERNAL(4,_args)
|
||||
#define XPC_LOG_FLUSH() PR_LogFlush()
|
||||
#define XPC_LOG_INDENT() XPC_Log_Indent()
|
||||
#define XPC_LOG_OUTDENT() XPC_Log_Outdent()
|
||||
#define XPC_LOG_CLEAR_INDENT() XPC_Log_Clear_Indent()
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
XPC_PUBLIC_API(void) XPC_Log_print(const char *fmt, ...);
|
||||
XPC_PUBLIC_API(PRBool) XPC_Log_Check(int i);
|
||||
XPC_PUBLIC_API(void) XPC_Log_Indent();
|
||||
XPC_PUBLIC_API(void) XPC_Log_Outdent();
|
||||
XPC_PUBLIC_API(void) XPC_Log_Clear_Indent();
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#else
|
||||
|
||||
#define XPC_LOG_ALWAYS(_args) ((void)0)
|
||||
#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)
|
||||
#define XPC_LOG_CLEAR_INDENT() ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* xpclog_h___ */
|
|
@ -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();
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Variant unions used internally be XPConnect - only include locally. */
|
||||
|
||||
#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
|
||||
// with no penalty.
|
||||
union
|
||||
{
|
||||
int8 i8;
|
||||
int16 i16;
|
||||
int32 i32;
|
||||
int64 i64;
|
||||
uint8 u8;
|
||||
uint16 u16;
|
||||
uint32 u32;
|
||||
uint64 u64;
|
||||
float f;
|
||||
double d;
|
||||
PRBool b;
|
||||
char c;
|
||||
wchar_t wc;
|
||||
void* p;
|
||||
} val;
|
||||
};
|
||||
|
||||
struct nsXPCVariant : public nsXPCMiniVariant
|
||||
{
|
||||
// No ctors or dtors so that we can use arrays of these on the stack
|
||||
// with no penalty.
|
||||
|
||||
// inherits 'val' here
|
||||
void* ptr;
|
||||
nsXPTType type;
|
||||
uint8 flags;
|
||||
|
||||
enum
|
||||
{
|
||||
// these are bitflags!
|
||||
PTR_IS_DATA = 0x1, // ptr points to 'real' data in val
|
||||
VAL_IS_OWNED = 0x2, // val.p holds alloced ptr that must be freed
|
||||
VAL_IS_IFACE = 0x4 // val.p holds interface ptr that must be released
|
||||
};
|
||||
|
||||
JSBool IsPtrData() const {return (JSBool) (flags & PTR_IS_DATA);}
|
||||
JSBool IsValOwned() const {return (JSBool) (flags & VAL_IS_OWNED);}
|
||||
JSBool IsValInterface() const {return (JSBool) (flags & VAL_IS_IFACE);}
|
||||
};
|
||||
|
||||
#endif /* xpcvariant_h___ */
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* The InterfaceInfo support public stuff. */
|
||||
|
||||
#include "xpt_struct.h"
|
||||
|
||||
#ifndef xpt_cpp_h___
|
||||
#define xpt_cpp_h___
|
||||
|
||||
// Everything here is dependent upon - and sensitive to changes in -
|
||||
// xpcom/libxpt/xpt_struct.h!
|
||||
|
||||
class nsXPTType : public XPTTypeDescriptorPrefix
|
||||
{
|
||||
// NO DATA - this a flyweight wrapper
|
||||
public:
|
||||
nsXPTType()
|
||||
{} // random contents
|
||||
nsXPTType(const XPTTypeDescriptorPrefix& prefix)
|
||||
{*(XPTTypeDescriptorPrefix*)this = prefix;}
|
||||
|
||||
nsXPTType(const uint8& prefix)
|
||||
{*(uint8*)this = prefix;}
|
||||
|
||||
nsXPTType& operator=(uint8 val)
|
||||
{flags = val; return *this;}
|
||||
|
||||
operator uint8() const
|
||||
{return flags;}
|
||||
|
||||
JSBool IsPointer() const
|
||||
{return (JSBool) (XPT_TDP_IS_POINTER(flags));}
|
||||
|
||||
JSBool IsUniquePointer() const
|
||||
{return (JSBool) (XPT_TDP_IS_UNIQUE_POINTER(flags));}
|
||||
|
||||
JSBool IsReference() const
|
||||
{return (JSBool) (XPT_TDP_IS_REFERENCE(flags));}
|
||||
|
||||
JSBool IsArithmetic() const // terminology from Harbison/Steele
|
||||
{return flags <= T_WCHAR;}
|
||||
|
||||
JSBool IsInterfacePointer() const
|
||||
{return (JSBool) (TagPart() == T_INTERFACE ||
|
||||
TagPart() == T_INTERFACE_IS);}
|
||||
|
||||
uint8 TagPart() const
|
||||
{return (uint8) (flags & XPT_TDP_TAGMASK);}
|
||||
|
||||
enum
|
||||
{
|
||||
T_I8 = TD_INT8 ,
|
||||
T_I16 = TD_INT16 ,
|
||||
T_I32 = TD_INT32 ,
|
||||
T_I64 = TD_INT64 ,
|
||||
T_U8 = TD_UINT8 ,
|
||||
T_U16 = TD_UINT16 ,
|
||||
T_U32 = TD_UINT32 ,
|
||||
T_U64 = TD_UINT64 ,
|
||||
T_FLOAT = TD_FLOAT ,
|
||||
T_DOUBLE = TD_DOUBLE ,
|
||||
T_BOOL = TD_BOOL ,
|
||||
T_CHAR = TD_CHAR ,
|
||||
T_WCHAR = TD_WCHAR ,
|
||||
T_VOID = TD_VOID ,
|
||||
T_IID = TD_PNSIID ,
|
||||
T_BSTR = TD_PBSTR ,
|
||||
T_CHAR_STR = TD_PSTRING ,
|
||||
T_WCHAR_STR = TD_PWSTRING ,
|
||||
T_INTERFACE = TD_INTERFACE_TYPE ,
|
||||
T_INTERFACE_IS = TD_INTERFACE_IS_TYPE
|
||||
};
|
||||
// NO DATA - this a flyweight wrapper
|
||||
};
|
||||
|
||||
class nsXPTParamInfo : public XPTParamDescriptor
|
||||
{
|
||||
// NO DATA - this a flyweight wrapper
|
||||
public:
|
||||
nsXPTParamInfo(const XPTParamDescriptor& desc)
|
||||
{*(XPTParamDescriptor*)this = desc;}
|
||||
|
||||
|
||||
JSBool IsIn() const {return (JSBool) (XPT_PD_IS_IN(flags));}
|
||||
JSBool IsOut() const {return (JSBool) (XPT_PD_IS_OUT(flags));}
|
||||
JSBool IsRetval() const {return (JSBool) (XPT_PD_IS_RETVAL(flags));}
|
||||
const nsXPTType GetType() const {return type.prefix;}
|
||||
|
||||
uint8 GetInterfaceIsArgNumber() const
|
||||
{
|
||||
NS_PRECONDITION(GetType().TagPart() == nsXPTType::T_INTERFACE_IS,"not an interface_is");
|
||||
return type.type.argnum;
|
||||
}
|
||||
|
||||
// This is not inlined, it is more involved!
|
||||
// If XPTInterfaceDirectoryEntry references remain indexes, then it
|
||||
// may be necessary to pass in a param here indicating which typelib
|
||||
// - or at least XPTInterfaceDirectoryEntry - this particular param
|
||||
// is associated with so that we can find the table this index indexes
|
||||
// and then find the referenced XPTInterfaceDirectoryEntry so that we can
|
||||
// find (or build) the appropriate nsIInterfaceInfo. Simple :)
|
||||
nsIInterfaceInfo* GetInterface() const ;
|
||||
|
||||
// a *little* simpler than the above
|
||||
nsIID* GetInterfaceIID() const ;
|
||||
|
||||
private:
|
||||
nsXPTParamInfo(); // no implementation
|
||||
// NO DATA - this a flyweight wrapper
|
||||
};
|
||||
|
||||
class nsXPTMethodInfo : public XPTMethodDescriptor
|
||||
{
|
||||
// NO DATA - this a flyweight wrapper
|
||||
public:
|
||||
nsXPTMethodInfo(const XPTMethodDescriptor& desc)
|
||||
{*(XPTMethodDescriptor*)this = desc;}
|
||||
|
||||
JSBool IsGetter() const {return (JSBool) (XPT_MD_IS_GETTER(flags) );}
|
||||
JSBool IsSetter() const {return (JSBool) (XPT_MD_IS_SETTER(flags) );}
|
||||
JSBool IsVarArgs() const {return (JSBool) (XPT_MD_IS_VARARGS(flags));}
|
||||
JSBool IsConstructor() const {return (JSBool) (XPT_MD_IS_CTOR(flags) );}
|
||||
JSBool IsHidden() const {return (JSBool) (XPT_MD_IS_HIDDEN(flags) );}
|
||||
const char* GetName() const {return name;}
|
||||
uint8 GetParamCount() const {return num_args;}
|
||||
const nsXPTParamInfo GetParam(uint8 index) const
|
||||
{
|
||||
NS_PRECONDITION(index < GetParamCount(),"bad arg");
|
||||
return params[index];
|
||||
}
|
||||
const nsXPTParamInfo GetResult() const
|
||||
{return *result;}
|
||||
private:
|
||||
nsXPTMethodInfo(); // no implementation
|
||||
// NO DATA - this a flyweight wrapper
|
||||
};
|
||||
|
||||
|
||||
// forward declaration
|
||||
struct nsXPCMiniVariant;
|
||||
|
||||
class nsXPTConstant : public XPTConstDescriptor
|
||||
{
|
||||
// NO DATA - this a flyweight wrapper
|
||||
public:
|
||||
nsXPTConstant(const XPTConstDescriptor& desc)
|
||||
{*(XPTConstDescriptor*)this = desc;}
|
||||
|
||||
const char* GetName() const
|
||||
{return name;}
|
||||
|
||||
const nsXPTType GetType() const
|
||||
{return type.prefix;}
|
||||
|
||||
// XXX this is ugly
|
||||
const nsXPCMiniVariant* GetValue() const
|
||||
{return (nsXPCMiniVariant*) &value;}
|
||||
private:
|
||||
nsXPTConstant(); // no implementation
|
||||
// NO DATA - this a flyweight wrapper
|
||||
};
|
||||
|
||||
#endif /* xpt_cpp_h___ */
|
Загрузка…
Ссылка в новой задаче