Skip to content

How should I map nested structs #258

Answered by basshelal
b4rd asked this question in Q&A
Discussion options

You must be logged in to vote

It depends on what the C code you're trying to map looks like.

If it uses an inner Struct reference meaning a pointer to a Struct such as:

typedef struct range {
    int min;
    int max;
} range_t;

struct outer {
    int mean;
    range_t *range;
};

Then use StructRef like below:

public class Range extends Struct {
    private final Signed32 min;
    private final Signed32 max;

    public Range(Runtime runtime) {
        super(runtime);
        this.min = new Signed32();
        this.max = new Signed32();
    }

    // methods here like setters getters or utilities
}

public class Outer extends Struct {
    private final Signed32 mean;
    private final StructRef<Range> range;

    public

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by headius
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #256 on August 05, 2021 14:37.