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

Side by Side Diff: src/api.cc

Issue 210953005: Clean up some "GetProperty" methods/functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 1934
1935 v8::Local<Value> v8::TryCatch::StackTrace() const { 1935 v8::Local<Value> v8::TryCatch::StackTrace() const {
1936 ASSERT(isolate_ == i::Isolate::Current()); 1936 ASSERT(isolate_ == i::Isolate::Current());
1937 if (HasCaught()) { 1937 if (HasCaught()) {
1938 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); 1938 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
1939 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); 1939 if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1940 i::HandleScope scope(isolate_); 1940 i::HandleScope scope(isolate_);
1941 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); 1941 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1942 i::Handle<i::String> name = isolate_->factory()->stack_string(); 1942 i::Handle<i::String> name = isolate_->factory()->stack_string();
1943 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); 1943 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>();
1944 i::Handle<i::Object> value = i::GetProperty(isolate_, obj, name); 1944 i::Handle<i::Object> value = i::Object::GetProperty(obj, name);
1945 if (value.is_null()) return v8::Local<Value>(); 1945 if (value.is_null()) return v8::Local<Value>();
1946 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); 1946 return v8::Utils::ToLocal(scope.CloseAndEscape(value));
1947 } else { 1947 } else {
1948 return v8::Local<Value>(); 1948 return v8::Local<Value>();
1949 } 1949 }
1950 } 1950 }
1951 1951
1952 1952
1953 v8::Local<v8::Message> v8::TryCatch::Message() const { 1953 v8::Local<v8::Message> v8::TryCatch::Message() const {
1954 ASSERT(isolate_ == i::Isolate::Current()); 1954 ASSERT(isolate_ == i::Isolate::Current());
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 } 3136 }
3137 3137
3138 3138
3139 Local<Value> v8::Object::Get(v8::Handle<Value> key) { 3139 Local<Value> v8::Object::Get(v8::Handle<Value> key) {
3140 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3140 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3141 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 3141 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3142 ENTER_V8(isolate); 3142 ENTER_V8(isolate);
3143 i::Handle<i::Object> self = Utils::OpenHandle(this); 3143 i::Handle<i::Object> self = Utils::OpenHandle(this);
3144 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3144 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3145 EXCEPTION_PREAMBLE(isolate); 3145 EXCEPTION_PREAMBLE(isolate);
3146 i::Handle<i::Object> result = i::GetProperty(isolate, self, key_obj); 3146 i::Handle<i::Object> result =
3147 i::Runtime::GetObjectProperty(isolate, self, key_obj);
3147 has_pending_exception = result.is_null(); 3148 has_pending_exception = result.is_null();
3148 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3149 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3149 return Utils::ToLocal(result); 3150 return Utils::ToLocal(result);
3150 } 3151 }
3151 3152
3152 3153
3153 Local<Value> v8::Object::Get(uint32_t index) { 3154 Local<Value> v8::Object::Get(uint32_t index) {
3154 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3155 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3155 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 3156 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3156 ENTER_V8(isolate); 3157 ENTER_V8(isolate);
(...skipping 2983 matching lines...) Expand 10 before | Expand all | Expand 10 after
6140 return Utils::ToLocal(result); 6141 return Utils::ToLocal(result);
6141 } 6142 }
6142 6143
6143 6144
6144 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { 6145 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) {
6145 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6146 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6146 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6147 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6147 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6148 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6148 i::Handle<i::String> part = i_isolate->factory()->for_string(); 6149 i::Handle<i::String> part = i_isolate->factory()->for_string();
6149 i::Handle<i::JSObject> symbols = 6150 i::Handle<i::JSObject> symbols =
6150 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); 6151 i::Handle<i::JSObject>::cast(
6151 i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name); 6152 i::Object::GetPropertyOrElement(registry, part));
6153 i::Handle<i::Object> symbol =
6154 i::Object::GetPropertyOrElement(symbols, i_name);
6152 if (!symbol->IsSymbol()) { 6155 if (!symbol->IsSymbol()) {
6153 ASSERT(symbol->IsUndefined()); 6156 ASSERT(symbol->IsUndefined());
6154 symbol = i_isolate->factory()->NewSymbol(); 6157 symbol = i_isolate->factory()->NewSymbol();
6155 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6158 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6156 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); 6159 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT);
6157 } 6160 }
6158 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6161 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6159 } 6162 }
6160 6163
6161 6164
6162 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { 6165 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) {
6163 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6166 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6164 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6167 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6165 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6168 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6166 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); 6169 i::Handle<i::String> part = i_isolate->factory()->for_api_string();
6167 i::Handle<i::JSObject> symbols = 6170 i::Handle<i::JSObject> symbols =
6168 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); 6171 i::Handle<i::JSObject>::cast(
6169 i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name); 6172 i::Object::GetPropertyOrElement(registry, part));
6173 i::Handle<i::Object> symbol =
6174 i::Object::GetPropertyOrElement(symbols, i_name);
6170 if (!symbol->IsSymbol()) { 6175 if (!symbol->IsSymbol()) {
6171 ASSERT(symbol->IsUndefined()); 6176 ASSERT(symbol->IsUndefined());
6172 symbol = i_isolate->factory()->NewSymbol(); 6177 symbol = i_isolate->factory()->NewSymbol();
6173 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6178 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6174 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); 6179 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT);
6175 } 6180 }
6176 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6181 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6177 } 6182 }
6178 6183
6179 6184
6180 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 6185 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
6181 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6186 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6182 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); 6187 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
6183 LOG_API(i_isolate, "Private::New()"); 6188 LOG_API(i_isolate, "Private::New()");
6184 ENTER_V8(i_isolate); 6189 ENTER_V8(i_isolate);
6185 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); 6190 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
6186 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); 6191 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
6187 Local<Symbol> result = Utils::ToLocal(symbol); 6192 Local<Symbol> result = Utils::ToLocal(symbol);
6188 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6193 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6189 } 6194 }
6190 6195
6191 6196
6192 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { 6197 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) {
6193 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6198 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6194 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6199 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6195 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6200 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6196 i::Handle<i::String> part = i_isolate->factory()->private_api_string(); 6201 i::Handle<i::String> part = i_isolate->factory()->private_api_string();
6197 i::Handle<i::JSObject> privates = 6202 i::Handle<i::JSObject> privates =
6198 i::Handle<i::JSObject>::cast(i::JSObject::GetProperty(registry, part)); 6203 i::Handle<i::JSObject>::cast(
6199 i::Handle<i::Object> symbol = i::JSObject::GetProperty(privates, i_name); 6204 i::Object::GetPropertyOrElement(registry, part));
6205 i::Handle<i::Object> symbol =
6206 i::Object::GetPropertyOrElement(privates, i_name);
6200 if (!symbol->IsSymbol()) { 6207 if (!symbol->IsSymbol()) {
6201 ASSERT(symbol->IsUndefined()); 6208 ASSERT(symbol->IsUndefined());
6202 symbol = i_isolate->factory()->NewPrivateSymbol(); 6209 symbol = i_isolate->factory()->NewPrivateSymbol();
6203 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6210 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6204 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT); 6211 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT);
6205 } 6212 }
6206 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6213 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6207 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6214 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6208 } 6215 }
6209 6216
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
6939 i::Isolate* isolate = i::Isolate::Current(); 6946 i::Isolate* isolate = i::Isolate::Current();
6940 if (!isolate->IsInitialized()) return Local<Value>(); 6947 if (!isolate->IsInitialized()) return Local<Value>();
6941 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); 6948 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
6942 ENTER_V8(isolate); 6949 ENTER_V8(isolate);
6943 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 6950 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
6944 i::Debug* isolate_debug = isolate->debug(); 6951 i::Debug* isolate_debug = isolate->debug();
6945 isolate_debug->Load(); 6952 isolate_debug->Load();
6946 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); 6953 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
6947 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( 6954 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
6948 STATIC_ASCII_VECTOR("MakeMirror")); 6955 STATIC_ASCII_VECTOR("MakeMirror"));
6949 i::Handle<i::Object> fun_obj = i::GetProperty(isolate, debug, name); 6956 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name);
6957 ASSERT(!fun_obj.is_null());
6950 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); 6958 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
6951 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); 6959 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
6952 const int kArgc = 1; 6960 const int kArgc = 1;
6953 v8::Handle<v8::Value> argv[kArgc] = { obj }; 6961 v8::Handle<v8::Value> argv[kArgc] = { obj };
6954 EXCEPTION_PREAMBLE(isolate); 6962 EXCEPTION_PREAMBLE(isolate);
6955 v8::Local<v8::Value> result = 6963 v8::Local<v8::Value> result =
6956 v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); 6964 v8_fun->Call(Utils::ToLocal(debug), kArgc, argv);
6957 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 6965 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
6958 return scope.Escape(result); 6966 return scope.Escape(result);
6959 } 6967 }
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
7635 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7643 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7636 Address callback_address = 7644 Address callback_address =
7637 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7645 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7638 VMState<EXTERNAL> state(isolate); 7646 VMState<EXTERNAL> state(isolate);
7639 ExternalCallbackScope call_scope(isolate, callback_address); 7647 ExternalCallbackScope call_scope(isolate, callback_address);
7640 callback(info); 7648 callback(info);
7641 } 7649 }
7642 7650
7643 7651
7644 } } // namespace v8::internal 7652 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698