Skip to content

Commit

Permalink
Update FFI signature table to use pipe format
Browse files Browse the repository at this point in the history
Rustdoc doesn't seem like it's converting the old format to a table as we can see here:
http://static.rust-lang.org/doc/master/complement-cheatsheet.html#ffi-(foreign-function-interface)
This new format should fix that and it's also rendered by Github's markdown preview.
  • Loading branch information
sodaplayer committed Apr 25, 2014
1 parent 0be4c33 commit e7ca1d1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/doc/complement-cheatsheet.md
Expand Up @@ -207,12 +207,12 @@ let _ = close(Door::<Closed>("front".to_owned())); // error: mismatched types: e

## C function signature conversions

Description C signature Equivalent Rust signature
---------------------- ---------------------------------------------- ------------------------------------------
no parameters `void foo(void);` `fn foo();`
return value `int foo(void);` `fn foo() -> c_int;`
function parameters `void foo(int x, int y);` `fn foo(x: c_int, y: c_int);`
in-out pointers `void foo(const int* in_ptr, int* out_ptr);` `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);`
| Description | C signature | Equivalent Rust signature |
|---------------------|-----------------------------------------------|------------------------------------------------|
| no parameters | `void foo(void);` | `fn foo();` |
| return value | `int foo(void);` | `fn foo() -> c_int;` |
| function parameters | `void foo(int x, int y);` | `fn foo(x: c_int, y: c_int);` |
| in-out pointers | `void foo(const int* in_ptr, int* out_ptr);` | `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);` |

Note: The Rust signatures should be wrapped in an `extern "ABI" { ... }` block.

Expand Down

5 comments on commit e7ca1d1

@bors
Copy link
Contributor

@bors bors commented on e7ca1d1 Apr 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at sodaplayer@e7ca1d1

@bors
Copy link
Contributor

@bors bors commented on e7ca1d1 Apr 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sodaplayer/rust/patch-1 = e7ca1d1 into auto

@bors
Copy link
Contributor

@bors bors commented on e7ca1d1 Apr 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sodaplayer/rust/patch-1 = e7ca1d1 merged ok, testing candidate = a5d2035

@bors
Copy link
Contributor

@bors bors commented on e7ca1d1 Apr 26, 2014

@bors
Copy link
Contributor

@bors bors commented on e7ca1d1 Apr 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = a5d2035

Please sign in to comment.