summaryrefslogtreecommitdiffstats
path: root/webkit/port/bindings/v8
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 12:41:22 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 12:41:22 +0000
commit4b6af4f75e9ad65588f01d9e980a0cc427695d91 (patch)
tree1a1314085360c475c3c439c94b8877c7a07c8ad5 /webkit/port/bindings/v8
parent3050f7d57b2dee4784df2cb0812c3b5845956ee1 (diff)
downloadchromium_src-4b6af4f75e9ad65588f01d9e980a0cc427695d91.zip
chromium_src-4b6af4f75e9ad65588f01d9e980a0cc427695d91.tar.gz
chromium_src-4b6af4f75e9ad65588f01d9e980a0cc427695d91.tar.bz2
Move a bunch of code-driven binding template configuration to a data-driven approach. This reduces the code size, and the overall binary size.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/bindings/v8')
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp35
-rw-r--r--webkit/port/bindings/v8/v8_proxy.h35
2 files changed, 69 insertions, 1 deletions
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index b5398a1..5cfcd62 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -183,7 +183,40 @@ void V8Proxy::UnregisterGlobalHandle(void* host,
ASSERT(info->host_ == host);
delete info;
}
-#endif
+#endif // ifndef NDEBUG
+
+void BatchConfigureAttributes(v8::Handle<v8::ObjectTemplate> inst,
+ v8::Handle<v8::ObjectTemplate> proto,
+ const BatchedAttribute* attrs,
+ size_t num_attrs) {
+ for (size_t i = 0; i < num_attrs; ++i) {
+ const BatchedAttribute* a = &attrs[i];
+ (a->on_proto ? proto : inst)->SetAccessor(
+ v8::String::New(a->name),
+ a->getter,
+ a->setter,
+ a->data == V8ClassIndex::INVALID_CLASS_INDEX
+ ? v8::Handle<v8::Value>()
+ : v8::Integer::New(V8ClassIndex::ToInt(a->data)),
+ a->settings,
+ a->attribute);
+ }
+}
+
+void BatchConfigureConstants(v8::Handle<v8::FunctionTemplate> desc,
+ v8::Handle<v8::ObjectTemplate> proto,
+ const BatchedConstant* consts,
+ size_t num_consts) {
+ for (size_t i = 0; i < num_consts; ++i) {
+ const BatchedConstant* c = &consts[i];
+ desc->Set(v8::String::New(c->name),
+ v8::Integer::New(c->value),
+ v8::ReadOnly);
+ proto->Set(v8::String::New(c->name),
+ v8::Integer::New(c->value),
+ v8::ReadOnly);
+ }
+}
typedef HashMap<Node*, v8::Object*> NodeMap;
diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h
index 40909c0..23d1f95 100644
--- a/webkit/port/bindings/v8/v8_proxy.h
+++ b/webkit/port/bindings/v8/v8_proxy.h
@@ -103,6 +103,41 @@ class GlobalHandleInfo {
#endif // NDEBUG
+// The following Batch structs and methods are used for setting multiple
+// properties on an ObjectTemplate, used from the generated bindings
+// initialization (ConfigureXXXTemplate). This greatly reduces the binary
+// size by moving from code driven setup to data table driven setup.
+
+// BatchedAttribute translates into calls to SetAccessor() on either the
+// instance or the prototype ObjectTemplate, based on |on_proto|.
+struct BatchedAttribute {
+ const char* const name;
+ v8::AccessorGetter getter;
+ v8::AccessorSetter setter;
+ V8ClassIndex::V8WrapperType data;
+ v8::AccessControl settings;
+ v8::PropertyAttribute attribute;
+ bool on_proto;
+};
+
+void BatchConfigureAttributes(v8::Handle<v8::ObjectTemplate> inst,
+ v8::Handle<v8::ObjectTemplate> proto,
+ const BatchedAttribute* attrs,
+ size_t num_attrs);
+
+// BhatchedConstant translates into calls to Set() for setting up an object's
+// constants. It sets the constant on both the FunctionTemplate |desc| and the
+// ObjectTemplate |proto|. PropertyAttributes is always ReadOnly.
+struct BatchedConstant {
+ const char* const name;
+ int value;
+};
+
+void BatchConfigureConstants(v8::Handle<v8::FunctionTemplate> desc,
+ v8::Handle<v8::ObjectTemplate> proto,
+ const BatchedConstant* consts,
+ size_t num_consts);
+
class V8Proxy {
public:
// The types of javascript errors that can be thrown.