dart-archive / ffi

Utilities for working with Foreign Function Interface (FFI) code
https://pub.dev/packages/ffi
BSD 3-Clause "New" or "Revised" License
155 stars 32 forks source link

Invocation native function of namespace PlatformConfigurationNativeApi #205

Closed virtualzeta closed 1 year ago

virtualzeta commented 1 year ago

Is there a way for a normal developer of the framework (not engine or otherwise) to have the symbols of the native functions of namespace PlatformConfigurationNativeApi (defined in FFI_FUNCTION_LIST) to invokate and use them in the app code?

Like for example PlatformConfigurationNativeApi::GetRootIsolateToken to be declared/invoked with the lookup method on the correct library or with:

   @FfiNative<Int64 Function()>(
       'PlatformConfigurationNativeApi::GetRootIsolateToken')
   external int getRootIsolateToken();

roughly as is done in the dart:ui library.

I randomly checked if the symbols are present in the global ones with DynamicLibrary.process().providesSymbol("PlatformConfigurationNativeApi::GetRootIsolateToken") or in the libflutter.so library after loading it with DynamicLibrary.open (which anyway I think is useless because all those symbols should already be loaded globally) but they are not there.

I also take the opportunity to ask if a DynamicLibrary method is available or planned to be implemented to get the list of symbols present in the library concerned rather than having to perform a specific check on the symbol to see if it exists.

Thank you.

dcharkes commented 1 year ago

This is a decision for the Flutter team whether to expose those functions yes or no. (I would expect no, as there are probably a bunch of invariants kept consistent between the Dart and C code. And also the dart_api.h which is a public C API in Dart is hidden in Flutter.)

dcharkes commented 1 year ago

I can't transfer this issue to the flutter/fluter repo from here, please open an issue there.