[go: nahoru, domu]

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

Subclass overriding methods that return/take NSRange not correctly generated #1180

Open
brianquinlan opened this issue May 30, 2024 · 8 comments
Assignees

Comments

@brianquinlan
Copy link
Contributor

When generating code for NSMutableIndexSet, this code is produced:

final class _NSRange extends ffi.Struct {
  @NSUInteger()
  external int location;

  @NSUInteger()
  external int length;
}

typedef NSRange = _NSRange;

class NSMutableIndexSet extends objc.NSIndexSet {
  ...
  @override
  objc.NSIndexSet initWithIndexesInRange_(NSRange range) {
    final _ret =
        _objc_msgSend_16(this.pointer, _sel_initWithIndexesInRange_, range);
    return NSMutableIndexSet.castFromPointer(_ret, retain: true, release: true);
  }
  ...
}

But package:objective_c defines NSIndexSet` like:

class NSIndexSet extends NSObject {
   ...
  NSIndexSet initWithIndexesInRange_(_NSRange range) {
    final _ret =
        _objc_msgSend_118(this.pointer, _sel_initWithIndexesInRange_, range);
    return NSIndexSet.castFromPointer(_ret, retain: true, release: true);
  }
  ...

Since the NSRange used in the base and subclass don't match, the @override is not valid. Probably NSRange has to be part of package:objective_c and generated code must reference that.

@brianquinlan
Copy link
Contributor Author

Maybe NSMutableIndexSet should be part of package:objective_c.

@brianquinlan
Copy link
Contributor Author

Name issue for NSSimpleCString for these methods:

  • initWithCharactersNoCopy_length_deallocator_ (because of deallocator)
  • initWithFormat_arguments_ (because of va_list)
  • initWithFormat_locale_arguments_ (because of va_list)
  • initWithValidatedFormat_validFormatSpecifiers_arguments_error_ (because of va_list)
  • initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_ (becase of va_list)
  • initWithBytesNoCopy_length_encoding_deallocator_ (because of deallocator)

@brianquinlan
Copy link
Contributor Author

I think that you fixed this.

@liamappelbe
Copy link
Contributor

Not sure if it's fixed, but package:objective_c should probably export the NSRange struct, and any other structs it defines.

@brianquinlan
Copy link
Contributor Author

Doesn't package:objective_c have to export every type that appears anywhere in any API that it exports?

@liamappelbe
Copy link
Contributor

Yep. I've exported all the interfaces, but not the structs.

@brianquinlan
Copy link
Contributor Author

If you wanted to add a test that verifies that you have exported everything that you need to, you could use dart:mirrors.

@brianquinlan
Copy link
Contributor Author

Ah, that would explain why the generated buildings are still incorrect:

  @override
  NSMutableIndexSet initWithIndexesInRange_(NSRange range) {
'NSMutableIndexSet.initWithIndexesInRange_' ('NSMutableIndexSet Function(_NSRange)') isn't a valid override of 'NSIndexSet.initWithIndexesInRange_' ('NSIndexSet Function(_NSRange)').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

No branches or pull requests

2 participants