From 30dc3c4a7e50aa298504390446b4c1b507a03e00 Mon Sep 17 00:00:00 2001 From: plafosse Date: Tue, 16 Aug 2016 22:27:54 +0100 Subject: Fixing documentation for parse_types_from_source --- python/__init__.py | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'python') diff --git a/python/__init__.py b/python/__init__.py index 3cbedc51..f496f03d 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -6714,38 +6714,22 @@ class Architecture(object): def parse_types_from_source(self, source, filename = None, include_dirs = []): """ - ``get_view_type_constant`` retrieves the view type constant for the given type_name and const_name. + ``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``. - :param str type_name: the BinaryView type name of the constant to be retrieved - :param str const_name: the constant name to retrieved - :param int value: optional default value if the type_name is not present. default value is zero. - :return: The BinaryView type constant or the default_value if not found - :rtype: int + :param str source: source string to be parsed + :param str filename: optional source filename + :param list(str) include_dirs: optional list of string filename include directories + :return: a tuple of py:class:`TypeParserResult` and error string +# :rtype: tuple(TypeParserResult,str) :Example: - >>> ELF_RELOC_COPY = 5 - >>> arch.set_view_type_constant("ELF", "R_COPY", ELF_RELOC_COPY) - >>> arch.get_view_type_constant("ELF", "R_COPY") - 5L - >>> arch.get_view_type_constant("ELF", "NOT_HERE", 100) - 100L + >>> arch.parse_types_from_source('int foo;\\nint bar(int x);\\nstruct bas{int x,y;};\\n') + ({types: {'bas': }, variables: {'foo': }, functions:{'bar': + }}, '') + >>> """ - # """ - # ``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``. - # - # :param str source: source string to be parsed - # :param str filename: optional source filename - # :param list(str) include_dirs: optional list of string filename include directories - # :return: a tuple of py:class:`TypeParserResult` and error string - # :rtype: tuple(TypeParserResult,str) - # :Example: - # - # >>> arch.parse_types_from_source('int foo;\nint bar(int x);\nstruct bas{int x,y;};\n') - # ({types: {'bas': }, variables: {'foo': }, functions: - # {'bar': }}, '') - # >>> - # """ + if filename is None: filename = "input" dir_buf = (ctypes.c_char_p * len(include_dirs))() @@ -6782,7 +6766,7 @@ class Architecture(object): >>> file = "/Users/binja/tmp.c" >>> open(file).read() - 'int foo;\nint bar(int x);\nstruct bas{int x,y;};\n' + 'int foo;\\nint bar(int x);\\nstruct bas{int x,y;};\\n' >>> arch.parse_types_from_source_file(file) ({types: {'bas': }, variables: {'foo': }, functions: {'bar': }}, '') -- cgit v1.3.1