Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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#.
- Host: GitHub
- URL: https://github.com/hexer10/dllimport_gen
- Owner: Hexer10
- License: bsd-3-clause
- Created: 2020-05-22T17:18:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-24T12:43:26.000Z (over 4 years ago)
- Last Synced: 2024-03-15T11:10:47.295Z (10 months ago)
- Topics: code, codegen, dart, ffi, generator
- Language: Dart
- Homepage:
- Size: 14.6 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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.