Provide private symbols through internal APIs
authorrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 13 Nov 2013 10:34:06 +0000 (10:34 +0000)
committerrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 13 Nov 2013 10:34:06 +0000 (10:34 +0000)
commitcec8383cff10f620e93a51a5a6c22bec048950dc
tree10409a239f2cf64498183003dc2c98a741861f2a
parent9d6dddb9aebdc26174f858c7585f363e27f828ad
Provide private symbols through internal APIs

Adds a notion of private symbols, mainly intended for internal use, especially, self-hosting of built-in types that would otherwise require new C++ classes.

On the JS side (i.e., in built-ins), private properties can be created and accessed through a set of macros:

  NEW_PRIVATE(print_name)
  HAS_PRIVATE(obj, sym)
  GET_PRIVATE(obj, sym)
  SET_PRIVATE(obj, sym, val)
  DELETE_PRIVATE(obj, sym)

In the V8 API, they are accessible via a new class Private, and respective HasPrivate/Get/Private/SetPrivate/DeletePrivate methods on calss Object.

These APIs are designed and restricted such that their implementation can later be replaced by whatever ES7+ will officially provide.

R=yangguo@chromium.org
BUG=

Review URL: https://codereview.chromium.org/48923002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17683 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
19 files changed:
include/v8.h
src/api.cc
src/array-iterator.js
src/factory.cc
src/factory.h
src/heap.cc
src/heap.h
src/macros.py
src/messages.js
src/objects-debug.cc
src/objects-inl.h
src/objects-printer.cc
src/objects.h
src/parser.cc
src/runtime.cc
src/runtime.h
test/cctest/test-api.cc
test/mjsunit/harmony/private.js [new file with mode: 0644]
test/mjsunit/harmony/symbols.js