Skip to content

Commit

Permalink
translation of opaque pointer types (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemkaKun authored Aug 11, 2023
1 parent 1f17436 commit e0d91a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/c2v.v
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,13 @@ fn (mut c C2V) typedef_decl(node &Node) {
if node.name in builtin_type_names {
return
}

if typ.starts_with('struct ') && typ.ends_with(' *') {
// Opaque pointer, for example: typedef struct TSTexture_t *TSTexture;
c.genln('type ${alias_name} = voidptr')
return
}

if !typ.contains(alias_name) {
if typ.contains('(*)') {
tt := convert_type(typ)
Expand Down
1 change: 1 addition & 0 deletions tests/17.partial_struct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typedef struct TSTexture_t *TSTexture;
4 changes: 4 additions & 0 deletions tests/17.partial_struct.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[translated]
module main

type TSTexture = voidptr

0 comments on commit e0d91a3

Please sign in to comment.