示例工程 ch10-ffi

ch10-ffi/lib/bindings/c_bindings_generated.dart

dart · 2.8 KB

// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
// ignore_for_file: type=lint, unused_import, unused_element, deprecated_member_use_from_same_package
import 'dart:ffi' as ffi;
 
/// 自动生成的 C 绑定(由 ffigen 从 native/c/add.h 生成)。
/// 不要手工修改,改头文件后重新运行 ffigen。
///
class CAdd {
  /// Holds the symbol lookup function.
  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
  _lookup;
 
  /// The symbols are looked up in [dynamicLibrary].
  CAdd(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup;
 
  /// The symbols are looked up with [lookup].
  CAdd.fromLookup(
    ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName) lookup,
  ) : _lookup = lookup;
 
  int add_i32(int a, int b) {
    return _add_i32(a, b);
  }
 
  late final _add_i32Ptr =
      _lookup<ffi.NativeFunction<ffi.Int32 Function(ffi.Int32, ffi.Int32)>>(
        'add_i32',
      );
  late final _add_i32 = _add_i32Ptr.asFunction<int Function(int, int)>();
 
  int apply_cb(
    ffi.Pointer<ffi.NativeFunction<ffi.Int32 Function(ffi.Int32)>> cb,
    int x,
  ) {
    return _apply_cb(cb, x);
  }
 
  late final _apply_cbPtr =
      _lookup<
        ffi.NativeFunction<
          ffi.Int32 Function(
            ffi.Pointer<ffi.NativeFunction<ffi.Int32 Function(ffi.Int32)>>,
            ffi.Int32,
          )
        >
      >('apply_cb');
  late final _apply_cb = _apply_cbPtr
      .asFunction<
        int Function(
          ffi.Pointer<ffi.NativeFunction<ffi.Int32 Function(ffi.Int32)>>,
          int,
        )
      >();
 
  ffi.Pointer<ffi.Char> concat_strings(
    ffi.Pointer<ffi.Char> a,
    ffi.Pointer<ffi.Char> b,
  ) {
    return _concat_strings(a, b);
  }
 
  late final _concat_stringsPtr =
      _lookup<
        ffi.NativeFunction<
          ffi.Pointer<ffi.Char> Function(
            ffi.Pointer<ffi.Char>,
            ffi.Pointer<ffi.Char>,
          )
        >
      >('concat_strings');
  late final _concat_strings = _concat_stringsPtr
      .asFunction<
        ffi.Pointer<ffi.Char> Function(
          ffi.Pointer<ffi.Char>,
          ffi.Pointer<ffi.Char>,
        )
      >();
 
  void free_string(ffi.Pointer<ffi.Char> s) {
    return _free_string(s);
  }
 
  late final _free_stringPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
        'free_string',
      );
  late final _free_string = _free_stringPtr
      .asFunction<void Function(ffi.Pointer<ffi.Char>)>();
 
  double mul_f64(double a, double b) {
    return _mul_f64(a, b);
  }
 
  late final _mul_f64Ptr =
      _lookup<ffi.NativeFunction<ffi.Double Function(ffi.Double, ffi.Double)>>(
        'mul_f64',
      );
  late final _mul_f64 = _mul_f64Ptr
      .asFunction<double Function(double, double)>();
}