update TODO list, fixed finalization to wrapper release mapping for wrapped native

This commit is contained in:
jband%netscape.com 1999-03-19 04:57:09 +00:00
Родитель 42c71b1afc
Коммит 73776f0792
6 изменённых файлов: 83 добавлений и 38 удалений

Просмотреть файл

@ -1,23 +1,49 @@
/* jband - 02/20/99 - TODO and issues list */
**** TODO ****
- Ports!
- Docs
- list of required docs
- docs on source?
- namespaces
- xpidl work
- xptinfo work
- XPConnect work
- ports
- Mac!
- other
- xpidl work for marking pointer, const, reference, nsID
- 64bit ints on platforms w/o 'long long'
- re-org the source directory layout
- define 'JSFILE' by default in JS engines
- better api for Components object
- reimplement nsSJIID and nsJSCID using multiple inheritence
- nsJSCID getSerrvice method
- global namespace interface
- fix interface constant stuff
- XPCOnnect as a service
- auto reg stuff
- flattened component scheme
- xpidl extensions
- XPConnect support
- simple aggregatable interface for GetCID()
- 'shared'
- resolve the string issues
- work with embedders
- better exceptions (not just throw strings)
- work in JS engine to track more info when exceptions thrown so that
the uncaught exceptions will not be so mysterious (filename and lineno)
- better tests
- xpidl work and documents
- 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?)
- Construct objects for 'Components' tree.
- safer use of jsdoubles?
**** ISSUES ****
- Contexts\Runtimes\ScopeChain problems
- Constants fo WrappedJS objects?
- Constants for 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?

Просмотреть файл

@ -285,6 +285,7 @@ public:
NS_IMETHODIMP _class::Finalize(JSContext *cx, JSObject *obj, \
nsIXPConnectWrappedNative* wrapper, \
nsIXPCScriptable* arbitrary) \
/* XPConnect does the finalization on the wrapper itself anyway */ \
{return arbitrary->Finalize(cx, obj, wrapper, NULL);}
/***************************************************************************/
@ -404,6 +405,7 @@ public:
NS_IMETHODIMP _class::Finalize(JSContext *cx, JSObject *obj, \
nsIXPConnectWrappedNative* wrapper, \
nsIXPCScriptable* arbitrary) \
/* XPConnect does the finalization on the wrapper itself anyway */ \
{return NS_OK;}
/***************************************************************************/

Просмотреть файл

@ -250,6 +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");
JS_FinalizeStub(cx, obj);
/* XPConnect does the finalization on the wrapper itself anyway */
return NS_OK;
}

Просмотреть файл

@ -531,7 +531,7 @@ public:
nsIXPCScriptable* GetArbitraryScriptable() const
{return GetClass()->GetArbitraryScriptable();}
void JSObjectFinalized();
void JSObjectFinalized(JSContext *cx, JSObject *obj);
virtual ~nsXPCWrappedNative();
private:

Просмотреть файл

@ -30,7 +30,7 @@ nsXPCWrappedNative::AddRef(void)
{
NS_PRECONDITION(mRoot, "bad root");
if(1 == ++mRefCnt && mRoot && mRoot != this)
if(1 == ++mRefCnt && mRoot != this)
NS_ADDREF(mRoot);
else if(2 == mRefCnt)
JS_AddRoot(mClass->GetXPCContext()->GetJSContext(), &mJSObj);
@ -48,16 +48,8 @@ nsXPCWrappedNative::Release(void)
if(0 == --mRefCnt)
{
if(mRoot == this)
{
// XPC_LOG_DEBUG(("--- Delete of %x with mJSObj %x and mRefCnt = %d",this,mJSObj, mRefCnt));
NS_DELETEXPCOM(this); // cascaded delete
}
else
{
// XPC_LOG_DEBUG(("--- Release of root %x with mJSObj %x and mRefCnt = %d",this,mJSObj, mRefCnt));
mRoot->Release();
}
// XPC_LOG_DEBUG(("--- Delete of wrapper %x with mJSObj %x and mRefCnt = %d",this,mJSObj, mRefCnt));
NS_DELETEXPCOM(this); // also unlinks us from chain
return 0;
}
if(1 == mRefCnt)
@ -72,14 +64,17 @@ nsXPCWrappedNative::Release(void)
}
void
nsXPCWrappedNative::JSObjectFinalized()
nsXPCWrappedNative::JSObjectFinalized(JSContext *cx, JSObject *obj)
{
NS_PRECONDITION(1 == mRefCnt, "bad JSObject finalization");
nsIXPCScriptable* ds;
if(NULL != (ds = GetDynamicScriptable()))
ds->Finalize(GetClass()->GetXPCContext()->GetJSContext(), GetJSObject(),
this, GetArbitraryScriptable());
ds->Finalize(cx, obj, this, GetArbitraryScriptable());
// pass through to the real JSObject finalization code
JS_FinalizeStub(cx, obj);
mJSObj = NULL;
Release();
}
@ -240,23 +235,45 @@ nsXPCWrappedNative::nsXPCWrappedNative(nsISupports* aObj,
nsXPCWrappedNative::~nsXPCWrappedNative()
{
NS_PRECONDITION(0 == mRefCnt, "refcounting error");
if(mRoot == this && GetClass())
NS_ASSERTION(mRoot, "wrapper without root deleted");
if(mRoot != this)
{
XPCContext* xpcc = GetClass()->GetXPCContext();
if(xpcc)
// unlink this wrapper
nsXPCWrappedNative* cur = mRoot;
while(1)
{
Native2WrappedNativeMap* map;
map = xpcc->GetWrappedNativeMap();
if(map)
map->Remove(this);
if(cur->mNext == this)
{
cur->mNext = mNext;
break;
}
cur = cur->mNext;
NS_ASSERTION(cur, "failed to find wrapper in its own chain");
}
// let the root go
NS_RELEASE(mRoot);
}
else
{
// remove this root wrapper from the map
NS_ASSERTION(!mNext, "root wrapper with non-empty chain being deleted");
nsXPCWrappedNativeClass* clazz;
XPCContext* xpcc;
Native2WrappedNativeMap* map;
if(NULL != (clazz = GetClass()) &&
NULL != (xpcc = clazz->GetXPCContext())&&
NULL != (map = xpcc->GetWrappedNativeMap()))
{
map->Remove(this);
}
}
if(mDynamicScriptable)
NS_RELEASE(mDynamicScriptable);
NS_RELEASE(mClass);
NS_RELEASE(mObj);
if(mNext)
NS_DELETEXPCOM(mNext); // cascaded delete
if(mClass)
NS_RELEASE(mClass);
if(mObj)
NS_RELEASE(mObj);
}
nsXPCWrappedNative*

Просмотреть файл

@ -1133,7 +1133,7 @@ WrappedNative_Finalize(JSContext *cx, JSObject *obj)
return;
NS_ASSERTION(obj == wrapper->GetJSObject(),"bad obj");
// wrapper is responsible for calling DynamicScriptable->Finalize
wrapper->JSObjectFinalized();
wrapper->JSObjectFinalized(cx, obj);
}
static JSObjectOps WrappedNative_ops = {