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

Side by Side Diff: src/api.cc

Issue 26709011: Expose v8::Function::GetDisplayName to public API. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: fixed test Created 7 years, 1 month 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 | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
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 4092 matching lines...) Expand 10 before | Expand all | Expand 10 after
4103 } 4103 }
4104 4104
4105 4105
4106 Handle<Value> Function::GetInferredName() const { 4106 Handle<Value> Function::GetInferredName() const {
4107 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4107 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4108 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), 4108 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(),
4109 func->GetIsolate())); 4109 func->GetIsolate()));
4110 } 4110 }
4111 4111
4112 4112
4113 Handle<Value> Function::GetDisplayName() const {
4114 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4115 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()",
4116 return ToApiHandle<Primitive>(
4117 isolate->factory()->undefined_value()));
4118 ENTER_V8(isolate);
4119 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4120 i::Handle<i::String> property_name =
4121 isolate->factory()->InternalizeOneByteString(
4122 STATIC_ASCII_VECTOR("displayName"));
4123 i::LookupResult lookup(isolate);
4124 func->LookupRealNamedProperty(*property_name, &lookup);
4125 if (lookup.IsFound()) {
4126 i::Object* value = lookup.GetLazyValue();
4127 if (value && value->IsString()) {
4128 i::String* name = i::String::cast(value);
4129 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name));
4130 }
4131 }
4132 return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
4133 }
4134
4135
4113 ScriptOrigin Function::GetScriptOrigin() const { 4136 ScriptOrigin Function::GetScriptOrigin() const {
4114 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4137 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4115 if (func->shared()->script()->IsScript()) { 4138 if (func->shared()->script()->IsScript()) {
4116 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4139 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4117 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script); 4140 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script);
4118 v8::ScriptOrigin origin( 4141 v8::ScriptOrigin origin(
4119 Utils::ToLocal(scriptName), 4142 Utils::ToLocal(scriptName),
4120 v8::Integer::New(script->line_offset()->value()), 4143 v8::Integer::New(script->line_offset()->value()),
4121 v8::Integer::New(script->column_offset()->value())); 4144 v8::Integer::New(script->column_offset()->value()));
4122 return origin; 4145 return origin;
(...skipping 3426 matching lines...) Expand 10 before | Expand all | Expand 10 after
7549 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7572 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7550 Address callback_address = 7573 Address callback_address =
7551 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7574 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7552 VMState<EXTERNAL> state(isolate); 7575 VMState<EXTERNAL> state(isolate);
7553 ExternalCallbackScope call_scope(isolate, callback_address); 7576 ExternalCallbackScope call_scope(isolate, callback_address);
7554 callback(info); 7577 callback(info);
7555 } 7578 }
7556 7579
7557 7580
7558 } } // namespace v8::internal 7581 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698