-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathstring.int
More file actions
58 lines (47 loc) · 1.41 KB
/
Copy pathstring.int
File metadata and controls
58 lines (47 loc) · 1.41 KB
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
target "C" {
inline function string(input: u32) -> string {
let output: string;
asprintf(&output, "%u", input);
return output;
}
inline function string(input: i32) -> string {
let output: string;
asprintf(&output, "%i", input);
return output;
}
inline function string(input: bool) -> string {
let out: string;
if input {
out = "1";
} else {
out = "0";
}
return out;
}
inline function string(input: string) -> string {
return input;
}
inline function stringInto(input: u32, output: &string) {
asprintf(output, "%u", input);
}
inline function stringInto(input: i32, output: &string) {
asprintf(output, "%i", input);
}
inline function stringInto(input: bool, output: &string) -> string {
if input {
*output = "1";
} else {
*output = "0";
}
}
inline function stringInto(input: string, output: &string) {
*output = input;
}
extern function asprintf(ptr: &string, ...) from "<stdio.h>";
// Adds source to the end of dest, returning dest.
// Dest MUST have enough space.
inline function stringAppend(dest: string, source: string) -> string {
return strcat(dest, source);
}
extern function strcat(dest: string, source: string) -> string from "<string.h>";
}