-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate prefixes to struct literals
Fix #238 This ensures that constants of a struct type have their type and the type of their underlying value expressions renamed in the case of a prefix.
- Loading branch information
Showing
7 changed files
with
152 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct PREFIXFoo { | ||
int32_t a; | ||
uint32_t b; | ||
} PREFIXFoo; | ||
|
||
#define PREFIXBAR (PREFIXFoo){ .a = 42, .b = 1337 } | ||
|
||
#define PREFIXFoo_FOO (PREFIXFoo){ .a = 42, .b = 47 } | ||
|
||
void root(PREFIXFoo x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct { | ||
int32_t a; | ||
uint32_t b; | ||
} PREFIXFoo; | ||
|
||
#define PREFIXBAR (PREFIXFoo){ .a = 42, .b = 1337 } | ||
|
||
#define PREFIXFoo_FOO (PREFIXFoo){ .a = 42, .b = 47 } | ||
|
||
void root(PREFIXFoo x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <cstdint> | ||
#include <cstdlib> | ||
|
||
struct PREFIXFoo { | ||
int32_t a; | ||
uint32_t b; | ||
}; | ||
|
||
static const PREFIXFoo PREFIXBAR = (PREFIXFoo){ .a = 42, .b = 1337 }; | ||
|
||
static const PREFIXFoo PREFIXFoo_FOO = (PREFIXFoo){ .a = 42, .b = 47 }; | ||
|
||
extern "C" { | ||
|
||
void root(PREFIXFoo x); | ||
|
||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
struct PREFIXFoo { | ||
int32_t a; | ||
uint32_t b; | ||
}; | ||
|
||
#define PREFIXBAR (PREFIXFoo){ .a = 42, .b = 1337 } | ||
|
||
#define PREFIXFoo_FOO (PREFIXFoo){ .a = 42, .b = 47 } | ||
|
||
void root(struct PREFIXFoo x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#[repr(C)] | ||
struct Foo { | ||
a: i32, | ||
b: u32, | ||
} | ||
|
||
impl Foo { | ||
const FOO: Foo = Foo{ a: 42, b: 47, }; | ||
} | ||
|
||
const BAR: Foo = Foo{ a: 42, b: 1337, }; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root(x: Foo) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[export] | ||
prefix = "PREFIX" |