-
Notifications
You must be signed in to change notification settings - Fork 395
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
Adds a nondestructive -attributeTypeName property to attributes #86
Conversation
-attributeTypeName uses the “attributeValueTypeName” field in userInfo if available, defaulting to the scalarAttributeType if any, or else the objectAttributeType suffixed with a *. Intended for use in the templates, deprecating both -scalarAttributeType and -objectAttributeType. Use case: transformable attributes with “id” as their type (as opposed to the unidiomatic and frankly weird NSObject *).
I should note, this would close #85. |
This is done by adding -scalarAttributeTypeName, -scalarAccessorMethodName, and -scalarFactoryMethodName to NSAttributeDescription. -scalarAttributeTypeName returns the same thing as -scalarAttributeType, except that where that uses short, int, and long long, the new method uses int16_t, int32_t, and int64_t. To allow simple boxing and unboxing with NSNumber, -scalarAccessorMethodName and -scalarFactoryMethodName return the appropriate values for the scalar type, e.g. boolValue, longLongValue, and numberWithShort:.
I did not mean to add the second commit to this pull request! Oh well, it provides a fix for #2. Do with it what you will! I leave my code humbly at your mercy. |
Also defaulted to using int*_t for scalars at the same time.
I found some other issues examining the test mule MOs, which I fixed up here: 25bc9fc You may want to take a look, especially since I removed support for |
Main difference with On the other hand, other type names would also be possible with The intention was basically “type name, verbatim.” I still kind of feel like this is valuable for the protocol case especially (without resorting to Sorry about the NSNumber mistakes. Derp :) |
Ah, I see. I don't think we need direct "type name, verbatim" support if we keep the generation code smart enough. For instance, I added Let me know if you have any other examples that aren't correctly handled. |
As I mentioned, Class and id. Rob Rix, Unknown Quantity. On 2012-01-07, at 10:51 PM, Jonathan 'Wolf' Rentzsch [email protected] wrote:
|
Oh, I misunderstood your text. Yup, those aren't covered. I'm more inclined to make attributeValueClassName mean "type name, verbatim" than add another userInfo key, and accept the fact folks will need to tweak their model to add the asterisk. |
That works for me. |
Although of course, folks will have to edit their data models too, which is rather more tedious. |
Devil's advocate time, I guess: What's wrong with special-casing an understanding of |
Yes, that would be a good approach. We still have to change the templates, but not all the data models. |
@JoeOsborn: yup, I was already thinking along those lines myself. Good to hear you're on the same wavelength. I'm thinking about something like this (in mostly-JavaScript):
|
--- It is usable as a replacement for both -scalarAttributeType and -objectAttributeType, and pulls from the attributeValueTypeName userInfo field if available.
--- It is usable as a replacement for both -scalarAttributeType and -objectAttributeType, and pulls from the attributeValueTypeName userInfo field if available.
[NEW] Better return value types: `int16_t`/`int32_t`/`int64_t` instead of `short`/`long`/`long long` and `id` instead of `NSObject*`. closes rentzsch#2, rentzsch#85 (Rob Rix)
It is usable as a replacement for both -scalarAttributeType and -objectAttributeType, and pulls from the attributeValueTypeName userInfo field if available.