mt-lang 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/index.html +4 -3
- data/lib/milk_tea/base.rb +1 -1
- data/std/asset_pack.mt +267 -0
- data/std/async/libuv_runtime.mt +539 -0
- data/std/async/mailbox.mt +191 -0
- data/std/async/runtime.mt +87 -0
- data/std/async.mt +87 -0
- data/std/base64.mt +185 -0
- data/std/behavior_tree.mt +396 -0
- data/std/binary.mt +314 -0
- data/std/binary_heap.mt +157 -0
- data/std/bitset.mt +239 -0
- data/std/box2d.mt +535 -0
- data/std/bytes.mt +46 -0
- data/std/c/box2d.mt +1254 -0
- data/std/c/cgltf.mt +647 -0
- data/std/c/cjson.mt +106 -0
- data/std/c/crypto.mt +11 -0
- data/std/c/crypto_support.h +51 -0
- data/std/c/ctype.mt +19 -0
- data/std/c/ctype_bindgen.h +29 -0
- data/std/c/curl.mt +1223 -0
- data/std/c/enet.mt +473 -0
- data/std/c/errno.mt +41 -0
- data/std/c/errno_bindgen.h +53 -0
- data/std/c/flecs.mt +2945 -0
- data/std/c/fs.linux.mt +43 -0
- data/std/c/fs.windows.mt +43 -0
- data/std/c/fs_support.h +954 -0
- data/std/c/gl.mt +2065 -0
- data/std/c/gl_registry_helpers.h +10748 -0
- data/std/c/glfw.mt +499 -0
- data/std/c/libc.mt +167 -0
- data/std/c/libuv.mt +1491 -0
- data/std/c/math.mt +22 -0
- data/std/c/math_bindgen.h +31 -0
- data/std/c/miniaudio.mt +3420 -0
- data/std/c/pcre2.mt +735 -0
- data/std/c/process.mt +58 -0
- data/std/c/process_support.h +1147 -0
- data/std/c/raygui.mt +1602 -0
- data/std/c/raylib.mt +1245 -0
- data/std/c/raymath.mt +163 -0
- data/std/c/rlgl.mt +434 -0
- data/std/c/rpng.mt +60 -0
- data/std/c/rres.mt +187 -0
- data/std/c/sdl3.mt +4132 -0
- data/std/c/sqlite3.mt +951 -0
- data/std/c/stb_image.mt +52 -0
- data/std/c/stb_image_resize2.mt +128 -0
- data/std/c/stb_image_write.mt +19 -0
- data/std/c/stb_rect_pack.mt +38 -0
- data/std/c/stb_truetype.mt +175 -0
- data/std/c/stb_vorbis.mt +31 -0
- data/std/c/stdio.mt +90 -0
- data/std/c/steamworks.h +5769 -0
- data/std/c/steamworks.mt +4771 -0
- data/std/c/string.mt +16 -0
- data/std/c/string_bindgen.h +36 -0
- data/std/c/sync.mt +33 -0
- data/std/c/sync_support.h +219 -0
- data/std/c/terminal.mt +24 -0
- data/std/c/terminal_support.h +408 -0
- data/std/c/time.mt +26 -0
- data/std/c/tls.mt +24 -0
- data/std/c/tls_support.h +626 -0
- data/std/c/tracy.mt +53 -0
- data/std/c/zlib.mt +20 -0
- data/std/c/zlib_support.h +239 -0
- data/std/c/zstd.mt +231 -0
- data/std/cell.mt +60 -0
- data/std/cgltf.mt +115 -0
- data/std/cjson.mt +90 -0
- data/std/cli.mt +768 -0
- data/std/cookie.mt +198 -0
- data/std/counter.mt +160 -0
- data/std/crypto.mt +74 -0
- data/std/cstring.mt +13 -0
- data/std/ctype.mt +52 -0
- data/std/curl/runtime.mt +261 -0
- data/std/curl.mt +38 -0
- data/std/deque.mt +348 -0
- data/std/encoding.mt +93 -0
- data/std/enet.mt +133 -0
- data/std/env.mt +41 -0
- data/std/errno.mt +47 -0
- data/std/flecs.mt +978 -0
- data/std/fmt.mt +271 -0
- data/std/fs.linux.mt +696 -0
- data/std/fs.windows.mt +711 -0
- data/std/fsm.mt +267 -0
- data/std/gl.mt +2062 -0
- data/std/glfw.mt +471 -0
- data/std/goap.mt +342 -0
- data/std/graph.mt +521 -0
- data/std/gzip.mt +77 -0
- data/std/hash.mt +429 -0
- data/std/http/server.mt +810 -0
- data/std/http.mt +1227 -0
- data/std/intern.mt +53 -0
- data/std/jobs.mt +288 -0
- data/std/json.mt +627 -0
- data/std/libc.mt +34 -0
- data/std/libuv.mt +554 -0
- data/std/linear_algebra.mt +243 -0
- data/std/linked_map.mt +372 -0
- data/std/linked_map_view.mt +49 -0
- data/std/linked_set.mt +117 -0
- data/std/log.mt +69 -0
- data/std/map.mt +418 -0
- data/std/math.mt +24 -0
- data/std/mem/arena.mt +137 -0
- data/std/mem/endian.mt +51 -0
- data/std/mem/heap.mt +298 -0
- data/std/mem/pool.mt +164 -0
- data/std/mem/stack.mt +47 -0
- data/std/mem/tracking.mt +119 -0
- data/std/miniaudio.mt +1299 -0
- data/std/multiset.mt +191 -0
- data/std/net/channel.mt +727 -0
- data/std/net/clock.mt +237 -0
- data/std/net/discovery.mt +277 -0
- data/std/net/lobby.mt +813 -0
- data/std/net/manager.mt +539 -0
- data/std/net/mux.mt +839 -0
- data/std/net/nat.mt +122 -0
- data/std/net/packet.mt +219 -0
- data/std/net/punch.mt +162 -0
- data/std/net/rpc.mt +119 -0
- data/std/net/session.mt +1157 -0
- data/std/net/stun.mt +252 -0
- data/std/net/sync.mt +183 -0
- data/std/net/turn.mt +459 -0
- data/std/net.mt +2944 -0
- data/std/oauth2.mt +408 -0
- data/std/option.mt +51 -0
- data/std/ordered_map.mt +497 -0
- data/std/ordered_set.mt +348 -0
- data/std/path.mt +368 -0
- data/std/pcre2/runtime.mt +35 -0
- data/std/pcre2.mt +78 -0
- data/std/priority_queue.mt +55 -0
- data/std/process.mt +837 -0
- data/std/queue.mt +55 -0
- data/std/random.mt +146 -0
- data/std/raygui.mt +99 -0
- data/std/raylib/debug_console.mt +71 -0
- data/std/raylib/easing.mt +388 -0
- data/std/raylib/packed_assets.mt +255 -0
- data/std/raylib/runtime.mt +30 -0
- data/std/raylib/tracy_gpu.mt +37 -0
- data/std/raylib.mt +1510 -0
- data/std/raymath.mt +153 -0
- data/std/result.mt +89 -0
- data/std/rlgl.mt +268 -0
- data/std/rpng.mt +46 -0
- data/std/rres.mt +36 -0
- data/std/sdl3/runtime.mt +54 -0
- data/std/sdl3.mt +1731 -0
- data/std/serialize.mt +68 -0
- data/std/set.mt +124 -0
- data/std/spatial.mt +176 -0
- data/std/sqlite3.mt +151 -0
- data/std/stack.mt +55 -0
- data/std/stb_image.mt +47 -0
- data/std/stb_image_resize2.mt +41 -0
- data/std/stb_image_write.mt +17 -0
- data/std/stb_rect_pack.mt +15 -0
- data/std/stb_truetype.mt +77 -0
- data/std/stb_vorbis.mt +16 -0
- data/std/stdio.mt +88 -0
- data/std/steamworks.mt +1542 -0
- data/std/str.mt +293 -0
- data/std/string.mt +234 -0
- data/std/sync.mt +194 -0
- data/std/tar.mt +704 -0
- data/std/terminal.mt +1002 -0
- data/std/testing.mt +266 -0
- data/std/thread.mt +120 -0
- data/std/time.mt +105 -0
- data/std/tls.mt +616 -0
- data/std/toml.mt +1310 -0
- data/std/tracy.mt +42 -0
- data/std/uri.mt +118 -0
- data/std/url.mt +372 -0
- data/std/vec.mt +433 -0
- data/std/zstd.mt +94 -0
- metadata +187 -2
data/std/serialize.mt
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import std.binary as bin
|
|
2
|
+
import std.bytes as bytes
|
|
3
|
+
import std.string as string
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function raw_unpack_error(message: str) -> bin.Error:
|
|
7
|
+
return bin.Error(code = -1, message = string.String.from_str(message))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
public function pack[T](v: ref[T]) -> bytes.Bytes:
|
|
11
|
+
let total = size_of(T)
|
|
12
|
+
var w = bin.Writer.with_capacity(total)
|
|
13
|
+
var src = unsafe: ptr[ubyte]<-ptr_of(v)
|
|
14
|
+
var i: ptr_uint = 0
|
|
15
|
+
while i < total:
|
|
16
|
+
w.write_ubyte(unsafe: read(src + i))
|
|
17
|
+
i += 1
|
|
18
|
+
return w.finish()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
public function unpack[T](source: span[ubyte]) -> Result[T, bin.Error]:
|
|
22
|
+
let total = size_of(T)
|
|
23
|
+
if source.len < total:
|
|
24
|
+
return Result[T, bin.Error].failure(
|
|
25
|
+
error = raw_unpack_error("source too short for target type")
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
var result = unsafe: zero[T]
|
|
29
|
+
var dest = unsafe: ptr[ubyte]<-ptr_of(result)
|
|
30
|
+
var i: ptr_uint = 0
|
|
31
|
+
while i < total:
|
|
32
|
+
unsafe: read(dest + i) = source[i]
|
|
33
|
+
i += 1
|
|
34
|
+
return Result[T, bin.Error].success(value = result)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
extending bin.Writer:
|
|
38
|
+
public editable function pack[T](v: ref[T]) -> void:
|
|
39
|
+
let total = size_of(T)
|
|
40
|
+
var src = unsafe: ptr[ubyte]<-ptr_of(v)
|
|
41
|
+
var i: ptr_uint = 0
|
|
42
|
+
while i < total:
|
|
43
|
+
this.write_ubyte(unsafe: read(src + i))
|
|
44
|
+
i += 1
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
extending bin.Reader:
|
|
48
|
+
public editable function unpack[T]() -> Result[T, bin.Error]:
|
|
49
|
+
let total = size_of(T)
|
|
50
|
+
match this.read_bytes(total):
|
|
51
|
+
Result.failure as p:
|
|
52
|
+
return Result[T, bin.Error].failure(error = p.error)
|
|
53
|
+
Result.success as bp:
|
|
54
|
+
var raw_bytes = bp.value
|
|
55
|
+
defer raw_bytes.release()
|
|
56
|
+
|
|
57
|
+
let src_ptr = raw_bytes.data else:
|
|
58
|
+
return Result[T, bin.Error].failure(
|
|
59
|
+
error = raw_unpack_error("reader returned empty data")
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
var result = unsafe: zero[T]
|
|
63
|
+
var dest = unsafe: ptr[ubyte]<-ptr_of(result)
|
|
64
|
+
var i: ptr_uint = 0
|
|
65
|
+
while i < total:
|
|
66
|
+
unsafe: read(dest + i) = read(src_ptr + i)
|
|
67
|
+
i += 1
|
|
68
|
+
return Result[T, bin.Error].success(value = result)
|
data/std/set.mt
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import std.map as map
|
|
2
|
+
|
|
3
|
+
public struct Set[T]:
|
|
4
|
+
values: map.Map[T, bool]
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
extending Set[T]:
|
|
8
|
+
public static function create() -> Set[T]:
|
|
9
|
+
return Set[T](values = map.Map[T, bool].create())
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
public static function with_capacity(capacity: ptr_uint) -> Set[T]:
|
|
13
|
+
var result = Set[T].create()
|
|
14
|
+
result.reserve(capacity)
|
|
15
|
+
return result
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
public function len() -> ptr_uint:
|
|
19
|
+
return this.values.len()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
public function capacity() -> ptr_uint:
|
|
23
|
+
return this.values.capacity()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function is_empty() -> bool:
|
|
27
|
+
return this.values.is_empty()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public function get(value: T) -> const_ptr[T]?:
|
|
31
|
+
return this.values.get_key(value)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function at(value: T) -> Option[T]:
|
|
35
|
+
let p = this.get(value) else:
|
|
36
|
+
return Option[T].none
|
|
37
|
+
|
|
38
|
+
unsafe:
|
|
39
|
+
return Option[T].some(value = read(ptr[T]<-p))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
public function contains(value: T) -> bool:
|
|
43
|
+
return this.values.contains(value)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
public function iter() -> map.Keys[T, bool]:
|
|
47
|
+
return this.values.keys()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public function is_subset(other: Set[T]) -> bool:
|
|
51
|
+
if this.len() > other.len():
|
|
52
|
+
return false
|
|
53
|
+
|
|
54
|
+
for value in this:
|
|
55
|
+
unsafe:
|
|
56
|
+
if not other.contains(read(ptr[T]<-value)):
|
|
57
|
+
return false
|
|
58
|
+
|
|
59
|
+
return true
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
public function union_with(other: Set[T]) -> Set[T]:
|
|
63
|
+
var result = Set[T].with_capacity(this.len() + other.len())
|
|
64
|
+
|
|
65
|
+
for value in this:
|
|
66
|
+
unsafe:
|
|
67
|
+
result.insert(read(ptr[T]<-value))
|
|
68
|
+
|
|
69
|
+
for value in other:
|
|
70
|
+
unsafe:
|
|
71
|
+
result.insert(read(ptr[T]<-value))
|
|
72
|
+
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
public function intersection(other: Set[T]) -> Set[T]:
|
|
77
|
+
var result = Set[T].with_capacity(this.len())
|
|
78
|
+
|
|
79
|
+
if this.len() <= other.len():
|
|
80
|
+
for value in this:
|
|
81
|
+
unsafe:
|
|
82
|
+
let current = read(ptr[T]<-value)
|
|
83
|
+
if other.contains(current):
|
|
84
|
+
result.insert(current)
|
|
85
|
+
else:
|
|
86
|
+
for value in other:
|
|
87
|
+
unsafe:
|
|
88
|
+
let current = read(ptr[T]<-value)
|
|
89
|
+
if this.contains(current):
|
|
90
|
+
result.insert(current)
|
|
91
|
+
|
|
92
|
+
return result
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
public function difference(other: Set[T]) -> Set[T]:
|
|
96
|
+
var result = Set[T].with_capacity(this.len())
|
|
97
|
+
|
|
98
|
+
for value in this:
|
|
99
|
+
unsafe:
|
|
100
|
+
let current = read(ptr[T]<-value)
|
|
101
|
+
if not other.contains(current):
|
|
102
|
+
result.insert(current)
|
|
103
|
+
|
|
104
|
+
return result
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
public editable function clear() -> void:
|
|
108
|
+
this.values.clear()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
public editable function release() -> void:
|
|
112
|
+
this.values.release()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
public editable function reserve(min_capacity: ptr_uint) -> void:
|
|
116
|
+
this.values.reserve(min_capacity)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
public editable function insert(value: T) -> bool:
|
|
120
|
+
return this.values.set(value, true).is_none()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
public editable function remove(value: T) -> bool:
|
|
124
|
+
return this.values.remove(value).is_some()
|
data/std/spatial.mt
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import std.vec as vec
|
|
2
|
+
|
|
3
|
+
public struct SpatialGrid[T]:
|
|
4
|
+
cells: vec.Vec[vec.Vec[T]]
|
|
5
|
+
cell_size: float
|
|
6
|
+
cols: uint
|
|
7
|
+
rows: uint
|
|
8
|
+
origin_x: float
|
|
9
|
+
origin_y: float
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
extending SpatialGrid[T]:
|
|
13
|
+
public editable function release() -> void:
|
|
14
|
+
var i: ptr_uint = 0
|
|
15
|
+
while i < this.cells.len():
|
|
16
|
+
let cell_ptr = this.cells.get(i) else:
|
|
17
|
+
break
|
|
18
|
+
unsafe: read(cell_ptr).release()
|
|
19
|
+
i += 1
|
|
20
|
+
this.cells.release()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function cell_index[T](grid: ref[SpatialGrid[T]], x: float, y: float) -> Option[ptr_uint]:
|
|
24
|
+
let cx = int<-(float<-((x - grid.origin_x) / grid.cell_size))
|
|
25
|
+
let cy = int<-(float<-((y - grid.origin_y) / grid.cell_size))
|
|
26
|
+
if cx < 0 or cy < 0 or uint<-cx >= grid.cols or uint<-cy >= grid.rows:
|
|
27
|
+
return Option[ptr_uint].none()
|
|
28
|
+
return Option[ptr_uint].some(value = ptr_uint<-cx + ptr_uint<-cy * ptr_uint<-grid.cols)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public function new[T](cell_size: float, width: float, height: float) -> SpatialGrid[T]:
|
|
32
|
+
var cols: uint = uint<-(float<-width / cell_size)
|
|
33
|
+
var rows: uint = uint<-(float<-height / cell_size)
|
|
34
|
+
if cols == 0:
|
|
35
|
+
cols = 1
|
|
36
|
+
if rows == 0:
|
|
37
|
+
rows = 1
|
|
38
|
+
|
|
39
|
+
var cells = vec.Vec[vec.Vec[T]].create()
|
|
40
|
+
var total: ptr_uint = ptr_uint<-cols * ptr_uint<-rows
|
|
41
|
+
var i: ptr_uint = 0
|
|
42
|
+
while i < total:
|
|
43
|
+
cells.push(vec.Vec[T].create())
|
|
44
|
+
i += 1
|
|
45
|
+
|
|
46
|
+
return SpatialGrid[T](
|
|
47
|
+
cells = cells,
|
|
48
|
+
cell_size = cell_size,
|
|
49
|
+
cols = cols,
|
|
50
|
+
rows = rows,
|
|
51
|
+
origin_x = 0.0,
|
|
52
|
+
origin_y = 0.0
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public function new_with_origin[T](
|
|
57
|
+
cell_size: float,
|
|
58
|
+
width: float,
|
|
59
|
+
height: float,
|
|
60
|
+
origin_x: float,
|
|
61
|
+
origin_y: float
|
|
62
|
+
) -> SpatialGrid[T]:
|
|
63
|
+
var grid = new[T](cell_size, width, height)
|
|
64
|
+
grid.origin_x = origin_x
|
|
65
|
+
grid.origin_y = origin_y
|
|
66
|
+
return grid
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
extending SpatialGrid[T]:
|
|
70
|
+
public editable function insert(entity: T, x: float, y: float) -> void:
|
|
71
|
+
let idx_opt = cell_index(ref_of(this), x, y)
|
|
72
|
+
match idx_opt:
|
|
73
|
+
Option.some as ip:
|
|
74
|
+
let cell_ptr = this.cells.get(ip.value) else:
|
|
75
|
+
return
|
|
76
|
+
unsafe: read(cell_ptr).push(entity)
|
|
77
|
+
Option.none:
|
|
78
|
+
return
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
public editable function insert_many(items: span[T], xs: span[float], ys: span[float]) -> void:
|
|
82
|
+
var i: ptr_uint = 0
|
|
83
|
+
let count = items.len
|
|
84
|
+
while i < count:
|
|
85
|
+
this.insert(items[i], xs[i], ys[i])
|
|
86
|
+
i += 1
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
public editable function query_radius(x: float, y: float, radius: float) -> vec.Vec[T]:
|
|
90
|
+
var result = vec.Vec[T].create()
|
|
91
|
+
let min_x = x - radius
|
|
92
|
+
let min_y = y - radius
|
|
93
|
+
let max_x = x + radius
|
|
94
|
+
let max_y = y + radius
|
|
95
|
+
|
|
96
|
+
let min_idx = cell_index(ref_of(this), min_x, min_y)
|
|
97
|
+
let max_idx = cell_index(ref_of(this), max_x, max_y)
|
|
98
|
+
|
|
99
|
+
var start_col: ptr_uint = 0
|
|
100
|
+
var end_col: ptr_uint = ptr_uint<-this.cols
|
|
101
|
+
var start_row: ptr_uint = 0
|
|
102
|
+
var end_row: ptr_uint = ptr_uint<-this.rows
|
|
103
|
+
|
|
104
|
+
match min_idx:
|
|
105
|
+
Option.some as mp:
|
|
106
|
+
start_col = mp.value % ptr_uint<-this.cols
|
|
107
|
+
start_row = mp.value / ptr_uint<-this.cols
|
|
108
|
+
Option.none:
|
|
109
|
+
return result
|
|
110
|
+
|
|
111
|
+
match max_idx:
|
|
112
|
+
Option.some as mp:
|
|
113
|
+
let ec = mp.value % ptr_uint<-this.cols
|
|
114
|
+
let er = mp.value / ptr_uint<-this.cols
|
|
115
|
+
if ec + 1z < end_col:
|
|
116
|
+
end_col = ec + 1z
|
|
117
|
+
if er + 1z < end_row:
|
|
118
|
+
end_row = er + 1z
|
|
119
|
+
Option.none:
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
var cy: ptr_uint = start_row
|
|
123
|
+
while cy < end_row:
|
|
124
|
+
var cx: ptr_uint = start_col
|
|
125
|
+
while cx < end_col:
|
|
126
|
+
let idx = cx + cy * ptr_uint<-this.cols
|
|
127
|
+
let cell_ptr = this.cells.get(idx) else:
|
|
128
|
+
cx += 1
|
|
129
|
+
continue
|
|
130
|
+
var cell = unsafe: read(cell_ptr)
|
|
131
|
+
var k: ptr_uint = 0
|
|
132
|
+
while k < cell.len():
|
|
133
|
+
let item_ptr = cell.get(k) else:
|
|
134
|
+
break
|
|
135
|
+
result.push(unsafe: read(item_ptr))
|
|
136
|
+
k += 1
|
|
137
|
+
cx += 1
|
|
138
|
+
cy += 1
|
|
139
|
+
|
|
140
|
+
return result
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
public editable function clear() -> void:
|
|
144
|
+
var i: ptr_uint = 0
|
|
145
|
+
while i < this.cells.len():
|
|
146
|
+
let cell_ptr = this.cells.get(i) else:
|
|
147
|
+
break
|
|
148
|
+
unsafe: read(cell_ptr).clear()
|
|
149
|
+
i += 1
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
public function cell_count() -> ptr_uint:
|
|
153
|
+
return ptr_uint<-this.cols * ptr_uint<-this.rows
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
public function occupied_cells() -> uint:
|
|
157
|
+
var count: ptr_uint = 0
|
|
158
|
+
var i: ptr_uint = 0
|
|
159
|
+
while i < this.cells.len():
|
|
160
|
+
let cell_ptr = this.cells.get(i) else:
|
|
161
|
+
break
|
|
162
|
+
if not unsafe: read(cell_ptr).is_empty():
|
|
163
|
+
count += 1
|
|
164
|
+
i += 1
|
|
165
|
+
return uint<-count
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
public function entity_count() -> ptr_uint:
|
|
169
|
+
var total: ptr_uint = 0
|
|
170
|
+
var i: ptr_uint = 0
|
|
171
|
+
while i < this.cells.len():
|
|
172
|
+
let cell_ptr = this.cells.get(i) else:
|
|
173
|
+
break
|
|
174
|
+
total += unsafe: read(cell_ptr).len()
|
|
175
|
+
i += 1
|
|
176
|
+
return total
|
data/std/sqlite3.mt
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# generated by mtc imported-bindings from std.c.sqlite3 using bindings/imported/sqlite3.binding.json
|
|
2
|
+
|
|
3
|
+
import std.c.sqlite3 as c
|
|
4
|
+
|
|
5
|
+
public type sqlite3_index_constraint = c.sqlite3_index_constraint
|
|
6
|
+
public type sqlite3_index_orderby = c.sqlite3_index_orderby
|
|
7
|
+
public type sqlite3_index_constraint_usage = c.sqlite3_index_constraint_usage
|
|
8
|
+
public type sqlite3 = c.sqlite3
|
|
9
|
+
public type sqlite3_int64 = c.sqlite3_int64
|
|
10
|
+
public type sqlite3_uint64 = c.sqlite3_uint64
|
|
11
|
+
public type sqlite3_file = c.sqlite3_file
|
|
12
|
+
public type sqlite3_io_methods = c.sqlite3_io_methods
|
|
13
|
+
public type sqlite3_vfs = c.sqlite3_vfs
|
|
14
|
+
public type sqlite3_stmt = c.sqlite3_stmt
|
|
15
|
+
public type sqlite3_value = c.sqlite3_value
|
|
16
|
+
public type sqlite3_context = c.sqlite3_context
|
|
17
|
+
public type sqlite3_module = c.sqlite3_module
|
|
18
|
+
public type sqlite3_index_info = c.sqlite3_index_info
|
|
19
|
+
public type sqlite3_vtab = c.sqlite3_vtab
|
|
20
|
+
public type sqlite3_vtab_cursor = c.sqlite3_vtab_cursor
|
|
21
|
+
public type sqlite3_blob = c.sqlite3_blob
|
|
22
|
+
public type sqlite3_backup = c.sqlite3_backup
|
|
23
|
+
|
|
24
|
+
public const OK: int = c.SQLITE_OK
|
|
25
|
+
public const ERROR: int = c.SQLITE_ERROR
|
|
26
|
+
public const INTERNAL: int = c.SQLITE_INTERNAL
|
|
27
|
+
public const PERM: int = c.SQLITE_PERM
|
|
28
|
+
public const ABORT: int = c.SQLITE_ABORT
|
|
29
|
+
public const BUSY: int = c.SQLITE_BUSY
|
|
30
|
+
public const LOCKED: int = c.SQLITE_LOCKED
|
|
31
|
+
public const NOMEM: int = c.SQLITE_NOMEM
|
|
32
|
+
public const READONLY: int = c.SQLITE_READONLY
|
|
33
|
+
public const INTERRUPT: int = c.SQLITE_INTERRUPT
|
|
34
|
+
public const IOERR: int = c.SQLITE_IOERR
|
|
35
|
+
public const CORRUPT: int = c.SQLITE_CORRUPT
|
|
36
|
+
public const NOTFOUND: int = c.SQLITE_NOTFOUND
|
|
37
|
+
public const FULL: int = c.SQLITE_FULL
|
|
38
|
+
public const CANTOPEN: int = c.SQLITE_CANTOPEN
|
|
39
|
+
public const PROTOCOL: int = c.SQLITE_PROTOCOL
|
|
40
|
+
public const EMPTY: int = c.SQLITE_EMPTY
|
|
41
|
+
public const SCHEMA: int = c.SQLITE_SCHEMA
|
|
42
|
+
public const TOOBIG: int = c.SQLITE_TOOBIG
|
|
43
|
+
public const CONSTRAINT: int = c.SQLITE_CONSTRAINT
|
|
44
|
+
public const MISMATCH: int = c.SQLITE_MISMATCH
|
|
45
|
+
public const MISUSE: int = c.SQLITE_MISUSE
|
|
46
|
+
public const NOLFS: int = c.SQLITE_NOLFS
|
|
47
|
+
public const AUTH: int = c.SQLITE_AUTH
|
|
48
|
+
public const FORMAT: int = c.SQLITE_FORMAT
|
|
49
|
+
public const RANGE: int = c.SQLITE_RANGE
|
|
50
|
+
public const NOTADB: int = c.SQLITE_NOTADB
|
|
51
|
+
public const NOTICE: int = c.SQLITE_NOTICE
|
|
52
|
+
public const WARNING: int = c.SQLITE_WARNING
|
|
53
|
+
public const ROW: int = c.SQLITE_ROW
|
|
54
|
+
public const DONE: int = c.SQLITE_DONE
|
|
55
|
+
public const OPEN_READONLY: int = c.SQLITE_OPEN_READONLY
|
|
56
|
+
public const OPEN_READWRITE: int = c.SQLITE_OPEN_READWRITE
|
|
57
|
+
public const OPEN_CREATE: int = c.SQLITE_OPEN_CREATE
|
|
58
|
+
public const OPEN_URI: int = c.SQLITE_OPEN_URI
|
|
59
|
+
public const OPEN_MEMORY: int = c.SQLITE_OPEN_MEMORY
|
|
60
|
+
public const INTEGER: int = c.SQLITE_INTEGER
|
|
61
|
+
public const FLOAT: int = c.SQLITE_FLOAT
|
|
62
|
+
public const BLOB: int = c.SQLITE_BLOB
|
|
63
|
+
public const NULL: int = c.SQLITE_NULL
|
|
64
|
+
public const TEXT: int = c.SQLITE_TEXT
|
|
65
|
+
public const UTF8: int = c.SQLITE_UTF8
|
|
66
|
+
public const UTF16LE: int = c.SQLITE_UTF16LE
|
|
67
|
+
public const UTF16BE: int = c.SQLITE_UTF16BE
|
|
68
|
+
public const UTF16: int = c.SQLITE_UTF16
|
|
69
|
+
public const ANY: int = c.SQLITE_ANY
|
|
70
|
+
public const DETERMINISTIC: int = c.SQLITE_DETERMINISTIC
|
|
71
|
+
public const DIRECTONLY: int = c.SQLITE_DIRECTONLY
|
|
72
|
+
public const SUBTYPE: int = c.SQLITE_SUBTYPE
|
|
73
|
+
public const INNOCUOUS: int = c.SQLITE_INNOCUOUS
|
|
74
|
+
public const RESULT_SUBTYPE: int = c.SQLITE_RESULT_SUBTYPE
|
|
75
|
+
public const SELFORDER1: int = c.SQLITE_SELFORDER1
|
|
76
|
+
public const INDEX_CONSTRAINT_EQ: int = c.SQLITE_INDEX_CONSTRAINT_EQ
|
|
77
|
+
public const INDEX_CONSTRAINT_GT: int = c.SQLITE_INDEX_CONSTRAINT_GT
|
|
78
|
+
public const INDEX_CONSTRAINT_LE: int = c.SQLITE_INDEX_CONSTRAINT_LE
|
|
79
|
+
public const INDEX_CONSTRAINT_LT: int = c.SQLITE_INDEX_CONSTRAINT_LT
|
|
80
|
+
public const INDEX_CONSTRAINT_GE: int = c.SQLITE_INDEX_CONSTRAINT_GE
|
|
81
|
+
public const INDEX_CONSTRAINT_MATCH: int = c.SQLITE_INDEX_CONSTRAINT_MATCH
|
|
82
|
+
public const INDEX_CONSTRAINT_LIKE: int = c.SQLITE_INDEX_CONSTRAINT_LIKE
|
|
83
|
+
public const INDEX_CONSTRAINT_GLOB: int = c.SQLITE_INDEX_CONSTRAINT_GLOB
|
|
84
|
+
public const INDEX_CONSTRAINT_REGEXP: int = c.SQLITE_INDEX_CONSTRAINT_REGEXP
|
|
85
|
+
public const INDEX_CONSTRAINT_NE: int = c.SQLITE_INDEX_CONSTRAINT_NE
|
|
86
|
+
public const INDEX_CONSTRAINT_ISNOT: int = c.SQLITE_INDEX_CONSTRAINT_ISNOT
|
|
87
|
+
public const INDEX_CONSTRAINT_ISNOTNULL: int = c.SQLITE_INDEX_CONSTRAINT_ISNOTNULL
|
|
88
|
+
public const INDEX_CONSTRAINT_ISNULL: int = c.SQLITE_INDEX_CONSTRAINT_ISNULL
|
|
89
|
+
public const INDEX_CONSTRAINT_IS: int = c.SQLITE_INDEX_CONSTRAINT_IS
|
|
90
|
+
public const INDEX_CONSTRAINT_LIMIT: int = c.SQLITE_INDEX_CONSTRAINT_LIMIT
|
|
91
|
+
public const INDEX_CONSTRAINT_OFFSET: int = c.SQLITE_INDEX_CONSTRAINT_OFFSET
|
|
92
|
+
public const INDEX_CONSTRAINT_FUNCTION: int = c.SQLITE_INDEX_CONSTRAINT_FUNCTION
|
|
93
|
+
public const VTAB_CONSTRAINT_SUPPORT: int = c.SQLITE_VTAB_CONSTRAINT_SUPPORT
|
|
94
|
+
public const VTAB_INNOCUOUS: int = c.SQLITE_VTAB_INNOCUOUS
|
|
95
|
+
public const VTAB_DIRECTONLY: int = c.SQLITE_VTAB_DIRECTONLY
|
|
96
|
+
public const VTAB_USES_ALL_SCHEMAS: int = c.SQLITE_VTAB_USES_ALL_SCHEMAS
|
|
97
|
+
|
|
98
|
+
public foreign function libversion() -> cstr = c.sqlite3_libversion
|
|
99
|
+
public foreign function sourceid() -> cstr = c.sqlite3_sourceid
|
|
100
|
+
public foreign function libversion_number() -> int = c.sqlite3_libversion_number
|
|
101
|
+
public foreign function close(arg0: ptr[sqlite3]) -> int = c.sqlite3_close
|
|
102
|
+
public foreign function close_v2(arg0: ptr[sqlite3]) -> int = c.sqlite3_close_v2
|
|
103
|
+
public foreign function exec(arg0: ptr[sqlite3], sql: str as cstr, callback: fn(arg0: ptr[void], arg1: int, arg2: ptr[ptr[char]], arg3: ptr[ptr[char]]) -> int, arg3: ptr[void], errmsg: ptr[ptr[char]]) -> int = c.sqlite3_exec
|
|
104
|
+
public foreign function last_insert_rowid(arg0: ptr[sqlite3]) -> sqlite3_int64 = c.sqlite3_last_insert_rowid
|
|
105
|
+
public foreign function changes(arg0: ptr[sqlite3]) -> int = c.sqlite3_changes
|
|
106
|
+
public foreign function busy_timeout(arg0: ptr[sqlite3], ms: int) -> int = c.sqlite3_busy_timeout
|
|
107
|
+
public foreign function free(arg0: ptr[void]) -> void = c.sqlite3_free
|
|
108
|
+
public foreign function open(filename: str as cstr, pp_db: ptr[ptr[sqlite3]]) -> int = c.sqlite3_open
|
|
109
|
+
public foreign function open_v2(filename: str as cstr, pp_db: ptr[ptr[sqlite3]], flags_: int, z_vfs: str as cstr) -> int = c.sqlite3_open_v2
|
|
110
|
+
public foreign function errcode(db: ptr[sqlite3]) -> int = c.sqlite3_errcode
|
|
111
|
+
public foreign function extended_errcode(db: ptr[sqlite3]) -> int = c.sqlite3_extended_errcode
|
|
112
|
+
public foreign function errmsg(arg0: ptr[sqlite3]) -> cstr = c.sqlite3_errmsg
|
|
113
|
+
public foreign function errstr(arg0: int) -> cstr = c.sqlite3_errstr
|
|
114
|
+
public foreign function prepare_v2(db: ptr[sqlite3], z_sql: str as cstr, n_byte: int, pp_stmt: ptr[ptr[sqlite3_stmt]], pz_tail: ptr[cstr]) -> int = c.sqlite3_prepare_v2
|
|
115
|
+
public foreign function bind_blob(arg0: ptr[sqlite3_stmt], arg1: int, arg2: const_ptr[void], n: int, arg4: fn(arg0: ptr[void]) -> void) -> int = c.sqlite3_bind_blob
|
|
116
|
+
public foreign function bind_double(arg0: ptr[sqlite3_stmt], arg1: int, arg2: double) -> int = c.sqlite3_bind_double
|
|
117
|
+
public foreign function bind_int(arg0: ptr[sqlite3_stmt], arg1: int, arg2: int) -> int = c.sqlite3_bind_int
|
|
118
|
+
public foreign function bind_int64(arg0: ptr[sqlite3_stmt], arg1: int, arg2: long) -> int = c.sqlite3_bind_int64
|
|
119
|
+
public foreign function bind_null(arg0: ptr[sqlite3_stmt], arg1: int) -> int = c.sqlite3_bind_null
|
|
120
|
+
public foreign function bind_text(arg0: ptr[sqlite3_stmt], arg1: int, arg2: str as cstr, arg3: int, arg4: fn(arg0: ptr[void]) -> void) -> int = c.sqlite3_bind_text
|
|
121
|
+
public foreign function bind_parameter_count(arg0: ptr[sqlite3_stmt]) -> int = c.sqlite3_bind_parameter_count
|
|
122
|
+
public foreign function bind_parameter_index(arg0: ptr[sqlite3_stmt], z_name: str as cstr) -> int = c.sqlite3_bind_parameter_index
|
|
123
|
+
public foreign function clear_bindings(arg0: ptr[sqlite3_stmt]) -> int = c.sqlite3_clear_bindings
|
|
124
|
+
public foreign function column_count(p_stmt: ptr[sqlite3_stmt]) -> int = c.sqlite3_column_count
|
|
125
|
+
public foreign function column_name(arg0: ptr[sqlite3_stmt], n: int) -> cstr = c.sqlite3_column_name
|
|
126
|
+
public foreign function step(arg0: ptr[sqlite3_stmt]) -> int = c.sqlite3_step
|
|
127
|
+
public foreign function column_blob(arg0: ptr[sqlite3_stmt], i_col: int) -> const_ptr[void] = c.sqlite3_column_blob
|
|
128
|
+
public foreign function column_double(arg0: ptr[sqlite3_stmt], i_col: int) -> double = c.sqlite3_column_double
|
|
129
|
+
public foreign function column_int(arg0: ptr[sqlite3_stmt], i_col: int) -> int = c.sqlite3_column_int
|
|
130
|
+
public foreign function column_int64(arg0: ptr[sqlite3_stmt], i_col: int) -> sqlite3_int64 = c.sqlite3_column_int64
|
|
131
|
+
public foreign function column_text(arg0: ptr[sqlite3_stmt], i_col: int) -> const_ptr[ubyte] = c.sqlite3_column_text
|
|
132
|
+
public foreign function column_bytes(arg0: ptr[sqlite3_stmt], i_col: int) -> int = c.sqlite3_column_bytes
|
|
133
|
+
public foreign function column_type(arg0: ptr[sqlite3_stmt], i_col: int) -> int = c.sqlite3_column_type
|
|
134
|
+
public foreign function finalize(p_stmt: ptr[sqlite3_stmt]) -> int = c.sqlite3_finalize
|
|
135
|
+
public foreign function reset(p_stmt: ptr[sqlite3_stmt]) -> int = c.sqlite3_reset
|
|
136
|
+
public foreign function create_module(db: ptr[sqlite3], z_name: str as cstr, p: const_ptr[sqlite3_module], p_client_data: ptr[void]) -> int = c.sqlite3_create_module
|
|
137
|
+
public foreign function create_module_v2(db: ptr[sqlite3], z_name: str as cstr, p: const_ptr[sqlite3_module], p_client_data: ptr[void], x_destroy: fn(arg0: ptr[void]) -> void) -> int = c.sqlite3_create_module_v2
|
|
138
|
+
public foreign function drop_modules(db: ptr[sqlite3], az_keep: ptr[cstr]) -> int = c.sqlite3_drop_modules
|
|
139
|
+
public foreign function declare_vtab(arg0: ptr[sqlite3], z_sql: str as cstr) -> int = c.sqlite3_declare_vtab
|
|
140
|
+
public foreign function overload_function(arg0: ptr[sqlite3], z_func_name: str as cstr, n_arg: int) -> int = c.sqlite3_overload_function
|
|
141
|
+
public foreign function vfs_find(z_vfs_name: str as cstr) -> ptr[sqlite3_vfs] = c.sqlite3_vfs_find
|
|
142
|
+
public foreign function vfs_register(arg0: ptr[sqlite3_vfs], make_dflt: int) -> int = c.sqlite3_vfs_register
|
|
143
|
+
public foreign function vfs_unregister(arg0: ptr[sqlite3_vfs]) -> int = c.sqlite3_vfs_unregister
|
|
144
|
+
public foreign function vtab_on_conflict(arg0: ptr[sqlite3]) -> int = c.sqlite3_vtab_on_conflict
|
|
145
|
+
public foreign function vtab_nochange(arg0: ptr[sqlite3_context]) -> int = c.sqlite3_vtab_nochange
|
|
146
|
+
public foreign function vtab_collation(arg0: ptr[sqlite3_index_info], arg1: int) -> cstr = c.sqlite3_vtab_collation
|
|
147
|
+
public foreign function vtab_distinct(arg0: ptr[sqlite3_index_info]) -> int = c.sqlite3_vtab_distinct
|
|
148
|
+
public foreign function vtab_in(arg0: ptr[sqlite3_index_info], i_cons: int, b_handle: int) -> int = c.sqlite3_vtab_in
|
|
149
|
+
public foreign function vtab_in_first(p_val: ptr[sqlite3_value], pp_out: ptr[ptr[sqlite3_value]]) -> int = c.sqlite3_vtab_in_first
|
|
150
|
+
public foreign function vtab_in_next(p_val: ptr[sqlite3_value], pp_out: ptr[ptr[sqlite3_value]]) -> int = c.sqlite3_vtab_in_next
|
|
151
|
+
public foreign function vtab_rhs_value(arg0: ptr[sqlite3_index_info], arg1: int, pp_val: ptr[ptr[sqlite3_value]]) -> int = c.sqlite3_vtab_rhs_value
|
data/std/stack.mt
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import std.deque as deque
|
|
2
|
+
|
|
3
|
+
public struct Stack[T]:
|
|
4
|
+
values: deque.Deque[T]
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
extending Stack[T]:
|
|
8
|
+
public static function create() -> Stack[T]:
|
|
9
|
+
return Stack[T](values = deque.Deque[T].create())
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
public static function with_capacity(capacity: ptr_uint) -> Stack[T]:
|
|
13
|
+
var result = Stack[T].create()
|
|
14
|
+
result.reserve(capacity)
|
|
15
|
+
return result
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
public function len() -> ptr_uint:
|
|
19
|
+
return this.values.len()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
public function capacity() -> ptr_uint:
|
|
23
|
+
return this.values.capacity()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
public function is_empty() -> bool:
|
|
27
|
+
return this.values.is_empty()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public function iter() -> deque.Iter[T]:
|
|
31
|
+
return this.values.iter()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function peek() -> ptr[T]?:
|
|
35
|
+
return this.values.last()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
public editable function clear() -> void:
|
|
39
|
+
this.values.clear()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
public editable function release() -> void:
|
|
43
|
+
this.values.release()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
public editable function reserve(min_capacity: ptr_uint) -> void:
|
|
47
|
+
this.values.reserve(min_capacity)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public editable function push(value: T) -> void:
|
|
51
|
+
this.values.push_back(value)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
public editable function pop() -> Option[T]:
|
|
55
|
+
return this.values.pop_back()
|
data/std/stb_image.mt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# generated by mtc imported-bindings from std.c.stb_image using bindings/imported/stb_image.binding.json
|
|
2
|
+
|
|
3
|
+
import std.c.stb_image as c
|
|
4
|
+
|
|
5
|
+
public type uc = c.stbi_uc
|
|
6
|
+
public type us = c.stbi_us
|
|
7
|
+
public type io_callbacks = c.stbi_io_callbacks
|
|
8
|
+
|
|
9
|
+
public const VERSION: int = c.STBI_VERSION
|
|
10
|
+
|
|
11
|
+
public foreign function load_from_memory(buffer: const_ptr[uc], len: int, x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[uc]? = c.stbi_load_from_memory
|
|
12
|
+
public foreign function load_from_callbacks(clbk: const_ptr[io_callbacks], user: ptr[void], x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[uc]? = c.stbi_load_from_callbacks
|
|
13
|
+
public foreign function load(filename: cstr, x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[uc]? = c.stbi_load
|
|
14
|
+
public foreign function load_gif_from_memory(buffer: const_ptr[uc], len: int, delays: ptr[ptr[int]], x: ptr[int], y: ptr[int], z: ptr[int], comp: ptr[int], req_comp: int) -> ptr[uc]? = c.stbi_load_gif_from_memory
|
|
15
|
+
public foreign function load_16_from_memory(buffer: const_ptr[uc], len: int, x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[us]? = c.stbi_load_16_from_memory
|
|
16
|
+
public foreign function load_16_from_callbacks(clbk: const_ptr[io_callbacks], user: ptr[void], x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[us]? = c.stbi_load_16_from_callbacks
|
|
17
|
+
public foreign function load_16(filename: cstr, x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[us]? = c.stbi_load_16
|
|
18
|
+
public foreign function loadf_from_memory(buffer: const_ptr[uc], len: int, x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[float]? = c.stbi_loadf_from_memory
|
|
19
|
+
public foreign function loadf_from_callbacks(clbk: const_ptr[io_callbacks], user: ptr[void], x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[float]? = c.stbi_loadf_from_callbacks
|
|
20
|
+
public foreign function loadf(filename: cstr, x: ptr[int], y: ptr[int], channels_in_file: ptr[int], desired_channels: int) -> ptr[float]? = c.stbi_loadf
|
|
21
|
+
public foreign function hdr_to_ldr_gamma(gamma: float) -> void = c.stbi_hdr_to_ldr_gamma
|
|
22
|
+
public foreign function hdr_to_ldr_scale(scale: float) -> void = c.stbi_hdr_to_ldr_scale
|
|
23
|
+
public foreign function ldr_to_hdr_gamma(gamma: float) -> void = c.stbi_ldr_to_hdr_gamma
|
|
24
|
+
public foreign function ldr_to_hdr_scale(scale: float) -> void = c.stbi_ldr_to_hdr_scale
|
|
25
|
+
public foreign function is_hdr_from_callbacks(clbk: const_ptr[io_callbacks], user: ptr[void]) -> int = c.stbi_is_hdr_from_callbacks
|
|
26
|
+
public foreign function is_hdr_from_memory(buffer: const_ptr[uc], len: int) -> int = c.stbi_is_hdr_from_memory
|
|
27
|
+
public foreign function is_hdr(filename: str as cstr) -> int = c.stbi_is_hdr
|
|
28
|
+
public foreign function failure_reason() -> cstr? = c.stbi_failure_reason
|
|
29
|
+
public foreign function image_free(retval_from_stbi_load: ptr[void]) -> void = c.stbi_image_free
|
|
30
|
+
public foreign function info_from_memory(buffer: const_ptr[uc], len: int, x: ptr[int], y: ptr[int], comp: ptr[int]) -> int = c.stbi_info_from_memory
|
|
31
|
+
public foreign function info_from_callbacks(clbk: const_ptr[io_callbacks], user: ptr[void], x: ptr[int], y: ptr[int], comp: ptr[int]) -> int = c.stbi_info_from_callbacks
|
|
32
|
+
public foreign function is_16_bit_from_memory(buffer: const_ptr[uc], len: int) -> int = c.stbi_is_16_bit_from_memory
|
|
33
|
+
public foreign function is_16_bit_from_callbacks(clbk: const_ptr[io_callbacks], user: ptr[void]) -> int = c.stbi_is_16_bit_from_callbacks
|
|
34
|
+
public foreign function info(filename: str as cstr, x: ptr[int], y: ptr[int], comp: ptr[int]) -> int = c.stbi_info
|
|
35
|
+
public foreign function is_16_bit(filename: str as cstr) -> int = c.stbi_is_16_bit
|
|
36
|
+
public foreign function set_unpremultiply_on_load(flag_true_if_should_unpremultiply: int) -> void = c.stbi_set_unpremultiply_on_load
|
|
37
|
+
public foreign function convert_iphone_png_to_rgb(flag_true_if_should_convert: int) -> void = c.stbi_convert_iphone_png_to_rgb
|
|
38
|
+
public foreign function set_flip_vertically_on_load(flag_true_if_should_flip: int) -> void = c.stbi_set_flip_vertically_on_load
|
|
39
|
+
public foreign function set_unpremultiply_on_load_thread(flag_true_if_should_unpremultiply: int) -> void = c.stbi_set_unpremultiply_on_load_thread
|
|
40
|
+
public foreign function convert_iphone_png_to_rgb_thread(flag_true_if_should_convert: int) -> void = c.stbi_convert_iphone_png_to_rgb_thread
|
|
41
|
+
public foreign function set_flip_vertically_on_load_thread(flag_true_if_should_flip: int) -> void = c.stbi_set_flip_vertically_on_load_thread
|
|
42
|
+
public foreign function zlib_decode_malloc_guesssize(buffer: cstr, len: int, initial_size: int, outlen: ptr[int]) -> ptr[char]? = c.stbi_zlib_decode_malloc_guesssize
|
|
43
|
+
public foreign function zlib_decode_malloc_guesssize_headerflag(buffer: cstr, len: int, initial_size: int, outlen: ptr[int], parse_header: int) -> ptr[char]? = c.stbi_zlib_decode_malloc_guesssize_headerflag
|
|
44
|
+
public foreign function zlib_decode_malloc(buffer: cstr, len: int, outlen: ptr[int]) -> ptr[char]? = c.stbi_zlib_decode_malloc
|
|
45
|
+
public foreign function zlib_decode_buffer(obuffer: ptr[char], olen: int, ibuffer: str as cstr, ilen: int) -> int = c.stbi_zlib_decode_buffer
|
|
46
|
+
public foreign function zlib_decode_noheader_malloc(buffer: cstr, len: int, outlen: ptr[int]) -> ptr[char]? = c.stbi_zlib_decode_noheader_malloc
|
|
47
|
+
public foreign function zlib_decode_noheader_buffer(obuffer: ptr[char], olen: int, ibuffer: str as cstr, ilen: int) -> int = c.stbi_zlib_decode_noheader_buffer
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# generated by mtc imported-bindings from std.c.stb_image_resize2 using bindings/imported/stb_image_resize2.binding.json
|
|
2
|
+
|
|
3
|
+
import std.c.stb_image_resize2 as c
|
|
4
|
+
|
|
5
|
+
public type uint8 = c.stbir_uint8
|
|
6
|
+
public type uint16 = c.stbir_uint16
|
|
7
|
+
public type uint32 = c.stbir_uint32
|
|
8
|
+
public type uint64 = c.stbir_uint64
|
|
9
|
+
public type pixel_layout = c.stbir_pixel_layout
|
|
10
|
+
public type edge = c.stbir_edge
|
|
11
|
+
public type filter = c.stbir_filter
|
|
12
|
+
public type datatype = c.stbir_datatype
|
|
13
|
+
public type input_callback = c.stbir_input_callback
|
|
14
|
+
public type output_callback = c.stbir_output_callback
|
|
15
|
+
public type _kernel_callback = c.stbir__kernel_callback
|
|
16
|
+
public type _support_callback = c.stbir__support_callback
|
|
17
|
+
public type _info = c.stbir__info
|
|
18
|
+
public type STBIR_RESIZE = c.STBIR_RESIZE
|
|
19
|
+
|
|
20
|
+
public foreign function resize_uint8_srgb(input_pixels: const_ptr[ubyte], input_w: int, input_h: int, input_stride_in_bytes: int, output_pixels: ptr[ubyte], output_w: int, output_h: int, output_stride_in_bytes: int, pixel_type: pixel_layout) -> ptr[ubyte] = c.stbir_resize_uint8_srgb
|
|
21
|
+
public foreign function resize_uint8_linear(input_pixels: const_ptr[ubyte], input_w: int, input_h: int, input_stride_in_bytes: int, output_pixels: ptr[ubyte], output_w: int, output_h: int, output_stride_in_bytes: int, pixel_type: pixel_layout) -> ptr[ubyte] = c.stbir_resize_uint8_linear
|
|
22
|
+
public foreign function resize_float_linear(input_pixels: const_ptr[float], input_w: int, input_h: int, input_stride_in_bytes: int, output_pixels: ptr[float], output_w: int, output_h: int, output_stride_in_bytes: int, pixel_type: pixel_layout) -> ptr[float] = c.stbir_resize_float_linear
|
|
23
|
+
public foreign function resize(input_pixels: const_ptr[void], input_w: int, input_h: int, input_stride_in_bytes: int, output_pixels: ptr[void], output_w: int, output_h: int, output_stride_in_bytes: int, pixel_layout: pixel_layout, data_type: datatype, edge: edge, filter: filter) -> ptr[void] = c.stbir_resize
|
|
24
|
+
public foreign function resize_init(resize: ptr[STBIR_RESIZE], input_pixels: const_ptr[void], input_w: int, input_h: int, input_stride_in_bytes: int, output_pixels: ptr[void], output_w: int, output_h: int, output_stride_in_bytes: int, pixel_layout: pixel_layout, data_type: datatype) -> void = c.stbir_resize_init
|
|
25
|
+
public foreign function set_datatypes(resize: ptr[STBIR_RESIZE], input_type: datatype, output_type: datatype) -> void = c.stbir_set_datatypes
|
|
26
|
+
public foreign function set_pixel_callbacks(resize: ptr[STBIR_RESIZE], input_cb: ptr[input_callback], output_cb: ptr[output_callback]) -> void = c.stbir_set_pixel_callbacks
|
|
27
|
+
public foreign function set_user_data(resize: ptr[STBIR_RESIZE], user_data: ptr[void]) -> void = c.stbir_set_user_data
|
|
28
|
+
public foreign function set_buffer_ptrs(resize: ptr[STBIR_RESIZE], input_pixels: const_ptr[void], input_stride_in_bytes: int, output_pixels: ptr[void], output_stride_in_bytes: int) -> void = c.stbir_set_buffer_ptrs
|
|
29
|
+
public foreign function set_pixel_layouts(resize: ptr[STBIR_RESIZE], input_pixel_layout: pixel_layout, output_pixel_layout: pixel_layout) -> int = c.stbir_set_pixel_layouts
|
|
30
|
+
public foreign function set_edgemodes(resize: ptr[STBIR_RESIZE], horizontal_edge: edge, vertical_edge: edge) -> int = c.stbir_set_edgemodes
|
|
31
|
+
public foreign function set_filters(resize: ptr[STBIR_RESIZE], horizontal_filter: filter, vertical_filter: filter) -> int = c.stbir_set_filters
|
|
32
|
+
public foreign function set_filter_callbacks(resize: ptr[STBIR_RESIZE], horizontal_filter: ptr[_kernel_callback], horizontal_support: ptr[_support_callback], vertical_filter: ptr[_kernel_callback], vertical_support: ptr[_support_callback]) -> int = c.stbir_set_filter_callbacks
|
|
33
|
+
public foreign function set_pixel_subrect(resize: ptr[STBIR_RESIZE], subx: int, suby: int, subw: int, subh: int) -> int = c.stbir_set_pixel_subrect
|
|
34
|
+
public foreign function set_input_subrect(resize: ptr[STBIR_RESIZE], s0: double, t0: double, s1: double, t1: double) -> int = c.stbir_set_input_subrect
|
|
35
|
+
public foreign function set_output_pixel_subrect(resize: ptr[STBIR_RESIZE], subx: int, suby: int, subw: int, subh: int) -> int = c.stbir_set_output_pixel_subrect
|
|
36
|
+
public foreign function set_non_pm_alpha_speed_over_quality(resize: ptr[STBIR_RESIZE], non_pma_alpha_speed_over_quality: int) -> int = c.stbir_set_non_pm_alpha_speed_over_quality
|
|
37
|
+
public foreign function build_samplers(resize: ptr[STBIR_RESIZE]) -> int = c.stbir_build_samplers
|
|
38
|
+
public foreign function free_samplers(resize: ptr[STBIR_RESIZE]) -> void = c.stbir_free_samplers
|
|
39
|
+
public foreign function resize_extended(resize: ptr[STBIR_RESIZE]) -> int = c.stbir_resize_extended
|
|
40
|
+
public foreign function build_samplers_with_splits(resize: ptr[STBIR_RESIZE], try_splits: int) -> int = c.stbir_build_samplers_with_splits
|
|
41
|
+
public foreign function resize_extended_split(resize: ptr[STBIR_RESIZE], split_start: int, split_count: int) -> int = c.stbir_resize_extended_split
|