summaryrefslogtreecommitdiffstats
path: root/gin/wrappable_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Get rid of even more Script::New calls in Chromium.marja@chromium.org2014-03-121-1/+1
| | | | | | | | | | | | Script::Compile is the right way (see previous changes in https://codereview.chromium.org/178663008 ). R=jochen@chromium.org BUG= Review URL: https://codereview.chromium.org/196573003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256538 0039d316-1c4b-4281-b951-d872f2087c98
* gin: Add ability to install call-as-function handlers on gin::Wrappablejochen@chromium.org2014-03-101-0/+54
| | | | | | | | | BUG=347565 R=dcarney@chromium.org Review URL: https://codereview.chromium.org/192693002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255927 0039d316-1c4b-4281-b951-d872f2087c98
* gin: Bug fix: Fix CreateHandle to return an emtpy handle in some extreme caseshajimehoshi@chromium.org2014-02-281-0/+22
| | | | | | | | | | | | | | In some extreme cases, ObjectTemplate::NewInstance might return an empty handler. For example, the getter and setter Object.prototype.constructor can be rewritten with a evil function which can throw exceptions. BUG=331301 TEST=gin_unittests --gtest_filter=WrappableTest.ErrorInObjectConstructorProperty Review URL: https://codereview.chromium.org/184253004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254109 0039d316-1c4b-4281-b951-d872f2087c98
* Use Script::Compile instead of Script::Newmarja@chromium.org2014-02-271-2/+2
| | | | | | | | | | | | | | | Script::New creates a context-independent script. Using it only makes sense if the resulting Script will be run in many different contexts. All these places run the script right after creating it, and only in one context. So they should have used Script::Compile, which creates a Script bound to the current context. Context-bound scripts are more efficient than context-unbound scripts. R=jochen@chromium.org BUG= Review URL: https://codereview.chromium.org/178663008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253884 0039d316-1c4b-4281-b951-d872f2087c98
* Remove usage of deprecate v8::Number constructors from ginjochen@chromium.org2014-01-031-1/+1
| | | | | | | | | TBR=dcarney@chromium.org BUG=none Review URL: https://codereview.chromium.org/109563003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242884 0039d316-1c4b-4281-b951-d872f2087c98
* [gin] fix casting WrappableBase to a derived classjochen@chromium.org2013-12-191-1/+13
| | | | | | | | | | | | | | | | | | We first need to cast the void pointer to WrappableBase before we can cast it to the derived class: initially a WrappableBase* is stored as holder, so we can't directly cast it to the derived class. To test this, I added a useless base class so the test object this pointers don't align with the WrappableBase this pointer. Also update the comments about how to use WrappableBase. BUG=none R=aa@chromium.org,dcarney@chromium.org Review URL: https://codereview.chromium.org/119173002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241863 0039d316-1c4b-4281-b951-d872f2087c98
* Add support for wrapping classes indirectly inherited from gin::Wrappable<T>aa@chromium.org2013-12-191-8/+55
| | | | | | | | This is needed for: https://codereview.chromium.org/116163008/ Review URL: https://codereview.chromium.org/118423004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241730 0039d316-1c4b-4281-b951-d872f2087c98
* [gin] Introduce Wrappable::GetObjectTemplatejochen@chromium.org2013-12-171-22/+8
| | | | | | | | | | | | | Instead of explicitly registering object templates for all wrapper infos, add a method on wrappable that returns the template when needed. BUG=none R=aa@chromium.org,abarth@chromium.org Review URL: https://codereview.chromium.org/113893005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241370 0039d316-1c4b-4281-b951-d872f2087c98
* [gin] Declare a wrappable's kWrapperInfo on the class deriving from Wrappablejochen@chromium.org2013-12-121-3/+9
| | | | | | | | | | | | | | | Otherwise, we need to put INIT_WRAPPABLE() in namespace gin no matter where the derived class is declared. I pulled this out from https://codereview.chromium.org/111083005/ BUG=none R=dcarney@chromium.org TBR=aa@chromium.org Review URL: https://codereview.chromium.org/113163007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240271 0039d316-1c4b-4281-b951-d872f2087c98
* [gin] WrappableBase's dtor needs to be virtualjochen@chromium.org2013-12-111-1/+1
| | | | | | | | | | | | | | Otherwise, the weak callback won't run the dtor of derived classes. Also clarify that the INIT_WRAPPABLE() macro needs to be called in namespace gin. BUG=none R=aa@chromium.org Review URL: https://codereview.chromium.org/93903003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240154 0039d316-1c4b-4281-b951-d872f2087c98
* Gin: Make it easier to implement Wrappable.aa@chromium.org2013-12-081-44/+10
| | | | | | | | BUG= Review URL: https://codereview.chromium.org/105743007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239387 0039d316-1c4b-4281-b951-d872f2087c98
* Gin: Consolidate all the Converter<Wrappable> subclasses.aa@chromium.org2013-12-061-8/+70
| | | | | | Review URL: https://codereview.chromium.org/107113005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239204 0039d316-1c4b-4281-b951-d872f2087c98
* Gin: Add support for binding JS methods to C++ instance methods.aa@chromium.org2013-12-061-31/+8
| | | | | | | | | | | | | Also: - Added support for computed properties to ObjectTemplateBuilder - Realized it was possible for CreateFunctionTemplate to be just one template BUG= R=abarth@chromium.org, jyasskin@chromium.org Review URL: https://codereview.chromium.org/103703002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239126 0039d316-1c4b-4281-b951-d872f2087c98
* gin::Wrappable shouldn't inherit from base::RefCountedabarth@chromium.org2013-12-051-6/+7
| | | | | | | | | | | | | | Rather than using reference counting to keep gin::Wrappable objects alive, we use the V8 garbage collector. To retain a reference to a wrappable object on the stack, use a gin::Handle. Currently there is no mechanism for retaining a gin::Wrappable object in the heap, but we'll likely add one in the future. R=aa@chromium.org BUG=none Review URL: https://codereview.chromium.org/105423003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238902 0039d316-1c4b-4281-b951-d872f2087c98
* Remove usage of deprecagted V8 API from gin/jochen@chromium.org2013-11-281-3/+3
| | | | | | | | | | R=mkwst@chromium.org TBR=abarth@chromium.org BUG=324225 Review URL: https://codereview.chromium.org/94413002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237750 0039d316-1c4b-4281-b951-d872f2087c98
* Convert the rest of the functions in core.cc to use CreateFunctionTemplate.aa@chromium.org2013-11-271-2/+2
| | | | | | | | BUG= Review URL: https://codereview.chromium.org/89723002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237492 0039d316-1c4b-4281-b951-d872f2087c98
* [gin] add support for non-gin managed isolates in gin.jochen@chromium.org2013-11-221-1/+1
| | | | | | | | | BUG=317398 R=abarth@chromium.org,aa@chromium.org Review URL: https://codereview.chromium.org/82963002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236766 0039d316-1c4b-4281-b951-d872f2087c98
* [Gin] Add a mechanism for wrapping C++ objectabarth@chromium.org2013-11-211-0/+137
This CL adds a mechanism for wrapping C++ objects to Gin. The approach in this CL is similar to Blink's ScriptWrappable class, with a couple of differences: 1) gin::Wrappable has a vtable whereas Blink's ScriptWrappable class does not. Having a vtable in this base class lets us simplify a large number of concerns. We've talked about adding a vtable to ScriptWrappable but have avoided it because Blink creates many thousands of wrapped objects. When we refactor Blink to use Gin, we can still support the non-vtable approach, but most clients of Gin will want the simpler approach. 2) In Gin, we've bound together the notion of being reference counted with the notion of being wrappable from JavaScript. In Blink, those concepts are separate because we don't want to introduce a virtual destructor for ScriptWrappable. However, because gin::Wrappable already has a vtable, adding a virtual destructor is relatively cheap. Actually wrapping a C++ object still takes too much typing, but we can improve that in future CLs. R=jochen@chromium.org BUG=317398 Review URL: https://codereview.chromium.org/79203004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236555 0039d316-1c4b-4281-b951-d872f2087c98