Skip to content

Add enum helper #47

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

Merged
merged 2 commits into from
Jun 10, 2018
Merged

Add enum helper #47

merged 2 commits into from
Jun 10, 2018

Conversation

kleisauke
Copy link
Member

@kleisauke kleisauke commented Jun 9, 2018

Needed for: libvips/php-vips#72.

To get all enum values for a specific enum.

To get all enum values for a specific enum.
@kleisauke
Copy link
Member Author

Just noticed that there are some warnings in the Travis build:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -I/home/travis/vips/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libgsf-1 -I/usr/include/ImageMagick -I/usr/include/orc-0.4 -I/usr/include/OpenEXR -I/usr/include/poppler/glib -I/usr/include/cairo -I/usr/include/librsvg-2.0 -I/usr/include/openslide -I/usr/include/pango-1.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/libpng12 -I/usr/include/libexif -I/usr/include/libxml2 -I/usr/include/poppler -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/harfbuzz -I/opt/python/3.6.3/include/python3.6m -c build/temp.linux-x86_64-3.6/_libvips.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/_libvips.o
build/temp.linux-x86_64-3.6/_libvips.c: In function ‘_cffi_checkfld__GEnumClass’:
build/temp.linux-x86_64-3.6/_libvips.c:4657:25: warning: initialization from incompatible pointer type [enabled by default]
   { GTypeClass * *tmp = &p->g_type_class; (void)tmp; }
                         ^
build/temp.linux-x86_64-3.6/_libvips.c: In function ‘_cffi_checkfld__GValue’:
build/temp.linux-x86_64-3.6/_libvips.c:4720:25: warning: initialization from incompatible pointer type [enabled by default]
   { uint64_t(*tmp)[2] = &p->data; (void)tmp; }
                         ^
build/temp.linux-x86_64-3.6/_libvips.c: In function ‘_cffi_checkfld__VipsObject’:
build/temp.linux-x86_64-3.6/_libvips.c:4781:19: warning: initialization from incompatible pointer type [enabled by default]
   { void * *tmp = &p->argument_table; (void)tmp; }
                   ^

Can we safely ignore those?

@jcupitt
Copy link
Member

jcupitt commented Jun 10, 2018

Yes, they are harmless, I looked into them a while ago. They are hard to suppress, unfortunately.

pyvips/base.py Outdated
value = _to_string(ffi.string(g_enum_class.values[i].value_nick))
values.append(value)

glib_lib.g_free(g_enum_class)
Copy link
Member

@jcupitt jcupitt Jun 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need this? g_type_class_ref() results can usually just be left: extra refs on classes don't matter, since we never unload., and I think freeing them is not correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about this one. Removed with jcupitt@d27b8e2.

Thanks!

Freeing isn't correct here.
@jcupitt jcupitt merged commit 40e57de into libvips:master Jun 10, 2018
@jcupitt
Copy link
Member

jcupitt commented Jun 10, 2018

Great!

@kleisauke kleisauke deleted the enum-helper branch June 10, 2018 10:37
kleisauke added a commit to kleisauke/pyvips that referenced this pull request Aug 19, 2020
Similar to libvips#47, but for flags (e.g. VipsForeignPngFilter).
kleisauke added a commit to kleisauke/pyvips that referenced this pull request Nov 2, 2021
Similar to libvips#47, but for flags (e.g. VipsForeignPngFilter).
@kleisauke kleisauke mentioned this pull request Nov 15, 2021
jcupitt pushed a commit that referenced this pull request Nov 15, 2021
Similar to #47, but for flags (e.g. VipsForeignPngFilter).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants