Last active
August 29, 2015 14:12
-
-
Save ymurase/d1b19b7e8fc78485b1eb to your computer and use it in GitHub Desktop.
x10でNativeのコードを呼ぶ。ミニマム実装
This file contains 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
import x10.compiler.Native; | |
public class Test { | |
@Native("c++", "printf(\"Hello world.\\n\")") | |
private static native def test2(): void; | |
// Use function parameters | |
// #0 : name of the class (Test) | |
// #1,#2,#3,...: parameters | |
@Native("c++", "printf(\"This is the number %d\\n\", (#1) )" ) | |
private static native def test3(x: Int): void; | |
public static def main(args:Rail[String]) { | |
test2(); | |
test3(30n); | |
// direct access | |
val x = 42; | |
{ | |
@Native("c++", "std::cout << x << std::endl;") {} | |
// 最後の{}がないと実行されない | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment