⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 api.cc.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
  i::Handle<i::CallHandlerInfo> obj =      i::Handle<i::CallHandlerInfo>::cast(struct_obj);  obj->set_callback(*FromCData(callback));  if (data.IsEmpty()) data = v8::Undefined();  obj->set_data(*Utils::OpenHandle(*data));  Utils::OpenHandle(this)->set_instance_call_handler(*obj);}// --- O b j e c t T e m p l a t e ---Local<ObjectTemplate> ObjectTemplate::New() {  return New(Local<FunctionTemplate>());}Local<ObjectTemplate> ObjectTemplate::New(      v8::Handle<FunctionTemplate> constructor) {  if (IsDeadCheck("v8::ObjectTemplate::New()")) return Local<ObjectTemplate>();  EnsureInitialized("v8::ObjectTemplate::New()");  LOG_API("ObjectTemplate::New");  i::Handle<i::Struct> struct_obj =      i::Factory::NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);  i::Handle<i::ObjectTemplateInfo> obj =      i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);  InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);  if (!constructor.IsEmpty())    obj->set_constructor(*Utils::OpenHandle(*constructor));  obj->set_internal_field_count(i::Smi::FromInt(0));  return Utils::ToLocal(obj);}// Ensure that the object template has a constructor.  If no// constructor is available we create one.static void EnsureConstructor(ObjectTemplate* object_template) {  if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) {    Local<FunctionTemplate> templ = FunctionTemplate::New();    i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);    constructor->set_instance_template(*Utils::OpenHandle(object_template));    Utils::OpenHandle(object_template)->set_constructor(*constructor);  }}void ObjectTemplate::SetAccessor(v8::Handle<String> name,                                 AccessorGetter getter,                                 AccessorSetter setter,                                 v8::Handle<Value> data,                                 AccessControl settings,                                 PropertyAttribute attribute) {  if (IsDeadCheck("v8::ObjectTemplate::SetAccessor()")) return;  HandleScope scope;  EnsureConstructor(this);  i::FunctionTemplateInfo* constructor =      i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());  i::Handle<i::FunctionTemplateInfo> cons(constructor);  Utils::ToLocal(cons)->AddInstancePropertyAccessor(name,                                                    getter,                                                    setter,                                                    data,                                                    settings,                                                    attribute);}void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter,                                             NamedPropertySetter setter,                                             NamedPropertyQuery query,                                             NamedPropertyDeleter remover,                                             NamedPropertyEnumerator enumerator,                                             Handle<Value> data) {  if (IsDeadCheck("v8::ObjectTemplate::SetNamedPropertyHandler()")) return;  HandleScope scope;  EnsureConstructor(this);  i::FunctionTemplateInfo* constructor =      i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());  i::Handle<i::FunctionTemplateInfo> cons(constructor);  Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter,                                                        setter,                                                        query,                                                        remover,                                                        enumerator,                                                        data);}void ObjectTemplate::MarkAsUndetectable() {  if (IsDeadCheck("v8::ObjectTemplate::MarkAsUndetectable()")) return;  HandleScope scope;  EnsureConstructor(this);  i::FunctionTemplateInfo* constructor =      i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());  i::Handle<i::FunctionTemplateInfo> cons(constructor);  cons->set_undetectable(true);}void ObjectTemplate::SetAccessCheckCallbacks(      NamedSecurityCallback named_callback,      IndexedSecurityCallback indexed_callback,      Handle<Value> data) {  if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return;  HandleScope scope;  EnsureConstructor(this);  i::Handle<i::Struct> struct_info =      i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE);  i::Handle<i::AccessCheckInfo> info =      i::Handle<i::AccessCheckInfo>::cast(struct_info);  info->set_named_callback(*FromCData(named_callback));  info->set_indexed_callback(*FromCData(indexed_callback));  if (data.IsEmpty()) data = v8::Undefined();  info->set_data(*Utils::OpenHandle(*data));  i::FunctionTemplateInfo* constructor =      i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());  i::Handle<i::FunctionTemplateInfo> cons(constructor);  cons->set_needs_access_check(true);  cons->set_access_check_info(*info);}void ObjectTemplate::SetIndexedPropertyHandler(      IndexedPropertyGetter getter,      IndexedPropertySetter setter,      IndexedPropertyQuery query,      IndexedPropertyDeleter remover,      IndexedPropertyEnumerator enumerator,      Handle<Value> data) {  if (IsDeadCheck("v8::ObjectTemplate::SetIndexedPropertyHandler()")) return;  HandleScope scope;  EnsureConstructor(this);  i::FunctionTemplateInfo* constructor =      i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());  i::Handle<i::FunctionTemplateInfo> cons(constructor);  Utils::ToLocal(cons)->SetIndexedInstancePropertyHandler(getter,                                                          setter,                                                          query,                                                          remover,                                                          enumerator,                                                          data);}void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback,                                              Handle<Value> data) {  if (IsDeadCheck("v8::ObjectTemplate::SetCallAsFunctionHandler()")) return;  HandleScope scope;  EnsureConstructor(this);  i::FunctionTemplateInfo* constructor =      i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());  i::Handle<i::FunctionTemplateInfo> cons(constructor);  Utils::ToLocal(cons)->SetInstanceCallAsFunctionHandler(callback, data);}int ObjectTemplate::InternalFieldCount() {  if (IsDeadCheck("v8::ObjectTemplate::InternalFieldCount()")) {    return 0;  }  return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();}void ObjectTemplate::SetInternalFieldCount(int value) {  if (IsDeadCheck("v8::ObjectTemplate::SetInternalFieldCount()")) return;  if (!ApiCheck(i::Smi::IsValid(value),                "v8::ObjectTemplate::SetInternalFieldCount()",                "Invalid internal field count")) {    return;  }  if (value > 0) {    // The internal field count is set by the constructor function's    // construct code, so we ensure that there is a constructor    // function to do the setting.    EnsureConstructor(this);  }  Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));}// --- S c r i p t D a t a ---ScriptData* ScriptData::PreCompile(const char* input, int length) {  unibrow::Utf8InputBuffer<> buf(input, length);  return i::PreParse(&buf, NULL);}ScriptData* ScriptData::New(unsigned* data, int length) {  return new i::ScriptDataImpl(i::Vector<unsigned>(data, length));}// --- S c r i p t ---Local<Script> Script::Compile(v8::Handle<String> source,                              v8::ScriptOrigin* origin,                              v8::ScriptData* script_data) {  ON_BAILOUT("v8::Script::Compile()", return Local<Script>());  LOG_API("Script::Compile");  i::Handle<i::String> str = Utils::OpenHandle(*source);  i::Handle<i::Object> name_obj;  int line_offset = 0;  int column_offset = 0;  if (origin != NULL) {    if (!origin->ResourceName().IsEmpty()) {      name_obj = Utils::OpenHandle(*origin->ResourceName());    }    if (!origin->ResourceLineOffset().IsEmpty()) {      line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());    }    if (!origin->ResourceColumnOffset().IsEmpty()) {      column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value());    }  }  EXCEPTION_PREAMBLE();  i::ScriptDataImpl* pre_data = static_cast<i::ScriptDataImpl*>(script_data);  // We assert that the pre-data is sane, even though we can actually  // handle it if it turns out not to be in release mode.  ASSERT(pre_data == NULL || pre_data->SanityCheck());  // If the pre-data isn't sane we simply ignore it  if (pre_data != NULL && !pre_data->SanityCheck())    pre_data = NULL;  i::Handle<i::JSFunction> boilerplate = i::Compiler::Compile(str,                                                              name_obj,                                                              line_offset,                                                              column_offset,                                                              NULL,                                                              pre_data);  has_pending_exception = boilerplate.is_null();  EXCEPTION_BAILOUT_CHECK(Local<Script>());  i::Handle<i::JSFunction> result =      i::Factory::NewFunctionFromBoilerplate(boilerplate,                                             i::Top::global_context());  return Local<Script>(ToApi<Script>(result));}Local<Script> Script::Compile(v8::Handle<String> source,                              v8::Handle<Value> file_name) {  ScriptOrigin origin(file_name);  return Compile(source, &origin);}Local<Value> Script::Run() {  ON_BAILOUT("v8::Script::Run()", return Local<Value>());  LOG_API("Script::Run");  i::Object* raw_result = NULL;  {    HandleScope scope;    i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);    EXCEPTION_PREAMBLE();    i::Handle<i::Object> global(i::Top::context()->global());    i::Handle<i::Object> result =        i::Execution::Call(fun, global, 0, NULL, &has_pending_exception);    EXCEPTION_BAILOUT_CHECK(Local<Value>());    raw_result = *result;  }  i::Handle<i::Object> result(raw_result);  return Utils::ToLocal(result);}// --- E x c e p t i o n s ---v8::TryCatch::TryCatch()    : next_(i::Top::try_catch_handler()),      exception_(i::Heap::the_hole_value()),      message_(i::Smi::FromInt(0)),      is_verbose_(false),      capture_message_(true) {  i::Top::RegisterTryCatchHandler(this);}v8::TryCatch::~TryCatch() {  i::Top::UnregisterTryCatchHandler(this);}bool v8::TryCatch::HasCaught() {  return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();}v8::Local<Value> v8::TryCatch::Exception() {  if (HasCaught()) {    // Check for out of memory exception.    i::Object* exception = reinterpret_cast<i::Object*>(exception_);    return v8::Utils::ToLocal(i::Handle<i::Object>(exception));  } else {    return v8::Local<Value>();  }}v8::Local<v8::Message> v8::TryCatch::Message() {  if (HasCaught() && message_ != i::Smi::FromInt(0)) {    i::Object* message = reinterpret_cast<i::Object*>(message_);    return v8::Utils::MessageToLocal(i::Handle<i::Object>(message));  } else {    return v8::Local<v8::Message>();  }}void v8::TryCatch::Reset() {  exception_ = i::Heap::the_hole_value();  message_ = i::Smi::FromInt(0);}void v8::TryCatch::SetVerbose(bool value) {  is_verbose_ = value;}void v8::TryCatch::SetCaptureMessage(bool value) {  capture_message_ = value;}// --- M e s s a g e ---Local<String> Message::Get() {  ON_BAILOUT("v8::Message::Get()", return Local<String>());  HandleScope scope;  i::Handle<i::Object> obj = Utils::OpenHandle(this);  i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj);  Local<String> result = Utils::ToLocal(raw_result);  return scope.Close(result);}v8::Handle<String> Message::GetScriptResourceName() {  if (IsDeadCheck("v8::Message::GetScriptResourceName()")) {    return Local<String>();  }  HandleScope scope;  i::Handle<i::JSObject> obj =      i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));  // Return this.script.name.  i::Handle<i::JSValue> script =      i::Handle<i::JSValue>::cast(GetProperty(obj, "script"));  i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name());  if (!resource_name->IsString()) {    return Local<String>();  }  Local<String> result =      Utils::ToLocal(i::Handle<i::String>::cast(resource_name));  return scope.Close(result);}// TODO(1240903): Remove this when no longer used in WebKit V8 bindings.Handle<Value> Message::GetSourceData() {  Handle<String> data = GetScriptResourceName();  if (data.IsEmpty()) return v8::Undefined();  return data;}static i::Handle<i::Object> CallV8HeapFunction(const char* name,                                               i::Handle<i::Object> recv,                                               int argc,                                               i::Object** argv[],                                               bool* has_pending_exception) {  i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name);  i::Object* object_fun = i::Top::builtins()->GetProperty(*fmt_str);  i::Handle<i::JSFunction> fun =      i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun));  i::Handle<i::Object> value =      i::Execution::Call(fun, recv, argc, argv, has_pending_exception);  return value;}static i::Handle<i::Object> CallV8HeapFunction(const char* name,                                               i::Handle<i::Object> data,                                               bool* has_pending_exception) {  i::Object** argv[1] = { data.location() };  return CallV8HeapFunction(name,                            i::Top::builtins(),                            1,                            argv,                            has_pending_exception);}int Message::GetLineNumber() {  ON_BAILOUT("v8::Message::GetLineNumber()", return -1);  HandleScope scope;  EXCEPTION_PREAMBLE();  i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",                                                   Utils::OpenHandle(this),                                                   &has_pending_exception);  EXCEPTION_BAILOUT_CHECK(0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -