Creating objects via AppleScript and setting readonly properties


Steve Mills
 

This seems like bug, or I need to override something. I have a class:

@interface Blah : NSObject
@property (readonly) NSUInteger id;
@end

The id property is exposed to AppleScript in the Blah class:

<property name=“id” code=“ID “ type=“integer” access=“r”>
<cocoa key=“id” />
</property>

If I make a new Blah like so:

make new blah at end of doc with properties {name:”Bob”, id:17}

The Blah is created and the id is happily set to 17. Shouldn’t something prevent that, either st the AppleScript level (access=“r”) or the Cocoa level ((readonly))?

Or do I need to implement -setId and have it return an error to AppleScript? Or is there something else I’m missing?

Oh, a side question. Is there any way to #include headers in an .sdef file so constants or #defines can be used and stringified? Seems problematic to have to type 4-char codes all through an sdef when the constants are already defined in private and Apple headers. I haven’t tried, but thought I’d ask, since I don’t see an Xcode setting for preprocessing sdefs or anything like that.

Steve via iPhone


Steve Mills
 

On May 10, 2019, at 11:08, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

Or is there something else I’m missing?
I did just find makeScriptingObjectOfClass or whatever it is (not at my desk now), so that’s a good way to ignore readonly properties. Still, seems like something should be doing that when letting the default methods handle it all.

Steve via iPad


Shane Stanley
 

On 11 May 2019, at 2:08 am, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

Or do I need to implement -setId and have it return an error to AppleScript?
If there's another way, I don't know it.

Is there any way to #include headers in an .sdef file so constants or #defines can be used and stringified?
It's just an XML file that gets added straight to the bundle, so I don't see how that would work.

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


Steve Mills
 

On May 10, 2019, at 18:31:43, Shane Stanley <sstanley@myriad-com.com.au> wrote:

On 11 May 2019, at 2:08 am, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

Is there any way to #include headers in an .sdef file so constants or #defines can be used and stringified?
It's just an XML file that gets added straight to the bundle, so I don't see how that would work.
Well, one could say the Info.plist is just a an xml file that gets added to the bundle, but it can be preprocessed. I use that feature a lot, like so the version number only has to be defined in one .h file and then can be used in the plist and other places. With there being so many AE constants, it would only make sense to allow sdef preprocessing to help prevent typos and mistakes.

--
Steve Mills
Drummer, Mac geek


Shane Stanley
 

On 11 May 2019, at 1:52 pm, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

On May 10, 2019, at 18:31:43, Shane Stanley <sstanley@myriad-com.com.au> wrote:

On 11 May 2019, at 2:08 am, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

Is there any way to #include headers in an .sdef file so constants or #defines can be used and stringified?
It's just an XML file that gets added straight to the bundle, so I don't see how that would work.
Well, one could say the Info.plist is just a an xml file that gets added to the bundle, but it can be preprocessed. I use that feature a lot, like so the version number only has to be defined in one .h file and then can be used in the plist and other places. With there being so many AE constants, it would only make sense to allow sdef preprocessing to help prevent typos and mistakes.
If you're logging a feature request, I'd be delighted to back it. But when you said "is", I presumed you meant present tense.

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


Steve Mills
 

On May 10, 2019, at 23:06:30, Shane Stanley <sstanley@myriad-com.com.au> wrote:

If you're logging a feature request, I'd be delighted to back it. But when you said "is", I presumed you meant present tense.
Yes, I did mean if there was currently a way to do it, but then I meandered over to "wouldn't it be great" territory. I've submitted radar://50687965 for this feature suggestion.

I was also thinking back to my MultiAd days when Creator's 'aete' Terminology.r file, which would've been a total nightmare had there been no such thing as preprocessing .r files. It's 435k.

--
Steve Mills
Drummer, Mac geek