// Convert handle.x,y ==> SkSize. Offset DartConverter<Offset>::FromDart(Dart_Handle handle) { DCHECK(!LogIfError(handle)); Dart_Handle dx_value = Dart_GetField(handle, DOMDartState::Current()->dx_handle()); Dart_Handle dy_value = Dart_GetField(handle, DOMDartState::Current()->dy_handle()); double dx = 0.0, dy = 0.0; Dart_Handle err = Dart_DoubleValue(dx_value, &dx); DCHECK(!LogIfError(err)); err = Dart_DoubleValue(dy_value, &dy); DCHECK(!LogIfError(err)); Offset result; result.sk_size.set(dx, dy); result.is_null = false; return result; }
inline void getValue<double>(Dart_NativeArguments args, int index, double* value) { Dart_Handle handle = Dart_GetNativeArgument(args, index); assert(Dart_IsDouble(handle)); Dart_DoubleValue(handle, value); }
inline void getValue<float>(Dart_NativeArguments args, int index, float* value) { Dart_Handle handle = Dart_GetNativeArgument(args, index); assert(Dart_IsDouble(handle)); double temp; Dart_DoubleValue(handle, &temp); *value = static_cast<float>(temp); }
// Convert handle.x,y ==> SkPoint. Point DartConverter<Point>::FromDart(Dart_Handle handle) { Point result; result.is_null = true; DCHECK(!LogIfError(handle)); Dart_Handle x_value = Dart_GetField(handle, DOMDartState::Current()->x_handle()); Dart_Handle y_value = Dart_GetField(handle, DOMDartState::Current()->y_handle()); double x = 0.0, y = 0.0; Dart_Handle err = Dart_DoubleValue(x_value, &x); DCHECK(!LogIfError(err)); err = Dart_DoubleValue(y_value, &y); DCHECK(!LogIfError(err)); result.sk_point.set(x, y); result.is_null = false; return result; }