Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid declaring types and functions in API mode #463

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
37 changes: 5 additions & 32 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 @@ -155,14 +153,6 @@ def cdefs(features):
unsigned int flags;
GType value_type;
GType owner_type;

// private, but cffi in API mode needs these to be able to get the
// offset of any member
char* _nick;
char* _blurb;
GData* qdata;
unsigned int ref_count;
unsigned int param_id;
} GParamSpec;

typedef struct _GEnumValue {
Expand Down Expand Up @@ -402,15 +392,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 +500,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