1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "tonic/dart_class_provider.h"
6
7#include "tonic/converter/dart_converter.h"
8#include "tonic/dart_state.h"
9#include "tonic/logging/dart_error.h"
10
11namespace tonic {
12
13DartClassProvider::DartClassProvider(DartState* dart_state,
14 const char* class_name) {
15 library_.Set(dart_state, Dart_LookupLibrary(ToDart(class_name)));
16}
17
18DartClassProvider::~DartClassProvider() {}
19
20Dart_Handle DartClassProvider::GetClassByName(const char* class_name) {
21 Dart_Handle name_handle = ToDart(class_name);
22 Dart_Handle class_handle =
23 Dart_GetType(library_.value(), name_handle, 0, nullptr);
24 TONIC_DCHECK(!Dart_IsError(class_handle));
25 return class_handle;
26}
27
28} // namespace tonic
29