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

[coreimage] Update for Xcode 11[.2] #7216

Merged
merged 11 commits into from Oct 16, 2019

Conversation

spouliot
Copy link
Contributor

Apple decided to expose most (but not all) CIFilter using protocols
(instead of weakly named dictionaries). Most of this maps well with
our strong bindings but there are cases where we:

  • missing some properties (easy, there were added); or
  • used a different types [1] and that requires new members / obsoletion

[1] Often ours are better (using float for a bool value is not
optimal) but we do not have [BindAs] for protocols :( to fix them

Note: this replace draft PR #7120 but it's has quite a bit of changes in filter generation (inlining protocols) and that affected bindings too.

Apple decided to expose most (but not all) `CIFilter` using protocols
(instead of weakly named dictionaries). Most of this maps well with
our strong bindings but there are cases where we:

* missing some properties (easy, there were added); or
* used a different types [1] and that requires new members / obsoletion

[1] Often ours are better (using `float` for a `bool` value is not
optimal) but we do not have `[BindAs]` for protocols :( to _fix_ them

Note: this replace draft PR xamarin#7120 but it's has quite a bit of changes in filter generation (inlining protocols) and that affected bindings too.
Copy link
Contributor

@VincentDondain VincentDondain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-read everything and I could not spot anything so LGTM 👍

This PR is a beast :P

interface CIKeystoneCorrectionHorizontal {
interface CIKeystoneCorrectionHorizontal : ICIKeystoneCorrectionHorizontalProtocol {

#if false // no documentation about the type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we tried not to push dead code 😉. Couldn't it just be in the xtro ignore file with a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's (almost) no headers for CIFilters, so no xtro reminders

almost because some stuff is now defined in protocols - and those are in headers, but the rest is not (it's all key/value based)

src/coreimage.cs Outdated
// `CILinearGradientProtocol` is a bit of a lie - but it would not compile (registrar) otherwise
interface CISmoothLinearGradientProtocol : CILinearGradientProtocol {

/* we get those from ICILinearGradientProtocol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we're keeping this code in case it's ever added again, wouldn't a #if false be better?
Similar to my comment above I don't know if we want dead code (:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, left over from the original attempt. I think that's fixed (properly) now. I'll uncomment it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncommented (that scenario works fine now)

src/coreimage.cs Outdated
@@ -2645,29 +2788,23 @@ interface CIImageProcessorKernel {
[iOS (8,0)]
[Mac (10,10)]
[BaseType (typeof (CIFilter))]
interface CIAccordionFoldTransition {
interface CIAccordionFoldTransition : ICIAccordionFoldTransitionProtocol {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spouliot I see you are using the I version of CIAccordionFoldTransitionProtocol is that intentional? IIRC you have to use the I less version when doing this else the generator won't do the right thing.

Also I see this being mixed in the whole PR, for example the following does what I expect :)

interface CIAccordionFoldTransitionProtocol : CITransitionFilterProtocol {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, I'll review those

CIFilter subclasses are generated differently that normal NSObjectso the end-result might be (nearly) identical. IOW I think my generator changes are not correct, with incorrect data giving the correct output.

Comment on lines 228 to 229
if (v is NSNumber)
return (v as NSNumber).NIntValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be done with just using the as? Like:

var n = v as NSNumber;
return n?.NIntValue ?? 0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (v is NSNumber n)
    return n.NIntValue;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was a copy/paste of the existing GetInt method, but I can fix all of them
who's counting the lines anyway :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in newer commits

{
return ValueForKey (CIFilterInputKey.Image) as CIImage;
var v = ValueForKey (key) as CIVector;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as can return null, right? So unless we are 100% sure.. I'd check that.

using (var nsstr = new NSString (key))
return ValueForKey (nsstr) as CIImage;
var v = ValueForKey (key) as CIVector;
return new CGRect (v.X, v.Y, v.Z, v.W);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.


[iOS (13,0)][TV (13,0)][Watch (6,0)][Mac (10,15)]
[Field ("kCIImageAuxiliarySemanticSegmentationTeethMatte")]
NSString AuxiliarySemanticSegmentationTeethMatteKey { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look like they could be a smart enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's actually a inside a type used tp create a strong dictionary [StrongDictionary ("CIImageInitializationOptionsKeys")] but I did not add the keys to it :| I'll fix this

Makes me wish for #6785 even more

src/coreimage.cs Outdated

[iOS (13,0)][TV (13,0)][Watch (6,0)][Mac (10,15)]
[Static]
[Wrap ("FromCGImageSource (source, index, options == null ? null : options.Dictionary)")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change, but I think options?.Dictionary would be the same.

src/coreimage.cs Outdated
IntPtr Constructor (CGImageSource source, nuint index, [NullAllowed] NSDictionary options);

[iOS (13,0)][TV (13,0)][Watch (6,0)][Mac (10,15)]
[Wrap ("this (source, index, options == null ? null : options.Dictionary)")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same options?.Dictionary should be the same.

[Static]
[Export ("imageWithSemanticSegmentationMatte:options:")]
[return: NullAllowed]
CIImage FromSemanticSegmentationMatte (AVSemanticSegmentationMatte matte, [NullAllowed] NSDictionary options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know about the options? Could it be a strong dictionary?


[TV (13,0), iOS (13,0), Mac (10,15)]
[Export ("initWithSemanticSegmentationMatte:options:")]
IntPtr Constructor (AVSemanticSegmentationMatte matte, [NullAllowed] NSDictionary options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know about the options? Could it be a string dictionary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string ? no, strong ? maybe :)

It was not documented before but now that
typedef NSString *CIImageOption;
was added we can be pretty sure it's the same as the one I mentioned above

However there's a lot of older members that also use NSDictionary so, to keep this PR from calling unicorns, I'll fix that in a separate PR.


[iOS (13,0)][TV (13,0)][Watch (6,0)][Mac (10,15)]
[Field ("kCIImageRepresentationSemanticSegmentationTeethMatteImage")]
NSString SemanticSegmentationTeethMatteImageKey { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like they could be a smart enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, but it's part of the type used for a strong dictionary: CIImageRepresentationOptions

I'll look if the types are documented, we are already missing a few of those

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, headers (not web doc) do mention the types of those (and the one we were missing from last year)


[Static]
[NullAllowed, Export ("customAttributes")]
NSDictionary<NSString, NSObject> CustomAttributes { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know anything about the attributes? Strong dict will be nicer if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
⚠️ Mono built from source
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

22 tests failed, 73 tests passed.

Failed tests

  • apitest/Mac Modern/Debug: Failed (Test run crashed (exit code: 134).)
  • introspection/Mac Modern/Debug: Failed (Test run failed.)
  • xammac tests/Mac Modern/Debug: Failed (Test run crashed (exit code: 134).)
  • xammac tests/Mac Modern/Release: Failed (Test run crashed (exit code: 134).)
  • xammac tests/Mac Modern/Release: Failed (Test run crashed (exit code: 134).)
  • apitest/Mac Full/Debug: Failed (Test run crashed (exit code: 134).)
  • monotouch-test/iOS Unified 32-bits - simulator/Debug: Failed
  • introspection/iOS Unified 32-bits - simulator/Debug: Failed
  • monotouch-test/iOS Unified 32-bits - simulator/Debug (LinkSdk): Failed
  • monotouch-test/iOS Unified 32-bits - simulator/Debug (static registrar): Failed
  • monotouch-test/iOS Unified 32-bits - simulator/Release (all optimizations): Failed
  • introspection/iOS Unified 32-bits - simulator/Debug (iOS 10.3): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (LinkSdk): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (static registrar): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Release (all optimizations): Failed
  • monotouch-test/tvOS - simulator/Debug: Failed
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar): Failed
  • monotouch-test/tvOS - simulator/Release (all optimizations): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2): Failed

// we can skip the name when it's identical to a protocol selector
if (name == null) {
if (export == null)
throw new BindingException (9999, true, $"Missing [CoreImageFilterProperty] attribute on {type.Name} property {ptype}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual error code is needed.

Also don't use string interpolation (we'll have to make everything use string.Format-syntax when we start translating text anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... how would translating {0} be different from {ptype} ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem isn't translating it, but using the translated string in C#. String interpolation requires the string to be a literal string, and translated strings aren't literal (https://stackoverflow.com/a/32360534/183422)

@monojenkins
Copy link
Collaborator

Build failure
Build failed or was aborted

🔥 Provisioning failed 🔥

@monojenkins
Copy link
Collaborator

Build failure
Build failed or was aborted

🔥 Provisioning failed 🔥

@spouliot
Copy link
Contributor Author

build

@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
⚠️ Mono built from source
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

9 tests failed, 86 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Test run failed.)
  • Xtro/Mac: BuildFailure
  • introspection/iOS Unified 32-bits - simulator/Debug: Failed
  • introspection/iOS Unified 32-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (static registrar): Crashed
  • introspection/tvOS - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2): Failed

@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
⚠️ Mono built from source
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

2 tests failed, 93 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • introspection/tvOS - simulator/Debug: Failed

@monojenkins
Copy link
Collaborator

Build success
Build succeeded
⚠️ Mono built from source
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
Test run succeeded

@spouliot
Copy link
Contributor Author

@mandel-macaque @dalexsoto your feedback should all be addressed now

@monojenkins
Copy link
Collaborator

Build success
Build succeeded
⚠️ Mono built from source
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
Test run succeeded

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now 👍

@spouliot spouliot merged commit a50c753 into xamarin:xcode11.2 Oct 16, 2019
@spouliot spouliot deleted the xcode112-coreimage branch October 16, 2019 13:16
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

Successfully merging this pull request may close these issues.

None yet

6 participants