Skip to content

Wrong decl_type for function pointers ? #61

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

Closed
teto opened this issue Jul 24, 2016 · 8 comments
Closed

Wrong decl_type for function pointers ? #61

teto opened this issue Jul 24, 2016 · 8 comments
Assignees
Labels
Milestone

Comments

@teto
Copy link

teto commented Jul 24, 2016

When the argument is a function pointer, there seems to be a few problems:

For instance for the function int atexit(void (*function)(void));, the pygccxml code decl.arguments[0].decl_type returns: void (*)( ) * which has 1 more asterisk then necessary ?

Nb: I made a mistake and ended up posting it first here
CastXML/CastXML#67

@iMichka iMichka added the bug label Jul 25, 2016
@iMichka iMichka added this to the 1.8.0 milestone Jul 25, 2016
@iMichka
Copy link
Collaborator

iMichka commented Jul 30, 2016

Thanks for reporting.

I will be on holidays for 3 weeks, so I will only able to have a look at this end of August. I will probably not have internet so I won't be able to respond to any questions/mails.

@teto
Copy link
Author

teto commented Jul 30, 2016

No problem, I have a workaround :)
Before you leave ( if you have the time, else no worry ) could you give me pointers (like what file to look into, what do you think is wrong) for #62 which is the only blocking pb for me. I might be able to provide a fix.
Enjoy your holyday to the fullest.

@iMichka
Copy link
Collaborator

iMichka commented Aug 29, 2016

Hi

I had a look at this problem. I do not think that it is a bug at first.

If you print type(decl.arguments[0].decl_type) you will see that the type is of pointer_t. Normally you would then use declarations.remove_pointer() to remove that type level and access the underlying free_function_type_t. The declarations.remove_pointer() function was broken and I fixed that, make sure you use the latest checkout from the develop branch.

I wrote an example to explain how these nested types work:
http://pygccxml.readthedocs.io/en/develop/examples/nested-types/example.html

And a more specific example for function pointers, which is the case you are treating here:
http://pygccxml.readthedocs.io/en/develop/examples/function-pointer/example.html

Hope that helps. Please close this bug if this works for you.

@iMichka iMichka removed the bug label Sep 1, 2016
@iMichka iMichka removed this from the 1.8.0 milestone Sep 1, 2016
@teto
Copy link
Author

teto commented Sep 10, 2016

when I ask for "decl.arguments[0].decl_type", do you agree it should return void (*)( ) and not
void (*)( ) * ? This is a function pointer, not a pointer to a function pointer, IMO I shouldn't have to call declarations.remove_pointer() .

iMichka added a commit that referenced this issue Sep 13, 2016
This does not change the type of the declaration, just the value of the decl_string attribute.
@iMichka
Copy link
Collaborator

iMichka commented Sep 13, 2016

Yes I guess the * is not wanted in that case. I am not using C++ often, so function pointer / pointer things are sometimes a little bit hairy for me.

I made a small change to the develop branch. I special-cased the function pointer decl_type creation, and the * is now gone.

The type is still pointer_t. One thing that may need to be done is to introduce a calldef_pointer_t class, extending pointer_t. Not sure this is needed anyway. It would require some work, for something that can still be checked with the is_calldef_pointer function.

Please tell me if that change is OK for you. I will apply that specific patch to the next 1.8.1 release then.

@iMichka iMichka added this to the 1.9.0 milestone Oct 5, 2016
@iMichka
Copy link
Collaborator

iMichka commented Oct 5, 2016

I'm closing this bug, as I consider the problem as fixed for now. Do not hesitate to open a new one if this does not work for you.

@iMichka iMichka closed this as completed Oct 5, 2016
@iMichka iMichka added the bug label Oct 5, 2016
@teto
Copy link
Author

teto commented Oct 5, 2016

The commit is in develop branch: is that the branch that will become pygccxml1.9 ? or should I cherry pick the commit ?
I am waiting for the struct fix in castxml before relaunching my tests.

@iMichka
Copy link
Collaborator

iMichka commented Oct 5, 2016

At the moment yes, but 1.9.0 will probably not go out before next year. It took at least 1 year between 1.7.0 and 1.8.0.

I will just make a 1.8.1 release with that specific fix, probably next week. I am currently looking at the struct thing.

@iMichka iMichka modified the milestones: 1.8.1, 1.9.0 Oct 5, 2016
@iMichka iMichka self-assigned this Oct 5, 2016
iMichka added a commit that referenced this issue Oct 21, 2016
This does not change the type of the declaration, just the value of the decl_string attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants