Fixes related to the switch to using std::shared_ptr/weak_ptr instead of using FXL pointers
The Dart isolate's embedder data will now need to be a std::shared_ptr<DartState>*
instead of a DartState*
Change-Id: Ic344f861b5073d8453b1feab05592dc10e59732b
diff --git a/dart_state.cc b/dart_state.cc
index 03ca2e9..6b9c265 100644
--- a/dart_state.cc
+++ b/dart_state.cc
@@ -25,8 +25,7 @@
message_handler_(new DartMessageHandler()),
file_loader_(new FileLoader(dirfd)),
message_epilogue_(message_epilogue),
- has_set_return_code_(false),
- weak_factory_(this) {}
+ has_set_return_code_(false) {}
DartState::~DartState() {}
@@ -38,11 +37,15 @@
}
DartState* DartState::From(Dart_Isolate isolate) {
- return static_cast<DartState*>(Dart_IsolateData(isolate));
+ auto isolate_data = static_cast<std::shared_ptr<DartState>*>(
+ Dart_IsolateData(isolate));
+ return isolate_data->get();
}
DartState* DartState::Current() {
- return static_cast<DartState*>(Dart_CurrentIsolateData());
+ auto isolate_data = static_cast<std::shared_ptr<DartState>*>(
+ Dart_CurrentIsolateData());
+ return isolate_data->get();
}
std::weak_ptr<DartState> DartState::GetWeakPtr() {
diff --git a/dart_state.h b/dart_state.h
index 830a4b9..1c0b774 100644
--- a/dart_state.h
+++ b/dart_state.h
@@ -21,7 +21,7 @@
// DartState represents the state associated with a given Dart isolate. The
// lifetime of this object is controlled by the DartVM. If you want to hold a
-// reference to a DartState instance, please hold a tonic::WeakPtr<DartState>.
+// reference to a DartState instance, please hold a std::weak_ptr<DartState>.
//
// DartState is analogous to gin::PerIsolateData and JSC::ExecState.
class DartState : public std::enable_shared_from_this<DartState> {