import objc, sys

if sys.maxsize > 2 ** 32:
    def sel32or64(a, b): return b
else:
    def sel32or64(a, b): return a
if sys.byteorder == 'little':
    def littleOrBig(a, b): return a
else:
    def littleOrBig(a, b): return b

misc = {
}
misc.update({})
constants = ''
enums = ''
misc.update({})
functions={}

r = objc.registerMetaDataForSelector
objc._updatingMetadata(True)

# Format of objc.registerMetaDataForSelector(class_, selector, metadata):
# class_ : Name of class being modified
# selector : Objective-C name of functions (with :)
# metadata : Dictionary updating the values
#   Mostly we will want to define the arugments
#   For Class methods, defined arguments start at 2 (Arg 0 is Class, Arg 1 is selector)
#   Define type_modifier as either objc._C_IN, objc._C_OUT, objc._C_INOUT
#   Define one of the following to describe C arrays:
#     c_array_delimited_by_null (True or False)
#     c_array_length_in_arg (Number of arg)
#     c_array_of_fixed_length (Length of array)
#     c_array_length_in_result (Used with _C_OUT)
# The following is an example of a function added to ATDeviceElement class:
#   + (BOOL) test:(uint32_t*)data size:(uint32_t)size
#   {
#       for(uint32_t i = 0; i < size; i++) {
#           NSLog(@"0x%08X", data[i]);
#       }
#       return YES;
#   }
# Since the function uses a C array (uint32_t in this case), we need to define the metadata
# So add this below to define arugment 0 as an input array with length found in argument 1:
#   r(b'ATDeviceElement', b'test:size:', dict(
#       arguments = {
#           2+0: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+1)
#       }
#   ))

try:
    # Folder: Logging
    _log_function_metadata = dict(
        arguments = {
            0: dict(type=b'^v'),
            1: dict(type=b'@')
        },
        retval = {
            'type': b'v'
        }
    )
    r(b'ATDeviceLogging', b'initWithLogging:withInfoFunction:andDebugFunction:', dict(
        arguments = {
            2+0: dict(type=b'@?', callable_retained=True, callable=_log_function_metadata),
            2+1: dict(type=b'@?', callable_retained=True, callable=_log_function_metadata),
            2+2: dict(type=b'@?', callable_retained=True, callable=_log_function_metadata),
        }
    ))
    
    # Folder: CommInterface
    r(b'ATDeviceBusInterface', b'readRegisterAtAddress:withLength:data:error:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_OUT, c_array_length_in_arg=2+1)
        }
    ))
    r(b'ATDeviceBusInterface', b'writeRegisterAtAddress:length:data:error:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+1)
        }
    ))
    r(b'ATDeviceBusInterface', b'writeDataBufferWithData:withLength:withError:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+1)
        }
    ))
    r(b'ATDeviceBusInterface', b'readDataBufferWithData:withLength:withError:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_OUT, c_array_length_in_arg=2+1)
        }
    ))
    r(b'ATDeviceBusInterface', b'execute4ccCommand:withArgs:withData:writeLength:readLength:timeoutMilliseconds:error:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+3)
        }
    ))
    
    # Folder: CommInterface/DebugInterface
    r(b'ATDeviceDebugInterface', b'startCapturingToBlock:withError:', dict(
        arguments = {
            2+0: dict(type=b'@?', callable_retained=True, callable=dict(
                arguments = {
                    0: dict(type=b'^v'),
                    1: dict(type=b'@')
                },
                retval = {
                    'type': b'v'
                }
            )),
        }
    ))
    
    # Folder: CommInterface/FastEthernetInterface
    r(b'ATDeviceBusInterface', b'exchangeWithType:andPayloadToSend:andToSendSize:andSendTimeOutInMilliSecond:anyTypeReceived:andPayloadToReceive:andToReceiveSize:andTimeOutInMilliSecond:andError:', dict(
        arguments = {
            2+1: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+2),
            2+5: dict(type_modifier=objc._C_OUT, c_array_length_in_arg=2+6)
        }
    ))
    
    # Folder: CommInterface/TBTInterface
    r(b'ATDeviceTBTInterface', b'rawI2C_transactionWithAddress:andOutData:andWriteLen:andInData:andReadLen:andError:', dict(
        arguments = {
            2+1: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+2),
            2+3: dict(type_modifier=objc._C_OUT, c_array_length_in_arg=2+4)
        }
    ))
    
    # Folder: Test Devices/BaseClass
    r(b'ATDeviceElement', b'canTransmitWithBusId:andWaitForSend:andSetRTR:andUseExtendedID:andLength:andMessageID:andData:andError:', dict(
        arguments = {
            2+6: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+4)
        }
    ))
    
    r(b'ATDeviceUSBC', b'readPDControllerRegisterOnPort:andRegisterOffset:andData:andReadDataLength:andError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_OUT, c_array_length_in_arg=2+3)
        }
    ))
    r(b'ATDeviceUSBC', b'writePDControllerRegisterOnPort:andRegisterOffset:andData:andWriteDataLength:andError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+3)
        }
    ))
          
    r(b'ATDeviceUSB4', b'orientationFromPortStatus:', dict(
        arguments = {
            2+0: dict(type=b'^{ATDeviceUSB4PortStatus=b4b4CCCII[7I]SSSSCCb7b1}'),
        }
    ))
    r(b'ATDeviceUSB4', b'sendVendorDefinedMessageOnPort:withSOP:withVDOs:withNumberOfVDOs:andExpectingResponse:withResponseTimeout:withResponseVDOs:withNumberOfResponseVDOs:withError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+3),
            2+6: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=7)
        }
    ))
    r(b'ATDeviceUSB4', b'sendStructuredVDMOnPort:withSOP:withSVID:withObjectPosition:withCommand:withAdditionalVDOs:withNumberOfAdditionalVDOs:andExpectingResponse:withResponseTimeout:withResponseVDOs:withNumberOfResponseVDOs:withError:', dict(
        arguments = {
            2+5: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+6),
            2+9: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=7)
        }
    ))
    r(b'ATDeviceUSB4', b'sendUnstructuredVDMOnPort:withSOP:withSVID:withHeader:withAdditionalVDOs:withNumberOfAdditionalVDOs:andExpectingResponse:withResponseTimeout:withResponseVDOs:withNumberOfResponseVDOs:withError:', dict(
        arguments = {
            2+4: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+5),
            2+8: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=7)
        }
    ))
    
    r(b'ATDeviceWirelessDebug', b'starkUartTxBytes:withData:loops:withDelay:andError:', dict(
        arguments = {
            2+1: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+0)
        }
    ))
    
    # Folder: Test Devices/Carbon
    r(b'ATDeviceCarbon', b'sendCANMessageToCANBus:andMessageId:andMessageType:andWriteLength:andData:andError:', dict(
        arguments = {
            2+4: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+3)
        }
    ))
    r(b'ATDeviceCarbon', b'receiveCANMessageWithMessageId:andMessageLeftInFifo:andIsRemoteTxRequest:andIsExtendedId:andActualDataLength:andData:andError:', dict(
        arguments = {
            2+5: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=8)
        }
    ))
    r(b'ATDeviceCarbon', b'canOpenSDOupLoadFromNodeID:andIndex:andSubIndex:andData:andActualReadLength:andError:', dict(
        arguments = {
            2+3: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=255)
        }
    ))
    r(b'ATDeviceCarbon', b'canOpenSDOdownLoadToNodeID:andIndex:andSubIndex:andData:andWritelength:andError:', dict(
        arguments = {
            2+3: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+4)
        }
    ))
    
    # Folder: Test Devices/Dysprosium
    r(b'ATDeviceDysprosium', b'rawADCValues:withSamples:withError:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=8)
        }
    ))
    r(b'ATDeviceDysprosium', b'uvdmSteamOnPort:withSOP:withRemoteEndpoint:withDirection:withStreamLength:withNumOfProtocolVDOs:withProtocolUseVDOs:withStreamWriteData:withStreamReadData:withError:', dict(
        arguments = {
            2+6: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+5)
        }
    ))
    
    
    
    # Folder: Test Devices/Metis
    r(b'ATDeviceMetis', b'gpioSetOutputsWithModule:withPinMask:withOutputData:withError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_of_fixed_length=4)
        }
    ))
    r(b'ATDeviceMetis', b'gpioGetPinStatesWithModule:withPinStates:withError:', dict(
        arguments = {
            2+1: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=4)
        }
    ))
    r(b'ATDeviceMetisPowerSequenceOperation', b'commandData:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=8)
        }
    ))
    r(b'ATDeviceMetisSPIOperation', b'commandData:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=16)
        }
    ))
    
    # Folder: Test Devices/Oxygen
    r(b'ATDeviceOxygen', b'writeEEPROMatOffset:andCount:withData:andError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+1)
        }
    ))
    r(b'ATDeviceOxygen', b'readEEPROMatOffset:andCount:withData:andError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_OUT, c_array_length_in_arg=2+1)
        }
    ))
    
    
    # Folder: Test Devices/Potassium
    r(b'ATDevicePotassium', b'getBananaSerialNumber:withError:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=24)
        }
    ))
    r(b'ATDevicePotassium', b'bananaTypeKeys:withModifierKeys:withSpecialKeys:forDuration:withError:', dict(
        arguments = {
            2+0: dict(type_modifier=objc._C_IN, c_array_of_fixed_length=5)
        }
    ))
    
    # Folder: Test Devices/Spartan
    r(b'ATDeviceSpartan', b'sendVendorDefinedMessageOnPort:withSOP:withVDOs:withNumberOfVDOs:andExpectingResponse:withResponseTimeout:withResponseVDOs:withNumberOfResponseVDOs:withError:', dict(
        arguments = {
            2+2: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+3),
            2+6: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=7)
        }
    ))
    r(b'ATDeviceSpartan', b'sendStructuredVDMOnPort:withSOP:withSVID:withObjectPosition:withCommand:withAdditionalVDOs:withNumberOfAdditionalVDOs:andExpectingResponse:withResponseTimeout:withResponseVDOs:withNumberOfResponseVDOs:withError:', dict(
        arguments = {
            2+5: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+6),
            2+9: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=7)
        }
    ))
    r(b'ATDeviceSpartan', b'sendUnstructuredVDMOnPort:withSOP:withSVID:withHeader:withAdditionalVDOs:withNumberOfAdditionalVDOs:andExpectingResponse:withResponseTimeout:withResponseVDOs:withNumberOfResponseVDOs:withError:', dict(
        arguments = {
            2+4: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+5),
            2+8: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=7)
        }
    ))
    
    
    #Folder: ProtocolHeaders
    r(b'ATDFixtureIOCapable', b'sendCANMessageToCANBus:andMessageId:andMessageType:andWriteLength:andData:andError:', dict(
        arguments = {
            2+4: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+3)
        }
    ))
    r(b'ATDFixtureIOCapable', b'receiveCANMessageWithMessageId:andMessageLeftInFifo:andIsRemoteTxRequest:andIsExtendedId:andActualDataLength:andData:andError:', dict(
        arguments = {
            2+5: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=8)
        }
    ))
    r(b'ATDFixtureIOCapable', b'canOpenSDOupLoadFromNodeID:andIndex:andSubIndex:andData:andActualReadLength:andError:', dict(
        arguments = {
            2+3: dict(type_modifier=objc._C_OUT, c_array_of_fixed_length=255)
        }
    ))
    r(b'ATDFixtureIOCapable', b'canOpenSDOdownLoadToNodeID:andIndex:andSubIndex:andData:andWritelength:andError:', dict(
        arguments = {
            2+3: dict(type_modifier=objc._C_IN, c_array_length_in_arg=2+4)
        }
    ))
    
    
    
finally:
    objc._updatingMetadata(False)

expressions = {}

# END OF FILE

