Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use exact types for Py_BuildValue.#7853

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
efiring merged 2 commits intomatplotlib:masterfromQuLogic:Py_BuildValue-types
Feb 25, 2018

Conversation

QuLogic
Copy link
Member

IIRC, most ABI upcast values passed to vararg functions anyway, but there might be some other ABIs that require the exact correct type.

@QuLogicQuLogic changed the titleUse exact types for Py_BuildValue.[MRG] Use exact types for Py_BuildValue.Jan 21, 2017
@QuLogicQuLogic requested a review frommdboomJanuary 21, 2017 04:34
@story645
Copy link
Member

Stupid questions cause I wanna wrap my head around this... What's the reference you're using to get specific types? And how come the new specific types don't have to be the same size as (and sometimes bigger than) the old types?

@QuLogic
Copy link
MemberAuthor

I get the types from theFreeType API.

IIRC, C ABI promotes all scalar values into the largest compatible type when passed to vararg functions likePy_BuildValue, so there's generally always enough space to treat it as a larger type even when it didn't start as one. I know for certain that this is true offloat, which is promoted todouble, on x86*, but I'm not exactly sure about integral types. And the ABI may be different on other architectures.

story645 reacted with thumbs up emoji

@tacaswelltacaswell added this to the2.1 (next point release) milestoneJan 24, 2017
@@ -18,8 +18,8 @@ extern "C" {
/*
By definition, FT_FIXED as 2 16bit values stored in a single long.
*/
#define FIXED_MAJOR(val) (long)((val & 0xffff000) >> 16)
#define FIXED_MINOR(val) (long)(val & 0xffff)
#define FIXED_MAJOR(val) (unsigned short)((val & 0xffff000) >> 16)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that supposed to be a signed long?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not exactly, but there appears to maybe be a deeper existing bug here. I'm not sure if I'm just reading it wrong, but will need some time to investigate.

Copy link
Member

Choose a reason for hiding this comment

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

What areFIXED_MAJOR andFIXED_MINOR?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

They extract the two 16-bit values. However, there's a bug inFIXED_MAJOR; it masks the input as if it were 16.12 (with 4 undefined bits) yet shifts by 16. The top 4 bits get lost.

In the end though, it turns out we never use these values for anything (they're all versions specifiers.)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, so they're what the freestype docs call something like FT_MAJOR and FT_MINOR?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I don't see such things?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Those are the Freetype version; I'm referring to font file versions.

IIRC, most ABI upcast values passed to vararg functions anyway, butthere might be some other ABIs that require the exact correct type.
It was masking the wrong bits, but fortunately, we never seem to usethis value for anything.
@QuLogic
Copy link
MemberAuthor

Ping@mdboom?

1 similar comment
@QuLogic
Copy link
MemberAuthor

Ping@mdboom?

@tacaswelltacaswell modified the milestones:2.1 (next point release),2.2 (next next feature release)Sep 24, 2017
@QuLogicQuLogic requested a review fromanntzerFebruary 5, 2018 04:03
#define FIXED_MAJOR(val) (long)((val &0xffff000) >> 16)
#define FIXED_MINOR(val) (long)(val & 0xffff)
#define FIXED_MAJOR(val) (signed short)((val &0xffff0000) >> 16)
#define FIXED_MINOR(val) (unsigned short)(val & 0xffff)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also cause a type change in the version and fontrevision fields of converting TT_Header no?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

As inhere?

anntzer reacted with thumbs up emoji
@anntzer
Copy link
Contributor

I think just a type change is missing? Otherwise looks fine (but this is the kind of things that decltype in modern C++ (e.g. via pybind11) makes much easier :-)).

@tacaswelltacaswell modified the milestones:v2.2,v3.0Feb 10, 2018
@efiringefiring merged commit57c9a78 intomatplotlib:masterFeb 25, 2018
@QuLogicQuLogic deleted the Py_BuildValue-types branchFebruary 25, 2018 21:44
@QuLogicQuLogic changed the title[MRG] Use exact types for Py_BuildValue.Use exact types for Py_BuildValue.Feb 25, 2018
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull requestOct 19, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@NelleVNelleVNelleV left review comments

@story645story645story645 left review comments

@anntzeranntzeranntzer approved these changes

@mdboommdboomAwaiting requested review from mdboom

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.0.0
Development

Successfully merging this pull request may close these issues.

6 participants
@QuLogic@story645@anntzer@NelleV@efiring@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp