V8 Project
v8::TypeSwitch Class Reference

A utility for determining the type of objects based on the template they were constructed from. More...

#include <v8.h>

+ Inheritance diagram for v8::TypeSwitch:
+ Collaboration diagram for v8::TypeSwitch:

Public Member Functions

int match (Handle< Value > value)
 

Static Public Member Functions

static Local< TypeSwitchNew (Handle< FunctionTemplate > type)
 
static Local< TypeSwitchNew (int argc, Handle< FunctionTemplate > types[])
 

Private Member Functions

 TypeSwitch ()
 

Detailed Description

A utility for determining the type of objects based on the template they were constructed from.

Definition at line 3979 of file v8.h.

Constructor & Destructor Documentation

◆ TypeSwitch()

v8::TypeSwitch::TypeSwitch ( )
private

Member Function Documentation

◆ match()

int v8::TypeSwitch::match ( v8::Handle< Value value)

Definition at line 1086 of file api.cc.

1086  {
1087  i::Isolate* isolate = i::Isolate::Current();
1088  LOG_API(isolate, "TypeSwitch::match");
1089  USE(isolate);
1092  i::FixedArray* types = i::FixedArray::cast(info->types());
1093  for (int i = 0; i < types->length(); i++) {
1094  if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj))
1095  return i + 1;
1096  }
1097  return 0;
1098 }
#define LOG_API(isolate, expr)
Definition: api.cc:52
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288
Object * get(int index)
Definition: objects-inl.h:2165
void USE(T)
Definition: macros.h:322

References v8::internal::FixedArray::get(), v8::internal::FixedArrayBase::length(), LOG_API, v8::Utils::OpenHandle(), and USE().

+ Here is the call graph for this function:

◆ New() [1/2]

Local< TypeSwitch > v8::TypeSwitch::New ( Handle< FunctionTemplate type)
static

Definition at line 1064 of file api.cc.

1064  {
1065  Handle<FunctionTemplate> types[1] = { type };
1066  return TypeSwitch::New(1, types);
1067 }
static Local< TypeSwitch > New(Handle< FunctionTemplate > type)
Definition: api.cc:1064

◆ New() [2/2]

Local< TypeSwitch > v8::TypeSwitch::New ( int  argc,
Handle< FunctionTemplate types[] 
)
static

Definition at line 1070 of file api.cc.

1070  {
1071  i::Isolate* isolate = i::Isolate::Current();
1072  LOG_API(isolate, "TypeSwitch::New");
1073  ENTER_V8(isolate);
1074  i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
1075  for (int i = 0; i < argc; i++)
1076  vector->set(i, *Utils::OpenHandle(*types[i]));
1077  i::Handle<i::Struct> struct_obj =
1078  isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE);
1081  obj->set_types(*vector);
1082  return Utils::ToLocal(obj);
1083 }
#define ENTER_V8(isolate)
Definition: api.cc:54
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
Factory * factory()
Definition: isolate.h:982
@ TYPE_SWITCH_INFO_TYPE
Definition: objects.h:706

References v8::internal::Handle< T >::cast(), ENTER_V8, v8::internal::Isolate::factory(), LOG_API, v8::Utils::OpenHandle(), v8::Utils::ToLocal(), and v8::internal::TYPE_SWITCH_INFO_TYPE.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: