Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hexer10/dllimport_gen

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.
https://github.com/hexer10/dllimport_gen

code codegen dart ffi generator

Last synced: 24 days ago
JSON representation

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

Awesome Lists containing this project

README

        

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

Example:

```dart
import 'package:dllimport_gen/dll_import.dart';

import 'example.ffi.g.dart';

@DllImport('user32.dll')
abstract class User32 {
/// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setcursorpos
BOOL SetCursorPos(int X, int Y);
}

@DllImport('kernel32.dll')
abstract class Kernel32 {
/// https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
DWORD GetLastError();
}

void main() {
var user32 = FFIUser32();
var kernel = FFIKernel32();
var success = user32.SetCursorPos(0, 0) != 0;
if (!success) {
print('Failed: ${kernel.GetLastError()}');
}
}
```

Run the code generation:
`pub run build_runner build`

See `example/`


Use `@Import('')` to import a custom library in the generated file, if for example you're using your custom structs.