From aa4d83e68fc91688e9f8018a13465651346ee6b9 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Tue, 27 Feb 2024 09:52:11 +0100 Subject: [PATCH] Improve docs --- .../lib/src/api/c_code_asset.dart | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkgs/native_assets_cli/lib/src/api/c_code_asset.dart b/pkgs/native_assets_cli/lib/src/api/c_code_asset.dart index bfcb3c060..aa88c11e0 100644 --- a/pkgs/native_assets_cli/lib/src/api/c_code_asset.dart +++ b/pkgs/native_assets_cli/lib/src/api/c_code_asset.dart @@ -9,11 +9,25 @@ part of 'asset.dart'; /// Typical other languages which produce code assets that respect the C ABI /// include C++ and Rust. /// +/// C code assets can be accessed at runtime through native external functions +/// via their asset [id]: +/// +/// ```dart +/// import 'dart:ffi'; +/// +/// void main() { +/// final result = add(14, 28); +/// print(result); +/// } +/// +/// @Native(assetId: 'package:my_package/add.dart') +/// external int add(int a, int b); +/// ``` +/// /// There are several types of C code assets: /// * Assets which designate symbols present in the target system /// ([SystemDylib]), process ([LookupInProcess]), or executable -/// ([LookupInExecutable]). These assets are identified by their [id], and do -/// not have a [file]. +/// ([LookupInExecutable]). These assets do not have a [file]. /// * Dynamic libraries bundled into the application ([BundledDylib]). These /// assets must provide a [file] to be bundled. /// @@ -28,9 +42,6 @@ part of 'asset.dart'; /// target system ([SystemDylib]). If the asset is bundled "manually", the Dart /// or Flutter SDK will take care of copying the asset [file] from its specified /// location on the current system into the application bundle. -/// -/// Assets are also called "native assets" to differentiate them from the Dart -/// code also bundled with an application. abstract final class CCodeAsset implements Asset { /// The operating system this asset can run on. OS get os;