github.com/hsfzxjy/dgo/go@v0.2.0/ffi.h (about)

     1  #ifndef DGO_VALUE_H
     2  #define DGO_VALUE_H
     3  
     4  #include "dart_api.h"
     5  #include "dart_api_dl.h"
     6  #include "dart_native_api.h"
     7  
     8  typedef struct _dgo__Dart_CObject {
     9    Dart_CObject_Type Type;
    10    union {
    11      bool    as_bool;
    12      int32_t as_int32;
    13      int64_t as_int64;
    14      double  as_double;
    15      char *  as_string;
    16      struct {
    17        Dart_Port id;
    18        Dart_Port origin_id;
    19      } as_send_port;
    20      struct {
    21        int64_t id;
    22      } as_capability;
    23      struct {
    24        intptr_t                    length;
    25        struct _dgo__Dart_CObject **values;
    26      } as_array;
    27      struct {
    28        Dart_TypedData_Type type;
    29        intptr_t            length; /* in elements, not bytes */
    30        uint8_t *           values;
    31      } as_typed_data;
    32      struct {
    33        Dart_TypedData_Type  type;
    34        intptr_t             length; /* in elements, not bytes */
    35        uint8_t *            data;
    36        void *               peer;
    37        Dart_HandleFinalizer callback;
    38      } as_external_typed_data;
    39      struct {
    40        intptr_t             ptr;
    41        intptr_t             size;
    42        Dart_HandleFinalizer callback;
    43      } as_native_pointer;
    44    } Value;
    45  } dgo__Dart_CObject;
    46  
    47  typedef struct {
    48    Dart_TypedData_Type Type;
    49    intptr_t            Length;
    50    uint8_t *           Values;
    51  } dgo__Dart_CObject_AsTypedData;
    52  
    53  typedef struct {
    54    intptr_t       Length;
    55    Dart_CObject **Values;
    56  } dgo__Dart_CObject_AsArray;
    57  
    58  typedef struct {
    59    Dart_TypedData_Type Type;
    60    intptr_t            Length; /* in elements, not bytes */
    61    uint8_t *           Data;
    62    uintptr_t           Peer;     // mod: from void*
    63    uintptr_t           Callback; // mod: from Dart_HandleFinalizer
    64  } dgo__Dart_Cobject_AsExternalTypedData;
    65  
    66  void         dgo__InitFFI(void *data);
    67  Dart_Port_DL dgo__InitPort(Dart_Port_DL send_port_id);
    68  bool dgo__PostCObjects(Dart_Port_DL port_id, int cnt, dgo__Dart_CObject *cobjs);
    69  bool dgo__PostCObjects2(
    70      Dart_Port_DL       port_id,
    71      int                cnt1,
    72      dgo__Dart_CObject *cobjs1,
    73      int                cnt2,
    74      dgo__Dart_CObject *cobjs2);
    75  bool dgo__PostCObject(Dart_Port_DL port_id, dgo__Dart_CObject *cobj);
    76  bool dgo__PostInt(Dart_Port_DL port_id, int64_t value);
    77  bool dgo__CloseNativePort(Dart_Port_DL port_id);
    78  
    79  extern uintptr_t dgo__pGoFinalizer;
    80  
    81  #endif