1
1
R"""
2
2
Auto-generated by:
3
- ctypesgen --library pdfium --no-macro-guards -- runtime-libdirs . --no-load-library -D PDF_ENABLE_V8 PDF_ENABLE_XFA PDF_USE_SKIA --symbol-rules if_needed=\w+_$|\w+_t$|_\w+ --headers fpdf_annot.h fpdf_attachment.h fpdf_catalog.h fpdf_dataavail.h fpdf_doc.h fpdf_edit.h fpdf_ext.h fpdf_flatten.h fpdf_formfill.h fpdf_fwlevent.h fpdf_javascript.h fpdf_ppo.h fpdf_progressive.h fpdf_save.h fpdf_searchex.h fpdf_signature.h fpdf_structtree.h fpdf_sysfontinfo.h fpdf_text.h fpdf_thumbnail.h fpdf_transformpage.h fpdfview.h -o ./data/bindings/bindings.py
3
+ ctypesgen -l pdfium --runtime-libdirs . --no-load-library --no-macro-guards - D PDF_ENABLE_V8 PDF_ENABLE_XFA PDF_USE_SKIA --symbol-rules ' if_needed=\w+_$|\w+_t$|_\w+' --headers fpdf_annot.h fpdf_attachment.h fpdf_catalog.h fpdf_dataavail.h fpdf_doc.h fpdf_edit.h fpdf_ext.h fpdf_flatten.h fpdf_formfill.h fpdf_fwlevent.h fpdf_javascript.h fpdf_ppo.h fpdf_progressive.h fpdf_save.h fpdf_searchex.h fpdf_signature.h fpdf_structtree.h fpdf_sysfontinfo.h fpdf_text.h fpdf_thumbnail.h fpdf_transformpage.h fpdfview.h -o ./data/bindings/bindings.py
4
4
"""
5
5
6
- # -- Begin preamble --
7
-
8
- # TODO
9
- # - add c_ptrdiff_t only on as-needed basis
10
- # - Avoid ctypes glob import (pollutes namespace)
11
-
12
6
import ctypes
13
- from ctypes import * # noqa: F401, F403
14
-
15
- def _get_ptrdiff_t ():
16
-
17
- int_types = (ctypes .c_int16 , ctypes .c_int32 )
18
- if hasattr (ctypes , "c_int64" ):
19
- # Some builds of ctypes apparently do not have ctypes.c_int64
20
- # defined; it's a pretty good bet that these builds do not
21
- # have 64-bit pointers.
22
- int_types += (ctypes .c_int64 ,)
23
-
24
- c_ptrdiff_t = None
25
- for t in int_types :
26
- if ctypes .sizeof (t ) == ctypes .sizeof (ctypes .c_size_t ):
27
- c_ptrdiff_t = t
28
-
29
- return c_ptrdiff_t
30
-
31
- c_ptrdiff_t = _get_ptrdiff_t ()
32
-
33
- # -- End preamble --
7
+ from ctypes import *
34
8
35
9
36
10
# -- Begin loader template --
37
11
38
12
import sys
39
13
import ctypes
40
14
import ctypes .util
41
- import warnings
42
15
import pathlib
43
16
44
- def _find_library (name , dirs , search_sys , reldir = None ):
17
+ def _find_library (name , dirs , search_sys ):
45
18
46
19
if sys .platform in ("win32" , "cygwin" , "msys" ):
47
20
patterns = ["{}.dll" , "lib{}.dll" , "{}" ]
@@ -50,39 +23,27 @@ def _find_library(name, dirs, search_sys, reldir=None):
50
23
else : # assume unix pattern or plain name
51
24
patterns = ["lib{}.so" , "{}.so" , "{}" ]
52
25
53
- if reldir is None :
54
- try :
55
- reldir = pathlib .Path (__file__ ).parent
56
- except NameError :
57
- reldir = None
58
-
59
26
for dir in dirs :
60
27
dir = pathlib .Path (dir )
61
28
if not dir .is_absolute ():
62
29
# NOTE joining an absolute path silently discardy the path before
63
- assert reldir != None , "cannot resolve relative paths without anchor point (__file__ not defined?)"
64
- dir = (reldir / dir ).resolve (strict = False )
30
+ dir = (pathlib .Path (__file__ ).parent / dir ).resolve (strict = False )
65
31
for pat in patterns :
66
32
libpath = dir / pat .format (name )
67
33
if libpath .is_file ():
68
34
return str (libpath )
69
35
70
- if search_sys :
71
- if dirs :
72
- warnings .warn (f"Could not find library '{ name } ' in { dirs } , falling back to system" )
73
- libpath = ctypes .util .find_library (name )
74
- if not libpath :
75
- raise ImportError (f"Could not find library '{ name } ' in system" )
76
- return libpath
77
- else :
78
- raise ImportError (f"Could not find library '{ name } ' in { dirs } (system search disabled)" )
36
+ libpath = ctypes .util .find_library (name ) if search_sys else None
37
+ if not libpath :
38
+ raise ImportError (f"Could not find library '{ name } ' (dirs={ dirs } , search_sys={ search_sys } )" )
39
+
40
+ return libpath
79
41
80
42
_libs_info , _libs = {}, {}
81
43
82
44
def _register_library (name , dllclass , ** kwargs ):
83
45
libpath = _find_library (name , ** kwargs )
84
- assert libpath , "output expected from _find_library()"
85
- _libs_info [name ] = {"name" : name , "dllclass" : dllclass , ** kwargs , "path" : libpath }
46
+ _libs_info [name ] = {** kwargs , "path" : libpath }
86
47
_libs [name ] = dllclass (libpath )
87
48
88
49
# -- End loader template --
@@ -2481,133 +2442,139 @@ class struct_FPDF_IMAGEOBJ_METADATA (Structure):
2481
2442
FPDFText_LoadStandardFont .argtypes = [FPDF_DOCUMENT , FPDF_BYTESTRING ]
2482
2443
FPDFText_LoadStandardFont .restype = FPDF_FONT
2483
2444
2484
- # ./data/bindings/headers/fpdf_edit.h: 1226
2445
+ # ./data/bindings/headers/fpdf_edit.h: 1235
2446
+ if hasattr (_libs ['pdfium' ], 'FPDFText_LoadCidType2Font' ):
2447
+ FPDFText_LoadCidType2Font = _libs ['pdfium' ]['FPDFText_LoadCidType2Font' ]
2448
+ FPDFText_LoadCidType2Font .argtypes = [FPDF_DOCUMENT , POINTER (uint8_t ), uint32_t , FPDF_BYTESTRING , POINTER (uint8_t ), uint32_t ]
2449
+ FPDFText_LoadCidType2Font .restype = FPDF_FONT
2450
+
2451
+ # ./data/bindings/headers/fpdf_edit.h: 1250
2485
2452
if hasattr (_libs ['pdfium' ], 'FPDFTextObj_GetFontSize' ):
2486
2453
FPDFTextObj_GetFontSize = _libs ['pdfium' ]['FPDFTextObj_GetFontSize' ]
2487
2454
FPDFTextObj_GetFontSize .argtypes = [FPDF_PAGEOBJECT , POINTER (c_float )]
2488
2455
FPDFTextObj_GetFontSize .restype = FPDF_BOOL
2489
2456
2490
- # ./data/bindings/headers/fpdf_edit.h: 1231
2457
+ # ./data/bindings/headers/fpdf_edit.h: 1255
2491
2458
if hasattr (_libs ['pdfium' ], 'FPDFFont_Close' ):
2492
2459
FPDFFont_Close = _libs ['pdfium' ]['FPDFFont_Close' ]
2493
2460
FPDFFont_Close .argtypes = [FPDF_FONT ]
2494
2461
FPDFFont_Close .restype = None
2495
2462
2496
- # ./data/bindings/headers/fpdf_edit.h: 1241
2463
+ # ./data/bindings/headers/fpdf_edit.h: 1265
2497
2464
if hasattr (_libs ['pdfium' ], 'FPDFPageObj_CreateTextObj' ):
2498
2465
FPDFPageObj_CreateTextObj = _libs ['pdfium' ]['FPDFPageObj_CreateTextObj' ]
2499
2466
FPDFPageObj_CreateTextObj .argtypes = [FPDF_DOCUMENT , FPDF_FONT , c_float ]
2500
2467
FPDFPageObj_CreateTextObj .restype = FPDF_PAGEOBJECT
2501
2468
2502
- # ./data/bindings/headers/fpdf_edit.h: 1252
2469
+ # ./data/bindings/headers/fpdf_edit.h: 1276
2503
2470
if hasattr (_libs ['pdfium' ], 'FPDFTextObj_GetTextRenderMode' ):
2504
2471
FPDFTextObj_GetTextRenderMode = _libs ['pdfium' ]['FPDFTextObj_GetTextRenderMode' ]
2505
2472
FPDFTextObj_GetTextRenderMode .argtypes = [FPDF_PAGEOBJECT ]
2506
2473
FPDFTextObj_GetTextRenderMode .restype = FPDF_TEXT_RENDERMODE
2507
2474
2508
- # ./data/bindings/headers/fpdf_edit.h: 1263
2475
+ # ./data/bindings/headers/fpdf_edit.h: 1287
2509
2476
if hasattr (_libs ['pdfium' ], 'FPDFTextObj_SetTextRenderMode' ):
2510
2477
FPDFTextObj_SetTextRenderMode = _libs ['pdfium' ]['FPDFTextObj_SetTextRenderMode' ]
2511
2478
FPDFTextObj_SetTextRenderMode .argtypes = [FPDF_PAGEOBJECT , FPDF_TEXT_RENDERMODE ]
2512
2479
FPDFTextObj_SetTextRenderMode .restype = FPDF_BOOL
2513
2480
2514
- # ./data/bindings/headers/fpdf_edit.h: 1280
2481
+ # ./data/bindings/headers/fpdf_edit.h: 1304
2515
2482
if hasattr (_libs ['pdfium' ], 'FPDFTextObj_GetText' ):
2516
2483
FPDFTextObj_GetText = _libs ['pdfium' ]['FPDFTextObj_GetText' ]
2517
2484
FPDFTextObj_GetText .argtypes = [FPDF_PAGEOBJECT , FPDF_TEXTPAGE , POINTER (FPDF_WCHAR ), c_ulong ]
2518
2485
FPDFTextObj_GetText .restype = c_ulong
2519
2486
2520
- # ./data/bindings/headers/fpdf_edit.h: 1299
2487
+ # ./data/bindings/headers/fpdf_edit.h: 1323
2521
2488
if hasattr (_libs ['pdfium' ], 'FPDFTextObj_GetRenderedBitmap' ):
2522
2489
FPDFTextObj_GetRenderedBitmap = _libs ['pdfium' ]['FPDFTextObj_GetRenderedBitmap' ]
2523
2490
FPDFTextObj_GetRenderedBitmap .argtypes = [FPDF_DOCUMENT , FPDF_PAGE , FPDF_PAGEOBJECT , c_float ]
2524
2491
FPDFTextObj_GetRenderedBitmap .restype = FPDF_BITMAP
2525
2492
2526
- # ./data/bindings/headers/fpdf_edit.h: 1310
2493
+ # ./data/bindings/headers/fpdf_edit.h: 1334
2527
2494
if hasattr (_libs ['pdfium' ], 'FPDFTextObj_GetFont' ):
2528
2495
FPDFTextObj_GetFont = _libs ['pdfium' ]['FPDFTextObj_GetFont' ]
2529
2496
FPDFTextObj_GetFont .argtypes = [FPDF_PAGEOBJECT ]
2530
2497
FPDFTextObj_GetFont .restype = FPDF_FONT
2531
2498
2532
- # ./data/bindings/headers/fpdf_edit.h: 1326
2499
+ # ./data/bindings/headers/fpdf_edit.h: 1350
2533
2500
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetFontName' ):
2534
2501
FPDFFont_GetFontName = _libs ['pdfium' ]['FPDFFont_GetFontName' ]
2535
2502
FPDFFont_GetFontName .argtypes = [FPDF_FONT , POINTER (c_char ), c_ulong ]
2536
2503
FPDFFont_GetFontName .restype = c_ulong
2537
2504
2538
- # ./data/bindings/headers/fpdf_edit.h: 1347
2505
+ # ./data/bindings/headers/fpdf_edit.h: 1371
2539
2506
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetFontData' ):
2540
2507
FPDFFont_GetFontData = _libs ['pdfium' ]['FPDFFont_GetFontData' ]
2541
2508
FPDFFont_GetFontData .argtypes = [FPDF_FONT , POINTER (uint8_t ), c_size_t , POINTER (c_size_t )]
2542
2509
FPDFFont_GetFontData .restype = FPDF_BOOL
2543
2510
2544
- # ./data/bindings/headers/fpdf_edit.h: 1358
2511
+ # ./data/bindings/headers/fpdf_edit.h: 1382
2545
2512
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetIsEmbedded' ):
2546
2513
FPDFFont_GetIsEmbedded = _libs ['pdfium' ]['FPDFFont_GetIsEmbedded' ]
2547
2514
FPDFFont_GetIsEmbedded .argtypes = [FPDF_FONT ]
2548
2515
FPDFFont_GetIsEmbedded .restype = c_int
2549
2516
2550
- # ./data/bindings/headers/fpdf_edit.h: 1367
2517
+ # ./data/bindings/headers/fpdf_edit.h: 1391
2551
2518
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetFlags' ):
2552
2519
FPDFFont_GetFlags = _libs ['pdfium' ]['FPDFFont_GetFlags' ]
2553
2520
FPDFFont_GetFlags .argtypes = [FPDF_FONT ]
2554
2521
FPDFFont_GetFlags .restype = c_int
2555
2522
2556
- # ./data/bindings/headers/fpdf_edit.h: 1376
2523
+ # ./data/bindings/headers/fpdf_edit.h: 1400
2557
2524
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetWeight' ):
2558
2525
FPDFFont_GetWeight = _libs ['pdfium' ]['FPDFFont_GetWeight' ]
2559
2526
FPDFFont_GetWeight .argtypes = [FPDF_FONT ]
2560
2527
FPDFFont_GetWeight .restype = c_int
2561
2528
2562
- # ./data/bindings/headers/fpdf_edit.h: 1388
2529
+ # ./data/bindings/headers/fpdf_edit.h: 1412
2563
2530
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetItalicAngle' ):
2564
2531
FPDFFont_GetItalicAngle = _libs ['pdfium' ]['FPDFFont_GetItalicAngle' ]
2565
2532
FPDFFont_GetItalicAngle .argtypes = [FPDF_FONT , POINTER (c_int )]
2566
2533
FPDFFont_GetItalicAngle .restype = FPDF_BOOL
2567
2534
2568
- # ./data/bindings/headers/fpdf_edit.h: 1402
2535
+ # ./data/bindings/headers/fpdf_edit.h: 1426
2569
2536
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetAscent' ):
2570
2537
FPDFFont_GetAscent = _libs ['pdfium' ]['FPDFFont_GetAscent' ]
2571
2538
FPDFFont_GetAscent .argtypes = [FPDF_FONT , c_float , POINTER (c_float )]
2572
2539
FPDFFont_GetAscent .restype = FPDF_BOOL
2573
2540
2574
- # ./data/bindings/headers/fpdf_edit.h: 1417
2541
+ # ./data/bindings/headers/fpdf_edit.h: 1441
2575
2542
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetDescent' ):
2576
2543
FPDFFont_GetDescent = _libs ['pdfium' ]['FPDFFont_GetDescent' ]
2577
2544
FPDFFont_GetDescent .argtypes = [FPDF_FONT , c_float , POINTER (c_float )]
2578
2545
FPDFFont_GetDescent .restype = FPDF_BOOL
2579
2546
2580
- # ./data/bindings/headers/fpdf_edit.h: 1433
2547
+ # ./data/bindings/headers/fpdf_edit.h: 1457
2581
2548
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetGlyphWidth' ):
2582
2549
FPDFFont_GetGlyphWidth = _libs ['pdfium' ]['FPDFFont_GetGlyphWidth' ]
2583
2550
FPDFFont_GetGlyphWidth .argtypes = [FPDF_FONT , uint32_t , c_float , POINTER (c_float )]
2584
2551
FPDFFont_GetGlyphWidth .restype = FPDF_BOOL
2585
2552
2586
- # ./data/bindings/headers/fpdf_edit.h: 1446
2553
+ # ./data/bindings/headers/fpdf_edit.h: 1470
2587
2554
if hasattr (_libs ['pdfium' ], 'FPDFFont_GetGlyphPath' ):
2588
2555
FPDFFont_GetGlyphPath = _libs ['pdfium' ]['FPDFFont_GetGlyphPath' ]
2589
2556
FPDFFont_GetGlyphPath .argtypes = [FPDF_FONT , uint32_t , c_float ]
2590
2557
FPDFFont_GetGlyphPath .restype = FPDF_GLYPHPATH
2591
2558
2592
- # ./data/bindings/headers/fpdf_edit.h: 1457
2559
+ # ./data/bindings/headers/fpdf_edit.h: 1481
2593
2560
if hasattr (_libs ['pdfium' ], 'FPDFGlyphPath_CountGlyphSegments' ):
2594
2561
FPDFGlyphPath_CountGlyphSegments = _libs ['pdfium' ]['FPDFGlyphPath_CountGlyphSegments' ]
2595
2562
FPDFGlyphPath_CountGlyphSegments .argtypes = [FPDF_GLYPHPATH ]
2596
2563
FPDFGlyphPath_CountGlyphSegments .restype = c_int
2597
2564
2598
- # ./data/bindings/headers/fpdf_edit.h: 1467
2565
+ # ./data/bindings/headers/fpdf_edit.h: 1491
2599
2566
if hasattr (_libs ['pdfium' ], 'FPDFGlyphPath_GetGlyphPathSegment' ):
2600
2567
FPDFGlyphPath_GetGlyphPathSegment = _libs ['pdfium' ]['FPDFGlyphPath_GetGlyphPathSegment' ]
2601
2568
FPDFGlyphPath_GetGlyphPathSegment .argtypes = [FPDF_GLYPHPATH , c_int ]
2602
2569
FPDFGlyphPath_GetGlyphPathSegment .restype = FPDF_PATHSEGMENT
2603
2570
2604
- # ./data/bindings/headers/fpdf_edit.h: 1475
2571
+ # ./data/bindings/headers/fpdf_edit.h: 1499
2605
2572
if hasattr (_libs ['pdfium' ], 'FPDFFormObj_CountObjects' ):
2606
2573
FPDFFormObj_CountObjects = _libs ['pdfium' ]['FPDFFormObj_CountObjects' ]
2607
2574
FPDFFormObj_CountObjects .argtypes = [FPDF_PAGEOBJECT ]
2608
2575
FPDFFormObj_CountObjects .restype = c_int
2609
2576
2610
- # ./data/bindings/headers/fpdf_edit.h: 1484
2577
+ # ./data/bindings/headers/fpdf_edit.h: 1508
2611
2578
if hasattr (_libs ['pdfium' ], 'FPDFFormObj_GetObject' ):
2612
2579
FPDFFormObj_GetObject = _libs ['pdfium' ]['FPDFFormObj_GetObject' ]
2613
2580
FPDFFormObj_GetObject .argtypes = [FPDF_PAGEOBJECT , c_ulong ]
0 commit comments