Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 897 of file dartutils.cc.

897 {
898 return value ? &true_ : &false_;
899}
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 893 of file dartutils.cc.

893 {
894 return &false_;
895}

◆ FileClosedError()

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

Definition at line 1038 of file dartutils.cc.

1038 {
1039 CObjectArray* result = new CObjectArray(CObject::NewArray(1));
1040 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kFileClosedError)));
1041 return result;
1042}
static constexpr int kFileClosedError
Definition dartutils.h:335
static Dart_CObject * NewArray(intptr_t length)
Definition dartutils.cc:942
static Dart_CObject * NewInt32(int32_t value)
Definition dartutils.cc:908
GAsyncResult * result

◆ FreeIOBufferData()

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

Definition at line 1025 of file dartutils.cc.

1025 {
1026 ASSERT(cobject->type == Dart_CObject_kExternalTypedData);
1027 cobject->value.as_external_typed_data.callback(
1028 nullptr, cobject->value.as_external_typed_data.peer);
1029 cobject->value.as_external_typed_data.data = nullptr;
1030}

◆ IllegalArgumentError()

CObject * dart::bin::CObject::IllegalArgumentError ( )
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(kArgumentError)));
1035 return result;
1036}
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(); }

◆ 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:2606

◆ NewArray()

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

Definition at line 942 of file dartutils.cc.

942 {
943 Dart_CObject* cobject =
944 New(Dart_CObject_kArray, length * sizeof(Dart_CObject*)); // NOLINT
945 cobject->value.as_array.length = length;
946 cobject->value.as_array.values =
947 reinterpret_cast<Dart_CObject**>(cobject + 1);
948 return cobject;
949}
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 927 of file dartutils.cc.

927 {
928 Dart_CObject* cobject = New(Dart_CObject_kDouble);
929 cobject->value.as_double = value;
930 return cobject;
931}

◆ NewExternalUint8Array()

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

Definition at line 961 of file dartutils.cc.

964 {
969 cobject->value.as_external_typed_data.peer = peer;
971 return cobject;
972}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static int8_t data[kExtLength]
Dart_HandleFinalizer callback
struct _Dart_CObject::@86::@91 as_external_typed_data

◆ NewInt32()

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

Definition at line 908 of file dartutils.cc.

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

◆ NewInt64()

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

Definition at line 914 of file dartutils.cc.

914 {
915 Dart_CObject* cobject = New(Dart_CObject_kInt64);
916 cobject->value.as_int64 = value;
917 return cobject;
918}

◆ NewIntptr()

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

Definition at line 920 of file dartutils.cc.

920 {
921 // Pointer values passed as intptr_t are always send as int64_t.
922 Dart_CObject* cobject = New(Dart_CObject_kInt64);
923 cobject->value.as_int64 = value;
924 return cobject;
925}

◆ NewIOBuffer()

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

Definition at line 984 of file dartutils.cc.

984 {
985 // Make sure that we do not have an integer overflow here. Actual check
986 // against max elements will be done at the time of writing, as the constant
987 // is not part of the public API.
988 if ((length < 0) || (length > kIntptrMax)) {
989 return nullptr;
990 }
991 uint8_t* data = IOBuffer::Allocate(static_cast<intptr_t>(length));
992 if (data == nullptr) {
993 return nullptr;
994 }
995 return NewExternalUint8Array(static_cast<intptr_t>(length), data, data,
997}
static Dart_CObject * NewExternalUint8Array(intptr_t length, uint8_t *data, void *peer, Dart_HandleFinalizer callback)
Definition dartutils.cc:961
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 974 of file dartutils.cc.

976 {
978 cobject->value.as_native_pointer.ptr = ptr;
979 cobject->value.as_native_pointer.size = size;
981 return cobject;
982}
@ 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 1044 of file dartutils.cc.

1044 {
1045 OSError os_error;
1046 return NewOSError(&os_error);
1047}
static CObject * NewOSError()

◆ NewOSError() [2/2]

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

Definition at line 1049 of file dartutils.cc.

1049 {
1050 CObject* error_message =
1051 new CObjectString(CObject::NewString(os_error->message()));
1052 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1053 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1054 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1055 result->SetAt(2, error_message);
1056 return result;
1057}
static Dart_CObject * NewString(const char *str)
Definition dartutils.cc:933
static constexpr int kOSError
Definition dartutils.h:334

◆ NewString()

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

Definition at line 933 of file dartutils.cc.

933 {
934 intptr_t length = strlen(str);
935 Dart_CObject* cobject = New(Dart_CObject_kString, length + 1);
936 char* payload = reinterpret_cast<char*>(cobject + 1);
937 memmove(payload, str, length + 1);
938 cobject->value.as_string = payload;
939 return cobject;
940}
const char * as_string

◆ NewUint8Array()

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

Definition at line 951 of file dartutils.cc.

951 {
953 memmove(reinterpret_cast<uint8_t*>(cobject + 1), data, length);
955 cobject->value.as_typed_data.length = length;
956 cobject->value.as_typed_data.values =
957 reinterpret_cast<const uint8_t*>(cobject + 1);
958 return cobject;
959}

◆ Null()

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

Definition at line 885 of file dartutils.cc.

885 {
886 return &null_;
887}

◆ 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 999 of file dartutils.cc.

999 {
1000 if (cobject == nullptr) return;
1002
1003 const auto old_data = cobject->value.as_external_typed_data.data;
1004 const auto old_length = cobject->value.as_external_typed_data.length;
1005
1006 // We only shrink IOBuffers, never grow them.
1007 ASSERT(0 <= new_length && new_length <= old_length);
1008
1009 // We only reallocate if we think the freed space is worth reallocating.
1010 // We consider it worthwhile when freed space is >=25% and we have at
1011 // least 100 free bytes.
1012 const auto free_memory = old_length - new_length;
1013 if ((old_length >> 2) <= free_memory && 100 <= free_memory) {
1014 const auto new_data = IOBuffer::Reallocate(old_data, new_length);
1015 if (new_data != nullptr) {
1016 cobject->value.as_external_typed_data.data = new_data;
1017 cobject->value.as_external_typed_data.peer = new_data;
1018 }
1019 }
1020
1021 // The typed data object always has to have the shranken length.
1022 cobject->value.as_external_typed_data.length = new_length;
1023}
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 889 of file dartutils.cc.

889 {
890 return &true_;
891}

◆ 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: