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

typedef support (Closes #135) #238

Merged
merged 1 commit into from Dec 31, 2014
Merged

typedef support (Closes #135) #238

merged 1 commit into from Dec 31, 2014

Conversation

edwintorok
Copy link

Preserve the view type formatter when projecting types.
Also introduce a convenience wrapper that just typedefs.

With these changes it is possible to support "anonymous" types in C stubs
as in issue #135, for example given:
typedef struct { ... } SDL_JoystickGUID

let joystick_guid : joystick_guid typ = structure "_SDL_JoystickGUID"
(* ... *)
let joystick_guid =
typedef "SDL_JoystickGUID" joystick_guid

let joystick_get_guid_string =
foreign "SDL_JoystickGetGUIDString"
(joystick_guid @-> ptr char @-> int @-> returning void)

Ctypes should generate 'SDL_JoystickGUID x1696 = ...' instead of
'struct _SDL_JoystickGUID x1696 = ...' which would fail to compile.

Preserve the view type formatter when projecting types.
Also introduce a convenience wrapper that just typedefs.

With these changes it is possible to support "anonymous" types in C stubs
as in issue #135, for example given:
typedef struct { ... } SDL_JoystickGUID

let joystick_guid : joystick_guid typ = structure "_SDL_JoystickGUID"
(* ... *)
let joystick_guid =
  typedef "SDL_JoystickGUID" joystick_guid

let joystick_get_guid_string =
  foreign "SDL_JoystickGetGUIDString"
    (joystick_guid @-> ptr char @-> int @-> returning void)

Ctypes should generate 'SDL_JoystickGUID x1696 = ...' instead of
'struct _SDL_JoystickGUID x1696 = ...' which would fail to compile.
@yallop
Copy link
Owner

yallop commented Dec 31, 2014

This looks good to me. Thanks for the contribution!

yallop added a commit that referenced this pull request Dec 31, 2014
@yallop yallop merged commit 690258c into yallop:master Dec 31, 2014
@edwintorok edwintorok deleted the typedef branch December 31, 2014 10:33
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.

None yet

2 participants