OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6129 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)"); | 6129 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)"); |
6130 ENTER_V8(isolate); | 6130 ENTER_V8(isolate); |
6131 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView(); | 6131 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView(); |
6132 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); | 6132 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); |
6133 SetupArrayBufferView( | 6133 SetupArrayBufferView( |
6134 isolate, obj, buffer, byte_offset, byte_length); | 6134 isolate, obj, buffer, byte_offset, byte_length); |
6135 return Utils::ToLocal(obj); | 6135 return Utils::ToLocal(obj); |
6136 } | 6136 } |
6137 | 6137 |
6138 | 6138 |
6139 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { | 6139 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { |
6140 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6140 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6141 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); | 6141 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); |
6142 LOG_API(i_isolate, "Symbol::New()"); | 6142 LOG_API(i_isolate, "Symbol::New()"); |
6143 ENTER_V8(i_isolate); | 6143 ENTER_V8(i_isolate); |
6144 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 6144 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
6145 if (data != NULL) { | 6145 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); |
6146 if (length == -1) length = i::StrLength(data); | |
6147 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( | |
6148 i::Vector<const char>(data, length)); | |
6149 result->set_name(*name); | |
6150 } | |
6151 return Utils::ToLocal(result); | 6146 return Utils::ToLocal(result); |
6152 } | 6147 } |
6153 | 6148 |
6154 | 6149 |
6155 Local<Private> v8::Private::New( | 6150 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { |
6156 Isolate* isolate, Local<String> name) { | 6151 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6152 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | |
6153 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | |
6154 i::Handle<i::String> part = i::handle(i_isolate->heap()->for_string()); | |
Michael Starzinger
2014/03/24 15:17:19
nit: Just use i_isolate->factory()->for_string() i
rossberg
2014/03/24 15:54:46
Done.
| |
6155 i::Handle<i::JSObject> symbols = | |
6156 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); | |
6157 i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name); | |
6158 if (!symbol->IsSymbol()) { | |
6159 ASSERT(symbol->IsUndefined()); | |
6160 symbol = i_isolate->factory()->NewSymbol(); | |
6161 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | |
6162 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); | |
6163 } | |
6164 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | |
6165 } | |
6166 | |
6167 | |
6168 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { | |
6169 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
6170 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | |
6171 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | |
6172 i::Handle<i::String> part = i::handle(i_isolate->heap()->for_api_string()); | |
Michael Starzinger
2014/03/24 15:17:19
nit: Just use i_isolate->factory()->for_api_string
rossberg
2014/03/24 15:54:46
Done.
| |
6173 i::Handle<i::JSObject> symbols = | |
6174 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); | |
6175 i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name); | |
6176 if (!symbol->IsSymbol()) { | |
6177 ASSERT(symbol->IsUndefined()); | |
6178 symbol = i_isolate->factory()->NewSymbol(); | |
6179 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | |
6180 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); | |
6181 } | |
6182 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | |
6183 } | |
6184 | |
6185 | |
6186 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | |
6157 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6187 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6158 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6188 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
6159 LOG_API(i_isolate, "Private::New()"); | 6189 LOG_API(i_isolate, "Private::New()"); |
6160 ENTER_V8(i_isolate); | 6190 ENTER_V8(i_isolate); |
6161 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6191 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
6162 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 6192 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
6163 Local<Symbol> result = Utils::ToLocal(symbol); | 6193 Local<Symbol> result = Utils::ToLocal(symbol); |
6164 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); | 6194 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
6165 } | 6195 } |
6166 | 6196 |
6167 | 6197 |
6198 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { | |
6199 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
6200 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | |
6201 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | |
6202 i::Handle<i::String> part = | |
6203 i::handle(i_isolate->heap()->private_api_string()); | |
Michael Starzinger
2014/03/24 15:17:19
nit: Just use i_isolate->factory()->private_api_st
rossberg
2014/03/24 15:54:46
Done.
| |
6204 i::Handle<i::JSObject> privates = | |
6205 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); | |
6206 i::Handle<i::Object> symbol = i::JSObject::GetProperty(privates, i_name); | |
6207 if (!symbol->IsSymbol()) { | |
6208 ASSERT(symbol->IsUndefined()); | |
6209 symbol = i_isolate->factory()->NewPrivateSymbol(); | |
6210 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | |
6211 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT); | |
6212 } | |
6213 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | |
6214 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); | |
6215 } | |
6216 | |
6217 | |
6168 Local<Number> v8::Number::New(Isolate* isolate, double value) { | 6218 Local<Number> v8::Number::New(Isolate* isolate, double value) { |
6169 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6219 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6170 ASSERT(internal_isolate->IsInitialized()); | 6220 ASSERT(internal_isolate->IsInitialized()); |
6171 if (std::isnan(value)) { | 6221 if (std::isnan(value)) { |
6172 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 6222 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
6173 value = i::OS::nan_value(); | 6223 value = i::OS::nan_value(); |
6174 } | 6224 } |
6175 ENTER_V8(internal_isolate); | 6225 ENTER_V8(internal_isolate); |
6176 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6226 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
6177 return Utils::NumberToLocal(result); | 6227 return Utils::NumberToLocal(result); |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7597 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7647 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7598 Address callback_address = | 7648 Address callback_address = |
7599 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7649 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7600 VMState<EXTERNAL> state(isolate); | 7650 VMState<EXTERNAL> state(isolate); |
7601 ExternalCallbackScope call_scope(isolate, callback_address); | 7651 ExternalCallbackScope call_scope(isolate, callback_address); |
7602 callback(info); | 7652 callback(info); |
7603 } | 7653 } |
7604 | 7654 |
7605 | 7655 |
7606 } } // namespace v8::internal | 7656 } } // namespace v8::internal |
OLD | NEW |