Created
July 16, 2014 21:38
-
-
Save euphoria/004005c8a6a9cb7f1183 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rustc --crate-type dylib rusty.rs | |
$ python rusty.py | |
5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cffi import FFI | |
ffi = FFI() | |
ffi.cdef(""" | |
int rusty_sum(int x, int y); | |
""") | |
rusty_lib = ffi.dlopen('librusty.so') | |
result = rusty_lib.rusty_sum(2, 3) | |
print result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn rusty_sum(x: int, y: int) -> int { | |
x + y | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment