Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
dart::bin::CObject Class Reference

#include <dartutils.h>

Inheritance diagram for dart::bin::CObject:
dart::bin::CObjectArray dart::bin::CObjectBool dart::bin::CObjectDouble dart::bin::CObjectExternalUint8Array dart::bin::CObjectInt32 dart::bin::CObjectInt64 dart::bin::CObjectIntptr dart::bin::CObjectNativePointer dart::bin::CObjectSendPort dart::bin::CObjectString dart::bin::CObjectTypedData dart::bin::CObjectUint8Array

Public Member Functions

 CObject (Dart_CObject *cobject)
 
Dart_CObject_Type type ()
 
Dart_TypedData_Type byte_array_type ()
 
bool IsNull ()
 
bool IsBool ()
 
bool IsInt32 ()
 
bool IsInt64 ()
 
bool IsInt32OrInt64 ()
 
bool IsIntptr ()
 
bool IsDouble ()
 
bool IsString ()
 
bool IsArray ()
 
bool IsTypedData ()
 
bool IsUint8Array ()
 
bool IsSendPort ()
 
bool IsTrue ()
 
bool IsFalse ()
 
void * operator new (size_t size)
 
Dart_CObjectAsApiCObject ()
 

Static Public Member Functions

static CObjectNull ()
 
static CObjectTrue ()
 
static CObjectFalse ()
 
static CObjectBool (bool value)
 
static Dart_CObjectNewInt32 (int32_t value)
 
static Dart_CObjectNewInt64 (int64_t value)
 
static Dart_CObjectNewIntptr (intptr_t value)
 
static Dart_CObjectNewDouble (double value)
 
static Dart_CObjectNewString (const char *str)
 
static Dart_CObjectNewArray (intptr_t length)
 
static Dart_CObjectNewUint8Array (const void *data, intptr_t length)
 
static Dart_CObjectNewExternalUint8Array (intptr_t length, uint8_t *data, void *peer, Dart_HandleFinalizer callback)
 
static Dart_CObjectNewNativePointer (intptr_t ptr, intptr_t size, Dart_HandleFinalizer callback)
 
static Dart_CObjectNewIOBuffer (int64_t length)
 
static void ShrinkIOBuffer (Dart_CObject *cobject, int64_t new_length)
 
static void FreeIOBufferData (Dart_CObject *object)
 
static CObjectIllegalArgumentError ()
 
static CObjectFileClosedError ()
 
static CObjectNewOSError ()
 
static CObjectNewOSError (OSError *os_error)
 

Static Public Attributes

static constexpr int kSuccess = 0
 
static constexpr int kArgumentError = 1
 
static constexpr int kOSError = 2
 
static constexpr int kFileClosedError = 3
 

Protected Member Functions

 CObject ()
 

Protected Attributes

Dart_CObjectcobject_
 

Detailed Description

Definition at line 329 of file dartutils.h.

Constructor & Destructor Documentation

◆ CObject() [1/2]

dart::bin::CObject::CObject ( Dart_CObject cobject)
inlineexplicit

Definition at line 337 of file dartutils.h.

337: cobject_(cobject) {}
Dart_CObject * cobject_
Definition: dartutils.h:407

◆ CObject() [2/2]

dart::bin::CObject::CObject ( )
inlineprotected

Definition at line 406 of file dartutils.h.

406: cobject_(nullptr) {}

Member Function Documentation

◆ AsApiCObject()

Dart_CObject * dart::bin::CObject::AsApiCObject ( )
inline

Definition at line 394 of file dartutils.h.

394{ return cobject_; }

◆ Bool()

CObject * dart::bin::CObject::Bool ( bool  value)
static

Definition at line 891 of file dartutils.cc.

891 {
892 return value ? &true_ : &false_;
893}
uint8_t value

◆ byte_array_type()

Dart_TypedData_Type dart::bin::CObject::byte_array_type ( )
inline

Definition at line 339 of file dartutils.h.

339 {
343 }
Dart_CObject_Type type()
Definition: dartutils.h:338
@ Dart_CObject_kTypedData
@ Dart_CObject_kExternalTypedData
#define ASSERT(E)
union _Dart_CObject::@86 value
Dart_CObject_Type type
struct _Dart_CObject::@86::@90 as_typed_data

◆ False()

CObject * dart::bin::CObject::False ( )
static

Definition at line 887 of file dartutils.cc.

887 {
888 return &false_;
889}

◆ FileClosedError()

CObject * dart::bin::CObject::FileClosedError ( )
static

Definition at line 1032 of file dartutils.cc.

1032 {
1033 CObjectArray* result = new CObjectArray(CObject::NewArray(1));
1034 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kFileClosedError)));
1035 return result;
1036}
static constexpr int kFileClosedError
Definition: dartutils.h:335
static Dart_CObject * NewArray(intptr_t length)
Definition: dartutils.cc:936
static Dart_CObject * NewInt32(int32_t value)
Definition: dartutils.cc:902
GAsyncResult * result

◆ FreeIOBufferData()

void dart::bin::CObject::FreeIOBufferData ( Dart_CObject object)
static

Definition at line 1019 of file dartutils.cc.

1019 {
1020 ASSERT(cobject->type == Dart_CObject_kExternalTypedData);
1021 cobject->value.as_external_typed_data.callback(
1022 nullptr, cobject->value.as_external_typed_data.peer);
1023 cobject->value.as_external_typed_data.data = nullptr;
1024}

◆ IllegalArgumentError()

CObject * dart::bin::CObject::IllegalArgumentError ( )
static

Definition at line 1026 of file dartutils.cc.

1026 {
1027 CObjectArray* result = new CObjectArray(CObject::NewArray(1));
1028 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kArgumentError)));
1029 return result;
1030}
static constexpr int kArgumentError
Definition: dartutils.h:333

◆ IsArray()

bool dart::bin::CObject::IsArray ( )
inline

Definition at line 353 of file dartutils.h.

353{ return type() == Dart_CObject_kArray; }
@ Dart_CObject_kArray

◆ IsBool()

bool dart::bin::CObject::IsBool ( )
inline

Definition at line 346 of file dartutils.h.

346{ return type() == Dart_CObject_kBool; }
@ Dart_CObject_kBool

◆ IsDouble()

bool dart::bin::CObject::IsDouble ( )
inline

Definition at line 351 of file dartutils.h.

351{ return type() == Dart_CObject_kDouble; }
@ Dart_CObject_kDouble

◆ IsFalse()

bool dart::bin::CObject::IsFalse ( )
inline

Definition at line 365 of file dartutils.h.

365 {
367 }

◆ IsInt32()

bool dart::bin::CObject::IsInt32 ( )
inline

Definition at line 347 of file dartutils.h.

347{ return type() == Dart_CObject_kInt32; }
@ Dart_CObject_kInt32

◆ IsInt32OrInt64()

bool dart::bin::CObject::IsInt32OrInt64 ( )
inline

Definition at line 349 of file dartutils.h.

349{ return IsInt32() || IsInt64(); }

◆ IsInt64()

bool dart::bin::CObject::IsInt64 ( )
inline

Definition at line 348 of file dartutils.h.

348{ return type() == Dart_CObject_kInt64; }
@ Dart_CObject_kInt64

◆ IsIntptr()

bool dart::bin::CObject::IsIntptr ( )
inline

Definition at line 350 of file dartutils.h.

350{ return IsInt32OrInt64(); }
bool IsInt32OrInt64()
Definition: dartutils.h:349

◆ IsNull()

bool dart::bin::CObject::IsNull ( )
inline

Definition at line 345 of file dartutils.h.

345{ return type() == Dart_CObject_kNull; }
@ Dart_CObject_kNull

◆ IsSendPort()

bool dart::bin::CObject::IsSendPort ( )
inline

Definition at line 359 of file dartutils.h.

359{ return type() == Dart_CObject_kSendPort; }
@ Dart_CObject_kSendPort

◆ IsString()

bool dart::bin::CObject::IsString ( )
inline

Definition at line 352 of file dartutils.h.

352{ return type() == Dart_CObject_kString; }
@ Dart_CObject_kString

◆ IsTrue()

bool dart::bin::CObject::IsTrue ( )
inline

Definition at line 361 of file dartutils.h.

361 {
363 }

◆ IsTypedData()

bool dart::bin::CObject::IsTypedData ( )
inline

Definition at line 354 of file dartutils.h.

354{ return type() == Dart_CObject_kTypedData; }

◆ IsUint8Array()

bool dart::bin::CObject::IsUint8Array ( )
inline

Definition at line 355 of file dartutils.h.

355 {
356 return type() == Dart_CObject_kTypedData &&
358 }
Dart_TypedData_Type byte_array_type()
Definition: dartutils.h:339
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615

◆ NewArray()

Dart_CObject * dart::bin::CObject::NewArray ( intptr_t  length)
static

Definition at line 936 of file dartutils.cc.

936 {
937 Dart_CObject* cobject =
938 New(Dart_CObject_kArray, length * sizeof(Dart_CObject*)); // NOLINT
939 cobject->value.as_array.length = length;
940 cobject->value.as_array.values =
941 reinterpret_cast<Dart_CObject**>(cobject + 1);
942 return cobject;
943}
size_t length
struct _Dart_CObject::@86::@89 as_array
struct _Dart_CObject ** values

◆ NewDouble()

Dart_CObject * dart::bin::CObject::NewDouble ( double  value)
static

Definition at line 921 of file dartutils.cc.

921 {
922 Dart_CObject* cobject = New(Dart_CObject_kDouble);
923 cobject->value.as_double = value;
924 return cobject;
925}

◆ NewExternalUint8Array()

Dart_CObject * dart::bin::CObject::NewExternalUint8Array ( intptr_t  length,
uint8_t *  data,
void *  peer,
Dart_HandleFinalizer  callback 
)
static

Definition at line 955 of file dartutils.cc.

958 {
963 cobject->value.as_external_typed_data.peer = peer;
965 return cobject;
966}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static int8_t data[kExtLength]
Dart_HandleFinalizer callback
uint8_t * data
struct _Dart_CObject::@86::@91 as_external_typed_data

◆ NewInt32()

Dart_CObject * dart::bin::CObject::NewInt32 ( int32_t  value)
static

Definition at line 902 of file dartutils.cc.

902 {
903 Dart_CObject* cobject = New(Dart_CObject_kInt32);
904 cobject->value.as_int32 = value;
905 return cobject;
906}

◆ NewInt64()

Dart_CObject * dart::bin::CObject::NewInt64 ( int64_t  value)
static

Definition at line 908 of file dartutils.cc.

908 {
909 Dart_CObject* cobject = New(Dart_CObject_kInt64);
910 cobject->value.as_int64 = value;
911 return cobject;
912}

◆ NewIntptr()

Dart_CObject * dart::bin::CObject::NewIntptr ( intptr_t  value)
static

Definition at line 914 of file dartutils.cc.

914 {
915 // Pointer values passed as intptr_t are always send as int64_t.
916 Dart_CObject* cobject = New(Dart_CObject_kInt64);
917 cobject->value.as_int64 = value;
918 return cobject;
919}

◆ NewIOBuffer()

Dart_CObject * dart::bin::CObject::NewIOBuffer ( int64_t  length)
static

Definition at line 978 of file dartutils.cc.

978 {
979 // Make sure that we do not have an integer overflow here. Actual check
980 // against max elements will be done at the time of writing, as the constant
981 // is not part of the public API.
982 if ((length < 0) || (length > kIntptrMax)) {
983 return nullptr;
984 }
985 uint8_t* data = IOBuffer::Allocate(static_cast<intptr_t>(length));
986 if (data == nullptr) {
987 return nullptr;
988 }
989 return NewExternalUint8Array(static_cast<intptr_t>(length), data, data,
991}
static Dart_CObject * NewExternalUint8Array(intptr_t length, uint8_t *data, void *peer, Dart_HandleFinalizer callback)
Definition: dartutils.cc:955
static void Finalizer(void *isolate_callback_data, void *buffer)
Definition: io_buffer.h:31
static Dart_Handle Allocate(intptr_t size, uint8_t **buffer)
Definition: io_buffer.cc:12
constexpr intptr_t kIntptrMax
Definition: globals.h:557

◆ NewNativePointer()

Dart_CObject * dart::bin::CObject::NewNativePointer ( intptr_t  ptr,
intptr_t  size,
Dart_HandleFinalizer  callback 
)
static

Definition at line 968 of file dartutils.cc.

970 {
972 cobject->value.as_native_pointer.ptr = ptr;
973 cobject->value.as_native_pointer.size = size;
975 return cobject;
976}
@ Dart_CObject_kNativePointer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
struct _Dart_CObject::@86::@92 as_native_pointer

◆ NewOSError() [1/2]

CObject * dart::bin::CObject::NewOSError ( )
static

Definition at line 1038 of file dartutils.cc.

1038 {
1039 OSError os_error;
1040 return NewOSError(&os_error);
1041}
static CObject * NewOSError()
Definition: dartutils.cc:1038

◆ NewOSError() [2/2]

CObject * dart::bin::CObject::NewOSError ( OSError os_error)
static

Definition at line 1043 of file dartutils.cc.

1043 {
1044 CObject* error_message =
1045 new CObjectString(CObject::NewString(os_error->message()));
1046 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1047 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1048 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1049 result->SetAt(2, error_message);
1050 return result;
1051}
static Dart_CObject * NewString(const char *str)
Definition: dartutils.cc:927
static constexpr int kOSError
Definition: dartutils.h:334

◆ NewString()

Dart_CObject * dart::bin::CObject::NewString ( const char *  str)
static

Definition at line 927 of file dartutils.cc.

927 {
928 intptr_t length = strlen(str);
929 Dart_CObject* cobject = New(Dart_CObject_kString, length + 1);
930 char* payload = reinterpret_cast<char*>(cobject + 1);
931 memmove(payload, str, length + 1);
932 cobject->value.as_string = payload;
933 return cobject;
934}
const char * as_string

◆ NewUint8Array()

Dart_CObject * dart::bin::CObject::NewUint8Array ( const void *  data,
intptr_t  length 
)
static

Definition at line 945 of file dartutils.cc.

945 {
947 memmove(reinterpret_cast<uint8_t*>(cobject + 1), data, length);
949 cobject->value.as_typed_data.length = length;
950 cobject->value.as_typed_data.values =
951 reinterpret_cast<const uint8_t*>(cobject + 1);
952 return cobject;
953}

◆ Null()

CObject * dart::bin::CObject::Null ( )
static

Definition at line 879 of file dartutils.cc.

879 {
880 return &null_;
881}

◆ operator new()

void * dart::bin::CObject::operator new ( size_t  size)
inline

Definition at line 369 of file dartutils.h.

369{ return Dart_ScopeAllocate(size); }
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)

◆ ShrinkIOBuffer()

void dart::bin::CObject::ShrinkIOBuffer ( Dart_CObject cobject,
int64_t  new_length 
)
static

Definition at line 993 of file dartutils.cc.

993 {
994 if (cobject == nullptr) return;
996
997 const auto old_data = cobject->value.as_external_typed_data.data;
998 const auto old_length = cobject->value.as_external_typed_data.length;
999
1000 // We only shrink IOBuffers, never grow them.
1001 ASSERT(0 <= new_length && new_length <= old_length);
1002
1003 // We only reallocate if we think the freed space is worth reallocating.
1004 // We consider it worthwhile when freed space is >=25% and we have at
1005 // least 100 free bytes.
1006 const auto free_memory = old_length - new_length;
1007 if ((old_length >> 2) <= free_memory && 100 <= free_memory) {
1008 const auto new_data = IOBuffer::Reallocate(old_data, new_length);
1009 if (new_data != nullptr) {
1010 cobject->value.as_external_typed_data.data = new_data;
1011 cobject->value.as_external_typed_data.peer = new_data;
1012 }
1013 }
1014
1015 // The typed data object always has to have the shranken length.
1016 cobject->value.as_external_typed_data.length = new_length;
1017}
static uint8_t * Reallocate(uint8_t *buffer, intptr_t new_size)
Definition: io_buffer.cc:34

◆ True()

CObject * dart::bin::CObject::True ( )
static

Definition at line 883 of file dartutils.cc.

883 {
884 return &true_;
885}

◆ type()

Dart_CObject_Type dart::bin::CObject::type ( )
inline

Definition at line 338 of file dartutils.h.

338{ return cobject_->type; }

Member Data Documentation

◆ cobject_

Dart_CObject* dart::bin::CObject::cobject_
protected

Definition at line 407 of file dartutils.h.

◆ kArgumentError

constexpr int dart::bin::CObject::kArgumentError = 1
staticconstexpr

Definition at line 333 of file dartutils.h.

◆ kFileClosedError

constexpr int dart::bin::CObject::kFileClosedError = 3
staticconstexpr

Definition at line 335 of file dartutils.h.

◆ kOSError

constexpr int dart::bin::CObject::kOSError = 2
staticconstexpr

Definition at line 334 of file dartutils.h.

◆ kSuccess

constexpr int dart::bin::CObject::kSuccess = 0
staticconstexpr

Definition at line 332 of file dartutils.h.


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