Skip to content

Create translator.py tool to provide full CEF API coverage in an automated way  #214

Open
@cztomczak

Description

@cztomczak

Create "translator.py" tool that automatically generates Cython source code based on the CEF header files. Let the translator create base classes eg. CefBrowserBase, CefFrameBase with everything wrapped automatically. These classes will be extended by CefBrowser, CefFrame and these final classes could optionally allow overwriting methods when there is a need for handling special cases or a need to add additional helper functions. Rename PyBrowser to CefBrowser and import CefBrowser as CefBrowserNative. These changes would allow for a lot of code reuse.

Such an automation would need to be implemented along with with documentation being generated from Cython sources (#204). It would make no sense to generate code automatically and create documentation for it manually.

CEF has built-in generator called CEF Translator that is used to translate between C<>C++ API. See CEF Translator's README. See translator.py, cef_parser.py and other scripts.

Take a look at other CEF wrappers that generate most of the code automatically and provide full API coverage. These projects wrap around C API, however they create a nice object-oriented API. See:


Expose as much of CEF API in an automated way as possible:

  • enums from cef_types.h eg. 'cef_termination_status_t'
  • structures eg. '_cef_settings_t'
  • functions
  • classes
  • client handlers - generate both .pyx and .h/c++ files. See also Issue Expose handlers as classes/interfaces: ClientHandler, DisplayHandler, LifespanHandler, etc. #215.
  • Declare CEF types as a) Python classes b) as uppercase constants (for backwards compatibility):
    • generate types/ directory by parsing cef header files: cef_types, cef_types_wrappers
    • request_handler.pyx, cef_types - TS_PROCESS_WAS_KILLED, TS_ABNORMAL_TERMINATION, TS_PROCESS_CRASHED - create class TerminationStatus with attrs: AbnormalTermination, ProcessWasKilled, ProcessCrashed
    • handle special cases with modifications to naming, eg. network_error.pyx - ERR_INVALID_ARGUMENT, ERR_INVALID_HANDLE - become NetworkError.InvalidArgument, NetworkError.InvalidHandle, but keep constants names intact "ERR_INVALID_ARGUMENT" (BC).
    • some types may be available only for Windows, eg. cef_graphics_implementation_t - already exposed in cef_types_win.pxd

See "cpdef enum" syntax added in latest Cython:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions