-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve function parameter names in output #515
Comments
The generator should preserve the names, but only if the names are present in the header file you passed into it. |
All arguments are all arg0, arg1 etc. This is from the header files: inline bool MoneyRange(const CAmount& nValue) {
// ..
} In the output, Btw, this is CAmount in the file, although it is not included in the output: typedef int64_t CAmount; This is my config: ffigen:
output: 'generated_bridge.dart'
headers:
- 'src/example/src/amount.h'
header-filter:
exclude:
- 'stdint.h'
- 'stdio.h'
- 'stdlib.h'
- 'assert.h'
name: 'Bridge'
description: 'Bridge to example'
array-workaround: true |
That's strange, could you try running |
Here's the output for the verbose ffigen: Here's the source file: Here's the actual dart output: /// AUTO GENERATED FILE, DO NOT EDIT.
///
/// Generated by `package:ffigen`.
import 'dart:ffi' as ffi;
/// Bridge to example
class ExampleBridge {
/// Holds the Dynamic library.
final ffi.DynamicLibrary _dylib;
/// The symbols are looked up in [dynamicLibrary].
ExampleBridge(ffi.DynamicLibrary dynamicLibrary) : _dylib = dynamicLibrary;
int MoneyRange(
int arg0,
) {
_MoneyRange ??=
_dylib.lookupFunction<_c_MoneyRange, _dart_MoneyRange>('MoneyRange');
return _MoneyRange(
arg0,
);
}
_dart_MoneyRange _MoneyRange;
}
class __fsid_t extends ffi.Struct {
@ffi.Int32()
int _unique___val_item_0;
@ffi.Int32()
int _unique___val_item_1;
/// Helper for array `__val`.
ArrayHelper___fsid_t___val_level0 get __val =>
ArrayHelper___fsid_t___val_level0(this, [2], 0, 0);
}
/// Helper for array `__val` in struct `__fsid_t`.
class ArrayHelper___fsid_t___val_level0 {
final __fsid_t _struct;
final List<int> dimensions;
final int level;
final int _absoluteIndex;
int get length => dimensions[level];
ArrayHelper___fsid_t___val_level0(
this._struct, this.dimensions, this.level, this._absoluteIndex);
void _checkBounds(int index) {
if (index >= length || index < 0) {
throw RangeError(
'Dimension $level: index not in range 0..${length} exclusive.');
}
}
int operator [](int index) {
_checkBounds(index);
switch (_absoluteIndex + index) {
case 0:
return _struct._unique___val_item_0;
case 1:
return _struct._unique___val_item_1;
default:
throw Exception('Invalid Array Helper generated.');
}
}
void operator []=(int index, int value) {
_checkBounds(index);
switch (_absoluteIndex + index) {
case 0:
_struct._unique___val_item_0 = value;
break;
case 1:
_struct._unique___val_item_1 = value;
break;
default:
throw Exception('Invalid Array Helper generated.');
}
}
}
typedef _c_MoneyRange = ffi.Int32 Function(
ffi.Int64 arg0,
);
typedef _dart_MoneyRange = int Function(
int arg0,
); (I replaced a few names here and there just to keep it generic) |
Thanks.
It tries to somehow fix the errors while parse the source, and during that process is not able to get the argument name
|
Tried parsing this as typedef long long CAmount;
bool MoneyRange(const CAmount& nValue); Tool cannot parse this (as of now )because
|
Oh yeah, cool. I removed the by reference (just for testing) and the param name shows up now. Any reason why the return type bool isn't supported? Just curious. |
When I parse the header files, all parameter names are being replace with
arg0
arg1
arg2
. It would be very usefull if the generator could keep the original name instead of the numbered arguments.output
to
The text was updated successfully, but these errors were encountered: