Created
December 29, 2014 10:05
-
-
Save waterlink/e00f4a5ee2940a69a1d2 to your computer and use it in GitHub Desktop.
Hello World example in ruby2cpp annotated ruby. Ready to be converted to c++.
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
# @ruby2cpp: std | |
class Hello | |
# @ruby2cpp: annotate(String -> void) | |
def initialize(greeting) | |
# @ruby2cpp: annotate(String) | |
@greeting = greeting | |
end | |
# @ruby2cpp: annotate(String -> void) | |
def greet(name) | |
puts("debug: Hello#greet :: got in") | |
puts("%s, %s!" % [@greeting, name]) | |
end | |
# @ruby2cpp: annotate(-> void) | |
def anonymous_greet | |
puts("%s!" % @greeting) | |
end | |
end | |
# @ruby2cpp: annotate(String, String -> void) | |
def greet(greeting, name) | |
# @ruby2cpp: annotate(Hello) | |
hello = Hello.new(greeting) | |
hello.greet(name) | |
# @ruby2cpp: annotate(bool) | |
done = true | |
end | |
# @ruby2cpp: annotate(-> int) | |
def main | |
# @ruby2cpp: annotate(String) | |
greeting = "Hello" | |
# @ruby2cpp: annotate(String) | |
name = "World" | |
greet(greeting, name) | |
# @ruby2cpp: annotate(int) | |
exit_code = 0 | |
end | |
# @ruby2cpp: entry_point | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment