# platform module

`binaryninja.platform.Platform`(arch[, handle]) | `class Platform` contains all information releated to the execution environment of the binary, mainly the
`binaryninja.platform.range`(*args) | A Python2 and Python3 Compatible Range Generator
`binaryninja.platform.with_metaclass`(meta, *bases) | Create a base class with a metaclass.

class `binaryninja.platform.``Platform`(arch, handle=None)

  Bases: `object`

  `class Platform` contains all information releated to the execution environment of the binary, mainly the calling conventions used.

  `add_related_platform`(arch, platform)
  `calling_conventions`

    List of platform CallingConvention objects (read-only)

    Getter: | returns the list of supported CallingConvention objects
    Type: | list(CallingConvention)

  `cdecl_calling_convention`

    Cdecl calling convention.

    Getter: | returns a CallingConvention object for the cdecl calling convention.

    :setter sets the cdecl calling convention :type: CallingConvention

  `default_calling_convention`

    Default calling convention.

    Getter: | returns a CallingConvention object for the default calling convention.
    Setter: | sets the default calling convention
    Type: | CallingConvention

  `fastcall_calling_convention`

    Fastcall calling convention.

    Getter: | returns a CallingConvention object for the fastcall calling convention.

    :setter sets the fastcall calling convention :type: CallingConvention

  `functions`

    List of platform-specific function definitions (read-only)

  `generate_auto_platform_type_id`(name)
  `generate_auto_platform_type_ref`(type_class, name)
  `get_associated_platform_by_address`(addr)
  `get_auto_platform_type_id_source`()
  `get_function_by_name`(name)
  `get_related_platform`(arch)
  `get_system_call_name`(number)
  `get_system_call_type`(number)
  `get_type_by_name`(name)
  `get_variable_by_name`(name)
  `list` = [<platform: decree-x86>, <platform: freebsd-aarch64>, <platform: freebsd-armv7>, <platform: freebsd-thumb2>, <platform: freebsd-x86>, <platform: freebsd-x86_64>, <platform: linux-aarch64>, <platform: linux-armv7>, <platform: linux-thumb2>, <platform: linux-armv7eb>, <platform: linux-thumb2eb>, <platform: linux-mipsel>, <platform: linux-mips>, <platform: linux-ppc32>, <platform: linux-ppc32_le>, <platform: linux-x86>, <platform: linux-x86_64>, <platform: mac-aarch64>, <platform: mac-armv7>, <platform: mac-thumb2>, <platform: mac-x86>, <platform: mac-x86_64>, <platform: windows-aarch64>, <platform: windows-armv7>, <platform: windows-thumb2>, <platform: windows-x86>, <platform: windows-x86_64>]
  `name` = None
  `parse_types_from_source`(source, filename=None, include_dirs=[], auto_type_source=None)

    `parse_types_from_source` parses the source string and any needed headers searching for them in the optional list of directories provided in `include_dirs`.

    Parameters:

    - source (str) – source string to be parsed
    - filename (str) – optional source filename
    - include_dirs (list(str)) – optional list of string filename include directories
    - auto_type_source (str) – optional source of types if used for automatically generated types

    Returns: | `TypeParserResult` (a SyntaxError is thrown on parse error)
    Return type: | TypeParserResult

    Example:

        >>> platform.parse_types_from_source('int foo;\nint bar(int x);\nstruct bas{int x,y;};\n')
        ({types: {'bas': <type: struct bas>}, variables: {'foo': <type: int32_t>}, functions:{'bar':
        <type: int32_t(int32_t x)>}}, '')
        >>>

  `parse_types_from_source_file`(filename, include_dirs=[], auto_type_source=None)

    `parse_types_from_source_file` parses the source file `filename` and any needed headers searching for them in the optional list of directories provided in `include_dirs`.

    Parameters:

    - filename (str) – filename of file to be parsed
    - include_dirs (list(str)) – optional list of string filename include directories
    - auto_type_source (str) – optional source of types if used for automatically generated types

    Returns: | `TypeParserResult` (a SyntaxError is thrown on parse error)
    Return type: | TypeParserResult

    Example:

        >>> file = "/Users/binja/tmp.c"
        >>> open(file).read()
        'int foo;\nint bar(int x);\nstruct bas{int x,y;};\n'
        >>> platform.parse_types_from_source_file(file)
        ({types: {'bas': <type: struct bas>}, variables: {'foo': <type: int32_t>}, functions:
        {'bar': <type: int32_t(int32_t x)>}}, '')
        >>>

  `register`(os)

    `register` registers the platform for given OS name.

    Parameters: | os (str) – OS name to register
    Return type: | None

  `register_calling_convention`(cc)

    `register_calling_convention` register a new calling convention.

    Parameters: | cc (CallingConvention) – a CallingConvention object to register
    Return type: | None

  `stdcall_calling_convention`

    Stdcall calling convention.

    Getter: | returns a CallingConvention object for the stdcall calling convention.

    :setter sets the stdcall calling convention :type: CallingConvention

  `system_call_convention`

    System call convention.

    Getter: | returns a CallingConvention object for the system call convention.

    :setter sets the system call convention :type: CallingConvention

  `system_calls`

    List of system calls for this platform (read-only)

  `types`

    List of platform-specific types (read-only)

  `variables`

    List of platform-specific variable definitions (read-only)