From 93f9f360fc88ea3bae8e74b7b22ad25d1ddaec85 Mon Sep 17 00:00:00 2001 From: "abarth@chromium.org" Date: Thu, 21 Nov 2013 18:38:51 +0000 Subject: [Gin] Add a mechanism for wrapping C++ object 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 --- gin/gin.gyp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'gin/gin.gyp') diff --git a/gin/gin.gyp b/gin/gin.gyp index e0ec34c..4b08dfc 100644 --- a/gin/gin.gyp +++ b/gin/gin.gyp @@ -19,14 +19,6 @@ '../v8/tools/gyp/v8.gyp:v8', ], 'sources': [ - 'modules/console.cc', - 'modules/console.h', - 'modules/file_module_provider.cc', - 'modules/file_module_provider.h', - 'modules/module_registry.cc', - 'modules/module_registry.h', - 'modules/module_runner_delegate.cc', - 'modules/module_runner_delegate.h', 'arguments.cc', 'arguments.h', 'array_buffer.cc', @@ -39,17 +31,27 @@ 'dictionary.h', 'gin.cc', 'gin.h', + 'modules/console.cc', + 'modules/console.h', + 'modules/file_module_provider.cc', + 'modules/file_module_provider.h', + 'modules/module_registry.cc', + 'modules/module_registry.h', + 'modules/module_runner_delegate.cc', + 'modules/module_runner_delegate.h', 'per_context_data.cc', 'per_context_data.h', 'per_isolate_data.cc', 'per_isolate_data.h', + 'public/gin_embedders.h', + 'public/wrapper_info.h', 'runner.cc', 'runner.h', 'try_catch.cc', 'try_catch.h', + 'wrappable.cc', + 'wrappable.h', 'wrapper_info.cc', - 'public/gin_embedders.h', - 'public/wrapper_info.h', ], }, { @@ -100,6 +102,7 @@ 'test/run_all_unittests.cc', 'test/run_js_tests.cc', 'runner_unittest.cc', + 'wrappable_unittest.cc', ], }, ], -- cgit v1.1