elif text == 'int64_t': text = 'long'
elif text == 'size_t': text = 'ulong'
elif text == 'unsigned int': text = 'uint'
+ elif text.startswith('enum '):
+ # This is primarily for enum pdf_zugferd_profile; C# does not
+ # like `enum` prefix, and we need to specify namespace name
+ # `mupdf`.
+ text = text[5:]
+ if text.startswith('pdf_') or text.startswith('fz_'):
+ text = f'{rename.namespace()}.{text}'
write(f'{text}')
# Generate the returned tuple.
ret += '_'
return ret
+def namespace():
+ return 'mupdf'
+
def namespace_ll_fn( fnname):
'''
Returns full-qualified name of low-level wrapper function for MuPDF C
function `fnname()`, adding a `ctx` arg and converting MuPDF exceptions
into C++ exceptions.
'''
- return f'mupdf::{ll_fn(fnname)}'
+ return f'{namespace()}::{ll_fn(fnname)}'
def fn( fnname):
'''
Returns fully-qualified name of wrapper function for MuPDF C function
`fnname()`, using wrapper classes for args and return values.
'''
- return f'mupdf::{fn(fnname)}'
+ return f'{namespace()}::{fn(fnname)}'
def class_( structname):
'''
'''
Returns fully-qualified name of class that wraps MuPDF struct `structname`.
'''
- return f'mupdf::{class_(structname)}'
+ return f'{namespace()}::{class_(structname)}'
def method( structname, fnname):
'''
# Ignore all C MuPDF functions; SWIG will still look at the C++ API in
# namespace mudf.
for fnname in generated.c_functions:
- if fnname in ('pdf_annot_type', 'pdf_widget_type'):
+ if fnname in (
+ 'pdf_annot_type',
+ 'pdf_widget_type',
+ 'pdf_zugferd_profile',
+ ):
# These are also enums which we don't want to ignore. SWIGing the
# functions is hopefully harmless.
pass