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

struct reflection #10

Closed
1 of 2 tasks
ihnorton opened this issue Mar 10, 2013 · 6 comments
Closed
1 of 2 tasks

struct reflection #10

ihnorton opened this issue Mar 10, 2013 · 6 comments

Comments

@ihnorton
Copy link
Collaborator

Generate Julia types to match C struct declarations

  • fixed-size arrays
  • unions
@mlubin
Copy link
Contributor

mlubin commented Apr 22, 2013

+1

@ihnorton
Copy link
Collaborator Author

This is available for simple structs (bitstypes and pointers only) if you set "WrapContext.options.wrap_structs = true". But the utility is kind of limited, because we can't pass structs by value or de-reference members in pure Julia yet.

For supported structs, the output should be usable with StrPack by adding @struct in front of the type declaration, but you would still need to do the pack/unpack steps yourself around each call. When I looked through StrPack I didn't really see a consistent way to generate wrappers to do that, because you need to know some things about how the function will actually be called... but maybe I should look in to that again.

@pao
Copy link

pao commented Apr 22, 2013

I'm open to patches. Of course avoiding StrPack is going to be better when possible since using it will force a copy in each direction. I'm not sure what currently works or doesn't natively, and as I believe you are aware it's not obvious from the current issues on the topic.

@ihnorton
Copy link
Collaborator Author

I should have phrased that differently, because the question of whether or not to strpack a particular pointer argument is kind of tangential to StrPack (context-specific and requires knowledge beyond just the fact that it is a pointer).

@ihnorton
Copy link
Collaborator Author

ihnorton commented Nov 7, 2013

Fixed-size arrays are supported here by pre-declaring a bitstype of the appropriate size, and then using that in the right place so that the struct is at least sized and aligned correctly. The result is eg: bitstype 32*sizeof(UINT8)*16 Array_16_UINT. (I suppose custom getindex/setindex can be defined on these if needed.. obviously this will all go away as soon as the new tuple stuff is merged)

Need to do unions in a similar way by finding the largest element.

@Gnimuc
Copy link
Member

Gnimuc commented Mar 30, 2019

closed in favor of #228

@Gnimuc Gnimuc closed this as completed Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants