Skip to content

Commit

Permalink
Avoid declaring types and functions in API mode
Browse files Browse the repository at this point in the history
This appears redundant, as these types and functions originate from
`vips/vips.h` in API mode.

Resolves: #459.
  • Loading branch information
kleisauke committed Apr 22, 2024
1 parent 9c7e151 commit dbcb5db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
16 changes: 0 additions & 16 deletions pyvips/pyvips_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,6 @@ def modversion(package):
""" + compat,
**pkgconfig.parse('vips'))

features = {
'major': major,
'minor': minor,
'micro': micro,
'api': True,
}


import vdecls

# handy for debugging
# with open('vips-source.txt','w') as f:
# c = vdecls.cdefs(features)
# f.write(c)

ffibuilder.cdef(vdecls.cdefs(features))

if __name__ == "__main__":
ffibuilder.compile(verbose=True)
29 changes: 5 additions & 24 deletions pyvips/vdecls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# all the C decls for pyvips

# we keep these together to make switching between ABI and API modes simpler

# we have to pass in the libvips version, since it can come from either
# pkg-config in compile.py (in API mode) or libvips itself in __init__.py
# (in ABI mode)
# we have to pass in the libvips version to maintain backwards compatibility.

import sys

Expand All @@ -18,8 +14,7 @@ def cdefs(features):
"""Return the C API declarations for libvips.
features is a dict with the features we want. Some features were only
added in later libvips, for example, and some need to be disabled in
some FFI modes.
added in later libvips, for example, and some need to be disabled.
"""

Expand Down Expand Up @@ -110,6 +105,9 @@ def cdefs(features):
void vips_value_set_array_int (GValue* value,
const int* array, int n );
void vips_value_set_array_image (GValue *value, int n);
typedef void (*FreeFn)(void* a);
void vips_value_set_blob (GValue* value,
FreeFn free_fn, void* data, size_t length);
int g_value_get_boolean (const GValue* value);
int g_value_get_int (GValue* value);
Expand Down Expand Up @@ -402,15 +400,6 @@ def cdefs(features):
int vips_cache_get_max_files();
'''

# we must only define this in ABI mode ... in API mode we use
# vips_value_set_blob_free in a backwards compatible way
if not features['api']:
code += '''
typedef void (*FreeFn)(void* a);
void vips_value_set_blob (GValue* value,
FreeFn free_fn, void* data, size_t length);
'''

if _at_least(features, 8, 5):
code += '''
char** vips_image_get_fields (VipsImage* image);
Expand Down Expand Up @@ -519,14 +508,6 @@ def cdefs(features):
'''

# we must only define these in API mode ... in ABI mode we need to call
# these things earlier
if features['api']:
code += '''
int vips_init (const char* argv0);
int vips_version (int flag);
'''

# ... means inherit from C defines
code += '#define VIPS_MAJOR_VERSION ...\n'
code += '#define VIPS_MINOR_VERSION ...\n'
Expand Down

0 comments on commit dbcb5db

Please sign in to comment.