chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 16 May 2019 11:40:44 +0000 (12:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 16 May 2019 11:40:44 +0000 (12:40 +0100)
.gitignore
Makefile
ffi-example-cpp.txt [new file with mode: 0644]
ffi-example.txt [new file with mode: 0644]
tour-main.fig

index 68eb0c9662c4cafaea20506fa9a1d89919e4c989..5e01ac9354b5a37c75be7b2a486c5b0f21f2c425 100644 (file)
@@ -8,6 +8,7 @@ bck-lifetimes.ps
 macros.ps
 tour-main.ps
 tour-6?.ps
+tourx-7?.ps
 *.1
 *.txt.eps
 slides.pdf
index ab7cf9aa357f88aaef4a55ee47abf3d50f025e1d..e30ab6c9e56019e1d4383e0aac3d39d51c720edd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,8 @@ SLIDES+= borrow-nonmut
 SLIDES+= tour-61
 SLIDES+= tour-62
 SLIDES+= tour-63
+SLIDES+= tourx-71
+SLIDES+= tourx-72
 
 SLIDES+= bck-lifetimes
 SLIDES+= macros
@@ -38,7 +40,11 @@ tour-main.ps: tour-example.txt.eps
 
 tour-%.ps: tour-main.fig tour-example.txt.eps Makefile
        iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1
-       LC_CTYPE=en_GB fig2dev -L ps -l dummy -z A4 -D+1:59,$*,80:99 <$@.1 $o
+       LC_CTYPE=en_GB fig2dev -L ps -l dummy -z A4 -D+1:59,$*,80:99,300:999 <$@.1 $o
+
+tourx-%.ps: tour-main.fig unsafe-example.txt.eps ffi-example.txt.eps ffi-example-cpp.txt.eps Makefile
+       iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1
+       LC_CTYPE=en_GB fig2dev -L ps -l dummy -z A4 -D+1:59,$*,80:89,91:99,300:999,1$*,2$* <$@.1 $o
 
 %.eps:   %.fig
        iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1
diff --git a/ffi-example-cpp.txt b/ffi-example-cpp.txt
new file mode 100644 (file)
index 0000000..fa78ed1
--- /dev/null
@@ -0,0 +1,5 @@
+extern "C" {
+   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
new file mode 100644 (file)
index 0000000..9632421
--- /dev/null
@@ -0,0 +1,13 @@
+#[link(name="glue")]
+extern "C" {
+    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(),
+                        ...
index 194c060dcc6a5d83753180f56eece46fea5f0526..7279814c85f5363d00c6eea1157e951f76499d2a 100644 (file)
@@ -7,12 +7,6 @@ A4
 Single
 -2
 1200 2
-6 1080 -1080 4410 1170
-4 0 0 50 -1 2 30 0.0000 4 435 2655 1080 -720 Type system\001
-4 0 0 50 -1 2 30 0.0000 4 330 1965 1260 -90 inference\001
-4 0 0 50 -1 2 30 0.0000 4 435 3105 1260 450 polymorphism\001
-4 0 0 50 -1 2 30 0.0000 4 435 2625 1530 990 ("generics")\001
--6
 2 2 0 2 1 7 61 -1 -1 0.000 0 0 -1 0 0 5
         -1530 -1170 450 -1170 450 -540 -1530 -540 -1530 -1170
 2 2 0 2 1 7 62 -1 -1 0.000 0 0 -1 0 0 5
@@ -21,9 +15,6 @@ Single
         4140 2250 4770 2250
 2 1 0 2 1 7 63 -1 -1 0.000 0 0 -1 0 0 2
         3240 2070 4140 1710
-2 5 0 1 0 -1 90 -1 -1 0.000 0 0 -1 0 0 5
-       0 tour-example.txt.eps
-        -1530 2106 9900 2106 9900 6300 -1530 6300 -1530 2106
 2 1 0 2 1 7 62 -1 -1 0.000 0 0 -1 0 0 3
         990 2700 1620 2880 990 3240
 2 1 0 2 1 7 63 -1 -1 0.000 0 0 -1 0 0 3
@@ -38,15 +29,29 @@ Single
         3690 5580 3420 4500
 2 1 0 2 1 7 62 -1 -1 0.000 0 0 -1 0 0 2
         3780 4500 3870 4860
-4 0 0 50 -1 2 30 0.0000 4 435 1335 4860 -720 Safety\001
-4 0 0 50 -1 2 30 0.0000 4 330 795 7650 -720 FFI\001
-4 0 0 50 -1 2 30 0.0000 4 435 1470 -1260 -720 Syntax\001
+2 5 0 1 0 -1 90 -1 20 0.000 0 0 -1 0 0 5
+       0 tour-example.txt.eps
+        -1530 2070 9900 2070 9900 6264 -1530 6264 -1530 2070
+2 2 0 2 1 7 71 -1 -1 0.000 0 0 -1 0 0 5
+        4680 -1170 6480 -1170 6480 990 4680 990 4680 -1170
+2 1 0 2 1 7 71 -1 -1 0.000 0 0 -1 0 0 2
+        1800 4770 2610 4410
+2 1 0 2 1 7 71 -1 -1 0.000 0 0 -1 0 0 2
+        3330 5580 3780 5850
+2 5 0 1 0 -1 171 -1 20 0.000 0 0 -1 0 0 5
+       0 unsafe-example.txt.eps
+        -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
+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
+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
 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 0 50 -1 2 27 0.0000 4 300 1260 4950 -180 unsafe\001
-4 0 0 50 -1 2 27 0.0000 4 300 1080 4950 720 hatch\001
-4 0 0 50 -1 2 27 0.0000 4 300 1245 4950 270 escape\001
-4 0 0 50 -1 2 27 0.0000 4 300 1605 7830 270 to C etc.\001
-4 0 0 50 -1 2 27 0.0000 4 390 1350 7830 -180 talking\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
 4 0 1 62 -1 1 27 0.0000 4 405 5100 1710 3870 construction of struct values\001
@@ -57,3 +62,21 @@ Single
 4 0 1 62 -1 1 27 0.0000 4 405 4500 5040 2340 definition of a struct type\001
 4 0 1 63 -1 1 27 0.0000 4 405 4905 4320 2160 there's Point<T> for any T\001
 4 0 1 62 -1 1 27 0.0000 4 405 7365 1890 2970 definition of the members and their types\001
+4 0 1 71 -1 1 27 0.0000 4 405 5280 4050 6300 bypasses array bounds check\001
+4 0 1 71 -1 1 27 0.0000 4 405 5310 3960 5850 raw pointer offset calculation\001
+4 0 1 71 -1 1 27 0.0000 4 405 6870 2700 4950 language features or library functions\001
+4 0 1 71 -1 1 27 0.0000 4 420 7035 2700 4500 required to surround any use of unsafe\001
+4 0 1 71 -1 1 27 0.0000 4 405 4755 4410 2250 unsafe code's assumptions\001
+4 0 1 71 -1 1 27 0.0000 4 390 4725 4230 1890 programmer documenting\001
+4 0 0 380 -1 2 30 0.0000 4 435 1470 -1260 -720 Syntax\001
+4 0 0 380 -1 2 30 0.0000 4 435 2655 1080 -720 Type system\001
+4 0 0 380 -1 2 30 0.0000 4 330 1965 1260 -90 inference\001
+4 0 0 380 -1 2 30 0.0000 4 435 3105 1260 450 polymorphism\001
+4 0 0 380 -1 2 30 0.0000 4 435 2625 1530 990 ("generics")\001
+4 0 0 380 -1 2 27 0.0000 4 300 1260 4950 -180 unsafe\001
+4 0 0 380 -1 2 27 0.0000 4 300 1245 4950 270 escape\001
+4 0 0 380 -1 2 27 0.0000 4 300 1080 4950 720 hatch\001
+4 0 0 380 -1 2 30 0.0000 4 435 1335 4860 -720 Safety\001
+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