OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 }; | 88 }; |
89 | 89 |
90 | 90 |
91 static v8::Local<v8::ObjectTemplate> CreateConstructor( | 91 static v8::Local<v8::ObjectTemplate> CreateConstructor( |
92 v8::Handle<v8::Context> context, | 92 v8::Handle<v8::Context> context, |
93 const char* class_name, | 93 const char* class_name, |
94 int internal_field, | 94 int internal_field, |
95 const char* descriptor_name = NULL, | 95 const char* descriptor_name = NULL, |
96 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = | 96 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = |
97 v8::Handle<v8::DeclaredAccessorDescriptor>()) { | 97 v8::Handle<v8::DeclaredAccessorDescriptor>()) { |
98 v8::Local<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(); | 98 v8::Local<v8::FunctionTemplate> constructor = |
| 99 v8::FunctionTemplate::New(context->GetIsolate()); |
99 v8::Local<v8::ObjectTemplate> obj_template = constructor->InstanceTemplate(); | 100 v8::Local<v8::ObjectTemplate> obj_template = constructor->InstanceTemplate(); |
100 // Setup object template. | 101 // Setup object template. |
101 if (descriptor_name != NULL && !descriptor.IsEmpty()) { | 102 if (descriptor_name != NULL && !descriptor.IsEmpty()) { |
102 bool added_accessor = | 103 bool added_accessor = |
103 obj_template->SetDeclaredAccessor(v8_str(descriptor_name), descriptor); | 104 obj_template->SetDeclaredAccessor(v8_str(descriptor_name), descriptor); |
104 CHECK(added_accessor); | 105 CHECK(added_accessor); |
105 } | 106 } |
106 obj_template->SetInternalFieldCount((internal_field+1)*2 + 7); | 107 obj_template->SetInternalFieldCount((internal_field+1)*2 + 7); |
107 context->Global()->Set(v8_str(class_name), constructor->GetFunction()); | 108 context->Global()->Set(v8_str(class_name), constructor->GetFunction()); |
108 return obj_template; | 109 return obj_template; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 int internal_field = 0; | 291 int internal_field = 0; |
291 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = | 292 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = |
292 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) | 293 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) |
293 ->NewRawShift(helper.isolate_, index*kPointerSize) | 294 ->NewRawShift(helper.isolate_, index*kPointerSize) |
294 ->NewHandleDereference(helper.isolate_); | 295 ->NewHandleDereference(helper.isolate_); |
295 HandleArray* array = helper.handle_array_.get(); | 296 HandleArray* array = helper.handle_array_.get(); |
296 v8::Handle<v8::String> expected = v8_str("whatever"); | 297 v8::Handle<v8::String> expected = v8_str("whatever"); |
297 array->handles_[index].Reset(helper.isolate_, expected); | 298 array->handles_[index].Reset(helper.isolate_, expected); |
298 VerifyRead(descriptor, internal_field, array, expected); | 299 VerifyRead(descriptor, internal_field, array, expected); |
299 } | 300 } |
OLD | NEW |