Skip to content

Commit dfd38c3

Browse files
committed
load_ext everything
1 parent b2592d0 commit dfd38c3

File tree

2 files changed

+47
-20
lines changed

2 files changed

+47
-20
lines changed

crates/byondapi-rs-test/dm_project/bindings.dm

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,78 @@
1313

1414
///Tests new
1515
/proc/test_new_obj()
16-
return call_ext(BYONDAPI_TEST, "byond:test_new_obj_ffi")()
16+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_new_obj_ffi")
17+
return call_ext(loaded)()
1718

1819
///Tests lists read
1920
/proc/test_list_read(list)
20-
return call_ext(BYONDAPI_TEST, "byond:test_list_read_ffi")(list)
21+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_list_read_ffi")
22+
return call_ext(loaded)(list)
2123

2224
///Tests non-assoc lists
2325
/proc/test_non_assoc_list(list)
24-
return call_ext(BYONDAPI_TEST, "byond:test_non_assoc_list_ffi")(list)
26+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_non_assoc_list_ffi")
27+
return call_ext(loaded)(list)
2528

2629
///Tests ref
2730
/proc/test_ref(turf)
28-
return call_ext(BYONDAPI_TEST, "byond:test_ref_ffi")(turf)
31+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_ref_ffi")
32+
return call_ext(loaded)(turf)
2933

3034
///Tests lists lookup
3135
/proc/test_list_key_lookup(list)
32-
return call_ext(BYONDAPI_TEST, "byond:test_list_key_lookup_ffi")(list)
36+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_list_key_lookup_ffi")
37+
return call_ext(loaded)(list)
3338

3439
///Tests length with strings
3540
/proc/test_length_with_str(object)
36-
return call_ext(BYONDAPI_TEST, "byond:test_length_with_str_ffi")(object)
41+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_length_with_str_ffi")
42+
return call_ext(loaded)(object)
3743

3844
///Tests block
3945
/proc/test_block()
40-
return call_ext(BYONDAPI_TEST, "byond:test_block_ffi")()
46+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_block_ffi")
47+
return call_ext(loaded)()
4148

4249
///Tests lists length
4350
/proc/test_length_with_list(list)
44-
return call_ext(BYONDAPI_TEST, "byond:test_length_with_list_ffi")(list)
51+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_length_with_list_ffi")
52+
return call_ext(loaded)(list)
4553

4654
///Tests lists popping
4755
/proc/test_list_pop(list)
48-
return call_ext(BYONDAPI_TEST, "byond:test_list_pop_ffi")(list)
56+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_list_pop_ffi")
57+
return call_ext(loaded)(list)
4958

5059
///Tests lists indexing
5160
/proc/test_list_index(list)
52-
return call_ext(BYONDAPI_TEST, "byond:test_list_index_ffi")(list)
61+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_list_index_ffi")
62+
return call_ext(loaded)(list)
5363

5464
///Tests lists
5565
/proc/test_list_double(list)
56-
return call_ext(BYONDAPI_TEST, "byond:test_list_double_ffi")(list)
66+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_list_double_ffi")
67+
return call_ext(loaded)(list)
5768

5869
///Tests list pushes
5970
/proc/test_list_push(list)
60-
return call_ext(BYONDAPI_TEST, "byond:test_list_push_ffi")(list)
71+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_list_push_ffi")
72+
return call_ext(loaded)(list)
6173

6274
///Tests readwrite vars
6375
/proc/test_readwrite_var(object)
64-
return call_ext(BYONDAPI_TEST, "byond:test_readwrite_var_ffi")(object)
76+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_readwrite_var_ffi")
77+
return call_ext(loaded)(object)
6578

6679
///Tests proccalls
6780
/proc/test_proc_call(object)
68-
return call_ext(BYONDAPI_TEST, "byond:test_proc_call_ffi")(object)
81+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_proc_call_ffi")
82+
return call_ext(loaded)(object)
6983

7084
///Tests pointers
7185
/proc/test_ptr(ptr)
72-
return call_ext(BYONDAPI_TEST, "byond:test_ptr_ffi")(ptr)
86+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_ptr_ffi")
87+
return call_ext(loaded)(ptr)
7388

7489
///Tests raw args binds
7590
/proc/test_args(...)
@@ -79,5 +94,6 @@
7994

8095
///Tests main lib connection
8196
/proc/test_connection()
82-
return call_ext(BYONDAPI_TEST, "byond:test_connection_ffi")()
97+
var/static/loaded = load_ext(BYONDAPI_TEST, "byond:test_connection_ffi")
98+
return call_ext(loaded)()
8399

crates/byondapi-rs/src/binds.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,24 @@ pub fn generate_bindings(libname: &str) {
6262
))
6363
.unwrap()
6464
} else {
65-
file.write_fmt(format_args!(
66-
r#"{docs}{path}({func_arguments_srcless})
65+
if cfg!(feature = "byond-515-1621") {
66+
file.write_fmt(format_args!(
67+
r#"{docs}{path}({func_arguments_srcless})
6768
return call_ext({libname_upper}, "byond:{func_name}")({func_arguments})
6869
6970
"#
70-
))
71-
.unwrap()
71+
))
72+
.unwrap()
73+
} else {
74+
file.write_fmt(format_args!(
75+
r#"{docs}{path}({func_arguments_srcless})
76+
var/static/loaded = load_ext({libname_upper}, "byond:{func_name}")
77+
return call_ext(loaded)({func_arguments})
78+
79+
"#
80+
))
81+
.unwrap()
82+
}
7283
}
7384
}
7485
}

0 commit comments

Comments
 (0)