Created
August 23, 2010 02:44
-
-
Save bdrewery/544660 to your computer and use it in GitHub Desktop.
C++ Scripting API example
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
ScriptInterpTCL tcl_script; | |
tcl_script.init(); | |
String x("54321"); | |
tcl_script.linkVar("x", x); | |
// Test Getting var from C++ | |
CPPUNIT_ASSERT_STRING_EQUAL(x, tcl_script.eval("set x")); | |
x = "test 1 2 3 4 5 "; | |
CPPUNIT_ASSERT_STRING_EQUAL(x, tcl_script.eval("set x")); | |
// Test Setting var from TCL | |
String newval("5 4 2 3 1 test"); | |
tcl_script.eval(String("set x \"") + newval + "\""); | |
CPPUNIT_ASSERT_STRING_EQUAL(newval, tcl_script.eval("set x")); | |
// Test getting a substring | |
x = newval(0, 5); | |
CPPUNIT_ASSERT_STRING_EQUAL(x, tcl_script.eval("set x")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment