lingua-franca icon indicating copy to clipboard operation
lingua-franca copied to clipboard

[CCPP]: Generic Type is not resolved in header for target CCPP

Open mkhubaibumer opened this issue 1 year ago • 2 comments

We implemented Generics in such a way that Template type is defined with its concrete type in source file and it gets replaced with the concrete type in header file For target CCPP source file resolution is working as expected but the template type doesn't get resolved in header file causing the state variable declaration to fail the compilation

Consider the following code

target CCPP;

preamble {=
    #include <iostream>
    #include <memory>
=}

reactor Base<T1> {
    input in:T1
    reaction(in) {=
        printf("Hello\n");
    =}
}

reactor Der<T1> extends Base {
    state val:std::vector<T1>
    reaction(in) {=
        self->val.push_back(in->value);
        printf("well\n");
    =}
    input print:bool
    reaction(print) {=
        printf("values: [ ");
        for(const auto &it : self->val) {
            printf("%d ", it);
        }
        printf("]\n");
        self->val.clear();
    =}
}

reactor T {
    timer t(0, 2sec)
    output out:int
    reaction(t) -> out {=
        lf_set(out, rand());
    =}

    timer t1(0, 1min)
    output print:bool
    reaction(t1) -> print {=
        lf_set(print, true);
    =}
}

main reactor {
    t= new T();
    d= new Der<int>();
    t.out -> d.in
    t.print -> d.print
}

state val:std::vector<T1> fails compilation due to the above mentioned issue

mkhubaibumer avatar Feb 14 '24 11:02 mkhubaibumer

@petervdonovan do you think this would be easily fixable?

cmnrd avatar Feb 22 '24 08:02 cmnrd

@petervdonovan do you think this would be easily fixable?

Probably.

petervdonovan avatar Feb 22 '24 20:02 petervdonovan