0

The INT_Command object declaration below is part of an Objective-C class that is bridged into my Swift 2.0 project. Only my Swift classes do not recognise it, because it needs recoding as an... enum? Right?

I am aware there are existing posts on this subject, but INT_Command is a very specific #define statement that I cannot find any guidance on:

#define INT_Command(command,integ,data) ((((UInt16)command&INT_CMDMASK)<<INT_CMDOFFSET)|(((UInt16)integ&INT_INTMASK)<<INT_INTOFFSET)|(((UInt16)data&INT_DATAMASK)<<INT_DATAOFFSET))

Thank you for reading.

Joseph Beuys' Mum
  • 2,395
  • 2
  • 24
  • 50
  • 3
    Just write it as a function. My only question would be that it doesn't feel like it deserves to be a top-level function, but probably belongs within some class that is dealing with these data and command types. – Rob May 21 '16 at 18:07
  • Can you describe a bit about the values of `command`, `integ`, and `data`? If they're all bitwise options, then rather than a strict port that simply rewrites this macro into a function, you might refactor this into a `OptionSetType` (see http://stackoverflow.com/questions/24066170/how-to-create-ns-options-style-bitmask-enumerations-in-swift). We need more information about the nature of the three values in order to recommend a Swift design. – Rob May 21 '16 at 19:52

0 Answers0