mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:39:49 +00:00
Rename Api::NewLocalHandle -> Api::NewHandle.
Api::NewHandle now takes a RawObject* intead of an Object&. - This makes the code shorter and easier to read. - This allows us to drop the DARTSCOPE from Dart_GetNativeArgument. (6% speedup on Benchmark_UseDartApi) Review URL: https://chromiumcodereview.appspot.com//10014002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6283 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
1125846660
commit
9731c1c254
|
@ -81,13 +81,12 @@ const char* CheckIsolateState(Isolate* isolate, bool generating_snapshot) {
|
|||
|
||||
|
||||
void SetupErrorResult(Isolate* isolate, Dart_Handle* handle) {
|
||||
const Error& error = Error::Handle(
|
||||
*handle = Api::NewHandle(
|
||||
isolate, Isolate::Current()->object_store()->sticky_error());
|
||||
*handle = Api::NewLocalHandle(isolate, error);
|
||||
}
|
||||
|
||||
|
||||
Dart_Handle Api::NewLocalHandle(Isolate* isolate, const Object& object) {
|
||||
Dart_Handle Api::NewHandle(Isolate* isolate, RawObject* raw) {
|
||||
ASSERT(isolate != NULL);
|
||||
ApiState* state = isolate->api_state();
|
||||
ASSERT(state != NULL);
|
||||
|
@ -96,7 +95,7 @@ Dart_Handle Api::NewLocalHandle(Isolate* isolate, const Object& object) {
|
|||
LocalHandles* local_handles = scope->local_handles();
|
||||
ASSERT(local_handles != NULL);
|
||||
LocalHandle* ref = local_handles->AllocateHandle();
|
||||
ref->set_raw(object);
|
||||
ref->set_raw(raw);
|
||||
return reinterpret_cast<Dart_Handle>(ref);
|
||||
}
|
||||
|
||||
|
@ -191,8 +190,7 @@ Dart_Handle Api::NewError(const char* format, ...) {
|
|||
va_end(args2);
|
||||
|
||||
const String& message = String::Handle(isolate, String::New(buffer));
|
||||
const Object& obj = Object::Handle(isolate, ApiError::New(message));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, ApiError::New(message));
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,8 +295,7 @@ DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle) {
|
|||
if (obj.IsUnhandledException()) {
|
||||
UnhandledException& error = UnhandledException::Handle(isolate);
|
||||
error ^= obj.raw();
|
||||
const Object& exception = Object::Handle(isolate, error.exception());
|
||||
return Api::NewLocalHandle(isolate, exception);
|
||||
return Api::NewHandle(isolate, error.exception());
|
||||
} else if (obj.IsError()) {
|
||||
return Api::NewError("This error is not an unhandled exception error.");
|
||||
} else {
|
||||
|
@ -314,8 +311,7 @@ DART_EXPORT Dart_Handle Dart_ErrorGetStacktrace(Dart_Handle handle) {
|
|||
if (obj.IsUnhandledException()) {
|
||||
UnhandledException& error = UnhandledException::Handle(isolate);
|
||||
error ^= obj.raw();
|
||||
const Object& stacktrace = Object::Handle(isolate, error.stacktrace());
|
||||
return Api::NewLocalHandle(isolate, stacktrace);
|
||||
return Api::NewHandle(isolate, error.stacktrace());
|
||||
} else if (obj.IsError()) {
|
||||
return Api::NewError("This error is not an unhandled exception error.");
|
||||
} else {
|
||||
|
@ -342,8 +338,7 @@ DART_EXPORT Dart_Handle Dart_Error(const char* format, ...) {
|
|||
va_end(args2);
|
||||
|
||||
const String& message = String::Handle(isolate, String::New(buffer));
|
||||
const Object& obj = Object::Handle(isolate, ApiError::New(message));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, ApiError::New(message));
|
||||
}
|
||||
|
||||
|
||||
|
@ -388,18 +383,16 @@ DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object) {
|
|||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
|
||||
Object& result = Object::Handle(isolate);
|
||||
if (obj.IsString()) {
|
||||
result = obj.raw();
|
||||
return Api::NewHandle(isolate, obj.raw());
|
||||
} else if (obj.IsInstance()) {
|
||||
Instance& receiver = Instance::Handle(isolate);
|
||||
receiver ^= obj.raw();
|
||||
result = DartLibraryCalls::ToString(receiver);
|
||||
return Api::NewHandle(isolate, DartLibraryCalls::ToString(receiver));
|
||||
} else {
|
||||
// This is a VM internal object. Call the C++ method of printing.
|
||||
result = String::New(obj.ToCString());
|
||||
return Api::NewHandle(isolate, String::New(obj.ToCString()));
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -780,7 +773,7 @@ DART_EXPORT Dart_Handle Dart_RunLoop() {
|
|||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(isolate, isolate->StandardRunLoop());
|
||||
if (obj.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, obj.raw());
|
||||
}
|
||||
ASSERT(obj.IsNull());
|
||||
return Api::Success(isolate);
|
||||
|
@ -824,7 +817,7 @@ DART_EXPORT Dart_Handle Dart_HandleMessage() {
|
|||
delete message;
|
||||
if (result.IsError()) {
|
||||
// TODO(turnidge): Propagating the error is probably wrong here.
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
}
|
||||
ASSERT(result.IsNull());
|
||||
} else {
|
||||
|
@ -834,7 +827,7 @@ DART_EXPORT Dart_Handle Dart_HandleMessage() {
|
|||
message->dest_port(), message->reply_port(), msg));
|
||||
delete message;
|
||||
if (result.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
}
|
||||
ASSERT(result.IsNull());
|
||||
}
|
||||
|
@ -930,9 +923,7 @@ DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) {
|
|||
DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& result =
|
||||
Object::Handle(isolate, DartLibraryCalls::NewSendPort(port_id));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
|
||||
}
|
||||
|
||||
|
||||
|
@ -959,9 +950,8 @@ DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) {
|
|||
Resolver::kIsQualified));
|
||||
GrowableArray<const Object*> arguments(kNumArguments);
|
||||
arguments.Add(&Integer::Handle(isolate, Integer::New(port_id)));
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate, DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1048,7 +1038,7 @@ DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2,
|
|||
*value = b.value();
|
||||
return Api::Success(isolate);
|
||||
} else if (result.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
} else {
|
||||
return Api::NewError("Expected boolean result from ==");
|
||||
}
|
||||
|
@ -1153,8 +1143,7 @@ DART_EXPORT Dart_Handle Dart_IntegerFitsIntoUint64(Dart_Handle integer,
|
|||
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Integer& obj = Integer::Handle(isolate, Integer::New(value));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, Integer::New(value));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1162,8 +1151,7 @@ DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* str) {
|
|||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& str_obj = String::Handle(isolate, String::New(str));
|
||||
const Integer& obj = Integer::Handle(isolate, Integer::New(str_obj));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, Integer::New(str_obj));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1304,8 +1292,7 @@ DART_EXPORT bool Dart_IsDouble(Dart_Handle object) {
|
|||
DART_EXPORT Dart_Handle Dart_NewDouble(double value) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Double& obj = Double::Handle(isolate, Double::New(value));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, Double::New(value));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1367,8 +1354,7 @@ DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len) {
|
|||
DART_EXPORT Dart_Handle Dart_NewString(const char* str) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& obj = String::Handle(isolate, String::New(str));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, String::New(str));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1376,8 +1362,7 @@ DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints,
|
|||
intptr_t length) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& obj = String::Handle(isolate, String::New(codepoints, length));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, String::New(codepoints, length));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1385,8 +1370,7 @@ DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints,
|
|||
intptr_t length) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& obj = String::Handle(isolate, String::New(codepoints, length));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, String::New(codepoints, length));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1394,8 +1378,7 @@ DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
|
|||
intptr_t length) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& obj = String::Handle(isolate, String::New(codepoints, length));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, String::New(codepoints, length));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1446,10 +1429,8 @@ DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints,
|
|||
return Api::NewError("%s expects argument 'length' to be greater than 0.",
|
||||
CURRENT_FUNC);
|
||||
}
|
||||
const String& obj =
|
||||
String::Handle(isolate,
|
||||
String::NewExternal(codepoints, length, peer, callback));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(
|
||||
isolate, String::NewExternal(codepoints, length, peer, callback));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1467,10 +1448,8 @@ DART_EXPORT Dart_Handle Dart_NewExternalString16(const uint16_t* codepoints,
|
|||
return Api::NewError("%s expects argument 'length' to be greater than 0.",
|
||||
CURRENT_FUNC);
|
||||
}
|
||||
const String& obj =
|
||||
String::Handle(isolate,
|
||||
String::NewExternal(codepoints, length, peer, callback));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(
|
||||
isolate, String::NewExternal(codepoints, length, peer, callback));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1488,10 +1467,8 @@ DART_EXPORT Dart_Handle Dart_NewExternalString32(const uint32_t* codepoints,
|
|||
return Api::NewError("%s expects argument 'length' to be greater than 0.",
|
||||
CURRENT_FUNC);
|
||||
}
|
||||
const String& obj =
|
||||
String::Handle(isolate,
|
||||
String::NewExternal(codepoints, length, peer, callback));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(
|
||||
isolate, String::NewExternal(codepoints, length, peer, callback));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1622,8 +1599,7 @@ DART_EXPORT bool Dart_IsList(Dart_Handle object) {
|
|||
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Array& obj = Array::Handle(isolate, Array::New(length));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, Array::New(length));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1679,7 +1655,7 @@ DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) {
|
|||
"maximum value that 'len' parameter can hold");
|
||||
}
|
||||
} else if (retval.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, retval);
|
||||
return Api::NewHandle(isolate, retval.raw());
|
||||
} else {
|
||||
return Api::NewError("Length of List object is not an integer");
|
||||
}
|
||||
|
@ -1694,8 +1670,7 @@ DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index) {
|
|||
Array& array_obj = Array::Handle(isolate);
|
||||
array_obj ^= obj.raw();
|
||||
if ((index >= 0) && (index < array_obj.Length())) {
|
||||
const Object& element = Object::Handle(isolate, array_obj.At(index));
|
||||
return Api::NewLocalHandle(isolate, element);
|
||||
return Api::NewHandle(isolate, array_obj.At(index));
|
||||
}
|
||||
return Api::NewError("Invalid index passed in to access array element");
|
||||
}
|
||||
|
@ -1714,10 +1689,9 @@ DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index) {
|
|||
indexobj = Integer::New(index);
|
||||
args.Add(&indexobj);
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(instance, function, args, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
|
@ -1760,10 +1734,9 @@ DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list,
|
|||
args.Add(&index_obj);
|
||||
args.Add(&value_obj);
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(instance, function, args, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
|
@ -1828,7 +1801,7 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
|
|||
result = DartEntry::InvokeDynamic(
|
||||
instance, function, args, kNoArgumentNames);
|
||||
if (result.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
}
|
||||
if (!result.IsInteger()) {
|
||||
return Api::NewError("%s expects the argument 'list' to be "
|
||||
|
@ -1903,7 +1876,7 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
|
|||
DartEntry::InvokeDynamic(
|
||||
instance, function, args, kNoArgumentNames));
|
||||
if (result.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
}
|
||||
}
|
||||
return Api::Success(isolate);
|
||||
|
@ -1927,9 +1900,7 @@ DART_EXPORT bool Dart_IsByteArray(Dart_Handle object) {
|
|||
DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const InternalByteArray& obj =
|
||||
InternalByteArray::Handle(isolate, InternalByteArray::New(length));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(isolate, InternalByteArray::New(length));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1947,13 +1918,8 @@ DART_EXPORT Dart_Handle Dart_NewExternalByteArray(uint8_t* data,
|
|||
return Api::NewError("%s expects argument 'length' to be greater than 0.",
|
||||
CURRENT_FUNC);
|
||||
}
|
||||
const ExternalByteArray& obj =
|
||||
ExternalByteArray::Handle(isolate,
|
||||
ExternalByteArray::New(data,
|
||||
length,
|
||||
peer,
|
||||
callback));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
return Api::NewHandle(
|
||||
isolate, ExternalByteArray::New(data, length, peer, callback));
|
||||
}
|
||||
|
||||
|
||||
|
@ -2186,10 +2152,9 @@ DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
|
|||
dart_arguments.Add(&arg);
|
||||
}
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeClosure(closure_obj, dart_arguments, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2240,7 +2205,7 @@ DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
|
|||
Object::Handle(isolate, Api::UnwrapHandle(arguments[i]));
|
||||
if (!arg.IsNull() && !arg.IsInstance()) {
|
||||
if (arg.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, arg);
|
||||
return Api::NewHandle(isolate, arg.raw());
|
||||
} else {
|
||||
return Api::NewError(
|
||||
"%s expects argument %d to be an instance of Object.",
|
||||
|
@ -2272,10 +2237,9 @@ DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
|
|||
cls_name.ToCString(),
|
||||
function_name.ToCString());
|
||||
}
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(instance, function, dart_args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
|
||||
} else if (obj.IsClass()) {
|
||||
// Finalize all classes.
|
||||
|
@ -2300,10 +2264,9 @@ DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
|
|||
cls_name.ToCString(),
|
||||
function_name.ToCString());
|
||||
}
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeStatic(function, dart_args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
|
||||
} else if (obj.IsLibrary()) {
|
||||
// Check whether class finalization is needed.
|
||||
|
@ -2334,9 +2297,8 @@ DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
|
|||
CURRENT_FUNC,
|
||||
function_name.ToCString());
|
||||
}
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate, DartEntry::InvokeStatic(function, dart_args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
|
||||
} else {
|
||||
return Api::NewError(
|
||||
|
@ -2416,10 +2378,9 @@ DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in,
|
|||
dart_arguments.Add(&arg);
|
||||
}
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeStatic(function, dart_arguments, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2464,11 +2425,10 @@ DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle object,
|
|||
dart_arguments.Add(&arg);
|
||||
}
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(
|
||||
receiver, function, dart_arguments, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2511,14 +2471,14 @@ static Dart_Handle LookupStaticField(Isolate* isolate,
|
|||
const Function& function =
|
||||
Function::Handle(isolate, cls.LookupStaticFunction(func_name));
|
||||
if (!function.IsNull()) {
|
||||
return Api::NewLocalHandle(isolate, function);
|
||||
return Api::NewHandle(isolate, function.raw());
|
||||
}
|
||||
return Api::NewError("Specified field is not found in the class");
|
||||
}
|
||||
if (fld.IsNull()) {
|
||||
return Api::NewError("Specified field is not found in the class");
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, fld);
|
||||
return Api::NewHandle(isolate, fld.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -2549,7 +2509,7 @@ static Dart_Handle LookupInstanceField(Isolate* isolate,
|
|||
if (function.IsNull()) {
|
||||
return Api::NewError("Unable to find accessor function in the class");
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, function);
|
||||
return Api::NewHandle(isolate, function.raw());
|
||||
}
|
||||
cls = cls.SuperClass();
|
||||
}
|
||||
|
@ -2598,10 +2558,9 @@ DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name) {
|
|||
// Invoke the getter and return the result.
|
||||
GrowableArray<const Object*> args;
|
||||
const Array& kNoArgNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(instance, getter, args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
|
||||
} else if (obj.IsClass()) {
|
||||
// To access a static field we may need to use the Field or the
|
||||
|
@ -2619,12 +2578,10 @@ DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name) {
|
|||
// Invoke the getter and return the result.
|
||||
GrowableArray<const Object*> args;
|
||||
const Array& kNoArgNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate, DartEntry::InvokeStatic(getter, args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
} else if (!field.IsNull()) {
|
||||
const Object& result = Object::Handle(isolate, field.value());
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, field.value());
|
||||
} else {
|
||||
return Api::NewError("%s: did not find static field '%s'.",
|
||||
CURRENT_FUNC, field_name.ToCString());
|
||||
|
@ -2654,12 +2611,10 @@ DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name) {
|
|||
// Invoke the getter and return the result.
|
||||
GrowableArray<const Object*> args;
|
||||
const Array& kNoArgNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate, DartEntry::InvokeStatic(getter, args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
} else if (!field.IsNull()) {
|
||||
const Object& result = Object::Handle(isolate, field.value());
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, field.value());
|
||||
} else {
|
||||
return Api::NewError("%s: did not find top-level variable '%s'.",
|
||||
CURRENT_FUNC, field_name.ToCString());
|
||||
|
@ -2729,10 +2684,9 @@ DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container,
|
|||
GrowableArray<const Object*> args(1);
|
||||
args.Add(&value_instance);
|
||||
const Array& kNoArgNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(instance, setter, args, kNoArgNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
|
||||
} else if (obj.IsClass()) {
|
||||
// To access a static field we may need to use the Field or the
|
||||
|
@ -2755,7 +2709,7 @@ DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container,
|
|||
isolate,
|
||||
DartEntry::InvokeStatic(setter, args, kNoArgNames));
|
||||
if (result.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
} else {
|
||||
return Api::Success(isolate);
|
||||
}
|
||||
|
@ -2793,7 +2747,7 @@ DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container,
|
|||
const Object& result = Object::Handle(
|
||||
isolate, DartEntry::InvokeStatic(setter, args, kNoArgNames));
|
||||
if (result.IsError()) {
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
return Api::NewHandle(isolate, result.raw());
|
||||
} else {
|
||||
return Api::Success(isolate);
|
||||
}
|
||||
|
@ -2826,21 +2780,18 @@ DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls,
|
|||
if (::Dart_IsError(result)) {
|
||||
return result;
|
||||
}
|
||||
Object& retval = Object::Handle(isolate);
|
||||
const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(result));
|
||||
if (obj.IsField()) {
|
||||
Field& fld = Field::Handle(isolate);
|
||||
fld ^= obj.raw();
|
||||
retval = fld.value();
|
||||
return Api::NewLocalHandle(isolate, retval);
|
||||
return Api::NewHandle(isolate, fld.value());
|
||||
} else {
|
||||
Function& func = Function::Handle(isolate);
|
||||
func ^= obj.raw();
|
||||
GrowableArray<const Object*> args;
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& result = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate, DartEntry::InvokeStatic(func, args, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2866,7 +2817,7 @@ DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls,
|
|||
Instance& instance = Instance::Handle(isolate);
|
||||
instance ^= val.raw();
|
||||
fld.set_value(instance);
|
||||
return Api::NewLocalHandle(isolate, val);
|
||||
return Api::NewHandle(isolate, val.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -2888,10 +2839,9 @@ DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
|
|||
func ^= Api::UnwrapHandle(result);
|
||||
GrowableArray<const Object*> arguments;
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& retval = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(object, func, arguments, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, retval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2916,10 +2866,9 @@ DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
|
|||
const Object& arg = Object::Handle(isolate, Api::UnwrapHandle(value));
|
||||
arguments.Add(&arg);
|
||||
const Array& kNoArgumentNames = Array::Handle(isolate);
|
||||
const Object& retval = Object::Handle(
|
||||
return Api::NewHandle(
|
||||
isolate,
|
||||
DartEntry::InvokeDynamic(object, func, arguments, kNoArgumentNames));
|
||||
return Api::NewLocalHandle(isolate, retval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2948,7 +2897,7 @@ DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
|
|||
return Api::NewError(
|
||||
"Unable to create native wrapper class : already exists");
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, cls);
|
||||
return Api::NewHandle(isolate, cls.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -3053,15 +3002,13 @@ DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
|
|||
CURRENT_FUNC, arguments->Count() - 1, index);
|
||||
}
|
||||
Isolate* isolate = arguments->isolate();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(isolate, arguments->At(index));
|
||||
return Api::NewLocalHandle(isolate, obj);
|
||||
CHECK_ISOLATE(isolate);
|
||||
return Api::NewHandle(isolate, arguments->At(index));
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) {
|
||||
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
|
||||
CHECK_ISOLATE(arguments->isolate());
|
||||
return arguments->Count();
|
||||
}
|
||||
|
||||
|
@ -3097,12 +3044,12 @@ static void CompileSource(Isolate* isolate,
|
|||
ASSERT(isolate != NULL);
|
||||
const Error& error = Error::Handle(isolate, Compiler::Compile(lib, script));
|
||||
if (error.IsNull()) {
|
||||
*result = Api::NewLocalHandle(isolate, lib);
|
||||
*result = Api::NewHandle(isolate, lib.raw());
|
||||
if (update_lib_status) {
|
||||
lib.SetLoaded();
|
||||
}
|
||||
} else {
|
||||
*result = Api::NewLocalHandle(isolate, error);
|
||||
*result = Api::NewHandle(isolate, error.raw());
|
||||
if (update_lib_status) {
|
||||
lib.SetLoadError();
|
||||
}
|
||||
|
@ -3181,7 +3128,7 @@ DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer) {
|
|||
}
|
||||
library ^= tmp.raw();
|
||||
isolate->object_store()->set_root_library(library);
|
||||
return Api::NewLocalHandle(isolate, library);
|
||||
return Api::NewHandle(isolate, library.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -3191,7 +3138,7 @@ static void CompileAll(Isolate* isolate, Dart_Handle* result) {
|
|||
if (error.IsNull()) {
|
||||
*result = Api::Success(isolate);
|
||||
} else {
|
||||
*result = Api::NewLocalHandle(isolate, error);
|
||||
*result = Api::NewHandle(isolate, error.raw());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3237,7 +3184,7 @@ DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name) {
|
|||
return Api::NewError("Class '%s' not found in library '%s'.",
|
||||
cls_name.ToCString(), lib_name.ToCString());
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, cls);
|
||||
return Api::NewHandle(isolate, cls.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -3250,7 +3197,7 @@ DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library) {
|
|||
}
|
||||
const String& url = String::Handle(isolate, lib.url());
|
||||
ASSERT(!url.IsNull());
|
||||
return Api::NewLocalHandle(isolate, url);
|
||||
return Api::NewHandle(isolate, url.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -3267,7 +3214,7 @@ DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) {
|
|||
return Api::NewError("%s: library '%s' not found.",
|
||||
CURRENT_FUNC, url_str.ToCString());
|
||||
} else {
|
||||
return Api::NewLocalHandle(isolate, library);
|
||||
return Api::NewHandle(isolate, library.raw());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void SetupErrorResult(Dart_Handle* handle);
|
|||
class Api : AllStatic {
|
||||
public:
|
||||
// Creates a new local handle.
|
||||
static Dart_Handle NewLocalHandle(Isolate* isolate, const Object& object);
|
||||
static Dart_Handle NewHandle(Isolate* isolate, RawObject* raw);
|
||||
|
||||
// Unwraps the raw object from the handle.
|
||||
static RawObject* UnwrapHandle(Dart_Handle object);
|
||||
|
|
|
@ -165,10 +165,8 @@ TEST_CASE(IsSame) {
|
|||
{
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE_NOCHECKS(isolate);
|
||||
const Object& cls1 = Object::Handle(Object::null_class());
|
||||
const Object& cls2 = Object::Handle(Object::class_class());
|
||||
Dart_Handle class1 = Api::NewLocalHandle(isolate, cls1);
|
||||
Dart_Handle class2 = Api::NewLocalHandle(isolate, cls2);
|
||||
Dart_Handle class1 = Api::NewHandle(isolate, Object::null_class());
|
||||
Dart_Handle class2 = Api::NewHandle(isolate, Object::class_class());
|
||||
|
||||
EXPECT_VALID(Dart_IsSame(class1, class1, &same));
|
||||
EXPECT(same);
|
||||
|
@ -1129,7 +1127,7 @@ UNIT_TEST_CASE(EnterExitScope) {
|
|||
EXPECT(state->top_scope() != NULL);
|
||||
DARTSCOPE_NOCHECKS(isolate);
|
||||
const String& str1 = String::Handle(String::New("Test String"));
|
||||
Dart_Handle ref = Api::NewLocalHandle(isolate, str1);
|
||||
Dart_Handle ref = Api::NewHandle(isolate, str1.raw());
|
||||
String& str2 = String::Handle();
|
||||
str2 ^= Api::UnwrapHandle(ref);
|
||||
EXPECT(str1.Equals(str2));
|
||||
|
@ -1153,14 +1151,12 @@ UNIT_TEST_CASE(PersistentHandles) {
|
|||
Dart_EnterScope();
|
||||
{
|
||||
DARTSCOPE_NOCHECKS(isolate);
|
||||
const String& str1 = String::Handle(String::New(kTestString1));
|
||||
Dart_Handle ref1 = Api::NewLocalHandle(isolate, str1);
|
||||
Dart_Handle ref1 = Api::NewHandle(isolate, String::New(kTestString1));
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
handles[i] = Dart_NewPersistentHandle(ref1);
|
||||
}
|
||||
Dart_EnterScope();
|
||||
const String& str2 = String::Handle(String::New(kTestString2));
|
||||
Dart_Handle ref2 = Api::NewLocalHandle(isolate, str2);
|
||||
Dart_Handle ref2 = Api::NewHandle(isolate, String::New(kTestString2));
|
||||
for (int i = 1000; i < 2000; i++) {
|
||||
handles[i] = Dart_NewPersistentHandle(ref2);
|
||||
}
|
||||
|
@ -1257,9 +1253,7 @@ TEST_CASE(WeakPersistentHandle) {
|
|||
{
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& str =
|
||||
String::Handle(String::New("old string", Heap::kOld));
|
||||
old_ref = Api::NewLocalHandle(isolate, str);
|
||||
old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld));
|
||||
EXPECT_VALID(old_ref);
|
||||
}
|
||||
|
||||
|
@ -1394,34 +1388,33 @@ TEST_CASE(ObjectGroups) {
|
|||
{
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
String& str = String::Handle();
|
||||
|
||||
str ^= String::New("strongly reachable", Heap::kOld);
|
||||
strong = Dart_NewPersistentHandle(Api::NewLocalHandle(isolate, str));
|
||||
strong = Dart_NewPersistentHandle(
|
||||
Api::NewHandle(isolate, String::New("strongly reachable", Heap::kOld)));
|
||||
EXPECT_VALID(strong);
|
||||
EXPECT(!Dart_IsNull(strong));
|
||||
|
||||
str ^= String::New("weakly reachable 1", Heap::kOld);
|
||||
weak1 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT_VALID(weak1);
|
||||
EXPECT(!Dart_IsNull(weak1));
|
||||
|
||||
str ^= String::New("weakly reachable 2", Heap::kOld);
|
||||
weak2 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT_VALID(weak2);
|
||||
EXPECT(!Dart_IsNull(weak2));
|
||||
|
||||
str ^= String::New("weakly reachable 3", Heap::kOld);
|
||||
weak3 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT_VALID(weak3);
|
||||
EXPECT(!Dart_IsNull(weak3));
|
||||
|
||||
str ^= String::New("weakly reachable 4", Heap::kOld);
|
||||
weak4 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT_VALID(weak4);
|
||||
EXPECT(!Dart_IsNull(weak4));
|
||||
}
|
||||
|
@ -1577,18 +1570,18 @@ TEST_CASE(PrologueWeakPersistentHandles) {
|
|||
{
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
String& str = String::Handle();
|
||||
str ^= String::New("new space prologue weak", Heap::kNew);
|
||||
new_pwph = Dart_NewPrologueWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate,
|
||||
String::New("new space prologue weak", Heap::kNew)),
|
||||
NULL, NULL);
|
||||
EXPECT_VALID(new_pwph);
|
||||
EXPECT(!Dart_IsNull(new_pwph));
|
||||
str ^= String::New("old space prologue weak", Heap::kOld);
|
||||
old_pwph = Dart_NewPrologueWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate,
|
||||
String::New("old space prologue weak", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT_VALID(old_pwph);
|
||||
EXPECT(!Dart_IsNull(old_pwph));
|
||||
str ^= String::null();
|
||||
}
|
||||
Dart_ExitScope();
|
||||
EXPECT_VALID(new_pwph);
|
||||
|
@ -1643,28 +1636,27 @@ TEST_CASE(ImplicitReferences) {
|
|||
{
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
String& str = String::Handle();
|
||||
|
||||
str ^= String::New("strongly reachable", Heap::kOld);
|
||||
strong = Dart_NewPersistentHandle(Api::NewLocalHandle(isolate, str));
|
||||
strong = Dart_NewPersistentHandle(
|
||||
Api::NewHandle(isolate, String::New("strongly reachable", Heap::kOld)));
|
||||
EXPECT(!Dart_IsNull(strong));
|
||||
EXPECT_VALID(strong);
|
||||
|
||||
str ^= String::New("weakly reachable 1", Heap::kOld);
|
||||
weak1 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT(!Dart_IsNull(weak1));
|
||||
EXPECT_VALID(weak1);
|
||||
|
||||
str ^= String::New("weakly reachable 2", Heap::kOld);
|
||||
weak2 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT(!Dart_IsNull(weak2));
|
||||
EXPECT_VALID(weak2);
|
||||
|
||||
str ^= String::New("weakly reachable 3", Heap::kOld);
|
||||
weak3 = Dart_NewWeakPersistentHandle(
|
||||
Api::NewLocalHandle(isolate, str), NULL, NULL);
|
||||
Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)),
|
||||
NULL, NULL);
|
||||
EXPECT(!Dart_IsNull(weak3));
|
||||
EXPECT_VALID(weak3);
|
||||
}
|
||||
|
@ -1984,8 +1976,7 @@ UNIT_TEST_CASE(LocalHandles) {
|
|||
// Start a new scope and allocate some local handles.
|
||||
Dart_EnterScope();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
val ^= Smi::New(i);
|
||||
handles[i] = Api::NewLocalHandle(isolate, val);
|
||||
handles[i] = Api::NewHandle(isolate, Smi::New(i));
|
||||
}
|
||||
EXPECT_EQ(100, state->CountLocalHandles());
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
@ -1996,8 +1987,7 @@ UNIT_TEST_CASE(LocalHandles) {
|
|||
{
|
||||
Dart_EnterScope();
|
||||
for (int i = 100; i < 200; i++) {
|
||||
val ^= Smi::New(i);
|
||||
handles[i] = Api::NewLocalHandle(isolate, val);
|
||||
handles[i] = Api::NewHandle(isolate, Smi::New(i));
|
||||
}
|
||||
EXPECT_EQ(200, state->CountLocalHandles());
|
||||
for (int i = 100; i < 200; i++) {
|
||||
|
@ -2009,8 +1999,7 @@ UNIT_TEST_CASE(LocalHandles) {
|
|||
{
|
||||
Dart_EnterScope();
|
||||
for (int i = 200; i < 300; i++) {
|
||||
val ^= Smi::New(i);
|
||||
handles[i] = Api::NewLocalHandle(isolate, val);
|
||||
handles[i] = Api::NewHandle(isolate, Smi::New(i));
|
||||
}
|
||||
EXPECT_EQ(300, state->CountLocalHandles());
|
||||
for (int i = 200; i < 300; i++) {
|
||||
|
@ -3543,8 +3532,7 @@ TEST_CASE(NullReceiver) {
|
|||
|
||||
Dart_Handle function_name = Dart_NewString("toString");
|
||||
const int number_of_arguments = 0;
|
||||
Dart_Handle null_receiver = Api::NewLocalHandle(isolate, Object::Handle());
|
||||
Dart_Handle result = Dart_InvokeDynamic(null_receiver,
|
||||
Dart_Handle result = Dart_InvokeDynamic(Dart_Null(),
|
||||
function_name,
|
||||
number_of_arguments,
|
||||
NULL);
|
||||
|
|
|
@ -64,7 +64,7 @@ class LocalHandle {
|
|||
public:
|
||||
// Accessors.
|
||||
RawObject* raw() const { return raw_; }
|
||||
void set_raw(const Object& object) { raw_ = object.raw(); }
|
||||
void set_raw(RawObject* raw) { raw_ = raw; }
|
||||
static intptr_t raw_offset() { return OFFSET_OF(LocalHandle, raw_); }
|
||||
|
||||
private:
|
||||
|
|
|
@ -93,12 +93,10 @@ DART_EXPORT Dart_Handle Dart_ActivationFrameInfo(
|
|||
DARTSCOPE(isolate);
|
||||
CHECK_AND_CAST(ActivationFrame, frame, activation_frame);
|
||||
if (function_name != NULL) {
|
||||
const String& name = String::Handle(frame->QualifiedFunctionName());
|
||||
*function_name = Api::NewLocalHandle(isolate, name);
|
||||
*function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName());
|
||||
}
|
||||
if (script_url != NULL) {
|
||||
const String& url = String::Handle(frame->SourceUrl());
|
||||
*script_url = Api::NewLocalHandle(isolate, url);
|
||||
*script_url = Api::NewHandle(isolate, frame->SourceUrl());
|
||||
}
|
||||
if (line_number != NULL) {
|
||||
*line_number = frame->LineNumber();
|
||||
|
@ -112,8 +110,7 @@ DART_EXPORT Dart_Handle Dart_GetLocalVariables(
|
|||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
CHECK_AND_CAST(ActivationFrame, frame, activation_frame);
|
||||
const Array& variables = Array::Handle(frame->GetLocalVariables());
|
||||
return Api::NewLocalHandle(isolate, variables);
|
||||
return Api::NewHandle(isolate, frame->GetLocalVariables());
|
||||
}
|
||||
|
||||
|
||||
|
@ -245,9 +242,7 @@ DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) {
|
|||
DARTSCOPE(isolate);
|
||||
Instance& obj = Instance::Handle();
|
||||
UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
|
||||
Array& fields = Array::Handle();
|
||||
fields = isolate->debugger()->GetInstanceFields(obj);
|
||||
return Api::NewLocalHandle(isolate, fields);
|
||||
return Api::NewHandle(isolate, isolate->debugger()->GetInstanceFields(obj));
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,9 +251,7 @@ DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) {
|
|||
DARTSCOPE(isolate);
|
||||
Class& cls = Class::Handle();
|
||||
UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
|
||||
Array& fields = Array::Handle();
|
||||
fields = isolate->debugger()->GetStaticFields(cls);
|
||||
return Api::NewLocalHandle(isolate, fields);
|
||||
return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls));
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,8 +260,7 @@ DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) {
|
|||
DARTSCOPE(isolate);
|
||||
Instance& obj = Instance::Handle();
|
||||
UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
|
||||
const Class& cls = Class::Handle(obj.clazz());
|
||||
return Api::NewLocalHandle(isolate, cls);
|
||||
return Api::NewHandle(isolate, obj.clazz());
|
||||
}
|
||||
|
||||
|
||||
|
@ -277,8 +269,7 @@ DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) {
|
|||
DARTSCOPE(isolate);
|
||||
Class& cls = Class::Handle();
|
||||
UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
|
||||
cls = cls.SuperClass();
|
||||
return Api::NewLocalHandle(isolate, cls);
|
||||
return Api::NewHandle(isolate, cls.SuperClass());
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,8 +296,7 @@ DART_EXPORT Dart_Handle Dart_GetScriptSource(
|
|||
library_url.ToCString());
|
||||
}
|
||||
|
||||
const String& source = String::Handle(script.source());
|
||||
return Api::NewLocalHandle(isolate, source);
|
||||
return Api::NewHandle(isolate, script.source());
|
||||
}
|
||||
|
||||
|
||||
|
@ -332,7 +322,7 @@ DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) {
|
|||
url = script.url();
|
||||
script_list.SetAt(i, url);
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, script_list);
|
||||
return Api::NewHandle(isolate, script_list.raw());
|
||||
}
|
||||
|
||||
|
||||
|
@ -360,7 +350,7 @@ DART_EXPORT Dart_Handle Dart_GetLibraryURLs() {
|
|||
library_list.SetAt(i, lib_url);
|
||||
lib = lib.next_registered();
|
||||
}
|
||||
return Api::NewLocalHandle(isolate, library_list);
|
||||
return Api::NewHandle(isolate, library_list.raw());
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -25,7 +25,7 @@ NativeFunction NativeEntry::ResolveNative(const Class& cls,
|
|||
Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries.
|
||||
Dart_NativeEntryResolver resolver = library.native_entry_resolver();
|
||||
Dart_NativeFunction native_function =
|
||||
resolver(Api::NewLocalHandle(Isolate::Current(), function_name),
|
||||
resolver(Api::NewHandle(Isolate::Current(), function_name.raw()),
|
||||
number_of_arguments);
|
||||
Dart_ExitScope(); // Exit the Dart API scope.
|
||||
return reinterpret_cast<NativeFunction>(native_function);
|
||||
|
|
|
@ -3396,9 +3396,9 @@ Dart_Handle Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
|
|||
ErrorMsg(token_pos, "no library handler registered");
|
||||
}
|
||||
Dart_Handle result = handler(tag,
|
||||
Api::NewLocalHandle(isolate, library_),
|
||||
Api::NewLocalHandle(isolate, url),
|
||||
Api::NewLocalHandle(isolate, import_map));
|
||||
Api::NewHandle(isolate, library_.raw()),
|
||||
Api::NewHandle(isolate, url.raw()),
|
||||
Api::NewHandle(isolate, import_map.raw()));
|
||||
if (Dart_IsError(result)) {
|
||||
Error& prev_error = Error::Handle();
|
||||
prev_error ^= Api::UnwrapHandle(result);
|
||||
|
|
Loading…
Reference in a new issue