dartApiDlForwarderContent function

String dartApiDlForwarderContent(
  1. String nitroNativePath
)

Returns the content of a dart_api_dl.c forwarder that includes the real file from the resolved nitro native path.

The forwarder is compiled as plain C (not C++) because the void*/function-pointer casts inside dart_api_dl.c would be rejected by a C++ compiler.

Implementation

String dartApiDlForwarderContent(String nitroNativePath) {
  final includePath = nitroNativePath
      .replaceAll(r'\', '/')
      .trimRight();
  return '// Generated by nitrogen link — do not edit.\n'
      '// Compiled as C (not C++) so the void*/function-pointer casts\n'
      '// in dart_api_dl.c are accepted by the compiler.\n'
      '#include "$includePath/dart_api_dl.c"\n';
}