Flutter Engine
The Flutter Engine
Classes | Static Public Member Functions | Friends | List of all members
dart::Api Class Reference

#include <dart_api_impl.h>

Inheritance diagram for dart::Api:
dart::AllStatic

Classes

class  Scope
 

Static Public Member Functions

static Dart_Handle NewHandle (Thread *thread, ObjectPtr raw)
 
static ObjectPtr UnwrapHandle (Dart_Handle object)
 
static const StringUnwrapStringHandle (const ReusableObjectHandleScope &reused, Dart_Handle object)
 
static const InstanceUnwrapInstanceHandle (const ReusableObjectHandleScope &reused, Dart_Handle object)
 
static Dart_Handle CheckAndFinalizePendingClasses (Thread *thread)
 
static Dart_Isolate CastIsolate (Isolate *isolate)
 
static Dart_IsolateGroup CastIsolateGroup (IsolateGroup *isolate_group)
 
static Dart_Handle Success ()
 
static bool IsSmi (Dart_Handle handle)
 
static intptr_t SmiValue (Dart_Handle handle)
 
static bool IsInstance (Dart_Handle handle)
 
static bool IsValid (Dart_Handle handle)
 
static bool IsError (Dart_Handle handle)
 
static intptr_t ClassId (Dart_Handle handle)
 
static Dart_Handle NewError (const char *format,...) PRINTF_ATTRIBUTE(1
 
static Dart_Handle static Dart_Handle NewArgumentError (const char *format,...) PRINTF_ATTRIBUTE(1
 
static Dart_Handle static Dart_Handle static Dart_Handle Null ()
 
static Dart_Handle True ()
 
static Dart_Handle False ()
 
static Dart_Handle EmptyString ()
 
static Dart_Handle NoCallbacksError ()
 
static Dart_Handle UnwindInProgressError ()
 
static bool IsProtectedHandle (Dart_Handle object)
 
static ApiLocalScopeTopScope (Thread *thread)
 
static void Init ()
 
static void InitHandles ()
 
static void Cleanup ()
 
static bool StringGetPeerHelper (NativeArguments *args, int arg_index, void **peer)
 
static bool GetNativeReceiver (NativeArguments *args, intptr_t *value)
 
static bool GetNativeBooleanArgument (NativeArguments *args, int arg_index, bool *value)
 
static bool GetNativeIntegerArgument (NativeArguments *args, int arg_index, int64_t *value)
 
static bool GetNativeDoubleArgument (NativeArguments *args, int arg_index, double *value)
 
static bool GetNativeFieldsOfArgument (NativeArguments *args, int arg_index, int num_fields, intptr_t *field_values)
 
static void SetReturnValue (NativeArguments *args, Dart_Handle retval)
 
static void SetSmiReturnValue (NativeArguments *args, intptr_t retval)
 
static void SetIntegerReturnValue (NativeArguments *args, int64_t retval)
 
static void SetDoubleReturnValue (NativeArguments *args, double retval)
 
static void SetWeakHandleReturnValue (NativeArguments *args, Dart_WeakPersistentHandle retval)
 
static StringPtr GetEnvironmentValue (Thread *thread, const String &name)
 
static bool IsFfiEnabled ()
 

Friends

class ApiNativeScope
 

Detailed Description

Definition at line 133 of file dart_api_impl.h.

Member Function Documentation

◆ CastIsolate()

Dart_Isolate dart::Api::CastIsolate ( Isolate isolate)
static

Definition at line 432 of file dart_api_impl.cc.

432 {
433 return reinterpret_cast<Dart_Isolate>(isolate);
434}
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88

◆ CastIsolateGroup()

Dart_IsolateGroup dart::Api::CastIsolateGroup ( IsolateGroup isolate_group)
static

Definition at line 436 of file dart_api_impl.cc.

436 {
437 return reinterpret_cast<Dart_IsolateGroup>(isolate_group);
438}
struct _Dart_IsolateGroup * Dart_IsolateGroup
Definition: dart_api.h:89

◆ CheckAndFinalizePendingClasses()

Dart_Handle dart::Api::CheckAndFinalizePendingClasses ( Thread thread)
static

Definition at line 419 of file dart_api_impl.cc.

419 {
420 Isolate* isolate = thread->isolate();
421 if (!isolate->AllowClassFinalization()) {
422 // Class finalization is blocked for the isolate. Do nothing.
423 return Api::Success();
424 }
426 return Api::Success();
427 }
428 ASSERT(thread->sticky_error() != Object::null());
429 return Api::NewHandle(thread, thread->sticky_error());
430}
static Dart_Handle Success()
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static bool ProcessPendingClasses()
static ObjectPtr null()
Definition: object.h:433
#define ASSERT(E)

◆ ClassId()

static intptr_t dart::Api::ClassId ( Dart_Handle  handle)
inlinestatic

Definition at line 212 of file dart_api_impl.h.

212 {
213 ObjectPtr raw = UnwrapHandle(handle);
214 if (!raw->IsHeapObject()) {
215 return kSmiCid;
216 }
217 return raw->GetClassId();
218 }
static ObjectPtr UnwrapHandle(Dart_Handle object)

◆ Cleanup()

void dart::Api::Cleanup ( )
static

Definition at line 551 of file dart_api_impl.cc.

551 {
552 true_handle_ = nullptr;
553 false_handle_ = nullptr;
554 null_handle_ = nullptr;
555 empty_string_handle_ = nullptr;
556 no_callbacks_error_handle_ = nullptr;
557 unwind_in_progress_error_handle_ = nullptr;
558}

◆ EmptyString()

static Dart_Handle dart::Api::EmptyString ( )
inlinestatic

Definition at line 235 of file dart_api_impl.h.

235{ return empty_string_handle_; }

◆ False()

static Dart_Handle dart::Api::False ( )
inlinestatic

Definition at line 232 of file dart_api_impl.h.

232{ return false_handle_; }

◆ GetEnvironmentValue()

StringPtr dart::Api::GetEnvironmentValue ( Thread thread,
const String name 
)
static

Definition at line 5254 of file dart_api_impl.cc.

5254 {
5255 String& result = String::Handle(CallEnvironmentCallback(thread, name));
5256 if (result.IsNull()) {
5257 // Every 'dart:X' library introduces an environment variable
5258 // 'dart.library.X' that is set to 'true'.
5259 // We just need to make sure to hide private libraries (starting with
5260 // "_", and the mirrors library, if it is not supported.
5261
5262 if (!FLAG_enable_mirrors && name.Equals(Symbols::DartLibraryMirrors())) {
5263 return Symbols::False().ptr();
5264 }
5265
5266 if (!Api::IsFfiEnabled() && name.Equals(Symbols::DartLibraryFfi())) {
5267 return Symbols::False().ptr();
5268 }
5269
5270 if (name.Equals(Symbols::DartVMProduct())) {
5271#ifdef PRODUCT
5272 return Symbols::True().ptr();
5273#else
5274 return Symbols::False().ptr();
5275#endif
5276 }
5277
5278 if (name.Equals(Symbols::DartDeveloperTimeline())) {
5279#ifdef SUPPORT_TIMELINE
5280 return Symbols::True().ptr();
5281#else
5282 return Symbols::False().ptr();
5283#endif
5284 }
5285
5286 const String& prefix = Symbols::DartLibrary();
5287 if (name.StartsWith(prefix)) {
5288 const String& library_name =
5290
5291 // Private libraries (starting with "_") are not exposed to the user.
5292 if (!library_name.IsNull() && library_name.CharAt(0) != '_') {
5293 const String& dart_library_name =
5294 String::Handle(String::Concat(Symbols::DartScheme(), library_name));
5295 const Library& library =
5296 Library::Handle(Library::LookupLibrary(thread, dart_library_name));
5297 if (!library.IsNull()) {
5298 return Symbols::True().ptr();
5299 }
5300 }
5301 }
5302 // Check for default VM provided values. If it was not overridden on the
5303 // command line.
5304 if (Symbols::DartIsVM().Equals(name)) {
5305 return Symbols::True().ptr();
5306 }
5307 }
5308 return result.ptr();
5309}
static bool IsFfiEnabled()
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
Definition: object.cc:14599
ObjectPtr ptr() const
Definition: object.h:332
static Object & Handle()
Definition: object.h:407
static StringPtr SubString(const String &str, intptr_t begin_index, Heap::Space space=Heap::kNew)
Definition: object.cc:24080
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
Definition: object.cc:24037
static const String & True()
Definition: symbols.h:693
static const String & False()
Definition: symbols.h:689
GAsyncResult * result
static bool Equals(const Object &expected, const Object &actual)
const char *const name

◆ GetNativeBooleanArgument()

bool dart::Api::GetNativeBooleanArgument ( NativeArguments args,
int  arg_index,
bool *  value 
)
static

Definition at line 599 of file dart_api_impl.cc.

601 {
602 NoSafepointScope no_safepoint_scope;
603 ObjectPtr raw_obj = arguments->NativeArgAt(arg_index);
604 if (raw_obj->IsHeapObject()) {
605 intptr_t cid = raw_obj->GetClassId();
606 if (cid == kBoolCid) {
607 *value = (raw_obj == Object::bool_true().ptr());
608 return true;
609 }
610 if (cid == kNullCid) {
611 *value = false;
612 return true;
613 }
614 }
615 return false;
616}
uint8_t value
@ kNullCid
Definition: class_id.h:252
const intptr_t cid

◆ GetNativeDoubleArgument()

bool dart::Api::GetNativeDoubleArgument ( NativeArguments args,
int  arg_index,
double *  value 
)
static

Definition at line 635 of file dart_api_impl.cc.

637 {
638 NoSafepointScope no_safepoint_scope;
639 ObjectPtr raw_obj = arguments->NativeArgAt(arg_index);
640 if (raw_obj->IsHeapObject()) {
641 intptr_t cid = raw_obj->GetClassId();
642 if (cid == kDoubleCid) {
643 *value = static_cast<DoublePtr>(raw_obj)->untag()->value_;
644 return true;
645 }
646 if (cid == kMintCid) {
647 *value =
648 static_cast<double>(static_cast<MintPtr>(raw_obj)->untag()->value_);
649 return true;
650 }
651 return false;
652 }
653 *value = static_cast<double>(Smi::Value(static_cast<SmiPtr>(raw_obj)));
654 return true;
655}
intptr_t Value() const
Definition: object.h:9990
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558

◆ GetNativeFieldsOfArgument()

bool dart::Api::GetNativeFieldsOfArgument ( NativeArguments args,
int  arg_index,
int  num_fields,
intptr_t *  field_values 
)
static

Definition at line 657 of file dart_api_impl.cc.

660 {
661 NoSafepointScope no_safepoint_scope;
662 ObjectPtr raw_obj = arguments->NativeArgAt(arg_index);
663 intptr_t cid = raw_obj->GetClassIdMayBeSmi();
664 int class_num_fields = arguments->thread()
665 ->isolate_group()
666 ->class_table()
667 ->At(cid)
668 ->untag()
669 ->num_native_fields_;
670 if (num_fields != class_num_fields) {
671 // No native fields or mismatched native field count.
672 return false;
673 }
674 TypedDataPtr native_fields =
675 reinterpret_cast<CompressedTypedDataPtr*>(
676 UntaggedObject::ToAddr(raw_obj) + sizeof(UntaggedObject))
677 ->Decompress(raw_obj->heap_base());
678 if (native_fields == TypedData::null()) {
679 // Native fields not initialized.
680 memset(field_values, 0, (num_fields * sizeof(field_values[0])));
681 return true;
682 }
683 ASSERT(class_num_fields == Smi::Value(native_fields->untag()->length()));
684 intptr_t* native_values =
685 reinterpret_cast<intptr_t*>(native_fields->untag()->data());
686 memmove(field_values, native_values, (num_fields * sizeof(field_values[0])));
687 return true;
688}
static uword ToAddr(const UntaggedObject *raw_obj)
Definition: raw_object.h:522

◆ GetNativeIntegerArgument()

bool dart::Api::GetNativeIntegerArgument ( NativeArguments args,
int  arg_index,
int64_t *  value 
)
static

Definition at line 618 of file dart_api_impl.cc.

620 {
621 NoSafepointScope no_safepoint_scope;
622 ObjectPtr raw_obj = arguments->NativeArgAt(arg_index);
623 if (raw_obj->IsHeapObject()) {
624 intptr_t cid = raw_obj->GetClassId();
625 if (cid == kMintCid) {
626 *value = static_cast<MintPtr>(raw_obj)->untag()->value_;
627 return true;
628 }
629 return false;
630 }
631 *value = Smi::Value(static_cast<SmiPtr>(raw_obj));
632 return true;
633}

◆ GetNativeReceiver()

bool dart::Api::GetNativeReceiver ( NativeArguments args,
intptr_t *  value 
)
static

Definition at line 577 of file dart_api_impl.cc.

577 {
578 NoSafepointScope no_safepoint_scope;
579 ObjectPtr raw_obj = arguments->NativeArg0();
580 if (raw_obj->IsHeapObject()) {
581 intptr_t cid = raw_obj->GetClassId();
582 if (cid >= kNumPredefinedCids) {
583 ASSERT(Instance::Cast(Object::Handle(raw_obj)).IsValidNativeIndex(0));
584 TypedDataPtr native_fields =
585 reinterpret_cast<CompressedTypedDataPtr*>(
586 UntaggedObject::ToAddr(raw_obj) + sizeof(UntaggedObject))
587 ->Decompress(raw_obj->heap_base());
588 if (native_fields == TypedData::null()) {
589 *value = 0;
590 } else {
591 *value = *bit_cast<intptr_t*, uint8_t*>(native_fields->untag()->data());
592 }
593 return true;
594 }
595 }
596 return false;
597}
@ kNumPredefinedCids
Definition: class_id.h:257

◆ Init()

void dart::Api::Init ( )
static

Definition at line 509 of file dart_api_impl.cc.

509 {
510 if (api_native_key_ == kUnsetThreadLocalKey) {
511 api_native_key_ = OSThread::CreateThreadLocal();
512 }
513 ASSERT(api_native_key_ != kUnsetThreadLocalKey);
514}
static ThreadLocalKey CreateThreadLocal(ThreadDestructor destructor=nullptr)
static const ThreadLocalKey kUnsetThreadLocalKey

◆ InitHandles()

void dart::Api::InitHandles ( )
static

Definition at line 523 of file dart_api_impl.cc.

523 {
524 Isolate* isolate = Isolate::Current();
525 ASSERT(isolate != nullptr);
526 ASSERT(isolate == Dart::vm_isolate());
527 ApiState* state = isolate->group()->api_state();
528 ASSERT(state != nullptr);
529
530 ASSERT(true_handle_ == nullptr);
531 true_handle_ = InitNewReadOnlyApiHandle(Bool::True().ptr());
532
533 ASSERT(false_handle_ == nullptr);
534 false_handle_ = InitNewReadOnlyApiHandle(Bool::False().ptr());
535
536 ASSERT(null_handle_ == nullptr);
537 null_handle_ = InitNewReadOnlyApiHandle(Object::null());
538
539 ASSERT(empty_string_handle_ == nullptr);
540 empty_string_handle_ = InitNewReadOnlyApiHandle(Symbols::Empty().ptr());
541
542 ASSERT(no_callbacks_error_handle_ == nullptr);
543 no_callbacks_error_handle_ =
544 InitNewReadOnlyApiHandle(Object::no_callbacks_error().ptr());
545
546 ASSERT(unwind_in_progress_error_handle_ == nullptr);
547 unwind_in_progress_error_handle_ =
548 InitNewReadOnlyApiHandle(Object::unwind_in_progress_error().ptr());
549}
static const Bool & False()
Definition: object.h:10799
static const Bool & True()
Definition: object.h:10797
static Isolate * vm_isolate()
Definition: dart.h:68
static Isolate * Current()
Definition: isolate.h:986
static const String & Empty()
Definition: symbols.h:688
AtkStateType state
static Dart_Handle InitNewReadOnlyApiHandle(ObjectPtr raw)

◆ IsError()

static bool dart::Api::IsError ( Dart_Handle  handle)
inlinestatic

Definition at line 208 of file dart_api_impl.h.

208 {
209 return IsErrorClassId(ClassId(handle));
210 }
static intptr_t ClassId(Dart_Handle handle)
bool IsErrorClassId(intptr_t index)
Definition: class_id.h:321

◆ IsFfiEnabled()

static bool dart::Api::IsFfiEnabled ( )
inlinestatic

Definition at line 312 of file dart_api_impl.h.

312{ return FLAG_enable_ffi; }

◆ IsInstance()

static bool dart::Api::IsInstance ( Dart_Handle  handle)
inlinestatic

Definition at line 200 of file dart_api_impl.h.

200 {
201 return !IsInternalOnlyClassId(ClassId(handle));
202 }
bool IsInternalOnlyClassId(intptr_t index)
Definition: class_id.h:299

◆ IsProtectedHandle()

static bool dart::Api::IsProtectedHandle ( Dart_Handle  object)
inlinestatic

Definition at line 245 of file dart_api_impl.h.

245 {
246 if (object == nullptr) return false;
247 return (object == true_handle_) || (object == false_handle_) ||
248 (object == null_handle_) || (object == empty_string_handle_) ||
249 (object == no_callbacks_error_handle_) ||
250 (object == unwind_in_progress_error_handle_);
251 }

◆ IsSmi()

static bool dart::Api::IsSmi ( Dart_Handle  handle)
inlinestatic

Definition at line 184 of file dart_api_impl.h.

184 {
185 // Important: we do not require current thread to be in VM state because
186 // we do not dereference the handle.
187 ObjectPtr raw = *(reinterpret_cast<ObjectPtr*>(handle));
188 return !raw->IsHeapObject();
189 }

◆ IsValid()

bool dart::Api::IsValid ( Dart_Handle  handle)
static

Definition at line 485 of file dart_api_impl.cc.

485 {
486 Isolate* isolate = Isolate::Current();
487 Thread* thread = Thread::Current();
488 ASSERT(thread->IsDartMutatorThread());
489 CHECK_ISOLATE(isolate);
490
491 // Check against all of the handles in the current isolate as well as the
492 // read-only handles.
493 return thread->IsValidHandle(handle) ||
494 isolate->group()->api_state()->IsActivePersistentHandle(
495 reinterpret_cast<Dart_PersistentHandle>(handle)) ||
496 isolate->group()->api_state()->IsActiveWeakPersistentHandle(
497 reinterpret_cast<Dart_WeakPersistentHandle>(handle)) ||
499 Dart::IsReadOnlyHandle(reinterpret_cast<uword>(handle));
500}
static bool IsReadOnlyHandle(uword address)
Definition: dart.cc:1147
static bool IsReadOnlyApiHandle(Dart_Handle handle)
Definition: dart.cc:1152
static Thread * Current()
Definition: thread.h:362
Dart_Handle Dart_PersistentHandle
Definition: dart_api.h:259
struct _Dart_WeakPersistentHandle * Dart_WeakPersistentHandle
Definition: dart_api.h:260
#define CHECK_ISOLATE(isolate)
Definition: dart_api_impl.h:42
uintptr_t uword
Definition: globals.h:501

◆ NewArgumentError()

Dart_Handle dart::Api::NewArgumentError ( const char *  format,
  ... 
)
static

Definition at line 458 of file dart_api_impl.cc.

458 {
459 Thread* T = Thread::Current();
462 // Ensure we transition safepoint state to VM if we are not already in
463 // that state.
464 TransitionToVM transition(T);
465 HANDLESCOPE(T);
466
467 va_list args;
469 char* buffer = OS::VSCreate(Z, format, args);
470 va_end(args);
471
472 const String& message = String::Handle(Z, String::New(buffer));
473 const Array& arguments = Array::Handle(Z, Array::New(1));
474 arguments.SetAt(0, message);
475 Object& error = Object::Handle(
478 Symbols::ArgumentError(), Symbols::Dot(), arguments));
479 if (!error.IsError()) {
481 }
482 return Api::NewHandle(T, error.ptr());
483}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
static ObjectPtr InstanceCreate(const Library &library, const String &exception_name, const String &constructor_name, const Array &arguments)
Definition: dart_entry.cc:583
static LibraryPtr CoreLibrary()
Definition: object.cc:14787
static char static char * VSCreate(Zone *zone, const char *format, va_list args)
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static const String & Dot()
Definition: symbols.h:613
static UnhandledExceptionPtr New(const Instance &exception, const Instance &stacktrace, Heap::Space space=Heap::kNew)
Definition: object.cc:19939
#define Z
#define CHECK_API_SCOPE(thread)
Definition: dart_api_impl.h:64
#define CHECK_CALLBACK_STATE(thread)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
#define HANDLESCOPE(thread)
Definition: handles.h:321
Win32Message message
va_start(args, format)
va_end(args)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
#define T
Definition: precompiler.cc:65

◆ NewError()

Dart_Handle dart::Api::NewError ( const char *  format,
  ... 
)
static

Definition at line 440 of file dart_api_impl.cc.

440 {
441 Thread* T = Thread::Current();
444 // Ensure we transition safepoint state to VM if we are not already in
445 // that state.
446 TransitionToVM transition(T);
447 HANDLESCOPE(T);
448
449 va_list args;
451 char* buffer = OS::VSCreate(Z, format, args);
452 va_end(args);
453
454 const String& message = String::Handle(Z, String::New(buffer));
455 return Api::NewHandle(T, ApiError::New(message));
456}

◆ NewHandle()

Dart_Handle dart::Api::NewHandle ( Thread thread,
ObjectPtr  raw 
)
static

Definition at line 361 of file dart_api_impl.cc.

361 {
362 if (raw == Object::null()) {
363 return Null();
364 }
365 if (raw == Bool::True().ptr()) {
366 return True();
367 }
368 if (raw == Bool::False().ptr()) {
369 return False();
370 }
371 ASSERT(thread->execution_state() == Thread::kThreadInVM);
372 return InitNewHandle(thread, raw);
373}
static Dart_Handle False()
static Dart_Handle static Dart_Handle static Dart_Handle Null()
static Dart_Handle True()

◆ NoCallbacksError()

static Dart_Handle dart::Api::NoCallbacksError ( )
inlinestatic

Definition at line 238 of file dart_api_impl.h.

238{ return no_callbacks_error_handle_; }

◆ Null()

static Dart_Handle static Dart_Handle static Dart_Handle dart::Api::Null ( )
inlinestatic

Definition at line 226 of file dart_api_impl.h.

226{ return null_handle_; }

◆ SetDoubleReturnValue()

static void dart::Api::SetDoubleReturnValue ( NativeArguments args,
double  retval 
)
inlinestatic

Definition at line 304 of file dart_api_impl.h.

304 {
305 args->SetReturnUnsafe(Double::New(retval));
306 }
static DoublePtr New(double d, Heap::Space space=Heap::kNew)
Definition: object.cc:23402

◆ SetIntegerReturnValue()

static void dart::Api::SetIntegerReturnValue ( NativeArguments args,
int64_t  retval 
)
inlinestatic

Definition at line 301 of file dart_api_impl.h.

301 {
302 args->SetReturnUnsafe(Integer::New(retval));
303 }
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
Definition: object.cc:22984

◆ SetReturnValue()

static void dart::Api::SetReturnValue ( NativeArguments args,
Dart_Handle  retval 
)
inlinestatic

Definition at line 295 of file dart_api_impl.h.

295 {
296 args->SetReturnUnsafe(UnwrapHandle(retval));
297 }

◆ SetSmiReturnValue()

static void dart::Api::SetSmiReturnValue ( NativeArguments args,
intptr_t  retval 
)
inlinestatic

Definition at line 298 of file dart_api_impl.h.

298 {
299 args->SetReturnUnsafe(Smi::New(retval));
300 }
static SmiPtr New(intptr_t value)
Definition: object.h:10006

◆ SetWeakHandleReturnValue()

void dart::Api::SetWeakHandleReturnValue ( NativeArguments args,
Dart_WeakPersistentHandle  retval 
)
static

Definition at line 690 of file dart_api_impl.cc.

691 {
692 args->SetReturnUnsafe(FinalizablePersistentHandle::Cast(retval)->ptr());
693}
static FinalizablePersistentHandle * Cast(Dart_WeakPersistentHandle handle)

◆ SmiValue()

static intptr_t dart::Api::SmiValue ( Dart_Handle  handle)
inlinestatic

Definition at line 192 of file dart_api_impl.h.

192 {
193 // Important: we do not require current thread to be in VM state because
194 // we do not dereference the handle.
195 ObjectPtr value = *(reinterpret_cast<ObjectPtr*>(handle));
196 return Smi::Value(static_cast<SmiPtr>(value));
197 }

◆ StringGetPeerHelper()

bool dart::Api::StringGetPeerHelper ( NativeArguments args,
int  arg_index,
void **  peer 
)
static

Definition at line 560 of file dart_api_impl.cc.

562 {
563 NoSafepointScope no_safepoint_scope;
564 ObjectPtr raw_obj = arguments->NativeArgAt(arg_index);
565 if (!raw_obj->IsHeapObject()) {
566 return false;
567 }
568 intptr_t cid = raw_obj->GetClassId();
569 if (cid == kOneByteStringCid || cid == kTwoByteStringCid) {
570 auto isolate_group = arguments->thread()->isolate_group();
571 *peer = isolate_group->heap()->GetPeer(raw_obj);
572 return (*peer != nullptr);
573 }
574 return false;
575}

◆ Success()

static Dart_Handle dart::Api::Success ( )
inlinestatic

Definition at line 181 of file dart_api_impl.h.

181{ return Api::True(); }

◆ TopScope()

ApiLocalScope * dart::Api::TopScope ( Thread thread)
static

Definition at line 502 of file dart_api_impl.cc.

502 {
503 ASSERT(thread != nullptr);
504 ApiLocalScope* scope = thread->api_top_scope();
505 ASSERT(scope != nullptr);
506 return scope;
507}

◆ True()

static Dart_Handle dart::Api::True ( )
inlinestatic

Definition at line 229 of file dart_api_impl.h.

229{ return true_handle_; }

◆ UnwindInProgressError()

static Dart_Handle dart::Api::UnwindInProgressError ( )
inlinestatic

Definition at line 241 of file dart_api_impl.h.

241 {
242 return unwind_in_progress_error_handle_;
243 }

◆ UnwrapHandle()

ObjectPtr dart::Api::UnwrapHandle ( Dart_Handle  object)
static

Definition at line 375 of file dart_api_impl.cc.

375 {
376#if defined(DEBUG)
377 Thread* thread = Thread::Current();
378 ASSERT(thread->execution_state() == Thread::kThreadInVM);
379 ASSERT(thread->IsDartMutatorThread());
380 ASSERT(thread->isolate() != nullptr);
383#endif
384 return (reinterpret_cast<LocalHandle*>(object))->ptr();
385}
static intptr_t ptr_offset()
static intptr_t ptr_offset()

◆ UnwrapInstanceHandle()

const Instance & dart::Api::UnwrapInstanceHandle ( const ReusableObjectHandleScope &  reused,
Dart_Handle  object 
)
static

Definition at line 408 of file dart_api_impl.cc.

410 {
411 Object& ref = reuse.Handle();
412 ref = Api::UnwrapHandle(dart_handle);
413 if (ref.IsInstance()) {
414 return Instance::Cast(ref);
415 }
416 return Object::null_instance();
417}

◆ UnwrapStringHandle()

const String & dart::Api::UnwrapStringHandle ( const ReusableObjectHandleScope &  reused,
Dart_Handle  object 
)
static

Definition at line 398 of file dart_api_impl.cc.

399 {
400 Object& ref = reuse.Handle();
401 ref = Api::UnwrapHandle(dart_handle);
402 if (ref.IsString()) {
403 return String::Cast(ref);
404 }
405 return Object::null_string();
406}

Friends And Related Function Documentation

◆ ApiNativeScope

friend class ApiNativeScope
friend

Definition at line 329 of file dart_api_impl.h.


The documentation for this class was generated from the following files: