Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
dart_native_api.h File Reference
#include "dart_api.h"

Go to the source code of this file.

Classes

struct  _Dart_CObject
 

Typedefs

typedef struct _Dart_CObject Dart_CObject
 
typedef void(* Dart_NativeMessageHandler) (Dart_Port dest_port_id, Dart_CObject *message)
 

Enumerations

enum  Dart_CObject_Type {
  Dart_CObject_kNull = 0 , Dart_CObject_kBool , Dart_CObject_kInt32 , Dart_CObject_kInt64 ,
  Dart_CObject_kDouble , Dart_CObject_kString , Dart_CObject_kArray , Dart_CObject_kTypedData ,
  Dart_CObject_kExternalTypedData , Dart_CObject_kSendPort , Dart_CObject_kCapability , Dart_CObject_kNativePointer ,
  Dart_CObject_kUnsupported , Dart_CObject_kUnmodifiableExternalTypedData , Dart_CObject_kNumberOfTypes
}
 

Functions

DART_EXPORT bool Dart_PostCObject (Dart_Port port_id, Dart_CObject *message)
 
DART_EXPORT bool Dart_PostInteger (Dart_Port port_id, int64_t message)
 
DART_EXPORT Dart_Port Dart_NewNativePort (const char *name, Dart_NativeMessageHandler handler, bool handle_concurrently)
 
DART_EXPORT bool Dart_CloseNativePort (Dart_Port native_port_id)
 
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll (void)
 
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeAllClasses (void)
 
DART_EXPORT void * Dart_ExecuteInternalCommand (const char *command, void *arg)
 

Typedef Documentation

◆ Dart_CObject

typedef struct _Dart_CObject Dart_CObject

◆ Dart_NativeMessageHandler

typedef void(* Dart_NativeMessageHandler) (Dart_Port dest_port_id, Dart_CObject *message)

A native message handler.

This handler is associated with a native port by calling Dart_NewNativePort.

The message received is decoded into the message structure. The lifetime of the message data is controlled by the caller. All the data references from the message are allocated by the caller and will be reclaimed when returning to it.

Definition at line 150 of file dart_native_api.h.

Enumeration Type Documentation

◆ Dart_CObject_Type

A Dart_CObject is used for representing Dart objects as native C data outside the Dart heap. These objects are totally detached from the Dart heap. Only a subset of the Dart objects have a representation as a Dart_CObject.

The string encoding in the 'value.as_string' is UTF-8.

All the different types from dart:typed_data are exposed as type kTypedData. The specific type from dart:typed_data is in the type field of the as_typed_data structure. The length in the as_typed_data structure is always in bytes.

The data for kTypedData is copied on message send and ownership remains with the caller. The ownership of data for kExternalTyped is passed to the VM on message send and returned when the VM invokes the Dart_HandleFinalizer callback; a non-NULL callback must be provided.

Note that Dart_CObject_kNativePointer is intended for internal use by dart:io implementation and has no connection to dart:ffi Pointer class. It represents a pointer to a native resource of a known type. The receiving side will only see this pointer as an integer and will not see the specified finalizer. The specified finalizer will only be invoked if the message is not delivered.

Enumerator
Dart_CObject_kNull 
Dart_CObject_kBool 
Dart_CObject_kInt32 
Dart_CObject_kInt64 
Dart_CObject_kDouble 
Dart_CObject_kString 
Dart_CObject_kArray 
Dart_CObject_kTypedData 
Dart_CObject_kExternalTypedData 
Dart_CObject_kSendPort 
Dart_CObject_kCapability 
Dart_CObject_kNativePointer 
Dart_CObject_kUnsupported 
Dart_CObject_kUnmodifiableExternalTypedData 
Dart_CObject_kNumberOfTypes 

Definition at line 43 of file dart_native_api.h.

43 {
Dart_CObject_Type
@ Dart_CObject_kInt64
@ Dart_CObject_kNativePointer
@ Dart_CObject_kNumberOfTypes
@ Dart_CObject_kDouble
@ Dart_CObject_kUnmodifiableExternalTypedData
@ Dart_CObject_kTypedData
@ Dart_CObject_kSendPort
@ Dart_CObject_kString
@ Dart_CObject_kArray
@ Dart_CObject_kUnsupported
@ Dart_CObject_kNull
@ Dart_CObject_kExternalTypedData
@ Dart_CObject_kInt32
@ Dart_CObject_kBool
@ Dart_CObject_kCapability

Function Documentation

◆ Dart_CloseNativePort()

DART_EXPORT bool Dart_CloseNativePort ( Dart_Port  native_port_id)

Closes the native port with the given id.

The port must have been allocated by a call to Dart_NewNativePort.

Parameters
native_port_idThe id of the native port to close.
Returns
Returns true if the port was closed successfully.

◆ Dart_CompileAll()

DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll ( void  )

Forces all loaded classes and functions to be compiled eagerly in the current isolate..

TODO(turnidge): Document.

◆ Dart_ExecuteInternalCommand()

DART_EXPORT void * Dart_ExecuteInternalCommand ( const char *  command,
void *  arg 
)

◆ Dart_FinalizeAllClasses()

DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeAllClasses ( void  )

Finalizes all classes.

◆ Dart_NewNativePort()

DART_EXPORT Dart_Port Dart_NewNativePort ( const char *  name,
Dart_NativeMessageHandler  handler,
bool  handle_concurrently 
)

Creates a new native port. When messages are received on this native port, then they will be dispatched to the provided native message handler.

Parameters
nameThe name of this port in debugging messages.
handlerThe C handler to run when messages arrive on the port.
handle_concurrentlyIs it okay to process requests on this native port concurrently?
Returns
If successful, returns the port id for the native port. In case of error, returns ILLEGAL_PORT.

◆ Dart_PostCObject()

DART_EXPORT bool Dart_PostCObject ( Dart_Port  port_id,
Dart_CObject message 
)

Posts a message on some port. The message will contain the Dart_CObject object graph rooted in 'message'.

While the message is being sent the state of the graph of Dart_CObject structures rooted in 'message' should not be accessed, as the message generation will make temporary modifications to the data. When the message has been sent the graph will be fully restored.

If true is returned, the message was enqueued, and finalizers for external typed data will eventually run, even if the receiving isolate shuts down before processing the message. If false is returned, the message was not enqueued and ownership of external typed data in the message remains with the caller.

This function may be called on any thread when the VM is running (that is, after Dart_Initialize has returned and before Dart_Cleanup has been called).

Parameters
port_idThe destination port.
messageThe message to send.
Returns
True if the message was posted.

◆ Dart_PostInteger()

DART_EXPORT bool Dart_PostInteger ( Dart_Port  port_id,
int64_t  message 
)

Posts a message on some port. The message will contain the integer 'message'.

Parameters
port_idThe destination port.
messageThe message to send.
Returns
True if the message was posted.