예제 #1
0
    header = CHeader(path)

    print('***** Constants *****')
    constants = header.constants()
    for key, value in constants.items():
        print(key, value)
    print('')

    print('***** Enums *****')
    enums = header.enums()
    for key, value in enums.items():
        print(key, value)
    print('')

    print('***** Structs *****')
    structs = header.structs()
    for key, value in structs.items():
        print(key, value)
    print('')

    print('***** Callbacks *****')
    callbacks = header.callbacks()
    for key, value in callbacks.items():
        print(key, value)
    print('')

    print('***** Functions *****')
    fcns = header.functions(fcn_regex)
    for key, value in fcns.items():
        print(key, value)
예제 #2
0
    #
    #     Parameters
    #     ----------
    #     timeout : :class:`int`
    #         The timeout value, in seconds.
    #     """
    #     self.sdk.SetTimeout(self._handle, timeout)


if __name__ == '__main__':
    from msl.equipment.resources.utils import CHeader, camelcase_to_underscore

    header = CHeader(
        r'C:\Users\j.borbely\Desktop\AppNotes_FW102C_v400\AppNotes_FW102C\msvc\fw_cmd_library.h'
    )
    fcns = header.functions(r'DllExport\s+(\w+)\s+(\w+)')

    for key, value in fcns.items():
        print('        self.sdk.{name}.restype = {res}'.format(name=key,
                                                               res=value[0]))
        print('        self.sdk.{name}.argtypes = [{args}]'.format(
            name=key,
            args=', '.join(
                [item[0] for item in value[1] if item[0] is not None])))
        print('        self.sdk.{name}.errcheck = self.errcheck_code'.format(
            name=key))

    print()

    for key, value in fcns.items():
        args_p = [
예제 #3
0
        return self.lib.BI_multi_park()

    def start_log(self, c_list):
        return self.lib.BI_start_log(c_list)

    def stop_log(self, c_list):
        return self.lib.BI_stop_log(c_list)


if __name__ == '__main__':
    from msl.equipment.resources.utils import CHeader, camelcase_to_underscore

    header = r'H:\Bentham\SDK\lang\c\bendll.h'

    header = CHeader(header)
    fcns = header.functions(r'typedef\s+(\w+)\s*\(WINAPI\*pf(\w+)\)')
    for key, value in fcns.items():
        print('        self.lib.{name}.restype = {res}'.format(name=key, res=value[0]))
        print('        self.lib.{name}.argtypes = [{args}]'.format(name=key, args=', '.join([item[0] for item in value[1] if item[0] is not None])))

    print()

    for key, value in fcns.items():
        args_p = [camelcase_to_underscore(item[1]) for item in value[1] if item[0] is not None and not item[0].startswith('POINTER')]
        args_c = [camelcase_to_underscore(item[1]) for item in value[1] if item[0] is not None]
        ptrs = [[camelcase_to_underscore(item[1]), item[0]] for item in value[1] if item[0] is not None and item[0].startswith('POINTER')]
        if args_p:
            print('    def {}(self, {}):'.format(camelcase_to_underscore(key[3:]), ', '.join(args_p)))
            for p in ptrs:
                print('        {} = {}()'.format(p[0], p[1][8:-1]))
            if not ptrs: