Flutter Engine
tonic::DartState Class Reference

#include <dart_state.h>

Inheritance diagram for tonic::DartState:
flutter::UIDartState flutter::DartIsolate

Classes

class  Scope
 

Public Member Functions

 DartState (int dirfd=-1, std::function< void(Dart_Handle)> message_epilogue=nullptr)
 
virtual ~DartState ()
 
std::weak_ptr< DartStateGetWeakPtr ()
 
Dart_Isolate isolate ()
 
void SetIsolate (Dart_Isolate isolate)
 
Dart_PersistentHandle private_constructor_name ()
 
DartClassLibraryclass_library ()
 
DartMessageHandlermessage_handler ()
 
FileLoaderfile_loader ()
 
void MessageEpilogue (Dart_Handle message_result)
 
void SetReturnCode (uint32_t return_code)
 
void SetReturnCodeCallback (std::function< void(uint32_t)> callback)
 
bool has_set_return_code () const
 
virtual void DidSetIsolate ()
 

Static Public Member Functions

static DartStateFrom (Dart_Isolate isolate)
 
static DartStateCurrent ()
 
static Dart_Handle HandleLibraryTag (Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
 

Protected Member Functions

 TONIC_DISALLOW_COPY_AND_ASSIGN (DartState)
 

Detailed Description

Definition at line 27 of file dart_state.h.

Constructor & Destructor Documentation

◆ DartState()

tonic::DartState::DartState ( int  dirfd = -1,
std::function< void(Dart_Handle)>  message_epilogue = nullptr 
)

Definition at line 22 of file dart_state.cc.

24  : isolate_(nullptr),
25  private_constructor_name_(),
26  class_library_(new DartClassLibrary),
27  message_handler_(new DartMessageHandler()),
28  file_loader_(new FileLoader(dirfd)),
29  message_epilogue_(message_epilogue),
30  has_set_return_code_(false) {}

◆ ~DartState()

tonic::DartState::~DartState ( )
virtual

Definition at line 32 of file dart_state.cc.

32 {}

Member Function Documentation

◆ class_library()

DartClassLibrary& tonic::DartState::class_library ( )
inline

◆ Current()

◆ DidSetIsolate()

void tonic::DartState::DidSetIsolate ( )
virtual

Definition at line 76 of file dart_state.cc.

Referenced by has_set_return_code(), and SetIsolate().

76 {}

◆ file_loader()

FileLoader& tonic::DartState::file_loader ( )
inline

Definition at line 60 of file dart_state.h.

Referenced by HandleLibraryTag().

60 { return *file_loader_; }

◆ From()

DartState * tonic::DartState::From ( Dart_Isolate  isolate)
static

Definition at line 49 of file dart_state.cc.

Referenced by tonic::DartMessageHandler::OnHandleMessage().

49  {
50  auto isolate_data =
51  static_cast<std::shared_ptr<DartState>*>(Dart_IsolateData(isolate));
52  return isolate_data->get();
53 }
Dart_Isolate isolate()
Definition: dart_state.h:49

◆ GetWeakPtr()

std::weak_ptr< DartState > tonic::DartState::GetWeakPtr ( )

Definition at line 61 of file dart_state.cc.

Referenced by tonic::DartMessageHandler::OnMessage(), and tonic::DartPersistentValue::Set().

61  {
62  return shared_from_this();
63 }

◆ HandleLibraryTag()

Dart_Handle tonic::DartState::HandleLibraryTag ( Dart_LibraryTag  tag,
Dart_Handle  library,
Dart_Handle  url 
)
static

Definition at line 78 of file dart_state.cc.

References Current(), file_loader(), and tonic::FileLoader::HandleLibraryTag().

Referenced by flutter::DartIsolate::GetServiceId(), has_set_return_code(), and flutter::DartIsolate::Shutdown().

80  {
81  return Current()->file_loader().HandleLibraryTag(tag, library, url);
82 }
static DartState * Current()
Definition: dart_state.cc:55
Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
Definition: file_loader.cc:118
FileLoader & file_loader()
Definition: dart_state.h:60

◆ has_set_return_code()

bool tonic::DartState::has_set_return_code ( ) const
inline

Definition at line 69 of file dart_state.h.

References DidSetIsolate(), HandleLibraryTag(), and TONIC_DISALLOW_COPY_AND_ASSIGN().

Referenced by tonic::DartMessageHandler::OnHandleMessage().

69 { return has_set_return_code_; }

◆ isolate()

◆ message_handler()

DartMessageHandler& tonic::DartState::message_handler ( )
inline

◆ MessageEpilogue()

void tonic::DartState::MessageEpilogue ( Dart_Handle  message_result)
inline

Definition at line 62 of file dart_state.h.

References function, SetReturnCode(), and SetReturnCodeCallback().

Referenced by tonic::DartMessageHandler::OnHandleMessage().

62  {
63  if (message_epilogue_) {
64  message_epilogue_(message_result);
65  }
66  }

◆ private_constructor_name()

Dart_PersistentHandle tonic::DartState::private_constructor_name ( )
inline

Definition at line 54 of file dart_state.h.

Referenced by tonic::DartWrappable::CreateDartWrapper().

54  {
55  return private_constructor_name_.Get();
56  }

◆ SetIsolate()

void tonic::DartState::SetIsolate ( Dart_Isolate  isolate)

Definition at line 34 of file dart_state.cc.

References tonic::DartPersistentValue::Clear(), DidSetIsolate(), isolate(), and tonic::DartPersistentValue::Set().

Referenced by flutter::DartIsolate::GetServiceId(), and isolate().

34  {
35  isolate_ = isolate;
36 
37  if (!isolate_)
38  return;
39 
40  private_constructor_name_.Clear();
41  Dart_EnterScope();
42  private_constructor_name_.Set(
43  this, Dart_NewPersistentHandle(Dart_NewStringFromCString("_")));
44  Dart_ExitScope();
45 
46  DidSetIsolate();
47 }
Dart_Isolate isolate()
Definition: dart_state.h:49
void Set(DartState *dart_state, Dart_Handle value)
virtual void DidSetIsolate()
Definition: dart_state.cc:76

◆ SetReturnCode()

void tonic::DartState::SetReturnCode ( uint32_t  return_code)

Definition at line 65 of file dart_state.cc.

Referenced by MessageEpilogue().

65  {
66  if (set_return_code_callback_) {
67  set_return_code_callback_(return_code);
68  }
69  has_set_return_code_ = true;
70 }

◆ SetReturnCodeCallback()

void tonic::DartState::SetReturnCodeCallback ( std::function< void(uint32_t)>  callback)

Definition at line 72 of file dart_state.cc.

Referenced by MessageEpilogue().

72  {
73  set_return_code_callback_ = callback;
74 }

◆ TONIC_DISALLOW_COPY_AND_ASSIGN()

tonic::DartState::TONIC_DISALLOW_COPY_AND_ASSIGN ( DartState  )
protected

Referenced by has_set_return_code().


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