本文整理汇总了C++中Shell::Interpreter方法的典型用法代码示例。如果您正苦于以下问题:C++ Shell::Interpreter方法的具体用法?C++ Shell::Interpreter怎么用?C++ Shell::Interpreter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shell
的用法示例。
在下文中一共展示了Shell::Interpreter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ()
{
printf ("Results of mathlib_performance test:\n");
try
{
Environment env;
Shell shell ("lua", env);
xtl::com_ptr<IInterpreter> script (shell.Interpreter ());
env.Library ("global").Register ("typename", make_invoker (&get_typename));
env.BindLibraries ("Math");
load_script (*script, SCRIPT_FILE_NAME);
printf ("Test c++ performance:\n");
size_t start_time = common::milliseconds ();
float test_result = test ();
printf ("Duration = %u ms, result = %f\n", common::milliseconds () - start_time, test_result);
printf ("Test lua performance:\n");
start_time = common::milliseconds ();
test_result = invoke<float> (*script, "test");
printf ("Duration = %u ms, result = %f\n", common::milliseconds () - start_time, test_result);
}
catch (xtl::bad_any_cast& exception)
{
printf ("%s: %s -> %s\n", exception.what (), exception.source_type ().name (), exception.target_type ().name ());
}
catch (std::exception& exception)
{
printf ("exception: %s\n", exception.what ());
}
return 0;
}
示例2: main
int main ()
{
printf ("Results of common_string_tree_test:\n");
try
{
common::LogFilter filter ("script.binds.*", &log_handler);
Environment env;
InvokerRegistry lib = env.CreateLibrary ("Utils");
lib.Register ("PrintIndent", make_invoker (&print_indent));
Shell shell ("lua", env);
xtl::com_ptr<IInterpreter> script (shell.Interpreter ());
env.BindLibraries ("Common");
load_script (*script, SCRIPT_FILE_NAME);
printf ("Test library:\n");
invoke<void> (*script, "test");
}
catch (xtl::bad_any_cast& exception)
{
printf ("%s: %s -> %s\n", exception.what (), exception.source_type ().name (), exception.target_type ().name ());
}
catch (std::exception& exception)
{
printf ("exception: %s\n", exception.what ());
}
return 0;
}