| 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<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
| 6156 Isolate* isolate, Local<String> name) { | |
| 6157 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6151 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6158 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6152 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
| 6159 LOG_API(i_isolate, "Private::New()"); | 6153 LOG_API(i_isolate, "Private::New()"); |
| 6160 ENTER_V8(i_isolate); | 6154 ENTER_V8(i_isolate); |
| 6161 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6155 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
| 6162 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 6156 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
| 6163 Local<Symbol> result = Utils::ToLocal(symbol); | 6157 Local<Symbol> result = Utils::ToLocal(symbol); |
| 6164 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); | 6158 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
| 6165 } | 6159 } |
| 6166 | 6160 |
| 6167 | 6161 |
| 6162 Local<Private> v8::Private::Global(Isolate* isolate, Local<String> name) { |
| 6163 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6164 i::Handle<i::String> i_name = Utils::OpenHandle(*name); |
| 6165 i::Handle<i::JSObject> registry = |
| 6166 i::handle(i_isolate->heap()->symbol_registry()); |
| 6167 i::Handle<i::String> part = |
| 6168 i::handle(i_isolate->heap()->private_api_string()); |
| 6169 i::Handle<i::Object> privates_val = |
| 6170 i::JSReceiver::GetProperty(registry, part); |
| 6171 i::Handle<i::JSObject> privates; |
| 6172 if (privates_val->IsJSObject()) { |
| 6173 privates = i::Handle<i::JSObject>::cast(privates_val); |
| 6174 } else { |
| 6175 ASSERT(privates_val->IsUndefined()); |
| 6176 privates = i_isolate->factory()->NewJSObject( |
| 6177 i_isolate->object_function(), i::TENURED); |
| 6178 i::JSObject::SetPrototype(privates, i_isolate->factory()->null_value()); |
| 6179 i::JSObject::SetProperty(registry, part, privates, NONE, i::STRICT); |
| 6180 } |
| 6181 i::Handle<i::Object> symbol = i::JSObject::GetProperty(privates, i_name); |
| 6182 if (!symbol->IsSymbol()) { |
| 6183 ASSERT(symbol->IsUndefined()); |
| 6184 symbol = i_isolate->factory()->NewPrivateSymbol(); |
| 6185 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); |
| 6186 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT); |
| 6187 } |
| 6188 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); |
| 6189 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
| 6190 } |
| 6191 |
| 6192 |
| 6168 Local<Number> v8::Number::New(Isolate* isolate, double value) { | 6193 Local<Number> v8::Number::New(Isolate* isolate, double value) { |
| 6169 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6194 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6170 ASSERT(internal_isolate->IsInitialized()); | 6195 ASSERT(internal_isolate->IsInitialized()); |
| 6171 if (std::isnan(value)) { | 6196 if (std::isnan(value)) { |
| 6172 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 6197 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
| 6173 value = i::OS::nan_value(); | 6198 value = i::OS::nan_value(); |
| 6174 } | 6199 } |
| 6175 ENTER_V8(internal_isolate); | 6200 ENTER_V8(internal_isolate); |
| 6176 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6201 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6177 return Utils::NumberToLocal(result); | 6202 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()); | 7622 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7598 Address callback_address = | 7623 Address callback_address = |
| 7599 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7624 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7600 VMState<EXTERNAL> state(isolate); | 7625 VMState<EXTERNAL> state(isolate); |
| 7601 ExternalCallbackScope call_scope(isolate, callback_address); | 7626 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7602 callback(info); | 7627 callback(info); |
| 7603 } | 7628 } |
| 7604 | 7629 |
| 7605 | 7630 |
| 7606 } } // namespace v8::internal | 7631 } } // namespace v8::internal |
| OLD | NEW |