~fredreichbier/+junk/pyjavascriptcore

Viewing all changes in revision 60.

  • Committer: Martín Soto
  • Date: 2009-11-28 00:12:50 UTC
  • Revision ID: soto@masoft-20091128001250-ks2wyxnmbheiup07
Add wrapper caching for the JavaScript-wrapped-in-Python direction

* javascriptcore.pyx (_pyWrappedJSObjs, wrapJSObject): New dictionary and
  function to cache the wrappers of JavaScript objects so that objects
  are not wrapped twice.
  (jsToPython): Use the object wrapping implementation.
  (_JSBaseObject.__weakref__): New attribute. Makes it possible to have
  weak references to wrappers.
  (_cachedStats): New debugging function. For the moment, it returns a
  dictionary containing the number of objects currently cached in
  _pyWrappedJSObjs.

* test/jsfrompy.py (WrapUnwrapTestCase.testIdentity1) 
  (WrapUnwrapTestCase.testIdentity2) 
  (WrapUnwrapTestCase.testCachedWrappers1): Test the caching mechanism.

* test/test.py: Verify that no objects remain in the cache after running
  the tests.


expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: