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

Bridged Casting Not Supported #33

Closed
TorreyBetts opened this issue Aug 7, 2015 · 4 comments
Closed

Bridged Casting Not Supported #33

TorreyBetts opened this issue Aug 7, 2015 · 4 comments

Comments

@TorreyBetts
Copy link

When you have code such as the following, should the __bridge cast be supported?

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.duration = _progressAnimationDuration;
animation.timingFunction = [CAMediaTimingFunction functionWithName:_progressAnimationTimingFunction];
animation.fromValue = (__bridge id) oldPath;
animation.toValue = (__bridge id) path;
[_progressShape addAnimation:animation forKey:@"animatePath"];
@jmsaunders-ms
Copy link
Contributor

We haven't seen issues involving bridged casts. Are you positive you have ARC enabled?

How did you set your project up? Is it imported? (Perhaps ARC settings aren't being preserved) If it's just some code you added after enabling ObjC support in MSVC then you can enable ARC per-file or per-project in the settings dialog.

Can I get a compiler log of the error you're seeing?

@TorreyBetts
Copy link
Author

I created a project this morning to demonstrate the issue. Also, this project was imported using vsimporter. Here's the VS log when attempting to build.

1>------ Build started: Project: WinObjC_Issue33 (WinObjC_Issue33\WinObjC_Issue33), Configuration: Debug Win32 ------
1>  ConsumeRuntimeComponent.cpp
1>  ..\..\WinObjC_Issue33\main.m
1>  ..\..\WinObjC_Issue33\AppDelegate.m
1>  ..\..\WinObjC_Issue33\ViewController.m
1>C:\winobjc\samples\WinObjC_Issue33\WinObjC_Issue33\ViewController.m(71,27): error : incompatible types casting 'CGPathRef' (aka 'id') to 'id' with a __bridge cast
1>C:\winobjc\samples\WinObjC_Issue33\WinObjC_Issue33\ViewController.m(72,25): error : incompatible types casting 'CGPathRef' (aka 'id') to 'id' with a __bridge cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

Project can be downloaded here: https://www.dropbox.com/s/5hcvs7m6s15d4g9/WinObjC_Issue33.zip?dl=0

@jmsaunders-ms
Copy link
Contributor

Thanks for the example.

The reason this is happening is because the iOS version of CGPathRef is a struct*, a C type. Our version is an id, which means no bridge cast is necessary in this circumstance (you can't bridge cast from id to id - in fact you don't have to).

This is a bug in our code. Unfortunately our CGPathRef is an Objective C class called CGPath that has a few convenience methods on it. It should be a C struct with only state. This will be the case for some other Ref types as well (CGFont for example) but we've fixed up most of them already.

We're working on it! Sorry again.

@nicholasgerard-msft
Copy link
Contributor

@TorreyBetts This issue should be fixed with newer versions of the bridge. Could you please check with the latest release and close the issue if it is resolved?

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

No branches or pull requests

4 participants