This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
native_test.c
74 lines (55 loc) · 1.62 KB
/
native_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#define aloc(T) ((T *)malloc(sizeof(T)))
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
bool Function1Bool(bool x) { return !x; }
uint8_t Function1Uint8(uint8_t x) { return x + 42; }
uint16_t Function1Uint16(uint16_t x) { return x + 42; }
uint32_t Function1Uint32(uint32_t x) { return x + 42; }
uint64_t Function1Uint64(uint64_t x) { return x + 42; }
int8_t Function1Int8(int8_t x) { return x + 42; }
int16_t Function1Int16(int16_t x) { return x + 42; }
int32_t Function1Int32(int32_t x) { return x + 42; }
int64_t Function1Int64(int64_t x) { return x + 42; }
intptr_t Function1IntPtr(intptr_t x) { return x + 42; }
uintptr_t Function1UintPtr(uintptr_t x) { return x + 42; }
float Function1Float(float x) { return x + 42.0f; }
double Function1Double(double x) { return x + 42.0; }
struct Struct1
{
int8_t a;
int32_t data[3][1][2];
};
struct Struct1 *getStruct1()
{
struct Struct1 *s = aloc(struct Struct1);
s->a = 0;
s->data[0][0][0] = 1;
s->data[0][0][1] = 2;
s->data[1][0][0] = 3;
s->data[1][0][1] = 4;
s->data[2][0][0] = 5;
s->data[2][0][1] = 6;
return s;
}
struct Struct3
{
int a;
int b;
int c;
};
struct Struct3 Function1StructReturnByValue(int a, int b, int c)
{
struct Struct3 s;
s.a = a;
s.b = b;
s.c = c;
return s;
}
int Function1StructPassByValue(struct Struct3 sum_a_b_c)
{
return sum_a_b_c.a + sum_a_b_c.b + sum_a_b_c.c;
}