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

Improved printing for tagless structs and unions #467

Merged
merged 2 commits into from
Nov 2, 2016
Merged

Improved printing for tagless structs and unions #467

merged 2 commits into from
Nov 2, 2016

Conversation

yallop
Copy link
Owner

@yallop yallop commented Nov 2, 2016

Closes #249.

Here are the examples from #249:

let struc = Ctypes.structure ""
let r = field struc "r" float
let g = field struc "g" float
let b = field struc "b" float
let a = field struc "a" float
let () = seal struc

let uni = union ""
let floats = field uni "rgba" (array 4 float)
let struc' = field uni "" struc
let () = seal uni

let struc'' = structure "NVGcolor"
let _ = field struc'' "" uni
let () = seal struc''

And here's how those types are printed before and after this change:

Unions with tagless struct fields

Before

# uni;;
- : '_a Static.union typ = union  { float rgba[4]; struct  ;  }

After

# uni;;
- : '_a Ctypes_static.union typ =
union { float rgba[4]; struct { float r; float g; float b; float a;  } ;  }

Structs with tagless union fields

Before

# struc'';;
- : '_a Static.structure typ = struct NVGcolor { union  ;  }

After

# struc'';;
- : '_a Ctypes_static.structure typ =
struct NVGcolor {
  union { float rgba[4]; struct { float r; float g; float b; float a;  } ; 
  } ; 
}

@yallop yallop merged commit ea7af5d into yallop:master Nov 2, 2016
@yallop yallop deleted the tagless-structure-printing branch November 2, 2016 14:53
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.

1 participant