[vm] Remove dart_mirrors_api.h.

Its last user was Dartium's DevTools.

Change-Id: I86e1a2aacc7f2589be53418b3030accc0cef9a7d
Reviewed-on: https://dart-review.googlesource.com/53464
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2018-05-02 21:39:27 +00:00 committed by commit-bot@chromium.org
parent 384c55c29e
commit 258c5172df
6 changed files with 0 additions and 681 deletions

View file

@ -182,7 +182,6 @@ source_set("dart_api") {
public_configs = [ ":dart_public_config" ]
sources = [
"include/dart_api.h",
"include/dart_mirrors_api.h",
"include/dart_native_api.h",
"include/dart_tools_api.h",
]
@ -214,11 +213,9 @@ template("libdart_library") {
sources = [
"$target_gen_dir/version.cc",
"include/dart_api.h",
"include/dart_mirrors_api.h",
"include/dart_native_api.h",
"include/dart_tools_api.h",
"vm/dart_api_impl.cc",
"vm/mirrors_api_impl.cc",
"vm/native_api_impl.cc",
"vm/version.h",
]

View file

@ -1,140 +0,0 @@
/*
* Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
#ifndef RUNTIME_INCLUDE_DART_MIRRORS_API_H_
#define RUNTIME_INCLUDE_DART_MIRRORS_API_H_
#include "dart_api.h"
/**
* Returns the simple name for the provided type.
*/
DART_EXPORT Dart_Handle Dart_TypeName(Dart_Handle type);
/**
* Returns the qualified name for the provided type.
*/
DART_EXPORT Dart_Handle Dart_QualifiedTypeName(Dart_Handle type);
/**
* Returns a list of the names of all functions or methods declared in
* a library or class.
*
* \param target A library or class.
*
* \return If no error occurs, a list of strings is returned.
* Otherwise an error handle is returned.
*/
DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target);
/**
* Looks up a function or method declaration by name from a library or
* class.
*
* \param target The library or class containing the function.
* \param function_name The name of the function.
*
* \return If an error is encountered, returns an error handle.
* Otherwise returns a function handle if the function is found of
* Dart_Null() if the function is not found.
*/
DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target,
Dart_Handle function_name);
/**
* Returns the name for the provided function or method.
*
* \return A valid string handle if no error occurs during the
* operation.
*/
DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function);
/**
* Returns a handle to the owner of a function.
*
* The owner of an instance method or a static method is its defining
* class. The owner of a top-level function is its defining
* library. The owner of the function of a non-implicit closure is the
* function of the method or closure that defines the non-implicit
* closure.
*
* \return A valid handle to the owner of the function, or an error
* handle if the argument is not a valid handle to a function.
*/
DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function);
/**
* Determines whether a function handle referes to a static function
* of method.
*
* For the purposes of the embedding API, a top-level function is
* implicitly declared static.
*
* \param function A handle to a function or method declaration.
* \param is_static Returns whether the function or method is declared static.
*
* \return A valid handle if no error occurs during the operation.
*/
DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function,
bool* is_static);
/**
* Determines whether a function handle referes to a constructor.
*
* \param function A handle to a function or method declaration.
* \param is_static Returns whether the function or method is a constructor.
*
* \return A valid handle if no error occurs during the operation.
*/
DART_EXPORT Dart_Handle Dart_FunctionIsConstructor(Dart_Handle function,
bool* is_constructor);
/* TODO(turnidge): Document behavior for factory constructors too. */
/**
* Determines whether a function or method is a getter.
*
* \param function A handle to a function or method declaration.
* \param is_static Returns whether the function or method is a getter.
*
* \return A valid handle if no error occurs during the operation.
*/
DART_EXPORT Dart_Handle Dart_FunctionIsGetter(Dart_Handle function,
bool* is_getter);
/**
* Determines whether a function or method is a setter.
*
* \param function A handle to a function or method declaration.
* \param is_static Returns whether the function or method is a setter.
*
* \return A valid handle if no error occurs during the operation.
*/
DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function,
bool* is_setter);
/**
* Returns the name of a library as declared in the #library directive.
*/
DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library);
/**
* Returns a list of the names of all classes and interfaces declared
* in a library.
*
* \return If no error occurs, a list of strings is returned.
* Otherwise an error handle is returned.
*/
DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library);
/**
* Retrieves the function of a closure.
*
* \return A handle to the function of the closure, or an error handle if the
* argument is not a closure.
*/
DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure);
#endif /* INCLUDE_DART_MIRRORS_API_H_ */ /* NOLINT */

View file

@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
#include "include/dart_api.h"
#include "include/dart_mirrors_api.h"
#include "include/dart_native_api.h"
#include "lib/stacktrace.h"

View file

@ -5,7 +5,6 @@
#include "vm/dart_api_impl.h"
#include "bin/builtin.h"
#include "include/dart_api.h"
#include "include/dart_mirrors_api.h"
#include "include/dart_native_api.h"
#include "include/dart_tools_api.h"
#include "platform/assert.h"
@ -775,18 +774,6 @@ TEST_CASE(DartAPI_InstanceGetType) {
const Type& bool_type_obj = Api::UnwrapTypeHandle(zone, type);
EXPECT(bool_type_obj.raw() == Type::BoolType());
Dart_Handle cls_name = Dart_TypeName(type);
EXPECT_VALID(cls_name);
const char* cls_name_cstr = "";
EXPECT_VALID(Dart_StringToCString(cls_name, &cls_name_cstr));
EXPECT_STREQ("bool", cls_name_cstr);
Dart_Handle qual_cls_name = Dart_QualifiedTypeName(type);
EXPECT_VALID(qual_cls_name);
const char* qual_cls_name_cstr = "";
EXPECT_VALID(Dart_StringToCString(qual_cls_name, &qual_cls_name_cstr));
EXPECT_STREQ("Library:'dart:core' Class: bool", qual_cls_name_cstr);
// Errors propagate.
Dart_Handle error = Dart_NewApiError("MyError");
Dart_Handle error_type = Dart_InstanceGetType(error);
@ -5706,13 +5693,6 @@ TEST_CASE(DartAPI_RootLibrary) {
EXPECT_VALID(LoadScript(TestCase::url(), kScriptChars));
root_lib = Dart_RootLibrary();
Dart_Handle lib_name = Dart_LibraryName(root_lib);
EXPECT_VALID(lib_name);
EXPECT(!Dart_IsNull(root_lib));
const char* name_cstr = "";
EXPECT_VALID(Dart_StringToCString(lib_name, &name_cstr));
EXPECT_STREQ("testlib", name_cstr);
Dart_Handle lib_uri = Dart_LibraryUrl(root_lib);
EXPECT_VALID(lib_uri);
EXPECT(!Dart_IsNull(lib_uri));
@ -5852,72 +5832,6 @@ TEST_CASE(DartAPI_LookupLibrary) {
Dart_GetError(result));
}
TEST_CASE(DartAPI_LibraryName) {
const char* kLibrary1Chars = "library library1_name;";
Dart_Handle lib = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
Dart_Handle error = Dart_NewApiError("incoming error");
EXPECT_VALID(lib);
Dart_Handle result = Dart_LibraryName(Dart_Null());
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LibraryName expects argument 'library' to be non-null.",
Dart_GetError(result));
result = Dart_LibraryName(Dart_True());
EXPECT(Dart_IsError(result));
EXPECT_STREQ(
"Dart_LibraryName expects argument 'library' to be of type Library.",
Dart_GetError(result));
result = Dart_LibraryName(error);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("incoming error", Dart_GetError(result));
result = Dart_LibraryName(lib);
EXPECT_VALID(result);
EXPECT(Dart_IsString(result));
const char* cstr = NULL;
EXPECT_VALID(Dart_StringToCString(result, &cstr));
EXPECT_STREQ("library1_name", cstr);
}
#ifndef PRODUCT
TEST_CASE(DartAPI_LibraryId) {
const char* kLibrary1Chars = "library library1_name;";
Dart_Handle lib = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
Dart_Handle error = Dart_NewApiError("incoming error");
EXPECT_VALID(lib);
intptr_t libraryId = -1;
Dart_Handle result = Dart_LibraryId(Dart_Null(), &libraryId);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LibraryId expects argument 'library' to be non-null.",
Dart_GetError(result));
result = Dart_LibraryId(Dart_True(), &libraryId);
EXPECT(Dart_IsError(result));
EXPECT_STREQ(
"Dart_LibraryId expects argument 'library' to be of type Library.",
Dart_GetError(result));
result = Dart_LibraryId(error, &libraryId);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("incoming error", Dart_GetError(result));
result = Dart_LibraryId(lib, &libraryId);
EXPECT_VALID(result);
Dart_Handle libFromId = Dart_GetLibraryFromId(libraryId);
EXPECT(Dart_IsLibrary(libFromId));
result = Dart_LibraryName(libFromId);
EXPECT(Dart_IsString(result));
const char* cstr = NULL;
EXPECT_VALID(Dart_StringToCString(result, &cstr));
EXPECT_STREQ("library1_name", cstr);
}
#endif // !PRODUCT
TEST_CASE(DartAPI_LibraryUrl) {
const char* kLibrary1Chars = "library library1_name;";
Dart_Handle lib = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
@ -5947,111 +5861,6 @@ TEST_CASE(DartAPI_LibraryUrl) {
EXPECT_SUBSTRING("library1_url", cstr);
}
TEST_CASE(DartAPI_LibraryGetClassNames) {
const char* kLibraryChars =
"library library_name;\n"
"\n"
"class A {}\n"
"class B {}\n"
"abstract class C {}\n"
"class _A {}\n"
"class _B {}\n"
"abstract class _C {}\n"
"\n"
"int _compare(dynamic a, dynamic b) => a.compareTo(b);\n"
"sort(list) => list.sort(_compare);\n";
Dart_Handle lib = TestCase::LoadTestLibrary("library_url", kLibraryChars);
EXPECT_VALID(lib);
Dart_Handle result = Dart_FinalizeLoading(false);
EXPECT_VALID(result);
Dart_Handle list = Dart_LibraryGetClassNames(lib);
EXPECT_VALID(list);
EXPECT(Dart_IsList(list));
// Sort the list.
const int kNumArgs = 1;
Dart_Handle args[1];
args[0] = list;
EXPECT_VALID(Dart_Invoke(lib, NewString("sort"), kNumArgs, args));
Dart_Handle list_string = Dart_ToString(list);
EXPECT_VALID(list_string);
const char* list_cstr = "";
EXPECT_VALID(Dart_StringToCString(list_string, &list_cstr));
EXPECT_STREQ("[A, B, C, _A, _B, _C]", list_cstr);
}
TEST_CASE(DartAPI_GetFunctionNames) {
const char* kLibraryChars =
"library library_name;\n"
"\n"
"void A() {}\n"
"get B => 11;\n"
"set C(x) { }\n"
"var D;\n"
"void _A() {}\n"
"get _B => 11;\n"
"set _C(x) { }\n"
"var _D;\n"
"\n"
"class MyClass {\n"
" void A2() {}\n"
" get B2 => 11;\n"
" set C2(x) { }\n"
" var D2;\n"
" void _A2() {}\n"
" get _B2 => 11;\n"
" set _C2(x) { }\n"
" var _D2;\n"
"}\n"
"\n"
"int _compare(dynamic a, dynamic b) => a.compareTo(b);\n"
"sort(list) => list.sort(_compare);\n";
// Get the functions from a library.
Dart_Handle lib = TestCase::LoadTestScript(kLibraryChars, NULL);
EXPECT_VALID(lib);
Dart_Handle result = Dart_FinalizeLoading(false);
EXPECT_VALID(result);
Dart_Handle list = Dart_GetFunctionNames(lib);
EXPECT_VALID(list);
EXPECT(Dart_IsList(list));
// Sort the list.
const int kNumArgs = 1;
Dart_Handle args[1];
args[0] = list;
EXPECT_VALID(Dart_Invoke(lib, NewString("sort"), kNumArgs, args));
Dart_Handle list_string = Dart_ToString(list);
EXPECT_VALID(list_string);
const char* list_cstr = "";
EXPECT_VALID(Dart_StringToCString(list_string, &list_cstr));
EXPECT_STREQ("[A, B, C=, _A, _B, _C=, _compare, sort]", list_cstr);
// Get the functions from a class.
Dart_Handle cls = Dart_GetClass(lib, NewString("MyClass"));
EXPECT_VALID(cls);
list = Dart_GetFunctionNames(cls);
EXPECT_VALID(list);
EXPECT(Dart_IsList(list));
// Sort the list.
args[0] = list;
EXPECT_VALID(Dart_Invoke(lib, NewString("sort"), kNumArgs, args));
// Check list contents.
list_string = Dart_ToString(list);
EXPECT_VALID(list_string);
list_cstr = "";
EXPECT_VALID(Dart_StringToCString(list_string, &list_cstr));
EXPECT_STREQ("[A2, B2, C2=, MyClass, _A2, _B2, _C2=]", list_cstr);
}
TEST_CASE(DartAPI_LibraryImportLibrary) {
const char* kLibrary1Chars = "library library1_name;";
const char* kLibrary2Chars = "library library2_name;";

View file

@ -1,344 +0,0 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "include/dart_mirrors_api.h"
#include "platform/assert.h"
#include "vm/class_finalizer.h"
#include "vm/dart.h"
#include "vm/dart_api_impl.h"
#include "vm/dart_api_state.h"
#include "vm/dart_entry.h"
#include "vm/exceptions.h"
#include "vm/growable_array.h"
#include "vm/object.h"
#include "vm/resolver.h"
#include "vm/stack_frame.h"
#include "vm/symbols.h"
namespace dart {
// Facilitate quick access to the current zone once we have the current thread.
#define Z (T->zone())
// --- Classes and Interfaces Reflection ---
DART_EXPORT Dart_Handle Dart_TypeName(Dart_Handle object) {
DARTSCOPE(Thread::Current());
const Object& obj = Object::Handle(Z, Api::UnwrapHandle(object));
if (obj.IsType()) {
const Class& cls = Class::Handle(Type::Cast(obj).type_class());
return Api::NewHandle(T, cls.UserVisibleName());
} else {
RETURN_TYPE_ERROR(Z, object, Class / Type);
}
}
DART_EXPORT Dart_Handle Dart_QualifiedTypeName(Dart_Handle object) {
DARTSCOPE(Thread::Current());
const Object& obj = Object::Handle(Z, Api::UnwrapHandle(object));
if (obj.IsType() || obj.IsClass()) {
const Class& cls = (obj.IsType())
? Class::Handle(Z, Type::Cast(obj).type_class())
: Class::Cast(obj);
const char* str = cls.ToCString();
if (str == NULL) {
RETURN_NULL_ERROR(str);
}
CHECK_CALLBACK_STATE(T);
return Api::NewHandle(T, String::New(str));
} else {
RETURN_TYPE_ERROR(Z, object, Class / Type);
}
}
// --- Function and Variable Reflection ---
// Outside of the vm, we expose setter names with a trailing '='.
static bool HasExternalSetterSuffix(const String& name) {
return name.CharAt(name.Length() - 1) == '=';
}
static RawString* RemoveExternalSetterSuffix(const String& name) {
ASSERT(HasExternalSetterSuffix(name));
return String::SubString(name, 0, name.Length() - 1);
}
DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target) {
DARTSCOPE(Thread::Current());
const Object& obj = Object::Handle(Z, Api::UnwrapHandle(target));
if (obj.IsError()) {
return target;
}
const GrowableObjectArray& names =
GrowableObjectArray::Handle(Z, GrowableObjectArray::New());
Function& func = Function::Handle(Z);
String& name = String::Handle(Z);
if (obj.IsType()) {
const Class& cls = Class::Handle(Z, Type::Cast(obj).type_class());
const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T));
if (!error.IsNull()) {
return Api::NewHandle(T, error.raw());
}
const Array& func_array = Array::Handle(Z, cls.functions());
// Some special types like 'dynamic' have a null functions list.
if (!func_array.IsNull()) {
for (intptr_t i = 0; i < func_array.Length(); ++i) {
func ^= func_array.At(i);
// Skip implicit getters and setters.
if (func.kind() == RawFunction::kImplicitGetter ||
func.kind() == RawFunction::kImplicitSetter ||
func.kind() == RawFunction::kImplicitStaticFinalGetter ||
func.kind() == RawFunction::kMethodExtractor ||
func.kind() == RawFunction::kNoSuchMethodDispatcher) {
continue;
}
name = func.UserVisibleName();
names.Add(name);
}
}
} else if (obj.IsLibrary()) {
const Library& lib = Library::Cast(obj);
DictionaryIterator it(lib);
Object& obj = Object::Handle();
while (it.HasNext()) {
obj = it.GetNext();
if (obj.IsFunction()) {
func ^= obj.raw();
name = func.UserVisibleName();
names.Add(name);
}
}
} else {
return Api::NewError(
"%s expects argument 'target' to be a class or library.", CURRENT_FUNC);
}
return Api::NewHandle(T, Array::MakeFixedLength(names));
}
DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target,
Dart_Handle function_name) {
DARTSCOPE(Thread::Current());
const Object& obj = Object::Handle(Z, Api::UnwrapHandle(target));
if (obj.IsError()) {
return target;
}
const String& func_name = Api::UnwrapStringHandle(Z, function_name);
if (func_name.IsNull()) {
RETURN_TYPE_ERROR(Z, function_name, String);
}
Function& func = Function::Handle(Z);
String& tmp_name = String::Handle(Z);
if (obj.IsType()) {
const Class& cls = Class::Handle(Z, Type::Cast(obj).type_class());
// Case 1. Lookup the unmodified function name.
func = cls.LookupFunctionAllowPrivate(func_name);
// Case 2. Lookup the function without the external setter suffix
// '='. Make sure to do this check after the regular lookup, so
// that we don't interfere with operator lookups (like ==).
if (func.IsNull() && HasExternalSetterSuffix(func_name)) {
tmp_name = RemoveExternalSetterSuffix(func_name);
tmp_name = Field::SetterName(tmp_name);
func = cls.LookupFunctionAllowPrivate(tmp_name);
}
// Case 3. Lookup the function with the getter prefix prepended.
if (func.IsNull()) {
tmp_name = Field::GetterName(func_name);
func = cls.LookupFunctionAllowPrivate(tmp_name);
}
// Case 4. Lookup the function with a . appended to find the
// unnamed constructor.
if (func.IsNull()) {
tmp_name = String::Concat(func_name, Symbols::Dot());
func = cls.LookupFunctionAllowPrivate(tmp_name);
}
} else if (obj.IsLibrary()) {
const Library& lib = Library::Cast(obj);
// Case 1. Lookup the unmodified function name.
func = lib.LookupFunctionAllowPrivate(func_name);
// Case 2. Lookup the function without the external setter suffix
// '='. Make sure to do this check after the regular lookup, so
// that we don't interfere with operator lookups (like ==).
if (func.IsNull() && HasExternalSetterSuffix(func_name)) {
tmp_name = RemoveExternalSetterSuffix(func_name);
tmp_name = Field::SetterName(tmp_name);
func = lib.LookupFunctionAllowPrivate(tmp_name);
}
// Case 3. Lookup the function with the getter prefix prepended.
if (func.IsNull()) {
tmp_name = Field::GetterName(func_name);
func = lib.LookupFunctionAllowPrivate(tmp_name);
}
} else {
return Api::NewError(
"%s expects argument 'target' to be a class or library.", CURRENT_FUNC);
}
#if defined(DEBUG)
if (!func.IsNull()) {
// We only provide access to a subset of function kinds.
RawFunction::Kind func_kind = func.kind();
ASSERT(func_kind == RawFunction::kRegularFunction ||
func_kind == RawFunction::kGetterFunction ||
func_kind == RawFunction::kSetterFunction ||
func_kind == RawFunction::kConstructor);
}
#endif
return Api::NewHandle(T, func.raw());
}
DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function) {
DARTSCOPE(Thread::Current());
const Function& func = Api::UnwrapFunctionHandle(Z, function);
if (func.IsNull()) {
RETURN_TYPE_ERROR(Z, function, Function);
}
return Api::NewHandle(T, func.UserVisibleName());
}
DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function) {
DARTSCOPE(Thread::Current());
const Function& func = Api::UnwrapFunctionHandle(Z, function);
if (func.IsNull()) {
RETURN_TYPE_ERROR(Z, function, Function);
}
if (func.IsNonImplicitClosureFunction()) {
RawFunction* parent_function = func.parent_function();
return Api::NewHandle(T, parent_function);
}
const Class& owner = Class::Handle(Z, func.Owner());
ASSERT(!owner.IsNull());
if (owner.IsTopLevel()) {
// Top-level functions are implemented as members of a hidden class. We hide
// that class here and instead answer the library.
#if defined(DEBUG)
const Library& lib = Library::Handle(Z, owner.library());
if (lib.IsNull()) {
ASSERT(owner.IsDynamicClass() || owner.IsVoidClass());
}
#endif
return Api::NewHandle(T, owner.library());
} else {
return Api::NewHandle(T, owner.RareType());
}
}
DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function,
bool* is_static) {
DARTSCOPE(Thread::Current());
if (is_static == NULL) {
RETURN_NULL_ERROR(is_static);
}
const Function& func = Api::UnwrapFunctionHandle(Z, function);
if (func.IsNull()) {
RETURN_TYPE_ERROR(Z, function, Function);
}
*is_static = func.is_static();
return Api::Success();
}
DART_EXPORT Dart_Handle Dart_FunctionIsConstructor(Dart_Handle function,
bool* is_constructor) {
DARTSCOPE(Thread::Current());
if (is_constructor == NULL) {
RETURN_NULL_ERROR(is_constructor);
}
const Function& func = Api::UnwrapFunctionHandle(Z, function);
if (func.IsNull()) {
RETURN_TYPE_ERROR(Z, function, Function);
}
*is_constructor = func.kind() == RawFunction::kConstructor;
return Api::Success();
}
DART_EXPORT Dart_Handle Dart_FunctionIsGetter(Dart_Handle function,
bool* is_getter) {
DARTSCOPE(Thread::Current());
if (is_getter == NULL) {
RETURN_NULL_ERROR(is_getter);
}
const Function& func = Api::UnwrapFunctionHandle(Z, function);
if (func.IsNull()) {
RETURN_TYPE_ERROR(Z, function, Function);
}
*is_getter = func.IsGetterFunction();
return Api::Success();
}
DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function,
bool* is_setter) {
DARTSCOPE(Thread::Current());
if (is_setter == NULL) {
RETURN_NULL_ERROR(is_setter);
}
const Function& func = Api::UnwrapFunctionHandle(Z, function);
if (func.IsNull()) {
RETURN_TYPE_ERROR(Z, function, Function);
}
*is_setter = (func.kind() == RawFunction::kSetterFunction);
return Api::Success();
}
// --- Libraries Reflection ---
DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library) {
DARTSCOPE(Thread::Current());
const Library& lib = Api::UnwrapLibraryHandle(Z, library);
if (lib.IsNull()) {
RETURN_TYPE_ERROR(Z, library, Library);
}
const String& name = String::Handle(Z, lib.name());
ASSERT(!name.IsNull());
return Api::NewHandle(T, name.raw());
}
DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library) {
DARTSCOPE(Thread::Current());
const Library& lib = Api::UnwrapLibraryHandle(Z, library);
if (lib.IsNull()) {
RETURN_TYPE_ERROR(Z, library, Library);
}
const GrowableObjectArray& names =
GrowableObjectArray::Handle(Z, GrowableObjectArray::New());
ClassDictionaryIterator it(lib);
Class& cls = Class::Handle(Z);
String& name = String::Handle(Z);
while (it.HasNext()) {
cls = it.GetNextClass();
name = cls.UserVisibleName();
names.Add(name);
}
return Api::NewHandle(T, Array::MakeFixedLength(names));
}
// --- Closures Reflection ---
DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure) {
DARTSCOPE(Thread::Current());
const Instance& closure_obj = Api::UnwrapInstanceHandle(Z, closure);
if (closure_obj.IsNull() || !closure_obj.IsClosure()) {
RETURN_TYPE_ERROR(Z, closure, Instance);
}
ASSERT(ClassFinalizer::AllClassesFinalized());
RawFunction* rf = Closure::Cast(closure_obj).function();
return Api::NewHandle(T, rf);
}
} // namespace dart

View file

@ -53,7 +53,6 @@ declare_args() {
#.............templates/
# ....include/
# ......dart_api.h
# ......dart_mirrors_api.h
# ......dart_native_api.h
# ......dart_tools_api.h
# ....lib/
@ -761,7 +760,6 @@ copy("copy_headers") {
visibility = [ ":create_common_sdk" ]
sources = [
"../runtime/include/dart_api.h",
"../runtime/include/dart_mirrors_api.h",
"../runtime/include/dart_native_api.h",
"../runtime/include/dart_tools_api.h",
]