~fredreichbier/+junk/pyjavascriptcore

Viewing all changes in revision 62.

  • Committer: Martín Soto
  • Date: 2009-11-28 21:41:59 UTC
  • Revision ID: soto@masoft-20091128214159-534s92z3lu5973ii
Add wrapper caching for the Python-wrapped-in-JavaScript direction

* javascriptcore.pyx (_pyWrappedPyObjs): New dictionary to cache
  JavaScript wrappers for Python objects.
  (wrapJSObject): Fix declaration of 'wrapper' variable.
  (wrapPyObject): New procedure to wrap Python objects into
  JavaScript. This uses the wrapper cache.
  (pythonToJS): Call wrapPyObject when wrapping objects.
  (finalizeCb): Remove wrappers from the cache when they are
  garbage-collected.
  (_cachedStats): Add number of cached JavaSript wrappers to the returned
  stats.

* test/pyfromjs.py (WrapUnwrapTestCase.testIdentity1) 
  (WrapUnwrapTestCase.testIdentity2): New tests to make sure that the
  same Python object always gets the same wrapper.

* test/test.py: Make sure no wrappers remain cached after the tests are
  run.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: