Auto-generated mupdf C++ wrappers

Status

As of 2020-4-28:

  • We generate class wrappers for all fz structs.
  • We auto-detect fz_*() fns suitable for wrapping as constructors, methods or static methods.
  • Some generated classes have auto-generated support for iteration.
  • We add various custom wrappers for fz_*() fns.
  • We add various custom methods/constructors.
  • We provide access via wrapper classes to 686 fz_*() fns.
  • There are a total of 888 fz_*() functions. Most of the omitted functions don't take struct args, e.g. fz_strlcpy(). Of the remaining, some use fz_* enums (which we don't yet wrap); see https://ghostscript.com/~julian/mupdf/platform/c++/fn_usage.txt for more information.
  • We work with swig-3 or swig-4.
  • We work with clang-6 or clang-7.
  • We work on peeved and jules-laptop.

Comments

  • We use clang to extract doxygen-style comments, and propogate them into generated header files.
  • If swig is version 4+, we tell it to propogate comments into generated mupdf.py.

Here are Doxygen html representations of the mupdf C API and the generated mupdf C++ API:

And pydoc html representation of the generated mupdf.py API:

Files

Auto-generated C++ headers and implementation files, plus test outputs (.html files have syntax-colouring):

Information about fz_*() fns that are not in the class-based API:

These were generated by the mupdfwrap.py programme, which also runs g++ and SWIG to generate a Python module that gives a Python API:

The generated Python module is tested by the (rather hacky) test_mupdfcpp_swig() function in mupdfwrap.py. For convenience, this function and its output can be viewed in https://ghostscript.com/~julian/mupdf/platform/python.

In mupdfwrap.py:

  • See "Todo:" section in comment near top, for status of various todo items.

Integration with mupdf git.

In mupdf, have added various things:

    mupdf/
        build/
            release-shared/
                libmupdf.so  [generated file]
                libmupdfcpp.so [generated file, implements C++ API]
            debug-shared/
                libmupdf.so  [generated file]
                libmupdfcpp.so [generated file, implements C++ API]
        platform/
            c++/
                implementation/
                    *.cpp [generated files]
                include/
                    mupdf/
                        *.h [generated files]
            python/
                mudf.py [generated file, implements Python API]
                _mupdf.so [generated file, implements Python API internals]
        scripts/
            mupdfwrap.py
            jlib.py

See:

To build:

    cd mupdf/
    ./scripts/mupdfwrap.py -b all -t

Have also added crude support for building mupdf as a shared object, which is required for integrating with the SWIG python module. At the moment, mupdfwrap.py drives this to build mupdf.so.


-- Julian Smith - 2020-03-04

Comments

Edit | Attach | Watch | Print version | History: r20 | r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r16 - 2020-04-27 - JulianSmith
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 2014 Artifex Software Inc