Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: Source/bindings/core/v8/V8DOMConfiguration.cpp

Issue 577303002: IDL: Support [DeprecateAs] and [MeasureAs] on constants (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adjusted encrypted-media-constants-expected.txt Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 v8::Local<v8::FunctionTemplate> setter; 64 v8::Local<v8::FunctionTemplate> setter;
65 if (setterCallback) { 65 if (setterCallback) {
66 setter = v8::FunctionTemplate::New(isolate, setterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 1); 66 setter = v8::FunctionTemplate::New(isolate, setterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 1);
67 setter->RemovePrototype(); 67 setter->RemovePrototype();
68 } 68 }
69 prototype->SetAccessorProperty(v8AtomicString(isolate, accessors[i].name ), getter, setter, accessors[i].attribute, accessors[i].settings); 69 prototype->SetAccessorProperty(v8AtomicString(isolate, accessors[i].name ), getter, setter, accessors[i].attribute, accessors[i].settings);
70 } 70 }
71 } 71 }
72 72
73 // Constant installation
74 //
75 // installConstants() is be used for simple constants. It installs constants
76 // using v8::Template::Set(), which results in a property that is much faster to
77 // access from scripts.
78 // installConstant() is used when some C++ code needs to be executed when the
79 // constant is accessed, e.g. to handle deprecation or measuring usage. The
80 // property appears the same to scripts, but is slower to access.
81
73 void V8DOMConfiguration::installConstants(v8::Handle<v8::FunctionTemplate> funct ionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfigura tion* constants, size_t constantCount, v8::Isolate* isolate) 82 void V8DOMConfiguration::installConstants(v8::Handle<v8::FunctionTemplate> funct ionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfigura tion* constants, size_t constantCount, v8::Isolate* isolate)
74 { 83 {
75 for (size_t i = 0; i < constantCount; ++i) { 84 for (size_t i = 0; i < constantCount; ++i) {
76 const ConstantConfiguration* constant = &constants[i]; 85 const ConstantConfiguration* constant = &constants[i];
77 v8::Handle<v8::String> constantName = v8AtomicString(isolate, constant-> name); 86 v8::Handle<v8::String> constantName = v8AtomicString(isolate, constant-> name);
78 switch (constant->type) { 87 switch (constant->type) {
79 case ConstantTypeShort: 88 case ConstantTypeShort:
80 case ConstantTypeLong: 89 case ConstantTypeLong:
81 case ConstantTypeUnsignedShort: 90 case ConstantTypeUnsignedShort:
82 functionDescriptor->Set(constantName, v8::Integer::New(isolate, cons tant->ivalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete) ); 91 functionDescriptor->Set(constantName, v8::Integer::New(isolate, cons tant->ivalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete) );
(...skipping 11 matching lines...) Expand all
94 case ConstantTypeString: 103 case ConstantTypeString:
95 functionDescriptor->Set(constantName, v8::String::NewFromUtf8(isolat e, constant->svalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::Dont Delete)); 104 functionDescriptor->Set(constantName, v8::String::NewFromUtf8(isolat e, constant->svalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::Dont Delete));
96 prototype->Set(constantName, v8::String::NewFromUtf8(isolate, consta nt->svalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); 105 prototype->Set(constantName, v8::String::NewFromUtf8(isolate, consta nt->svalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
97 break; 106 break;
98 default: 107 default:
99 ASSERT_NOT_REACHED(); 108 ASSERT_NOT_REACHED();
100 } 109 }
101 } 110 }
102 } 111 }
103 112
113 void V8DOMConfiguration::installConstant(v8::Handle<v8::FunctionTemplate> functi onDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const char* name, v8::Ac cessorGetterCallback getter, v8::Isolate* isolate)
114 {
115 v8::Handle<v8::String> constantName = v8AtomicString(isolate, name);
116 functionDescriptor->SetNativeDataProperty(constantName, getter, 0, v8::Handl e<v8::Value>(), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete ));
117 prototype->SetNativeDataProperty(constantName, getter, 0, v8::Handle<v8::Val ue>(), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
118 }
119
104 void V8DOMConfiguration::installMethods(v8::Handle<v8::ObjectTemplate> prototype , v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const M ethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate) 120 void V8DOMConfiguration::installMethods(v8::Handle<v8::ObjectTemplate> prototype , v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const M ethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate)
105 { 121 {
106 for (size_t i = 0; i < callbackCount; ++i) 122 for (size_t i = 0; i < callbackCount; ++i)
107 installMethod(prototype, signature, attributes, callbacks[i], isolate); 123 installMethod(prototype, signature, attributes, callbacks[i], isolate);
108 } 124 }
109 125
110 v8::Handle<v8::FunctionTemplate> V8DOMConfiguration::functionTemplateForCallback (v8::Handle<v8::Signature> signature, v8::FunctionCallback callback, int length, v8::Isolate* isolate) 126 v8::Handle<v8::FunctionTemplate> V8DOMConfiguration::functionTemplateForCallback (v8::Handle<v8::Signature> signature, v8::FunctionCallback callback, int length, v8::Isolate* isolate)
111 { 127 {
112 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New (isolate, callback, v8Undefined(), signature, length); 128 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New (isolate, callback, v8Undefined(), signature, length);
113 functionTemplate->RemovePrototype(); 129 functionTemplate->RemovePrototype();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return result; 166 return result;
151 167
152 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); 168 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
153 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode); 169 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode);
154 configureDOMClassTemplate(result, isolate); 170 configureDOMClassTemplate(result, isolate);
155 data->setDOMTemplate(wrapperTypeInfo, result); 171 data->setDOMTemplate(wrapperTypeInfo, result);
156 return result; 172 return result;
157 } 173 }
158 174
159 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698