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
Autowire idea #178
Comments
Very good analysis.
|
|
There are Objective-C grammars for Yacc, but I think the fastest way to parse would be to use Clang's Active Syntax Tree (AST). Even if it would be cool to literally shave that Yacc ;) . . . . actually what am I thinking!? . . shouldn't need a syntax tree just to match a macro in the header. |
Which syntax do people prefer? I like this one: @Property (nonatomic, strong, typhoon_injected) NSString *foo; |
I tried to use AST, but property in AST is
for this declaration:
Aslo I think that AST slower that 'just parse' - it analys code, type checking etc.. May be you can test something else or Yacc for parsing |
I don't like to add build phase or preprocessor (especially for tiny frameworks) but it is only way to 'extend' objective-c by our own directives.
I don't like auto-wire (don't want dependency on typhoon in code, want to keep all definitions in one place), but if someone likes it - ask him what is more important nice syntax or no-extra-phase. |
@ratkins @notjosh Would you care to comment on this ticket? Options:
|
Using @dynamic is not recommended and can have side effects for all non-typhoon dynamic properties. Also there is a lot of runtime works
Also all injected properties become lazy - can be unexpected for users. Send from iPhone 20.02.2014, â 13:16, Jasper Blues notifications@github.com íàïèñàë(à):
|
Also @dynamic way can't specify factory - only default factory usage.. 20.02.2014, â 13:16, Jasper Blues notifications@github.com íàïèñàë(à):
|
Agree regarding dynamic. @ratkins, @notjosh we don't recommend this approach - just listed to be complete. Usually you want to resolve dependencies up-front, and fail early. Except in the case of say, transitioning from one view controller to another. For that we have:
Couple of course with: Typhoon Scopes |
Let's use @property (nonatomic, strong, inject) NSString *foo; for all injected properties just for documentation purpose |
inject vs injected. which is better? |
I used inject to be same as 'copy' 'retain' - not 'copied', 'retained' |
Ah, yes, of course. |
Catching up. +1 on the feature! Super valuable :) If I'm going to bikeshed, I prefer the @property (nonatomic, strong) TYPHOON_INJECTED NSString *foo; I think it's more familiar to anyone that's used IB that "this gets compiled out", whereas the |
I agree that @property (nonatomic, strong) TyphoonInjected NSString *foo; or just @property (nonatomic, strong) Injection NSString *foo; more clear for users, because IBOutlet is same as Injected but by xibs. So it is place for Injection tag. @notjosh on feature you mean using attribute for self-documentation or preprocessor way? |
@alexgarbarev I meant the preprocessing. ✨Magical✨ autowiring via a preprocessor will be amazing. |
My vote for documentation purpose instead of magical preprocessor |
I agree with @notjosh, I like
I would also say |
Thanks @ratkins. How about we follow (as we did with the original autowiring feature) @jonreid 's approach of:
This would allow the tag to catch on if it wanted to, at the same time as give some safety. |
@ratkins Did you have a vote on the 2nd table?
|
Votes:
* I imaged with an IDE tool we can do the following:
|
Hi @jasperblues. |
Thanks @AlexDenisov !!! This is very valuable input. . . (and great work on Blood and Magic, btw) |
@AlexDenisov In fact, we were inspired and impressed by BM's annotated properties . . . but thought the pre-processor approach might work better for Typhoon. |
:shy: 😄 btw, I've started small project for analysing projects that use BM. I'm working on it just from academical interest, but I think that it might be useful for you too, at least used approaches. |
We'll look forward to hearing more about that. Is it already on GitHub? |
No, it's still in my private repo. |
Hi guys, It's already outvoted, but I would definitely go with General note. |
@literator, as I know there is no possibility to deal with macro definitions via runtime, so this feature will affect only on visual representation and, maybe, on some tools. |
@AlexDenisov, Yes you're right - it will be just optional. Well, actually we proposed two ideas:
⋅⋅* warn if the injection didn't happen. |
@literator do you mean like this? @property(nonatomic, strong) TyphoonInjected Thing *foo; prefer it to this? @property(nonatomic, strong) TYPHOON_INJECTED Thing *foo; |
@jasperblues for me |
Do we annotate:
Follow the behavior of Spring's @required annotation here? (Need to check what that behavior is). |
@jasperblues, that's what I meant here |
Great work Alexey! A trove of useful stuff there. |
Btw, it's also discontinued, because Apple's clang doesn't support plugins :( |
If I had to have a macro-based solution, I'd want it to look like this #252 (great work from Aleksey)
. . this feature is currently on trunk if you want to try it out. We'll be posting docs soon. It will deprecate Typhoon's old autowiring. |
Hi folks,
I have some idea how to implement autowite with syntax:
Since we cannot add our own property attributes or clang attributes - all keywords above are just empty defines:
Because we cannot obtain these marks at runtime I thought that we can collect all these marks by our own 'parser', lets call it TyphoonPreprocessor.
It should be fast objective-c written utility (with caching in 'derived data' processed filepaths to avoid processing not changed files).
Result of TyphoonPreprocessor can be XML file in typhoon format. XML should has definitions with TYPHOON_INJECTED properties. For example:
Next step is coping result XML into application bundle - this step can be similar to Pods-resources.sh script.
Final step is loading TyphoonXmlComponentFactory with autowiring XML and re-register all definitions to user-created TyphoonComponentFactory.
Disadvantages
Advantages
What do you think? Make sense?
The text was updated successfully, but these errors were encountered: