Skip to content

Commit

Permalink
feat: try typedef to handle allo-isolate
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed Jan 4, 2024
1 parent d6ed831 commit 9a3bfa2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frb_codegen/src/library/commands/cbindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ pub(crate) fn default_cbindgen_config() -> cbindgen::Config {
cbindgen::Config {
// copied from: dart-sdk/dart_api.h
// used to convert Dart_Handle to Object.
after_includes: Some("typedef struct _Dart_Handle* Dart_Handle;".to_owned()),
after_includes: Some(
"typedef struct _Dart_Handle* Dart_Handle;\ntypedef struct Dart_CObject DartCObject;"
.to_owned(),
),
language: cbindgen::Language::C,
sys_includes: vec![
"stdbool.h".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdlib.h>
typedef struct _Dart_Handle* Dart_Handle;
typedef struct Dart_CObject DartCObject;
#include "dart_api.h"

/**
Expand Down
1 change: 1 addition & 0 deletions frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdlib.h>
typedef struct _Dart_Handle* Dart_Handle;
typedef struct Dart_CObject DartCObject;
#include "dart_api.h"
#include "dart_native_api.h"

Expand Down
5 changes: 4 additions & 1 deletion frb_dart/lib/src/ffigen_generated/multi_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ typedef Dart_NativeMessageHandler = ffi.Pointer<

final class _Dart_Handle extends ffi.Opaque {}

final class Dart_CObject1 extends ffi.Opaque {}

/// Posts a message on some port. The message will contain the
/// Dart_CObject object graph rooted in 'message'.
///
Expand All @@ -561,10 +563,11 @@ final class _Dart_Handle extends ffi.Opaque {}
/// return true if the message was posted.
typedef DartPostCObjectFnType = ffi.Pointer<
ffi.NativeFunction<
ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Int> message)>>;
ffi.Bool Function(DartPort port_id, ffi.Pointer<DartCObject> message)>>;

/// A port is used to send or receive inter-isolate messages
typedef DartPort = ffi.Int64;
typedef DartCObject = Dart_CObject1;

final class WireSyncRust2DartSse extends ffi.Struct {
external ffi.Pointer<ffi.Uint8> ptr;
Expand Down

0 comments on commit 9a3bfa2

Please sign in to comment.