Skip to content

Why is everything an Int? #20

@mattneub

Description

@mattneub

I did

sdef /Applications/iTunes.app > iTunes.sdef
sdp -fh --basename iTunes iTunes.sdef
sbhc.py iTunes.h
sbsc.py iTunes.sdef

and added the resulting Swift files to my project and fixed iTunes.swift so that it compiled (as explained in another issue). But I still am not able to interrogate iTunes usefully because everything in iTunes.swift is typed as an Int. For example:

// MARK: iTunesItem
@objc public protocol iTunesItem: SBObjectProtocol, iTunesGenericMethods {
    @objc optional var container: Int { get } // the container of the item
    @objc optional func id() // the id of the item
    @objc optional var index: Int { get } // The index of the item in internal application order.
    @objc optional var name: Int { get } // the name of the item
    @objc optional var persistentID: Int { get } // the id of the item as a hexadecimal string. This id does not change over time.
    @objc optional var properties: Int { get } // every property of the item
    @objc optional func download() // download a cloud track or playlist, or a podcast episode
    @objc optional func reveal() // reveal and select a track or playlist
    @objc optional func setName(_ name: Int) // the name of the item
    @objc optional func setProperties(_ properties: Int) // every property of the item
}
extension SBObject: iTunesItem {}

The container is an Int. The name is an Int. The properties is an Int. That's just wrong. The Objective-C file iTunes.h has this:

@interface iTunesItem : SBObject <iTunesGenericMethods>

@property (copy, readonly) SBObject *container;  // the container of the item
- (NSInteger) id;  // the id of the item
@property (readonly) NSInteger index;  // The index of the item in internal application order.
@property (copy) NSString *name;  // the name of the item
@property (copy, readonly) NSString *persistentID;  // the id of the item as a hexadecimal string. This id does not change over time.
@property (copy) NSDictionary *properties;  // every property of the item

- (void) download;  // download a cloud track or playlist, or a podcast episode
- (void) reveal;  // reveal and select a track or playlist

@end

Clearly, the container is an SBObject, the name is an NSString, and the properties is an NSDictionary. The Python script is being given the right types but is generating the wrong types.

I can fix this by editing all the types by hand. For example, everything works fine if I write

@objc optional var name: String { get } // the name of the item

But if I have to do that for every property, the Python script is not really being very helpful to begin with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions