<meta name="robots" content="noindex" />

Future Work

- Handling other ways of calling Python

  • PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *fp, const char *filename, int, PyCompilerFlags *);
    • Also PyRun_AnyFile or PyRun_AnyFileEx or PyRun_AnyFileFlags
    • if FP is associated with an interactive device, return PyRun_InteractiveLoop(); else return the result of PyRun_SimpleFile().
    • IF filename is NULL, the function uses "???" as the filename

  • PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char * command, PyCompilerFlags *);
    • also PyRun_SimpleString
    • "command" is the python command(s) to be executed. The function will create a main function to add and run what is defined in "command"
      • the string can be filtered to find default Python functions
      • using a default name for this kind of python call to represent it in the graph (numbered default name to differ calls)

  • PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *);
    • also PyRun_InteractiveOne
    • fp is an interactive device (console, terminal) and filename is the name of the file
      • executes only ONE statement from "filename"

  • PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *);
    • Also PyRun_InteractiveLoop
    • fp is an interactive device (console, terminal) and filename is the name of the file
      • executes statements from "filename"

  • PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *);
    • Also PyRun_String
    • runs "str" in the context specified by "globals" and "locals"
      • create a default function name for this kind of call, then use it as nodes in the graph

  • PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *, PyObject *, int, PyCompilerFlags *);
    • Also PyRun_File or PyRun_FileExFlags or PyRun_FileExFlags
    • Python source code is read from fp, and filename is the name of the file.

    All these methods use a string as identifier to modules or commands. It should not be difficult to identify functions and analyze them. They are also similar to "PyRun_SimpleFile", which is already implemented .

  • Pure Embedding (most safe and complete way of calling python)
    • see for the original code: https://docs.python.org/3/extending/embedding.html
    • Process:
      • pModule = PyImport_Import(PyObject *pName);
        • pName comes from converting C string to Python Object using Python.h interface. It is the name of the module(file) to open.

      • pFunc = PyObject_GetAttrString(PyObject *pModule, const char *func);
        • func is the name of the function inside the module.

      • pValue = PyObject_CallObject(PyObject *pFunc, PyObject *pArgs);
        • pArgs is the list of arguments. pValue is the return value of the function. It must be converted to a C type

    The problem with this approach is that there are multiple conversions and attributions before getting the reference to the function. A Reaching Definition Analysis is necessary to find the intermediate values.

    There is a pattern for the steps to be performed, and it also gives more information about the function and the module. So it will make it easier to resolve scoping issues.


  • Persons/group who can view/change the page:

-- (c) Fordham University Robotics and Computer Vision

This topic: Main > WebHome > FordhamRoboticsAndComputerVisionLaboratory > FRCVPublicProject > FRCVLabMLSA > FRCVLabMLSA_future
Topic revision: r1 - 2016-07-28 - BrunoVieiro
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback