test/shared/app.rad 983 B raw
1
//! Shared entry with callbacks, initialized data pointers, and private counters.
2
3
use support;
4
5
/// Callback table contains a linked dependency function address.
6
static CALLBACKS: [fn() -> i32; 1] = [support::read];
7
/// The slice contains a pointer into this domain's string storage.
8
constant TEXT: *[u8] = "xy";
9
/// Number of calls in the current domain.
10
unsafe static calls: i32 = 0;
11
12
/// Read dependency state through calls and data, then advance private state.
13
@default export fn main() -> i32 {
14
    let number = support::Number { value: 23, extra: 47 };
15
    let borrowed = support::borrow(&number);
16
    let copied = support::copied(borrowed);
17
    assert copied.value == 23;
18
    assert copied.extra == 47;
19
    let referenced = support::referenced(&number);
20
    assert referenced.value.value == 23;
21
    assert support::reading(&copied) == 23;
22
    unsafe {
23
        set calls += 1;
24
        return support::read() + CALLBACKS[0]() + support::value + TEXT[0] as i32 + calls;
25
    }
26
}