Skip to content
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

Dart Example gives error with Dart 2.9.0-14.1.beta on MacOS #21

Open
satindergrewal opened this issue Jun 29, 2020 · 2 comments
Open

Dart Example gives error with Dart 2.9.0-14.1.beta on MacOS #21

satindergrewal opened this issue Jun 29, 2020 · 2 comments

Comments

@satindergrewal
Copy link

@dpurfield Thank you for giving Dart Example for FFI. But when I execute it, it gives the following errors.

Would really appreciate if you can help.

~ dart --version
Dart VM version: 2.9.0-14.1.beta (beta) (Tue Jun 9 10:52:57 2020 +0200) on "macos_x64"
$ dart client.dart 
client.dart:5:23: Error: Expected 0 type arguments.
class GoSlice extends Struct<GoSlice> {
                      ^
client.dart:35:24: Error: Expected 0 type arguments.
class GoString extends Struct<GoString> {
                       ^
client.dart:22:35: Error: Type argument 'GoSlice' doesn't conform to the bound 'NativeType' of the type variable 'T' on 'Pointer' in the return type.
 - 'GoSlice' is from 'client.dart'.
 - 'NativeType' is from 'dart:ffi'.
Try changing type arguments so that they conform to the bounds.
  static Pointer<GoSlice> fromList(List<int> units) {
                                  ^
client.dart:49:38: Error: Type argument 'GoString' doesn't conform to the bound 'NativeType' of the type variable 'T' on 'Pointer' in the return type.
 - 'GoString' is from 'client.dart'.
 - 'NativeType' is from 'dart:ffi'.
Try changing type arguments so that they conform to the bounds.
  static Pointer<GoString> fromString(String string) {
                                     ^
client.dart:17:35: Error: The method 'load' isn't defined for the class 'Pointer<Int64>'.
 - 'Pointer' is from 'dart:ffi'.
 - 'Int64' is from 'dart:ffi'.
Try correcting the name to the name of an existing method, or defining a method named 'load'.
      units.add(data.elementAt(i).load<int>());
                                  ^^^^
client.dart:23:32: Error: Method not found: 'Pointer.allocate'.
    final ptr = Pointer<Int64>.allocate(count: units.length);
                               ^^^^^^^^
client.dart:27:44: Error: Method not found: 'Pointer.allocate'.
    final GoSlice slice = Pointer<GoSlice>.allocate().load();
                                           ^^^^^^^^
client.dart:31:18: Error: The getter 'addressOf' isn't defined for the class 'GoSlice'.
 - 'GoSlice' is from 'client.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'addressOf'.
    return slice.addressOf;
                 ^^^^^^^^^
client.dart:44:37: Error: The method 'load' isn't defined for the class 'Pointer<Uint8>'.
 - 'Pointer' is from 'dart:ffi'.
 - 'Uint8' is from 'dart:ffi'.
Try correcting the name to the name of an existing method, or defining a method named 'load'.
      units.add(string.elementAt(i).load<int>());
                                    ^^^^
client.dart:51:32: Error: Method not found: 'Pointer.allocate'.
    final ptr = Pointer<Uint8>.allocate(count: units.length);

Thanks,
Satinder

@satindergrewal
Copy link
Author

I also tried codesign command as referred here dart-lang/sdk#38314 (comment), but that did not help either:

$ codesign --remove-signature awesome.so

$ dart client.dart                      
client.dart:5:23: Error: Expected 0 type arguments.
class GoSlice extends Struct<GoSlice> {
                      ^
client.dart:35:24: Error: Expected 0 type arguments.
class GoString extends Struct<GoString> {
                       ^
client.dart:22:35: Error: Type argument 'GoSlice' doesn't conform to the bound 'NativeType' of the type variable 'T' on 'Pointer' in the return type.
 - 'GoSlice' is from 'client.dart'.
 - 'NativeType' is from 'dart:ffi'.
Try changing type arguments so that they conform to the bounds.
  static Pointer<GoSlice> fromList(List<int> units) {
                                  ^
client.dart:49:38: Error: Type argument 'GoString' doesn't conform to the bound 'NativeType' of the type variable 'T' on 'Pointer' in the return type.
 - 'GoString' is from 'client.dart'.
 - 'NativeType' is from 'dart:ffi'.
Try changing type arguments so that they conform to the bounds.
  static Pointer<GoString> fromString(String string) {
                                     ^
client.dart:17:35: Error: The method 'load' isn't defined for the class 'Pointer<Int64>'.
 - 'Pointer' is from 'dart:ffi'.
 - 'Int64' is from 'dart:ffi'.
Try correcting the name to the name of an existing method, or defining a method named 'load'.
      units.add(data.elementAt(i).load<int>());
                                  ^^^^
client.dart:23:32: Error: Method not found: 'Pointer.allocate'.
    final ptr = Pointer<Int64>.allocate(count: units.length);
                               ^^^^^^^^
client.dart:27:44: Error: Method not found: 'Pointer.allocate'.
    final GoSlice slice = Pointer<GoSlice>.allocate().load();
                                           ^^^^^^^^
client.dart:31:18: Error: The getter 'addressOf' isn't defined for the class 'GoSlice'.
 - 'GoSlice' is from 'client.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'addressOf'.
    return slice.addressOf;
                 ^^^^^^^^^
client.dart:44:37: Error: The method 'load' isn't defined for the class 'Pointer<Uint8>'.
 - 'Pointer' is from 'dart:ffi'.
 - 'Uint8' is from 'dart:ffi'.
Try correcting the name to the name of an existing method, or defining a method named 'load'.
      units.add(string.elementAt(i).load<int>());
                                    ^^^^
client.dart:51:32: Error: Method not found: 'Pointer.allocate'.
    final ptr = Pointer<Uint8>.allocate(count: units.length);

@gargakshit
Copy link

If it is fine with the maintainers, I can make a PR to fix the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants