From: Ian Jackson Date: Thu, 16 May 2019 11:51:10 +0000 (+0100) Subject: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=85fdffe788798a44530bb5a14ded76d4f71e10fe;p=talk-2019-ghm-rust.git wip --- diff --git a/ffi-example-cpp.txt b/ffi-example-cpp.txt index fa78ed1..9532376 100644 --- a/ffi-example-cpp.txt +++ b/ffi-example-cpp.txt @@ -1,5 +1,5 @@ extern "C" { - int cxx_chrobak_payne(const size_t nvertices, - const size_t edge_data[][2], - const size_t n_edge_data, - ... + int cxx_chrobak_payne(const size_t nvertices, + const size_t edge_data[][2], + const size_t n_edge_data, + ... diff --git a/ffi-example.txt b/ffi-example.txt index 9632421..9f89a0a 100644 --- a/ffi-example.txt +++ b/ffi-example.txt @@ -1,13 +1,14 @@ #[link(name="glue")] extern "C" { - pub fn cxx_chrobak_payne( - nvertices : size_t, - edge_data : *const [size_t; 2], - n_edge_data : size_t, + pub fn cxx_chrobak_payne( + nvertices : size_t, + edge_data : *const [size_t; 2], + n_edge_data : size_t, ... } - let ok = unsafe { - cxx_chrobak_payne(nvertices, - edges.as_ptr(), edges.len(), - ... + let ok = unsafe { + cxx_chrobak_payne(nvertices, + edges.as_ptr(), + edges.len(), + ... diff --git a/tour-main.fig b/tour-main.fig index 7279814..43b0e0e 100644 --- a/tour-main.fig +++ b/tour-main.fig @@ -43,14 +43,24 @@ Single -1530 1710 9900 1710 9900 5904 -1530 5904 -1530 1710 2 5 0 1 0 -1 172 -1 20 0.000 0 0 -1 0 0 5 0 ffi-example.txt.eps - -1440 -450 6930 -450 6930 4112 -1440 4112 -1440 -450 -2 5 0 1 0 -1 172 -1 20 0.000 0 0 -1 0 0 5 - 0 ffi-example-cpp.txt.eps - -1440 4590 7425 4590 7425 6030 -1440 6030 -1440 4590 + -1440 -1170 6212 -1170 6212 3592 -1440 3592 -1440 -1170 2 2 0 1 0 7 272 -1 20 0.000 0 0 -1 0 0 5 - -1440 -450 7020 -450 7020 4230 -1440 4230 -1440 -450 + -1530 -1260 7020 -1260 7020 3870 -1530 3870 -1530 -1260 2 2 0 1 0 7 272 -1 20 0.000 0 0 -1 0 0 5 - -1530 4500 7560 4500 7560 6120 -1530 6120 -1530 4500 + -1530 4140 9540 4140 9540 6120 -1530 6120 -1530 4140 +2 5 0 1 0 -1 172 -1 20 0.000 0 0 -1 0 0 5 + 0 ffi-example-cpp.txt.eps + -1440 4320 9356 4320 9356 5940 -1440 5940 -1440 4320 +2 1 0 2 1 7 72 -1 -1 0.000 0 0 -1 0 0 2 + 2070 450 2250 1080 +2 1 0 2 1 7 72 -1 -1 0.000 0 0 -1 0 0 2 + 2250 2070 2880 1980 +2 1 0 2 1 7 72 -1 -1 0.000 0 0 -1 0 0 3 + 3150 2610 2970 2880 3150 2880 +2 1 0 2 1 7 72 -1 -1 0.000 0 0 -1 0 0 2 + 2970 2880 3150 3150 +2 2 0 2 1 7 72 -1 -1 0.000 0 0 -1 0 0 5 + 7470 -1260 9720 -1260 9720 540 7470 540 7470 -1260 4 0 0 50 -1 2 32 0.0000 4 465 11850 -1530 -1620 Other properties of Rust - illustrated in an example\001 4 0 1 62 -1 1 27 0.0000 4 405 6480 1980 4320 by specifying values of the members\001 4 0 1 63 -1 1 27 0.0000 4 405 4680 4230 1710 struct type is polymorphic\001 @@ -80,3 +90,10 @@ Single 4 0 0 380 -1 2 30 0.0000 4 330 795 7650 -720 FFI\001 4 0 0 380 -1 2 27 0.0000 4 390 1350 7830 -180 talking\001 4 0 0 380 -1 2 27 0.0000 4 300 1605 7830 270 to C etc.\001 +4 0 0 72 -1 2 32 0.0000 4 360 1080 -1440 3690 Rust\001 +4 0 0 72 -1 2 32 0.0000 4 360 1020 -1440 6030 C++\001 +4 0 1 72 -1 1 27 0.0000 4 390 2970 1170 1440 raw pointer type\001 +4 0 1 72 -1 1 27 0.0000 4 405 2955 4230 810 array of 2 size_t\001 +4 0 1 72 -1 1 27 0.0000 4 405 5160 2970 2070 calls out of Rust are not safe\001 +4 0 1 72 -1 1 27 0.0000 4 405 2235 810 3060 types will be\001 +4 0 1 72 -1 1 27 0.0000 4 315 1425 1620 3420 checked\001